From 100564d41225bfd2fa163c0174557ed979285b4e Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Tue, 8 Jun 2010 06:09:57 +0000 Subject: 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(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(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") 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] --- .gitattributes | 21 +- src/emu/audit.c | 14 +- src/emu/clifront.c | 39 +- src/emu/cpu/adsp2100/adsp2100.c | 280 ++- src/emu/cpu/adsp2100/adsp2100.h | 6 +- src/emu/cpu/alph8201/alph8201.c | 9 +- src/emu/cpu/am29000/am29000.c | 13 +- src/emu/cpu/apexc/apexc.c | 11 +- src/emu/cpu/arm/arm.c | 15 +- src/emu/cpu/arm7/arm7.c | 11 +- src/emu/cpu/arm7/arm7core.c | 4 +- src/emu/cpu/arm7/arm7core.h | 2 +- src/emu/cpu/asap/asap.c | 11 +- src/emu/cpu/avr8/avr8.c | 11 +- src/emu/cpu/ccpu/ccpu.c | 15 +- src/emu/cpu/cdp1802/cdp1802.c | 182 +- src/emu/cpu/cdp1802/cdp1802.h | 2 +- src/emu/cpu/cop400/cop400.c | 213 +-- src/emu/cpu/cop400/cop400.h | 6 +- src/emu/cpu/cp1610/cp1610.c | 11 +- src/emu/cpu/cubeqcpu/cubeqcpu.c | 33 +- src/emu/cpu/drcbec.c | 2 +- src/emu/cpu/drcbex64.c | 2 +- src/emu/cpu/drcbex86.c | 2 +- src/emu/cpu/drcfe.c | 18 +- src/emu/cpu/drcuml.c | 5 +- src/emu/cpu/dsp32/dsp32.c | 11 +- src/emu/cpu/dsp56k/dsp56def.h | 5 +- src/emu/cpu/dsp56k/dsp56k.c | 8 +- src/emu/cpu/dsp56k/dsp56mem.c | 4 +- src/emu/cpu/e132xs/e132xs.c | 25 +- src/emu/cpu/esrip/esrip.c | 13 +- src/emu/cpu/f8/f8.c | 19 +- src/emu/cpu/g65816/g65816.c | 11 +- src/emu/cpu/g65816/g65816cm.h | 2 +- src/emu/cpu/g65816/g65816op.h | 12 +- src/emu/cpu/h6280/h6280.c | 25 +- src/emu/cpu/h6280/h6280.h | 2 +- src/emu/cpu/h83002/h8_16.c | 18 +- src/emu/cpu/h83002/h8_8.c | 10 +- src/emu/cpu/h83002/h8priv.h | 7 +- src/emu/cpu/hd6309/hd6309.c | 11 +- src/emu/cpu/i386/i386.c | 36 +- src/emu/cpu/i386/i386priv.h | 7 +- src/emu/cpu/i4004/i4004.c | 113 +- src/emu/cpu/i4004/i4004.h | 6 +- src/emu/cpu/i8008/i8008.c | 120 +- src/emu/cpu/i8008/i8008.h | 6 +- src/emu/cpu/i8085/i8085.c | 131 +- src/emu/cpu/i8085/i8085.h | 6 +- src/emu/cpu/i86/i286.c | 17 +- src/emu/cpu/i86/i86.c | 159 +- src/emu/cpu/i86/i86.h | 6 +- src/emu/cpu/i860/i860.c | 4 +- src/emu/cpu/i860/i860.h | 5 +- src/emu/cpu/i960/i960.c | 11 +- src/emu/cpu/jaguar/jaguar.c | 17 +- src/emu/cpu/konami/konami.c | 11 +- src/emu/cpu/lh5801/lh5801.c | 11 +- src/emu/cpu/lr35902/lr35902.c | 13 +- src/emu/cpu/m37710/m37710.c | 12 +- src/emu/cpu/m37710/m37710cm.h | 7 +- src/emu/cpu/m37710/m37710op.h | 2 +- src/emu/cpu/m6502/m4510.c | 13 +- src/emu/cpu/m6502/m6502.c | 19 +- src/emu/cpu/m6502/m6509.c | 21 +- src/emu/cpu/m6502/m65ce02.c | 13 +- src/emu/cpu/m6800/m6800.c | 57 +- src/emu/cpu/m68000/m68000.h | 6 +- src/emu/cpu/m68000/m68kcpu.c | 309 ++-- src/emu/cpu/m68000/m68kcpu.h | 3 +- src/emu/cpu/m6805/m6805.c | 19 +- src/emu/cpu/m6809/6809dasm.c | 2 +- src/emu/cpu/m6809/m6809.c | 13 +- src/emu/cpu/mb86233/mb86233.c | 11 +- src/emu/cpu/mb88xx/mb88xx.c | 23 +- src/emu/cpu/mc68hc11/mc68hc11.c | 15 +- src/emu/cpu/mcs48/mcs48.c | 145 +- src/emu/cpu/mcs48/mcs48.h | 6 +- src/emu/cpu/mcs51/mcs51.c | 17 +- src/emu/cpu/minx/minx.c | 25 +- src/emu/cpu/mips/mips3com.c | 8 +- src/emu/cpu/mips/mips3com.h | 4 +- src/emu/cpu/mips/mips3drc.c | 11 +- src/emu/cpu/mips/psx.c | 13 +- src/emu/cpu/mips/r3000.c | 13 +- src/emu/cpu/mn10200/mn10200.c | 13 +- src/emu/cpu/nec/nec.c | 17 +- src/emu/cpu/pdp1/pdp1.c | 11 +- src/emu/cpu/pdp1/tx0.c | 15 +- src/emu/cpu/pic16c5x/pic16c5x.c | 13 +- src/emu/cpu/pic16c62x/pic16c62x.c | 13 +- src/emu/cpu/powerpc/ppc.c | 26 +- src/emu/cpu/powerpc/ppccom.c | 22 +- src/emu/cpu/powerpc/ppccom.h | 4 +- src/emu/cpu/powerpc/ppcdrc.c | 15 +- src/emu/cpu/rsp/rsp.c | 11 +- src/emu/cpu/rsp/rsp.h | 2 +- src/emu/cpu/rsp/rspdrc.c | 15 +- src/emu/cpu/s2650/s2650.c | 17 +- src/emu/cpu/saturn/saturn.c | 13 +- src/emu/cpu/sc61860/sc61860.c | 11 +- src/emu/cpu/scmp/scmp.c | 93 +- src/emu/cpu/scmp/scmp.h | 6 +- src/emu/cpu/se3208/se3208.c | 15 +- src/emu/cpu/sh2/sh2.c | 2 +- src/emu/cpu/sh2/sh2comn.c | 12 +- src/emu/cpu/sh2/sh2comn.h | 4 +- src/emu/cpu/sh2/sh2drc.c | 11 +- src/emu/cpu/sh4/sh4.c | 23 +- src/emu/cpu/sh4/sh4comn.c | 5 +- src/emu/cpu/sh4/sh4comn.h | 2 +- src/emu/cpu/sharc/sharc.c | 15 +- src/emu/cpu/sm8500/sm8500.c | 29 +- src/emu/cpu/spc700/spc700.c | 11 +- src/emu/cpu/ssem/ssem.c | 9 +- src/emu/cpu/ssp1601/ssp1601.c | 11 +- src/emu/cpu/superfx/superfx.c | 13 +- src/emu/cpu/t11/t11.c | 13 +- src/emu/cpu/tlcs90/tlcs90.c | 13 +- src/emu/cpu/tlcs900/tlcs900.c | 13 +- src/emu/cpu/tms0980/tms0980.c | 19 +- src/emu/cpu/tms32010/tms32010.c | 13 +- src/emu/cpu/tms32025/tms32025.c | 15 +- src/emu/cpu/tms32031/tms32031.c | 13 +- src/emu/cpu/tms32051/tms32051.c | 13 +- src/emu/cpu/tms34010/34010gfx.c | 18 +- src/emu/cpu/tms34010/tms34010.c | 202 +-- src/emu/cpu/tms34010/tms34010.h | 8 +- src/emu/cpu/tms57002/tms57002.c | 11 +- src/emu/cpu/tms7000/tms7000.c | 13 +- src/emu/cpu/tms9900/99xxcore.h | 15 +- src/emu/cpu/unsp/unsp.c | 9 +- src/emu/cpu/upd7810/upd7810.c | 21 +- src/emu/cpu/v30mz/v30mz.c | 21 +- src/emu/cpu/v60/v60.c | 19 +- src/emu/cpu/v810/v810.c | 13 +- src/emu/cpu/vtlb.c | 23 +- src/emu/cpu/z180/z180.c | 352 ++-- src/emu/cpu/z180/z180.h | 6 +- src/emu/cpu/z180/z180op.c | 4 +- src/emu/cpu/z180/z180ops.h | 3 +- src/emu/cpu/z8/z8.c | 114 +- src/emu/cpu/z8/z8.h | 4 +- src/emu/cpu/z80/z80.c | 198 +-- src/emu/cpu/z80/z80.h | 6 +- src/emu/cpu/z80/z80daisy.c | 184 +- src/emu/cpu/z80/z80daisy.h | 97 +- src/emu/cpu/z8000/z8000.c | 29 +- src/emu/cpuexec.c | 1998 ---------------------- src/emu/cpuexec.h | 347 ---- src/emu/cpuintrf.h | 429 ----- src/emu/crsshair.c | 22 +- src/emu/crsshair.h | 8 +- src/emu/debug/debugcmd.c | 119 +- src/emu/debug/debugcmd.h | 2 +- src/emu/debug/debugcmt.c | 25 +- src/emu/debug/debugcmt.h | 14 +- src/emu/debug/debugcpu.c | 686 ++++---- src/emu/debug/debugcpu.h | 44 +- src/emu/debug/debugvw.c | 325 ++-- src/emu/debug/debugvw.h | 6 +- src/emu/debugger.h | 10 +- src/emu/debugint/debugint.c | 5 +- src/emu/deprecat.h | 8 +- src/emu/devcb.c | 108 +- src/emu/devcb.h | 24 +- src/emu/devconv.h | 72 +- src/emu/devcpu.c | 550 ++++++ src/emu/devcpu.h | 557 ++++++ src/emu/devintrf.c | 1071 ++++++++---- src/emu/devintrf.h | 785 ++++----- src/emu/devlegcy.c | 332 ++++ src/emu/devlegcy.h | 583 +++++++ src/emu/devtempl.h | 48 - src/emu/didisasm.c | 88 + src/emu/didisasm.h | 125 ++ src/emu/diexec.c | 1000 +++++++++++ src/emu/diexec.h | 519 ++++++ src/emu/dimemory.c | 368 ++++ src/emu/dimemory.h | 292 ++++ src/emu/dinvram.c | 89 + src/emu/dinvram.h | 97 ++ src/emu/disound.c | 226 +++ src/emu/disound.h | 161 ++ src/emu/distate.c | 630 +++++++ src/emu/distate.h | 229 +++ src/emu/emu.h | 13 +- src/emu/emu.mak | 10 +- src/emu/emualloc.c | 3 + src/emu/emucore.h | 181 +- src/emu/emupal.c | 11 +- src/emu/info.c | 75 +- src/emu/inptport.c | 36 +- src/emu/inptport.h | 4 +- src/emu/machine/6522via.c | 17 +- src/emu/machine/6522via.h | 5 +- src/emu/machine/6526cia.c | 29 +- src/emu/machine/6526cia.h | 10 +- src/emu/machine/6532riot.c | 20 +- src/emu/machine/6532riot.h | 5 +- src/emu/machine/6821pia.c | 8 +- src/emu/machine/6821pia.h | 19 +- src/emu/machine/6840ptm.c | 11 +- src/emu/machine/6840ptm.h | 7 +- src/emu/machine/6850acia.c | 9 +- src/emu/machine/6850acia.h | 6 +- src/emu/machine/68681.c | 14 +- src/emu/machine/68681.h | 5 +- src/emu/machine/74123.c | 8 +- src/emu/machine/74123.h | 7 +- src/emu/machine/74148.c | 7 +- src/emu/machine/74148.h | 6 +- src/emu/machine/74153.c | 7 +- src/emu/machine/74153.h | 6 +- src/emu/machine/7474.c | 7 +- src/emu/machine/7474.h | 6 +- src/emu/machine/8237dma.c | 12 +- src/emu/machine/8237dma.h | 6 +- src/emu/machine/8255ppi.c | 8 +- src/emu/machine/8255ppi.h | 6 +- src/emu/machine/8257dma.c | 10 +- src/emu/machine/8257dma.h | 6 +- src/emu/machine/adc083x.c | 34 +- src/emu/machine/adc083x.h | 16 +- src/emu/machine/adc1038.c | 10 +- src/emu/machine/adc1038.h | 11 +- src/emu/machine/adc1213x.c | 10 +- src/emu/machine/adc1213x.h | 13 +- src/emu/machine/at28c16.c | 12 +- src/emu/machine/at28c16.h | 5 +- src/emu/machine/cdp1852.c | 14 +- src/emu/machine/cdp1852.h | 7 +- src/emu/machine/ds1302.c | 6 +- src/emu/machine/ds1302.h | 7 +- src/emu/machine/ds2404.c | 7 +- src/emu/machine/ds2404.h | 5 +- src/emu/machine/eeprom.c | 750 ++++---- src/emu/machine/eeprom.h | 194 ++- src/emu/machine/f3853.c | 10 +- src/emu/machine/f3853.h | 7 +- src/emu/machine/generic.c | 108 +- src/emu/machine/i2cmemdev.c | 12 +- src/emu/machine/i2cmemdev.h | 5 +- src/emu/machine/i8243.c | 9 +- src/emu/machine/i8243.h | 5 +- src/emu/machine/i8255a.c | 8 +- src/emu/machine/i8255a.h | 6 +- src/emu/machine/idectrl.c | 18 +- src/emu/machine/idectrl.h | 6 +- src/emu/machine/ins8154.c | 7 +- src/emu/machine/ins8154.h | 7 +- src/emu/machine/ins8250.c | 18 +- src/emu/machine/ins8250.h | 22 +- src/emu/machine/k033906.c | 10 +- src/emu/machine/k033906.h | 10 +- src/emu/machine/k056230.c | 10 +- src/emu/machine/k056230.h | 10 +- src/emu/machine/laserdsc.h | 6 +- src/emu/machine/latch8.c | 8 +- src/emu/machine/latch8.h | 7 +- src/emu/machine/ldcore.c | 42 +- src/emu/machine/ldcore.h | 4 +- src/emu/machine/ldpr8210.c | 56 +- src/emu/machine/ldv1000.c | 40 +- src/emu/machine/ldvp931.c | 40 +- src/emu/machine/mb14241.c | 6 +- src/emu/machine/mb14241.h | 9 +- src/emu/machine/mb3773.c | 6 +- src/emu/machine/mb3773.h | 7 +- src/emu/machine/mb87078.c | 10 +- src/emu/machine/mb87078.h | 10 +- src/emu/machine/msm6242.c | 6 +- src/emu/machine/msm6242.h | 7 +- src/emu/machine/pci.c | 12 +- src/emu/machine/pci.h | 6 +- src/emu/machine/pd4990a.c | 6 +- src/emu/machine/pd4990a.h | 7 +- src/emu/machine/pic8259.c | 8 +- src/emu/machine/pic8259.h | 4 +- src/emu/machine/pit8253.c | 8 +- src/emu/machine/pit8253.h | 11 +- src/emu/machine/rp5h01.c | 11 +- src/emu/machine/rp5h01.h | 7 +- src/emu/machine/rtc65271.c | 7 +- src/emu/machine/rtc65271.h | 11 +- src/emu/machine/smc91c9x.c | 12 +- src/emu/machine/smc91c9x.h | 9 +- src/emu/machine/timekpr.c | 32 +- src/emu/machine/timekpr.h | 14 +- src/emu/machine/tms6100.c | 9 +- src/emu/machine/tms6100.h | 8 +- src/emu/machine/upd4701.c | 6 +- src/emu/machine/upd4701.h | 7 +- src/emu/machine/x2212.c | 11 +- src/emu/machine/x2212.h | 5 +- src/emu/machine/z80ctc.c | 781 ++++----- src/emu/machine/z80ctc.h | 176 +- src/emu/machine/z80dart.c | 1754 +++++++++---------- src/emu/machine/z80dart.h | 286 +++- src/emu/machine/z80dma.c | 1090 ++++++------ src/emu/machine/z80dma.h | 173 +- src/emu/machine/z80pio.c | 1273 +++++++------- src/emu/machine/z80pio.h | 190 ++- src/emu/machine/z80sio.c | 1227 +++++++------- src/emu/machine/z80sio.h | 185 +- src/emu/machine/z80sti.c | 956 +++++------ src/emu/machine/z80sti.h | 199 ++- src/emu/mame.c | 83 +- src/emu/mame.h | 30 +- src/emu/mconfig.c | 111 +- src/emu/mconfig.h | 167 +- src/emu/memory.c | 215 +-- src/emu/memory.h | 52 +- src/emu/profiler.c | 6 +- src/emu/profiler.h | 4 +- src/emu/render.c | 48 +- src/emu/render.h | 10 +- src/emu/rendfont.c | 7 +- src/emu/rendlay.c | 48 +- src/emu/rendutil.c | 2 +- src/emu/romload.c | 53 +- src/emu/schedule.c | 413 +++++ src/emu/schedule.h | 104 ++ src/emu/sound.c | 771 ++++----- src/emu/sound.h | 249 +-- src/emu/sound/2151intf.c | 12 +- src/emu/sound/2151intf.h | 5 +- src/emu/sound/2203intf.c | 14 +- src/emu/sound/2203intf.h | 5 +- src/emu/sound/2413intf.c | 12 +- src/emu/sound/2413intf.h | 5 +- src/emu/sound/2608intf.c | 18 +- src/emu/sound/2608intf.h | 5 +- src/emu/sound/2610intf.c | 20 +- src/emu/sound/2610intf.h | 8 +- src/emu/sound/2612intf.c | 12 +- src/emu/sound/2612intf.h | 8 +- src/emu/sound/262intf.c | 12 +- src/emu/sound/262intf.h | 5 +- src/emu/sound/3526intf.c | 12 +- src/emu/sound/3526intf.h | 5 +- src/emu/sound/3812intf.c | 12 +- src/emu/sound/3812intf.h | 5 +- src/emu/sound/8950intf.c | 14 +- src/emu/sound/8950intf.h | 5 +- src/emu/sound/aica.c | 12 +- src/emu/sound/aica.h | 5 +- src/emu/sound/astrocde.c | 8 +- src/emu/sound/astrocde.h | 5 +- src/emu/sound/ay8910.c | 34 +- src/emu/sound/ay8910.h | 29 +- src/emu/sound/beep.c | 6 +- src/emu/sound/beep.h | 5 +- src/emu/sound/bsmt2000.c | 14 +- src/emu/sound/bsmt2000.h | 5 +- src/emu/sound/c140.c | 12 +- src/emu/sound/c140.h | 5 +- src/emu/sound/c352.c | 12 +- src/emu/sound/c352.h | 5 +- src/emu/sound/c6280.c | 12 +- src/emu/sound/c6280.h | 5 +- src/emu/sound/cdda.c | 18 +- src/emu/sound/cdda.h | 7 +- src/emu/sound/cdp1863.c | 7 +- src/emu/sound/cdp1863.h | 11 +- src/emu/sound/cdp1864.c | 38 +- src/emu/sound/cdp1864.h | 8 +- src/emu/sound/cdp1869.c | 15 +- src/emu/sound/cdp1869.h | 11 +- src/emu/sound/cem3394.c | 8 +- src/emu/sound/cem3394.h | 5 +- src/emu/sound/dac.c | 8 +- src/emu/sound/dac.h | 5 +- src/emu/sound/digitalk.c | 8 +- src/emu/sound/digitalk.h | 5 +- src/emu/sound/disc_inp.c | 6 +- src/emu/sound/discrete.c | 6 +- src/emu/sound/discrete.h | 4 +- src/emu/sound/dmadac.c | 14 +- src/emu/sound/dmadac.h | 13 +- src/emu/sound/es5503.c | 12 +- src/emu/sound/es5503.h | 5 +- src/emu/sound/es5506.c | 16 +- src/emu/sound/es5506.h | 8 +- src/emu/sound/es8712.c | 10 +- src/emu/sound/es8712.h | 5 +- src/emu/sound/flt_rc.c | 8 +- src/emu/sound/flt_rc.h | 4 +- src/emu/sound/flt_vol.c | 6 +- src/emu/sound/flt_vol.h | 6 +- src/emu/sound/gaelco.c | 15 +- src/emu/sound/gaelco.h | 9 +- src/emu/sound/hc55516.c | 12 +- src/emu/sound/hc55516.h | 12 +- src/emu/sound/ics2115.c | 10 +- src/emu/sound/ics2115.h | 5 +- src/emu/sound/iremga20.c | 12 +- src/emu/sound/iremga20.h | 5 +- src/emu/sound/k005289.c | 12 +- src/emu/sound/k005289.h | 5 +- src/emu/sound/k007232.c | 18 +- src/emu/sound/k007232.h | 5 +- src/emu/sound/k051649.c | 10 +- src/emu/sound/k051649.h | 5 +- src/emu/sound/k053260.c | 16 +- src/emu/sound/k053260.h | 5 +- src/emu/sound/k054539.c | 16 +- src/emu/sound/k054539.h | 5 +- src/emu/sound/k056800.c | 9 +- src/emu/sound/k056800.h | 10 +- src/emu/sound/mos6560.c | 21 +- src/emu/sound/mos6560.h | 10 +- src/emu/sound/msm5205.c | 12 +- src/emu/sound/msm5205.h | 5 +- src/emu/sound/msm5232.c | 12 +- src/emu/sound/msm5232.h | 5 +- src/emu/sound/multipcm.c | 10 +- src/emu/sound/multipcm.h | 5 +- src/emu/sound/n63701x.c | 10 +- src/emu/sound/n63701x.h | 5 +- src/emu/sound/namco.c | 16 +- src/emu/sound/namco.h | 12 +- src/emu/sound/nes_apu.c | 16 +- src/emu/sound/nes_apu.h | 5 +- src/emu/sound/nile.c | 8 +- src/emu/sound/nile.h | 5 +- src/emu/sound/okim6258.c | 12 +- src/emu/sound/okim6258.h | 5 +- src/emu/sound/okim6295.c | 797 ++++----- src/emu/sound/okim6295.h | 192 ++- src/emu/sound/okim6376.c | 12 +- src/emu/sound/okim6376.h | 5 +- src/emu/sound/pokey.c | 20 +- src/emu/sound/pokey.h | 5 +- src/emu/sound/psx.c | 8 +- src/emu/sound/psx.h | 5 +- src/emu/sound/qsound.c | 12 +- src/emu/sound/qsound.h | 5 +- src/emu/sound/rf5c400.c | 12 +- src/emu/sound/rf5c400.h | 5 +- src/emu/sound/rf5c68.c | 10 +- src/emu/sound/rf5c68.h | 5 +- src/emu/sound/s14001a.c | 10 +- src/emu/sound/s14001a.h | 7 +- src/emu/sound/saa1099.c | 8 +- src/emu/sound/saa1099.h | 5 +- src/emu/sound/samples.c | 8 +- src/emu/sound/samples.h | 5 +- src/emu/sound/scsp.c | 14 +- src/emu/sound/scsp.h | 5 +- src/emu/sound/segapcm.c | 14 +- src/emu/sound/segapcm.h | 5 +- src/emu/sound/sid6581.c | 8 +- src/emu/sound/sid6581.h | 8 +- src/emu/sound/sn76477.c | 12 +- src/emu/sound/sn76477.h | 4 +- src/emu/sound/sn76496.c | 22 +- src/emu/sound/sn76496.h | 27 +- src/emu/sound/snkwave.c | 10 +- src/emu/sound/snkwave.h | 5 +- src/emu/sound/sp0250.c | 12 +- src/emu/sound/sp0250.h | 5 +- src/emu/sound/sp0256.c | 12 +- src/emu/sound/sp0256.h | 5 +- src/emu/sound/speaker.c | 8 +- src/emu/sound/speaker.h | 12 +- src/emu/sound/st0016.c | 8 +- src/emu/sound/st0016.h | 5 +- src/emu/sound/t6w28.c | 8 +- src/emu/sound/t6w28.h | 6 +- src/emu/sound/tiaintf.c | 10 +- src/emu/sound/tiaintf.h | 5 +- src/emu/sound/tms3615.c | 12 +- src/emu/sound/tms3615.h | 5 +- src/emu/sound/tms36xx.c | 14 +- src/emu/sound/tms36xx.h | 5 +- src/emu/sound/tms5110.c | 39 +- src/emu/sound/tms5110.h | 29 +- src/emu/sound/tms5220.c | 24 +- src/emu/sound/tms5220.h | 15 +- src/emu/sound/upd7759.c | 14 +- src/emu/sound/upd7759.h | 5 +- src/emu/sound/vlm5030.c | 14 +- src/emu/sound/vlm5030.h | 5 +- src/emu/sound/votrax.c | 6 +- src/emu/sound/votrax.h | 5 +- src/emu/sound/vrender0.c | 8 +- src/emu/sound/vrender0.h | 5 +- src/emu/sound/wave.c | 4 +- src/emu/sound/wave.h | 5 +- src/emu/sound/x1_010.c | 16 +- src/emu/sound/x1_010.h | 5 +- src/emu/sound/ymf271.c | 14 +- src/emu/sound/ymf271.h | 5 +- src/emu/sound/ymf278b.c | 14 +- src/emu/sound/ymf278b.h | 5 +- src/emu/sound/ymz280b.c | 12 +- src/emu/sound/ymz280b.h | 5 +- src/emu/sound/zsg2.c | 10 +- src/emu/sound/zsg2.h | 3 +- src/emu/streams.c | 15 +- src/emu/streams.h | 16 +- src/emu/tilemap.c | 10 +- src/emu/tilemap.h | 6 +- src/emu/timer.c | 551 +++--- src/emu/timer.h | 220 ++- src/emu/ui.c | 150 +- src/emu/uigfx.c | 15 +- src/emu/uimenu.c | 8 +- src/emu/validity.c | 616 ++----- src/emu/validity.h | 4 +- src/emu/video.c | 3388 ++++++++++++++++++------------------- src/emu/video.h | 478 ++++-- src/emu/video/generic.c | 12 +- src/emu/video/hd63484.c | 12 +- src/emu/video/hd63484.h | 11 +- src/emu/video/mc6845.c | 83 +- src/emu/video/mc6845.h | 25 +- src/emu/video/pc_vga.c | 6 +- src/emu/video/pc_video.c | 6 +- src/emu/video/s2636.c | 16 +- src/emu/video/s2636.h | 13 +- src/emu/video/saa5050.c | 10 +- src/emu/video/saa5050.h | 10 +- src/emu/video/tms34061.c | 12 +- src/emu/video/tms9927.c | 24 +- src/emu/video/tms9927.h | 16 +- src/emu/video/tms9928a.c | 8 +- src/emu/video/v9938.c | 10 +- src/emu/video/v9938.h | 2 +- src/emu/video/vector.c | 12 +- src/emu/video/vooddefs.h | 2 +- src/emu/video/voodoo.c | 46 +- src/emu/video/voodoo.h | 13 +- src/emu/watchdog.c | 8 +- src/ldplayer/ldplayer.c | 4 +- src/lib/util/astring.c | 14 +- src/lib/util/astring.h | 2 + src/mame/audio/amiga.c | 4 +- src/mame/audio/atarijsa.c | 43 +- src/mame/audio/cage.c | 36 +- src/mame/audio/cinemat.c | 18 +- src/mame/audio/cps3.c | 2 +- src/mame/audio/dcs.c | 67 +- src/mame/audio/exidy.c | 9 +- src/mame/audio/exidy440.c | 18 +- src/mame/audio/jaguar.c | 11 +- src/mame/audio/leland.c | 4 +- src/mame/audio/micro3d.c | 8 +- src/mame/audio/n8080.c | 8 +- src/mame/audio/namco52.c | 23 +- src/mame/audio/namco52.h | 5 +- src/mame/audio/namco54.c | 15 +- src/mame/audio/namco54.h | 5 +- src/mame/audio/segag80r.c | 7 +- src/mame/audio/segasnd.c | 4 +- src/mame/audio/seibu.c | 14 +- src/mame/audio/seibu.h | 19 +- src/mame/audio/senjyo.c | 9 +- src/mame/audio/snes_snd.c | 6 +- src/mame/audio/snes_snd.h | 11 +- src/mame/audio/taito_en.c | 11 +- src/mame/audio/taitosnd.c | 9 +- src/mame/audio/taitosnd.h | 9 +- src/mame/audio/tiamc1.c | 2 +- src/mame/audio/williams.c | 5 +- src/mame/drivers/1945kiii.c | 22 +- src/mame/drivers/39in1.c | 12 +- src/mame/drivers/3super8.c | 3 +- src/mame/drivers/5clown.c | 3 +- src/mame/drivers/acefruit.c | 6 +- src/mame/drivers/acommand.c | 12 +- src/mame/drivers/actfancr.c | 6 +- src/mame/drivers/adp.c | 8 +- src/mame/drivers/aerofgt.c | 23 +- src/mame/drivers/airbustr.c | 3 +- src/mame/drivers/alg.c | 14 +- src/mame/drivers/aquarium.c | 3 +- src/mame/drivers/arcadecl.c | 12 +- src/mame/drivers/artmagic.c | 8 +- src/mame/drivers/astinvad.c | 4 +- src/mame/drivers/astrocde.c | 2 +- src/mame/drivers/astrocorp.c | 16 +- src/mame/drivers/astrof.c | 10 +- src/mame/drivers/atarig1.c | 2 +- src/mame/drivers/atarig42.c | 2 +- src/mame/drivers/atarigt.c | 2 +- src/mame/drivers/atarigx2.c | 2 +- src/mame/drivers/atarisy1.c | 7 +- src/mame/drivers/atarisy2.c | 10 +- src/mame/drivers/atetris.c | 4 +- src/mame/drivers/backfire.c | 2 +- src/mame/drivers/badlands.c | 14 +- src/mame/drivers/batman.c | 10 +- src/mame/drivers/beaminv.c | 6 +- src/mame/drivers/beathead.c | 13 +- src/mame/drivers/berzerk.c | 10 +- src/mame/drivers/bestleag.c | 6 +- src/mame/drivers/big10.c | 2 +- src/mame/drivers/bigstrkb.c | 6 +- src/mame/drivers/bingor.c | 8 +- src/mame/drivers/bishjan.c | 12 +- src/mame/drivers/blackt96.c | 8 +- src/mame/drivers/blmbycar.c | 6 +- src/mame/drivers/blockout.c | 3 +- src/mame/drivers/blstroid.c | 6 +- src/mame/drivers/bmcbowl.c | 3 +- src/mame/drivers/boogwing.c | 23 +- src/mame/drivers/boxer.c | 10 +- src/mame/drivers/btime.c | 4 +- src/mame/drivers/calchase.c | 2 +- src/mame/drivers/capbowl.c | 6 +- src/mame/drivers/cardline.c | 3 +- src/mame/drivers/cave.c | 35 +- src/mame/drivers/cball.c | 4 +- src/mame/drivers/cbasebal.c | 3 +- src/mame/drivers/cbuster.c | 6 +- src/mame/drivers/ccastles.c | 8 +- src/mame/drivers/cchasm.c | 2 +- src/mame/drivers/centiped.c | 4 +- src/mame/drivers/changela.c | 6 +- src/mame/drivers/chinagat.c | 9 +- src/mame/drivers/cinemat.c | 4 +- src/mame/drivers/cischeat.c | 27 +- src/mame/drivers/cliffhgr.c | 4 +- src/mame/drivers/cloud9.c | 8 +- src/mame/drivers/clshroad.c | 2 +- src/mame/drivers/cninja.c | 53 +- src/mame/drivers/coolpool.c | 9 +- src/mame/drivers/coolridr.c | 4 +- src/mame/drivers/cosmic.c | 2 +- src/mame/drivers/cps1.c | 13 +- src/mame/drivers/cps2.c | 9 +- src/mame/drivers/cps3.c | 12 +- src/mame/drivers/crospang.c | 6 +- src/mame/drivers/crystal.c | 2 +- src/mame/drivers/cubeqst.c | 4 +- src/mame/drivers/cultures.c | 3 +- src/mame/drivers/cyberbal.c | 4 +- src/mame/drivers/cybertnk.c | 8 +- src/mame/drivers/darkhors.c | 3 +- src/mame/drivers/darkseal.c | 6 +- src/mame/drivers/dassault.c | 21 +- src/mame/drivers/dblewing.c | 5 +- src/mame/drivers/dbz.c | 3 +- src/mame/drivers/ddealer.c | 12 +- src/mame/drivers/ddenlovr.c | 75 +- src/mame/drivers/ddragon.c | 9 +- src/mame/drivers/ddragon3.c | 12 +- src/mame/drivers/dec0.c | 27 +- src/mame/drivers/deco156.c | 27 +- src/mame/drivers/deco32.c | 68 +- src/mame/drivers/deco_mlc.c | 18 +- src/mame/drivers/deniam.c | 16 +- src/mame/drivers/destroyr.c | 8 +- src/mame/drivers/dietgo.c | 3 +- src/mame/drivers/diverboy.c | 8 +- src/mame/drivers/djboy.c | 6 +- src/mame/drivers/dlair.c | 12 +- src/mame/drivers/dooyong.c | 6 +- src/mame/drivers/dorachan.c | 2 +- src/mame/drivers/dotrikun.c | 2 +- src/mame/drivers/dragrace.c | 8 +- src/mame/drivers/dreamwld.c | 6 +- src/mame/drivers/drgnmst.c | 13 +- src/mame/drivers/drtomy.c | 6 +- src/mame/drivers/dunhuang.c | 5 +- src/mame/drivers/dynax.c | 4 +- src/mame/drivers/egghunt.c | 6 +- src/mame/drivers/enigma2.c | 20 +- src/mame/drivers/eolith.c | 6 +- src/mame/drivers/eolith16.c | 3 +- src/mame/drivers/eprom.c | 2 +- src/mame/drivers/esd16.c | 3 +- src/mame/drivers/esripsys.c | 8 +- src/mame/drivers/expro02.c | 3 +- src/mame/drivers/exprraid.c | 1 - src/mame/drivers/exterm.c | 5 +- src/mame/drivers/f-32.c | 3 +- src/mame/drivers/f1gp.c | 3 +- src/mame/drivers/fantland.c | 2 +- src/mame/drivers/fcrash.c | 3 +- src/mame/drivers/feversoc.c | 6 +- src/mame/drivers/fgoal.c | 8 +- src/mame/drivers/firebeat.c | 8 +- src/mame/drivers/firefox.c | 8 +- src/mame/drivers/firetrk.c | 6 +- src/mame/drivers/fitfight.c | 6 +- src/mame/drivers/flyball.c | 8 +- src/mame/drivers/foodf.c | 7 +- src/mame/drivers/funkyjet.c | 3 +- src/mame/drivers/funworld.c | 4 + src/mame/drivers/funybubl.c | 6 +- src/mame/drivers/fuukifg2.c | 28 +- src/mame/drivers/fuukifg3.c | 22 +- src/mame/drivers/gaelco.c | 12 +- src/mame/drivers/gaelco3d.c | 28 +- src/mame/drivers/gaiden.c | 9 +- src/mame/drivers/galaga.c | 4 +- src/mame/drivers/galaxi.c | 7 +- src/mame/drivers/galaxian.c | 2 +- src/mame/drivers/galpani2.c | 9 +- src/mame/drivers/galpanic.c | 27 +- src/mame/drivers/galspnbl.c | 3 +- src/mame/drivers/gameplan.c | 3 +- src/mame/drivers/gauntlet.c | 8 +- src/mame/drivers/gcpinbal.c | 9 +- src/mame/drivers/ghosteo.c | 4 +- src/mame/drivers/glass.c | 3 +- src/mame/drivers/go2000.c | 4 +- src/mame/drivers/goldstar.c | 15 +- src/mame/drivers/good.c | 3 +- src/mame/drivers/gotcha.c | 6 +- src/mame/drivers/gottlieb.c | 6 +- src/mame/drivers/grchamp.c | 2 +- src/mame/drivers/gridlee.c | 14 +- src/mame/drivers/gstream.c | 21 +- src/mame/drivers/gumbo.c | 3 +- src/mame/drivers/gunpey.c | 5 +- src/mame/drivers/halleys.c | 3 +- src/mame/drivers/harddriv.c | 30 +- src/mame/drivers/hexion.c | 3 +- src/mame/drivers/highvdeo.c | 10 +- src/mame/drivers/hitme.c | 2 +- src/mame/drivers/hng64.c | 4 +- src/mame/drivers/homedata.c | 7 +- src/mame/drivers/homerun.c | 2 +- src/mame/drivers/hyprduel.c | 6 +- src/mame/drivers/igs009.c | 11 +- src/mame/drivers/igs011.c | 18 +- src/mame/drivers/igs017.c | 22 +- src/mame/drivers/igspoker.c | 5 +- src/mame/drivers/ilpag.c | 20 +- src/mame/drivers/itech32.c | 8 +- src/mame/drivers/itech8.c | 22 +- src/mame/drivers/itgambl2.c | 2 +- src/mame/drivers/itgambl3.c | 5 +- src/mame/drivers/itgamble.c | 15 +- src/mame/drivers/jackie.c | 8 +- src/mame/drivers/jackpool.c | 3 +- src/mame/drivers/jalmah.c | 11 +- src/mame/drivers/janshi.c | 3 +- src/mame/drivers/jantotsu.c | 2 +- src/mame/drivers/jedi.c | 4 +- src/mame/drivers/jpmimpct.c | 5 +- src/mame/drivers/kaneko16.c | 42 +- src/mame/drivers/kangaroo.c | 2 +- src/mame/drivers/kickgoal.c | 66 +- src/mame/drivers/kingdrby.c | 9 +- src/mame/drivers/klax.c | 11 +- src/mame/drivers/koftball.c | 3 +- src/mame/drivers/konamigx.c | 5 +- src/mame/drivers/laserbas.c | 2 +- src/mame/drivers/lastduel.c | 3 +- src/mame/drivers/lastfght.c | 2 +- src/mame/drivers/legionna.c | 9 +- src/mame/drivers/lemmings.c | 3 +- src/mame/drivers/lethalj.c | 9 +- src/mame/drivers/limenko.c | 3 +- src/mame/drivers/lordgun.c | 11 +- src/mame/drivers/luckgrln.c | 18 +- src/mame/drivers/m10.c | 20 +- src/mame/drivers/m107.c | 15 +- src/mame/drivers/m62.c | 9 +- src/mame/drivers/m72.c | 14 +- src/mame/drivers/m92.c | 15 +- src/mame/drivers/madmotor.c | 6 +- src/mame/drivers/magic10.c | 3 +- src/mame/drivers/magicard.c | 12 +- src/mame/drivers/magmax.c | 4 +- src/mame/drivers/malzak.c | 2 +- src/mame/drivers/marinedt.c | 8 +- src/mame/drivers/mario.c | 5 +- src/mame/drivers/maxaflex.c | 8 +- src/mame/drivers/mazerbla.c | 8 +- src/mame/drivers/mcr3.c | 2 +- src/mame/drivers/meadows.c | 6 +- src/mame/drivers/mediagx.c | 35 +- src/mame/drivers/megadriv.c | 84 +- src/mame/drivers/megasys1.c | 22 +- src/mame/drivers/merit.c | 4 +- src/mame/drivers/meritm.c | 10 +- src/mame/drivers/metro.c | 61 +- src/mame/drivers/mgolf.c | 4 +- src/mame/drivers/midvunit.c | 14 +- src/mame/drivers/midyunit.c | 14 +- src/mame/drivers/midzeus.c | 18 +- src/mame/drivers/mil4000.c | 3 +- src/mame/drivers/mirage.c | 32 +- src/mame/drivers/missb2.c | 3 +- src/mame/drivers/missile.c | 12 +- src/mame/drivers/mitchell.c | 20 +- src/mame/drivers/mjkjidai.c | 16 +- src/mame/drivers/mjsister.c | 4 +- src/mame/drivers/model2.c | 24 +- src/mame/drivers/model3.c | 2 +- src/mame/drivers/mogura.c | 12 +- src/mame/drivers/moo.c | 5 +- src/mame/drivers/mpu4.c | 2 +- src/mame/drivers/mugsmash.c | 3 +- src/mame/drivers/multfish.c | 2 +- src/mame/drivers/mw8080bw.c | 2 +- src/mame/drivers/mwarr.c | 8 +- src/mame/drivers/n8080.c | 4 +- src/mame/drivers/namcofl.c | 14 +- src/mame/drivers/namcona1.c | 4 +- src/mame/drivers/namconb1.c | 8 +- src/mame/drivers/namcos23.c | 8 +- src/mame/drivers/nbmj9195.c | 4 +- src/mame/drivers/neogeo.c | 16 +- src/mame/drivers/news.c | 3 +- src/mame/drivers/ninjaw.c | 2 +- src/mame/drivers/niyanpai.c | 2 +- src/mame/drivers/nmg5.c | 5 +- src/mame/drivers/nmk16.c | 126 +- src/mame/drivers/norautp.c | 5 + src/mame/drivers/nyny.c | 2 +- src/mame/drivers/offtwall.c | 6 +- src/mame/drivers/ohmygod.c | 3 +- src/mame/drivers/oneshot.c | 5 +- src/mame/drivers/onetwo.c | 3 +- src/mame/drivers/orbit.c | 4 +- src/mame/drivers/othldrby.c | 5 +- src/mame/drivers/paradise.c | 8 +- src/mame/drivers/pasha2.c | 8 +- src/mame/drivers/pass.c | 3 +- src/mame/drivers/pcat_dyn.c | 4 +- src/mame/drivers/pcat_nit.c | 6 - src/mame/drivers/pcxt.c | 12 +- src/mame/drivers/peplus.c | 8 +- src/mame/drivers/pgm.c | 2 +- src/mame/drivers/phoenix.c | 1 + src/mame/drivers/photoply.c | 4 +- src/mame/drivers/pipeline.c | 2 +- src/mame/drivers/pirates.c | 8 +- src/mame/drivers/pkscram.c | 13 +- src/mame/drivers/pktgaldx.c | 14 +- src/mame/drivers/playmark.c | 17 +- src/mame/drivers/pokechmp.c | 3 +- src/mame/drivers/polepos.c | 2 +- src/mame/drivers/policetr.c | 2 +- src/mame/drivers/polyplay.c | 10 +- src/mame/drivers/powerbal.c | 8 +- src/mame/drivers/powerins.c | 9 +- src/mame/drivers/psikyo.c | 3 +- src/mame/drivers/puckpkmn.c | 3 +- src/mame/drivers/pzletime.c | 9 +- src/mame/drivers/quizdna.c | 3 +- src/mame/drivers/quizpani.c | 3 +- src/mame/drivers/rabbit.c | 2 +- src/mame/drivers/raiden2.c | 3 +- src/mame/drivers/rampart.c | 9 +- src/mame/drivers/rbmk.c | 3 +- src/mame/drivers/redalert.c | 2 +- src/mame/drivers/relief.c | 16 +- src/mame/drivers/renegade.c | 12 +- src/mame/drivers/rohga.c | 48 +- src/mame/drivers/rotaryf.c | 2 +- src/mame/drivers/royalmah.c | 15 +- src/mame/drivers/runaway.c | 4 +- src/mame/drivers/sandscrp.c | 3 +- src/mame/drivers/sangho.c | 2 +- src/mame/drivers/sbowling.c | 4 +- src/mame/drivers/sbrkout.c | 18 +- src/mame/drivers/scramble.c | 3 +- src/mame/drivers/sderby.c | 9 +- src/mame/drivers/seattle.c | 24 +- src/mame/drivers/segac2.c | 6 +- src/mame/drivers/segahang.c | 12 +- src/mame/drivers/segamsys.c | 4 +- src/mame/drivers/segaorun.c | 6 +- src/mame/drivers/segas16b.c | 2 +- src/mame/drivers/segas24.c | 22 +- src/mame/drivers/segas32.c | 20 +- src/mame/drivers/segaxbd.c | 4 +- src/mame/drivers/segaybd.c | 9 +- src/mame/drivers/seibuspi.c | 16 +- src/mame/drivers/seta.c | 9 +- src/mame/drivers/seta2.c | 4 +- src/mame/drivers/sfbonus.c | 9 +- src/mame/drivers/sfkick.c | 2 +- src/mame/drivers/shadfrce.c | 19 +- src/mame/drivers/shangha3.c | 13 +- src/mame/drivers/shuuz.c | 11 +- src/mame/drivers/silkroad.c | 8 +- src/mame/drivers/simpl156.c | 23 +- src/mame/drivers/skeetsht.c | 4 +- src/mame/drivers/skimaxx.c | 14 +- src/mame/drivers/skullxbo.c | 18 +- src/mame/drivers/sliver.c | 7 +- src/mame/drivers/slotcarn.c | 4 +- src/mame/drivers/sms.c | 2 +- src/mame/drivers/snk6502.c | 4 +- src/mame/drivers/snookr10.c | 3 +- src/mame/drivers/snowbros.c | 32 +- src/mame/drivers/sothello.c | 2 +- src/mame/drivers/spacefb.c | 6 +- src/mame/drivers/spbactn.c | 3 +- src/mame/drivers/speedspn.c | 5 +- src/mame/drivers/spoker.c | 5 +- src/mame/drivers/spool99.c | 3 +- src/mame/drivers/sprint2.c | 6 +- src/mame/drivers/sprint4.c | 4 +- src/mame/drivers/sprint8.c | 2 +- src/mame/drivers/srmp5.c | 4 +- src/mame/drivers/sshangha.c | 3 +- src/mame/drivers/sslam.c | 20 +- src/mame/drivers/stadhero.c | 3 +- src/mame/drivers/stlforce.c | 8 +- src/mame/drivers/stv.c | 78 +- src/mame/drivers/subsino.c | 6 +- src/mame/drivers/suna8.c | 2 +- src/mame/drivers/supbtime.c | 6 +- src/mame/drivers/suprnova.c | 2 +- src/mame/drivers/system1.c | 4 +- src/mame/drivers/taito_b.c | 6 +- src/mame/drivers/taito_f2.c | 9 +- src/mame/drivers/taito_f3.c | 3 +- src/mame/drivers/taito_l.c | 2 +- src/mame/drivers/targeth.c | 3 +- src/mame/drivers/tatsumi.c | 12 +- src/mame/drivers/tecmo.c | 6 +- src/mame/drivers/tecmo16.c | 3 +- src/mame/drivers/tecmosys.c | 5 +- src/mame/drivers/tetrisp2.c | 3 +- src/mame/drivers/tgtpanic.c | 2 +- src/mame/drivers/thoop2.c | 3 +- src/mame/drivers/thunderj.c | 8 +- src/mame/drivers/tickee.c | 38 +- src/mame/drivers/tmaster.c | 13 +- src/mame/drivers/tmnt.c | 3 +- src/mame/drivers/toaplan1.c | 4 +- src/mame/drivers/toaplan2.c | 66 +- src/mame/drivers/tomcat.c | 2 +- src/mame/drivers/toobin.c | 4 +- src/mame/drivers/tubep.c | 16 +- src/mame/drivers/tugboat.c | 4 +- src/mame/drivers/tumbleb.c | 24 +- src/mame/drivers/tumblep.c | 3 +- src/mame/drivers/turbo.c | 4 +- src/mame/drivers/twincobr.c | 2 +- src/mame/drivers/ultraman.c | 3 +- src/mame/drivers/ultratnk.c | 4 +- src/mame/drivers/unico.c | 22 +- src/mame/drivers/vamphalf.c | 32 +- src/mame/drivers/vaportra.c | 6 +- src/mame/drivers/vball.c | 11 +- src/mame/drivers/vegas.c | 30 +- src/mame/drivers/vicdual.c | 12 +- src/mame/drivers/videopin.c | 6 +- src/mame/drivers/videopkr.c | 11 +- src/mame/drivers/vindictr.c | 2 +- src/mame/drivers/vmetal.c | 3 +- src/mame/drivers/wheelfir.c | 40 +- src/mame/drivers/wolfpack.c | 6 +- src/mame/drivers/wrally.c | 3 +- src/mame/drivers/wwfsstar.c | 13 +- src/mame/drivers/wwfwfest.c | 13 +- src/mame/drivers/xain.c | 8 +- src/mame/drivers/xexex.c | 2 +- src/mame/drivers/xtheball.c | 2 +- src/mame/drivers/yunsun16.c | 6 +- src/mame/drivers/zerozone.c | 3 +- src/mame/drivers/zn.c | 2 +- src/mame/includes/amiga.h | 9 +- src/mame/includes/artmagic.h | 2 +- src/mame/includes/atarig1.h | 2 +- src/mame/includes/atarig42.h | 2 +- src/mame/includes/atarigt.h | 2 +- src/mame/includes/atarigx2.h | 2 +- src/mame/includes/atarisy1.h | 14 +- src/mame/includes/balsente.h | 21 +- src/mame/includes/batman.h | 2 +- src/mame/includes/blstroid.h | 2 +- src/mame/includes/boogwing.h | 20 +- src/mame/includes/btoads.h | 2 +- src/mame/includes/bzone.h | 5 +- src/mame/includes/cninja.h | 20 +- src/mame/includes/cps3.h | 5 +- src/mame/includes/cyberbal.h | 2 +- src/mame/includes/dassault.h | 20 +- src/mame/includes/drgnmst.h | 10 +- src/mame/includes/dynax.h | 4 +- src/mame/includes/eprom.h | 2 +- src/mame/includes/exidy.h | 5 +- src/mame/includes/exterm.h | 2 +- src/mame/includes/flower.h | 5 +- src/mame/includes/gaelco3d.h | 2 +- src/mame/includes/gcpinbal.h | 14 +- src/mame/includes/gomoku.h | 5 +- src/mame/includes/gridlee.h | 5 +- src/mame/includes/harddriv.h | 33 +- src/mame/includes/jpmimpct.h | 2 +- src/mame/includes/kickgoal.h | 11 +- src/mame/includes/leland.h | 13 +- src/mame/includes/lethalj.h | 2 +- src/mame/includes/mcr.h | 4 +- src/mame/includes/metro.h | 21 +- src/mame/includes/micro3d.h | 7 +- src/mame/includes/midtunit.h | 4 +- src/mame/includes/midyunit.h | 2 +- src/mame/includes/mitchell.h | 10 +- src/mame/includes/naomibd.h | 14 +- src/mame/includes/phoenix.h | 15 +- src/mame/includes/polepos.h | 4 +- src/mame/includes/rohga.h | 20 +- src/mame/includes/segas16.h | 5 +- src/mame/includes/senjyo.h | 2 +- src/mame/includes/simpl156.h | 18 +- src/mame/includes/snes.h | 1 + src/mame/includes/snk6502.h | 4 +- src/mame/includes/taito_f2.h | 7 +- src/mame/includes/tiamc1.h | 5 +- src/mame/includes/tx1.h | 10 +- src/mame/includes/vindictr.h | 2 +- src/mame/includes/warpwarp.h | 10 +- src/mame/includes/wiping.h | 5 +- src/mame/machine/amiga.c | 16 +- src/mame/machine/archimds.c | 4 +- src/mame/machine/atari_vg.c | 6 +- src/mame/machine/atari_vg.h | 5 +- src/mame/machine/atarigen.c | 91 +- src/mame/machine/atarigen.h | 18 +- src/mame/machine/balsente.c | 70 +- src/mame/machine/dc.c | 4 +- src/mame/machine/decocass.c | 22 +- src/mame/machine/decocass.h | 5 +- src/mame/machine/fddebug.c | 4 +- src/mame/machine/galaxold.c | 13 +- src/mame/machine/harddriv.c | 19 +- src/mame/machine/irobot.c | 22 +- src/mame/machine/leland.c | 12 +- src/mame/machine/mathbox.c | 6 +- src/mame/machine/mathbox.h | 5 +- src/mame/machine/mcr.c | 8 +- src/mame/machine/mhavoc.c | 4 +- src/mame/machine/mw8080bw.c | 6 +- src/mame/machine/n64.c | 14 +- src/mame/machine/namco06.c | 9 +- src/mame/machine/namco06.h | 5 +- src/mame/machine/namco50.c | 13 +- src/mame/machine/namco50.h | 5 +- src/mame/machine/namco51.c | 11 +- src/mame/machine/namco51.h | 6 +- src/mame/machine/namco53.c | 15 +- src/mame/machine/namco53.h | 6 +- src/mame/machine/namcoio.c | 9 +- src/mame/machine/namcoio.h | 14 +- src/mame/machine/namcos2.c | 6 +- src/mame/machine/naomibd.c | 121 +- src/mame/machine/nitedrvr.c | 10 +- src/mame/machine/nmk112.c | 9 +- src/mame/machine/nmk112.h | 12 +- src/mame/machine/segaic16.c | 28 +- src/mame/machine/segaic16.h | 18 +- src/mame/machine/seicop.c | 4 +- src/mame/machine/snes.c | 30 +- src/mame/machine/stvcd.c | 14 +- src/mame/machine/taitoio.c | 30 +- src/mame/machine/taitoio.h | 18 +- src/mame/machine/ticket.c | 9 +- src/mame/machine/ticket.h | 7 +- src/mame/machine/williams.c | 60 +- src/mame/machine/xevious.c | 18 +- src/mame/video/40love.c | 4 +- src/mame/video/actfancr.c | 4 +- src/mame/video/airbustr.c | 2 +- src/mame/video/amiga.c | 10 +- src/mame/video/amigaaga.c | 10 +- src/mame/video/amspdwy.c | 4 +- src/mame/video/angelkds.c | 10 +- src/mame/video/argus.c | 16 +- src/mame/video/artmagic.c | 2 +- src/mame/video/astrocde.c | 20 +- src/mame/video/atari.c | 12 +- src/mame/video/atarig1.c | 14 +- src/mame/video/atarig42.c | 14 +- src/mame/video/atarigt.c | 16 +- src/mame/video/atarigx2.c | 14 +- src/mame/video/atarimo.c | 20 +- src/mame/video/atarirle.c | 38 +- src/mame/video/atarisy1.c | 39 +- src/mame/video/atarisy2.c | 10 +- src/mame/video/avgdvg.c | 16 +- src/mame/video/aztarac.c | 10 +- src/mame/video/badlands.c | 2 +- src/mame/video/balsente.c | 6 +- src/mame/video/batman.c | 18 +- src/mame/video/battlera.c | 8 +- src/mame/video/beathead.c | 4 +- src/mame/video/bfm_dm01.c | 6 +- src/mame/video/bigevglf.c | 8 +- src/mame/video/bishi.c | 2 +- src/mame/video/bking.c | 4 +- src/mame/video/blockade.c | 2 +- src/mame/video/blockout.c | 6 +- src/mame/video/blstroid.c | 16 +- src/mame/video/boogwing.c | 2 +- src/mame/video/btime.c | 2 +- src/mame/video/btoads.c | 14 +- src/mame/video/buggychl.c | 4 +- src/mame/video/bwing.c | 2 +- src/mame/video/carpolo.c | 2 +- src/mame/video/cave.c | 28 +- src/mame/video/cbuster.c | 2 +- src/mame/video/ccastles.c | 4 +- src/mame/video/cchasm.c | 6 +- src/mame/video/changela.c | 12 +- src/mame/video/cheekyms.c | 4 +- src/mame/video/cinemat.c | 10 +- src/mame/video/cloak.c | 2 +- src/mame/video/cloud9.c | 2 +- src/mame/video/cninja.c | 8 +- src/mame/video/contra.c | 4 +- src/mame/video/cosmic.c | 10 +- src/mame/video/cps1.c | 6 +- src/mame/video/crospang.c | 2 +- src/mame/video/cvs.c | 6 +- src/mame/video/cyberbal.c | 40 +- src/mame/video/darkseal.c | 2 +- src/mame/video/dassault.c | 2 +- src/mame/video/dc.c | 32 +- src/mame/video/dcheese.c | 12 +- src/mame/video/dday.c | 2 +- src/mame/video/dec0.c | 2 +- src/mame/video/dec8.c | 2 +- src/mame/video/deco16ic.c | 22 +- src/mame/video/deco16ic.h | 14 +- src/mame/video/deco32.c | 14 +- src/mame/video/deco_mlc.c | 2 +- src/mame/video/decocass.c | 4 +- src/mame/video/dietgo.c | 2 +- src/mame/video/dkong.c | 16 +- src/mame/video/dogfgt.c | 2 +- src/mame/video/eprom.c | 4 +- src/mame/video/equites.c | 2 +- src/mame/video/esd16.c | 12 +- src/mame/video/esripsys.c | 12 +- src/mame/video/exerion.c | 10 +- src/mame/video/exidy.c | 8 +- src/mame/video/exidy440.c | 24 +- src/mame/video/exterm.c | 4 +- src/mame/video/fantland.c | 4 +- src/mame/video/fastlane.c | 4 +- src/mame/video/fgoal.c | 4 +- src/mame/video/finalizr.c | 6 +- src/mame/video/firetrk.c | 18 +- src/mame/video/flkatck.c | 10 +- src/mame/video/fromance.c | 38 +- src/mame/video/funkyjet.c | 2 +- src/mame/video/fuukifg2.c | 20 +- src/mame/video/fuukifg3.c | 28 +- src/mame/video/gaelco2.c | 4 +- src/mame/video/gaelco3d.c | 30 +- src/mame/video/gaiden.c | 12 +- src/mame/video/galastrm.c | 8 +- src/mame/video/galaxian.c | 26 +- src/mame/video/galaxold.c | 4 +- src/mame/video/galpanic.c | 4 +- src/mame/video/galspnbl.c | 2 +- src/mame/video/gameplan.c | 6 +- src/mame/video/gaplus.c | 12 +- src/mame/video/gauntlet.c | 4 +- src/mame/video/genesis.c | 28 +- src/mame/video/glass.c | 2 +- src/mame/video/gomoku.c | 2 +- src/mame/video/gottlieb.c | 2 +- src/mame/video/grchamp.c | 4 +- src/mame/video/gridlee.c | 2 +- src/mame/video/gstriker.c | 4 +- src/mame/video/gtia.c | 2 +- src/mame/video/gticlub.c | 48 +- src/mame/video/gyruss.c | 6 +- src/mame/video/harddriv.c | 16 +- src/mame/video/hng64.c | 34 +- src/mame/video/homedata.c | 12 +- src/mame/video/homerun.c | 2 +- src/mame/video/hyhoo.c | 2 +- src/mame/video/hyprduel.c | 8 +- src/mame/video/ikki.c | 2 +- src/mame/video/irobot.c | 8 +- src/mame/video/itech32.c | 10 +- src/mame/video/itech8.c | 12 +- src/mame/video/jaguar.c | 30 +- src/mame/video/jpmimpct.c | 6 +- src/mame/video/kan_pand.c | 20 +- src/mame/video/kan_pand.h | 11 +- src/mame/video/kaneko16.c | 26 +- src/mame/video/karnov.c | 4 +- src/mame/video/kncljoe.c | 10 +- src/mame/video/konamigx.c | 34 +- src/mame/video/konamiic.c | 18 +- src/mame/video/konicdev.c | 287 ++-- src/mame/video/konicdev.h | 104 +- src/mame/video/labyrunr.c | 4 +- src/mame/video/leland.c | 14 +- src/mame/video/lemmings.c | 4 +- src/mame/video/lethalj.c | 10 +- src/mame/video/liberatr.c | 2 +- src/mame/video/lockon.c | 4 +- src/mame/video/lordgun.c | 14 +- src/mame/video/m52.c | 6 +- src/mame/video/m58.c | 26 +- src/mame/video/madalien.c | 2 +- src/mame/video/madmotor.c | 2 +- src/mame/video/magmax.c | 2 +- src/mame/video/mappy.c | 2 +- src/mame/video/matmania.c | 6 +- src/mame/video/mcr68.c | 2 +- src/mame/video/meadows.c | 2 +- src/mame/video/megazone.c | 2 +- src/mame/video/mermaid.c | 54 +- src/mame/video/metro.c | 8 +- src/mame/video/micro3d.c | 4 +- src/mame/video/midtunit.c | 4 +- src/mame/video/midvunit.c | 14 +- src/mame/video/midyunit.c | 8 +- src/mame/video/midzeus.c | 18 +- src/mame/video/midzeus2.c | 14 +- src/mame/video/mitchell.c | 4 +- src/mame/video/model1.c | 2 +- src/mame/video/model2.c | 13 +- src/mame/video/model3.c | 6 +- src/mame/video/moo.c | 2 +- src/mame/video/mrflea.c | 2 +- src/mame/video/ms32.c | 8 +- src/mame/video/munchmo.c | 2 +- src/mame/video/mustache.c | 8 +- src/mame/video/mystston.c | 4 +- src/mame/video/n8080.c | 6 +- src/mame/video/naughtyb.c | 2 +- src/mame/video/nbmj8688.c | 2 +- src/mame/video/nbmj8891.c | 28 +- src/mame/video/nbmj8900.c | 12 +- src/mame/video/nbmj8991.c | 22 +- src/mame/video/nbmj9195.c | 36 +- src/mame/video/neogeo.c | 12 +- src/mame/video/ninjakd2.c | 2 +- src/mame/video/niyanpai.c | 22 +- src/mame/video/nmk16.c | 2 +- src/mame/video/ojankohs.c | 2 +- src/mame/video/pacland.c | 2 +- src/mame/video/paradise.c | 2 +- src/mame/video/pastelg.c | 14 +- src/mame/video/pitnrun.c | 8 +- src/mame/video/pktgaldx.c | 2 +- src/mame/video/playch10.c | 2 +- src/mame/video/policetr.c | 4 +- src/mame/video/popeye.c | 4 +- src/mame/video/popper.c | 2 +- src/mame/video/powerins.c | 4 +- src/mame/video/ppu2c0x.c | 78 +- src/mame/video/ppu2c0x.h | 31 +- src/mame/video/psikyo.c | 8 +- src/mame/video/psikyo4.c | 2 +- src/mame/video/psikyosh.c | 4 +- src/mame/video/psx.c | 26 +- src/mame/video/qix.c | 15 +- src/mame/video/quasar.c | 2 +- src/mame/video/rallyx.c | 6 +- src/mame/video/realbrk.c | 12 +- src/mame/video/rohga.c | 6 +- src/mame/video/rpunch.c | 4 +- src/mame/video/sega16sp.c | 22 +- src/mame/video/segag80r.c | 4 +- src/mame/video/segag80v.c | 4 +- src/mame/video/segaic16.c | 28 +- src/mame/video/segaic16.h | 4 +- src/mame/video/segas18.c | 10 +- src/mame/video/segas32.c | 98 +- src/mame/video/seta.c | 6 +- src/mame/video/shangha3.c | 2 +- src/mame/video/simpl156.c | 2 +- src/mame/video/skullxbo.c | 12 +- src/mame/video/skyfox.c | 4 +- src/mame/video/skyraid.c | 2 +- src/mame/video/snes.c | 30 +- src/mame/video/snk.c | 4 +- src/mame/video/snk68.c | 8 +- src/mame/video/spacefb.c | 16 +- src/mame/video/spbactn.c | 4 +- src/mame/video/spdodgeb.c | 4 +- src/mame/video/sprint2.c | 20 +- src/mame/video/sprint4.c | 4 +- src/mame/video/sprint8.c | 18 +- src/mame/video/srmp2.c | 12 +- src/mame/video/sshangha.c | 2 +- src/mame/video/ssv.c | 4 +- src/mame/video/st0016.c | 10 +- src/mame/video/stadhero.c | 2 +- src/mame/video/starcrus.c | 10 +- src/mame/video/starfire.c | 2 +- src/mame/video/starshp1.c | 20 +- src/mame/video/stvvdp2.c | 32 +- src/mame/video/suna16.c | 4 +- src/mame/video/suna8.c | 8 +- src/mame/video/supbtime.c | 2 +- src/mame/video/superqix.c | 4 +- src/mame/video/suprnova.c | 4 +- src/mame/video/suprridr.c | 8 +- src/mame/video/system1.c | 14 +- src/mame/video/taito_b.c | 10 +- src/mame/video/taito_f3.c | 10 +- src/mame/video/taitoic.c | 102 +- src/mame/video/taitoic.h | 49 +- src/mame/video/taitojc.c | 18 +- src/mame/video/taitosj.c | 14 +- src/mame/video/tank8.c | 26 +- src/mame/video/taotaido.c | 10 +- src/mame/video/tceptor.c | 4 +- src/mame/video/tecmo16.c | 12 +- src/mame/video/tia.c | 16 +- src/mame/video/timeplt.c | 2 +- src/mame/video/toaplan1.c | 14 +- src/mame/video/toaplan2.c | 32 +- src/mame/video/toki.c | 2 +- src/mame/video/toobin.c | 8 +- src/mame/video/tp84.c | 16 +- src/mame/video/triplhnt.c | 4 +- src/mame/video/tumbleb.c | 6 +- src/mame/video/tumblep.c | 2 +- src/mame/video/tunhunt.c | 2 +- src/mame/video/turbo.c | 2 +- src/mame/video/twin16.c | 2 +- src/mame/video/tx1.c | 8 +- src/mame/video/ultratnk.c | 4 +- src/mame/video/vaportra.c | 2 +- src/mame/video/vdc.c | 2 +- src/mame/video/vicdual.c | 2 +- src/mame/video/victory.c | 4 +- src/mame/video/vigilant.c | 2 +- src/mame/video/vindictr.c | 20 +- src/mame/video/volfied.c | 4 +- src/mame/video/vrender0.c | 10 +- src/mame/video/vrender0.h | 9 +- src/mame/video/wecleman.c | 6 +- src/mame/video/welltris.c | 6 +- src/mame/video/williams.c | 8 +- src/mame/video/wolfpack.c | 2 +- src/mame/video/xexex.c | 2 +- src/mame/video/xmen.c | 2 +- src/mame/video/ygv608.c | 25 +- src/mame/video/yunsun16.c | 6 +- src/mame/video/zac2650.c | 34 +- src/mame/video/zaxxon.c | 4 +- src/osd/osdepend.h | 4 +- src/osd/sdl/debugwin.c | 2 +- src/osd/sdl/drawogl.c | 8 +- src/osd/sdl/video.c | 3 +- src/osd/windows/d3d8intf.c | 1 + src/osd/windows/d3d9intf.c | 1 + src/osd/windows/debugwin.c | 5 +- src/osd/windows/drawd3d.c | 8 +- src/osd/windows/drawdd.c | 8 +- src/osd/windows/input.c | 1 + src/osd/windows/sound.c | 1 + src/osd/windows/video.c | 3 +- src/osd/windows/windows.mak | 4 +- src/osd/windows/winmain.c | 9 +- 1360 files changed, 25189 insertions(+), 22003 deletions(-) delete mode 100644 src/emu/cpuexec.c delete mode 100644 src/emu/cpuexec.h delete mode 100644 src/emu/cpuintrf.h create mode 100644 src/emu/devcpu.c create mode 100644 src/emu/devcpu.h create mode 100644 src/emu/devlegcy.c create mode 100644 src/emu/devlegcy.h create mode 100644 src/emu/didisasm.c create mode 100644 src/emu/didisasm.h create mode 100644 src/emu/diexec.c create mode 100644 src/emu/diexec.h create mode 100644 src/emu/dimemory.c create mode 100644 src/emu/dimemory.h create mode 100644 src/emu/dinvram.c create mode 100644 src/emu/dinvram.h create mode 100644 src/emu/disound.c create mode 100644 src/emu/disound.h create mode 100644 src/emu/distate.c create mode 100644 src/emu/distate.h create mode 100644 src/emu/schedule.c create mode 100644 src/emu/schedule.h diff --git a/.gitattributes b/.gitattributes index 284ae217ac6..5862cec2c23 100644 --- a/.gitattributes +++ b/.gitattributes @@ -533,9 +533,6 @@ src/emu/cpu/z8000/z8000cpu.h svneol=native#text/plain src/emu/cpu/z8000/z8000dab.h svneol=native#text/plain src/emu/cpu/z8000/z8000ops.c svneol=native#text/plain src/emu/cpu/z8000/z8000tbl.c svneol=native#text/plain -src/emu/cpuexec.c svneol=native#text/plain -src/emu/cpuexec.h svneol=native#text/plain -src/emu/cpuintrf.h svneol=native#text/plain src/emu/crsshair.c svneol=native#text/plain src/emu/crsshair.h svneol=native#text/plain src/emu/debug/debugcmd.c svneol=native#text/plain @@ -562,9 +559,25 @@ src/emu/deprecat.h svneol=native#text/plain src/emu/devcb.c svneol=native#text/plain src/emu/devcb.h svneol=native#text/plain src/emu/devconv.h svneol=native#text/plain +src/emu/devcpu.c svneol=native#text/plain +src/emu/devcpu.h svneol=native#text/plain src/emu/devintrf.c svneol=native#text/plain src/emu/devintrf.h svneol=native#text/plain +src/emu/devlegcy.c svneol=native#text/plain +src/emu/devlegcy.h svneol=native#text/plain src/emu/devtempl.h svneol=native#text/plain +src/emu/didisasm.c svneol=native#text/plain +src/emu/didisasm.h svneol=native#text/plain +src/emu/diexec.c svneol=native#text/plain +src/emu/diexec.h svneol=native#text/plain +src/emu/dimemory.c svneol=native#text/plain +src/emu/dimemory.h svneol=native#text/plain +src/emu/dinvram.c svneol=native#text/plain +src/emu/dinvram.h svneol=native#text/plain +src/emu/disound.c svneol=native#text/plain +src/emu/disound.h svneol=native#text/plain +src/emu/distate.c svneol=native#text/plain +src/emu/distate.h svneol=native#text/plain src/emu/drawgfx.c svneol=native#text/plain src/emu/drawgfx.h svneol=native#text/plain src/emu/drawgfxm.h svneol=native#text/plain @@ -792,6 +805,8 @@ src/emu/rendutil.c svneol=native#text/plain src/emu/rendutil.h svneol=native#text/plain src/emu/romload.c svneol=native#text/plain src/emu/romload.h svneol=native#text/plain +src/emu/schedule.c svneol=native#text/plain +src/emu/schedule.h svneol=native#text/plain src/emu/sound.c svneol=native#text/plain src/emu/sound.h svneol=native#text/plain src/emu/sound/2151intf.c svneol=native#text/plain diff --git a/src/emu/audit.c b/src/emu/audit.c index eb6863b0e6e..526a50f70a8 100644 --- a/src/emu/audit.c +++ b/src/emu/audit.c @@ -147,16 +147,16 @@ int audit_images(core_options *options, const game_driver *gamedrv, UINT32 valid int audit_samples(core_options *options, const game_driver *gamedrv, audit_record **audit) { machine_config *config = machine_config_alloc(gamedrv->machine_config); - const device_config *devconfig; audit_record *record; int records = 0; int sampnum; /* count the number of sample records attached to this driver */ - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) - if (sound_get_type(devconfig) == SOUND_SAMPLES) + const device_config_sound_interface *sound; + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->devconfig().type() == SOUND_SAMPLES) { - const samples_interface *intf = (const samples_interface *)devconfig->static_config; + const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); if (intf->samplenames != NULL) { @@ -176,10 +176,10 @@ int audit_samples(core_options *options, const game_driver *gamedrv, audit_recor record = *audit; /* now iterate over sample entries */ - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) - if (sound_get_type(devconfig) == SOUND_SAMPLES) + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->devconfig().type() == SOUND_SAMPLES) { - const samples_interface *intf = (const samples_interface *)devconfig->static_config; + const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config(); const char *sharedname = NULL; if (intf->samplenames != NULL) diff --git a/src/emu/clifront.c b/src/emu/clifront.c index 11d9ac58cb9..f05616006bf 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -621,13 +621,13 @@ int cli_info_listsamples(core_options *options, const char *gamename) if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0) { machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config); - const device_config *devconfig; + const device_config_sound_interface *sound; /* find samples interfaces */ - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) - if (sound_get_type(devconfig) == SOUND_SAMPLES) + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->devconfig().type() == SOUND_SAMPLES) { - const char *const *samplenames = ((const samples_interface *)devconfig->static_config)->samplenames; + const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; int sampnum; /* if the list is legit, walk it and print the sample info */ @@ -667,26 +667,19 @@ int cli_info_listdevices(core_options *options, const char *gamename) printf("Driver %s (%s):\n", drivers[drvindex]->name, drivers[drvindex]->description); /* iterate through devices */ - for (devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next) + for (devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) { - switch (devconfig->devclass) - { - case DEVICE_CLASS_AUDIO: printf(" Audio: "); break; - case DEVICE_CLASS_VIDEO: printf(" Video: "); break; - case DEVICE_CLASS_CPU_CHIP: printf(" CPU: "); break; - case DEVICE_CLASS_SOUND_CHIP: printf(" Sound: "); break; - case DEVICE_CLASS_TIMER: printf(" Timer: "); break; - default: printf(" Other: "); break; - } - printf("%s ('%s')", devconfig->name(), devconfig->tag()); - if (devconfig->clock >= 1000000000) - printf(" @ %d.%02d GHz\n", devconfig->clock / 1000000000, (devconfig->clock / 10000000) % 100); - else if (devconfig->clock >= 1000000) - printf(" @ %d.%02d MHz\n", devconfig->clock / 1000000, (devconfig->clock / 10000) % 100); - else if (devconfig->clock >= 1000) - printf(" @ %d.%02d kHz\n", devconfig->clock / 1000, (devconfig->clock / 10) % 100); - else if (devconfig->clock > 0) - printf(" @ %d Hz\n", devconfig->clock); + printf(" %s ('%s')", devconfig->name(), devconfig->tag()); + + UINT32 clock = devconfig->clock(); + if (clock >= 1000000000) + printf(" @ %d.%02d GHz\n", clock / 1000000000, (clock / 10000000) % 100); + else if (clock >= 1000000) + printf(" @ %d.%02d MHz\n", clock / 1000000, (clock / 10000) % 100); + else if (clock >= 1000) + printf(" @ %d.%02d kHz\n", clock / 1000, (clock / 10) % 100); + else if (clock > 0) + printf(" @ %d Hz\n", clock); else printf("\n"); } diff --git a/src/emu/cpu/adsp2100/adsp2100.c b/src/emu/cpu/adsp2100/adsp2100.c index 129e50f0656..c1ff81cf89f 100644 --- a/src/emu/cpu/adsp2100/adsp2100.c +++ b/src/emu/cpu/adsp2100/adsp2100.c @@ -241,7 +241,7 @@ typedef struct UINT16 ifc; UINT8 irq_state[9]; UINT8 irq_latch[9]; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; /* other internal states */ @@ -266,7 +266,6 @@ typedef struct const address_space *program; const address_space *data; const address_space *io; - cpu_state_table state; } adsp2100_state; @@ -286,132 +285,6 @@ static UINT32 pcbucket[0x4000]; -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define ADSP21XX_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(ADSP2100_##_name, #_name, _format, adsp2100_state, _member, _datamask, ~0, _flags) - -#define ADSP21XX_STATE_ENTRY_MASK(_name, _format, _member, _datamask, _flags, _validmask) \ - CPU_STATE_ENTRY(ADSP2100_##_name, #_name, _format, adsp2100_state, _member, _datamask, _validmask, _flags) - -static const cpu_state_entry state_array[] = -{ - ADSP21XX_STATE_ENTRY(PC, "%04X", pc, 0xffff, 0) - ADSP21XX_STATE_ENTRY(GENPC, "%04X", pc, 0xffff, CPUSTATE_NOSHOW) - ADSP21XX_STATE_ENTRY(GENPCBASE, "%04X", ppc, 0xffff, CPUSTATE_NOSHOW) - - ADSP21XX_STATE_ENTRY(AX0, "%04X", core.ax0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AX1, "%04X", core.ax1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AY0, "%04X", core.ay0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AY1, "%04X", core.ay1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AR, "%04X", core.ar.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AF, "%04X", core.af.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(MX0, "%04X", core.mx0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MX1, "%04X", core.mx1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MY0, "%04X", core.my0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MY1, "%04X", core.my1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR0, "%04X", core.mr.mrx.mr0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR1, "%04X", core.mr.mrx.mr1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR2, "%02X", core.mr.mrx.mr2.u, 0xff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(MF, "%04X", core.mf.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(SI, "%04X", core.si.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(SE, "%02X", core.se.u, 0xff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(SB, "%02X", core.sb.u, 0x1f, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(SR0, "%04X", core.sr.srx.sr0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(SR1, "%04X", core.sr.srx.sr0.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(AX0_SEC, "%04X", alt.ax0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AX1_SEC, "%04X", alt.ax1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AY0_SEC, "%04X", alt.ay0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AY1_SEC, "%04X", alt.ay1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AR_SEC, "%04X", alt.ar.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(AF_SEC, "%04X", alt.af.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(MX0_SEC, "%04X", alt.mx0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MX1_SEC, "%04X", alt.mx1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MY0_SEC, "%04X", alt.my0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MY1_SEC, "%04X", alt.my1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR0_SEC, "%04X", alt.mr.mrx.mr0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR1_SEC, "%04X", alt.mr.mrx.mr1.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(MR2_SEC, "%02X", alt.mr.mrx.mr2.u, 0xff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(MF_SEC, "%04X", alt.mf.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(SI_SEC, "%04X", alt.si.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(SE_SEC, "%02X", alt.se.u, 0xff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(SB_SEC, "%02X", alt.sb.u, 0x1f, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(SR0_SEC, "%04X", alt.sr.srx.sr0.u, 0xffff, 0) - ADSP21XX_STATE_ENTRY(SR1_SEC, "%04X", alt.sr.srx.sr0.u, 0xffff, 0) - - ADSP21XX_STATE_ENTRY(I0, "%04X", i[0], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I1, "%04X", i[1], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I2, "%04X", i[2], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I3, "%04X", i[3], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I4, "%04X", i[4], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I5, "%04X", i[5], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I6, "%04X", i[6], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(I7, "%04X", i[7], 0x3fff, CPUSTATE_IMPORT) - - ADSP21XX_STATE_ENTRY(L0, "%04X", l[0], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L1, "%04X", l[1], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L2, "%04X", l[2], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L3, "%04X", l[3], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L4, "%04X", l[4], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L5, "%04X", l[5], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L6, "%04X", l[6], 0x3fff, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(L7, "%04X", l[7], 0x3fff, CPUSTATE_IMPORT) - - ADSP21XX_STATE_ENTRY(M0, "%04X", m[0], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M1, "%04X", m[1], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M2, "%04X", m[2], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M3, "%04X", m[3], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M4, "%04X", m[4], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M5, "%04X", m[5], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M6, "%04X", m[6], 0x3fff, CPUSTATE_IMPORT_SEXT) - ADSP21XX_STATE_ENTRY(M7, "%04X", m[7], 0x3fff, CPUSTATE_IMPORT_SEXT) - - ADSP21XX_STATE_ENTRY(PX, "%02X", px, 0xff, 0) - ADSP21XX_STATE_ENTRY(CNTR, "%04X", cntr, 0x3fff, 0) - ADSP21XX_STATE_ENTRY(ASTAT, "%02X", astat, 0xff, 0) - ADSP21XX_STATE_ENTRY(SSTAT, "%02X", sstat, 0xff, 0) - ADSP21XX_STATE_ENTRY_MASK(MSTAT, "%01X", mstat, 0x0f, CPUSTATE_IMPORT, (1 << CHIP_TYPE_ADSP2100)) - ADSP21XX_STATE_ENTRY_MASK(MSTAT, "%02X", mstat, 0x7f, CPUSTATE_IMPORT, ~(1 << CHIP_TYPE_ADSP2100)) - - ADSP21XX_STATE_ENTRY(PCSP, "%02X", pc_sp, 0xff, 0) - ADSP21XX_STATE_ENTRY(GENSP, "%02X", pc_sp, 0xff, CPUSTATE_NOSHOW) - ADSP21XX_STATE_ENTRY(CNTRSP, "%01X", cntr_sp, 0xf, 0) - ADSP21XX_STATE_ENTRY(STATSP, "%01X", stat_sp, 0xf, 0) - ADSP21XX_STATE_ENTRY(LOOPSP, "%01X", loop_sp, 0xf, 0) - - ADSP21XX_STATE_ENTRY_MASK(IMASK, "%01X", imask, 0x00f, CPUSTATE_IMPORT, (1 << CHIP_TYPE_ADSP2100)) - ADSP21XX_STATE_ENTRY_MASK(IMASK, "%02X", imask, 0x03f, CPUSTATE_IMPORT, ~((1 << CHIP_TYPE_ADSP2100) | (1 << CHIP_TYPE_ADSP2181))) - ADSP21XX_STATE_ENTRY_MASK(IMASK, "%03X", imask, 0x3ff, CPUSTATE_IMPORT, (1 << CHIP_TYPE_ADSP2181)) - ADSP21XX_STATE_ENTRY(ICNTL, "%02X", icntl, 0x1f, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(IRQSTATE0, "%1u", irq_state[0], 0x1, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(IRQSTATE1, "%1u", irq_state[1], 0x1, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY(IRQSTATE2, "%1u", irq_state[2], 0x1, CPUSTATE_IMPORT) - ADSP21XX_STATE_ENTRY_MASK(IRQSTATE3, "%1u", irq_state[3], 0x1, CPUSTATE_IMPORT, (1 << CHIP_TYPE_ADSP2100)) - - ADSP21XX_STATE_ENTRY(FLAGIN, "%1u", flagin, 0x1, 0) - ADSP21XX_STATE_ENTRY(FLAGOUT, "%1u", flagout, 0x1, 0) - ADSP21XX_STATE_ENTRY(FL0, "%1u", fl0, 0x1, 0) - ADSP21XX_STATE_ENTRY(FL1, "%1u", fl1, 0x1, 0) - ADSP21XX_STATE_ENTRY(FL2, "%1u", fl2, 0x1, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - - /*************************************************************************** PRIVATE FUNCTION PROTOTYPES ***************************************************************************/ @@ -428,15 +301,14 @@ static void check_irqs(adsp2100_state *adsp); INLINE adsp2100_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ADSP2100 || cpu_get_type(device) == CPU_ADSP2101 || cpu_get_type(device) == CPU_ADSP2104 || cpu_get_type(device) == CPU_ADSP2105 || cpu_get_type(device) == CPU_ADSP2115 || cpu_get_type(device) == CPU_ADSP2181); - return (adsp2100_state *)device->token; + return (adsp2100_state *)downcast(device)->token(); } @@ -691,9 +563,9 @@ static void set_irq_line(adsp2100_state *adsp, int irqline, int state) INITIALIZATION AND SHUTDOWN ***************************************************************************/ -static adsp2100_state *adsp21xx_init(running_device *device, cpu_irq_callback irqcallback, int chiptype) +static adsp2100_state *adsp21xx_init(running_device *device, device_irq_callback irqcallback, int chiptype) { - const adsp21xx_config *config = (const adsp21xx_config *)device->baseconfig().static_config; + const adsp21xx_config *config = (const adsp21xx_config *)device->baseconfig().static_config(); adsp2100_state *adsp = get_safe_token(device); /* create the tables */ @@ -706,9 +578,9 @@ static adsp2100_state *adsp21xx_init(running_device *device, cpu_irq_callback ir /* fetch device parameters */ adsp->device = device; - adsp->program = device->space(AS_PROGRAM); - adsp->data = device->space(AS_DATA); - adsp->io = device->space(AS_IO); + adsp->program = device_memory(device)->space(AS_PROGRAM); + adsp->data = device_memory(device)->space(AS_DATA); + adsp->io = device_memory(device)->space(AS_IO); /* copy function pointers from the config */ if (config != NULL) @@ -718,11 +590,6 @@ static adsp2100_state *adsp21xx_init(running_device *device, cpu_irq_callback ir adsp->timer_fired = config->timer; } - /* set up the state table */ - adsp->state = state_table_template; - adsp->state.baseptr = adsp; - adsp->state.subtypemask = 1 << chiptype; - /* set up ALU register pointers */ adsp->alu_xregs[0] = &adsp->core.ax0; adsp->alu_xregs[1] = &adsp->core.ax1; @@ -843,6 +710,93 @@ static adsp2100_state *adsp21xx_init(running_device *device, cpu_irq_callback ir state_save_register_device_item_array(device, 0, adsp->irq_state); state_save_register_device_item_array(device, 0, adsp->irq_latch); + // eventually this will be built-in + device_state_interface *state; + device->interface(state); + state->state_add(ADSP2100_PC, "PC", adsp->pc); + state->state_add(STATE_GENPC, "GENPC", adsp->pc).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", adsp->ppc).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", adsp->astat).mask(0xff).noshow().formatstr("%8s"); + + state->state_add(ADSP2100_AX0, "AX0", adsp->core.ax0.u); + state->state_add(ADSP2100_AX1, "AX1", adsp->core.ax1.u); + state->state_add(ADSP2100_AY0, "AY0", adsp->core.ay0.u); + state->state_add(ADSP2100_AY1, "AY1", adsp->core.ay1.u); + state->state_add(ADSP2100_AR, "AR", adsp->core.ar.u); + state->state_add(ADSP2100_AF, "AF", adsp->core.af.u); + + state->state_add(ADSP2100_MX0, "MX0", adsp->core.mx0.u); + state->state_add(ADSP2100_MX1, "MX1", adsp->core.mx1.u); + state->state_add(ADSP2100_MY0, "MY0", adsp->core.my0.u); + state->state_add(ADSP2100_MY1, "MY1", adsp->core.my1.u); + state->state_add(ADSP2100_MR0, "MR0", adsp->core.mr.mrx.mr0.u); + state->state_add(ADSP2100_MR1, "MR1", adsp->core.mr.mrx.mr1.u); + state->state_add(ADSP2100_MR2, "MR2", adsp->core.mr.mrx.mr2.u).signed_mask(0xff); + state->state_add(ADSP2100_MF, "MF", adsp->core.mf.u); + + state->state_add(ADSP2100_SI, "SI", adsp->core.si.u); + state->state_add(ADSP2100_SE, "SE", adsp->core.se.u).signed_mask(0xff); + state->state_add(ADSP2100_SB, "SB", adsp->core.sb.u).signed_mask(0x1f); + state->state_add(ADSP2100_SR0, "SR0", adsp->core.sr.srx.sr0.u); + state->state_add(ADSP2100_SR1, "SR1", adsp->core.sr.srx.sr1.u); + + state->state_add(ADSP2100_AX0_SEC, "AX0_SEC", adsp->alt.ax0.u); + state->state_add(ADSP2100_AX1_SEC, "AX1_SEC", adsp->alt.ax1.u); + state->state_add(ADSP2100_AY0_SEC, "AY0_SEC", adsp->alt.ay0.u); + state->state_add(ADSP2100_AY1_SEC, "AY1_SEC", adsp->alt.ay1.u); + state->state_add(ADSP2100_AR_SEC, "AR_SEC", adsp->alt.ar.u); + state->state_add(ADSP2100_AF_SEC, "AF_SEC", adsp->alt.af.u); + + state->state_add(ADSP2100_MX0_SEC, "MX0_SEC", adsp->alt.mx0.u); + state->state_add(ADSP2100_MX1_SEC, "MX1_SEC", adsp->alt.mx1.u); + state->state_add(ADSP2100_MY0_SEC, "MY0_SEC", adsp->alt.my0.u); + state->state_add(ADSP2100_MY1_SEC, "MY1_SEC", adsp->alt.my1.u); + state->state_add(ADSP2100_MR0_SEC, "MR0_SEC", adsp->alt.mr.mrx.mr0.u); + state->state_add(ADSP2100_MR1_SEC, "MR1_SEC", adsp->alt.mr.mrx.mr1.u); + state->state_add(ADSP2100_MR2_SEC, "MR2_SEC", adsp->alt.mr.mrx.mr2.u).signed_mask(0xff); + state->state_add(ADSP2100_MF_SEC, "MF_SEC", adsp->alt.mf.u); + + state->state_add(ADSP2100_SI_SEC, "SI_SEC", adsp->alt.si.u); + state->state_add(ADSP2100_SE_SEC, "SE_SEC", adsp->alt.se.u).signed_mask(0xff); + state->state_add(ADSP2100_SB_SEC, "SB_SEC", adsp->alt.sb.u).signed_mask(0x1f); + state->state_add(ADSP2100_SR0_SEC, "SR0_SEC", adsp->alt.sr.srx.sr0.u); + state->state_add(ADSP2100_SR1_SEC, "SR1_SEC", adsp->alt.sr.srx.sr1.u); + + astring tempstring; + for (int ireg = 0; ireg < 8; ireg++) + state->state_add(ADSP2100_I0 + ireg, tempstring.format("I%d", ireg), adsp->i[ireg]).mask(0x3fff).callimport(); + + for (int lreg = 0; lreg < 8; lreg++) + state->state_add(ADSP2100_L0 + lreg, tempstring.format("L%d", lreg), adsp->l[lreg]).mask(0x3fff).callimport(); + + for (int mreg = 0; mreg < 8; mreg++) + state->state_add(ADSP2100_M0 + mreg, tempstring.format("M%d", mreg), adsp->m[mreg]).signed_mask(0x3fff); + + state->state_add(ADSP2100_PX, "PX", adsp->px); + state->state_add(ADSP2100_CNTR, "CNTR", adsp->cntr).mask(0x3fff); + state->state_add(ADSP2100_ASTAT, "ASTAT", adsp->astat).mask(0xff); + state->state_add(ADSP2100_SSTAT, "SSTAT", adsp->sstat).mask(0xff); + state->state_add(ADSP2100_MSTAT, "MSTAT", adsp->mstat).mask((chiptype == CHIP_TYPE_ADSP2100) ? 0x0f : 0x7f).callimport(); + + state->state_add(ADSP2100_PCSP, "PCSP", adsp->pc_sp).mask(0xff); + state->state_add(STATE_GENSP, "GENSP", adsp->pc_sp).mask(0xff).noshow(); + state->state_add(ADSP2100_CNTRSP, "CNTRSP", adsp->cntr_sp).mask(0xf); + state->state_add(ADSP2100_STATSP, "STATSP", adsp->stat_sp).mask(0xf); + state->state_add(ADSP2100_LOOPSP, "LOOPSP", adsp->loop_sp).mask(0xf); + + state->state_add(ADSP2100_IMASK, "IMASK", adsp->imask).mask((chiptype == CHIP_TYPE_ADSP2100) ? 0x00f : (chiptype == CHIP_TYPE_ADSP2181) ? 0x3ff : 0x07f).callimport(); + state->state_add(ADSP2100_ICNTL, "ICNTL", adsp->icntl).mask(0x1f).callimport(); + + for (int irqnum = 0; irqnum < 4; irqnum++) + if (irqnum < 4 || chiptype == CHIP_TYPE_ADSP2100) + state->state_add(ADSP2100_IRQSTATE0 + irqnum, tempstring.format("IRQ%d", irqnum), adsp->irq_state[irqnum]).mask(1).callimport(); + + state->state_add(ADSP2100_FLAGIN, "FLAGIN", adsp->flagin).mask(1); + state->state_add(ADSP2100_FLAGOUT, "FLAGOUT", adsp->flagout).mask(1); + state->state_add(ADSP2100_FL0, "FL0", adsp->fl0).mask(1); + state->state_add(ADSP2100_FL1, "FL1", adsp->fl1).mask(1); + state->state_add(ADSP2100_FL2, "FL2", adsp->fl2).mask(1); + return adsp; } @@ -1807,7 +1761,7 @@ extern CPU_DISASSEMBLE( adsp21xx ); static CPU_IMPORT_STATE( adsp21xx ) { adsp2100_state *adsp = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case ADSP2100_MSTAT: update_mstat(adsp); @@ -1830,7 +1784,7 @@ static CPU_IMPORT_STATE( adsp21xx ) case ADSP2100_I5: case ADSP2100_I6: case ADSP2100_I7: - update_i(adsp, entry->index - ADSP2100_I0); + update_i(adsp, entry.index() - ADSP2100_I0); break; case ADSP2100_L0: @@ -1841,7 +1795,7 @@ static CPU_IMPORT_STATE( adsp21xx ) case ADSP2100_L5: case ADSP2100_L6: case ADSP2100_L7: - update_l(adsp, entry->index - ADSP2100_L0); + update_l(adsp, entry.index() - ADSP2100_L0); break; default: @@ -1851,6 +1805,28 @@ static CPU_IMPORT_STATE( adsp21xx ) } +static CPU_EXPORT_STRING( adsp21xx ) +{ + adsp2100_state *adsp = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c", + adsp->astat & 0x80 ? 'X':'.', + adsp->astat & 0x40 ? 'M':'.', + adsp->astat & 0x20 ? 'Q':'.', + adsp->astat & 0x10 ? 'S':'.', + adsp->astat & 0x08 ? 'C':'.', + adsp->astat & 0x04 ? 'V':'.', + adsp->astat & 0x02 ? 'N':'.', + adsp->astat & 0x01 ? 'Z':'.'); + break; + } +} + + + /************************************************************************** * Generic set_info @@ -1885,7 +1861,7 @@ static CPU_SET_INFO( adsp21xx ) static CPU_GET_INFO( adsp21xx ) { - adsp2100_state *adsp = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + adsp2100_state *adsp = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1928,10 +1904,10 @@ static CPU_GET_INFO( adsp21xx ) case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(adsp21xx); break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(adsp21xx); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(adsp21xx); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(adsp21xx); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &adsp->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &adsp->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: /* set per CPU */ break; @@ -1939,18 +1915,6 @@ static CPU_GET_INFO( adsp21xx ) case DEVINFO_STR_VERSION: strcpy(info->s, "2.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Aaron Giles"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c", - adsp->astat & 0x80 ? 'X':'.', - adsp->astat & 0x40 ? 'M':'.', - adsp->astat & 0x20 ? 'Q':'.', - adsp->astat & 0x10 ? 'S':'.', - adsp->astat & 0x08 ? 'C':'.', - adsp->astat & 0x04 ? 'V':'.', - adsp->astat & 0x02 ? 'N':'.', - adsp->astat & 0x01 ? 'Z':'.'); - break; } } diff --git a/src/emu/cpu/adsp2100/adsp2100.h b/src/emu/cpu/adsp2100/adsp2100.h index 1d6d279d26d..d7cb50dd795 100644 --- a/src/emu/cpu/adsp2100/adsp2100.h +++ b/src/emu/cpu/adsp2100/adsp2100.h @@ -52,9 +52,9 @@ enum ADSP2100_MX0_SEC, ADSP2100_MX1_SEC, ADSP2100_MY0_SEC, ADSP2100_MY1_SEC, ADSP2100_MR0_SEC, ADSP2100_MR1_SEC, ADSP2100_MR2_SEC, ADSP2100_MF_SEC, ADSP2100_SI_SEC, ADSP2100_SE_SEC, ADSP2100_SB_SEC, ADSP2100_SR0_SEC, ADSP2100_SR1_SEC, - ADSP2100_GENPC = REG_GENPC, - ADSP2100_GENSP = REG_GENSP, - ADSP2100_GENPCBASE = REG_GENPCBASE + ADSP2100_GENPC = STATE_GENPC, + ADSP2100_GENSP = STATE_GENSP, + ADSP2100_GENPCBASE = STATE_GENPCBASE }; diff --git a/src/emu/cpu/alph8201/alph8201.c b/src/emu/cpu/alph8201/alph8201.c index 17f5b40c831..a68eb843226 100644 --- a/src/emu/cpu/alph8201/alph8201.c +++ b/src/emu/cpu/alph8201/alph8201.c @@ -227,11 +227,10 @@ typedef struct { INLINE alpha8201_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ALPHA8201 || cpu_get_type(device) == CPU_ALPHA8301); - return (alpha8201_state *)device->token; + return (alpha8201_state *)downcast(device)->token(); } /* Get next opcode argument and increment program counter */ @@ -670,7 +669,7 @@ static CPU_INIT( alpha8201 ) alpha8201_state *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item_array(device, 0, cpustate->RAM); state_save_register_device_item(device, 0, cpustate->PREVPC); @@ -879,7 +878,7 @@ static CPU_SET_INFO( alpha8201 ) /* 8201 and 8301 */ static CPU_GET_INFO( alpha8xxx ) { - alpha8201_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + alpha8201_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/am29000/am29000.c b/src/emu/cpu/am29000/am29000.c index b1455847595..6c896ae7de8 100644 --- a/src/emu/cpu/am29000/am29000.c +++ b/src/emu/cpu/am29000/am29000.c @@ -144,19 +144,18 @@ typedef struct _am29000_state INLINE am29000_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_AM29000); - return (am29000_state *)device->token; + return (am29000_state *)downcast(device)->token(); } static CPU_INIT( am29000 ) { am29000_state *am29000 = get_safe_token(device); - am29000->program = device->space(AS_PROGRAM); - am29000->data = device->space(AS_DATA); - am29000->io = device->space(AS_IO); + am29000->program = device_memory(device)->space(AS_PROGRAM); + am29000->data = device_memory(device)->space(AS_DATA); + am29000->io = device_memory(device)->space(AS_IO); am29000->cfg = (PRL_AM29000 | PRL_REV_D) << CFG_PRL_SHIFT; /* Register state for saving */ @@ -713,7 +712,7 @@ static CPU_SET_INFO( am29000 ) CPU_GET_INFO( am29000 ) { - am29000_state *am29000 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + am29000_state *am29000 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/apexc/apexc.c b/src/emu/cpu/apexc/apexc.c index cb4cfdc3d8b..5a66f04c5b1 100644 --- a/src/emu/cpu/apexc/apexc.c +++ b/src/emu/cpu/apexc/apexc.c @@ -371,10 +371,9 @@ struct _apexc_state INLINE apexc_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_APEXC); - return (apexc_state *)device->token; + return (apexc_state *)downcast(device)->token(); } @@ -803,8 +802,8 @@ static CPU_INIT( apexc ) apexc_state *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->a); state_save_register_device_item(device, 0, cpustate->r); @@ -890,7 +889,7 @@ static CPU_SET_INFO( apexc ) CPU_GET_INFO( apexc ) { - apexc_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + apexc_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/arm/arm.c b/src/emu/cpu/arm/arm.c index d0aa838a6be..40bfcea293d 100644 --- a/src/emu/cpu/arm/arm.c +++ b/src/emu/cpu/arm/arm.c @@ -233,7 +233,7 @@ typedef struct UINT32 coproRegister[16]; UINT8 pendingIrq; UINT8 pendingFiq; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; } ARM_REGS; @@ -253,10 +253,9 @@ static void arm_check_irq_state(ARM_REGS* cpustate); INLINE ARM_REGS *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ARM); - return (ARM_REGS *)device->token; + return (ARM_REGS *)downcast(device)->token(); } INLINE void cpu_write32( ARM_REGS* cpustate, int addr, UINT32 data ) @@ -312,11 +311,11 @@ static CPU_RESET( arm ) { ARM_REGS *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback = cpustate->irq_callback; + device_irq_callback save_irqcallback = cpustate->irq_callback; memset(cpustate, 0, sizeof(ARM_REGS)); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* start up in SVC mode with interrupts disabled. */ R15 = eARM_MODE_SVC|I_MASK|F_MASK; @@ -501,7 +500,7 @@ static CPU_INIT( arm ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item_array(device, 0, cpustate->sArmRegister); state_save_register_device_item_array(device, 0, cpustate->coproRegister); @@ -1436,7 +1435,7 @@ static CPU_SET_INFO( arm ) CPU_GET_INFO( arm ) { - ARM_REGS *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + ARM_REGS *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/arm7/arm7.c b/src/emu/cpu/arm7/arm7.c index a53cf2f2276..278b9a6606d 100644 --- a/src/emu/cpu/arm7/arm7.c +++ b/src/emu/cpu/arm7/arm7.c @@ -71,10 +71,9 @@ void arm7_dt_w_callback(arm_state *cpustate, UINT32 insn, UINT32 *prn, void (*wr INLINE arm_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ARM7 || cpu_get_type(device) == CPU_ARM9 || cpu_get_type(device) == CPU_PXA255); - return (arm_state *)device->token; + return (arm_state *)downcast(device)->token(); } INLINE INT64 saturate_qbit_overflow(arm_state *cpustate, INT64 res) @@ -191,7 +190,7 @@ INLINE UINT32 arm7_tlb_translate(arm_state *cpustate, UINT32 vaddr) static CPU_TRANSLATE( arm7 ) { - arm_state *cpustate = (device != NULL) ? (arm_state *)device->token : NULL; + arm_state *cpustate = (device != NULL) ? (arm_state *)downcast(device)->token() : NULL; /* only applies to the program address space and only does something if the MMU's enabled */ if( space == ADDRESS_SPACE_PROGRAM && ( COPRO_CTRL & COPRO_CTRL_MMU_EN ) ) @@ -217,7 +216,7 @@ static CPU_INIT( arm7 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); // setup co-proc callbacks arm7_coproc_do_callback = arm7_do_callback; @@ -385,7 +384,7 @@ static CPU_SET_INFO( arm7 ) CPU_GET_INFO( arm7 ) { - arm_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + arm_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/arm7/arm7core.c b/src/emu/cpu/arm7/arm7core.c index 953e56a1668..ab73095cefc 100644 --- a/src/emu/cpu/arm7/arm7core.c +++ b/src/emu/cpu/arm7/arm7core.c @@ -547,12 +547,12 @@ static void arm7_core_reset(running_device *device) { arm_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback = cpustate->irq_callback; + device_irq_callback save_irqcallback = cpustate->irq_callback; memset(cpustate, 0, sizeof(arm_state)); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* start up in SVC mode with interrupts disabled. */ SwitchMode(cpustate, eARM7_MODE_SVC); diff --git a/src/emu/cpu/arm7/arm7core.h b/src/emu/cpu/arm7/arm7core.h index 67e9b918eed..8e0764f0944 100644 --- a/src/emu/cpu/arm7/arm7core.h +++ b/src/emu/cpu/arm7/arm7core.h @@ -160,7 +160,7 @@ enum UINT8 pendingUnd; \ UINT8 pendingSwi; \ INT32 iCount; \ - cpu_irq_callback irq_callback; \ + device_irq_callback irq_callback; \ running_device *device; \ const address_space *program; diff --git a/src/emu/cpu/asap/asap.c b/src/emu/cpu/asap/asap.c index ab9377a9e3a..4875d3d30d1 100644 --- a/src/emu/cpu/asap/asap.c +++ b/src/emu/cpu/asap/asap.c @@ -85,7 +85,7 @@ struct _asap_state UINT32 nextpc; UINT8 irq_state; int icount; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; const address_space *program; running_device *device; @@ -271,10 +271,9 @@ static void (*const conditiontable[16])(asap_state *) = INLINE asap_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ASAP); - return (asap_state *)device->token; + return (asap_state *)downcast(device)->token(); } @@ -447,7 +446,7 @@ static CPU_INIT( asap ) asap->src2val[i] = i; asap->irq_callback = irqcallback; asap->device = device; - asap->program = device->space(AS_PROGRAM); + asap->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item(device, 0, asap->pc); @@ -1728,7 +1727,7 @@ static CPU_SET_INFO( asap ) CPU_GET_INFO( asap ) { - asap_state *asap = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + asap_state *asap = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/avr8/avr8.c b/src/emu/cpu/avr8/avr8.c index a651050b041..649b62c48ea 100644 --- a/src/emu/cpu/avr8/avr8.c +++ b/src/emu/cpu/avr8/avr8.c @@ -78,10 +78,9 @@ enum INLINE avr8_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_AVR8); - return (avr8_state *)device->token; + return (avr8_state *)downcast(device)->token(); } /*****************************************************************************/ @@ -190,8 +189,8 @@ static CPU_INIT( avr8 ) cpustate->pc = 0; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); WRITE_IO_8(cpustate, AVR8_IO_SREG, 0); @@ -1074,7 +1073,7 @@ static CPU_SET_INFO( avr8 ) CPU_GET_INFO( avr8 ) { - avr8_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + avr8_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/ccpu/ccpu.c b/src/emu/cpu/ccpu/ccpu.c index c6d9c59b95e..a0a57c88ace 100644 --- a/src/emu/cpu/ccpu/ccpu.c +++ b/src/emu/cpu/ccpu/ccpu.c @@ -53,10 +53,9 @@ struct _ccpu_state INLINE ccpu_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CCPU); - return (ccpu_state *)device->token; + return (ccpu_state *)downcast(device)->token(); } @@ -125,16 +124,16 @@ void ccpu_wdt_timer_trigger(running_device *device) static CPU_INIT( ccpu ) { - const ccpu_config *configdata = (const ccpu_config *)device->baseconfig().static_config; + const ccpu_config *configdata = (const ccpu_config *)device->baseconfig().static_config(); ccpu_state *cpustate = get_safe_token(device); /* copy input params */ cpustate->external_input = configdata->external_input ? configdata->external_input : read_jmi; cpustate->vector_callback = configdata->vector_callback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->PC); state_save_register_device_item(device, 0, cpustate->A); @@ -731,7 +730,7 @@ static CPU_SET_INFO( ccpu ) CPU_GET_INFO( ccpu ) { - ccpu_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + ccpu_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/cdp1802/cdp1802.c b/src/emu/cpu/cdp1802/cdp1802.c index 41a5293639b..46b247d4d39 100644 --- a/src/emu/cpu/cdp1802/cdp1802.c +++ b/src/emu/cpu/cdp1802/cdp1802.c @@ -45,6 +45,7 @@ struct _cdp1802_state UINT8 t; /* temporary register */ int ie; /* interrupt enable */ int q; /* output flip-flop */ + UINT8 flags; // used for I/O only /* cpu state */ cdp1802_cpu_state state; /* processor state */ @@ -59,70 +60,19 @@ struct _cdp1802_state int ef; /* external flags */ /* execution logic */ - UINT16 fake_pc; /* fake program counter */ int icount; /* instruction counter */ - - cpu_state_table state_table; }; /*************************************************************************** CPU STATE DESCRIPTION ***************************************************************************/ -#define CDP1802_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(CDP1802_##_name, #_name, _format, cdp1802_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - CDP1802_STATE_ENTRY(GENPC, "%04X", fake_pc, 0xffff, CPUSTATE_NOSHOW | CPUSTATE_IMPORT | CPUSTATE_EXPORT) - - CDP1802_STATE_ENTRY(P, "%01X", p, 0xf, 0) - CDP1802_STATE_ENTRY(X, "%01X", x, 0xf, 0) - CDP1802_STATE_ENTRY(D, "%02X", d, 0xff, 0) - CDP1802_STATE_ENTRY(B, "%02X", b, 0xff, 0) - CDP1802_STATE_ENTRY(T, "%02X", t, 0xff, 0) - - CDP1802_STATE_ENTRY(I, "%01X", i, 0xf, 0) - CDP1802_STATE_ENTRY(N, "%01X", n, 0xf, 0) - - CDP1802_STATE_ENTRY(R0, "%04X", r[0], 0xffff, 0) - CDP1802_STATE_ENTRY(R1, "%04X", r[1], 0xffff, 0) - CDP1802_STATE_ENTRY(R2, "%04X", r[2], 0xffff, 0) - CDP1802_STATE_ENTRY(R3, "%04X", r[3], 0xffff, 0) - CDP1802_STATE_ENTRY(R4, "%04X", r[4], 0xffff, 0) - CDP1802_STATE_ENTRY(R5, "%04X", r[5], 0xffff, 0) - CDP1802_STATE_ENTRY(R6, "%04X", r[6], 0xffff, 0) - CDP1802_STATE_ENTRY(R7, "%04X", r[7], 0xffff, 0) - CDP1802_STATE_ENTRY(R8, "%04X", r[8], 0xffff, 0) - CDP1802_STATE_ENTRY(R9, "%04X", r[9], 0xffff, 0) - CDP1802_STATE_ENTRY(Ra, "%04X", r[10], 0xffff, 0) - CDP1802_STATE_ENTRY(Rb, "%04X", r[11], 0xffff, 0) - CDP1802_STATE_ENTRY(Rc, "%04X", r[12], 0xffff, 0) - CDP1802_STATE_ENTRY(Rd, "%04X", r[13], 0xffff, 0) - CDP1802_STATE_ENTRY(Re, "%04X", r[14], 0xffff, 0) - CDP1802_STATE_ENTRY(Rf, "%04X", r[15], 0xffff, 0) - - CDP1802_STATE_ENTRY(SC, "%1u", state_code, 0x3, CPUSTATE_NOSHOW) - CDP1802_STATE_ENTRY(DF, "%1u", df, 0x1, CPUSTATE_NOSHOW) - CDP1802_STATE_ENTRY(IE, "%1u", ie, 0x1, CPUSTATE_NOSHOW) - CDP1802_STATE_ENTRY(Q, "%1u", q, 0x1, CPUSTATE_NOSHOW) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - INLINE cdp1802_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CDP1802); - return (cdp1802_state *)device->token; + return (cdp1802_state *)downcast(device)->token(); } #define OPCODE_R(addr) memory_decrypted_read_byte(cpustate->program, addr) @@ -960,12 +910,55 @@ static CPU_RESET( cdp1802 ) cpustate->mode = CDP1802_MODE_RESET; } +static CPU_IMPORT_STATE( cdp1802 ) +{ + cdp1802_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->df = (cpustate->flags >> 1) & 1; + cpustate->ie = (cpustate->flags >> 1) & 1; + cpustate->q = (cpustate->flags >> 0) & 1; + break; + } +} + +static CPU_EXPORT_STATE( cdp1802 ) +{ + cdp1802_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->flags = (cpustate->df ? 0x04 : 0x00) | + (cpustate->ie ? 0x02 : 0x00) | + (cpustate->q ? 0x01 : 0x00); + break; + } +} + +static CPU_EXPORT_STRING( cdp1802 ) +{ + cdp1802_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c", + cpustate->df ? 'D' : '.', + cpustate->ie ? 'I' : '.', + cpustate->q ? 'Q' : '.'); + break; + } +} + static CPU_INIT( cdp1802 ) { cdp1802_state *cpustate = get_safe_token(device); int i; - cpustate->intf = (cdp1802_interface *) device->baseconfig().static_config; + cpustate->intf = (cdp1802_interface *) device->baseconfig().static_config(); /* resolve callbacks */ devcb_resolve_write_line(&cpustate->out_q_func, &cpustate->intf->out_q_func, device); @@ -973,13 +966,34 @@ static CPU_INIT( cdp1802 ) devcb_resolve_write8(&cpustate->out_dma_func, &cpustate->intf->out_dma_func, device); /* set up the state table */ - cpustate->state_table = state_table_template; - cpustate->state_table.baseptr = cpustate; - cpustate->state_table.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(STATE_GENPC, "GENPC", R[P]).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).mask(0x7).callimport().callexport().noshow().formatstr("%3s"); + + state->state_add(CDP1802_P, "P", cpustate->p).mask(0xf); + state->state_add(CDP1802_X, "X", cpustate->x).mask(0xf); + state->state_add(CDP1802_D, "D", cpustate->d); + state->state_add(CDP1802_B, "B", cpustate->b); + state->state_add(CDP1802_T, "T", cpustate->t); + + state->state_add(CDP1802_I, "I", cpustate->i).mask(0xf); + state->state_add(CDP1802_N, "N", cpustate->n).mask(0xf); + + astring tempstr; + for (int regnum = 0; regnum < 16; regnum++) + state->state_add(CDP1802_R0 + regnum, tempstr.format("R%x", regnum), cpustate->r[regnum]); + + state->state_add(CDP1802_SC, "SC", cpustate->state_code).mask(0x3).noshow(); + state->state_add(CDP1802_DF, "DF", cpustate->df).mask(0x1).noshow(); + state->state_add(CDP1802_IE, "IE", cpustate->ie).mask(0x1).noshow(); + state->state_add(CDP1802_Q, "Q", cpustate->q).mask(0x1).noshow(); + } /* find address spaces */ - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* set initial values */ cpustate->p = mame_rand(device->machine) & 0x0f; @@ -1022,42 +1036,6 @@ static CPU_INIT( cdp1802 ) state_save_register_device_item(device, 0, cpustate->ef); } -/************************************************************************** - * STATE IMPORT/EXPORT - **************************************************************************/ - -static CPU_IMPORT_STATE( cdp1802 ) -{ - cdp1802_state *cpustate = get_safe_token(device); - - switch (entry->index) - { - case CDP1802_GENPC: - R[P] = cpustate->fake_pc; - break; - - default: - fatalerror("CPU_IMPORT_STATE(cdp1802) called for unexpected value\n"); - break; - } -} - -static CPU_EXPORT_STATE( cdp1802 ) -{ - cdp1802_state *cpustate = get_safe_token(device); - - switch (entry->index) - { - case CDP1802_GENPC: - cpustate->fake_pc = R[P]; - break; - - default: - fatalerror("CPU_EXPORT_STATE(cdp1802) called for unexpected value\n"); - break; - } -} - /************************************************************************** * Generic set_info **************************************************************************/ @@ -1080,7 +1058,7 @@ static CPU_SET_INFO( cdp1802 ) CPU_GET_INFO( cdp1802 ) { - cdp1802_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + cdp1802_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1116,12 +1094,12 @@ CPU_GET_INFO( cdp1802 ) case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(cdp1802); break; case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(cdp1802); break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cdp1802); break; - case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(cdp1802);break; - case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(cdp1802);break; + case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(cdp1802); break; + case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(cdp1802); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(cdp1802); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state_table; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "CDP1802"); break; @@ -1129,11 +1107,5 @@ CPU_GET_INFO( cdp1802 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; - - case CPUINFO_STR_FLAGS: sprintf(info->s, - "%c%c%c", - cpustate->df ? 'D' : '.', - cpustate->ie ? 'I' : '.', - cpustate->q ? 'Q' : '.'); break; } } diff --git a/src/emu/cpu/cdp1802/cdp1802.h b/src/emu/cpu/cdp1802/cdp1802.h index 133191e75d7..c4a18d6bae8 100644 --- a/src/emu/cpu/cdp1802/cdp1802.h +++ b/src/emu/cpu/cdp1802/cdp1802.h @@ -56,7 +56,7 @@ enum CDP1802_R0, CDP1802_R1, CDP1802_R2, CDP1802_R3, CDP1802_R4, CDP1802_R5, CDP1802_R6, CDP1802_R7, CDP1802_R8, CDP1802_R9, CDP1802_Ra, CDP1802_Rb, CDP1802_Rc, CDP1802_Rd, CDP1802_Re, CDP1802_Rf, CDP1802_DF, CDP1802_IE, CDP1802_Q, CDP1802_N, CDP1802_I, CDP1802_SC, - CDP1802_GENPC = REG_GENPC + CDP1802_GENPC = STATE_GENPC }; typedef cdp1802_control_mode (*cdp1802_mode_read_func)(running_device *device); diff --git a/src/emu/cpu/cop400/cop400.c b/src/emu/cpu/cop400/cop400.c index 27714cc3ab5..1ee6d92e953 100644 --- a/src/emu/cpu/cop400/cop400.c +++ b/src/emu/cpu/cop400/cop400.c @@ -92,6 +92,8 @@ struct _cop400_state const address_space *program; const address_space *data; const address_space *io; + + UINT8 featuremask; /* registers */ UINT16 pc; /* 9/10/11-bit ROM address program counter */ @@ -108,6 +110,7 @@ struct _cop400_state int skl; /* 1-bit latch for SK output */ UINT8 h; /* 4-bit general purpose I/O port (COP440 only) */ UINT8 r; /* 8-bit general purpose I/O port (COP440 only) */ + UINT8 flags; // used for I/O only /* counter */ UINT8 t; /* 8-bit timer */ @@ -136,7 +139,6 @@ struct _cop400_state int LBIops[256]; int LBIops33[256]; int icount; /* instruction counter */ - cpu_state_table state_table; /* state table */ const cop400_opcode_map *opcode_map; @@ -154,62 +156,6 @@ struct _cop400_opcode_map { cop400_opcode_func function; }; -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define COP400_STATE_ENTRY(_name, _format, _member, _datamask, _featuremask, _flags) \ - CPU_STATE_ENTRY(COP400_##_name, #_name, _format, cop400_state, _member, _datamask, _featuremask, _flags) - -#define COP410_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE | COP440_FEATURE, _flags) - -#define COP420_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP420_FEATURE | COP444_FEATURE | COP440_FEATURE, _flags) - -#define COP444_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP444_FEATURE | COP440_FEATURE, _flags) - -#define COP440_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - COP400_STATE_ENTRY(_name, _format, _member, _datamask, COP440_FEATURE, _flags) - -static const cpu_state_entry state_array[] = -{ - COP410_STATE_ENTRY(GENPC, "%03X", pc, 0xfff, CPUSTATE_NOSHOW) - COP410_STATE_ENTRY(GENPCBASE, "%03X", prevpc, 0xfff, CPUSTATE_NOSHOW) - COP440_STATE_ENTRY(GENSP, "%01X", n, 0x3, CPUSTATE_NOSHOW) - - COP410_STATE_ENTRY(PC, "%03X", pc, 0xfff, 0) - - COP400_STATE_ENTRY(SA, "%03X", sa, 0xfff, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE, 0) - COP400_STATE_ENTRY(SB, "%03X", sb, 0xfff, COP410_FEATURE | COP420_FEATURE | COP444_FEATURE, 0) - COP400_STATE_ENTRY(SC, "%03X", sc, 0xfff, COP420_FEATURE | COP444_FEATURE, 0) - COP440_STATE_ENTRY(N, "%01X", n, 0x3, 0) - - COP410_STATE_ENTRY(A, "%01X", a, 0xf, 0) - COP410_STATE_ENTRY(B, "%02X", b, 0xff, 0) - COP410_STATE_ENTRY(C, "%1u", c, 0x1, 0) - - COP410_STATE_ENTRY(EN, "%01X", en, 0xf, 0) - COP410_STATE_ENTRY(G, "%01X", g, 0xf, 0) - COP440_STATE_ENTRY(H, "%01X", h, 0xf, 0) - COP410_STATE_ENTRY(Q, "%02X", q, 0xff, 0) - COP440_STATE_ENTRY(R, "%02X", r, 0xff, 0) - - COP410_STATE_ENTRY(SIO, "%01X", sio, 0xf, 0) - COP410_STATE_ENTRY(SKL, "%1u", skl, 0x1, 0) - - COP420_STATE_ENTRY(T, "%02X", t, 0xff, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - /*************************************************************************** MACROS ***************************************************************************/ @@ -256,8 +202,7 @@ static const cpu_state_table state_table_template = INLINE cop400_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_COP401 || cpu_get_type(device) == CPU_COP410 || cpu_get_type(device) == CPU_COP411 || @@ -271,12 +216,12 @@ INLINE cop400_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_COP426 || cpu_get_type(device) == CPU_COP444 || cpu_get_type(device) == CPU_COP445); - return (cop400_state *)device->token; + return (cop400_state *)downcast(device)->token(); } INLINE void PUSH(cop400_state *cpustate, UINT16 data) { - if (cpustate->state_table.subtypemask != COP410_FEATURE) + if (cpustate->featuremask != COP410_FEATURE) { SC = SB; } @@ -290,7 +235,7 @@ INLINE void POP(cop400_state *cpustate) PC = SA; SA = SB; - if (cpustate->state_table.subtypemask != COP410_FEATURE) + if (cpustate->featuremask != COP410_FEATURE) { SB = SC; } @@ -878,17 +823,59 @@ static TIMER_CALLBACK( microbus_tick ) INITIALIZATION ***************************************************************************/ +static void define_state_table(running_device *device) +{ + cop400_state *cpustate = get_safe_token(device); + + device_state_interface *state; + device->interface(state); + state->state_add(STATE_GENPC, "GENPC", cpustate->pc).mask(0xfff).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", cpustate->prevpc).mask(0xfff).noshow(); + state->state_add(STATE_GENSP, "GENSP", cpustate->n).mask(0x3).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).mask(0x3).callimport().callexport().noshow().formatstr("%2s"); + + state->state_add(COP400_PC, "PC", cpustate->pc).mask(0xfff); + + if (cpustate->featuremask & (COP410_FEATURE | COP420_FEATURE | COP444_FEATURE)) + { + state->state_add(COP400_SA, "SA", cpustate->sa).mask(0xfff); + state->state_add(COP400_SB, "SB", cpustate->sb).mask(0xfff); + if (cpustate->featuremask & (COP420_FEATURE | COP444_FEATURE)) + state->state_add(COP400_SC, "SC", cpustate->sc).mask(0xfff); + } + if (cpustate->featuremask & COP440_FEATURE) + state->state_add(COP400_N, "N", cpustate->n).mask(0x3); + + state->state_add(COP400_A, "A", cpustate->a).mask(0xf); + state->state_add(COP400_B, "B", cpustate->b); + state->state_add(COP400_C, "C", cpustate->c).mask(0x1); + + state->state_add(COP400_EN, "EN", cpustate->en).mask(0xf); + state->state_add(COP400_G, "G", cpustate->g).mask(0xf); + if (cpustate->featuremask & COP440_FEATURE) + state->state_add(COP400_H, "H", cpustate->h).mask(0xf); + state->state_add(COP400_Q, "Q", cpustate->q); + if (cpustate->featuremask & COP440_FEATURE) + state->state_add(COP400_R, "R", cpustate->r); + + state->state_add(COP400_SIO, "SIO", cpustate->sio).mask(0xf); + state->state_add(COP400_SKL, "SKL", cpustate->skl).mask(0x1); + + if (cpustate->featuremask & (COP420_FEATURE | COP444_FEATURE | COP440_FEATURE)) + state->state_add(COP400_T, "T", cpustate->t); +} + static void cop400_init(running_device *device, UINT8 g_mask, UINT8 d_mask, UINT8 in_mask, int has_counter, int has_inil) { cop400_state *cpustate = get_safe_token(device); - cpustate->intf = (cop400_interface *) device->baseconfig().static_config; + cpustate->intf = (cop400_interface *) device->baseconfig().static_config(); /* find address spaces */ - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); /* set output pin masks */ @@ -899,14 +886,14 @@ static void cop400_init(running_device *device, UINT8 g_mask, UINT8 d_mask, UINT /* allocate serial timer */ cpustate->serial_timer = timer_alloc(device->machine, serial_tick, cpustate); - timer_adjust_periodic(cpustate->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); + timer_adjust_periodic(cpustate->serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock() / 16)); /* allocate counter timer */ if (has_counter) { cpustate->counter_timer = timer_alloc(device->machine, counter_tick, cpustate); - timer_adjust_periodic(cpustate->counter_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16 / 4)); + timer_adjust_periodic(cpustate->counter_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock() / 16 / 4)); } /* allocate IN latch timer */ @@ -914,7 +901,7 @@ static void cop400_init(running_device *device, UINT8 g_mask, UINT8 d_mask, UINT if (has_inil) { cpustate->inil_timer = timer_alloc(device->machine, inil_tick, cpustate); - timer_adjust_periodic(cpustate->inil_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); + timer_adjust_periodic(cpustate->inil_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock() / 16)); } /* allocate Microbus timer */ @@ -922,7 +909,7 @@ static void cop400_init(running_device *device, UINT8 g_mask, UINT8 d_mask, UINT if (cpustate->intf->microbus == COP400_MICROBUS_ENABLED) { cpustate->microbus_timer = timer_alloc(device->machine, microbus_tick, cpustate); - timer_adjust_periodic(cpustate->microbus_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 16)); + timer_adjust_periodic(cpustate->microbus_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock() / 16)); } /* register for state saving */ @@ -962,9 +949,8 @@ static void cop410_init_opcodes(running_device *device) /* set up the state table */ - cpustate->state_table = state_table_template; - cpustate->state_table.baseptr = cpustate; - cpustate->state_table.subtypemask = COP410_FEATURE; + cpustate->featuremask = COP410_FEATURE; + define_state_table(device); /* initialize instruction length array */ @@ -993,9 +979,8 @@ static void cop420_init_opcodes(running_device *device) /* set up the state table */ - cpustate->state_table = state_table_template; - cpustate->state_table.baseptr = cpustate; - cpustate->state_table.subtypemask = COP420_FEATURE; + cpustate->featuremask = COP420_FEATURE; + define_state_table(device); /* initialize instruction length array */ @@ -1028,9 +1013,8 @@ static void cop444_init_opcodes(running_device *device) /* set up the state table */ - cpustate->state_table = state_table_template; - cpustate->state_table.baseptr = cpustate; - cpustate->state_table.subtypemask = COP444_FEATURE; + cpustate->featuremask = COP444_FEATURE; + define_state_table(device); /* initialize instruction length array */ @@ -1287,6 +1271,7 @@ ADDRESS_MAP_END VALIDITY CHECKS ***************************************************************************/ +#if 0 static CPU_VALIDITY_CHECK( cop410 ) { int error = FALSE; @@ -1342,11 +1327,52 @@ static CPU_VALIDITY_CHECK( cop444 ) return error; } +#endif /*************************************************************************** GENERAL CONTEXT ACCESS ***************************************************************************/ +static CPU_IMPORT_STATE( cop400 ) +{ + cop400_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->c = (cpustate->flags >> 1) & 1; + cpustate->skl = (cpustate->flags >> 0) & 1; + break; + } +} + +static CPU_EXPORT_STATE( cop400 ) +{ + cop400_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->flags = (cpustate->c ? 0x02 : 0x00) | + (cpustate->skl ? 0x01 : 0x00); + break; + } +} + +static CPU_EXPORT_STRING( cop400 ) +{ + cop400_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c", + cpustate->c ? 'C' : '.', + cpustate->skl ? 'S' : '.'); + break; + } +} + static CPU_SET_INFO( cop400 ) { /* nothing to set */ @@ -1354,8 +1380,8 @@ static CPU_SET_INFO( cop400 ) static CPU_GET_INFO( cop400 ) { - cop400_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - cop400_interface *intf = (devconfig->static_config != NULL) ? (cop400_interface *)devconfig->static_config : NULL; + cop400_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; + cop400_interface *intf = (devconfig->static_config() != NULL) ? (cop400_interface *)devconfig->static_config() : NULL; switch (state) { @@ -1387,11 +1413,13 @@ static CPU_GET_INFO( cop400 ) case CPUINFO_FCT_RESET: info->reset = CPU_RESET_NAME(cop400); break; case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(cop400); break; case CPUINFO_FCT_DISASSEMBLE: /* set per-core */ break; - case CPUINFO_FCT_VALIDITY_CHECK: /* set per-core */ break; +// case CPUINFO_FCT_VALIDITY_CHECK: /* set per-core */ break; + case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(cop400); break; + case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(cop400); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(cop400); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state_table; break; case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: /* set per-core */ break; case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: /* set per-core */ break; @@ -1410,8 +1438,6 @@ static CPU_GET_INFO( cop400 ) CPU_GET_INFO( cop410 ) { - cop400_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1421,7 +1447,7 @@ CPU_GET_INFO( cop410 ) /* --- the following bits of info are returned as pointers to functions --- */ case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop410); break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop410); break; - case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop410); break; +// case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop410); break; /* --- the following bits of info are returned as pointers --- */ case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_512b); break; @@ -1430,11 +1456,6 @@ CPU_GET_INFO( cop410 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "COP410"); break; - case CPUINFO_STR_FLAGS: sprintf(info->s, - "%c%c", - cpustate->c ? 'C' : '.', - cpustate->skl ? 'S' : '.'); break; - default: CPU_GET_INFO_CALL(cop400); break; } } @@ -1473,7 +1494,7 @@ CPU_GET_INFO( cop401 ) CPU_GET_INFO( cop420 ) { - cop400_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + cop400_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1484,7 +1505,7 @@ CPU_GET_INFO( cop420 ) /* --- the following bits of info are returned as pointers to functions --- */ case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop420); break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop420); break; - case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop420); break; +// case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop420); break; /* --- the following bits of info are returned as pointers --- */ case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_1kb); break; @@ -1511,7 +1532,7 @@ CPU_GET_INFO( cop421 ) { /* --- the following bits of info are returned as pointers to data or functions --- */ case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop421); break; - case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop421); break; +// case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop421); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "COP421"); break; @@ -1554,7 +1575,7 @@ CPU_GET_INFO( cop402 ) CPU_GET_INFO( cop444 ) { - cop400_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + cop400_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1565,7 +1586,7 @@ CPU_GET_INFO( cop444 ) /* --- the following bits of info are returned as pointers to functions --- */ case CPUINFO_FCT_INIT: info->init = CPU_INIT_NAME(cop444); break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(cop444); break; - case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop444); break; +// case CPUINFO_FCT_VALIDITY_CHECK: info->validity_check = CPU_VALIDITY_CHECK_NAME(cop444); break; /* --- the following bits of info are returned as pointers --- */ case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_2kb); break; diff --git a/src/emu/cpu/cop400/cop400.h b/src/emu/cpu/cop400/cop400.h index 7d9fadc5dec..b1fd37b1331 100644 --- a/src/emu/cpu/cop400/cop400.h +++ b/src/emu/cpu/cop400/cop400.h @@ -37,9 +37,9 @@ enum COP400_SIO, COP400_SKL, COP400_T, - COP400_GENPC = REG_GENPC, - COP400_GENPCBASE = REG_GENPCBASE, - COP400_GENSP = REG_GENSP + COP400_GENPC = STATE_GENPC, + COP400_GENPCBASE = STATE_GENPCBASE, + COP400_GENSP = STATE_GENSP }; /* special I/O space ports */ diff --git a/src/emu/cpu/cp1610/cp1610.c b/src/emu/cpu/cp1610/cp1610.c index d6bef729de0..d74afc947ee 100644 --- a/src/emu/cpu/cp1610/cp1610.c +++ b/src/emu/cpu/cp1610/cp1610.c @@ -37,7 +37,7 @@ struct _cp1610_state UINT8 flags; /* flags */ int intr_enabled; //int (*reset_callback)(cp1610_state *cpustate); - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; UINT16 intr_vector; int reset_state; int intr_state; @@ -54,10 +54,9 @@ struct _cp1610_state INLINE cp1610_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CP1610); - return (cp1610_state *)device->token; + return (cp1610_state *)downcast(device)->token(); } #define cp1610_readop(A) memory_read_word_16be(cpustate->program, (A)<<1) @@ -3395,7 +3394,7 @@ static CPU_INIT( cp1610 ) cpustate->intrm_pending = 0; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item_array(device, 0, cpustate->r); state_save_register_device_item(device, 0, cpustate->flags); @@ -3460,7 +3459,7 @@ static CPU_SET_INFO( cp1610 ) CPU_GET_INFO( cp1610 ) { - cp1610_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + cp1610_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/cubeqcpu/cubeqcpu.c b/src/emu/cpu/cubeqcpu/cubeqcpu.c index f6c07541683..ac3d21d14ea 100644 --- a/src/emu/cpu/cubeqcpu/cubeqcpu.c +++ b/src/emu/cpu/cubeqcpu/cubeqcpu.c @@ -196,28 +196,25 @@ typedef struct INLINE cquestsnd_state *get_safe_token_snd(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CQUESTSND); - return (cquestsnd_state *)device->token; + return (cquestsnd_state *)downcast(device)->token(); } INLINE cquestrot_state *get_safe_token_rot(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CQUESTROT); - return (cquestrot_state *)device->token; + return (cquestrot_state *)downcast(device)->token(); } INLINE cquestlin_state *get_safe_token_lin(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_CQUESTLIN); - return (cquestlin_state *)device->token; + return (cquestlin_state *)downcast(device)->token(); } /*************************************************************************** @@ -284,7 +281,7 @@ static void cquestsnd_state_register(running_device *device) static CPU_INIT( cquestsnd ) { cquestsnd_state *cpustate = get_safe_token_snd(device); - cubeqst_snd_config* _config = (cubeqst_snd_config*)device->baseconfig().static_config; + cubeqst_snd_config* _config = (cubeqst_snd_config*)device->baseconfig().static_config(); memset(cpustate, 0, sizeof(*cpustate)); @@ -292,7 +289,7 @@ static CPU_INIT( cquestsnd ) cpustate->sound_data = (UINT16*)memory_region(device->machine, _config->sound_data_region); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* Allocate RAM shared with 68000 */ cpustate->sram = auto_alloc_array(device->machine, UINT16, 4096/2); @@ -356,7 +353,7 @@ static void cquestrot_state_register(running_device *device) static CPU_INIT( cquestrot ) { - const cubeqst_rot_config *rotconfig = (const cubeqst_rot_config *)device->baseconfig().static_config; + const cubeqst_rot_config *rotconfig = (const cubeqst_rot_config *)device->baseconfig().static_config(); cquestrot_state *cpustate = get_safe_token_rot(device); memset(cpustate, 0, sizeof(*cpustate)); @@ -366,7 +363,7 @@ static CPU_INIT( cquestrot ) cpustate->device = device; cpustate->lindevice = device->machine->device(rotconfig->lin_cpu_tag); - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); cquestrot_state_register(device); } @@ -439,7 +436,7 @@ static void cquestlin_state_register(running_device *device) static CPU_INIT( cquestlin ) { - const cubeqst_lin_config *linconfig = (const cubeqst_lin_config *)device->baseconfig().static_config; + const cubeqst_lin_config *linconfig = (const cubeqst_lin_config *)device->baseconfig().static_config(); cquestlin_state *cpustate = get_safe_token_lin(device); memset(cpustate, 0, sizeof(*cpustate)); @@ -451,7 +448,7 @@ static CPU_INIT( cquestlin ) cpustate->device = device; cpustate->rotdevice = device->machine->device(linconfig->rot_cpu_tag); - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); cquestlin_state_register(device); } @@ -1600,7 +1597,7 @@ static CPU_SET_INFO( cquestsnd ) CPU_GET_INFO( cquestsnd ) { - cquestsnd_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token_snd(device) : NULL; + cquestsnd_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token_snd(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1718,7 +1715,7 @@ static CPU_SET_INFO( cquestrot ) CPU_GET_INFO( cquestrot ) { - cquestrot_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token_rot(device) : NULL; + cquestrot_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token_rot(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1836,7 +1833,7 @@ static CPU_SET_INFO( cquestlin ) CPU_GET_INFO( cquestlin ) { - cquestlin_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token_lin(device) : NULL; + cquestlin_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token_lin(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/drcbec.c b/src/emu/cpu/drcbec.c index cfae7a70918..f8d43a354bf 100644 --- a/src/emu/cpu/drcbec.c +++ b/src/emu/cpu/drcbec.c @@ -353,7 +353,7 @@ static drcbe_state *drcbec_alloc(drcuml_state *drcuml, drccache *cache, running_ /* remember our pointers */ drcbe->device = device; for (spacenum = 0; spacenum < ARRAY_LENGTH(drcbe->space); spacenum++) - drcbe->space[spacenum] = device->space(spacenum); + drcbe->space[spacenum] = device_memory(device)->space(spacenum); drcbe->drcuml = drcuml; drcbe->cache = cache; diff --git a/src/emu/cpu/drcbex64.c b/src/emu/cpu/drcbex64.c index cd9c97524a4..9753c7d8080 100644 --- a/src/emu/cpu/drcbex64.c +++ b/src/emu/cpu/drcbex64.c @@ -714,7 +714,7 @@ static drcbe_state *drcbex64_alloc(drcuml_state *drcuml, drccache *cache, runnin /* get address spaces and accessors */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - drcbe->space[spacenum] = device->space(spacenum); + drcbe->space[spacenum] = device_memory(device)->space(spacenum); if (drcbe->space[spacenum] != NULL) drcbe->accessors[spacenum] = drcbe->space[spacenum]->accessors; } diff --git a/src/emu/cpu/drcbex86.c b/src/emu/cpu/drcbex86.c index 5fbce56fb2b..61b3e74ac92 100644 --- a/src/emu/cpu/drcbex86.c +++ b/src/emu/cpu/drcbex86.c @@ -631,7 +631,7 @@ static drcbe_state *drcbex86_alloc(drcuml_state *drcuml, drccache *cache, runnin /* get address spaces */ for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - drcbe->space[spacenum] = device->space(spacenum); + drcbe->space[spacenum] = device_memory(device)->space(spacenum); /* allocate hash tables */ drcbe->hash = drchash_alloc(cache, modes, addrbits, ignorebits); diff --git a/src/emu/cpu/drcfe.c b/src/emu/cpu/drcfe.c index f1ab974d6bd..43b73f089c6 100644 --- a/src/emu/cpu/drcfe.c +++ b/src/emu/cpu/drcfe.c @@ -54,10 +54,9 @@ struct _drcfe_state void * param; /* parameter for the callback */ /* CPU parameters */ - running_device *device; /* CPU device object */ + cpu_device * cpudevice; /* CPU device object */ const address_space *program; /* program address space for this CPU */ offs_t pageshift; /* shift to convert address to a page index */ - cpu_translate_func translate; /* pointer to translation function */ /* opcode descriptor arrays */ opcode_desc * desc_live_list; /* head of list of live descriptions */ @@ -95,7 +94,7 @@ INLINE opcode_desc *desc_alloc(drcfe_state *drcfe) if (desc != NULL) drcfe->desc_free_list = desc->next; else - desc = auto_alloc(drcfe->device->machine, opcode_desc); + desc = auto_alloc(drcfe->cpudevice->machine, opcode_desc); return desc; } @@ -139,10 +138,9 @@ drcfe_state *drcfe_init(running_device *cpu, const drcfe_config *config, void *p drcfe->param = param; /* initialize the state */ - drcfe->device = cpu; - drcfe->program = cpu->space(AS_PROGRAM); - drcfe->pageshift = cpu_get_page_shift(cpu, ADDRESS_SPACE_PROGRAM); - drcfe->translate = (cpu_translate_func)cpu->get_config_fct(CPUINFO_FCT_TRANSLATE); + drcfe->cpudevice = downcast(cpu); + drcfe->program = device_memory(cpu)->space(AS_PROGRAM); + drcfe->pageshift = device_memory(cpu)->space_config(AS_PROGRAM)->m_page_shift; return drcfe; } @@ -162,14 +160,14 @@ void drcfe_exit(drcfe_state *drcfe) { opcode_desc *freeme = drcfe->desc_free_list; drcfe->desc_free_list = drcfe->desc_free_list->next; - auto_free(drcfe->device->machine, freeme); + auto_free(drcfe->cpudevice->machine, freeme); } /* free the description array */ - auto_free(drcfe->device->machine, drcfe->desc_array); + auto_free(drcfe->cpudevice->machine, drcfe->desc_array); /* free the object itself */ - auto_free(drcfe->device->machine, drcfe); + auto_free(drcfe->cpudevice->machine, drcfe); } diff --git a/src/emu/cpu/drcuml.c b/src/emu/cpu/drcuml.c index ca466e16371..7d38967cb15 100644 --- a/src/emu/cpu/drcuml.c +++ b/src/emu/cpu/drcuml.c @@ -1134,6 +1134,7 @@ void drcuml_disasm(const drcuml_instruction *inst, char *buffer, drcuml_state *d static const char *const pound_size[] = { "?", "?", "?", "?", "s", "?", "?", "?", "d" }; static const char *const bang_size[] = { "?", "b", "h", "?", "", "?", "?", "?", "d" }; static const char *const fmods[] = { "trunc", "round", "ceil", "floor", "default" }; + static const char *const spaces[] = { "program", "data", "io", "3", "4", "5", "6", "7" }; static const char *const sizes[] = { "byte", "word", "dword", "qword" }; const drcuml_opcode_info *opinfo = opcode_info_table[inst->opcode]; char *dest = buffer; @@ -1179,11 +1180,11 @@ void drcuml_disasm(const drcuml_instruction *inst, char *buffer, drcuml_state *d /* address space immediate */ else if (typemask == PTYPES_SPACE) - dest += sprintf(dest, "%s", address_space_names[param->value]); + dest += sprintf(dest, "%s", spaces[param->value]); /* size + address space immediate */ else if (typemask == PTYPES_SPSZ) - dest += sprintf(dest, "%s_%s", address_space_names[param->value / 16], sizes[param->value % 16]); + dest += sprintf(dest, "%s_%s", spaces[param->value / 16], sizes[param->value % 16]); /* size + scale immediate */ else if (typemask == PTYPES_SCSZ) diff --git a/src/emu/cpu/dsp32/dsp32.c b/src/emu/cpu/dsp32/dsp32.c index e5c064034b4..bef89c8b92e 100644 --- a/src/emu/cpu/dsp32/dsp32.c +++ b/src/emu/cpu/dsp32/dsp32.c @@ -205,10 +205,9 @@ static CPU_RESET( dsp32c ); INLINE dsp32_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_DSP32C); - return (dsp32_state *)device->token; + return (dsp32_state *)downcast(device)->token(); } @@ -352,7 +351,7 @@ static void dsp32_register_save( running_device *device ) static CPU_INIT( dsp32c ) { - const dsp32_config *configdata = (const dsp32_config *)device->baseconfig().static_config; + const dsp32_config *configdata = (const dsp32_config *)device->baseconfig().static_config(); dsp32_state *cpustate = get_safe_token(device); /* copy in config data */ @@ -360,7 +359,7 @@ static CPU_INIT( dsp32c ) cpustate->output_pins_changed = configdata->output_pins_changed; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); dsp32_register_save(device); } @@ -766,7 +765,7 @@ static CPU_SET_INFO( dsp32c ) CPU_GET_INFO( dsp32c ) { - dsp32_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + dsp32_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/dsp56k/dsp56def.h b/src/emu/cpu/dsp56k/dsp56def.h index 899e94d6f5a..213d9669e94 100644 --- a/src/emu/cpu/dsp56k/dsp56def.h +++ b/src/emu/cpu/dsp56k/dsp56def.h @@ -415,8 +415,7 @@ static void PCD_set(dsp56k_core* cpustate, UINT16 value); INLINE dsp56k_core *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_DSP56156); - return (dsp56k_core *)device->token; + return (dsp56k_core *)downcast(device)->token(); } diff --git a/src/emu/cpu/dsp56k/dsp56k.c b/src/emu/cpu/dsp56k/dsp56k.c index a5c03177b67..15215a1b464 100644 --- a/src/emu/cpu/dsp56k/dsp56k.c +++ b/src/emu/cpu/dsp56k/dsp56k.c @@ -232,11 +232,11 @@ static CPU_INIT( dsp56k ) state_save_register_device_item(device, 0, cpustate->HI.trxl); state_save_register_device_item(device, 0, cpustate->HI.bootstrap_offset); - //cpustate->config = device->baseconfig().static_config; + //cpustate->config = device->baseconfig().static_config(); //cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); /* Setup the direct memory handler for this CPU */ /* NOTE: Be sure to grab this guy and call him if you ever install another direct_update_hander in a driver! */ @@ -436,7 +436,7 @@ static CPU_SET_INFO( dsp56k ) CPU_GET_INFO( dsp56k ) { - dsp56k_core* cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + dsp56k_core* cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/dsp56k/dsp56mem.c b/src/emu/cpu/dsp56k/dsp56mem.c index a8ef6455611..c25f746c1cd 100644 --- a/src/emu/cpu/dsp56k/dsp56mem.c +++ b/src/emu/cpu/dsp56k/dsp56mem.c @@ -31,7 +31,7 @@ static void mem_reset(dsp56k_core* cpustate) /* Work */ static READ16_HANDLER( peripheral_register_r ) { - dsp56k_core* cpustate = (dsp56k_core*)space->cpu->token; + dsp56k_core* cpustate = get_safe_token(space->cpu); // (printf) logerror("Peripheral read 0x%04x\n", O2A(offset)); switch (O2A(offset)) @@ -166,7 +166,7 @@ static READ16_HANDLER( peripheral_register_r ) static WRITE16_HANDLER( peripheral_register_w ) { - dsp56k_core* cpustate = (dsp56k_core*)space->cpu->token; + dsp56k_core* cpustate = get_safe_token(space->cpu); // Its primary behavior is RAM // COMBINE_DATA(&dsp56k_peripheral_ram[offset]); diff --git a/src/emu/cpu/e132xs/e132xs.c b/src/emu/cpu/e132xs/e132xs.c index c48cb1ca1fe..b6292c81caf 100644 --- a/src/emu/cpu/e132xs/e132xs.c +++ b/src/emu/cpu/e132xs/e132xs.c @@ -318,7 +318,7 @@ struct _hyperstone_state struct _delay delay; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -416,8 +416,7 @@ ADDRESS_MAP_END INLINE hyperstone_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_E116T || cpu_get_type(device) == CPU_E116XT || cpu_get_type(device) == CPU_E116XS || @@ -432,7 +431,7 @@ INLINE hyperstone_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_GMS30C2132 || cpu_get_type(device) == CPU_GMS30C2216 || cpu_get_type(device) == CPU_GMS30C2232); - return (hyperstone_state *)device->token; + return (hyperstone_state *)downcast(device)->token(); } /* Return the entry point for a determinated trap */ @@ -1528,7 +1527,7 @@ static void set_irq_line(hyperstone_state *cpustate, int irqline, int state) ISR &= ~(1 << irqline); } -static void hyperstone_init(running_device *device, cpu_irq_callback irqcallback, int scale_mask) +static void hyperstone_init(running_device *device, device_irq_callback irqcallback, int scale_mask) { hyperstone_state *cpustate = get_safe_token(device); @@ -1544,13 +1543,13 @@ static void hyperstone_init(running_device *device, cpu_irq_callback irqcallback cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->timer = timer_alloc(device->machine, e132xs_timer_callback, (void *)device); cpustate->clock_scale_mask = scale_mask; } -static void e116_init(running_device *device, cpu_irq_callback irqcallback, int scale_mask) +static void e116_init(running_device *device, device_irq_callback irqcallback, int scale_mask) { hyperstone_state *cpustate = get_safe_token(device); hyperstone_init(device, irqcallback, scale_mask); @@ -1587,7 +1586,7 @@ static CPU_INIT( gms30c2216 ) e116_init(device, irqcallback, 0); } -static void e132_init(running_device *device, cpu_irq_callback irqcallback, int scale_mask) +static void e132_init(running_device *device, device_irq_callback irqcallback, int scale_mask) { hyperstone_state *cpustate = get_safe_token(device); hyperstone_init(device, irqcallback, scale_mask); @@ -1641,7 +1640,7 @@ static CPU_RESET( hyperstone ) //TODO: Add different reset initializations for BCR, MCR, FCR, TPR emu_timer *save_timer; - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; UINT32 save_opcodexor; save_timer = cpustate->timer; @@ -1651,8 +1650,8 @@ static CPU_RESET( hyperstone ) cpustate->irq_callback = save_irqcallback; cpustate->opcodexor = save_opcodexor; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->timer = save_timer; cpustate->tr_clocks_per_tick = 2; @@ -4844,7 +4843,7 @@ static CPU_SET_INFO( hyperstone ) static CPU_GET_INFO( hyperstone ) { - hyperstone_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + hyperstone_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/esrip/esrip.c b/src/emu/cpu/esrip/esrip.c index 7c1142cef4e..b3c78476098 100644 --- a/src/emu/cpu/esrip/esrip.c +++ b/src/emu/cpu/esrip/esrip.c @@ -123,10 +123,9 @@ typedef struct INLINE esrip_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ESRIP); - return (esrip_state *)device->token; + return (esrip_state *)downcast(device)->token(); } @@ -250,7 +249,7 @@ static void make_ops(esrip_state *cpustate) static CPU_INIT( esrip ) { esrip_state *cpustate = get_safe_token(device); - esrip_config* _config = (esrip_config*)device->baseconfig().static_config; + esrip_config* _config = (esrip_config*)device->baseconfig().static_config(); memset(cpustate, 0, sizeof(cpustate)); @@ -265,7 +264,7 @@ static CPU_INIT( esrip ) cpustate->ipt_ram = auto_alloc_array(device->machine, UINT16, IPT_RAM_SIZE/2); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* Create the instruction decode lookup table */ cpustate->optable = auto_alloc_array(device->machine, UINT8, 65536); @@ -356,7 +355,7 @@ static CPU_EXIT( esrip ) static int get_hblank(running_machine *machine) { - return video_screen_get_hblank(machine->primary_screen); + return machine->primary_screen->hblank(); } /* Return the state of the LBRM line (Y-scaling related) */ @@ -1891,7 +1890,7 @@ static CPU_SET_INFO( esrip ) CPU_GET_INFO( esrip ) { - esrip_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + esrip_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/f8/f8.c b/src/emu/cpu/f8/f8.c index 95079a45723..c6ff2362bfa 100644 --- a/src/emu/cpu/f8/f8.c +++ b/src/emu/cpu/f8/f8.c @@ -52,7 +52,7 @@ struct _f8_Regs UINT8 dbus; /* data bus value */ UINT16 io; /* last I/O address */ UINT16 irq_vector; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *iospace; @@ -64,10 +64,9 @@ struct _f8_Regs INLINE f8_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_F8); - return (f8_Regs *)device->token; + return (f8_Regs *)downcast(device)->token(); } /* timer shifter polynome values (will be used for timer interrupts) */ @@ -1546,14 +1545,14 @@ static CPU_RESET( f8 ) f8_Regs *cpustate = get_safe_token(device); UINT8 data; int i; - cpu_irq_callback save_callback; + device_irq_callback save_callback; save_callback = cpustate->irq_callback; memset(cpustate, 0, sizeof(f8_Regs)); cpustate->irq_callback = save_callback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->iospace = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->iospace = device_memory(device)->space(AS_IO); cpustate->w&=~I; /* save PC0 to PC1 and reset PC0 */ @@ -1902,8 +1901,8 @@ static CPU_INIT( f8 ) f8_Regs *cpustate = get_safe_token(device); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->iospace = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->iospace = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->pc0); state_save_register_device_item(device, 0, cpustate->pc1); @@ -2020,7 +2019,7 @@ static CPU_SET_INFO( f8 ) CPU_GET_INFO( f8 ) { - f8_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + f8_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/g65816/g65816.c b/src/emu/cpu/g65816/g65816.c index 953dd27c0b1..b238aa92ac3 100644 --- a/src/emu/cpu/g65816/g65816.c +++ b/src/emu/cpu/g65816/g65816.c @@ -98,10 +98,9 @@ TODO general: INLINE g65816i_cpu_struct *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_G65816 || cpu_get_type(device) == CPU_5A22); - return (g65816i_cpu_struct *)device->token; + return (g65816i_cpu_struct *)downcast(device)->token(); } /* Temporary Variables */ @@ -303,7 +302,7 @@ static void g65816_set_irq_line(g65816i_cpu_struct *cpustate, int line, int stat } /* Set the callback that is called when servicing an interrupt */ -static void g65816_set_irq_callback(g65816i_cpu_struct *cpustate, cpu_irq_callback callback) +static void g65816_set_irq_callback(g65816i_cpu_struct *cpustate, device_irq_callback callback) { INT_ACK = callback; } @@ -338,7 +337,7 @@ static CPU_INIT( g65816 ) g65816_set_irq_callback(cpustate, irqcallback); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); cpustate->cpu_type = CPU_TYPE_G65816; state_save_register_device_item(device, 0, cpustate->a); @@ -419,7 +418,7 @@ void g65816_set_read_vector_callback(running_device *device, read8_space_func re CPU_GET_INFO( g65816 ) { - g65816i_cpu_struct *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + g65816i_cpu_struct *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/g65816/g65816cm.h b/src/emu/cpu/g65816/g65816cm.h index b1743d4ebda..c463a3c6002 100644 --- a/src/emu/cpu/g65816/g65816cm.h +++ b/src/emu/cpu/g65816/g65816cm.h @@ -93,7 +93,7 @@ struct _g65816i_cpu_struct uint line_nmi; /* Status of the NMI line */ uint ir; /* Instruction Register */ uint irq_delay; /* delay 1 instruction before checking irq */ - cpu_irq_callback int_ack; /* Interrupt Acknowledge */ + device_irq_callback int_ack; /* Interrupt Acknowledge */ running_device *device; const address_space *program; read8_space_func read_vector; /* Read vector override */ diff --git a/src/emu/cpu/g65816/g65816op.h b/src/emu/cpu/g65816/g65816op.h index 6c281125129..9495214205f 100644 --- a/src/emu/cpu/g65816/g65816op.h +++ b/src/emu/cpu/g65816/g65816op.h @@ -2288,9 +2288,9 @@ TABLE_FUNCTION(uint, get_reg, (g65816i_cpu_struct *cpustate, int regnum)) case G65816_A: return REGISTER_B | REGISTER_A; case G65816_X: return REGISTER_X; case G65816_Y: return REGISTER_Y; - case REG_GENSP: return REGISTER_S; + case STATE_GENSP: return REGISTER_S; case G65816_S: return REGISTER_S; - case REG_GENPC: return REGISTER_PC; + case STATE_GENPC: return REGISTER_PC; case G65816_PC: return REGISTER_PC; case G65816_PB: return REGISTER_PB >> 16; case G65816_DB: return REGISTER_DB >> 16; @@ -2298,7 +2298,7 @@ TABLE_FUNCTION(uint, get_reg, (g65816i_cpu_struct *cpustate, int regnum)) case G65816_P: return g65816i_get_reg_p(cpustate); case G65816_NMI_STATE: return LINE_NMI; case G65816_IRQ_STATE: return LINE_IRQ; - case REG_GENPCBASE: return REGISTER_PPC; + case STATE_GENPCBASE: return REGISTER_PPC; } return 0; } @@ -2309,11 +2309,11 @@ TABLE_FUNCTION(void, set_reg, (g65816i_cpu_struct *cpustate, int regnum, uint va { switch(regnum) { - case REG_GENPC: case G65816_PC: REGISTER_PC = MAKE_UINT_16(val); break; + case STATE_GENPC: case G65816_PC: REGISTER_PC = MAKE_UINT_16(val); break; #if FLAG_SET_E - case REG_GENSP: case G65816_S: REGISTER_S = MAKE_UINT_8(val) | 0x100; break; + case STATE_GENSP: case G65816_S: REGISTER_S = MAKE_UINT_8(val) | 0x100; break; #else - case REG_GENSP: case G65816_S: REGISTER_S = MAKE_UINT_16(val); break; + case STATE_GENSP: case G65816_S: REGISTER_S = MAKE_UINT_16(val); break; #endif case G65816_P: g65816i_set_reg_p(cpustate, val); break; #if FLAG_SET_M diff --git a/src/emu/cpu/h6280/h6280.c b/src/emu/cpu/h6280/h6280.c index 496caad3c01..03077fb098d 100644 --- a/src/emu/cpu/h6280/h6280.c +++ b/src/emu/cpu/h6280/h6280.c @@ -120,10 +120,9 @@ static void set_irq_line(h6280_Regs* cpustate, int irqline, int state); INLINE h6280_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_H6280); - return (h6280_Regs *)device->token; + return (h6280_Regs *)downcast(device)->token(); } /* include the opcode macros, functions and function pointer tables */ @@ -163,15 +162,15 @@ static CPU_INIT( h6280 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); } static CPU_RESET( h6280 ) { h6280_Regs* cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; int i; /* wipe out the h6280 structure */ @@ -179,8 +178,8 @@ static CPU_RESET( h6280 ) memset(cpustate, 0, sizeof(h6280_Regs)); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* set I and B flags */ P = _fI | _fB; @@ -292,7 +291,7 @@ static void set_irq_line(h6280_Regs* cpustate, int irqline, int state) READ8_HANDLER( h6280_irq_status_r ) { int status; - h6280_Regs *cpustate = (h6280_Regs*)space->cpu->token; + h6280_Regs *cpustate = get_safe_token(space->cpu); switch (offset&3) { @@ -311,7 +310,7 @@ READ8_HANDLER( h6280_irq_status_r ) WRITE8_HANDLER( h6280_irq_status_w ) { - h6280_Regs *cpustate = (h6280_Regs*)space->cpu->token; + h6280_Regs *cpustate = get_safe_token(space->cpu); cpustate->io_buffer=data; switch (offset&3) { @@ -330,13 +329,13 @@ WRITE8_HANDLER( h6280_irq_status_w ) READ8_HANDLER( h6280_timer_r ) { /* only returns countdown */ - h6280_Regs *cpustate = (h6280_Regs*)space->cpu->token; + h6280_Regs *cpustate = get_safe_token(space->cpu); return ((cpustate->timer_value/1024)&0x7F)|(cpustate->io_buffer&0x80); } WRITE8_HANDLER( h6280_timer_w ) { - h6280_Regs *cpustate = (h6280_Regs*)space->cpu->token; + h6280_Regs *cpustate = get_safe_token(space->cpu); cpustate->io_buffer=data; switch (offset) { case 0: /* Counter preload */ @@ -426,7 +425,7 @@ static CPU_SET_INFO( h6280 ) CPU_GET_INFO( h6280 ) { - h6280_Regs* cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + h6280_Regs* cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/h6280/h6280.h b/src/emu/cpu/h6280/h6280.h index 6f5e57dc23a..fc652f94289 100644 --- a/src/emu/cpu/h6280/h6280.h +++ b/src/emu/cpu/h6280/h6280.h @@ -60,7 +60,7 @@ typedef struct UINT8 nmi_state; UINT8 irq_state[3]; UINT8 irq_pending; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; diff --git a/src/emu/cpu/h83002/h8_16.c b/src/emu/cpu/h83002/h8_16.c index 7ea9044dd50..c637afccf3c 100644 --- a/src/emu/cpu/h83002/h8_16.c +++ b/src/emu/cpu/h83002/h8_16.c @@ -220,8 +220,8 @@ static CPU_INIT(h8) h8->mode_8bit = 0; - h8->program = device->space(AS_PROGRAM); - h8->io = device->space(AS_IO); + h8->program = device_memory(device)->space(AS_PROGRAM); + h8->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, h8->h8err); state_save_register_device_item_array(device, 0, h8->regs); @@ -429,7 +429,7 @@ static CPU_SET_INFO( h8 ) static READ16_HANDLER( h8_itu_r ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -450,7 +450,7 @@ static READ16_HANDLER( h8_itu_r ) static WRITE16_HANDLER( h8_itu_w ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -470,7 +470,7 @@ static WRITE16_HANDLER( h8_itu_w ) static READ16_HANDLER( h8_3007_itu_r ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -490,7 +490,7 @@ static READ16_HANDLER( h8_3007_itu_r ) } static WRITE16_HANDLER( h8_3007_itu_w ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -510,7 +510,7 @@ static WRITE16_HANDLER( h8_3007_itu_w ) static READ16_HANDLER( h8_3007_itu1_r ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -530,7 +530,7 @@ static READ16_HANDLER( h8_3007_itu1_r ) } static WRITE16_HANDLER( h8_3007_itu1_w ) { - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -570,7 +570,7 @@ ADDRESS_MAP_END CPU_GET_INFO( h8_3002 ) { - h83xx_state *h8 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + h83xx_state *h8 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { // Interface functions and variables diff --git a/src/emu/cpu/h83002/h8_8.c b/src/emu/cpu/h83002/h8_8.c index c77841b7691..da8618fc0e9 100644 --- a/src/emu/cpu/h83002/h8_8.c +++ b/src/emu/cpu/h83002/h8_8.c @@ -237,8 +237,8 @@ static CPU_INIT(h8bit) h8->mode_8bit = 1; - h8->program = device->space(AS_PROGRAM); - h8->io = device->space(AS_IO); + h8->program = device_memory(device)->space(AS_PROGRAM); + h8->io = device_memory(device)->space(AS_IO); h8->timer[0] = timer_alloc(h8->device->machine, h8_timer_0_cb, h8); h8->timer[1] = timer_alloc(h8->device->machine, h8_timer_1_cb, h8); @@ -515,7 +515,7 @@ static READ8_HANDLER( h8330_itu_r ) UINT8 reg; UINT64 frc; static const UINT64 divider[4] = { 2, 8, 32, 1 }; - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); reg = (offset + 0x88) & 0xff; @@ -603,7 +603,7 @@ static READ8_HANDLER( h8330_itu_r ) static WRITE8_HANDLER( h8330_itu_w ) { UINT8 reg; - h83xx_state *h8 = (h83xx_state *)space->cpu->token; + h83xx_state *h8 = get_safe_token(space->cpu); reg = (offset + 0x88) & 0xff; @@ -751,7 +751,7 @@ ADDRESS_MAP_END CPU_GET_INFO( h8_3334 ) { - h83xx_state *h8 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + h83xx_state *h8 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { // Interface functions and variables diff --git a/src/emu/cpu/h83002/h8priv.h b/src/emu/cpu/h83002/h8priv.h index 87bfd64aa86..5f9091b3555 100644 --- a/src/emu/cpu/h83002/h8priv.h +++ b/src/emu/cpu/h83002/h8priv.h @@ -25,7 +25,7 @@ struct _h83xx_state UINT8 h8uflag, h8uiflag; UINT8 incheckirqs; - cpu_irq_callback irq_cb; + device_irq_callback irq_cb; running_device *device; const address_space *program; @@ -50,13 +50,12 @@ extern h83xx_state h8; INLINE h83xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_H83002 || cpu_get_type(device) == CPU_H83007 || cpu_get_type(device) == CPU_H83044 || cpu_get_type(device) == CPU_H83334); - return (h83xx_state *)device->token; + return (h83xx_state *)downcast(device)->token(); } UINT8 h8_register_read8(h83xx_state *h8, UINT32 address); diff --git a/src/emu/cpu/hd6309/hd6309.c b/src/emu/cpu/hd6309/hd6309.c index f14775c6d3e..7ac0dc1cfe1 100644 --- a/src/emu/cpu/hd6309/hd6309.c +++ b/src/emu/cpu/hd6309/hd6309.c @@ -131,7 +131,7 @@ struct _m68_state_t UINT8 irq_state[2]; int extra_cycles; /* cycles used up by interrupts */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; int icount; PAIR ea; /* effective address */ @@ -154,10 +154,9 @@ struct _m68_state_t INLINE m68_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_HD6309); - return (m68_state_t *)device->token; + return (m68_state_t *)downcast(device)->token(); } static void check_irq_lines( m68_state_t *m68_state ); @@ -523,7 +522,7 @@ static CPU_INIT( hd6309 ) m68_state->irq_callback = irqcallback; m68_state->device = device; - m68_state->program = device->space(AS_PROGRAM); + m68_state->program = device_memory(device)->space(AS_PROGRAM); /* setup regtable */ @@ -1259,7 +1258,7 @@ static CPU_SET_INFO( hd6309 ) CPU_GET_INFO( hd6309 ) { - m68_state_t *m68_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m68_state_t *m68_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/i386/i386.c b/src/emu/cpu/i386/i386.c index 5518e7bedaa..0b5686e1485 100644 --- a/src/emu/cpu/i386/i386.c +++ b/src/emu/cpu/i386/i386.c @@ -548,8 +548,8 @@ static CPU_INIT( i386 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item_array(device, 0, cpustate->reg.d); state_save_register_device_item(device, 0, cpustate->sreg[ES].selector); @@ -641,14 +641,14 @@ static void build_opcode_table(i386_state *cpustate, UINT32 features) static CPU_RESET( i386 ) { i386_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_irqcallback = cpustate->irq_callback; memset( cpustate, 0, sizeof(*cpustate) ); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sreg[CS].selector = 0xf000; cpustate->sreg[CS].base = 0xffff0000; @@ -870,7 +870,7 @@ static CPU_SET_INFO( i386 ) CPU_GET_INFO( i386 ) { - i386_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i386_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1097,14 +1097,14 @@ static CPU_INIT( i486 ) static CPU_RESET( i486 ) { i386_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_irqcallback = cpustate->irq_callback; memset( cpustate, 0, sizeof(*cpustate) ); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sreg[CS].selector = 0xf000; cpustate->sreg[CS].base = 0xffff0000; @@ -1165,7 +1165,7 @@ static CPU_SET_INFO( i486 ) CPU_GET_INFO( i486 ) { - i386_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i386_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(i486);break; @@ -1213,14 +1213,14 @@ static CPU_INIT( pentium ) static CPU_RESET( pentium ) { i386_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_irqcallback = cpustate->irq_callback; memset( cpustate, 0, sizeof(*cpustate) ); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sreg[CS].selector = 0xf000; cpustate->sreg[CS].base = 0xffff0000; @@ -1296,7 +1296,7 @@ static CPU_SET_INFO( pentium ) CPU_GET_INFO( pentium ) { - i386_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i386_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(pentium); break; @@ -1344,14 +1344,14 @@ static CPU_INIT( mediagx ) static CPU_RESET( mediagx ) { i386_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_irqcallback = cpustate->irq_callback; memset( cpustate, 0, sizeof(*cpustate) ); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sreg[CS].selector = 0xf000; cpustate->sreg[CS].base = 0xffff0000; @@ -1422,7 +1422,7 @@ static CPU_SET_INFO( mediagx ) CPU_GET_INFO( mediagx ) { - i386_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i386_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { case CPUINFO_FCT_SET_INFO: info->setinfo = CPU_SET_INFO_NAME(mediagx); break; diff --git a/src/emu/cpu/i386/i386priv.h b/src/emu/cpu/i386/i386priv.h index 98de137ce55..48c27d0a9ed 100644 --- a/src/emu/cpu/i386/i386priv.h +++ b/src/emu/cpu/i386/i386priv.h @@ -226,7 +226,7 @@ struct _i386_state UINT8 opcode; UINT8 irq_state; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -260,13 +260,12 @@ struct _i386_state INLINE i386_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I386 || cpu_get_type(device) == CPU_I486 || cpu_get_type(device) == CPU_PENTIUM || cpu_get_type(device) == CPU_MEDIAGX); - return (i386_state *)device->token; + return (i386_state *)downcast(device)->token(); } extern int i386_parity_table[256]; diff --git a/src/emu/cpu/i4004/i4004.c b/src/emu/cpu/i4004/i4004.c index 1d046d36ceb..8d74e4ecef8 100644 --- a/src/emu/cpu/i4004/i4004.c +++ b/src/emu/cpu/i4004/i4004.c @@ -31,12 +31,12 @@ struct _i4004_state UINT8 C; // Carry flag UINT8 TEST; // Test PIN status PAIR PC; // It is in fact one of ADDR regs + UINT8 flags; // used for I/O only running_device *device; const address_space *program; const address_space *data; const address_space *io; - cpu_state_table state; int icount; int pc_pos; // PC possition in ADDR int addr_mask; @@ -47,41 +47,6 @@ struct _i4004_state ***************************************************************************/ #define GET_PC (cpustate->ADDR[cpustate->pc_pos]) -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define I4004_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(I4004_##_name, #_name, _format, i4004_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - I4004_STATE_ENTRY(PC, "%03X", PC.w.l, 0x0fff, 0) - I4004_STATE_ENTRY(GENPC,"%03X", PC.w.l, 0x0fff, CPUSTATE_NOSHOW) - I4004_STATE_ENTRY(A, "%01X", A, 0x0f, 0) - I4004_STATE_ENTRY(R01, "%02X", R[0], 0xff, 0) - I4004_STATE_ENTRY(R23, "%02X", R[1], 0xff, 0) - I4004_STATE_ENTRY(R45, "%02X", R[2], 0xff, 0) - I4004_STATE_ENTRY(R67, "%02X", R[3], 0xff, 0) - I4004_STATE_ENTRY(R89, "%02X", R[4], 0xff, 0) - I4004_STATE_ENTRY(RAB, "%02X", R[5], 0xff, 0) - I4004_STATE_ENTRY(RCD, "%02X", R[6], 0xff, 0) - I4004_STATE_ENTRY(REF, "%02X", R[7], 0xff, 0) - I4004_STATE_ENTRY(ADDR1, "%03X", ADDR[0].w.l, 0x0fff, 0) - I4004_STATE_ENTRY(ADDR2, "%03X", ADDR[1].w.l, 0x0fff, 0) - I4004_STATE_ENTRY(ADDR3, "%03X", ADDR[2].w.l, 0x0fff, 0) - I4004_STATE_ENTRY(ADDR4, "%03X", ADDR[3].w.l, 0x0fff, 0) - I4004_STATE_ENTRY(RAM, "%03X", RAM.w.l, 0x0fff, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -89,10 +54,9 @@ static const cpu_state_table state_table_template = INLINE i4004_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I4004); - return (i4004_state *)device->token; + return (i4004_state *)downcast(device)->token(); } INLINE UINT8 ROP(i4004_state *cpustate) @@ -484,15 +448,29 @@ static CPU_INIT( i4004 ) i4004_state *cpustate = get_safe_token(device); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(I4004_PC, "PC", cpustate->PC.w.l).mask(0x0fff); + state->state_add(STATE_GENPC, "GENPC", cpustate->PC.w.l).mask(0x0fff).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).mask(0x0f).callimport().callexport().noshow().formatstr("%4s"); + state->state_add(I4004_A, "A", cpustate->A).mask(0x0f); + + astring tempstr; + for (int regnum = 0; regnum < 8; regnum++) + state->state_add(I4004_R01 + regnum, tempstr.format("R%X%X", regnum*2, regnum*2+1), cpustate->R[regnum]); + + for (int addrnum = 0; addrnum < 4; addrnum++) + state->state_add(I4004_ADDR1 + addrnum, tempstr.format("ADDR%d", addrnum + 1), cpustate->ADDR[addrnum].w.l).mask(0xfff); + + state->state_add(I4004_RAM, "RAM", cpustate->RAM.w.l).mask(0x0fff); + } cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->PC); state_save_register_device_item(device, 0, cpustate->A); @@ -543,10 +521,44 @@ static CPU_RESET( i4004 ) static CPU_IMPORT_STATE( i4004 ) { + i4004_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->C = (cpustate->flags >> 1) & 1; + cpustate->TEST = (cpustate->flags >> 0) & 1; + break; + } } static CPU_EXPORT_STATE( i4004 ) { + i4004_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->flags = ((cpustate->A == 0) ? 0x04 : 0x00) | + (cpustate->C ? 0x02 : 0x00) | + (cpustate->TEST ? 0x01 : 0x00); + break; + } +} + +static CPU_EXPORT_STRING( i4004 ) +{ + i4004_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf(".%c%c%c", + (cpustate->A==0) ? 'Z':'.', + cpustate->C ? 'C':'.', + cpustate->TEST ? 'T':'.'); + break; + } } /*************************************************************************** @@ -562,7 +574,7 @@ static CPU_SET_INFO( i4004 ) CPU_GET_INFO( i4004 ) { - i4004_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i4004_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -597,10 +609,10 @@ CPU_GET_INFO( i4004 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(i4004); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(i4004); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(i4004); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(i4004); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "4004"); break; @@ -608,12 +620,5 @@ CPU_GET_INFO( i4004 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Miodrag Milanovic"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, ".%c%c%c", - (cpustate->A==0) ? 'Z':'.', - cpustate->C ? 'C':'.', - cpustate->TEST ? 'T':'.'); - break; } } diff --git a/src/emu/cpu/i4004/i4004.h b/src/emu/cpu/i4004/i4004.h index c0a90116823..de76710d4ed 100644 --- a/src/emu/cpu/i4004/i4004.h +++ b/src/emu/cpu/i4004/i4004.h @@ -13,9 +13,9 @@ enum I4004_A, I4004_R01, I4004_R23, I4004_R45, I4004_R67, I4004_R89, I4004_RAB, I4004_RCD, I4004_REF, I4004_ADDR1,I4004_ADDR2,I4004_ADDR3,I4004_ADDR4,I4004_RAM, - I4004_GENPC = REG_GENPC, - I4004_GENSP = REG_GENSP, - I4004_GENPCBASE = REG_GENPCBASE + I4004_GENPC = STATE_GENPC, + I4004_GENSP = STATE_GENSP, + I4004_GENPCBASE = STATE_GENPCBASE }; /*************************************************************************** diff --git a/src/emu/cpu/i8008/i8008.c b/src/emu/cpu/i8008/i8008.c index 2cab3c57d04..4eddffe9034 100644 --- a/src/emu/cpu/i8008/i8008.c +++ b/src/emu/cpu/i8008/i8008.c @@ -32,14 +32,14 @@ struct _i8008_state UINT8 SF; // Sign flag UINT8 PF; // Parity flag UINT8 HALT; + UINT8 flags; // temporary I/O only running_device *device; const address_space *program; const address_space *io; - cpu_state_table state; int icount; int pc_pos; // PC possition in ADDR - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; UINT8 irq_state; }; @@ -50,42 +50,6 @@ struct _i8008_state #define REG_2 (opcode & 7) #define GET_PC (cpustate->ADDR[cpustate->pc_pos]) -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define I8008_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(I8008_##_name, #_name, _format, i8008_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - I8008_STATE_ENTRY(PC, "%04X", PC.w.l, 0x3fff, 0) - I8008_STATE_ENTRY(GENPC,"%04X", PC.w.l, 0x3fff, CPUSTATE_NOSHOW) - I8008_STATE_ENTRY(A, "%02X", A, 0xff, 0) - I8008_STATE_ENTRY(B, "%02X", B, 0xff, 0) - I8008_STATE_ENTRY(C, "%02X", C, 0xff, 0) - I8008_STATE_ENTRY(D, "%02X", D, 0xff, 0) - I8008_STATE_ENTRY(E, "%02X", E, 0xff, 0) - I8008_STATE_ENTRY(H, "%02X", H, 0xff, 0) - I8008_STATE_ENTRY(L, "%02X", L, 0xff, 0) - I8008_STATE_ENTRY(ADDR1, "%04X", ADDR[0].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR2, "%04X", ADDR[1].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR3, "%04X", ADDR[2].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR4, "%04X", ADDR[3].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR5, "%04X", ADDR[4].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR6, "%04X", ADDR[5].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR7, "%04X", ADDR[6].w.l, 0x0fff, 0) - I8008_STATE_ENTRY(ADDR8, "%04X", ADDR[7].w.l, 0x0fff, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -93,10 +57,9 @@ static const cpu_state_table state_table_template = INLINE i8008_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I8008); - return (i8008_state *)device->token; + return (i8008_state *)downcast(device)->token(); } INLINE void PUSH_STACK(i8008_state *cpustate) @@ -563,14 +526,29 @@ static CPU_INIT( i8008 ) i8008_state *cpustate = get_safe_token(device); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(I8008_PC, "PC", cpustate->PC.w.l).mask(0x3fff); + state->state_add(STATE_GENPC, "GENPC", cpustate->PC.w.l).mask(0x3fff).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).mask(0x0f).callimport().callexport().noshow().formatstr("%4s"); + state->state_add(I8008_A, "A", cpustate->A); + state->state_add(I8008_B, "B", cpustate->B); + state->state_add(I8008_C, "C", cpustate->C); + state->state_add(I8008_D, "D", cpustate->D); + state->state_add(I8008_E, "E", cpustate->E); + state->state_add(I8008_H, "H", cpustate->H); + state->state_add(I8008_L, "L", cpustate->L); + + astring tempstr; + for (int addrnum = 0; addrnum < 8; addrnum++) + state->state_add(I8008_ADDR1 + addrnum, tempstr.format("ADDR%d", addrnum + 1), cpustate->ADDR[addrnum].w.l).mask(0xfff); + } cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->irq_callback = irqcallback; @@ -635,10 +613,48 @@ static void set_irq_line(i8008_state *cpustate, int irqline, int state) static CPU_IMPORT_STATE( i8008 ) { + i8008_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->CF = (cpustate->flags >> 3) & 1; + cpustate->ZF = (cpustate->flags >> 2) & 1; + cpustate->SF = (cpustate->flags >> 1) & 1; + cpustate->PF = (cpustate->flags >> 0) & 1; + break; + } } static CPU_EXPORT_STATE( i8008 ) { + i8008_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + cpustate->flags = (cpustate->CF ? 0x08 : 0x00) | + (cpustate->ZF ? 0x04 : 0x00) | + (cpustate->SF ? 0x02 : 0x00) | + (cpustate->PF ? 0x01 : 0x00); + break; + } +} + +static CPU_EXPORT_STRING( i8008 ) +{ + i8008_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c", + cpustate->CF ? 'C':'.', + cpustate->ZF ? 'Z':'.', + cpustate->SF ? 'S':'.', + cpustate->PF ? 'P':'.'); + break; + } } /*************************************************************************** @@ -660,7 +676,7 @@ static CPU_SET_INFO( i8008 ) CPU_GET_INFO( i8008 ) { - i8008_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i8008_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -695,10 +711,10 @@ CPU_GET_INFO( i8008 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(i8008); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(i8008); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(i8008); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(i8008); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "8008"); break; @@ -706,13 +722,5 @@ CPU_GET_INFO( i8008 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Miodrag Milanovic"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c", - cpustate->CF ? 'C':'.', - cpustate->ZF ? 'Z':'.', - cpustate->SF ? 'S':'.', - cpustate->PF ? 'P':'.'); - break; } } diff --git a/src/emu/cpu/i8008/i8008.h b/src/emu/cpu/i8008/i8008.h index 81083179fc8..78f06d2b71b 100644 --- a/src/emu/cpu/i8008/i8008.h +++ b/src/emu/cpu/i8008/i8008.h @@ -12,9 +12,9 @@ enum I8008_PC, I8008_A,I8008_B,I8008_C,I8008_D,I8008_E,I8008_H,I8008_L, I8008_ADDR1,I8008_ADDR2,I8008_ADDR3,I8008_ADDR4,I8008_ADDR5,I8008_ADDR6,I8008_ADDR7,I8008_ADDR8, - I8008_GENPC = REG_GENPC, - I8008_GENSP = REG_GENSP, - I8008_GENPCBASE = REG_GENPCBASE + I8008_GENPC = STATE_GENPC, + I8008_GENSP = STATE_GENSP, + I8008_GENPCBASE = STATE_GENPCBASE }; /*************************************************************************** diff --git a/src/emu/cpu/i8085/i8085.c b/src/emu/cpu/i8085/i8085.c index 707470bdbab..e36aa7c7662 100644 --- a/src/emu/cpu/i8085/i8085.c +++ b/src/emu/cpu/i8085/i8085.c @@ -182,62 +182,15 @@ struct _i8085_state UINT8 ietemp; /* import/export temp space */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; - cpu_state_table state; int icount; }; -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define I8085_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(I8085_##_name, #_name, _format, i8085_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - I8085_STATE_ENTRY(PC, "%04X", PC.w.l, 0xffff, 0) - I8085_STATE_ENTRY(GENPC, "%04X", PC.w.l, 0xffff, CPUSTATE_NOSHOW) -// I8085_STATE_ENTRY(GENPCBASE, "%04X", prvpc.w.l, 0xffff, CPUSTATE_NOSHOW) - - I8085_STATE_ENTRY(SP, "%04X", SP.w.l, 0xffff, 0) - I8085_STATE_ENTRY(GENSP, "%04X", SP.w.l, 0xffff, CPUSTATE_NOSHOW) - - I8085_STATE_ENTRY(A, "%02X", AF.b.h, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(B, "%02X", BC.b.h, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(C, "%02X", BC.b.l, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(D, "%02X", DE.b.h, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(E, "%02X", DE.b.l, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(F, "%02X", AF.b.l, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(H, "%02X", HL.b.h, 0xff, CPUSTATE_NOSHOW) - I8085_STATE_ENTRY(L, "%02X", HL.b.l, 0xff, CPUSTATE_NOSHOW) - - I8085_STATE_ENTRY(AF, "%04X", AF.w.l, 0xffff, 0) - I8085_STATE_ENTRY(BC, "%04X", BC.w.l, 0xffff, 0) - I8085_STATE_ENTRY(DE, "%04X", DE.w.l, 0xffff, 0) - I8085_STATE_ENTRY(HL, "%04X", HL.w.l, 0xffff, 0) - - I8085_STATE_ENTRY(STATUS, "%02X", STATUS, 0xff, 0) - I8085_STATE_ENTRY(SOD, "%1u", sod_state, 0x1, 0) - I8085_STATE_ENTRY(SID, "%1u", ietemp, 0x1, CPUSTATE_EXPORT | CPUSTATE_IMPORT) - I8085_STATE_ENTRY(INTE, "%1u", ietemp, 0x1, CPUSTATE_EXPORT | CPUSTATE_IMPORT) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - - /*************************************************************************** MACROS ***************************************************************************/ @@ -322,11 +275,10 @@ static void execute_one(i8085_state *cpustate, int opcode); INLINE i8085_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_8080 || cpu_get_type(device) == CPU_8085A); - return (i8085_state *)device->token; + return (i8085_state *)downcast(device)->token(); } INLINE void set_sod(i8085_state *cpustate, int state) @@ -1019,25 +971,47 @@ static void init_tables (int type) } -static void init_808x_common(running_device *device, cpu_irq_callback irqcallback, int type) +static void init_808x_common(running_device *device, device_irq_callback irqcallback, int type) { i8085_state *cpustate = get_safe_token(device); init_tables(type); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1 << type; + { + device_state_interface *state; + device->interface(state); + state->state_add(I8085_PC, "PC", cpustate->PC.w.l); + state->state_add(STATE_GENPC, "GENPC", cpustate->PC.w.l).noshow(); + state->state_add(I8085_SP, "SP", cpustate->SP.w.l); + state->state_add(STATE_GENSP, "GENSP", cpustate->SP.w.l).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->AF.b.l).noshow().formatstr("%8s"); + state->state_add(I8085_A, "A", cpustate->AF.b.l).noshow(); + state->state_add(I8085_B, "B", cpustate->BC.b.h).noshow(); + state->state_add(I8085_C, "C", cpustate->BC.b.l).noshow(); + state->state_add(I8085_D, "D", cpustate->DE.b.h).noshow(); + state->state_add(I8085_E, "E", cpustate->DE.b.l).noshow(); + state->state_add(I8085_F, "F", cpustate->AF.b.l).noshow(); + state->state_add(I8085_H, "H", cpustate->HL.b.h).noshow(); + state->state_add(I8085_L, "L", cpustate->HL.b.l).noshow(); + state->state_add(I8085_AF, "AF", cpustate->AF.w.l); + state->state_add(I8085_BC, "BC", cpustate->BC.w.l); + state->state_add(I8085_DE, "DE", cpustate->DE.w.l); + state->state_add(I8085_HL, "HL", cpustate->HL.w.l); + state->state_add(I8085_STATUS, "STATUS", cpustate->STATUS); + state->state_add(I8085_SOD, "SOD", cpustate->sod_state).mask(0x1); + state->state_add(I8085_SID, "SID", cpustate->ietemp).mask(0x1).callimport().callexport(); + state->state_add(I8085_INTE, "INTE", cpustate->ietemp).mask(0x1).callimport().callexport(); + } - if (device->baseconfig().static_config != NULL) - cpustate->config = *(i8085_config *)device->baseconfig().static_config; + if (device->baseconfig().static_config() != NULL) + cpustate->config = *(i8085_config *)device->baseconfig().static_config(); cpustate->cputype = type; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* resolve callbacks */ devcb_resolve_write8(&cpustate->out_status_func, &cpustate->config.out_status_func, device); @@ -1104,7 +1078,7 @@ static CPU_IMPORT_STATE( i808x ) { i8085_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case I8085_SID: if (cpustate->ietemp) @@ -1131,7 +1105,7 @@ static CPU_EXPORT_STATE( i808x ) { i8085_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case I8085_SID: { @@ -1152,6 +1126,26 @@ static CPU_EXPORT_STATE( i808x ) } } +static CPU_EXPORT_STRING( i808x ) +{ + i8085_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c", + cpustate->AF.b.l & 0x80 ? 'S':'.', + cpustate->AF.b.l & 0x40 ? 'Z':'.', + cpustate->AF.b.l & 0x20 ? 'X':'.', // X5 + cpustate->AF.b.l & 0x10 ? 'H':'.', + cpustate->AF.b.l & 0x08 ? '?':'.', + cpustate->AF.b.l & 0x04 ? 'P':'.', + cpustate->AF.b.l & 0x02 ? 'V':'.', + cpustate->AF.b.l & 0x01 ? 'C':'.'); + break; + } +} + /*************************************************************************** @@ -1208,7 +1202,7 @@ static CPU_SET_INFO( i808x ) CPU_GET_INFO( i8085 ) { - i8085_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i8085_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1238,10 +1232,10 @@ CPU_GET_INFO( i8085 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(i8085); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(i808x); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(i808x); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(i808x); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "8085A"); break; @@ -1249,17 +1243,6 @@ CPU_GET_INFO( i8085 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.1"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Juergen Buchmueller, all rights reserved."); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c", - cpustate->AF.b.l & 0x80 ? 'S':'.', - cpustate->AF.b.l & 0x40 ? 'Z':'.', - cpustate->AF.b.l & 0x20 ? 'X':'.', // X5 - cpustate->AF.b.l & 0x10 ? 'H':'.', - cpustate->AF.b.l & 0x08 ? '?':'.', - cpustate->AF.b.l & 0x04 ? 'P':'.', - cpustate->AF.b.l & 0x02 ? 'V':'.', - cpustate->AF.b.l & 0x01 ? 'C':'.'); break; } } diff --git a/src/emu/cpu/i8085/i8085.h b/src/emu/cpu/i8085/i8085.h index e975b145ba8..0c18f6a67e6 100644 --- a/src/emu/cpu/i8085/i8085.h +++ b/src/emu/cpu/i8085/i8085.h @@ -13,9 +13,9 @@ enum I8085_STATUS, I8085_SOD, I8085_SID, I8085_INTE, I8085_HALT, I8085_IM, - I8085_GENPC = REG_GENPC, - I8085_GENSP = REG_GENSP, - I8085_GENPCBASE = REG_GENPCBASE + I8085_GENPC = STATE_GENPC, + I8085_GENSP = STATE_GENSP, + I8085_GENPCBASE = STATE_GENPCBASE }; #define I8085_INTR_LINE 0 diff --git a/src/emu/cpu/i86/i286.c b/src/emu/cpu/i86/i286.c index 540a6b91b9a..0ff4ed2593b 100644 --- a/src/emu/cpu/i86/i286.c +++ b/src/emu/cpu/i86/i286.c @@ -57,7 +57,7 @@ struct _i80286_state UINT16 limit; UINT8 rights; } ldtr, tr; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -84,10 +84,9 @@ struct _i80286_state INLINE i80286_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I80286); - return (i80286_state *)device->token; + return (i80286_state *)downcast(device)->token(); } #define INT_IRQ 0x01 @@ -294,12 +293,12 @@ static CPU_INIT( i80286 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* If a reset parameter is given, take it as pointer to an address mask */ - if( device->baseconfig().static_config ) - cpustate->amask = *(unsigned*)device->baseconfig().static_config; + if( device->baseconfig().static_config() ) + cpustate->amask = *(unsigned*)device->baseconfig().static_config(); else cpustate->amask = 0x00ffff; @@ -389,7 +388,7 @@ static CPU_SET_INFO( i80286 ) CPU_GET_INFO( i80286 ) { - i80286_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i80286_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/i86/i86.c b/src/emu/cpu/i86/i86.c index 331f093c50b..08fc3b90986 100644 --- a/src/emu/cpu/i86/i86.c +++ b/src/emu/cpu/i86/i86.c @@ -40,7 +40,7 @@ struct _i8086_state UINT32 base[4]; UINT16 sregs[4]; UINT16 flags; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; INT32 AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal; /* 0 or non-0 valued flags */ UINT8 ParityVal; UINT8 TF, IF; /* 0 or 1 valued flags */ @@ -63,7 +63,6 @@ struct _i8086_state const address_space *program; const address_space *io; int icount; - cpu_state_table state; unsigned prefix_base; /* base address of the latest prefix segment */ char seg_prefix; /* prefix segment indicator */ @@ -74,64 +73,14 @@ struct _i8086_state INLINE i8086_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I8086 || cpu_get_type(device) == CPU_I8088 || cpu_get_type(device) == CPU_I80186 || cpu_get_type(device) == CPU_I80188); - return (i8086_state *)device->token; + return (i8086_state *)downcast(device)->token(); } -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define I86_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(I8086_##_name, #_name, _format, i8086_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - I86_STATE_ENTRY(GENPC, "%9s", pc, 0xfffff, CPUSTATE_IMPORT) - I86_STATE_ENTRY(GENPCBASE, "%08X", pc, 0xfffff, CPUSTATE_NOSHOW) /* not implemented */ - I86_STATE_ENTRY(IP, "%04X", ip, 0xffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - - I86_STATE_ENTRY(FLAGS, "%04X", flags, 0xffff, CPUSTATE_NOSHOW | CPUSTATE_IMPORT | CPUSTATE_EXPORT) - - I86_STATE_ENTRY(AX, "%04X", regs.w[AX], 0xffff, 0) - I86_STATE_ENTRY(BX, "%04X", regs.w[BX], 0xffff, 0) - I86_STATE_ENTRY(CX, "%04X", regs.w[CX], 0xffff, 0) - I86_STATE_ENTRY(DX, "%04X", regs.w[DX], 0xffff, 0) - I86_STATE_ENTRY(SI, "%04X", regs.w[SI], 0xffff, 0) - I86_STATE_ENTRY(DI, "%04X", regs.w[DI], 0xffff, 0) - I86_STATE_ENTRY(BP, "%04X", regs.w[BP], 0xffff, 0) - I86_STATE_ENTRY(SP, "%04X", regs.w[SP], 0xffff, 0) - I86_STATE_ENTRY(GENSP, "%9s", sp, 0xfffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - - I86_STATE_ENTRY(AL, "%02X", regs.b[AL], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(BL, "%02X", regs.b[BL], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(CL, "%02X", regs.b[CL], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(DL, "%02X", regs.b[DL], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(AH, "%02X", regs.b[AH], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(BH, "%02X", regs.b[BH], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(CH, "%02X", regs.b[CH], 0xff, CPUSTATE_NOSHOW) - I86_STATE_ENTRY(DH, "%02X", regs.b[DH], 0xff, CPUSTATE_NOSHOW) - - I86_STATE_ENTRY(CS, "%04X", sregs[CS], 0xffff, CPUSTATE_IMPORT) - I86_STATE_ENTRY(DS, "%04X", sregs[DS], 0xffff, CPUSTATE_IMPORT) - I86_STATE_ENTRY(ES, "%04X", sregs[ES], 0xffff, CPUSTATE_IMPORT) - I86_STATE_ENTRY(SS, "%04X", sregs[SS], 0xffff, CPUSTATE_IMPORT) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - #include "i86time.c" @@ -218,13 +167,39 @@ static CPU_INIT( i8086 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(STATE_GENPC, "GENPC", cpustate->pc).mask(0xfffff).formatstr("%9s").callimport(); + state->state_add(I8086_IP, "IP", cpustate->ip).callimport().callexport(); + state->state_add(I8086_FLAGS, "FLAGS", cpustate->flags).callimport().callexport().noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->flags).callimport().callexport().noshow().formatstr("%16s"); + state->state_add(I8086_AX, "AX", cpustate->regs.w[AX]); + state->state_add(I8086_BX, "BX", cpustate->regs.w[BX]); + state->state_add(I8086_CX, "CX", cpustate->regs.w[CX]); + state->state_add(I8086_DX, "DX", cpustate->regs.w[DX]); + state->state_add(I8086_SI, "SI", cpustate->regs.w[SI]); + state->state_add(I8086_DI, "DI", cpustate->regs.w[DI]); + state->state_add(I8086_BP, "BP", cpustate->regs.w[BP]); + state->state_add(I8086_SP, "SP", cpustate->regs.w[SP]); + state->state_add(STATE_GENSP, "GENSP", cpustate->sp).mask(0xfffff).formatstr("%9s").callimport().callexport(); + state->state_add(I8086_AL, "AL", cpustate->regs.b[AL]).noshow(); + state->state_add(I8086_BL, "BL", cpustate->regs.b[BL]).noshow(); + state->state_add(I8086_CL, "CL", cpustate->regs.b[CL]).noshow(); + state->state_add(I8086_DL, "DL", cpustate->regs.b[DL]).noshow(); + state->state_add(I8086_AH, "AH", cpustate->regs.b[AH]).noshow(); + state->state_add(I8086_BH, "BH", cpustate->regs.b[BH]).noshow(); + state->state_add(I8086_CH, "CH", cpustate->regs.b[CH]).noshow(); + state->state_add(I8086_DH, "DH", cpustate->regs.b[DH]).noshow(); + state->state_add(I8086_CS, "CS", cpustate->sregs[CS]).callimport(); + state->state_add(I8086_DS, "DS", cpustate->sregs[DS]).callimport(); + state->state_add(I8086_ES, "ES", cpustate->sregs[ES]).callimport(); + state->state_add(I8086_SS, "SS", cpustate->sregs[SS]).callimport(); + } i8086_state_register(device); configure_memory_16bit(cpustate); @@ -240,20 +215,17 @@ static CPU_INIT( i8088 ) static CPU_RESET( i8086 ) { i8086_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; memory_interface save_mem; - cpu_state_table save_state; save_irqcallback = cpustate->irq_callback; save_mem = cpustate->mem; - save_state = cpustate->state; memset(cpustate, 0, sizeof(*cpustate)); cpustate->irq_callback = save_irqcallback; cpustate->mem = save_mem; - cpustate->state = save_state; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sregs[CS] = 0xf000; cpustate->base[CS] = SegBase(CS); @@ -407,7 +379,7 @@ static CPU_IMPORT_STATE( i8086 ) { i8086_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case I8086_GENPC: if (cpustate->pc - cpustate->base[CS] >= 0x10000) @@ -431,6 +403,7 @@ static CPU_IMPORT_STATE( i8086 ) break; case I8086_FLAGS: + case STATE_GENFLAGS: ExpandFlags(cpustate->flags); break; @@ -461,13 +434,14 @@ static CPU_EXPORT_STATE( i8086 ) { i8086_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case I8086_IP: cpustate->ip = cpustate->pc - cpustate->base[CS]; break; case I8086_FLAGS: + case STATE_GENFLAGS: cpustate->flags = CompressFlags(); break; @@ -486,14 +460,35 @@ static CPU_EXPORT_STRING( i8086 ) { i8086_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case I8086_GENPC: - sprintf(string, "%04X:%04X", cpustate->sregs[CS] & 0xffff, (cpustate->pc - cpustate->base[CS]) & 0xffff); + string.printf("%04X:%04X", cpustate->sregs[CS] & 0xffff, (cpustate->pc - cpustate->base[CS]) & 0xffff); break; case I8086_GENSP: - sprintf(string, "%04X:%04X", cpustate->sregs[SS] & 0xffff, cpustate->regs.w[SP] & 0xffff); + string.printf("%04X:%04X", cpustate->sregs[SS] & 0xffff, cpustate->regs.w[SP] & 0xffff); + break; + + case STATE_GENFLAGS: + cpustate->flags = CompressFlags(); + string.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", + cpustate->flags & 0x8000 ? '?' : '.', + cpustate->flags & 0x4000 ? '?' : '.', + cpustate->flags & 0x2000 ? '?' : '.', + cpustate->flags & 0x1000 ? '?' : '.', + cpustate->flags & 0x0800 ? 'O' : '.', + cpustate->flags & 0x0400 ? 'D' : '.', + cpustate->flags & 0x0200 ? 'I' : '.', + cpustate->flags & 0x0100 ? 'T' : '.', + cpustate->flags & 0x0080 ? 'S' : '.', + cpustate->flags & 0x0040 ? 'Z' : '.', + cpustate->flags & 0x0020 ? '?' : '.', + cpustate->flags & 0x0010 ? 'A' : '.', + cpustate->flags & 0x0008 ? '?' : '.', + cpustate->flags & 0x0004 ? 'P' : '.', + cpustate->flags & 0x0002 ? 'N' : '.', + cpustate->flags & 0x0001 ? 'C' : '.'); break; default: @@ -528,7 +523,7 @@ static CPU_SET_INFO( i8086 ) CPU_GET_INFO( i8086 ) { - i8086_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i8086_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -570,7 +565,6 @@ CPU_GET_INFO( i8086 ) case CPUINFO_FCT_BURN: info->burn = NULL; break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(i8086); break; case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(i8086); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(i8086); break; case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(i8086);break; @@ -581,27 +575,6 @@ CPU_GET_INFO( i8086 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.4"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Real mode i286 emulator v1.4 by Fabrice Frances\n(initial work cpustate->based on David Hedley's pcemu)"); break; - - case CPUINFO_STR_FLAGS: - cpustate->flags = CompressFlags(); - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - cpustate->flags & 0x8000 ? '?' : '.', - cpustate->flags & 0x4000 ? '?' : '.', - cpustate->flags & 0x2000 ? '?' : '.', - cpustate->flags & 0x1000 ? '?' : '.', - cpustate->flags & 0x0800 ? 'O' : '.', - cpustate->flags & 0x0400 ? 'D' : '.', - cpustate->flags & 0x0200 ? 'I' : '.', - cpustate->flags & 0x0100 ? 'T' : '.', - cpustate->flags & 0x0080 ? 'S' : '.', - cpustate->flags & 0x0040 ? 'Z' : '.', - cpustate->flags & 0x0020 ? '?' : '.', - cpustate->flags & 0x0010 ? 'A' : '.', - cpustate->flags & 0x0008 ? '?' : '.', - cpustate->flags & 0x0004 ? 'P' : '.', - cpustate->flags & 0x0002 ? 'N' : '.', - cpustate->flags & 0x0001 ? 'C' : '.'); - break; } } diff --git a/src/emu/cpu/i86/i86.h b/src/emu/cpu/i86/i86.h index 4b7ac5a6834..358cc3723f5 100644 --- a/src/emu/cpu/i86/i86.h +++ b/src/emu/cpu/i86/i86.h @@ -33,9 +33,9 @@ enum I8086_DS, I8086_VECTOR, - I8086_GENPC = REG_GENPC, - I8086_GENSP = REG_GENSP, - I8086_GENPCBASE = REG_GENPCBASE + I8086_GENPC = STATE_GENPC, + I8086_GENSP = STATE_GENSP, + I8086_GENPCBASE = STATE_GENPCBASE }; /* Public functions */ diff --git a/src/emu/cpu/i860/i860.c b/src/emu/cpu/i860/i860.c index 7cd02812f59..75e0f475850 100644 --- a/src/emu/cpu/i860/i860.c +++ b/src/emu/cpu/i860/i860.c @@ -30,7 +30,7 @@ static CPU_INIT( i860 ) { i860_state_t *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); reset_i860(cpustate); i860_set_pin(device, DEC_PIN_BUS_HOLD, 0); i860_set_pin(device, DEC_PIN_RESET, 0); @@ -176,7 +176,7 @@ static CPU_SET_INFO( i860 ) CPU_GET_INFO( i860 ) { - i860_state_t *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i860_state_t *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/i860/i860.h b/src/emu/cpu/i860/i860.h index 0a322a974c3..f9149a6d99e 100644 --- a/src/emu/cpu/i860/i860.h +++ b/src/emu/cpu/i860/i860.h @@ -179,10 +179,9 @@ typedef struct { INLINE i860_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I860); - return (i860_state_t *)device->token; + return (i860_state_t *)downcast(device)->token(); } diff --git a/src/emu/cpu/i960/i960.c b/src/emu/cpu/i960/i960.c index 4e3ed211672..43878fe6535 100644 --- a/src/emu/cpu/i960/i960.c +++ b/src/emu/cpu/i960/i960.c @@ -33,7 +33,7 @@ struct _i960_state_t { int immediate_irq, immediate_vector, immediate_pri; - cpu_irq_callback irq_cb; + device_irq_callback irq_cb; running_device *device; const address_space *program; @@ -43,10 +43,9 @@ struct _i960_state_t { INLINE i960_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I960); - return (i960_state_t *)device->token; + return (i960_state_t *)downcast(device)->token(); } static void do_call(i960_state_t *i960, UINT32 adr, int type, UINT32 stack); @@ -2071,7 +2070,7 @@ static CPU_INIT( i960 ) i960->irq_cb = irqcallback; i960->device = device; - i960->program = device->space(AS_PROGRAM); + i960->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item(device, 0, i960->PIP); state_save_register_device_item(device, 0, i960->SAT); @@ -2108,7 +2107,7 @@ static CPU_RESET( i960 ) CPU_GET_INFO( i960 ) { - i960_state_t *i960 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + i960_state_t *i960 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; if(state >= CPUINFO_INT_REGISTER+I960_R0 && state <= CPUINFO_INT_REGISTER + I960_G15) { info->i = i960->r[state - (CPUINFO_INT_REGISTER + I960_R0)]; diff --git a/src/emu/cpu/jaguar/jaguar.c b/src/emu/cpu/jaguar/jaguar.c index 81926a57253..874642ed0c9 100644 --- a/src/emu/cpu/jaguar/jaguar.c +++ b/src/emu/cpu/jaguar/jaguar.c @@ -98,7 +98,7 @@ struct _jaguar_state int icount; int bankswitch_icount; void (*const *table)(jaguar_state *jaguar, UINT16 op); - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; jaguar_int_func cpu_interrupt; running_device *device; const address_space *program; @@ -251,11 +251,10 @@ static void (*const dsp_op_table[64])(jaguar_state *jaguar, UINT16 op) = INLINE jaguar_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_JAGUARGPU || cpu_get_type(device) == CPU_JAGUARDSP); - return (jaguar_state *)device->token; + return (jaguar_state *)downcast(device)->token(); } INLINE void update_register_banks(jaguar_state *jaguar) @@ -410,9 +409,9 @@ static STATE_POSTLOAD( jaguar_postload ) } -static void init_common(int isdsp, running_device *device, cpu_irq_callback irqcallback) +static void init_common(int isdsp, running_device *device, device_irq_callback irqcallback) { - const jaguar_cpu_config *configdata = (const jaguar_cpu_config *)device->baseconfig().static_config; + const jaguar_cpu_config *configdata = (const jaguar_cpu_config *)device->baseconfig().static_config(); jaguar_state *jaguar = get_safe_token(device); init_tables(); @@ -422,7 +421,7 @@ static void init_common(int isdsp, running_device *device, cpu_irq_callback irqc jaguar->irq_callback = irqcallback; jaguar->device = device; - jaguar->program = device->space(AS_PROGRAM); + jaguar->program = device_memory(device)->space(AS_PROGRAM); if (configdata != NULL) jaguar->cpu_interrupt = configdata->cpu_int_callback; @@ -1496,7 +1495,7 @@ static CPU_SET_INFO( jaguargpu ) CPU_GET_INFO( jaguargpu ) { - jaguar_state *jaguar = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + jaguar_state *jaguar = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1649,7 +1648,7 @@ static CPU_SET_INFO( jaguardsp ) CPU_GET_INFO( jaguardsp ) { - jaguar_state *jaguar = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + jaguar_state *jaguar = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/konami/konami.c b/src/emu/cpu/konami/konami.c index eb2bb8c4d02..cabd2a9f52b 100644 --- a/src/emu/cpu/konami/konami.c +++ b/src/emu/cpu/konami/konami.c @@ -56,7 +56,7 @@ struct _konami_state UINT8 cc; UINT8 ireg; UINT8 irq_state[2]; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; UINT8 int_state; /* SYNC and CWAI flags */ UINT8 nmi_state; UINT8 nmi_pending; @@ -69,10 +69,9 @@ struct _konami_state INLINE konami_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_KONAMI); - return (konami_state *)device->token; + return (konami_state *)downcast(device)->token(); } /* flag bits in the cc register */ @@ -405,7 +404,7 @@ static CPU_INIT( konami ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item(device, 0, PC); state_save_register_device_item(device, 0, U); @@ -548,7 +547,7 @@ static CPU_SET_INFO( konami ) CPU_GET_INFO( konami ) { - konami_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + konami_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/lh5801/lh5801.c b/src/emu/cpu/lh5801/lh5801.c index 012c714c9d7..0d8385d9b53 100644 --- a/src/emu/cpu/lh5801/lh5801.c +++ b/src/emu/cpu/lh5801/lh5801.c @@ -71,10 +71,9 @@ struct _lh5810_state INLINE lh5801_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_LH5801); - return (lh5801_state *)device->token; + return (lh5801_state *)downcast(device)->token(); } #define P cpustate->p.w.l @@ -105,9 +104,9 @@ static CPU_INIT( lh5801 ) lh5801_state *cpustate = get_safe_token(device); memset(cpustate, 0, sizeof(*cpustate)); - cpustate->config = (const lh5801_cpu_core *) device->baseconfig().static_config; + cpustate->config = (const lh5801_cpu_core *) device->baseconfig().static_config(); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } static CPU_RESET( lh5801 ) @@ -184,7 +183,7 @@ static CPU_SET_INFO( lh5801 ) CPU_GET_INFO( lh5801 ) { - lh5801_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + lh5801_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/lr35902/lr35902.c b/src/emu/cpu/lr35902/lr35902.c index 50f30fa0028..90250e91507 100644 --- a/src/emu/cpu/lr35902/lr35902.c +++ b/src/emu/cpu/lr35902/lr35902.c @@ -64,7 +64,7 @@ typedef struct { UINT8 IF; int irq_state; int ei_delay; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int icount; @@ -116,10 +116,9 @@ union _lr35902_state { INLINE lr35902_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_LR35902); - return (lr35902_state *)device->token; + return (lr35902_state *)downcast(device)->token(); } typedef int (*OpcodeEmulator) (lr35902_state *cpustate); @@ -191,10 +190,10 @@ static CPU_INIT( lr35902 ) { lr35902_state *cpustate = get_safe_token(device); - cpustate->w.config = (const lr35902_cpu_core *) device->baseconfig().static_config; + cpustate->w.config = (const lr35902_cpu_core *) device->baseconfig().static_config(); cpustate->w.irq_callback = irqcallback; cpustate->w.device = device; - cpustate->w.program = device->space(AS_PROGRAM); + cpustate->w.program = device_memory(device)->space(AS_PROGRAM); } /*** Reset lr353902 registers: ******************************/ @@ -411,7 +410,7 @@ static CPU_SET_INFO( lr35902 ) CPU_GET_INFO( lr35902 ) { - lr35902_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + lr35902_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m37710/m37710.c b/src/emu/cpu/m37710/m37710.c index 3dd3b5150af..3fc6d67c7dd 100644 --- a/src/emu/cpu/m37710/m37710.c +++ b/src/emu/cpu/m37710/m37710.c @@ -527,7 +527,7 @@ static void m37710_internal_w(m37710i_cpu_struct *cpustate, int offset, UINT8 da static READ16_HANDLER( m37710_internal_word_r ) { - m37710i_cpu_struct *cpustate = (m37710i_cpu_struct *)space->cpu->token; + m37710i_cpu_struct *cpustate = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -547,7 +547,7 @@ static READ16_HANDLER( m37710_internal_word_r ) static WRITE16_HANDLER( m37710_internal_word_w ) { - m37710i_cpu_struct *cpustate = (m37710i_cpu_struct *)space->cpu->token; + m37710i_cpu_struct *cpustate = get_safe_token(space->cpu); if (mem_mask == 0xffff) { @@ -860,7 +860,7 @@ static void m37710_set_irq_line(m37710i_cpu_struct *cpustate, int line, int stat /* Set the callback that is called when servicing an interrupt */ #ifdef UNUSED_FUNCTION -void m37710_set_irq_callback(cpu_irq_callback callback) +void m37710_set_irq_callback(device_irq_callback callback) { INT_ACK = callback; } @@ -896,8 +896,8 @@ static CPU_INIT( m37710 ) INT_ACK = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->ICount = 0; @@ -1014,7 +1014,7 @@ ADDRESS_MAP_END CPU_GET_INFO( m37710 ) { - m37710i_cpu_struct *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m37710i_cpu_struct *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m37710/m37710cm.h b/src/emu/cpu/m37710/m37710cm.h index 3a3a0f033fa..95b4631bf6a 100644 --- a/src/emu/cpu/m37710/m37710cm.h +++ b/src/emu/cpu/m37710/m37710cm.h @@ -108,7 +108,7 @@ struct _m37710i_cpu_struct int ICount; /* cycle count */ uint source; /* temp register */ uint destination; /* temp register */ - cpu_irq_callback int_ack; + device_irq_callback int_ack; running_device *device; const address_space *program; const address_space *io; @@ -130,11 +130,10 @@ struct _m37710i_cpu_struct INLINE m37710i_cpu_struct *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M37710 || cpu_get_type(device) == CPU_M37702); - return (m37710i_cpu_struct *)device->token; + return (m37710i_cpu_struct *)downcast(device)->token(); } extern uint m37710i_adc_tbl[]; diff --git a/src/emu/cpu/m37710/m37710op.h b/src/emu/cpu/m37710/m37710op.h index 2155b6d37a9..1ae9cbc0b56 100644 --- a/src/emu/cpu/m37710/m37710op.h +++ b/src/emu/cpu/m37710/m37710op.h @@ -2905,7 +2905,7 @@ TABLE_FUNCTION(uint, get_reg, (m37710i_cpu_struct *cpustate, int regnum)) case M37710_D: return REG_D; case M37710_P: return m37710i_get_reg_p(cpustate); case M37710_IRQ_STATE: return LINE_IRQ; - case REG_GENPCBASE: return REG_PPC; + case STATE_GENPCBASE: return REG_PPC; } return 0; } diff --git a/src/emu/cpu/m6502/m4510.c b/src/emu/cpu/m6502/m4510.c index 6f2d7fabbcc..6a3da6e51db 100644 --- a/src/emu/cpu/m6502/m4510.c +++ b/src/emu/cpu/m6502/m4510.c @@ -142,7 +142,7 @@ struct _m4510_Regs { UINT16 low, high; UINT32 mem[8]; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *space; int icount; @@ -159,10 +159,9 @@ struct _m4510_Regs { INLINE m4510_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M4510); - return (m4510_Regs *)device->token; + return (m4510_Regs *)downcast(device)->token(); } /*************************************************************** @@ -198,7 +197,7 @@ static void default_wrmem_id(const address_space *space, offs_t address, UINT8 d static CPU_INIT( m4510 ) { m4510_Regs *cpustate = get_safe_token(device); - const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config; + const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config(); cpustate->interrupt_inhibit = 0; cpustate->rdmem_id = default_rdmem_id; @@ -207,7 +206,7 @@ static CPU_INIT( m4510 ) cpustate->port_write = NULL; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->space = device->space(AS_PROGRAM); + cpustate->space = device_memory(device)->space(AS_PROGRAM); if ( intf ) { @@ -456,7 +455,7 @@ static CPU_SET_INFO( m4510 ) CPU_GET_INFO( m4510 ) { - m4510_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m4510_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m6502/m6502.c b/src/emu/cpu/m6502/m6502.c index 7c7796b7eaa..b28ae872fc6 100644 --- a/src/emu/cpu/m6502/m6502.c +++ b/src/emu/cpu/m6502/m6502.c @@ -68,7 +68,7 @@ struct _m6502_Regs UINT8 irq_state; UINT8 so_state; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *space; const address_space *io; @@ -87,8 +87,7 @@ struct _m6502_Regs INLINE m6502_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M6502 || cpu_get_type(device) == CPU_M6510 || cpu_get_type(device) == CPU_M6510T || @@ -98,7 +97,7 @@ INLINE m6502_Regs *get_safe_token(running_device *device) cpu_get_type(device) == CPU_M65C02 || cpu_get_type(device) == CPU_M65SC02 || cpu_get_type(device) == CPU_DECO16); - return (m6502_Regs *)device->token; + return (m6502_Regs *)downcast(device)->token(); } static UINT8 default_rdmem_id(const address_space *space, offs_t offset) { return memory_read_byte_8le(space, offset); } @@ -129,14 +128,14 @@ static void default_wdmem_id(const address_space *space, offs_t offset, UINT8 da * *****************************************************************************/ -static void m6502_common_init(running_device *device, cpu_irq_callback irqcallback, UINT8 subtype, void (*const *insn)(m6502_Regs *cpustate), const char *type) +static void m6502_common_init(running_device *device, device_irq_callback irqcallback, UINT8 subtype, void (*const *insn)(m6502_Regs *cpustate), const char *type) { m6502_Regs *cpustate = get_safe_token(device); - const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config; + const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config(); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->space = device->space(AS_PROGRAM); + cpustate->space = device_memory(device)->space(AS_PROGRAM); cpustate->subtype = subtype; cpustate->insn = insn; cpustate->rdmem_id = default_rdmem_id; @@ -529,7 +528,7 @@ static CPU_INIT( deco16 ) { m6502_Regs *cpustate = get_safe_token(device); m6502_common_init(device, irqcallback, SUBTYPE_DECO16, insndeco16, "deco16"); - cpustate->io = device->space(AS_IO); + cpustate->io = device_memory(device)->space(AS_IO); } @@ -692,7 +691,7 @@ static CPU_SET_INFO( m6502 ) CPU_GET_INFO( m6502 ) { - m6502_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6502_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -810,7 +809,7 @@ static CPU_SET_INFO( m6510 ) CPU_GET_INFO( m6510 ) { - m6502_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6502_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m6502/m6509.c b/src/emu/cpu/m6502/m6509.c index 258ea184767..0e6977ef869 100644 --- a/src/emu/cpu/m6502/m6509.c +++ b/src/emu/cpu/m6502/m6509.c @@ -77,7 +77,7 @@ struct _m6509_Regs { UINT8 nmi_state; UINT8 irq_state; UINT8 so_state; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *space; @@ -90,10 +90,9 @@ struct _m6509_Regs { INLINE m6509_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M6509); - return (m6509_Regs *)device->token; + return (m6509_Regs *)downcast(device)->token(); } /*************************************************************** @@ -104,21 +103,21 @@ INLINE m6509_Regs *get_safe_token(running_device *device) static READ8_HANDLER( m6509_read_00000 ) { - m6509_Regs *cpustate = (m6509_Regs *)space->cpu->token; + m6509_Regs *cpustate = get_safe_token(space->cpu); return cpustate->pc_bank.b.h2; } static READ8_HANDLER( m6509_read_00001 ) { - m6509_Regs *cpustate = (m6509_Regs *)space->cpu->token; + m6509_Regs *cpustate = get_safe_token(space->cpu); return cpustate->ind_bank.b.h2; } static WRITE8_HANDLER( m6509_write_00000 ) { - m6509_Regs *cpustate = (m6509_Regs *)space->cpu->token; + m6509_Regs *cpustate = get_safe_token(space->cpu); cpustate->pc_bank.b.h2=data&0xf; cpustate->pc.w.h=cpustate->pc_bank.w.h; @@ -126,7 +125,7 @@ static WRITE8_HANDLER( m6509_write_00000 ) static WRITE8_HANDLER( m6509_write_00001 ) { - m6509_Regs *cpustate = (m6509_Regs *)space->cpu->token; + m6509_Regs *cpustate = get_safe_token(space->cpu); cpustate->ind_bank.b.h2=data&0xf; } @@ -142,13 +141,13 @@ static void default_wdmem_id(const address_space *space, offs_t address, UINT8 d static CPU_INIT( m6509 ) { m6509_Regs *cpustate = get_safe_token(device); - const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config; + const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config(); cpustate->rdmem_id = default_rdmem_id; cpustate->wrmem_id = default_wdmem_id; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->space = device->space(AS_PROGRAM); + cpustate->space = device_memory(device)->space(AS_PROGRAM); if ( intf ) { @@ -331,7 +330,7 @@ static CPU_SET_INFO( m6509 ) CPU_GET_INFO( m6509 ) { - m6509_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6509_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m6502/m65ce02.c b/src/emu/cpu/m6502/m65ce02.c index 14a933900a6..bdc0179ae73 100644 --- a/src/emu/cpu/m6502/m65ce02.c +++ b/src/emu/cpu/m6502/m65ce02.c @@ -74,7 +74,7 @@ struct _m65ce02_Regs { UINT8 nmi_state; UINT8 irq_state; int icount; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *space; read8_space_func rdmem_id; /* readmem callback for indexed instructions */ @@ -84,10 +84,9 @@ struct _m65ce02_Regs { INLINE m65ce02_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M65CE02); - return (m65ce02_Regs *)device->token; + return (m65ce02_Regs *)downcast(device)->token(); } /*************************************************************** @@ -102,13 +101,13 @@ static void default_wdmem_id(const address_space *space, offs_t address, UINT8 d static CPU_INIT( m65ce02 ) { m65ce02_Regs *cpustate = get_safe_token(device); - const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config; + const m6502_interface *intf = (const m6502_interface *)device->baseconfig().static_config(); cpustate->rdmem_id = default_rdmem_id; cpustate->wrmem_id = default_wdmem_id; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->space = device->space(AS_PROGRAM); + cpustate->space = device_memory(device)->space(AS_PROGRAM); if ( intf ) { @@ -276,7 +275,7 @@ static CPU_SET_INFO( m65ce02 ) CPU_GET_INFO( m65ce02 ) { - m65ce02_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m65ce02_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch( state ) { diff --git a/src/emu/cpu/m6800/m6800.c b/src/emu/cpu/m6800/m6800.c index d8e1820619e..28e3664c17b 100644 --- a/src/emu/cpu/m6800/m6800.c +++ b/src/emu/cpu/m6800/m6800.c @@ -112,7 +112,7 @@ struct _m6800_state UINT8 irq_state[2]; /* IRQ line state [IRQ1,TIN] */ UINT8 ic_eddge; /* InputCapture eddge , b.0=fall,b.1=raise */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; /* Memory spaces */ @@ -156,8 +156,7 @@ struct _m6800_state INLINE m6800_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M6800 || cpu_get_type(device) == CPU_M6801 || cpu_get_type(device) == CPU_M6802 || @@ -165,7 +164,7 @@ INLINE m6800_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_M6808 || cpu_get_type(device) == CPU_HD63701 || cpu_get_type(device) == CPU_NSC8105); - return (m6800_state *)device->token; + return (m6800_state *)downcast(device)->token(); } #if 0 @@ -898,9 +897,9 @@ static CPU_INIT( m6800 ) { m6800_state *cpustate = get_safe_token(device); - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); // cpustate->subtype = SUBTYPE_M6800; cpustate->insn = m6800_insn; @@ -1294,11 +1293,11 @@ static CPU_INIT( m6801 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); - cpustate->clock = device->clock / 4; + cpustate->clock = device->clock() / 4; cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate); cpustate->m6800_tx_timer = timer_alloc(device->machine, m6800_tx_tick, cpustate); @@ -1317,9 +1316,9 @@ static CPU_INIT( m6802 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); state_register(cpustate, "m6802"); } @@ -1336,11 +1335,11 @@ static CPU_INIT( m6803 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); - cpustate->clock = device->clock / 4; + cpustate->clock = device->clock() / 4; cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate); cpustate->m6800_tx_timer = timer_alloc(device->machine, m6800_tx_tick, cpustate); @@ -1670,9 +1669,9 @@ static CPU_INIT( m6808 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); state_register(cpustate, "m6808"); } @@ -1690,11 +1689,11 @@ static CPU_INIT( hd63701 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); - cpustate->clock = device->clock / 4; + cpustate->clock = device->clock() / 4; cpustate->m6800_rx_timer = timer_alloc(device->machine, m6800_rx_tick, cpustate); cpustate->m6800_tx_timer = timer_alloc(device->machine, m6800_tx_tick, cpustate); @@ -2038,9 +2037,9 @@ static CPU_INIT( nsc8105 ) // cpustate->subtype = SUBTYPE_NSC8105; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->insn = nsc8105_insn; cpustate->cycles = cycles_nsc8105; @@ -2672,7 +2671,7 @@ static CPU_SET_INFO( m6800 ) CPU_GET_INFO( m6800 ) { - m6800_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6800_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/m68000/m68000.h b/src/emu/cpu/m68000/m68000.h index 6edebb328a1..eb5aece8132 100644 --- a/src/emu/cpu/m68000/m68000.h +++ b/src/emu/cpu/m68000/m68000.h @@ -61,9 +61,9 @@ enum M68K_FP0, M68K_FP1, M68K_FP2, M68K_FP3, M68K_FP4, M68K_FP5, M68K_FP6, M68K_FP7, M68K_FPSR, M68K_FPCR, - M68K_GENPC = REG_GENPC, - M68K_GENSP = REG_GENSP, - M68K_GENPCBASE = REG_GENPCBASE + M68K_GENPC = STATE_GENPC, + M68K_GENSP = STATE_GENSP, + M68K_GENPCBASE = STATE_GENPCBASE }; typedef void (*m68k_bkpt_ack_func)(running_device *device, UINT32 data); diff --git a/src/emu/cpu/m68000/m68kcpu.c b/src/emu/cpu/m68000/m68kcpu.c index bc2a6c6be5d..f07eed4531f 100644 --- a/src/emu/cpu/m68000/m68kcpu.c +++ b/src/emu/cpu/m68000/m68kcpu.c @@ -492,82 +492,11 @@ const UINT8 m68ki_ea_idx_cycle_table[64] = #define MASK_030_OR_LATER (CPU_TYPE_030 | CPU_TYPE_EC030 | CPU_TYPE_040 | CPU_TYPE_EC040) #define MASK_040_OR_LATER (CPU_TYPE_040 | CPU_TYPE_EC040) -#define M68K_STATE_ENTRY(_name, _format, _member, _datamask, _flags, _mask) \ - CPU_STATE_ENTRY(M68K_##_name, #_name, _format, m68ki_cpu_core, _member, _datamask, _mask, _flags) - -static const cpu_state_entry state_array[] = -{ - M68K_STATE_ENTRY(PC, "%06X", pc, 0xffffff, 0, MASK_24BIT_SPACE) - M68K_STATE_ENTRY(PC, "%08X", pc, 0xffffffff, 0, MASK_32BIT_SPACE) - M68K_STATE_ENTRY(GENPC, "%06X", pc, 0xffffff, CPUSTATE_NOSHOW, MASK_24BIT_SPACE) - M68K_STATE_ENTRY(GENPC, "%08X", pc, 0xffffffff, CPUSTATE_NOSHOW, MASK_32BIT_SPACE) - M68K_STATE_ENTRY(GENPCBASE, "%06X", ppc, 0xffffff, CPUSTATE_NOSHOW, MASK_24BIT_SPACE) - M68K_STATE_ENTRY(GENPCBASE, "%08X", ppc, 0xffffffff, CPUSTATE_NOSHOW, MASK_32BIT_SPACE) - - M68K_STATE_ENTRY(SP, "%08X", dar[15], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(GENSP, "%08X", dar[15], 0xffffffff, CPUSTATE_NOSHOW, MASK_ALL) - - M68K_STATE_ENTRY(ISP, "%08X", iotemp, 0xffffffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT, MASK_ALL) - M68K_STATE_ENTRY(USP, "%08X", iotemp, 0xffffffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT, MASK_ALL) - M68K_STATE_ENTRY(MSP, "%08X", iotemp, 0xffffffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT, MASK_020_OR_LATER) - M68K_STATE_ENTRY(SR, "%04X", iotemp, 0xffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT, MASK_ALL) - - M68K_STATE_ENTRY(D0, "%08X", dar[0], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D1, "%08X", dar[1], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D2, "%08X", dar[2], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D3, "%08X", dar[3], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D4, "%08X", dar[4], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D5, "%08X", dar[5], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D6, "%08X", dar[6], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(D7, "%08X", dar[7], 0xffffffff, 0, MASK_ALL) - - M68K_STATE_ENTRY(A0, "%08X", dar[8], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A1, "%08X", dar[9], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A2, "%08X", dar[10], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A3, "%08X", dar[11], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A4, "%08X", dar[12], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A5, "%08X", dar[13], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A6, "%08X", dar[14], 0xffffffff, 0, MASK_ALL) - M68K_STATE_ENTRY(A7, "%08X", dar[15], 0xffffffff, 0, MASK_ALL) - - M68K_STATE_ENTRY(PREF_ADDR, "%06X", pref_addr, 0xffffff, 0, MASK_24BIT_SPACE) - M68K_STATE_ENTRY(PREF_ADDR, "%08X", pref_addr, 0xffffffff, 0, MASK_32BIT_SPACE) - M68K_STATE_ENTRY(PREF_DATA, "%08X", pref_data, 0xffffffff, 0, MASK_ALL) - - M68K_STATE_ENTRY(SFC, "%01X", sfc, 0x7, 0, MASK_010_OR_LATER) - M68K_STATE_ENTRY(DFC, "%01X", dfc, 0x7, 0, MASK_010_OR_LATER) - M68K_STATE_ENTRY(VBR, "%08X", vbr, 0xffffffff, 0, MASK_010_OR_LATER) - - M68K_STATE_ENTRY(CACR, "%08X", cacr, 0xffffffff, 0, MASK_020_OR_LATER) - M68K_STATE_ENTRY(CAAR, "%08X", caar, 0xffffffff, 0, MASK_020_OR_LATER) - - M68K_STATE_ENTRY(FP0, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP1, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP2, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP3, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP4, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP5, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP6, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FP7, "%s", iotemp, 0xffffffff, CPUSTATE_EXPORT, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FPSR, "%08X", fpsr, 0xffffffff, 0, MASK_030_OR_LATER) - M68K_STATE_ENTRY(FPCR, "%08X", fpcr, 0xffffffff, 0, MASK_030_OR_LATER) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - INLINE m68ki_cpu_core *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M68000 || cpu_get_type(device) == CPU_M68008 || cpu_get_type(device) == CPU_M68010 || @@ -579,7 +508,7 @@ INLINE m68ki_cpu_core *get_safe_token(running_device *device) cpu_get_type(device) == CPU_M68EC040 || cpu_get_type(device) == CPU_M68040 || cpu_get_type(device) == CPU_SCC68070); - return (m68ki_cpu_core *)device->token; + return (m68ki_cpu_core *)downcast(device)->token(); } /* ======================================================================== */ @@ -708,7 +637,7 @@ static CPU_INIT( m68k ) m68ki_cpu_core *m68k = get_safe_token(device); m68k->device = device; - m68k->program = device->space(AS_PROGRAM); + m68k->program = device_memory(device)->space(AS_PROGRAM); m68k->int_ack_callback = irqcallback; /* The first call to this function initializes the opcode handler jump table */ @@ -718,10 +647,6 @@ static CPU_INIT( m68k ) emulation_initialized = 1; } - /* set up the state table */ - m68k->state = state_table_template; - m68k->state.baseptr = m68k; - /* Note, D covers A because the dar array is common, REG_A=REG_D+8 */ state_save_register_device_item_array(device, 0, REG_D); state_save_register_device_item(device, 0, REG_PPC); @@ -802,9 +727,10 @@ static CPU_IMPORT_STATE( m68k ) { m68ki_cpu_core *m68k = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case M68K_SR: + case STATE_GENFLAGS: m68ki_set_sr(m68k, m68k->iotemp); break; @@ -840,9 +766,10 @@ static CPU_EXPORT_STATE( m68k ) { m68ki_cpu_core *m68k = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case M68K_SR: + case STATE_GENFLAGS: m68k->iotemp = m68ki_get_sr(m68k); break; @@ -897,47 +824,68 @@ static CPU_SET_INFO( m68k ) static CPU_EXPORT_STRING( m68k ) { m68ki_cpu_core *m68k = get_safe_token(device); + UINT16 sr; - switch (entry->index) + switch (entry.index()) { case M68K_FP0: - sprintf(string, "%f", fx80_to_double(REG_FP[0])); + string.printf("%f", fx80_to_double(REG_FP[0])); break; case M68K_FP1: - sprintf(string, "%f", fx80_to_double(REG_FP[1])); + string.printf("%f", fx80_to_double(REG_FP[1])); break; case M68K_FP2: - sprintf(string, "%f", fx80_to_double(REG_FP[2])); + string.printf("%f", fx80_to_double(REG_FP[2])); break; case M68K_FP3: - sprintf(string, "%f", fx80_to_double(REG_FP[3])); + string.printf("%f", fx80_to_double(REG_FP[3])); break; case M68K_FP4: - sprintf(string, "%f", fx80_to_double(REG_FP[4])); + string.printf("%f", fx80_to_double(REG_FP[4])); break; case M68K_FP5: - sprintf(string, "%f", fx80_to_double(REG_FP[5])); + string.printf("%f", fx80_to_double(REG_FP[5])); break; case M68K_FP6: - sprintf(string, "%f", fx80_to_double(REG_FP[6])); + string.printf("%f", fx80_to_double(REG_FP[6])); break; case M68K_FP7: - sprintf(string, "%f", fx80_to_double(REG_FP[7])); + string.printf("%f", fx80_to_double(REG_FP[7])); + break; + + case STATE_GENFLAGS: + sr = m68ki_get_sr(m68k); + string.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", + sr & 0x8000 ? 'T':'.', + sr & 0x4000 ? 't':'.', + sr & 0x2000 ? 'S':'.', + sr & 0x1000 ? 'M':'.', + sr & 0x0800 ? '?':'.', + sr & 0x0400 ? 'I':'.', + sr & 0x0200 ? 'I':'.', + sr & 0x0100 ? 'I':'.', + sr & 0x0080 ? '?':'.', + sr & 0x0040 ? '?':'.', + sr & 0x0020 ? '?':'.', + sr & 0x0010 ? 'X':'.', + sr & 0x0008 ? 'N':'.', + sr & 0x0004 ? 'Z':'.', + sr & 0x0002 ? 'V':'.', + sr & 0x0001 ? 'C':'.'); break; } } static CPU_GET_INFO( m68k ) { - m68ki_cpu_core *m68k = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - int sr; + m68ki_cpu_core *m68k = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -979,7 +927,6 @@ static CPU_GET_INFO( m68k ) /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &m68k->remaining_cycles; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &m68k->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: /* set per-core */ break; @@ -987,27 +934,6 @@ static CPU_GET_INFO( m68k ) case DEVINFO_STR_VERSION: strcpy(info->s, "4.60"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Karl Stenerud. All rights reserved. (2.1 fixes HJB, FPU+MMU by RB)"); break; - - case CPUINFO_STR_FLAGS: - sr = m68ki_get_sr(m68k); - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - sr & 0x8000 ? 'T':'.', - sr & 0x4000 ? '?':'.', - sr & 0x2000 ? 'S':'.', - sr & 0x1000 ? '?':'.', - sr & 0x0800 ? '?':'.', - sr & 0x0400 ? 'I':'.', - sr & 0x0200 ? 'I':'.', - sr & 0x0100 ? 'I':'.', - sr & 0x0080 ? '?':'.', - sr & 0x0040 ? '?':'.', - sr & 0x0020 ? '?':'.', - sr & 0x0010 ? 'X':'.', - sr & 0x0008 ? 'N':'.', - sr & 0x0004 ? 'Z':'.', - sr & 0x0002 ? 'V':'.', - sr & 0x0001 ? 'C':'.'); - break; } } @@ -1308,6 +1234,61 @@ void m68k_set_tas_callback(running_device *device, m68k_tas_func callback) } +/**************************************************************************** + * State definition + ****************************************************************************/ + +static void define_state(running_device *device) +{ + m68ki_cpu_core *m68k = get_safe_token(device); + UINT32 addrmask = (m68k->cpu_type & MASK_24BIT_SPACE) ? 0xffffff : 0xffffffff; + + device_state_interface *state; + device->interface(state); + state->state_add(M68K_PC, "PC", m68k->pc).mask(addrmask); + state->state_add(STATE_GENPC, "GENPC", m68k->pc).mask(addrmask).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", m68k->ppc).mask(addrmask).noshow(); + state->state_add(M68K_SP, "SP", m68k->dar[15]); + state->state_add(STATE_GENSP, "GENSP", m68k->dar[15]).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", m68k->iotemp).noshow().callimport().callexport().formatstr("%16s"); + state->state_add(M68K_ISP, "ISP", m68k->iotemp).callimport().callexport(); + state->state_add(M68K_USP, "USP", m68k->iotemp).callimport().callexport(); + if (m68k->cpu_type & MASK_020_OR_LATER) + state->state_add(M68K_MSP, "MSP", m68k->iotemp).callimport().callexport(); + state->state_add(M68K_ISP, "ISP", m68k->iotemp).callimport().callexport(); + + astring tempstr; + for (int regnum = 0; regnum < 8; regnum++) + state->state_add(M68K_D0 + regnum, tempstr.format("D%d", regnum), m68k->dar[regnum]); + for (int regnum = 0; regnum < 8; regnum++) + state->state_add(M68K_A0 + regnum, tempstr.format("A%d", regnum), m68k->dar[8 + regnum]); + + state->state_add(M68K_PREF_ADDR, "PREF_ADDR", m68k->pref_addr).mask(addrmask); + state->state_add(M68K_PREF_DATA, "PREF_DATA", m68k->pref_data); + + if (m68k->cpu_type & MASK_010_OR_LATER) + { + state->state_add(M68K_SFC, "SFC", m68k->sfc).mask(0x7); + state->state_add(M68K_DFC, "DFC", m68k->dfc).mask(0x7); + state->state_add(M68K_VBR, "VBR", m68k->vbr); + } + + if (m68k->cpu_type & MASK_020_OR_LATER) + { + state->state_add(M68K_CACR, "CACR", m68k->cacr); + state->state_add(M68K_CAAR, "CAAR", m68k->caar); + } + + if (m68k->cpu_type & MASK_030_OR_LATER) + { + for (int regnum = 0; regnum < 8; regnum++) + state->state_add(M68K_FP0 + regnum, tempstr.format("FP%d", regnum), m68k->iotemp).callimport().callexport().formatstr("%10s"); + state->state_add(M68K_FPSR, "FPSR", m68k->fpsr); + state->state_add(M68K_FPCR, "FPCR", m68k->fpcr); + } +} + + /**************************************************************************** * 68000 section ****************************************************************************/ @@ -1319,7 +1300,6 @@ static CPU_INIT( m68000 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_000; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68000; m68k->memory = interface_d16; m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1335,6 +1315,8 @@ static CPU_INIT( m68000 ) m68k->cyc_shift = 1; m68k->cyc_reset = 132; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68000 ) @@ -1363,7 +1345,6 @@ static CPU_INIT( m68008 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_008; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68008; m68k->memory = interface_d8; m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1379,6 +1360,8 @@ static CPU_INIT( m68008 ) m68k->cyc_shift = 1; m68k->cyc_reset = 132; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68008 ) @@ -1411,7 +1394,6 @@ static CPU_INIT( m68010 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_010; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68010; m68k->memory = interface_d16; m68k->sr_mask = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1427,6 +1409,8 @@ static CPU_INIT( m68010 ) m68k->cyc_shift = 1; m68k->cyc_reset = 130; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68010 ) @@ -1455,7 +1439,6 @@ static CPU_INIT( m68020 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_020; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68020; m68k->memory = interface_d32; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1471,13 +1454,12 @@ static CPU_INIT( m68020 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68020 ) { - m68ki_cpu_core *m68k = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - int sr; - switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1494,27 +1476,6 @@ CPU_GET_INFO( m68020 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "68020"); break; - case CPUINFO_STR_FLAGS: - sr = m68ki_get_sr(m68k); - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - sr & 0x8000 ? 'T':'.', - sr & 0x4000 ? 't':'.', - sr & 0x2000 ? 'S':'.', - sr & 0x1000 ? 'M':'.', - sr & 0x0800 ? '?':'.', - sr & 0x0400 ? 'I':'.', - sr & 0x0200 ? 'I':'.', - sr & 0x0100 ? 'I':'.', - sr & 0x0080 ? '?':'.', - sr & 0x0040 ? '?':'.', - sr & 0x0020 ? '?':'.', - sr & 0x0010 ? 'X':'.', - sr & 0x0008 ? 'N':'.', - sr & 0x0004 ? 'Z':'.', - sr & 0x0002 ? 'V':'.', - sr & 0x0001 ? 'C':'.'); - break; - default: CPU_GET_INFO_CALL(m68k); break; } } @@ -1555,7 +1516,6 @@ static CPU_INIT( m68ec020 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_EC020; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68EC020; m68k->memory = interface_d32; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1571,6 +1531,8 @@ static CPU_INIT( m68ec020 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68ec020 ) @@ -1601,7 +1563,6 @@ static CPU_INIT( m68030 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_030; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68030; m68k->memory = interface_d32_mmu; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1617,13 +1578,12 @@ static CPU_INIT( m68030 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 1; + + define_state(device); } CPU_GET_INFO( m68030 ) { - m68ki_cpu_core *m68k = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - int sr; - switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1640,27 +1600,6 @@ CPU_GET_INFO( m68030 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "68030"); break; - case CPUINFO_STR_FLAGS: - sr = m68ki_get_sr(m68k); - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - sr & 0x8000 ? 'T':'.', - sr & 0x4000 ? 't':'.', - sr & 0x2000 ? 'S':'.', - sr & 0x1000 ? 'M':'.', - sr & 0x0800 ? '?':'.', - sr & 0x0400 ? 'I':'.', - sr & 0x0200 ? 'I':'.', - sr & 0x0100 ? 'I':'.', - sr & 0x0080 ? '?':'.', - sr & 0x0040 ? '?':'.', - sr & 0x0020 ? '?':'.', - sr & 0x0010 ? 'X':'.', - sr & 0x0008 ? 'N':'.', - sr & 0x0004 ? 'Z':'.', - sr & 0x0002 ? 'V':'.', - sr & 0x0001 ? 'C':'.'); - break; - default: CPU_GET_INFO_CALL(m68k); break; } } @@ -1677,7 +1616,6 @@ static CPU_INIT( m68ec030 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_EC030; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68EC030; m68k->memory = interface_d32; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1693,6 +1631,8 @@ static CPU_INIT( m68ec030 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 0; /* EC030 lacks the PMMU and is effectively a die-shrink 68020 */ + + define_state(device); } CPU_GET_INFO( m68ec030 ) @@ -1720,7 +1660,6 @@ static CPU_INIT( m68040 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_040; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68040; m68k->memory = interface_d32_mmu; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1736,13 +1675,12 @@ static CPU_INIT( m68040 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 1; + + define_state(device); } CPU_GET_INFO( m68040 ) { - m68ki_cpu_core *m68k = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; - int sr; - switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1759,27 +1697,6 @@ CPU_GET_INFO( m68040 ) /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "68040"); break; - case CPUINFO_STR_FLAGS: - sr = m68ki_get_sr(m68k); - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - sr & 0x8000 ? 'T':'.', - sr & 0x4000 ? 't':'.', - sr & 0x2000 ? 'S':'.', - sr & 0x1000 ? 'M':'.', - sr & 0x0800 ? '?':'.', - sr & 0x0400 ? 'I':'.', - sr & 0x0200 ? 'I':'.', - sr & 0x0100 ? 'I':'.', - sr & 0x0080 ? '?':'.', - sr & 0x0040 ? '?':'.', - sr & 0x0020 ? '?':'.', - sr & 0x0010 ? 'X':'.', - sr & 0x0008 ? 'N':'.', - sr & 0x0004 ? 'Z':'.', - sr & 0x0002 ? 'V':'.', - sr & 0x0001 ? 'C':'.'); - break; - default: CPU_GET_INFO_CALL(m68k); break; } } @@ -1795,7 +1712,6 @@ static CPU_INIT( m68ec040 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_EC040; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68EC040; m68k->memory = interface_d32; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1811,6 +1727,8 @@ static CPU_INIT( m68ec040 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 0; + + define_state(device); } CPU_GET_INFO( m68ec040 ) @@ -1838,7 +1756,6 @@ static CPU_INIT( m68lc040 ) CPU_INIT_CALL(m68k); m68k->cpu_type = CPU_TYPE_LC040; - m68k->state.subtypemask = m68k->cpu_type; m68k->dasm_type = M68K_CPU_TYPE_68LC040; m68k->memory = interface_d32; m68k->sr_mask = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ @@ -1854,6 +1771,8 @@ static CPU_INIT( m68lc040 ) m68k->cyc_shift = 0; m68k->cyc_reset = 518; m68k->has_pmmu = 1; + + define_state(device); } CPU_GET_INFO( m68lc040 ) diff --git a/src/emu/cpu/m68000/m68kcpu.h b/src/emu/cpu/m68000/m68kcpu.h index 6b04a6cd65e..65b6eb3d3fd 100644 --- a/src/emu/cpu/m68000/m68kcpu.h +++ b/src/emu/cpu/m68000/m68kcpu.h @@ -620,7 +620,7 @@ struct _m68ki_cpu_core const UINT8* cyc_exception; /* Callbacks to host */ - cpu_irq_callback int_ack_callback; /* Interrupt Acknowledge */ + device_irq_callback int_ack_callback; /* Interrupt Acknowledge */ m68k_bkpt_ack_func bkpt_ack_callback; /* Breakpoint Acknowledge */ m68k_reset_func reset_instr_callback; /* Called when a RESET instruction is encountered */ m68k_cmpild_func cmpild_instr_callback; /* Called when a CMPI.L #v, Dn instruction is encountered */ @@ -633,7 +633,6 @@ struct _m68ki_cpu_core offs_t encrypted_start; offs_t encrypted_end; - cpu_state_table state; UINT32 iotemp; /* save state data */ diff --git a/src/emu/cpu/m6805/m6805.c b/src/emu/cpu/m6805/m6805.c index 292772b7fc8..bca36f885bb 100644 --- a/src/emu/cpu/m6805/m6805.c +++ b/src/emu/cpu/m6805/m6805.c @@ -60,7 +60,7 @@ typedef struct UINT8 cc; /* Condition codes */ UINT16 pending_interrupts; /* MB */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int irq_state[9]; /* KW Additional lines for HD63705 */ @@ -70,12 +70,11 @@ typedef struct INLINE m6805_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M6805 || cpu_get_type(device) == CPU_M68705 || cpu_get_type(device) == CPU_HD63705); - return (m6805_Regs *)device->token; + return (m6805_Regs *)downcast(device)->token(); } /****************************************************************************/ @@ -460,20 +459,20 @@ static CPU_INIT( m6805 ) state_register(cpustate, "m6805", device); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = cpustate->device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } static CPU_RESET( m6805 ) { m6805_Regs *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback = cpustate->irq_callback; + device_irq_callback save_irqcallback = cpustate->irq_callback; memset(cpustate, 0, sizeof(m6805_Regs)); cpustate->iCount=50000; /* Used to be global */ cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = cpustate->device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* Force CPU sub-type and relevant masks */ cpustate->subtype = SUBTYPE_M6805; @@ -908,7 +907,7 @@ static CPU_SET_INFO( m6805 ) CPU_GET_INFO( m6805 ) { - m6805_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6805_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1002,7 +1001,7 @@ static CPU_SET_INFO( m68705 ) CPU_GET_INFO( m68705 ) { - m6805_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6805_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1049,7 +1048,7 @@ static CPU_SET_INFO( hd63705 ) CPU_GET_INFO( hd63705 ) { - m6805_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m6805_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/m6809/6809dasm.c b/src/emu/cpu/m6809/6809dasm.c index 41534d1ee2a..430d2d9636d 100644 --- a/src/emu/cpu/m6809/6809dasm.c +++ b/src/emu/cpu/m6809/6809dasm.c @@ -369,7 +369,7 @@ CPU_DISASSEMBLE( m6809 ) const UINT8 *operandarray; unsigned int ea, flags; int numoperands, offset, indirect; - const m6809_config *configdata = device ? (const m6809_config *)device->baseconfig().static_config : NULL; + const m6809_config *configdata = device ? (const m6809_config *)device->baseconfig().static_config() : NULL; int encrypt_only_first_byte = configdata ? configdata->encrypt_only_first_byte : 0; int i, p = 0, page = 0, opcode_found = FALSE; diff --git a/src/emu/cpu/m6809/m6809.c b/src/emu/cpu/m6809/m6809.c index 710fc762a0d..65debfcf7fd 100644 --- a/src/emu/cpu/m6809/m6809.c +++ b/src/emu/cpu/m6809/m6809.c @@ -98,7 +98,7 @@ struct _m68_state_t UINT8 irq_state[2]; int extra_cycles; /* cycles used up by interrupts */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const m6809_config *config; int icount; @@ -114,11 +114,10 @@ struct _m68_state_t INLINE m68_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_M6809 || cpu_get_type(device) == CPU_M6809E); - return (m68_state_t *)device->token; + return (m68_state_t *)downcast(device)->token(); } static void check_irq_lines( m68_state_t *m68_state ); @@ -377,14 +376,14 @@ static CPU_INIT( m6809 ) 0 }; - const m6809_config *configdata = device->baseconfig().static_config ? (const m6809_config *)device->baseconfig().static_config : &default_config; + const m6809_config *configdata = device->baseconfig().static_config() ? (const m6809_config *)device->baseconfig().static_config() : &default_config; m68_state_t *m68_state = get_safe_token(device); m68_state->config = configdata; m68_state->irq_callback = irqcallback; m68_state->device = device; - m68_state->program = device->space(AS_PROGRAM); + m68_state->program = device_memory(device)->space(AS_PROGRAM); /* setup regtable */ @@ -1102,7 +1101,7 @@ static CPU_SET_INFO( m6809 ) CPU_GET_INFO( m6809 ) { - m68_state_t *m68_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + m68_state_t *m68_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/mb86233/mb86233.c b/src/emu/cpu/mb86233/mb86233.c index 88ec36a31a7..c5fb8016f9a 100644 --- a/src/emu/cpu/mb86233/mb86233.c +++ b/src/emu/cpu/mb86233/mb86233.c @@ -68,10 +68,9 @@ struct _mb86233_state INLINE mb86233_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_MB86233); - return (mb86233_state *)device->token; + return (mb86233_state *)downcast(device)->token(); } /*************************************************************************** @@ -108,12 +107,12 @@ INLINE mb86233_state *get_safe_token(running_device *device) static CPU_INIT( mb86233 ) { mb86233_state *cpustate = get_safe_token(device); - mb86233_cpu_core * _config = (mb86233_cpu_core *)device->baseconfig().static_config; + mb86233_cpu_core * _config = (mb86233_cpu_core *)device->baseconfig().static_config(); (void)irqcallback; memset(cpustate, 0, sizeof( *cpustate ) ); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); if ( _config ) { @@ -1607,7 +1606,7 @@ static CPU_SET_INFO( mb86233 ) CPU_GET_INFO( mb86233 ) { - mb86233_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mb86233_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/mb88xx/mb88xx.c b/src/emu/cpu/mb88xx/mb88xx.c index 7fa2b3e576b..f21dde9f633 100644 --- a/src/emu/cpu/mb88xx/mb88xx.c +++ b/src/emu/cpu/mb88xx/mb88xx.c @@ -73,7 +73,7 @@ struct _mb88_state /* IRQ handling */ UINT8 pending_interrupt; - cpu_irq_callback irqcallback; + device_irq_callback irqcallback; running_device *device; const address_space *program; const address_space *data; @@ -84,14 +84,13 @@ struct _mb88_state INLINE mb88_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_MB88 || cpu_get_type(device) == CPU_MB8841 || cpu_get_type(device) == CPU_MB8842 || cpu_get_type(device) == CPU_MB8843 || cpu_get_type(device) == CPU_MB8844); - return (mb88_state *)device->token; + return (mb88_state *)downcast(device)->token(); } static TIMER_CALLBACK( serial_timer ); @@ -137,17 +136,17 @@ static CPU_INIT( mb88 ) { mb88_state *cpustate = get_safe_token(device); - if ( device->baseconfig().static_config ) + if ( device->baseconfig().static_config() ) { - const mb88_cpu_core *_config = (const mb88_cpu_core*)device->baseconfig().static_config; + const mb88_cpu_core *_config = (const mb88_cpu_core*)device->baseconfig().static_config(); cpustate->PLA = _config->PLA_config; } cpustate->irqcallback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->serial = timer_alloc(device->machine, serial_timer, (void *)device); @@ -263,7 +262,7 @@ static void update_pio_enable( mb88_state *cpustate, UINT8 newpio ) if ((newpio & 0x30) == 0) timer_adjust_oneshot(cpustate->serial, attotime_never, 0); else if ((newpio & 0x30) == 0x20) - timer_adjust_periodic(cpustate->serial, ATTOTIME_IN_HZ(cpustate->device->clock / SERIAL_PRESCALE), 0, ATTOTIME_IN_HZ(cpustate->device->clock / SERIAL_PRESCALE)); + timer_adjust_periodic(cpustate->serial, ATTOTIME_IN_HZ(cpustate->device->clock() / SERIAL_PRESCALE), 0, ATTOTIME_IN_HZ(cpustate->device->clock() / SERIAL_PRESCALE)); else fatalerror("mb88xx: update_pio_enable set serial enable to unsupported value %02X\n", newpio & 0x30); } @@ -615,7 +614,7 @@ static CPU_EXECUTE( mb88 ) { /* re-enable the timer if we disabled it previously */ if (cpustate->SBcount >= SERIAL_DISABLE_THRESH) - timer_adjust_periodic(cpustate->serial, ATTOTIME_IN_HZ(cpustate->device->clock / SERIAL_PRESCALE), 0, ATTOTIME_IN_HZ(cpustate->device->clock / SERIAL_PRESCALE)); + timer_adjust_periodic(cpustate->serial, ATTOTIME_IN_HZ(cpustate->device->clock() / SERIAL_PRESCALE), 0, ATTOTIME_IN_HZ(cpustate->device->clock() / SERIAL_PRESCALE)); cpustate->SBcount = 0; } cpustate->sf = 0; @@ -927,7 +926,7 @@ static CPU_SET_INFO( mb88 ) CPU_GET_INFO( mb88 ) { - mb88_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mb88_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/mc68hc11/mc68hc11.c b/src/emu/cpu/mc68hc11/mc68hc11.c index 76361913085..c701e911d16 100644 --- a/src/emu/cpu/mc68hc11/mc68hc11.c +++ b/src/emu/cpu/mc68hc11/mc68hc11.c @@ -59,7 +59,7 @@ struct _hc11_state UINT8 adctl; int ad_channel; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; UINT8 irq_state[2]; running_device *device; const address_space *program; @@ -81,10 +81,9 @@ struct _hc11_state INLINE hc11_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_MC68HC11); - return (hc11_state *)device->token; + return (hc11_state *)downcast(device)->token(); } #define HC11OP(XX) hc11_##XX @@ -370,7 +369,7 @@ static CPU_INIT( hc11 ) hc11_state *cpustate = get_safe_token(device); int i; - const hc11_config *conf = (const hc11_config *)device->baseconfig().static_config; + const hc11_config *conf = (const hc11_config *)device->baseconfig().static_config(); /* clear the opcode tables */ for(i=0; i < 256; i++) { @@ -417,8 +416,8 @@ static CPU_INIT( hc11 ) cpustate->ram_position = 0x100; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); } static CPU_RESET( hc11 ) @@ -538,7 +537,7 @@ static CPU_SET_INFO( mc68hc11 ) CPU_GET_INFO( mc68hc11 ) { - hc11_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + hc11_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/mcs48/mcs48.c b/src/emu/cpu/mcs48/mcs48.c index 68ff876bd2c..44aa706e9e6 100644 --- a/src/emu/cpu/mcs48/mcs48.c +++ b/src/emu/cpu/mcs48/mcs48.c @@ -149,7 +149,7 @@ struct _mcs48_state UINT16 a11; /* A11 value, either 0x000 or 0x800 */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; int icount; @@ -161,7 +161,6 @@ struct _mcs48_state UINT8 feature_mask; /* processor feature flags */ UINT16 int_rom_size; /* internal rom size */ - cpu_state_table state; /* state table */ UINT8 rtemp; /* temporary for import/export */ }; @@ -171,57 +170,6 @@ typedef int (*mcs48_ophandler)(mcs48_state *state); -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define MCS48_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(MCS48_##_name, #_name, _format, mcs48_state, _member, _datamask, MCS48_FEATURE | UPI41_FEATURE, _flags) - -#define UPI41_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(MCS48_##_name, #_name, _format, mcs48_state, _member, _datamask, UPI41_FEATURE, _flags) - -static const cpu_state_entry state_array[] = -{ - MCS48_STATE_ENTRY(PC, "%03X", pc, 0xfff, 0) - MCS48_STATE_ENTRY(GENPC, "%03X", pc, 0xfff, CPUSTATE_NOSHOW) - MCS48_STATE_ENTRY(GENPCBASE, "%03X", prevpc, 0xfff, CPUSTATE_NOSHOW) - - MCS48_STATE_ENTRY(GENSP, "%1X", psw, 0x7, CPUSTATE_NOSHOW) - - MCS48_STATE_ENTRY(A, "%02X", a, 0xff, 0) - MCS48_STATE_ENTRY(TC, "%02X", timer, 0xff, 0) - MCS48_STATE_ENTRY(TPRE, "%02X", prescaler, 0x1f, 0) - - MCS48_STATE_ENTRY(P1, "%02X", p1, 0xff, 0) - MCS48_STATE_ENTRY(P2, "%02X", p2, 0xff, 0) - - MCS48_STATE_ENTRY(R0, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R1, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R2, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R3, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R4, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R5, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R6, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - MCS48_STATE_ENTRY(R7, "%02X", rtemp, 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - - MCS48_STATE_ENTRY(EA, "%1u", ea, 0x1, 0) - - UPI41_STATE_ENTRY(STS, "%02X", sts, 0xff, 0) - UPI41_STATE_ENTRY(DBBI, "%02X", dbbi, 0xff, 0) - UPI41_STATE_ENTRY(DBBO, "%02X", dbbo, 0xff, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - - /*************************************************************************** MACROS ***************************************************************************/ @@ -272,8 +220,7 @@ static int check_irqs(mcs48_state *cpustate); INLINE mcs48_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I8035 || cpu_get_type(device) == CPU_I8048 || cpu_get_type(device) == CPU_I8648 || @@ -291,7 +238,7 @@ INLINE mcs48_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_MB8884 || cpu_get_type(device) == CPU_N7751 || cpu_get_type(device) == CPU_M58715); - return (mcs48_state *)device->token; + return (mcs48_state *)downcast(device)->token(); } @@ -893,7 +840,7 @@ static const mcs48_ophandler opcode_table[256]= mcs48_init - generic MCS-48 initialization -------------------------------------------------*/ -static void mcs48_init(running_device *device, cpu_irq_callback irqcallback, UINT8 feature_mask, UINT16 romsize) +static void mcs48_init(running_device *device, device_irq_callback irqcallback, UINT8 feature_mask, UINT16 romsize) { mcs48_state *cpustate = get_safe_token(device); @@ -910,14 +857,39 @@ static void mcs48_init(running_device *device, cpu_irq_callback irqcallback, UIN cpustate->int_rom_size = romsize; cpustate->feature_mask = feature_mask; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = feature_mask; + { + device_state_interface *state; + device->interface(state); + state->state_add(MCS48_PC, "PC", cpustate->pc).mask(0xfff); + state->state_add(STATE_GENPC, "GENPC", cpustate->pc).mask(0xfff).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", cpustate->prevpc).mask(0xfff).noshow(); + state->state_add(STATE_GENSP, "GENSP", cpustate->psw).mask(0x7).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->psw).noshow().formatstr("%10s"); + state->state_add(MCS48_A, "A", cpustate->a); + state->state_add(MCS48_TC, "TC", cpustate->timer); + state->state_add(MCS48_TPRE, "TPRE", cpustate->prescaler).mask(0x1f); + state->state_add(MCS48_P1, "P1", cpustate->p1); + state->state_add(MCS48_P2, "P2", cpustate->p2); + + astring tempstr; + for (int regnum = 0; regnum < 8; regnum++) + state->state_add(MCS48_R0 + regnum, tempstr.format("R%d", regnum), cpustate->rtemp).callimport().callexport(); + + state->state_add(MCS48_EA, "EA", cpustate->ea).mask(0x1); + + if (feature_mask & UPI41_FEATURE) + { + state->state_add(MCS48_STS, "STS", cpustate->sts); + state->state_add(MCS48_DBBI, "DBBI", cpustate->dbbi); + state->state_add(MCS48_DBBO, "DBBO", cpustate->dbbo); + } + + } /* ensure that regptr is valid before get_info gets called */ update_regptr(cpustate); @@ -1292,7 +1264,7 @@ static CPU_IMPORT_STATE( mcs48 ) { mcs48_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case MCS48_R0: case MCS48_R1: @@ -1302,7 +1274,7 @@ static CPU_IMPORT_STATE( mcs48 ) case MCS48_R5: case MCS48_R6: case MCS48_R7: - cpustate->regptr[entry->index - MCS48_R0] = cpustate->rtemp; + cpustate->regptr[entry.index() - MCS48_R0] = cpustate->rtemp; break; default: @@ -1321,7 +1293,7 @@ static CPU_EXPORT_STATE( mcs48 ) { mcs48_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case MCS48_R0: case MCS48_R1: @@ -1331,7 +1303,7 @@ static CPU_EXPORT_STATE( mcs48 ) case MCS48_R5: case MCS48_R6: case MCS48_R7: - cpustate->rtemp = cpustate->regptr[entry->index - MCS48_R0]; + cpustate->rtemp = cpustate->regptr[entry.index() - MCS48_R0]; break; default: @@ -1340,6 +1312,27 @@ static CPU_EXPORT_STATE( mcs48 ) } } +static CPU_EXPORT_STRING( mcs48 ) +{ + mcs48_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case CPUINFO_STR_FLAGS: + string.printf("%c%c %c%c%c%c%c%c%c%c", + cpustate->irq_state ? 'I':'.', + cpustate->a11 ? 'M':'.', + cpustate->psw & 0x80 ? 'C':'.', + cpustate->psw & 0x40 ? 'A':'.', + cpustate->psw & 0x20 ? 'F':'.', + cpustate->psw & 0x10 ? 'B':'.', + cpustate->psw & 0x08 ? '?':'.', + cpustate->psw & 0x04 ? '4':'.', + cpustate->psw & 0x02 ? '2':'.', + cpustate->psw & 0x01 ? '1':'.'); + break; + } +} /*------------------------------------------------- mcs48_set_info - set a piece of information @@ -1366,7 +1359,7 @@ static CPU_SET_INFO( mcs48 ) static CPU_GET_INFO( mcs48 ) { - mcs48_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mcs48_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1403,10 +1396,10 @@ static CPU_GET_INFO( mcs48 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(mcs48); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(mcs48); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(mcs48); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(mcs48); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: /* set per-core */ break; case DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: /* set per-core */ break; @@ -1416,20 +1409,6 @@ static CPU_GET_INFO( mcs48 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.2"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Mirko Buffoni\nBased on the original work Copyright Dan Boris"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c %c%c%c%c%c%c%c%c", - cpustate->irq_state ? 'I':'.', - cpustate->a11 ? 'M':'.', - cpustate->psw & 0x80 ? 'C':'.', - cpustate->psw & 0x40 ? 'A':'.', - cpustate->psw & 0x20 ? 'F':'.', - cpustate->psw & 0x10 ? 'B':'.', - cpustate->psw & 0x08 ? '?':'.', - cpustate->psw & 0x04 ? '4':'.', - cpustate->psw & 0x02 ? '2':'.', - cpustate->psw & 0x01 ? '1':'.'); - break; } } diff --git a/src/emu/cpu/mcs48/mcs48.h b/src/emu/cpu/mcs48/mcs48.h index 347c4b069d9..6d27bd55ccd 100644 --- a/src/emu/cpu/mcs48/mcs48.h +++ b/src/emu/cpu/mcs48/mcs48.h @@ -44,9 +44,9 @@ enum MCS48_DBBO, /* UPI-41 systems only */ MCS48_DBBI, /* UPI-41 systems only */ - MCS48_GENPC = REG_GENPC, - MCS48_GENSP = REG_GENSP, - MCS48_GENPCBASE = REG_GENPCBASE + MCS48_GENPC = STATE_GENPC, + MCS48_GENSP = STATE_GENSP, + MCS48_GENPCBASE = STATE_GENPCBASE }; diff --git a/src/emu/cpu/mcs51/mcs51.c b/src/emu/cpu/mcs51/mcs51.c index 60fdd3a165f..e42eb551331 100644 --- a/src/emu/cpu/mcs51/mcs51.c +++ b/src/emu/cpu/mcs51/mcs51.c @@ -281,7 +281,7 @@ struct _mcs51_state_t UINT8 (*sfr_read)(mcs51_state_t *mcs51_state, size_t offset); /* Interrupt Callback */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; /* Memory spaces */ @@ -651,8 +651,7 @@ INLINE void serial_transmit(mcs51_state_t *mcs51_state, UINT8 data); INLINE mcs51_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_I8031 || cpu_get_type(device) == CPU_I8032 || cpu_get_type(device) == CPU_I8051 || @@ -667,7 +666,7 @@ INLINE mcs51_state_t *get_safe_token(running_device *device) cpu_get_type(device) == CPU_I87C52 || cpu_get_type(device) == CPU_AT89C4051 || cpu_get_type(device) == CPU_DS5002FP); - return (mcs51_state_t *)device->token; + return (mcs51_state_t *)downcast(device)->token(); } INLINE void clear_current_irq(mcs51_state_t *mcs51_state) @@ -2080,9 +2079,9 @@ static CPU_INIT( mcs51 ) mcs51_state->irq_callback = irqcallback; mcs51_state->device = device; - mcs51_state->program = device->space(AS_PROGRAM); - mcs51_state->data = device->space(AS_DATA); - mcs51_state->io = device->space(AS_IO); + mcs51_state->program = device_memory(device)->space(AS_PROGRAM); + mcs51_state->data = device_memory(device)->space(AS_DATA); + mcs51_state->io = device_memory(device)->space(AS_IO); mcs51_state->features = FEATURE_NONE; mcs51_state->ram_mask = 0x7F; /* 128 bytes of ram */ @@ -2389,7 +2388,7 @@ static CPU_INIT( ds5002fp ) { /* default configuration */ static const ds5002fp_config default_config = { 0x00, 0x00, 0x00 }; - const ds5002fp_config *sconfig = device->baseconfig().static_config ? (const ds5002fp_config *)device->baseconfig().static_config : &default_config; + const ds5002fp_config *sconfig = device->baseconfig().static_config() ? (const ds5002fp_config *)device->baseconfig().static_config() : &default_config; mcs51_state_t *mcs51_state = get_safe_token(device); CPU_INIT_CALL( mcs51 ); @@ -2476,7 +2475,7 @@ static CPU_SET_INFO( mcs51 ) static CPU_GET_INFO( mcs51 ) { - mcs51_state_t *mcs51_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mcs51_state_t *mcs51_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/minx/minx.c b/src/emu/cpu/minx/minx.c index fba6a4df76b..202b9a21da2 100644 --- a/src/emu/cpu/minx/minx.c +++ b/src/emu/cpu/minx/minx.c @@ -83,7 +83,7 @@ typedef struct { UINT8 YI; UINT8 halted; UINT8 interrupt_pending; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int icount; @@ -96,11 +96,10 @@ typedef struct { INLINE minx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_MINX); - return (minx_state *)device->token; + return (minx_state *)downcast(device)->token(); } INLINE UINT16 rd16( minx_state *minx, UINT32 offset ) @@ -121,8 +120,8 @@ static CPU_INIT( minx ) minx_state *minx = get_safe_token(device); minx->irq_callback = irqcallback; minx->device = device; - minx->program = device->space(AS_PROGRAM); - if ( device->baseconfig().static_config != NULL ) + minx->program = device_memory(device)->space(AS_PROGRAM); + if ( device->baseconfig().static_config() != NULL ) { } else @@ -226,9 +225,9 @@ static unsigned minx_get_reg( minx_state *minx, int regnum ) { switch( regnum ) { - case REG_GENPC: return GET_MINX_PC; + case STATE_GENPC: return GET_MINX_PC; case MINX_PC: return minx->PC; - case REG_GENSP: + case STATE_GENSP: case MINX_SP: return minx->SP; case MINX_BA: return minx->BA; case MINX_HL: return minx->HL; @@ -251,9 +250,9 @@ static void minx_set_reg( minx_state *minx, int regnum, unsigned val ) { switch( regnum ) { - case REG_GENPC: break; + case STATE_GENPC: break; case MINX_PC: minx->PC = val; break; - case REG_GENSP: + case STATE_GENSP: case MINX_SP: minx->SP = val; break; case MINX_BA: minx->BA = val; break; case MINX_HL: minx->HL = val; break; @@ -313,7 +312,7 @@ static CPU_SET_INFO( minx ) CPU_GET_INFO( minx ) { - minx_state *minx = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + minx_state *minx = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch( state ) { case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(minx_state); break; @@ -336,8 +335,8 @@ CPU_GET_INFO( minx ) case DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break; case DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break; case CPUINFO_INT_INPUT_STATE + 0: info->i = 0; break; - case CPUINFO_INT_REGISTER + REG_GENPC: info->i = GET_MINX_PC; break; - case CPUINFO_INT_REGISTER + REG_GENSP: + case CPUINFO_INT_REGISTER + STATE_GENPC: info->i = GET_MINX_PC; break; + case CPUINFO_INT_REGISTER + STATE_GENSP: case CPUINFO_INT_REGISTER + MINX_PC: case CPUINFO_INT_REGISTER + MINX_SP: case CPUINFO_INT_REGISTER + MINX_BA: diff --git a/src/emu/cpu/mips/mips3com.c b/src/emu/cpu/mips/mips3com.c index a0113413710..221f8318791 100644 --- a/src/emu/cpu/mips/mips3com.c +++ b/src/emu/cpu/mips/mips3com.c @@ -69,19 +69,19 @@ INLINE int tlb_entry_is_global(const mips3_tlb_entry *entry) structure based on the configured type -------------------------------------------------*/ -void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, running_device *device, cpu_irq_callback irqcallback) +void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, running_device *device, device_irq_callback irqcallback) { - const mips3_config *config = (const mips3_config *)device->baseconfig().static_config; + const mips3_config *config = (const mips3_config *)device->baseconfig().static_config(); int tlbindex; /* initialize based on the config */ memset(mips, 0, sizeof(*mips)); mips->flavor = flavor; mips->bigendian = bigendian; - mips->cpu_clock = device->clock; + mips->cpu_clock = device->clock(); mips->irq_callback = irqcallback; mips->device = device; - mips->program = device->space(AS_PROGRAM); + mips->program = device_memory(device)->space(AS_PROGRAM); mips->icache_size = config->icache; mips->dcache_size = config->dcache; mips->system_clock = config->system_clock; diff --git a/src/emu/cpu/mips/mips3com.h b/src/emu/cpu/mips/mips3com.h index 26462b4b28a..282d208d002 100644 --- a/src/emu/cpu/mips/mips3com.h +++ b/src/emu/cpu/mips/mips3com.h @@ -194,7 +194,7 @@ struct _mips3_state /* internal stuff */ mips3_flavor flavor; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; UINT32 system_clock; @@ -229,7 +229,7 @@ struct _mips3_state FUNCTION PROTOTYPES ***************************************************************************/ -void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, running_device *device, cpu_irq_callback irqcallback); +void mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, running_device *device, device_irq_callback irqcallback); void mips3com_exit(mips3_state *mips); void mips3com_reset(mips3_state *mips); diff --git a/src/emu/cpu/mips/mips3drc.c b/src/emu/cpu/mips/mips3drc.c index c2ff2b70e40..0b2a72df334 100644 --- a/src/emu/cpu/mips/mips3drc.c +++ b/src/emu/cpu/mips/mips3drc.c @@ -276,8 +276,7 @@ static const UINT8 fpmode_source[4] = INLINE mips3_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_VR4300BE || cpu_get_type(device) == CPU_VR4300LE || cpu_get_type(device) == CPU_VR4310BE || @@ -294,7 +293,7 @@ INLINE mips3_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_QED5271LE || cpu_get_type(device) == CPU_RM7000BE || cpu_get_type(device) == CPU_RM7000LE); - return *(mips3_state **)device->token; + return *(mips3_state **)downcast(device)->token(); } @@ -360,7 +359,7 @@ INLINE void save_fast_iregs(mips3_state *mips3, drcuml_block *block) mips3_init - initialize the processor -------------------------------------------------*/ -static void mips3_init(mips3_flavor flavor, int bigendian, running_device *device, cpu_irq_callback irqcallback) +static void mips3_init(mips3_flavor flavor, int bigendian, running_device *device, device_irq_callback irqcallback) { drcfe_config feconfig = { @@ -381,7 +380,7 @@ static void mips3_init(mips3_flavor flavor, int bigendian, running_device *devic fatalerror("Unable to allocate cache of size %d", (UINT32)(CACHE_SIZE + sizeof(*mips3))); /* allocate the core memory */ - *(mips3_state **)device->token = mips3 = (mips3_state *)drccache_memory_alloc_near(cache, sizeof(*mips3)); + *(mips3_state **)downcast(device)->token() = mips3 = (mips3_state *)drccache_memory_alloc_near(cache, sizeof(*mips3)); memset(mips3, 0, sizeof(*mips3)); /* initialize the core */ @@ -602,7 +601,7 @@ static CPU_SET_INFO( mips3 ) static CPU_GET_INFO( mips3 ) { - mips3_state *mips3 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mips3_state *mips3 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/mips/psx.c b/src/emu/cpu/mips/psx.c index 2d3d9ddc1e8..e4ce31d14e0 100644 --- a/src/emu/cpu/mips/psx.c +++ b/src/emu/cpu/mips/psx.c @@ -184,7 +184,7 @@ struct _psxcpu_state int multiplier_operation; UINT32 multiplier_operand1; UINT32 multiplier_operand2; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int bus_attached; @@ -196,11 +196,10 @@ struct _psxcpu_state INLINE psxcpu_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_PSXCPU || cpu_get_type(device) == CPU_CXD8661R); - return (psxcpu_state *)device->token; + return (psxcpu_state *)downcast(device)->token(); } static const UINT32 mips_mtc0_writemask[]= @@ -1633,11 +1632,11 @@ static void mips_state_register( const char *type, running_device *device ) static CPU_INIT( psxcpu ) { psxcpu_state *psxcpu = get_safe_token(device); -// psxcpu->intf = (psxcpu_interface *) device->baseconfig().static_config; +// psxcpu->intf = (psxcpu_interface *) device->baseconfig().static_config(); psxcpu->irq_callback = irqcallback; psxcpu->device = device; - psxcpu->program = device->space(AS_PROGRAM); + psxcpu->program = device_memory(device)->space(AS_PROGRAM); mips_state_register( "psxcpu", device ); } @@ -6111,7 +6110,7 @@ static CPU_SET_INFO( psxcpu ) CPU_GET_INFO( psxcpu ) { - psxcpu_state *psxcpu = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + psxcpu_state *psxcpu = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/mips/r3000.c b/src/emu/cpu/mips/r3000.c index 7f5e2fc926e..94a08d52af3 100644 --- a/src/emu/cpu/mips/r3000.c +++ b/src/emu/cpu/mips/r3000.c @@ -137,7 +137,7 @@ struct _r3000_state int icount; int interrupt_cycles; int hasfpu; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; @@ -165,13 +165,12 @@ struct _r3000_state INLINE r3000_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_R3000BE || cpu_get_type(device) == CPU_R3000LE || cpu_get_type(device) == CPU_R3041BE || cpu_get_type(device) == CPU_R3041LE); - return (r3000_state *)device->token; + return (r3000_state *)downcast(device)->token(); } @@ -300,7 +299,7 @@ static void set_irq_line(r3000_state *r3000, int irqline, int state) static CPU_INIT( r3000 ) { - const r3000_cpu_core *configdata = (const r3000_cpu_core *)device->baseconfig().static_config; + const r3000_cpu_core *configdata = (const r3000_cpu_core *)device->baseconfig().static_config(); r3000_state *r3000 = get_safe_token(device); /* allocate memory */ @@ -313,7 +312,7 @@ static CPU_INIT( r3000 ) r3000->irq_callback = irqcallback; r3000->device = device; - r3000->program = device->space(AS_PROGRAM); + r3000->program = device_memory(device)->space(AS_PROGRAM); } @@ -1164,7 +1163,7 @@ static CPU_SET_INFO( r3000 ) static CPU_GET_INFO( r3000 ) { - r3000_state *r3000 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + r3000_state *r3000 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/mn10200/mn10200.c b/src/emu/cpu/mn10200/mn10200.c index 8fb39bc6954..1c66ae76d45 100644 --- a/src/emu/cpu/mn10200/mn10200.c +++ b/src/emu/cpu/mn10200/mn10200.c @@ -149,11 +149,10 @@ INLINE void mn102_change_pc(mn102_info *mn102, UINT32 pc) INLINE mn102_info *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_MN10200); - return (mn102_info *)device->token; + return (mn102_info *)downcast(device)->token(); } static void mn102_take_irq(mn102_info *mn102, int level, int group) @@ -277,8 +276,8 @@ static CPU_INIT(mn10200) memset(cpustate, 0, sizeof(mn102_info)); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->pc); state_save_register_device_item_array(device, 0, cpustate->d); @@ -2336,7 +2335,7 @@ static UINT32 mn10200_r(mn102_info *mn102, UINT32 adr, int type) static CPU_SET_INFO(mn10200) { - mn102_info *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mn102_info *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -2365,7 +2364,7 @@ static CPU_SET_INFO(mn10200) CPU_GET_INFO( mn10200 ) { - mn102_info *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + mn102_info *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/nec/nec.c b/src/emu/cpu/nec/nec.c index f85a2ae642e..b705963df27 100644 --- a/src/emu/cpu/nec/nec.c +++ b/src/emu/cpu/nec/nec.c @@ -160,7 +160,7 @@ struct _nec_state_t UINT32 poll_state; UINT8 no_interrupt; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -184,14 +184,13 @@ struct _nec_state_t INLINE nec_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_V20 || cpu_get_type(device) == CPU_V25 || cpu_get_type(device) == CPU_V30 || cpu_get_type(device) == CPU_V33 || cpu_get_type(device) == CPU_V35); - return (nec_state_t *)device->token; + return (nec_state_t *)downcast(device)->token(); } /* The interrupt number of a pending external interrupt pending NMI is 2. */ @@ -1101,9 +1100,9 @@ static CPU_DISASSEMBLE( nec ) return necv_dasm_one(buffer, pc, oprom, nec_state->config); } -static void nec_init(running_device *device, cpu_irq_callback irqcallback, int type) +static void nec_init(running_device *device, device_irq_callback irqcallback, int type) { - const nec_config *config = device->baseconfig().static_config ? (const nec_config *)device->baseconfig().static_config : &default_config; + const nec_config *config = device->baseconfig().static_config() ? (const nec_config *)device->baseconfig().static_config() : &default_config; nec_state_t *nec_state = get_safe_token(device); nec_state->config = config; @@ -1131,8 +1130,8 @@ static void nec_init(running_device *device, cpu_irq_callback irqcallback, int t nec_state->irq_callback = irqcallback; nec_state->device = device; - nec_state->program = device->space(AS_PROGRAM); - nec_state->io = device->space(AS_IO); + nec_state->program = device_memory(device)->space(AS_PROGRAM); + nec_state->io = device_memory(device)->space(AS_IO); } @@ -1321,7 +1320,7 @@ static CPU_SET_INFO( nec ) static CPU_GET_INFO( nec ) { - nec_state_t *nec_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + nec_state_t *nec_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; int flags; switch (state) diff --git a/src/emu/cpu/pdp1/pdp1.c b/src/emu/cpu/pdp1/pdp1.c index 3aecd7c0905..82ee77aa82b 100644 --- a/src/emu/cpu/pdp1/pdp1.c +++ b/src/emu/cpu/pdp1/pdp1.c @@ -425,10 +425,9 @@ struct _pdp1_state INLINE pdp1_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_PDP1); - return (pdp1_state *)device->token; + return (pdp1_state *)downcast(device)->token(); } static void execute_instruction(pdp1_state *cpustate); @@ -539,14 +538,14 @@ static void pdp1_set_irq_line (pdp1_state *cpustate, int irqline, int state) static CPU_INIT( pdp1 ) { - const pdp1_reset_param_t *param = (const pdp1_reset_param_t *)device->baseconfig().static_config; + const pdp1_reset_param_t *param = (const pdp1_reset_param_t *)device->baseconfig().static_config(); pdp1_state *cpustate = get_safe_token(device); int i; /* clean-up */ memset (cpustate, 0, sizeof (*cpustate)); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* set up params and callbacks */ for (i=0; i<64; i++) @@ -937,7 +936,7 @@ static CPU_SET_INFO( pdp1 ) CPU_GET_INFO( pdp1 ) { - pdp1_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + pdp1_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/pdp1/tx0.c b/src/emu/cpu/pdp1/tx0.c index dc4f6857994..29f925f5e74 100644 --- a/src/emu/cpu/pdp1/tx0.c +++ b/src/emu/cpu/pdp1/tx0.c @@ -71,11 +71,10 @@ struct _tx0_state INLINE tx0_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TX0_64KW || cpu_get_type(device) == CPU_TX0_8KW); - return (tx0_state *)device->token; + return (tx0_state *)downcast(device)->token(); } #define READ_TX0_18BIT(A) ((signed)memory_read_dword_32be(cpustate->program, (A)<<2)) @@ -127,18 +126,18 @@ static void tx0_write(tx0_state *cpustate, offs_t address, int data) ; } -static void tx0_init_common(running_device *device, cpu_irq_callback irqcallback, int is_64kw) +static void tx0_init_common(running_device *device, device_irq_callback irqcallback, int is_64kw) { tx0_state *cpustate = get_safe_token(device); /* clean-up */ - cpustate->iface = (const tx0_reset_param_t *)device->baseconfig().static_config; + cpustate->iface = (const tx0_reset_param_t *)device->baseconfig().static_config(); cpustate->address_mask = is_64kw ? ADDRESS_MASK_64KW : ADDRESS_MASK_8KW; cpustate->ir_mask = is_64kw ? 03 : 037; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } static CPU_INIT( tx0_64kw ) @@ -435,7 +434,7 @@ static CPU_SET_INFO( tx0 ) CPU_GET_INFO( tx0_64kw ) { - tx0_state *cpustate = ( device != NULL && device->token != NULL ) ? get_safe_token(device) : NULL; + tx0_state *cpustate = ( device != NULL && downcast(device)->token() != NULL ) ? get_safe_token(device) : NULL; switch (state) { @@ -561,7 +560,7 @@ CPU_GET_INFO( tx0_64kw ) CPU_GET_INFO( tx0_8kw ) { - tx0_state *cpustate = ( device != NULL && device->token != NULL ) ? get_safe_token(device) : NULL; + tx0_state *cpustate = ( device != NULL && downcast(device)->token() != NULL ) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/pic16c5x/pic16c5x.c b/src/emu/cpu/pic16c5x/pic16c5x.c index 5722e9206bc..d10bfe0911f 100644 --- a/src/emu/cpu/pic16c5x/pic16c5x.c +++ b/src/emu/cpu/pic16c5x/pic16c5x.c @@ -106,14 +106,13 @@ struct _pic16c5x_state INLINE pic16c5x_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_PIC16C54 || cpu_get_type(device) == CPU_PIC16C55 || cpu_get_type(device) == CPU_PIC16C56 || cpu_get_type(device) == CPU_PIC16C57 || cpu_get_type(device) == CPU_PIC16C58); - return (pic16c5x_state *)device->token; + return (pic16c5x_state *)downcast(device)->token(); } @@ -730,9 +729,9 @@ static CPU_INIT( pic16c5x ) pic16c5x_state *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); /* ensure the internal ram pointers are set before get_info is called */ update_internalram_ptr(cpustate); @@ -997,7 +996,7 @@ static CPU_SET_INFO( pic16c5x ) static CPU_GET_INFO( pic16c5x ) { - pic16c5x_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + pic16c5x_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/pic16c62x/pic16c62x.c b/src/emu/cpu/pic16c62x/pic16c62x.c index fce03383309..98c97b162ed 100644 --- a/src/emu/cpu/pic16c62x/pic16c62x.c +++ b/src/emu/cpu/pic16c62x/pic16c62x.c @@ -96,8 +96,7 @@ struct _pic16c62x_state INLINE pic16c62x_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_PIC16C620 || cpu_get_type(device) == CPU_PIC16C620A || // cpu_get_type(device) == CPU_PIC16CR620A || @@ -105,7 +104,7 @@ INLINE pic16c62x_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_PIC16C621A || cpu_get_type(device) == CPU_PIC16C622 || cpu_get_type(device) == CPU_PIC16C622A); - return (pic16c62x_state *)device->token; + return (pic16c62x_state *)downcast(device)->token(); } @@ -838,9 +837,9 @@ static CPU_INIT( pic16c62x ) pic16c62x_state *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->CONFIG = 0x3fff; @@ -1115,7 +1114,7 @@ static CPU_SET_INFO( pic16c62x ) static CPU_GET_INFO( pic16c62x ) { - pic16c62x_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + pic16c62x_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/powerpc/ppc.c b/src/emu/cpu/powerpc/ppc.c index 95c6cde13a3..41d71c75007 100644 --- a/src/emu/cpu/powerpc/ppc.c +++ b/src/emu/cpu/powerpc/ppc.c @@ -305,7 +305,7 @@ typedef struct { UINT64 tb; /* 56-bit timebase register */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; @@ -929,7 +929,7 @@ static void ppc_init(void) // !!! probably should move this stuff elsewhere !!! static CPU_INIT( ppc403 ) { - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); ppc_init(); @@ -963,7 +963,7 @@ static CPU_INIT( ppc403 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; } @@ -975,7 +975,7 @@ static CPU_EXIT( ppc403 ) static CPU_INIT( ppc603 ) { - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); int pll_config = 0; float multiplier; int i ; @@ -1088,7 +1088,7 @@ static CPU_INIT( ppc603 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; @@ -1120,7 +1120,7 @@ static CPU_EXIT( ppc603 ) static CPU_INIT( ppc602 ) { float multiplier; - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); int i ; @@ -1236,7 +1236,7 @@ static CPU_INIT( ppc602 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; @@ -1263,7 +1263,7 @@ static void mpc8240_tlbld(UINT32 op) static CPU_INIT( mpc8240 ) { float multiplier; - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); int i ; @@ -1377,7 +1377,7 @@ static CPU_INIT( mpc8240 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; @@ -1393,7 +1393,7 @@ static CPU_EXIT( mpc8240 ) static CPU_INIT( ppc601 ) { - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); float multiplier; int i ; @@ -1503,7 +1503,7 @@ static CPU_INIT( ppc601 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; @@ -1521,7 +1521,7 @@ static CPU_EXIT( ppc601 ) static CPU_INIT( ppc604 ) { - const ppc_config *configdata = device->baseconfig().static_config; + const ppc_config *configdata = device->baseconfig().static_config(); float multiplier; int i ; @@ -1633,7 +1633,7 @@ static CPU_INIT( ppc604 ) ppc.irq_callback = irqcallback; ppc.device = device; - ppc.program = device->space(AS_PROGRAM); + ppc.program = device_memory(device)->space(AS_PROGRAM); ppc.pvr = configdata->pvr; diff --git a/src/emu/cpu/powerpc/ppccom.c b/src/emu/cpu/powerpc/ppccom.c index 2974b356a56..66cd194eb4a 100644 --- a/src/emu/cpu/powerpc/ppccom.c +++ b/src/emu/cpu/powerpc/ppccom.c @@ -286,9 +286,9 @@ INLINE int sign_double(double x) structure based on the configured type -------------------------------------------------*/ -void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, cpu_irq_callback irqcallback) +void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, device_irq_callback irqcallback) { - const powerpc_config *config = (const powerpc_config *)device->baseconfig().static_config; + const powerpc_config *config = (const powerpc_config *)device->baseconfig().static_config(); /* initialize based on the config */ memset(ppc, 0, sizeof(*ppc)); @@ -296,14 +296,14 @@ void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_di ppc->cap = cap; ppc->cache_line_size = 32; ppc->tb_divisor = tb_divisor; - ppc->cpu_clock = device->clock; + ppc->cpu_clock = device->clock(); ppc->irq_callback = irqcallback; ppc->device = device; - ppc->program = device->space(AS_PROGRAM); - ppc->system_clock = (config != NULL) ? config->bus_frequency : device->clock; - ppc->tb_divisor = (ppc->tb_divisor * device->clock + ppc->system_clock / 2 - 1) / ppc->system_clock; + ppc->program = device_memory(device)->space(AS_PROGRAM); + ppc->system_clock = (config != NULL) ? config->bus_frequency : device->clock(); + ppc->tb_divisor = (ppc->tb_divisor * device->clock() + ppc->system_clock / 2 - 1) / ppc->system_clock; ppc->codexor = 0; - if (!(cap & PPCCAP_4XX) && device->endianness() != ENDIANNESS_NATIVE) + if (!(cap & PPCCAP_4XX) && device_memory(device)->space_config()->m_endianness != ENDIANNESS_NATIVE) ppc->codexor = 4; /* allocate the virtual TLB */ @@ -1980,7 +1980,7 @@ updateirq: static READ8_HANDLER( ppc4xx_spu_r ) { - powerpc_state *ppc = *(powerpc_state **)space->cpu->token; + powerpc_state *ppc = *(powerpc_state **)downcast(space->cpu)->token(); UINT8 result = 0xff; switch (offset) @@ -2007,7 +2007,7 @@ static READ8_HANDLER( ppc4xx_spu_r ) static WRITE8_HANDLER( ppc4xx_spu_w ) { - powerpc_state *ppc = *(powerpc_state **)space->cpu->token; + powerpc_state *ppc = *(powerpc_state **)downcast(space->cpu)->token(); UINT8 oldstate, newstate; if (PRINTF_SPU) @@ -2084,7 +2084,7 @@ ADDRESS_MAP_END void ppc4xx_spu_set_tx_handler(running_device *device, ppc4xx_spu_tx_handler handler) { - powerpc_state *ppc = *(powerpc_state **)device->token; + powerpc_state *ppc = *(powerpc_state **)downcast(device)->token(); ppc->spu.tx_handler = handler; } @@ -2096,7 +2096,7 @@ void ppc4xx_spu_set_tx_handler(running_device *device, ppc4xx_spu_tx_handler han void ppc4xx_spu_receive_byte(running_device *device, UINT8 byteval) { - powerpc_state *ppc = *(powerpc_state **)device->token; + powerpc_state *ppc = *(powerpc_state **)downcast(device)->token(); ppc4xx_spu_rx_data(ppc, byteval); } diff --git a/src/emu/cpu/powerpc/ppccom.h b/src/emu/cpu/powerpc/ppccom.h index b9c038acb74..698dd1f228b 100644 --- a/src/emu/cpu/powerpc/ppccom.h +++ b/src/emu/cpu/powerpc/ppccom.h @@ -550,7 +550,7 @@ struct _powerpc_state UINT32 mmu603_r[4]; /* internal stuff */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; offs_t codexor; @@ -571,7 +571,7 @@ struct _powerpc_state FUNCTION PROTOTYPES ***************************************************************************/ -void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, cpu_irq_callback irqcallback); +void ppccom_init(powerpc_state *ppc, powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, device_irq_callback irqcallback); void ppccom_exit(powerpc_state *ppc); void ppccom_reset(powerpc_state *ppc); diff --git a/src/emu/cpu/powerpc/ppcdrc.c b/src/emu/cpu/powerpc/ppcdrc.c index ff8a5c8862d..0da960f9bea 100644 --- a/src/emu/cpu/powerpc/ppcdrc.c +++ b/src/emu/cpu/powerpc/ppcdrc.c @@ -438,8 +438,7 @@ static const UINT8 fcmp_cr_table_source[32] = INLINE powerpc_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_PPC403GA || cpu_get_type(device) == CPU_PPC403GCX || cpu_get_type(device) == CPU_PPC601 || @@ -449,7 +448,7 @@ INLINE powerpc_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_PPC603R || cpu_get_type(device) == CPU_PPC604 || cpu_get_type(device) == CPU_MPC8240); - return *(powerpc_state **)device->token; + return *(powerpc_state **)downcast(device)->token(); } /*------------------------------------------------- @@ -548,7 +547,7 @@ INLINE UINT32 compute_spr(UINT32 spr) ppcdrc_init - initialize the processor -------------------------------------------------*/ -static void ppcdrc_init(powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, cpu_irq_callback irqcallback) +static void ppcdrc_init(powerpc_flavor flavor, UINT8 cap, int tb_divisor, running_device *device, device_irq_callback irqcallback) { drcfe_config feconfig = { @@ -569,7 +568,7 @@ static void ppcdrc_init(powerpc_flavor flavor, UINT8 cap, int tb_divisor, runnin fatalerror("Unable to allocate cache of size %d", (UINT32)(CACHE_SIZE + sizeof(*ppc))); /* allocate the core from the near cache */ - *(powerpc_state **)device->token = ppc = (powerpc_state *)drccache_memory_alloc_near(cache, sizeof(*ppc)); + *(powerpc_state **)downcast(device)->token() = ppc = (powerpc_state *)drccache_memory_alloc_near(cache, sizeof(*ppc)); memset(ppc, 0, sizeof(*ppc)); /* initialize the core */ @@ -794,7 +793,7 @@ static CPU_SET_INFO( ppcdrc ) static CPU_GET_INFO( ppcdrc ) { - powerpc_state *ppc = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + powerpc_state *ppc = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -1479,7 +1478,7 @@ static void static_generate_memory_accessor(powerpc_state *ppc, int mode, int si /* on exit, read result is in I0 */ /* routine trashes I0-I3 */ drcuml_state *drcuml = ppc->impstate->drcuml; - int fastxor = BYTE8_XOR_BE(0) >> (int)(ppc->device->databus_width(AS_PROGRAM) < 64); + int fastxor = BYTE8_XOR_BE(0) >> (int)(device_memory(ppc->device)->space_config(AS_PROGRAM)->m_databus_width < 64); drcuml_block *block; jmp_buf errorbuf; int translate_type; @@ -4291,7 +4290,7 @@ static void log_opcode_desc(drcuml_state *drcuml, const opcode_desc *desclist, i static CPU_GET_INFO( ppcdrc4xx ) { - powerpc_state *ppc = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + powerpc_state *ppc = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; CPU_GET_INFO_CALL(ppcdrc); ppc4xx_get_info(ppc, state, info); } diff --git a/src/emu/cpu/rsp/rsp.c b/src/emu/cpu/rsp/rsp.c index b1f2652f9d8..721a8ff0aaa 100644 --- a/src/emu/cpu/rsp/rsp.c +++ b/src/emu/cpu/rsp/rsp.c @@ -30,10 +30,9 @@ extern offs_t rsp_dasm_one(char *buffer, offs_t pc, UINT32 op); INLINE rsp_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_RSP); - return (rsp_state *)device->token; + return (rsp_state *)downcast(device)->token(); } #define SIMM16 ((INT32)(INT16)(op)) @@ -302,14 +301,14 @@ static CPU_INIT( rsp ) rsp_state *rsp = get_safe_token(device); int regIdx; int accumIdx; - rsp->config = (const rsp_config *)device->baseconfig().static_config; + rsp->config = (const rsp_config *)device->baseconfig().static_config(); if (LOG_INSTRUCTION_EXECUTION) rsp->exec_output = fopen("rsp_execute.txt", "wt"); rsp->irq_callback = irqcallback; rsp->device = device; - rsp->program = device->space(AS_PROGRAM); + rsp->program = device_memory(device)->space(AS_PROGRAM); #if 1 // Inaccurate. RSP registers power on to a random state... @@ -2866,7 +2865,7 @@ static CPU_SET_INFO( rsp ) CPU_GET_INFO( rsp ) { - rsp_state *rsp = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + rsp_state *rsp = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/rsp/rsp.h b/src/emu/cpu/rsp/rsp.h index 4a206474401..02baab1f4f6 100644 --- a/src/emu/cpu/rsp/rsp.h +++ b/src/emu/cpu/rsp/rsp.h @@ -208,7 +208,7 @@ struct _rsp_state UINT32 ppc; UINT32 nextpc; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int icount; diff --git a/src/emu/cpu/rsp/rspdrc.c b/src/emu/cpu/rsp/rspdrc.c index 74f586488e1..4bee6959240 100644 --- a/src/emu/cpu/rsp/rspdrc.c +++ b/src/emu/cpu/rsp/rspdrc.c @@ -351,10 +351,9 @@ static void log_add_disasm_comment(rsp_state *rsp, drcuml_block *block, UINT32 p INLINE rsp_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_RSP); - return *(rsp_state **)device->token; + return *(rsp_state **)downcast(device)->token(); } /*************************************************************************** @@ -685,17 +684,17 @@ static const int vector_elements_2[16][8] = { 7, 7, 7, 7, 7, 7, 7, 7 }, // 7 }; -static void rspcom_init(rsp_state *rsp, running_device *device, cpu_irq_callback irqcallback) +static void rspcom_init(rsp_state *rsp, running_device *device, device_irq_callback irqcallback) { int regIdx = 0; int accumIdx; memset(rsp, 0, sizeof(*rsp)); - rsp->config = (const rsp_config *)device->baseconfig().static_config; + rsp->config = (const rsp_config *)device->baseconfig().static_config(); rsp->irq_callback = irqcallback; rsp->device = device; - rsp->program = device->space(AS_PROGRAM); + rsp->program = device_memory(device)->space(AS_PROGRAM); #if 1 // Inaccurate. RSP registers power on to a random state... @@ -748,7 +747,7 @@ static CPU_INIT( rsp ) } /* allocate the core memory */ - *(rsp_state **)device->token = rsp = (rsp_state *)drccache_memory_alloc_near(cache, sizeof(*rsp)); + *(rsp_state **)downcast(device)->token() = rsp = (rsp_state *)drccache_memory_alloc_near(cache, sizeof(*rsp)); memset(rsp, 0, sizeof(*rsp)); rspcom_init(rsp, device, irqcallback); @@ -8595,7 +8594,7 @@ static CPU_SET_INFO( rsp ) CPU_GET_INFO( rsp ) { - rsp_state *rsp = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + rsp_state *rsp = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/s2650/s2650.c b/src/emu/cpu/s2650/s2650.c index 759cdfc897a..325b8bcb589 100644 --- a/src/emu/cpu/s2650/s2650.c +++ b/src/emu/cpu/s2650/s2650.c @@ -41,7 +41,7 @@ struct _s2650_regs { UINT8 irq_state; int icount; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -50,10 +50,9 @@ struct _s2650_regs { INLINE s2650_regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_S2650); - return (s2650_regs *)device->token; + return (s2650_regs *)downcast(device)->token(); } /* condition code changes for a byte */ @@ -797,8 +796,8 @@ static CPU_INIT( s2650 ) s2650c->irq_callback = irqcallback; s2650c->device = device; - s2650c->program = device->space(AS_PROGRAM); - s2650c->io = device->space(AS_IO); + s2650c->program = device_memory(device)->space(AS_PROGRAM); + s2650c->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, s2650c->ppc); state_save_register_device_item(device, 0, s2650c->page); @@ -829,8 +828,8 @@ static CPU_RESET( s2650 ) memset(s2650c->ras, 0, sizeof(s2650c->ras)); s2650c->device = device; - s2650c->program = device->space(AS_PROGRAM); - s2650c->io = device->space(AS_IO); + s2650c->program = device_memory(device)->space(AS_PROGRAM); + s2650c->io = device_memory(device)->space(AS_IO); s2650c->psl = COM | WC; /* force write */ s2650c->psu = 0xff; @@ -1546,7 +1545,7 @@ static CPU_SET_INFO( s2650 ) CPU_GET_INFO( s2650 ) { - s2650_regs *s2650c = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + s2650_regs *s2650c = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/saturn/saturn.c b/src/emu/cpu/saturn/saturn.c index 3b739e77850..17920054d54 100644 --- a/src/emu/cpu/saturn/saturn.c +++ b/src/emu/cpu/saturn/saturn.c @@ -81,7 +81,7 @@ struct _saturn_state UINT8 sleeping; /* low-consumption state */ int monitor_id; int monitor_in; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; int icount; @@ -90,10 +90,9 @@ struct _saturn_state INLINE saturn_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SATURN); - return (saturn_state *)device->token; + return (saturn_state *)downcast(device)->token(); } /*************************************************************** @@ -113,10 +112,10 @@ static CPU_INIT( saturn ) { saturn_state *cpustate = get_safe_token(device); - cpustate->config = (saturn_cpu_core *) device->baseconfig().static_config; + cpustate->config = (saturn_cpu_core *) device->baseconfig().static_config(); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item_array(device, 0,cpustate->reg[R0]); state_save_register_device_item_array(device, 0,cpustate->reg[R1]); @@ -305,7 +304,7 @@ static INT64 Reg64Int(Saturn64 r) CPU_GET_INFO( saturn ) { - saturn_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + saturn_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/sc61860/sc61860.c b/src/emu/cpu/sc61860/sc61860.c index 09baa0690f6..629c0ccfb9a 100644 --- a/src/emu/cpu/sc61860/sc61860.c +++ b/src/emu/cpu/sc61860/sc61860.c @@ -63,10 +63,9 @@ struct _sc61860_state INLINE sc61860_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SC61860); - return (sc61860_state *)device->token; + return (sc61860_state *)downcast(device)->token(); } UINT8 *sc61860_internal_ram(running_device *device) @@ -104,10 +103,10 @@ static CPU_RESET( sc61860 ) static CPU_INIT( sc61860 ) { sc61860_state *cpustate = get_safe_token(device); - cpustate->config = (sc61860_cpu_core *) device->baseconfig().static_config; + cpustate->config = (sc61860_cpu_core *) device->baseconfig().static_config(); timer_pulse(device->machine, ATTOTIME_IN_HZ(500), cpustate, 0, sc61860_2ms_tick); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } static CPU_EXECUTE( sc61860 ) @@ -174,7 +173,7 @@ static CPU_SET_INFO( sc61860 ) CPU_GET_INFO( sc61860 ) { - sc61860_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + sc61860_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/scmp/scmp.c b/src/emu/cpu/scmp/scmp.c index 5ebf5d57bd1..fbb965c55d0 100644 --- a/src/emu/cpu/scmp/scmp.c +++ b/src/emu/cpu/scmp/scmp.c @@ -35,7 +35,6 @@ struct _scmp_state running_device *device; const address_space *program; const address_space *io; - cpu_state_table state; int icount; devcb_resolved_write8 flag_out_func; @@ -50,34 +49,6 @@ struct _scmp_state MACROS ***************************************************************************/ -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define SCMP_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(SCMP_##_name, #_name, _format, scmp_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - SCMP_STATE_ENTRY(PC, "%04X", PC.w.l, 0xffff, 0) - SCMP_STATE_ENTRY(GENPC,"%04X", PC.w.l, 0xffff, CPUSTATE_NOSHOW) - SCMP_STATE_ENTRY(P1, "%04X", P1.w.l, 0xffff, 0) - SCMP_STATE_ENTRY(P2, "%04X", P2.w.l, 0xffff, 0) - SCMP_STATE_ENTRY(P3, "%04X", P3.w.l, 0xffff, 0) - SCMP_STATE_ENTRY(AC, "%02X", AC, 0xff, 0) - SCMP_STATE_ENTRY(ER, "%02X", ER, 0xff, 0) - SCMP_STATE_ENTRY(SR, "%02X", SR, 0xff, 0) - -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -85,10 +56,9 @@ static const cpu_state_table state_table_template = INLINE scmp_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SCMP || cpu_get_type(device) == CPU_INS8060); - return (scmp_state *)device->token; + return (scmp_state *)downcast(device)->token(); } INLINE UINT16 ADD12(UINT16 addr, INT8 val) @@ -528,16 +498,27 @@ static CPU_INIT( scmp ) { scmp_state *cpustate = get_safe_token(device); - if (device->baseconfig().static_config != NULL) - cpustate->config = *(scmp_config *)device->baseconfig().static_config; + if (device->baseconfig().static_config() != NULL) + cpustate->config = *(scmp_config *)device->baseconfig().static_config(); + /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(SCMP_PC, "PC", cpustate->PC.w.l); + state->state_add(STATE_GENPC, "GENPC", cpustate->PC.w.l).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->SR).noshow().formatstr("%8s"); + state->state_add(SCMP_P1, "P1", cpustate->P1.w.l); + state->state_add(SCMP_P2, "P2", cpustate->P2.w.l); + state->state_add(SCMP_P3, "P3", cpustate->P3.w.l); + state->state_add(SCMP_AC, "AC", cpustate->AC); + state->state_add(SCMP_ER, "ER", cpustate->ER); + state->state_add(SCMP_SR, "SR", cpustate->SR); + } cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); /* resolve callbacks */ devcb_resolve_write8(&cpustate->flag_out_func, &cpustate->config.flag_out_func, device); @@ -589,6 +570,26 @@ static CPU_EXPORT_STATE( scmp ) { } +static CPU_EXPORT_STRING( scmp ) +{ + scmp_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c", + (cpustate->SR & 0x80) ? 'C' : '.', + (cpustate->SR & 0x40) ? 'V' : '.', + (cpustate->SR & 0x20) ? 'B' : '.', + (cpustate->SR & 0x10) ? 'A' : '.', + (cpustate->SR & 0x08) ? 'I' : '.', + (cpustate->SR & 0x04) ? '2' : '.', + (cpustate->SR & 0x02) ? '1' : '.', + (cpustate->SR & 0x01) ? '0' : '.'); + break; + } +} + /*************************************************************************** COMMON SET INFO ***************************************************************************/ @@ -602,7 +603,7 @@ static CPU_SET_INFO( scmp ) CPU_GET_INFO( scmp ) { - scmp_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + scmp_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -637,10 +638,10 @@ CPU_GET_INFO( scmp ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(scmp); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(scmp); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(scmp); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(scmp); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "INS 8050 SC/MP"); break; @@ -648,18 +649,6 @@ CPU_GET_INFO( scmp ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Miodrag Milanovic"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c", - (cpustate->SR & 0x80) ? 'C' : '.', - (cpustate->SR & 0x40) ? 'V' : '.', - (cpustate->SR & 0x20) ? 'B' : '.', - (cpustate->SR & 0x10) ? 'A' : '.', - (cpustate->SR & 0x08) ? 'I' : '.', - (cpustate->SR & 0x04) ? '2' : '.', - (cpustate->SR & 0x02) ? '1' : '.', - (cpustate->SR & 0x01) ? '0' : '.'); - break; } } diff --git a/src/emu/cpu/scmp/scmp.h b/src/emu/cpu/scmp/scmp.h index 968e9685bda..e8fccffe9ff 100644 --- a/src/emu/cpu/scmp/scmp.h +++ b/src/emu/cpu/scmp/scmp.h @@ -9,9 +9,9 @@ enum { SCMP_PC, SCMP_P1, SCMP_P2, SCMP_P3, SCMP_AC, SCMP_ER, SCMP_SR, - SCMP_GENPC = REG_GENPC, - SCMP_GENSP = REG_GENSP, - SCMP_GENPCBASE = REG_GENPCBASE + SCMP_GENPC = STATE_GENPC, + SCMP_GENSP = STATE_GENSP, + SCMP_GENPCBASE = STATE_GENPCBASE }; /*************************************************************************** diff --git a/src/emu/cpu/se3208/se3208.c b/src/emu/cpu/se3208/se3208.c index a9726e0ed31..52abbf7152d 100644 --- a/src/emu/cpu/se3208/se3208.c +++ b/src/emu/cpu/se3208/se3208.c @@ -22,7 +22,7 @@ struct _se3208_state_t UINT32 ER; UINT32 PPC; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; UINT8 IRQ; @@ -61,10 +61,9 @@ static _OP *OpTable=NULL; INLINE se3208_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SE3208); - return (se3208_state_t *)device->token; + return (se3208_state_t *)downcast(device)->token(); } INLINE UINT32 read_dword_unaligned(const address_space *space, UINT32 address) @@ -1715,11 +1714,11 @@ static CPU_RESET( se3208 ) { se3208_state_t *se3208_state = get_safe_token(device); - cpu_irq_callback save_irqcallback = se3208_state->irq_callback; + device_irq_callback save_irqcallback = se3208_state->irq_callback; memset(se3208_state,0,sizeof(se3208_state_t)); se3208_state->irq_callback = save_irqcallback; se3208_state->device = device; - se3208_state->program = device->space(AS_PROGRAM); + se3208_state->program = device_memory(device)->space(AS_PROGRAM); se3208_state->PC=SE3208_Read32(se3208_state, 0); se3208_state->SR=0; se3208_state->IRQ=CLEAR_LINE; @@ -1792,7 +1791,7 @@ static CPU_INIT( se3208 ) se3208_state->irq_callback = irqcallback; se3208_state->device = device; - se3208_state->program = device->space(AS_PROGRAM); + se3208_state->program = device_memory(device)->space(AS_PROGRAM); } static CPU_EXIT( se3208 ) @@ -1843,7 +1842,7 @@ static CPU_SET_INFO( se3208 ) CPU_GET_INFO( se3208 ) { - se3208_state_t *se3208_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + se3208_state_t *se3208_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/sh2/sh2.c b/src/emu/cpu/sh2/sh2.c index a7150eca15c..8e8ba0d5e3c 100644 --- a/src/emu/cpu/sh2/sh2.c +++ b/src/emu/cpu/sh2/sh2.c @@ -2142,7 +2142,7 @@ static CPU_RESET( sh2 ) int save_is_slave; void (*f)(UINT32 data); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; m = sh2->m; tsave = sh2->timer; diff --git a/src/emu/cpu/sh2/sh2comn.c b/src/emu/cpu/sh2/sh2comn.c index cbeb42d3bcb..b31528fafb0 100644 --- a/src/emu/cpu/sh2/sh2comn.c +++ b/src/emu/cpu/sh2/sh2comn.c @@ -16,9 +16,9 @@ #define LOG(x) do { if (VERBOSE) logerror x; } while (0) #ifdef USE_SH2DRC -#define GET_SH2(dev) *(SH2 **)(dev)->token +#define GET_SH2(dev) *(SH2 **)downcast(dev)->token() #else -#define GET_SH2(dev) (SH2 *)(dev)->token +#define GET_SH2(dev) (SH2 *)downcast(dev)->token() #endif @@ -699,9 +699,9 @@ void sh2_exception(SH2 *sh2, const char *message, int irqline) #endif } -void sh2_common_init(SH2 *sh2, running_device *device, cpu_irq_callback irqcallback) +void sh2_common_init(SH2 *sh2, running_device *device, device_irq_callback irqcallback) { - const sh2_cpu_core *conf = (const sh2_cpu_core *)device->baseconfig().static_config; + const sh2_cpu_core *conf = (const sh2_cpu_core *)device->baseconfig().static_config(); sh2->timer = timer_alloc(device->machine, sh2_timer_callback, sh2); timer_adjust_oneshot(sh2->timer, attotime_never, 0); @@ -727,8 +727,8 @@ void sh2_common_init(SH2 *sh2, running_device *device, cpu_irq_callback irqcallb } sh2->irq_callback = irqcallback; sh2->device = device; - sh2->program = device->space(AS_PROGRAM); - sh2->internal = device->space(AS_PROGRAM); + sh2->program = device_memory(device)->space(AS_PROGRAM); + sh2->internal = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item(device, 0, sh2->pc); state_save_register_device_item(device, 0, sh2->r[15]); diff --git a/src/emu/cpu/sh2/sh2comn.h b/src/emu/cpu/sh2/sh2comn.h index f9559d72d0c..c9055133a08 100644 --- a/src/emu/cpu/sh2/sh2comn.h +++ b/src/emu/cpu/sh2/sh2comn.h @@ -114,7 +114,7 @@ typedef struct UINT32 pcflushes[16]; // pcflush entries INT8 irq_line_state[17]; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *internal; @@ -172,7 +172,7 @@ typedef struct #endif } SH2; -void sh2_common_init(SH2 *sh2, running_device *device, cpu_irq_callback irqcallback); +void sh2_common_init(SH2 *sh2, running_device *device, device_irq_callback irqcallback); void sh2_recalc_irq(SH2 *sh2); void sh2_set_irq_line(SH2 *sh2, int irqline, int state); void sh2_exception(SH2 *sh2, const char *message, int irqline); diff --git a/src/emu/cpu/sh2/sh2drc.c b/src/emu/cpu/sh2/sh2drc.c index 571ae8a237a..d0f98a19095 100644 --- a/src/emu/cpu/sh2/sh2drc.c +++ b/src/emu/cpu/sh2/sh2drc.c @@ -140,11 +140,10 @@ static void cfunc_DIV1(void *param); INLINE SH2 *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SH1 || cpu_get_type(device) == CPU_SH2); - return *(SH2 **)device->token; + return *(SH2 **)downcast(device)->token(); } INLINE UINT16 RW(SH2 *sh2, offs_t A) @@ -694,7 +693,7 @@ static CPU_INIT( sh2 ) fatalerror("Unable to allocate cache of size %d", (UINT32)(CACHE_SIZE + sizeof(SH2))); /* allocate the core memory */ - *(SH2 **)device->token = sh2 = (SH2 *)drccache_memory_alloc_near(cache, sizeof(SH2)); + *(SH2 **)downcast(device)->token() = sh2 = (SH2 *)drccache_memory_alloc_near(cache, sizeof(SH2)); memset(sh2, 0, sizeof(SH2)); /* initialize the common core parts */ @@ -797,7 +796,7 @@ static CPU_RESET( sh2 ) UINT32 *m; void (*f)(UINT32 data); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; m = sh2->m; tsave = sh2->timer; @@ -3263,7 +3262,7 @@ static CPU_SET_INFO( sh2 ) CPU_GET_INFO( sh2 ) { - SH2 *sh2 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + SH2 *sh2 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/sh4/sh4.c b/src/emu/cpu/sh4/sh4.c index 11defd4522e..27f9b5f44f6 100644 --- a/src/emu/cpu/sh4/sh4.c +++ b/src/emu/cpu/sh4/sh4.c @@ -33,10 +33,9 @@ CPU_DISASSEMBLE( sh4 ); INLINE SH4 *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SH4); - return (SH4 *)device->token; + return (SH4 *)downcast(device)->token(); } /* Called for unimplemented opcodes */ @@ -3255,7 +3254,7 @@ static CPU_RESET( sh4 ) int savecpu_clock, savebus_clock, savepm_clock; void (*f)(UINT32 data); - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; m = sh4->m; tsaved[0] = sh4->dma_timer[0]; @@ -3282,9 +3281,9 @@ static CPU_RESET( sh4 ) sh4->ftcsr_read_callback = f; sh4->irq_callback = save_irqcallback; sh4->device = device; - sh4->internal = device->space(AS_PROGRAM); - sh4->program = device->space(AS_PROGRAM); - sh4->io = device->space(AS_IO); + sh4->internal = device_memory(device)->space(AS_PROGRAM); + sh4->program = device_memory(device)->space(AS_PROGRAM); + sh4->io = device_memory(device)->space(AS_IO); sh4->dma_timer[0] = tsaved[0]; sh4->dma_timer[1] = tsaved[1]; @@ -3384,7 +3383,7 @@ static CPU_EXECUTE( sh4 ) static CPU_INIT( sh4 ) { - const struct sh4_config *conf = (const struct sh4_config *)device->baseconfig().static_config; + const struct sh4_config *conf = (const struct sh4_config *)device->baseconfig().static_config(); SH4 *sh4 = get_safe_token(device); sh4_common_init(device); @@ -3393,9 +3392,9 @@ static CPU_INIT( sh4 ) sh4->irq_callback = irqcallback; sh4->device = device; - sh4->internal = device->space(AS_PROGRAM); - sh4->program = device->space(AS_PROGRAM); - sh4->io = device->space(AS_IO); + sh4->internal = device_memory(device)->space(AS_PROGRAM); + sh4->program = device_memory(device)->space(AS_PROGRAM); + sh4->io = device_memory(device)->space(AS_IO); sh4_default_exception_priorities(sh4); sh4->irln = 15; sh4->test_irq = 0; @@ -3675,7 +3674,7 @@ ADDRESS_MAP_END CPU_GET_INFO( sh4 ) { - SH4 *sh4 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + SH4 *sh4 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/sh4/sh4comn.c b/src/emu/cpu/sh4/sh4comn.c index 18cf77fc8a3..ce8304887a9 100644 --- a/src/emu/cpu/sh4/sh4comn.c +++ b/src/emu/cpu/sh4/sh4comn.c @@ -33,10 +33,9 @@ static const UINT16 tcr[] = { TCR0, TCR1, TCR2 }; INLINE SH4 *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SH4); - return (SH4 *)device->token; + return (SH4 *)downcast(device)->token(); } void sh4_change_register_bank(SH4 *sh4, int to) diff --git a/src/emu/cpu/sh4/sh4comn.h b/src/emu/cpu/sh4/sh4comn.h index c252f67fbf5..16a14f9a09c 100644 --- a/src/emu/cpu/sh4/sh4comn.h +++ b/src/emu/cpu/sh4/sh4comn.h @@ -61,7 +61,7 @@ typedef struct int exception_requesting[128]; INT8 irq_line_state[17]; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *internal; const address_space *program; diff --git a/src/emu/cpu/sharc/sharc.c b/src/emu/cpu/sharc/sharc.c index 759f7010a47..1667b4064e8 100644 --- a/src/emu/cpu/sharc/sharc.c +++ b/src/emu/cpu/sharc/sharc.c @@ -124,7 +124,7 @@ struct _SHARC_REGS UINT16 *internal_ram; UINT16 *internal_ram_block0, *internal_ram_block1; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *data; @@ -187,10 +187,9 @@ static void (* sharc_op[512])(SHARC_REGS *cpustate); INLINE SHARC_REGS *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_ADSP21062); - return (SHARC_REGS *)device->token; + return (SHARC_REGS *)downcast(device)->token(); } INLINE void CHANGE_PC(SHARC_REGS *cpustate, UINT32 newpc) @@ -420,15 +419,15 @@ void sharc_external_dma_write(running_device *device, UINT32 address, UINT64 dat static CPU_INIT( sharc ) { SHARC_REGS *cpustate = get_safe_token(device); - const sharc_config *cfg = (const sharc_config *)device->baseconfig().static_config; + const sharc_config *cfg = (const sharc_config *)device->baseconfig().static_config(); int saveindex; cpustate->boot_mode = cfg->boot_mode; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); build_opcode_table(); @@ -1059,7 +1058,7 @@ ADDRESS_MAP_END static CPU_GET_INFO( sharc ) { - SHARC_REGS *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + SHARC_REGS *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/sm8500/sm8500.c b/src/emu/cpu/sm8500/sm8500.c index f73f5ca49c6..b53c17035e8 100644 --- a/src/emu/cpu/sm8500/sm8500.c +++ b/src/emu/cpu/sm8500/sm8500.c @@ -50,7 +50,7 @@ struct _sm8500_state UINT8 CheckInterrupts; int halted; int icount; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; UINT8 internal_ram[0x500]; @@ -59,10 +59,9 @@ struct _sm8500_state INLINE sm8500_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SM8500); - return (sm8500_state *)device->token; + return (sm8500_state *)downcast(device)->token(); } static const UINT8 sm8500_b2w[8] = { @@ -100,10 +99,10 @@ static CPU_INIT( sm8500 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - if ( device->baseconfig().static_config != NULL ) { - cpustate->config.handle_dma = ((SM8500_CONFIG *)device->baseconfig().static_config)->handle_dma; - cpustate->config.handle_timers = ((SM8500_CONFIG *)device->baseconfig().static_config)->handle_timers; + cpustate->program = device_memory(device)->space(AS_PROGRAM); + if ( device->baseconfig().static_config() != NULL ) { + cpustate->config.handle_dma = ((SM8500_CONFIG *)device->baseconfig().static_config())->handle_dma; + cpustate->config.handle_timers = ((SM8500_CONFIG *)device->baseconfig().static_config())->handle_timers; } else { cpustate->config.handle_dma = NULL; cpustate->config.handle_timers = NULL; @@ -281,9 +280,9 @@ static unsigned sm8500_get_reg( sm8500_state *cpustate, int regnum ) { switch( regnum ) { - case REG_GENPC: + case STATE_GENPC: case SM8500_PC: return cpustate->PC; - case REG_GENSP: + case STATE_GENSP: case SM8500_SP: return ( cpustate->SYS & 0x40 ) ? cpustate->SP : cpustate->SP & 0xFF ; case SM8500_PS: return ( cpustate->PS0 << 8 ) | cpustate->PS1; case SM8500_SYS16: return cpustate->SYS; @@ -321,9 +320,9 @@ static void sm8500_set_reg( sm8500_state *cpustate, int regnum, unsigned val ) { switch( regnum ) { - case REG_GENPC: + case STATE_GENPC: case SM8500_PC: cpustate->PC = val; break; - case REG_GENSP: + case STATE_GENSP: case SM8500_SP: cpustate->SP = val; break; case SM8500_PS: sm8500_set_reg( cpustate, SM8500_PS0, ( val >> 8 ) & 0xFF ); sm8500_set_reg( cpustate, SM8500_PS1, val & 0xFF ); break; case SM8500_SYS16: cpustate->SYS = val; break; @@ -445,7 +444,7 @@ static CPU_SET_INFO( sm8500 ) CPU_GET_INFO( sm8500 ) { - sm8500_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + sm8500_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { @@ -507,8 +506,8 @@ CPU_GET_INFO( sm8500 ) case CPUINFO_INT_REGISTER + SM8500_P2C: case CPUINFO_INT_REGISTER + SM8500_P3C: info->i = sm8500_get_reg( cpustate, state - CPUINFO_INT_REGISTER ); break; - case CPUINFO_INT_REGISTER + REG_GENPC: info->i = sm8500_get_reg( cpustate, SM8500_PC ); break; - case CPUINFO_INT_REGISTER + REG_GENSP: info->i = sm8500_get_reg( cpustate, SM8500_SP ); break; + case CPUINFO_INT_REGISTER + STATE_GENPC: info->i = sm8500_get_reg( cpustate, SM8500_PC ); break; + case CPUINFO_INT_REGISTER + STATE_GENSP: info->i = sm8500_get_reg( cpustate, SM8500_SP ); break; case CPUINFO_INT_PREVIOUSPC: info->i = 0x0000; break; diff --git a/src/emu/cpu/spc700/spc700.c b/src/emu/cpu/spc700/spc700.c index 993fe43ee5f..42ab36dc1f3 100644 --- a/src/emu/cpu/spc700/spc700.c +++ b/src/emu/cpu/spc700/spc700.c @@ -86,7 +86,7 @@ typedef struct uint line_nmi; /* Status of the NMI line */ uint line_rst; /* Status of the RESET line */ uint ir; /* Instruction Register */ - cpu_irq_callback int_ack; + device_irq_callback int_ack; running_device *device; const address_space *program; uint stopped; /* stopped status */ @@ -101,10 +101,9 @@ typedef struct INLINE spc700i_cpu *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SPC700); - return (spc700i_cpu *)device->token; + return (spc700i_cpu *)downcast(device)->token(); } /* ======================================================================== */ @@ -1288,7 +1287,7 @@ static CPU_INIT( spc700 ) INT_ACK = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } @@ -1658,7 +1657,7 @@ static CPU_SET_INFO( spc700 ) CPU_GET_INFO( spc700 ) { - spc700i_cpu *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + spc700i_cpu *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; uint p = 0; if (cpustate != NULL) diff --git a/src/emu/cpu/ssem/ssem.c b/src/emu/cpu/ssem/ssem.c index 5a20acba887..b18c91c8096 100644 --- a/src/emu/cpu/ssem/ssem.c +++ b/src/emu/cpu/ssem/ssem.c @@ -29,10 +29,9 @@ struct _ssem_state INLINE ssem_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SSEM); - return (ssem_state *)device->token; + return (ssem_state *)downcast(device)->token(); } #define INSTR ((op >> 13) & 7) @@ -152,7 +151,7 @@ static CPU_INIT( ssem ) cpustate->halt = 0; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); } static CPU_EXIT( ssem ) @@ -256,7 +255,7 @@ static CPU_SET_INFO( ssem ) CPU_GET_INFO( ssem ) { - ssem_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + ssem_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/ssp1601/ssp1601.c b/src/emu/cpu/ssp1601/ssp1601.c index 3a3a66794fd..a65561bb56b 100644 --- a/src/emu/cpu/ssp1601/ssp1601.c +++ b/src/emu/cpu/ssp1601/ssp1601.c @@ -60,10 +60,9 @@ struct _ssp1601_state_t INLINE ssp1601_state_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SSP1601); - return (ssp1601_state_t *)device->token; + return (ssp1601_state_t *)downcast(device)->token(); } @@ -530,8 +529,8 @@ static CPU_INIT( ssp1601 ) memset(ssp1601_state, 0, sizeof(ssp1601_state_t)); ssp1601_state->gr[0].w.h = 0xffff; // constant reg ssp1601_state->device = device; - ssp1601_state->program = device->space(AS_PROGRAM); - ssp1601_state->io = device->space(AS_IO); + ssp1601_state->program = device_memory(device)->space(AS_PROGRAM); + ssp1601_state->io = device_memory(device)->space(AS_IO); } @@ -809,7 +808,7 @@ static CPU_SET_INFO( ssp1601 ) CPU_GET_INFO( ssp1601 ) { - ssp1601_state_t *ssp1601_state = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + ssp1601_state_t *ssp1601_state = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/superfx/superfx.c b/src/emu/cpu/superfx/superfx.c index 71b17173ef1..b6eb305d0ea 100644 --- a/src/emu/cpu/superfx/superfx.c +++ b/src/emu/cpu/superfx/superfx.c @@ -69,10 +69,9 @@ struct _superfx_state INLINE superfx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_SUPERFX); - return (superfx_state *)device->token; + return (superfx_state *)downcast(device)->token(); } /*****************************************************************************/ @@ -754,11 +753,11 @@ static CPU_INIT( superfx ) superfx_update_speed(cpustate); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); - if (device->baseconfig().static_config != NULL) + if (device->baseconfig().static_config() != NULL) { - cpustate->config = *(superfx_config *)device->baseconfig().static_config; + cpustate->config = *(superfx_config *)device->baseconfig().static_config(); } devcb_resolve_write_line(&cpustate->out_irq_func, &cpustate->config.out_irq_func, device); @@ -1557,7 +1556,7 @@ static CPU_SET_INFO( superfx ) CPU_GET_INFO( superfx ) { - superfx_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + superfx_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/t11/t11.c b/src/emu/cpu/t11/t11.c index 4be9a723ba3..64d341d4256 100644 --- a/src/emu/cpu/t11/t11.c +++ b/src/emu/cpu/t11/t11.c @@ -32,7 +32,7 @@ struct _t11_state UINT8 wait_state; UINT8 irq_state; int icount; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; }; @@ -41,10 +41,9 @@ struct _t11_state INLINE t11_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_T11); - return (t11_state *)device->token; + return (t11_state *)downcast(device)->token(); } @@ -259,13 +258,13 @@ static CPU_INIT( t11 ) 0xc000, 0x8000, 0x4000, 0x2000, 0x1000, 0x0000, 0xf600, 0xf400 }; - const struct t11_setup *setup = (const struct t11_setup *)device->baseconfig().static_config; + const struct t11_setup *setup = (const struct t11_setup *)device->baseconfig().static_config(); t11_state *cpustate = get_safe_token(device); cpustate->initial_pc = initial_pc[setup->mode >> 13]; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); + cpustate->program = device_memory(device)->space(AS_PROGRAM); state_save_register_device_item(device, 0, cpustate->ppc.w.l); state_save_register_device_item(device, 0, cpustate->reg[0].w.l); @@ -413,7 +412,7 @@ static CPU_SET_INFO( t11 ) CPU_GET_INFO( t11 ) { - t11_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + t11_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/tlcs90/tlcs90.c b/src/emu/cpu/tlcs90/tlcs90.c index b9bbbe05bf7..e871367f5fb 100644 --- a/src/emu/cpu/tlcs90/tlcs90.c +++ b/src/emu/cpu/tlcs90/tlcs90.c @@ -30,7 +30,7 @@ typedef struct PAIR af2,bc2,de2,hl2; UINT8 halt, after_EI; UINT16 irq_state, irq_mask; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -63,13 +63,12 @@ typedef struct INLINE t90_Regs *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMP90840 || cpu_get_type(device) == CPU_TMP90841 || cpu_get_type(device) == CPU_TMP91640 || cpu_get_type(device) == CPU_TMP91641); - return (t90_Regs *)device->token; + return (t90_Regs *)downcast(device)->token(); } enum { @@ -2716,8 +2715,8 @@ static CPU_INIT( t90 ) memset(cpustate, 0, sizeof(t90_Regs)); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->timer_period = attotime_mul(ATTOTIME_IN_HZ(cpu_get_clock(device)), 8); @@ -2791,7 +2790,7 @@ static CPU_SET_INFO( t90 ) CPU_GET_INFO( tmp90840 ) { - t90_Regs *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + t90_Regs *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/tlcs900/tlcs900.c b/src/emu/cpu/tlcs900/tlcs900.c index ca881bb91e9..49ba68f5540 100644 --- a/src/emu/cpu/tlcs900/tlcs900.c +++ b/src/emu/cpu/tlcs900/tlcs900.c @@ -71,7 +71,7 @@ struct _tlcs900_state int halted; int icount; int regbank; - cpu_irq_callback irqcallback; + device_irq_callback irqcallback; running_device *device; const address_space *program; }; @@ -207,11 +207,10 @@ struct _tlcs900_state INLINE tlcs900_state *get_safe_token( running_device *device ) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == CPU ); + assert( device->type() == CPU ); assert( cpu_get_type(device) == CPU_TLCS900H ); - return (tlcs900_state *) device->token; + return (tlcs900_state *) downcast(device)->token(); } @@ -219,10 +218,10 @@ static CPU_INIT( tlcs900 ) { tlcs900_state *cpustate = get_safe_token(device); - cpustate->intf = (const tlcs900_interface *)device->baseconfig().static_config; + cpustate->intf = (const tlcs900_interface *)device->baseconfig().static_config(); cpustate->irqcallback = irqcallback; cpustate->device = device; - cpustate->program = device->space( AS_PROGRAM ); + cpustate->program = device_memory(device)->space( AS_PROGRAM ); devcb_resolve_write8( &cpustate->to1, &cpustate->intf->to1, device ); devcb_resolve_write8( &cpustate->to3, &cpustate->intf->to3, device ); @@ -1126,7 +1125,7 @@ static CPU_SET_INFO( tlcs900 ) CPU_GET_INFO( tlcs900h ) { - tlcs900_state *cpustate = ( device != NULL && device->token != NULL ) ? get_safe_token(device) : NULL; + tlcs900_state *cpustate = ( device != NULL && downcast(device)->token() != NULL ) ? get_safe_token(device) : NULL; switch( state ) { diff --git a/src/emu/cpu/tms0980/tms0980.c b/src/emu/cpu/tms0980/tms0980.c index 1e1651588b4..dab45d007da 100644 --- a/src/emu/cpu/tms0980/tms0980.c +++ b/src/emu/cpu/tms0980/tms0980.c @@ -449,8 +449,7 @@ static const UINT32 tms1100_default_decode[256] = { INLINE tms0980_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS0980 || cpu_get_type(device) == CPU_TMS1000 || cpu_get_type(device) == CPU_TMS1070 || @@ -458,7 +457,7 @@ INLINE tms0980_state *get_safe_token(running_device *device) cpu_get_type(device) == CPU_TMS1200 || cpu_get_type(device) == CPU_TMS1270 || cpu_get_type(device) == CPU_TMS1300 ); - return (tms0980_state *)device->token; + return (tms0980_state *)downcast(device)->token(); } @@ -496,7 +495,7 @@ static void cpu_init_tms_common( running_device *device, const UINT32* decode_ta { tms0980_state *cpustate = get_safe_token( device ); - cpustate->config = (const tms0980_config *) device->baseconfig().static_config; + cpustate->config = (const tms0980_config *) device->baseconfig().static_config(); assert( cpustate->config != NULL ); @@ -506,8 +505,8 @@ static void cpu_init_tms_common( running_device *device, const UINT32* decode_ta cpustate->pc_size = pc_size; cpustate->byte_size = byte_size; - cpustate->program = device->space( AS_PROGRAM ); - cpustate->data = device->space( AS_PROGRAM ); + cpustate->program = device_memory(device)->space( AS_PROGRAM ); + cpustate->data = device_memory(device)->space( AS_PROGRAM ); state_save_register_device_item( device, 0, cpustate->prev_pc ); state_save_register_device_item( device, 0, cpustate->prev_pa ); @@ -1115,7 +1114,7 @@ static CPU_SET_INFO( tms0980 ) static CPU_GET_INFO( tms_generic ) { - tms0980_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms0980_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { @@ -1171,7 +1170,7 @@ static CPU_GET_INFO( tms_generic ) CPU_GET_INFO( tms0980 ) { - tms0980_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms0980_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { @@ -1194,7 +1193,7 @@ CPU_GET_INFO( tms0980 ) CPU_GET_INFO( tms1000 ) { - tms0980_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms0980_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { @@ -1251,7 +1250,7 @@ CPU_GET_INFO( tms1270 ) CPU_GET_INFO( tms1100 ) { - tms0980_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms0980_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/tms32010/tms32010.c b/src/emu/cpu/tms32010/tms32010.c index 79659162f23..145dc5d5fb2 100644 --- a/src/emu/cpu/tms32010/tms32010.c +++ b/src/emu/cpu/tms32010/tms32010.c @@ -100,10 +100,9 @@ struct _tms32010_state INLINE tms32010_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS32010); - return (tms32010_state *)device->token; + return (tms32010_state *)downcast(device)->token(); } /* opcode table entry */ @@ -801,9 +800,9 @@ static CPU_INIT( tms32010 ) state_save_register_device_item(device, 0, cpustate->addr_mask); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); } @@ -944,7 +943,7 @@ static CPU_SET_INFO( tms32010 ) CPU_GET_INFO( tms32010 ) { - tms32010_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms32010_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/tms32025/tms32025.c b/src/emu/cpu/tms32025/tms32025.c index 6afa0978c26..c682ec0ebd5 100644 --- a/src/emu/cpu/tms32025/tms32025.c +++ b/src/emu/cpu/tms32025/tms32025.c @@ -165,7 +165,7 @@ struct _tms32025_state int init_load_addr; /* 0=No, 1=Yes, 2=Once for repeat mode */ int tms32025_irq_cycles; int tms32025_dec_cycles; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; PAIR oldacc; UINT32 memaccess; @@ -185,11 +185,10 @@ struct _tms32025_state INLINE tms32025_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS32025 || cpu_get_type(device) == CPU_TMS32026); - return (tms32025_state *)device->token; + return (tms32025_state *)downcast(device)->token(); } /* opcode table entry */ @@ -1723,9 +1722,9 @@ static CPU_INIT( tms32025 ) cpustate->intRAM = auto_alloc_array(device->machine, UINT16, 0x800); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->PC); state_save_register_device_item(device, 0, cpustate->STR0); @@ -2311,7 +2310,7 @@ static CPU_SET_INFO( tms32025 ) CPU_GET_INFO( tms32025 ) { - tms32025_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms32025_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/tms32031/tms32031.c b/src/emu/cpu/tms32031/tms32031.c index 028a08c4111..26cd86a78f9 100644 --- a/src/emu/cpu/tms32031/tms32031.c +++ b/src/emu/cpu/tms32031/tms32031.c @@ -118,7 +118,7 @@ struct _tms32031_state tms32031_xf_func xf0_w; tms32031_xf_func xf1_w; tms32031_iack_func iack_w; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; }; @@ -126,11 +126,10 @@ struct _tms32031_state INLINE tms32031_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS32031 || cpu_get_type(device) == CPU_TMS32032); - return (tms32031_state *)device->token; + return (tms32031_state *)downcast(device)->token(); } @@ -369,13 +368,13 @@ static void set_irq_line(tms32031_state *tms, int irqline, int state) static CPU_INIT( tms32031 ) { - const tms32031_config *configdata = (const tms32031_config *)device->baseconfig().static_config; + const tms32031_config *configdata = (const tms32031_config *)device->baseconfig().static_config(); tms32031_state *tms = get_safe_token(device); int i; tms->irq_callback = irqcallback; tms->device = device; - tms->program = device->space(AS_PROGRAM); + tms->program = device_memory(device)->space(AS_PROGRAM); /* copy in the xf write routines */ tms->bootoffset = (configdata != NULL) ? configdata->bootoffset : 0; @@ -689,7 +688,7 @@ ADDRESS_MAP_END CPU_GET_INFO( tms32031 ) { - tms32031_state *tms = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms32031_state *tms = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; float ftemp; switch (state) diff --git a/src/emu/cpu/tms32051/tms32051.c b/src/emu/cpu/tms32051/tms32051.c index f825f3c89b3..1183e27a223 100644 --- a/src/emu/cpu/tms32051/tms32051.c +++ b/src/emu/cpu/tms32051/tms32051.c @@ -142,7 +142,7 @@ struct _tms32051_state INT32 treg2; } shadow; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *data; @@ -152,10 +152,9 @@ struct _tms32051_state INLINE tms32051_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS32051); - return (tms32051_state *)device->token; + return (tms32051_state *)downcast(device)->token(); } static void delay_slot(tms32051_state *cpustate, UINT16 startpc); @@ -225,8 +224,8 @@ static CPU_INIT( tms ) tms32051_state *cpustate = get_safe_token(device); cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); } static CPU_RESET( tms ) @@ -576,7 +575,7 @@ static CPU_READ( tms ) static CPU_GET_INFO( tms ) { - tms32051_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms32051_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/tms34010/34010gfx.c b/src/emu/cpu/tms34010/34010gfx.c index 2e3995a5ee8..cfb74e9b666 100644 --- a/src/emu/cpu/tms34010/34010gfx.c +++ b/src/emu/cpu/tms34010/34010gfx.c @@ -25,7 +25,7 @@ static void line(tms34010_state *tms, UINT16 op) tms->st |= STBIT_P; TEMP(tms) = (op & 0x80) ? 1 : 0; /* boundary value depends on the algorithm */ - LOGGFX(("%08X(%3d):LINE (%d,%d)-(%d,%d)\n", tms->pc, video_screen_get_vpos(tms->screen), DADDR_X(tms), DADDR_Y(tms), DADDR_X(tms) + DYDX_X(tms), DADDR_Y(tms) + DYDX_Y(tms))); + LOGGFX(("%08X(%3d):LINE (%d,%d)-(%d,%d)\n", tms->pc, tms->screen->vpos(), DADDR_X(tms), DADDR_Y(tms), DADDR_X(tms) + DYDX_X(tms), DADDR_Y(tms) + DYDX_Y(tms))); } if (COUNT(tms) > 0) @@ -906,7 +906,7 @@ static void pixblt_b_l(tms34010_state *tms, UINT16 op) int trans = (IOREG(tms, REG_CONTROL) & 0x20) >> 5; int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT B,L (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT B,L (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; (*pixblt_b_op_table[ix])(tms, 1); @@ -918,7 +918,7 @@ static void pixblt_b_xy(tms34010_state *tms, UINT16 op) int trans = (IOREG(tms, REG_CONTROL) & 0x20) >> 5; int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT B,XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT B,XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; (*pixblt_b_op_table[ix])(tms, 0); @@ -931,7 +931,7 @@ static void pixblt_l_l(tms34010_state *tms, UINT16 op) int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int pbh = (IOREG(tms, REG_CONTROL) >> 8) & 1; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT L,L (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT L,L (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; if (!pbh) @@ -947,7 +947,7 @@ static void pixblt_l_xy(tms34010_state *tms, UINT16 op) int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int pbh = (IOREG(tms, REG_CONTROL) >> 8) & 1; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT L,XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT L,XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; if (!pbh) @@ -963,7 +963,7 @@ static void pixblt_xy_l(tms34010_state *tms, UINT16 op) int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int pbh = (IOREG(tms, REG_CONTROL) >> 8) & 1; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT XY,L (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT XY,L (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; if (!pbh) @@ -979,7 +979,7 @@ static void pixblt_xy_xy(tms34010_state *tms, UINT16 op) int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int pbh = (IOREG(tms, REG_CONTROL) >> 8) & 1; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT XY,XY (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):PIXBLT XY,XY (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; if (!pbh) @@ -994,7 +994,7 @@ static void fill_l(tms34010_state *tms, UINT16 op) int trans = (IOREG(tms, REG_CONTROL) & 0x20) >> 5; int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):FILL L (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):FILL L (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; (*fill_op_table[ix])(tms, 1); @@ -1006,7 +1006,7 @@ static void fill_xy(tms34010_state *tms, UINT16 op) int trans = (IOREG(tms, REG_CONTROL) & 0x20) >> 5; int rop = (IOREG(tms, REG_CONTROL) >> 10) & 0x1f; int ix = trans | (rop << 1) | (psize << 6); - if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):FILL XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, video_screen_get_vpos(tms->screen), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); + if (!P_FLAG(tms)) LOGGFX(("%08X(%3d):FILL XY (%d,%d) (%dx%d) depth=%d\n", tms->pc, tms->screen->vpos(), DADDR_X(tms), DADDR_Y(tms), DYDX_X(tms), DYDX_Y(tms), IOREG(tms, REG_PSIZE) ? IOREG(tms, REG_PSIZE) : 32)); pixel_op = pixel_op_table[rop]; pixel_op_timing = pixel_op_timing_table[rop]; (*fill_op_table[ix])(tms, 0); diff --git a/src/emu/cpu/tms34010/tms34010.c b/src/emu/cpu/tms34010/tms34010.c index 6a08660a7e5..9fb75e6f71a 100644 --- a/src/emu/cpu/tms34010/tms34010.c +++ b/src/emu/cpu/tms34010/tms34010.c @@ -61,11 +61,11 @@ struct _tms34010_state UINT8 hblank_stable; UINT8 external_host_access; UINT8 executing; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const tms34010_config *config; - running_device *screen; + screen_device *screen; emu_timer * scantimer; int icount; @@ -78,18 +78,15 @@ struct _tms34010_state } regs[31]; UINT16 IOregs[64]; - - cpu_state_table state; }; INLINE tms34010_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS34010 || cpu_get_type(device) == CPU_TMS34020); - return (tms34010_state *)device->token; + return (tms34010_state *)downcast(device)->token(); } #include "34010ops.h" @@ -201,66 +198,6 @@ static STATE_POSTLOAD( tms34010_state_postload ); -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define TMS340X0_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(TMS34010_##_name, #_name, _format, tms34010_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - TMS340X0_STATE_ENTRY(PC, "%08X", pc, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(GENPC, "%08X", pc, 0xffffffff, CPUSTATE_NOSHOW) - TMS340X0_STATE_ENTRY(GENPCBASE, "%08X", ppc, 0xffffffff, CPUSTATE_NOSHOW) - - TMS340X0_STATE_ENTRY(SP, "%08X", regs[15].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(GENSP, "%08X", regs[15].reg, 0xffffffff, CPUSTATE_NOSHOW) - - TMS340X0_STATE_ENTRY(ST, "%08X", st, 0xffffffff, 0) - - TMS340X0_STATE_ENTRY(A0, "%08X", regs[0].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A1, "%08X", regs[1].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A2, "%08X", regs[2].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A3, "%08X", regs[3].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A4, "%08X", regs[4].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A5, "%08X", regs[5].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A6, "%08X", regs[6].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A7, "%08X", regs[7].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A8, "%08X", regs[8].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A9, "%08X", regs[9].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A10, "%08X", regs[10].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A11, "%08X", regs[11].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A12, "%08X", regs[12].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A13, "%08X", regs[13].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(A14, "%08X", regs[14].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B0, "%08X", regs[30-0].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B1, "%08X", regs[30-1].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B2, "%08X", regs[30-2].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B3, "%08X", regs[30-3].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B4, "%08X", regs[30-4].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B5, "%08X", regs[30-5].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B6, "%08X", regs[30-6].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B7, "%08X", regs[30-7].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B8, "%08X", regs[30-8].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B9, "%08X", regs[30-9].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B10, "%08X", regs[30-10].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B11, "%08X", regs[30-11].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B12, "%08X", regs[30-12].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B13, "%08X", regs[30-13].reg, 0xffffffff, 0) - TMS340X0_STATE_ENTRY(B14, "%08X", regs[30-14].reg, 0xffffffff, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - - /*************************************************************************** INLINE SHORTCUTS ***************************************************************************/ @@ -683,7 +620,7 @@ static void check_interrupt(tms34010_state *tms) static CPU_INIT( tms34010 ) { - const tms34010_config *configdata = device->baseconfig().static_config ? (const tms34010_config *)device->baseconfig().static_config : &default_config; + const tms34010_config *configdata = device->baseconfig().static_config() ? (const tms34010_config *)device->baseconfig().static_config() : &default_config; tms34010_state *tms = get_safe_token(device); tms->external_host_access = FALSE; @@ -691,13 +628,27 @@ static CPU_INIT( tms34010 ) tms->config = configdata; tms->irq_callback = irqcallback; tms->device = device; - tms->program = device->space(AS_PROGRAM); - tms->screen = device->machine->device(configdata->screen_tag); + tms->program = device_memory(device)->space(AS_PROGRAM); + tms->screen = downcast(device->machine->device(configdata->screen_tag)); /* set up the state table */ - tms->state = state_table_template; - tms->state.baseptr = tms; - tms->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(TMS34010_PC, "PC", tms->pc); + state->state_add(STATE_GENPC, "GENPC", tms->pc).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", tms->ppc).noshow(); + state->state_add(TMS34010_SP, "SP", tms->regs[15].reg); + state->state_add(STATE_GENSP, "GENSP", tms->regs[15].reg).noshow(); + state->state_add(TMS34010_ST, "ST", tms->st); + state->state_add(STATE_GENFLAGS, "GENFLAGS", tms->st).noshow().formatstr("%18s"); + + astring tempstr; + for (int regnum = 0; regnum < 15; regnum++) + state->state_add(TMS34010_A0 + regnum, tempstr.format("A%d", regnum), tms->regs[regnum].reg); + for (int regnum = 0; regnum < 15; regnum++) + state->state_add(TMS34010_B0 + regnum, tempstr.format("B%d", regnum), tms->regs[30 - regnum].reg); + } /* allocate a scanline timer and set it to go off at the start */ tms->scantimer = timer_alloc(device->machine, scanline_callback, tms); @@ -725,11 +676,10 @@ static CPU_RESET( tms34010 ) /* zap the state and copy in the config pointer */ tms34010_state *tms = get_safe_token(device); const tms34010_config *config = tms->config; - running_device *screen = tms->screen; + screen_device *screen = tms->screen; UINT16 *shiftreg = tms->shiftreg; - cpu_irq_callback save_irqcallback = tms->irq_callback; + device_irq_callback save_irqcallback = tms->irq_callback; emu_timer *save_scantimer = tms->scantimer; - cpu_state_table savetable = tms->state; memset(tms, 0, sizeof(*tms)); @@ -739,8 +689,7 @@ static CPU_RESET( tms34010 ) tms->irq_callback = save_irqcallback; tms->scantimer = save_scantimer; tms->device = device; - tms->program = device->space(AS_PROGRAM); - tms->state = savetable; + tms->program = device_memory(device)->space(AS_PROGRAM); /* fetch the initial PC and reset the state */ tms->pc = RLONG(tms, 0xffffffe0) & 0xfffffff0; @@ -750,7 +699,7 @@ static CPU_RESET( tms34010 ) /* the first time we are run */ tms->reset_deferred = tms->config->halt_on_reset; if (tms->config->halt_on_reset) - tms34010_io_register_w(device->space(AS_PROGRAM), REG_HSTCTLH, 0x8000, 0xffff); + tms34010_io_register_w(device_memory(device)->space(AS_PROGRAM), REG_HSTCTLH, 0x8000, 0xffff); } @@ -959,14 +908,13 @@ static void set_raster_op(tms34010_state *tms) static TIMER_CALLBACK( scanline_callback ) { tms34010_state *tms = (tms34010_state *)ptr; - const rectangle *current_visarea; int vsblnk, veblnk, vtotal; int vcount = param; int enabled; int master; /* fetch the core timing parameters */ - current_visarea = video_screen_get_visible_area(tms->screen); + const rectangle ¤t_visarea = tms->screen->visible_area(); enabled = SMART_IOREG(tms, DPYCTL) & 0x8000; master = (tms->is_34020 || (SMART_IOREG(tms, DPYCTL) & 0x2000)); vsblnk = SMART_IOREG(tms, VSBLNK); @@ -974,8 +922,8 @@ static TIMER_CALLBACK( scanline_callback ) vtotal = SMART_IOREG(tms, VTOTAL); if (!master) { - vtotal = MIN(video_screen_get_height(tms->screen) - 1, vtotal); - vcount = video_screen_get_vpos(tms->screen); + vtotal = MIN(tms->screen->height() - 1, vtotal); + vcount = tms->screen->vpos(); } /* update the VCOUNT */ @@ -1033,13 +981,13 @@ static TIMER_CALLBACK( scanline_callback ) /* because many games play with the HEBLNK/HSBLNK for effects, we don't change if they are the only thing that has changed, unless they are stable for a couple of frames */ - int current_width = video_screen_get_width(tms->screen); - int current_height = video_screen_get_height(tms->screen); + int current_width = tms->screen->width(); + int current_height = tms->screen->height(); - if (width != current_width || height != current_height || visarea.min_y != current_visarea->min_y || visarea.max_y != current_visarea->max_y || - (tms->hblank_stable > 2 && (visarea.min_x != current_visarea->min_x || visarea.max_x != current_visarea->max_x))) + if (width != current_width || height != current_height || visarea.min_y != current_visarea.min_y || visarea.max_y != current_visarea.max_y || + (tms->hblank_stable > 2 && (visarea.min_x != current_visarea.min_x || visarea.max_x != current_visarea.max_x))) { - video_screen_configure(tms->screen, width, height, &visarea, refresh); + tms->screen->configure(width, height, visarea, refresh); } tms->hblank_stable++; } @@ -1055,8 +1003,8 @@ static TIMER_CALLBACK( scanline_callback ) } /* force a partial update within the visible area */ - if (vcount >= current_visarea->min_y && vcount <= current_visarea->max_y && tms->config->scanline_callback != NULL) - video_screen_update_partial(tms->screen, vcount); + if (vcount >= current_visarea.min_y && vcount <= current_visarea.max_y && tms->config->scanline_callback != NULL) + tms->screen->update_partial(vcount); /* if we are in the visible area, increment DPYADR by DUDATE */ if (vcount >= veblnk && vcount < vsblnk) @@ -1092,7 +1040,7 @@ static TIMER_CALLBACK( scanline_callback ) /* note that we add !master (0 or 1) as a attoseconds value; this makes no practical difference */ /* but helps ensure that masters are updated first before slaves */ - timer_adjust_oneshot(tms->scantimer, attotime_add_attoseconds(video_screen_get_time_until_pos(tms->screen, vcount, 0), !master), vcount); + timer_adjust_oneshot(tms->scantimer, attotime_add_attoseconds(tms->screen->time_until_pos(vcount), !master), vcount); } @@ -1161,7 +1109,7 @@ VIDEO_UPDATE( tms340x0 ) { /* call through to the callback */ LOG((" Update: scan=%3d ROW=%04X COL=%04X\n", cliprect->min_y, params.rowaddr, params.coladdr)); - (*tms->config->scanline_callback)(screen, bitmap, cliprect->min_y, ¶ms); + (*tms->config->scanline_callback)(*screen, bitmap, cliprect->min_y, ¶ms); } /* otherwise, just blank the current scanline */ @@ -1322,7 +1270,7 @@ WRITE16_HANDLER( tms34010_io_register_w ) } // if (LOG_CONTROL_REGS) -// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(tms->device->machine), ioreg_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); +// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(tms->device->machine), ioreg_name[offset], IOREG(tms, offset), tms->screen->vpos()); } @@ -1359,7 +1307,7 @@ WRITE16_HANDLER( tms34020_io_register_w ) IOREG(tms, offset) = data; // if (LOG_CONTROL_REGS) -// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(device->machine), ioreg020_name[offset], IOREG(tms, offset), video_screen_get_vpos(tms->screen)); +// logerror("%s: %s = %04X (%d)\n", cpuexec_describe_context(device->machine), ioreg020_name[offset], IOREG(tms, offset), tms->screen->vpos()); switch (offset) { @@ -1524,9 +1472,9 @@ READ16_HANDLER( tms34010_io_register_r ) { case REG_HCOUNT: /* scale the horizontal position from screen width to HTOTAL */ - result = video_screen_get_hpos(tms->screen); + result = tms->screen->hpos(); total = IOREG(tms, REG_HTOTAL) + 1; - result = result * total / video_screen_get_width(tms->screen); + result = result * total / tms->screen->width(); /* offset by the HBLANK end */ result += IOREG(tms, REG_HEBLNK); @@ -1567,9 +1515,9 @@ READ16_HANDLER( tms34020_io_register_r ) { case REG020_HCOUNT: /* scale the horizontal position from screen width to HTOTAL */ - result = video_screen_get_hpos(tms->screen); + result = tms->screen->hpos(); total = IOREG(tms, REG020_HTOTAL) + 1; - result = result * total / video_screen_get_width(tms->screen); + result = result * total / tms->screen->width(); /* offset by the HBLANK end */ result += IOREG(tms, REG020_HEBLNK); @@ -1646,7 +1594,7 @@ void tms34010_host_w(running_device *cpu, int reg, int data) /* control register */ case TMS34010_HOST_CONTROL: tms->external_host_access = TRUE; - space = tms->device->space(AS_PROGRAM); + space = device_memory(tms->device)->space(AS_PROGRAM); tms34010_io_register_w(space, REG_HSTCTLH, data & 0xff00, 0xffff); tms34010_io_register_w(space, REG_HSTCTLL, data & 0x00ff, 0xffff); tms->external_host_access = FALSE; @@ -1740,9 +1688,39 @@ static CPU_SET_INFO( tms34010 ) * Generic get_info **************************************************************************/ +CPU_EXPORT_STRING( tms34010 ) +{ + tms34010_state *tms = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", + tms->st & 0x80000000 ? 'N':'.', + tms->st & 0x40000000 ? 'C':'.', + tms->st & 0x20000000 ? 'Z':'.', + tms->st & 0x10000000 ? 'V':'.', + tms->st & 0x02000000 ? 'P':'.', + tms->st & 0x00200000 ? 'I':'.', + tms->st & 0x00000800 ? 'E':'.', + tms->st & 0x00000400 ? 'F':'.', + tms->st & 0x00000200 ? 'F':'.', + tms->st & 0x00000100 ? 'F':'.', + tms->st & 0x00000080 ? 'F':'.', + tms->st & 0x00000040 ? 'F':'.', + tms->st & 0x00000020 ? 'E':'.', + tms->st & 0x00000010 ? 'F':'.', + tms->st & 0x00000008 ? 'F':'.', + tms->st & 0x00000004 ? 'F':'.', + tms->st & 0x00000002 ? 'F':'.', + tms->st & 0x00000001 ? 'F':'.'); + break; + } +} + CPU_GET_INFO( tms34010 ) { - tms34010_state *tms = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms34010_state *tms = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -1773,10 +1751,10 @@ CPU_GET_INFO( tms34010 ) case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(tms34010); break; case CPUINFO_FCT_BURN: info->burn = NULL; break; case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(tms34010); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(tms34010); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &tms->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &tms->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "TMS34010"); break; @@ -1784,28 +1762,6 @@ CPU_GET_INFO( tms34010 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Alex Pasadyn/Zsolt Vasvari\nParts based on code by Aaron Giles"); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", - tms->st & 0x80000000 ? 'N':'.', - tms->st & 0x40000000 ? 'C':'.', - tms->st & 0x20000000 ? 'Z':'.', - tms->st & 0x10000000 ? 'V':'.', - tms->st & 0x02000000 ? 'P':'.', - tms->st & 0x00200000 ? 'I':'.', - tms->st & 0x00000800 ? 'E':'.', - tms->st & 0x00000400 ? 'F':'.', - tms->st & 0x00000200 ? 'F':'.', - tms->st & 0x00000100 ? 'F':'.', - tms->st & 0x00000080 ? 'F':'.', - tms->st & 0x00000040 ? 'F':'.', - tms->st & 0x00000020 ? 'E':'.', - tms->st & 0x00000010 ? 'F':'.', - tms->st & 0x00000008 ? 'F':'.', - tms->st & 0x00000004 ? 'F':'.', - tms->st & 0x00000002 ? 'F':'.', - tms->st & 0x00000001 ? 'F':'.'); - break; } } diff --git a/src/emu/cpu/tms34010/tms34010.h b/src/emu/cpu/tms34010/tms34010.h index 62b40d218aa..6e1d453bc00 100644 --- a/src/emu/cpu/tms34010/tms34010.h +++ b/src/emu/cpu/tms34010/tms34010.h @@ -50,9 +50,9 @@ enum TMS34010_B13, TMS34010_B14, - TMS34010_GENPC = REG_GENPC, - TMS34010_GENSP = REG_GENSP, - TMS34010_GENPCBASE = REG_GENPCBASE + TMS34010_GENPC = STATE_GENPC, + TMS34010_GENSP = STATE_GENSP, + TMS34010_GENPCBASE = STATE_GENPCBASE }; @@ -196,7 +196,7 @@ struct _tms34010_config const char *screen_tag; /* the screen operated on */ UINT32 pixclock; /* the pixel clock (0 means don't adjust screen size) */ int pixperclock; /* pixels per clock */ - void (*scanline_callback)(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); + void (*scanline_callback)(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); void (*output_int)(running_device *device, int state); /* output interrupt callback */ void (*to_shiftreg)(const address_space *space, offs_t, UINT16 *); /* shift register write */ void (*from_shiftreg)(const address_space *space, offs_t, UINT16 *); /* shift register read */ diff --git a/src/emu/cpu/tms57002/tms57002.c b/src/emu/cpu/tms57002/tms57002.c index b1c56dfc089..1f782b1e3e2 100644 --- a/src/emu/cpu/tms57002/tms57002.c +++ b/src/emu/cpu/tms57002/tms57002.c @@ -112,10 +112,9 @@ typedef struct { INLINE tms57002_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS57002); - return (tms57002_t *)device->token; + return (tms57002_t *)downcast(device)->token(); } static void tms57002_cache_flush(tms57002_t *s); @@ -1343,8 +1342,8 @@ static CPU_INIT(tms57002) tms57002_t *s = get_safe_token(device); tms57002_cache_flush(s); s->sti = S_IDLE; - s->program = device->space(AS_PROGRAM); - s->data = device->space(AS_DATA); + s->program = device_memory(device)->space(AS_PROGRAM); + s->data = device_memory(device)->space(AS_DATA); } @@ -1358,7 +1357,7 @@ ADDRESS_MAP_END CPU_GET_INFO(tms57002) { - tms57002_t *s = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms57002_t *s = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(tms57002_t); break; diff --git a/src/emu/cpu/tms7000/tms7000.c b/src/emu/cpu/tms7000/tms7000.c index c4384082c91..a27e22afbb8 100644 --- a/src/emu/cpu/tms7000/tms7000.c +++ b/src/emu/cpu/tms7000/tms7000.c @@ -72,7 +72,7 @@ struct _tms7000_state UINT8 irq_state[3]; /* State of the three IRQs */ UINT8 rf[0x80]; /* Register file (SJE) */ UINT8 pf[0x100]; /* Perpherial file */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -88,11 +88,10 @@ struct _tms7000_state INLINE tms7000_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_TMS7000 || cpu_get_type(device) == CPU_TMS7000_EXL); - return (tms7000_state *)device->token; + return (tms7000_state *)downcast(device)->token(); } #define pPC cpustate->pc.w.l @@ -166,8 +165,8 @@ static CPU_INIT( tms7000 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); memset(cpustate->pf, 0, 0x100); memset(cpustate->rf, 0, 0x80); @@ -265,7 +264,7 @@ static CPU_SET_INFO( tms7000 ) CPU_GET_INFO( tms7000 ) { - tms7000_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms7000_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch( state ) { diff --git a/src/emu/cpu/tms9900/99xxcore.h b/src/emu/cpu/tms9900/99xxcore.h index fd5228bca2a..d2be6c05de9 100644 --- a/src/emu/cpu/tms9900/99xxcore.h +++ b/src/emu/cpu/tms9900/99xxcore.h @@ -435,7 +435,7 @@ struct _tms99xx_state /* interrupt callback */ /* note that this callback is used by tms9900_set_irq_line(cpustate) and tms9980a_set_irq_line(cpustate) to retreive the value on IC0-IC3 (non-standard behaviour) */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -512,10 +512,9 @@ struct _tms99xx_state INLINE tms99xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == TMS99XX_GET_INFO); - return (tms99xx_state *)device->token; + return (tms99xx_state *)downcast(device)->token(); } #if (TMS99XX_MODEL == TMS9995_ID) @@ -1288,7 +1287,7 @@ static void register_for_save_state(running_device *device) static CPU_INIT( tms99xx ) { - const TMS99XX_RESET_PARAM *param = (const TMS99XX_RESET_PARAM *) device->baseconfig().static_config; + const TMS99XX_RESET_PARAM *param = (const TMS99XX_RESET_PARAM *) device->baseconfig().static_config(); tms99xx_state *cpustate = get_safe_token(device); register_for_save_state(device); @@ -1296,8 +1295,8 @@ static CPU_INIT( tms99xx ) cpustate->irq_level = 16; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); #if (TMS99XX_MODEL == TMS9995_ID) cpustate->timer = timer_alloc(device->machine, decrementer_callback, cpustate); @@ -4637,7 +4636,7 @@ static CPU_SET_INFO( tms99xx ) void TMS99XX_GET_INFO(const device_config *devconfig, running_device *device, UINT32 state, cpuinfo *info) { - tms99xx_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + tms99xx_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/unsp/unsp.c b/src/emu/cpu/unsp/unsp.c index ba629b19bde..8e4d5624210 100644 --- a/src/emu/cpu/unsp/unsp.c +++ b/src/emu/cpu/unsp/unsp.c @@ -13,10 +13,9 @@ INLINE unsp_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_UNSP); - return (unsp_state *)device->token; + return (unsp_state *)downcast(device)->token(); } static void unsp_set_irq_line(unsp_state *unsp, int irqline, int state); @@ -116,7 +115,7 @@ static CPU_INIT( unsp ) memset(unsp->r, 0, sizeof(UINT16) * UNSP_GPR_COUNT); unsp->device = device; - unsp->program = device->space(AS_PROGRAM); + unsp->program = device_memory(device)->space(AS_PROGRAM); unsp->irq = 0; unsp->fiq = 0; } @@ -857,7 +856,7 @@ static CPU_SET_INFO( unsp ) CPU_GET_INFO( unsp ) { - unsp_state *unsp = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + unsp_state *unsp = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch(state) { diff --git a/src/emu/cpu/upd7810/upd7810.c b/src/emu/cpu/upd7810/upd7810.c index 7b9a843cac9..0d2742b277c 100644 --- a/src/emu/cpu/upd7810/upd7810.c +++ b/src/emu/cpu/upd7810/upd7810.c @@ -498,7 +498,7 @@ struct _upd7810_state const struct opcode_s *op74; void (*handle_timers)(upd7810_state *cpustate, int cycles); UPD7810_CONFIG config; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -508,14 +508,13 @@ struct _upd7810_state INLINE upd7810_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_UPD7810 || cpu_get_type(device) == CPU_UPD7807 || cpu_get_type(device) == CPU_UPD7801 || cpu_get_type(device) == CPU_UPD78C05 || cpu_get_type(device) == CPU_UPD78C06); - return (upd7810_state *)device->token; + return (upd7810_state *)downcast(device)->token(); } #define CY 0x01 @@ -1701,11 +1700,11 @@ static CPU_INIT( upd7810 ) { upd7810_state *cpustate = get_safe_token(device); - cpustate->config = *(const UPD7810_CONFIG*) device->baseconfig().static_config; + cpustate->config = *(const UPD7810_CONFIG*) device->baseconfig().static_config(); cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item(device, 0, cpustate->ppc.w.l); state_save_register_device_item(device, 0, cpustate->pc.w.l); @@ -1780,7 +1779,7 @@ static CPU_RESET( upd7810 ) { upd7810_state *cpustate = get_safe_token(device); UPD7810_CONFIG save_config; - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_config = cpustate->config; save_irqcallback = cpustate->irq_callback; @@ -1788,8 +1787,8 @@ static CPU_RESET( upd7810 ) cpustate->config = save_config; cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->opXX = opXX_7810; cpustate->op48 = op48; @@ -2130,7 +2129,7 @@ static CPU_SET_INFO( upd7810 ) CPU_GET_INFO( upd7810 ) { - upd7810_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + upd7810_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ diff --git a/src/emu/cpu/v30mz/v30mz.c b/src/emu/cpu/v30mz/v30mz.c index b1a0c91d12a..e1d9afcff94 100644 --- a/src/emu/cpu/v30mz/v30mz.c +++ b/src/emu/cpu/v30mz/v30mz.c @@ -83,7 +83,7 @@ struct _v30mz_state UINT32 irq_state; UINT8 no_interrupt; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -104,10 +104,9 @@ extern int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, const nec INLINE v30mz_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_V30MZ); - return (v30mz_state *)device->token; + return (v30mz_state *)downcast(device)->token(); } /***************************************************************************/ @@ -134,14 +133,14 @@ static CPU_RESET( nec ) v30mz_state *cpustate = get_safe_token(device); unsigned int i,j,c; static const BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH }; - cpu_irq_callback save_irqcallback; + device_irq_callback save_irqcallback; save_irqcallback = cpustate->irq_callback; memset( cpustate, 0, sizeof(*cpustate) ); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->sregs[CS] = 0xffff; @@ -933,7 +932,7 @@ static CPU_DISASSEMBLE( nec ) return necv_dasm_one(buffer, pc, oprom, cpustate->config); } -static void nec_init(running_device *device, cpu_irq_callback irqcallback, int type) +static void nec_init(running_device *device, device_irq_callback irqcallback, int type) { v30mz_state *cpustate = get_safe_token(device); @@ -961,8 +960,8 @@ static void nec_init(running_device *device, cpu_irq_callback irqcallback, int t cpustate->config = config; cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); } static CPU_INIT( v30mz ) { nec_init(device, irqcallback, 3); } @@ -1056,7 +1055,7 @@ static CPU_SET_INFO( nec ) CPU_GET_INFO( v30mz ) { - v30mz_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + v30mz_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; int flags; switch (state) diff --git a/src/emu/cpu/v60/v60.c b/src/emu/cpu/v60/v60.c index 040663a4758..3429f3bb6a1 100644 --- a/src/emu/cpu/v60/v60.c +++ b/src/emu/cpu/v60/v60.c @@ -77,7 +77,7 @@ struct _v60_state v60_flags flags; UINT8 irq_line; UINT8 nmi_line; - cpu_irq_callback irq_cb; + device_irq_callback irq_cb; running_device *device; const address_space *program; const address_space *io; @@ -114,11 +114,10 @@ struct _v60_state INLINE v60_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_V60 || cpu_get_type(device) == CPU_V70); - return (v60_state *)device->token; + return (v60_state *)downcast(device)->token(); } /* @@ -312,7 +311,7 @@ static UINT32 opUNHANDLED(v60_state *cpustate) // Opcode jump table #include "optable.c" -static void base_init(running_device *device, cpu_irq_callback irqcallback) +static void base_init(running_device *device, device_irq_callback irqcallback) { v60_state *cpustate = get_safe_token(device); @@ -342,8 +341,8 @@ static CPU_INIT( v60 ) cpustate->PIR = 0x00006000; cpustate->info = v60_i; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); } static CPU_INIT( v70 ) @@ -356,8 +355,8 @@ static CPU_INIT( v70 ) cpustate->PIR = 0x00007000; cpustate->info = v70_i; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); } static CPU_RESET( v60 ) @@ -552,7 +551,7 @@ static CPU_SET_INFO( v60 ) CPU_GET_INFO( v60 ) { - v60_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + v60_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/v810/v810.c b/src/emu/cpu/v810/v810.c index b5ba3da4b2c..89b56aac340 100644 --- a/src/emu/cpu/v810/v810.c +++ b/src/emu/cpu/v810/v810.c @@ -29,7 +29,7 @@ struct _v810_state UINT32 reg[65]; UINT8 irq_line; UINT8 nmi_line; - cpu_irq_callback irq_cb; + device_irq_callback irq_cb; running_device *device; const address_space *program; const address_space *io; @@ -40,10 +40,9 @@ struct _v810_state INLINE v810_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_V810); - return (v810_state *)device->token; + return (v810_state *)downcast(device)->token(); } #define R0 reg[0] @@ -1003,8 +1002,8 @@ static CPU_INIT( v810 ) cpustate->nmi_line = CLEAR_LINE; cpustate->irq_cb = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); state_save_register_device_item_array(device, 0, cpustate->reg); state_save_register_device_item(device, 0, cpustate->irq_line); @@ -1135,7 +1134,7 @@ static CPU_SET_INFO( v810 ) CPU_GET_INFO( v810 ) { - v810_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + v810_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpu/vtlb.c b/src/emu/cpu/vtlb.c index 68320609d5d..cf128e5b134 100644 --- a/src/emu/cpu/vtlb.c +++ b/src/emu/cpu/vtlb.c @@ -30,7 +30,7 @@ /* VTLB state */ struct _vtlb_state { - running_device *device; /* CPU device */ + cpu_device * cpudevice; /* CPU device */ int space; /* address space */ int dynamic; /* number of dynamic entries */ int fixed; /* number of fixed entries */ @@ -41,7 +41,6 @@ struct _vtlb_state int * fixedpages; /* number of pages each fixed entry covers */ vtlb_entry * table; /* table of entries by address */ vtlb_entry * save; /* cache of live table entries for saving */ - cpu_translate_func translate; /* translate function */ }; @@ -63,17 +62,17 @@ vtlb_state *vtlb_alloc(running_device *cpu, int space, int fixed_entries, int dy vtlb = auto_alloc_clear(cpu->machine, vtlb_state); /* fill in CPU information */ - vtlb->device = cpu; + vtlb->cpudevice = downcast(cpu); vtlb->space = space; vtlb->dynamic = dynamic_entries; vtlb->fixed = fixed_entries; - vtlb->pageshift = cpu_get_page_shift(cpu, space); - vtlb->addrwidth = cpu_get_logaddr_width(cpu, space); - vtlb->translate = (cpu_translate_func)cpu->get_config_fct(CPUINFO_FCT_TRANSLATE); + const address_space_config *spaceconfig = devconfig_get_space_config(cpu->baseconfig(), space); + assert(spaceconfig != NULL); + vtlb->pageshift = spaceconfig->m_page_shift; + vtlb->addrwidth = spaceconfig->m_logaddr_width; /* validate CPU information */ assert((1 << vtlb->pageshift) > VTLB_FLAGS_MASK); - assert(vtlb->translate != NULL); assert(vtlb->addrwidth > vtlb->pageshift); /* allocate the entry array */ @@ -102,16 +101,16 @@ void vtlb_free(vtlb_state *vtlb) { /* free the fixed pages if allocated */ if (vtlb->fixedpages != NULL) - auto_free(vtlb->device->machine, vtlb->fixedpages); + auto_free(vtlb->cpudevice->machine, vtlb->fixedpages); /* free the table and array if they exist */ if (vtlb->live != NULL) - auto_free(vtlb->device->machine, vtlb->live); + auto_free(vtlb->cpudevice->machine, vtlb->live); if (vtlb->table != NULL) - auto_free(vtlb->device->machine, vtlb->table); + auto_free(vtlb->cpudevice->machine, vtlb->table); /* and then the VTLB object itself */ - auto_free(vtlb->device->machine, vtlb); + auto_free(vtlb->cpudevice->machine, vtlb); } @@ -147,7 +146,7 @@ int vtlb_fill(vtlb_state *vtlb, offs_t address, int intention) /* ask the CPU core to translate for us */ taddress = address; - if (!(*vtlb->translate)(vtlb->device, vtlb->space, intention, &taddress)) + if (!vtlb->cpudevice->translate(vtlb->space, intention, taddress)) { if (PRINTF_TLB) printf("failed: no translation\n"); diff --git a/src/emu/cpu/z180/z180.c b/src/emu/cpu/z180/z180.c index 32cc55d47b9..940e6491a27 100644 --- a/src/emu/cpu/z180/z180.c +++ b/src/emu/cpu/z180/z180.c @@ -137,12 +137,11 @@ struct _z180_state UINT8 timer_cnt; /* timer counter / divide by 20 */ UINT8 dma0_cnt; /* dma0 counter / divide by 20 */ UINT8 dma1_cnt; /* dma1 counter / divide by 20 */ - z80_daisy_state *daisy; - cpu_irq_callback irq_callback; + z80_daisy_chain daisy; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *iospace; - cpu_state_table state; UINT8 rtemp; UINT32 ioltemp; int icount; @@ -153,10 +152,9 @@ struct _z180_state INLINE z180_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_Z180); - return (z180_state *)device->token; + return (z180_state *)downcast(device)->token(); } static void set_irq_line(z180_state *cpustate, int irqline, int state); @@ -798,7 +796,7 @@ static void set_irq_line(z180_state *cpustate, int irqline, int state); /*************************************************************************** CPU PREFIXES - + order is important here - see z180tbl.h ***************************************************************************/ @@ -812,130 +810,6 @@ static void set_irq_line(z180_state *cpustate, int irqline, int state); #define Z180_PREFIX_COUNT (Z180_PREFIX_xycb + 1) -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define Z180_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(Z180_##_name, #_name, _format, z180_state, _member, _datamask, ~0, _flags) - -#define Z180_STATE_IO_ENTRY(_name, _flags) \ - CPU_STATE_ENTRY(Z180_##_name, #_name, "%02X", z180_state, IO_##_name, 0xff, ~0, _flags) - - -static const cpu_state_entry state_array[] = -{ - Z180_STATE_ENTRY(PC, "%04X", PC.w.l, 0xffff, 0) - Z180_STATE_ENTRY(GENPC, "%04X", _PCD, 0xffff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(GENPCBASE, "%04X", PREPC.w.l, 0xffff, CPUSTATE_NOSHOW) - - Z180_STATE_ENTRY(SP, "%04X", _SPD, 0xffff, 0) - Z180_STATE_ENTRY(GENSP, "%04X", SP.w.l, 0xffff, CPUSTATE_NOSHOW) - - Z180_STATE_ENTRY(A, "%02X", _A, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(B, "%02X", _B, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(C, "%02X", _C, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(D, "%02X", _D, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(E, "%02X", _E, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(H, "%02X", _H, 0xff, CPUSTATE_NOSHOW) - Z180_STATE_ENTRY(L, "%02X", _L, 0xff, CPUSTATE_NOSHOW) - - Z180_STATE_ENTRY(AF, "%04X", AF.w.l, 0xffff, 0) - Z180_STATE_ENTRY(BC, "%04X", BC.w.l, 0xffff, 0) - Z180_STATE_ENTRY(DE, "%04X", DE.w.l, 0xffff, 0) - Z180_STATE_ENTRY(HL, "%04X", HL.w.l, 0xffff, 0) - Z180_STATE_ENTRY(IX, "%04X", IX.w.l, 0xffff, 0) - Z180_STATE_ENTRY(IY, "%04X", IY.w.l, 0xffff, 0) - - Z180_STATE_ENTRY(AF2, "%04X", AF2.w.l, 0xffff, 0) - Z180_STATE_ENTRY(BC2, "%04X", BC2.w.l, 0xffff, 0) - Z180_STATE_ENTRY(DE2, "%04X", DE2.w.l, 0xffff, 0) - Z180_STATE_ENTRY(HL2, "%04X", HL2.w.l, 0xffff, 0) - - Z180_STATE_ENTRY(R, "%02X", rtemp, 0xff, CPUSTATE_EXPORT | CPUSTATE_IMPORT) - Z180_STATE_ENTRY(I, "%02X", I, 0xff, 0) - Z180_STATE_ENTRY(IM, "%1u", IM, 0x3, 0) - Z180_STATE_ENTRY(IFF1, "%1u", IFF1, 0x1, 0) - Z180_STATE_ENTRY(IFF2, "%1u", IFF2, 0x1, 0) - Z180_STATE_ENTRY(HALT, "%1u", HALT, 0x1, 0) - - Z180_STATE_ENTRY(IOLINES, "%06X", ioltemp, 0xffffff, CPUSTATE_IMPORT) - - Z180_STATE_IO_ENTRY(CNTLA0, 0) - Z180_STATE_IO_ENTRY(CNTLA1, 0) - Z180_STATE_IO_ENTRY(CNTLB0, 0) - Z180_STATE_IO_ENTRY(CNTLB1, 0) - Z180_STATE_IO_ENTRY(STAT0, 0) - Z180_STATE_IO_ENTRY(STAT1, 0) - Z180_STATE_IO_ENTRY(TDR0, 0) - Z180_STATE_IO_ENTRY(TDR1, 0) - Z180_STATE_IO_ENTRY(RDR0, 0) - Z180_STATE_IO_ENTRY(RDR1, 0) - Z180_STATE_IO_ENTRY(CNTR, 0) - Z180_STATE_IO_ENTRY(TRDR, 0) - Z180_STATE_IO_ENTRY(TMDR0L, 0) - Z180_STATE_IO_ENTRY(TMDR0H, 0) - Z180_STATE_IO_ENTRY(RLDR0L, 0) - Z180_STATE_IO_ENTRY(RLDR0H, 0) - Z180_STATE_IO_ENTRY(TCR, 0) - Z180_STATE_IO_ENTRY(IO11, 0) - Z180_STATE_IO_ENTRY(ASEXT0, 0) - Z180_STATE_IO_ENTRY(ASEXT1, 0) - Z180_STATE_IO_ENTRY(TMDR1L, 0) - Z180_STATE_IO_ENTRY(TMDR1H, 0) - Z180_STATE_IO_ENTRY(RLDR1L, 0) - Z180_STATE_IO_ENTRY(RLDR1H, 0) - Z180_STATE_IO_ENTRY(FRC, 0) - Z180_STATE_IO_ENTRY(IO19, 0) - Z180_STATE_IO_ENTRY(ASTC0L, 0) - Z180_STATE_IO_ENTRY(ASTC0H, 0) - Z180_STATE_IO_ENTRY(ASTC1L, 0) - Z180_STATE_IO_ENTRY(ASTC1H, 0) - Z180_STATE_IO_ENTRY(CMR, 0) - Z180_STATE_IO_ENTRY(CCR, 0) - Z180_STATE_IO_ENTRY(SAR0L, 0) - Z180_STATE_IO_ENTRY(SAR0H, 0) - Z180_STATE_IO_ENTRY(SAR0B, 0) - Z180_STATE_IO_ENTRY(DAR0L, 0) - Z180_STATE_IO_ENTRY(DAR0H, 0) - Z180_STATE_IO_ENTRY(DAR0B, 0) - Z180_STATE_IO_ENTRY(BCR0L, 0) - Z180_STATE_IO_ENTRY(BCR0H, 0) - Z180_STATE_IO_ENTRY(MAR1L, 0) - Z180_STATE_IO_ENTRY(MAR1H, 0) - Z180_STATE_IO_ENTRY(MAR1B, 0) - Z180_STATE_IO_ENTRY(IAR1L, 0) - Z180_STATE_IO_ENTRY(IAR1H, 0) - Z180_STATE_IO_ENTRY(IAR1B, 0) - Z180_STATE_IO_ENTRY(BCR1L, 0) - Z180_STATE_IO_ENTRY(BCR1H, 0) - Z180_STATE_IO_ENTRY(DSTAT, 0) - Z180_STATE_IO_ENTRY(DMODE, 0) - Z180_STATE_IO_ENTRY(DCNTL, 0) - Z180_STATE_IO_ENTRY(IL, 0) - Z180_STATE_IO_ENTRY(ITC, 0) - Z180_STATE_IO_ENTRY(IO35, 0) - Z180_STATE_IO_ENTRY(RCR, 0) - Z180_STATE_IO_ENTRY(IO37, 0) - Z180_STATE_IO_ENTRY(CBR, CPUSTATE_IMPORT) - Z180_STATE_IO_ENTRY(BBR, CPUSTATE_IMPORT) - Z180_STATE_IO_ENTRY(CBAR, CPUSTATE_IMPORT) - Z180_STATE_IO_ENTRY(IO3B, 0) - Z180_STATE_IO_ENTRY(IO3C, 0) - Z180_STATE_IO_ENTRY(IO3D, 0) - Z180_STATE_IO_ENTRY(OMCR, 0) - Z180_STATE_IO_ENTRY(IOCR, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - static UINT8 SZ[256]; /* zero and sign flags */ static UINT8 SZ_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */ @@ -2067,18 +1941,114 @@ static void z180_write_iolines(z180_state *cpustate, UINT32 data) static CPU_INIT( z180 ) { z180_state *cpustate = get_safe_token(device); - cpustate->daisy = NULL; - if (device->baseconfig().static_config) - cpustate->daisy = z80daisy_init(device, (const z80_daisy_chain *)device->baseconfig().static_config); + if (device->baseconfig().static_config() != NULL) + cpustate->daisy.init(device, (const z80_daisy_config *)device->baseconfig().static_config()); cpustate->irq_callback = irqcallback; SZHVC_add = auto_alloc_array(device->machine, UINT8, 2*256*256); SZHVC_sub = auto_alloc_array(device->machine, UINT8, 2*256*256); /* set up the state table */ - cpustate->state = state_table_template; - cpustate->state.baseptr = cpustate; - cpustate->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(Z180_PC, "PC", cpustate->PC.w.l); + state->state_add(STATE_GENPC, "GENPC", cpustate->_PCD).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", cpustate->PREPC.w.l).noshow(); + state->state_add(Z180_SP, "SP", cpustate->_SPD); + state->state_add(STATE_GENSP, "GENSP", cpustate->SP.w.l).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->AF.b.l).noshow().formatstr("%8s"); + state->state_add(Z180_A, "A", cpustate->_A).noshow(); + state->state_add(Z180_B, "B", cpustate->_B).noshow(); + state->state_add(Z180_C, "C", cpustate->_C).noshow(); + state->state_add(Z180_D, "D", cpustate->_D).noshow(); + state->state_add(Z180_E, "E", cpustate->_E).noshow(); + state->state_add(Z180_H, "H", cpustate->_H).noshow(); + state->state_add(Z180_L, "L", cpustate->_L).noshow(); + state->state_add(Z180_AF, "AF", cpustate->AF.w.l); + state->state_add(Z180_BC, "BC", cpustate->BC.w.l); + state->state_add(Z180_DE, "DE", cpustate->DE.w.l); + state->state_add(Z180_HL, "HL", cpustate->HL.w.l); + state->state_add(Z180_IX, "IX", cpustate->IX.w.l); + state->state_add(Z180_IY, "IY", cpustate->IY.w.l); + state->state_add(Z180_AF2, "AF2", cpustate->AF2.w.l); + state->state_add(Z180_BC2, "BC2", cpustate->BC2.w.l); + state->state_add(Z180_DE2, "DE2", cpustate->DE2.w.l); + state->state_add(Z180_HL2, "HL2", cpustate->HL2.w.l); + state->state_add(Z180_R, "R", cpustate->rtemp).callimport().callexport(); + state->state_add(Z180_I, "I", cpustate->I); + state->state_add(Z180_IM, "IM", cpustate->IM).mask(0x3); + state->state_add(Z180_IFF1, "IFF1", cpustate->IFF1).mask(0x1); + state->state_add(Z180_IFF2, "IFF2", cpustate->IFF2).mask(0x1); + state->state_add(Z180_HALT, "HALT", cpustate->HALT).mask(0x1); + + state->state_add(Z180_IOLINES, "IOLINES", cpustate->ioltemp).mask(0xffffff).callimport(); + + state->state_add(Z180_CNTLA0, "CNTLA0", cpustate->IO_CNTLA0); + state->state_add(Z180_CNTLA1, "CNTLA1", cpustate->IO_CNTLA1); + state->state_add(Z180_CNTLB0, "CNTLB0", cpustate->IO_CNTLB0); + state->state_add(Z180_CNTLB1, "CNTLB1", cpustate->IO_CNTLB1); + state->state_add(Z180_STAT0, "STAT0", cpustate->IO_STAT0); + state->state_add(Z180_STAT1, "STAT1", cpustate->IO_STAT1); + state->state_add(Z180_TDR0, "TDR0", cpustate->IO_TDR0); + state->state_add(Z180_TDR1, "TDR1", cpustate->IO_TDR1); + state->state_add(Z180_RDR0, "RDR0", cpustate->IO_RDR0); + state->state_add(Z180_RDR1, "RDR1", cpustate->IO_RDR1); + state->state_add(Z180_CNTR, "CNTR", cpustate->IO_CNTR); + state->state_add(Z180_TRDR, "TRDR", cpustate->IO_TRDR); + state->state_add(Z180_TMDR0L, "TMDR0L", cpustate->IO_TMDR0L); + state->state_add(Z180_TMDR0H, "TMDR0H", cpustate->IO_TMDR0H); + state->state_add(Z180_RLDR0L, "RLDR0L", cpustate->IO_RLDR0L); + state->state_add(Z180_RLDR0H, "RLDR0H", cpustate->IO_RLDR0H); + state->state_add(Z180_TCR, "TCR", cpustate->IO_TCR); + state->state_add(Z180_IO11, "IO11", cpustate->IO_IO11); + state->state_add(Z180_ASEXT0, "ASEXT0", cpustate->IO_ASEXT0); + state->state_add(Z180_ASEXT1, "ASEXT1", cpustate->IO_ASEXT1); + state->state_add(Z180_TMDR1L, "TMDR1L", cpustate->IO_TMDR1L); + state->state_add(Z180_TMDR1H, "TMDR1H", cpustate->IO_TMDR1H); + state->state_add(Z180_RLDR1L, "RLDR1L", cpustate->IO_RLDR1L); + state->state_add(Z180_RLDR1H, "RLDR1H", cpustate->IO_RLDR1H); + state->state_add(Z180_FRC, "FRC", cpustate->IO_FRC); + state->state_add(Z180_IO19, "IO19", cpustate->IO_IO19); + state->state_add(Z180_ASTC0L, "ASTC0L", cpustate->IO_ASTC0L); + state->state_add(Z180_ASTC0H, "ASTC0H", cpustate->IO_ASTC0H); + state->state_add(Z180_ASTC1L, "ASTC1L", cpustate->IO_ASTC1L); + state->state_add(Z180_ASTC1H, "ASTC1H", cpustate->IO_ASTC1H); + state->state_add(Z180_CMR, "CMR", cpustate->IO_CMR); + state->state_add(Z180_CCR, "CCR", cpustate->IO_CCR); + state->state_add(Z180_SAR0L, "SAR0L", cpustate->IO_SAR0L); + state->state_add(Z180_SAR0H, "SAR0H", cpustate->IO_SAR0H); + state->state_add(Z180_SAR0B, "SAR0B", cpustate->IO_SAR0B); + state->state_add(Z180_DAR0L, "DAR0L", cpustate->IO_DAR0L); + state->state_add(Z180_DAR0H, "DAR0H", cpustate->IO_DAR0H); + state->state_add(Z180_DAR0B, "DAR0B", cpustate->IO_DAR0B); + state->state_add(Z180_BCR0L, "BCR0L", cpustate->IO_BCR0L); + state->state_add(Z180_BCR0H, "BCR0H", cpustate->IO_BCR0H); + state->state_add(Z180_MAR1L, "MAR1L", cpustate->IO_MAR1L); + state->state_add(Z180_MAR1H, "MAR1H", cpustate->IO_MAR1H); + state->state_add(Z180_MAR1B, "MAR1B", cpustate->IO_MAR1B); + state->state_add(Z180_IAR1L, "IAR1L", cpustate->IO_IAR1L); + state->state_add(Z180_IAR1H, "IAR1H", cpustate->IO_IAR1H); + state->state_add(Z180_IAR1B, "IAR1B", cpustate->IO_IAR1B); + state->state_add(Z180_BCR1L, "BCR1L", cpustate->IO_BCR1L); + state->state_add(Z180_BCR1H, "BCR1H", cpustate->IO_BCR1H); + state->state_add(Z180_DSTAT, "DSTAT", cpustate->IO_DSTAT); + state->state_add(Z180_DMODE, "DMODE", cpustate->IO_DMODE); + state->state_add(Z180_DCNTL, "DCNTL", cpustate->IO_DCNTL); + state->state_add(Z180_IL, "IL", cpustate->IO_IL); + state->state_add(Z180_ITC, "ITC", cpustate->IO_ITC); + state->state_add(Z180_IO35, "IO35", cpustate->IO_IO35); + state->state_add(Z180_RCR, "RCR", cpustate->IO_RCR); + state->state_add(Z180_IO37, "IO37", cpustate->IO_IO37); + state->state_add(Z180_CBR, "CBR", cpustate->IO_CBR).callimport(); + state->state_add(Z180_BBR, "BBR", cpustate->IO_BBR).callimport(); + state->state_add(Z180_CBAR, "CBAR", cpustate->IO_CBAR).callimport(); + state->state_add(Z180_IO3B, "IO3B", cpustate->IO_IO3B); + state->state_add(Z180_IO3C, "IO3C", cpustate->IO_IO3C); + state->state_add(Z180_IO3D, "IO3D", cpustate->IO_IO3D); + state->state_add(Z180_OMCR, "OMCR", cpustate->IO_OMCR); + state->state_add(Z180_IOCR, "IOCR", cpustate->IO_IOCR); + } state_save_register_device_item(device, 0, cpustate->AF.w.l); state_save_register_device_item(device, 0, cpustate->BC.w.l); @@ -2129,9 +2099,6 @@ static CPU_INIT( z180 ) static CPU_RESET( z180 ) { z180_state *cpustate = get_safe_token(device); - z80_daisy_state *save_daisy; - cpu_irq_callback save_irqcallback; - cpu_state_table save_table; int i, p; int oldval, newval, val; UINT8 *padd, *padc, *psub, *psbc; @@ -2206,32 +2173,52 @@ static CPU_RESET( z180 ) if( (i & 0x0f) == 0x0f ) SZHV_dec[i] |= HF; } - save_daisy = cpustate->daisy; - save_irqcallback = cpustate->irq_callback; - save_table = cpustate->state; - memset(cpustate, 0, sizeof(*cpustate)); - - memcpy(cpustate->cc, (UINT8 *)cc_default, sizeof(cpustate->cc)); - cpustate->daisy = save_daisy; - cpustate->irq_callback = save_irqcallback; - cpustate->state = save_table; - cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->iospace = device->space(AS_IO); - cpustate->_IX = cpustate->_IY = 0xffff; /* IX and IY are FFFF after a reset! */ - cpustate->_F = ZF; /* Zero flag is set */ + cpustate->_PPC = 0; + cpustate->_PCD = 0; + cpustate->_SPD = 0; + cpustate->_AFD = 0; + cpustate->_BCD = 0; + cpustate->_DED = 0; + cpustate->_HLD = 0; + cpustate->_IXD = 0; + cpustate->_IYD = 0; + cpustate->AF2.d = 0; + cpustate->BC2.d = 0; + cpustate->DE2.d = 0; + cpustate->HL2.d = 0; + cpustate->R = 0; + cpustate->R2 = 0; + cpustate->IFF1 = 0; + cpustate->IFF2 = 0; + cpustate->HALT = 0; + cpustate->IM = 0; + cpustate->I = 0; + cpustate->tmdr_latch = 0; + cpustate->read_tcr_tmdr[0] = 0; + cpustate->read_tcr_tmdr[1] = 0; + cpustate->iol = 0; + memset(cpustate->io, 0, sizeof(cpustate->io)); + memset(cpustate->mmu, 0, sizeof(cpustate->mmu)); + cpustate->tmdrh[0] = 0; + cpustate->tmdrh[1] = 0; + cpustate->tmdr_value[0] = 0xffff; + cpustate->tmdr_value[1] = 0xffff; + cpustate->tif[0] = 0; + cpustate->tif[1] = 0; cpustate->nmi_state = CLEAR_LINE; cpustate->nmi_pending = 0; cpustate->irq_state[0] = CLEAR_LINE; cpustate->irq_state[1] = CLEAR_LINE; cpustate->irq_state[2] = CLEAR_LINE; cpustate->after_EI = 0; - cpustate->tif[0] = 0; - cpustate->tif[1] = 0; - cpustate->read_tcr_tmdr[0] = 0; - cpustate->read_tcr_tmdr[1] = 0; - cpustate->tmdr_value[0] = 0xffff; - cpustate->tmdr_value[1] = 0xffff; + cpustate->ea = 0; + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->iospace = device_memory(device)->space(AS_IO); + cpustate->device = device; + + memcpy(cpustate->cc, (UINT8 *)cc_default, sizeof(cpustate->cc)); + cpustate->_IX = cpustate->_IY = 0xffff; /* IX and IY are FFFF after a reset! */ + cpustate->_F = ZF; /* Zero flag is set */ for (i=0; i <= Z180_INT_MAX; i++) cpustate->int_pending[i] = 0; @@ -2306,8 +2293,7 @@ static CPU_RESET( z180 ) cpustate->IO_OMCR = Z180_OMCR_RESET; cpustate->IO_IOCR = Z180_IOCR_RESET; - if (cpustate->daisy) - z80daisy_reset(cpustate->daisy); + cpustate->daisy.reset(); z180_mmu(cpustate); } @@ -2569,8 +2555,8 @@ static void set_irq_line(z180_state *cpustate, int irqline, int state) /* update the IRQ state */ cpustate->irq_state[irqline] = state; - if (cpustate->daisy) - cpustate->irq_state[0] = z80daisy_update_irq_state(cpustate->daisy); + if (cpustate->daisy.present()) + cpustate->irq_state[0] = cpustate->daisy.update_irq_state(); /* the main execute loop will take the interrupt */ } @@ -2596,7 +2582,7 @@ static CPU_IMPORT_STATE( z180 ) { z180_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z180_R: cpustate->R = cpustate->rtemp & 0x7f; @@ -2624,7 +2610,7 @@ static CPU_EXPORT_STATE( z180 ) { z180_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z180_R: cpustate->rtemp = (cpustate->R & 0x7f) | (cpustate->R2 & 0x80); @@ -2640,6 +2626,25 @@ static CPU_EXPORT_STATE( z180 ) } } +static CPU_EXPORT_STRING( z180 ) +{ + z180_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c", + cpustate->AF.b.l & 0x80 ? 'S':'.', + cpustate->AF.b.l & 0x40 ? 'Z':'.', + cpustate->AF.b.l & 0x20 ? '5':'.', + cpustate->AF.b.l & 0x10 ? 'H':'.', + cpustate->AF.b.l & 0x08 ? '3':'.', + cpustate->AF.b.l & 0x04 ? 'P':'.', + cpustate->AF.b.l & 0x02 ? 'N':'.', + cpustate->AF.b.l & 0x01 ? 'C':'.'); + break; + } +} /************************************************************************** * Generic set_info @@ -2673,7 +2678,7 @@ static CPU_SET_INFO( z180 ) CPU_GET_INFO( z180 ) { - z180_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + z180_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -2710,10 +2715,10 @@ CPU_GET_INFO( z180 ) case CPUINFO_FCT_TRANSLATE: info->translate = CPU_TRANSLATE_NAME(z180); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(z180); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(z180); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(z180); break; /* --- the following bits of info are returned as pointers to functions --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state; break; case CPUINFO_PTR_Z180_CYCLE_TABLE + Z180_TABLE_op: info->p = (void *)cpustate->cc[Z180_TABLE_op]; break; case CPUINFO_PTR_Z180_CYCLE_TABLE + Z180_TABLE_cb: info->p = (void *)cpustate->cc[Z180_TABLE_cb]; break; @@ -2728,17 +2733,6 @@ CPU_GET_INFO( z180 ) case DEVINFO_STR_VERSION: strcpy(info->s, "0.4"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Juergen Buchmueller, all rights reserved."); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c", - cpustate->AF.b.l & 0x80 ? 'S':'.', - cpustate->AF.b.l & 0x40 ? 'Z':'.', - cpustate->AF.b.l & 0x20 ? '5':'.', - cpustate->AF.b.l & 0x10 ? 'H':'.', - cpustate->AF.b.l & 0x08 ? '3':'.', - cpustate->AF.b.l & 0x04 ? 'P':'.', - cpustate->AF.b.l & 0x02 ? 'N':'.', - cpustate->AF.b.l & 0x01 ? 'C':'.'); break; } } diff --git a/src/emu/cpu/z180/z180.h b/src/emu/cpu/z180/z180.h index c1453adf17f..f773847997f 100644 --- a/src/emu/cpu/z180/z180.h +++ b/src/emu/cpu/z180/z180.h @@ -101,9 +101,9 @@ enum Z180_IOCR, /* 3f I/O control register */ Z180_IOLINES, /* read/write I/O lines */ - Z180_GENPC = REG_GENPC, - Z180_GENSP = REG_GENSP, - Z180_GENPCBASE = REG_GENPCBASE + Z180_GENPC = STATE_GENPC, + Z180_GENSP = STATE_GENSP, + Z180_GENPCBASE = STATE_GENPCBASE }; enum diff --git a/src/emu/cpu/z180/z180op.c b/src/emu/cpu/z180/z180op.c index 60bcbf1aca9..1dd7018663b 100644 --- a/src/emu/cpu/z180/z180op.c +++ b/src/emu/cpu/z180/z180op.c @@ -309,8 +309,8 @@ static int take_interrupt(z180_state *cpustate, int irq) if( irq == Z180_INT_IRQ0 ) { /* Daisy chain mode? If so, call the requesting device */ - if (cpustate->daisy) - irq_vector = z80daisy_call_ack_device(cpustate->daisy); + if (cpustate->daisy.present()) + irq_vector = cpustate->daisy.call_ack_device(); /* else call back the cpu interface to retrieve the vector */ else diff --git a/src/emu/cpu/z180/z180ops.h b/src/emu/cpu/z180/z180ops.h index dfaaad868a6..a28297b43d5 100644 --- a/src/emu/cpu/z180/z180ops.h +++ b/src/emu/cpu/z180/z180ops.h @@ -246,8 +246,7 @@ INLINE UINT32 ARG16(z180_state *cpustate) POP(cpustate, PC); \ /* according to http://www.msxnet.org/tech/Z80/z80undoc.txt */ \ /* cpustate->IFF1 = cpustate->IFF2; */ \ - if (cpustate->daisy) \ - z80daisy_call_reti_device(cpustate->daisy); \ + cpustate->daisy.call_reti_device(); \ } /*************************************************************** diff --git a/src/emu/cpu/z8/z8.c b/src/emu/cpu/z8/z8.c index 69e44b6f7d4..3e2b1c4127b 100644 --- a/src/emu/cpu/z8/z8.c +++ b/src/emu/cpu/z8/z8.c @@ -182,56 +182,11 @@ struct _z8_state int clock; /* clock */ int icount; /* instruction counter */ - cpu_state_table state_table; - /* timers */ emu_timer *t0_timer; emu_timer *t1_timer; }; -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define Z8_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(Z8_##_name, #_name, _format, z8_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - Z8_STATE_ENTRY(PC, "%04X", pc, 0xffff, 0) - Z8_STATE_ENTRY(GENPC, "%04X", pc, 0xffff, CPUSTATE_NOSHOW) - Z8_STATE_ENTRY(SP, "%04X", fake_sp, 0xffff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(GENSP, "%04X", fake_sp, 0xffff, CPUSTATE_NOSHOW | CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(RP, "%02X", r[Z8_REGISTER_RP], 0xff, 0) - Z8_STATE_ENTRY(T0, "%02X", t0, 0xff, 0) - Z8_STATE_ENTRY(T1, "%02X", t1, 0xff, 0) - - Z8_STATE_ENTRY(R0, "%02X", fake_r[0], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R1, "%02X", fake_r[1], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R2, "%02X", fake_r[2], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R3, "%02X", fake_r[3], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R4, "%02X", fake_r[4], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R5, "%02X", fake_r[5], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R6, "%02X", fake_r[6], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R7, "%02X", fake_r[7], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R8, "%02X", fake_r[8], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R9, "%02X", fake_r[9], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R10, "%02X", fake_r[10], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R11, "%02X", fake_r[11], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R12, "%02X", fake_r[12], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R13, "%02X", fake_r[13], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R14, "%02X", fake_r[14], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) - Z8_STATE_ENTRY(R15, "%02X", fake_r[15], 0xff, CPUSTATE_IMPORT | CPUSTATE_EXPORT) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -239,12 +194,11 @@ static const cpu_state_table state_table_template = INLINE z8_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert((cpu_get_type(device) == CPU_Z8601) || (cpu_get_type(device) == CPU_UB8830D) || (cpu_get_type(device) == CPU_Z8611)); - return (z8_state *)device->token; + return (z8_state *)downcast(device)->token(); } INLINE UINT8 fetch(z8_state *cpustate) @@ -689,16 +643,29 @@ static CPU_INIT( z8 ) z8_state *cpustate = get_safe_token(device); /* set up the state table */ - cpustate->state_table = state_table_template; - cpustate->state_table.baseptr = cpustate; - cpustate->state_table.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(Z8_PC, "PC", cpustate->pc); + state->state_add(STATE_GENPC, "GENPC", cpustate->pc).noshow(); + state->state_add(Z8_SP, "SP", cpustate->fake_sp).callimport().callexport(); + state->state_add(STATE_GENSP, "GENSP", cpustate->fake_sp).callimport().callexport().noshow(); + state->state_add(Z8_RP, "RP", cpustate->r[Z8_REGISTER_RP]); + state->state_add(Z8_T0, "T0", cpustate->t0); + state->state_add(Z8_T1, "T1", cpustate->t1); + state->state_add(STATE_GENFLAGS, "GENFLAGS", cpustate->r[Z8_REGISTER_FLAGS]).noshow().formatstr("%6s"); + + astring tempstr; + for (int regnum = 0; regnum < 16; regnum++) + state->state_add(Z8_R0 + regnum, tempstr.format("R%d", regnum), cpustate->fake_r[regnum]).callimport().callexport(); + } - cpustate->clock = device->clock; + cpustate->clock = device->clock(); /* find address spaces */ - cpustate->program = device->space(AS_PROGRAM); - cpustate->data = device->space(AS_DATA); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->data = device_memory(device)->space(AS_DATA); + cpustate->io = device_memory(device)->space(AS_IO); /* allocate timers */ cpustate->t0_timer = timer_alloc(device->machine, t0_tick, cpustate); @@ -786,7 +753,7 @@ static CPU_IMPORT_STATE( z8 ) { z8_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z8_SP: case Z8_GENSP: @@ -795,7 +762,7 @@ static CPU_IMPORT_STATE( z8 ) break; case Z8_R0: case Z8_R1: case Z8_R2: case Z8_R3: case Z8_R4: case Z8_R5: case Z8_R6: case Z8_R7: case Z8_R8: case Z8_R9: case Z8_R10: case Z8_R11: case Z8_R12: case Z8_R13: case Z8_R14: case Z8_R15: - cpustate->r[cpustate->r[Z8_REGISTER_RP] + (entry->index - Z8_R0)] = cpustate->fake_r[entry->index - Z8_R0]; + cpustate->r[cpustate->r[Z8_REGISTER_RP] + (entry.index() - Z8_R0)] = cpustate->fake_r[entry.index() - Z8_R0]; break; default: @@ -808,7 +775,7 @@ static CPU_EXPORT_STATE( z8 ) { z8_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z8_SP: case Z8_GENSP: @@ -816,7 +783,7 @@ static CPU_EXPORT_STATE( z8 ) break; case Z8_R0: case Z8_R1: case Z8_R2: case Z8_R3: case Z8_R4: case Z8_R5: case Z8_R6: case Z8_R7: case Z8_R8: case Z8_R9: case Z8_R10: case Z8_R11: case Z8_R12: case Z8_R13: case Z8_R14: case Z8_R15: - cpustate->fake_r[entry->index - Z8_R0] = cpustate->r[cpustate->r[Z8_REGISTER_RP] + (entry->index - Z8_R0)]; + cpustate->fake_r[entry.index() - Z8_R0] = cpustate->r[cpustate->r[Z8_REGISTER_RP] + (entry.index() - Z8_R0)]; break; default: @@ -825,6 +792,22 @@ static CPU_EXPORT_STATE( z8 ) } } +static CPU_EXPORT_STRING( z8 ) +{ + z8_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: string.printf("%c%c%c%c%c%c", + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_C ? 'C' : '.', + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_Z ? 'Z' : '.', + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_S ? 'S' : '.', + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_V ? 'V' : '.', + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_D ? 'D' : '.', + cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_H ? 'H' : '.'); break; + } +} + /*************************************************************************** GENERAL CONTEXT ACCESS ***************************************************************************/ @@ -844,7 +827,7 @@ static CPU_SET_INFO( z8 ) static CPU_GET_INFO( z8 ) { - z8_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + z8_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { @@ -878,10 +861,10 @@ static CPU_GET_INFO( z8 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(z8); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(z8); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(z8); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(z8); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &cpustate->state_table; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Z8"); break; @@ -889,15 +872,6 @@ static CPU_GET_INFO( z8 ) case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; - - case CPUINFO_STR_FLAGS: sprintf(info->s, - "%c%c%c%c%c%c", - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_C ? 'C' : '.', - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_Z ? 'Z' : '.', - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_S ? 'S' : '.', - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_V ? 'V' : '.', - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_D ? 'D' : '.', - cpustate->r[Z8_REGISTER_FLAGS] & Z8_FLAGS_H ? 'H' : '.'); break; } } diff --git a/src/emu/cpu/z8/z8.h b/src/emu/cpu/z8/z8.h index 59309092f6e..cdf148c0ef8 100644 --- a/src/emu/cpu/z8/z8.h +++ b/src/emu/cpu/z8/z8.h @@ -19,8 +19,8 @@ enum Z8_R0, Z8_R1, Z8_R2, Z8_R3, Z8_R4, Z8_R5, Z8_R6, Z8_R7, Z8_R8, Z8_R9, Z8_R10, Z8_R11, Z8_R12, Z8_R13, Z8_R14, Z8_R15, - Z8_GENPC = REG_GENPC, - Z8_GENSP = REG_GENSP + Z8_GENPC = STATE_GENPC, + Z8_GENSP = STATE_GENSP }; /* Zilog Z8601 */ diff --git a/src/emu/cpu/z80/z80.c b/src/emu/cpu/z80/z80.c index f8a9cb2db6a..c06c6bab865 100644 --- a/src/emu/cpu/z80/z80.c +++ b/src/emu/cpu/z80/z80.c @@ -148,13 +148,12 @@ struct _z80_state UINT8 nsc800_irq_state[4];/* state of NSC800 restart interrupts A, B, C */ UINT8 after_ei; /* are we in the EI shadow? */ UINT32 ea; - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; int icount; - z80_daisy_state *daisy; - cpu_state_table state; + z80_daisy_chain daisy; UINT8 rtemp; const UINT8 * cc_op; const UINT8 * cc_cb; @@ -167,10 +166,9 @@ struct _z80_state INLINE z80_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_Z80 || cpu_get_type(device) == CPU_NSC800); - return (z80_state *)device->token; + return (z80_state *)downcast(device)->token(); } #define CF 0x01 @@ -229,61 +227,6 @@ INLINE z80_state *get_safe_token(running_device *device) #define WZ_L wz.b.l -/*************************************************************************** - CPU STATE DESCRIPTION -***************************************************************************/ - -#define Z80_STATE_ENTRY(_name, _format, _member, _datamask, _flags) \ - CPU_STATE_ENTRY(Z80_##_name, #_name, _format, z80_state, _member, _datamask, ~0, _flags) - -static const cpu_state_entry state_array[] = -{ - Z80_STATE_ENTRY(PC, "%04X", PCD, 0xffff, 0) - Z80_STATE_ENTRY(GENPC, "%04X", PCD, 0xffff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(GENPCBASE, "%04X", prvpc.w.l, 0xffff, CPUSTATE_NOSHOW) - - Z80_STATE_ENTRY(SP, "%04X", SP, 0xffff, 0) - Z80_STATE_ENTRY(GENSP, "%04X", SPD, 0xffff, CPUSTATE_NOSHOW) - - Z80_STATE_ENTRY(A, "%02X", A, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(B, "%02X", B, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(C, "%02X", C, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(D, "%02X", D, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(E, "%02X", E, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(H, "%02X", H, 0xff, CPUSTATE_NOSHOW) - Z80_STATE_ENTRY(L, "%02X", L, 0xff, CPUSTATE_NOSHOW) - - Z80_STATE_ENTRY(AF, "%04X", AF, 0xffff, 0) - Z80_STATE_ENTRY(BC, "%04X", BC, 0xffff, 0) - Z80_STATE_ENTRY(DE, "%04X", DE, 0xffff, 0) - Z80_STATE_ENTRY(HL, "%04X", HL, 0xffff, 0) - Z80_STATE_ENTRY(IX, "%04X", IX, 0xffff, 0) - Z80_STATE_ENTRY(IY, "%04X", IY, 0xffff, 0) - - Z80_STATE_ENTRY(AF2, "%04X", af2.w.l, 0xffff, 0) - Z80_STATE_ENTRY(BC2, "%04X", bc2.w.l, 0xffff, 0) - Z80_STATE_ENTRY(DE2, "%04X", de2.w.l, 0xffff, 0) - Z80_STATE_ENTRY(HL2, "%04X", hl2.w.l, 0xffff, 0) - - Z80_STATE_ENTRY(WZ, "%04X", WZ, 0xffff, 0) - Z80_STATE_ENTRY(R, "%02X", rtemp,0xff, CPUSTATE_EXPORT | CPUSTATE_IMPORT) - Z80_STATE_ENTRY(I, "%02X", i, 0xff, 0) - Z80_STATE_ENTRY(IM, "%1u", im, 0x3, 0) - Z80_STATE_ENTRY(IFF1,"%1u", iff1, 0x1, 0) - Z80_STATE_ENTRY(IFF2,"%1u", iff2, 0x1, 0) - Z80_STATE_ENTRY(HALT,"%1u", halt, 0x1, 0) -}; - -static const cpu_state_table state_table_template = -{ - NULL, /* pointer to the base of state (offsets are relative to this) */ - 0, /* subtype this table refers to */ - ARRAY_LENGTH(state_array), /* number of entries */ - state_array /* array of entries */ -}; - - - static UINT8 SZ[256]; /* zero and sign flags */ static UINT8 SZ_BIT[256]; /* zero, sign and parity/overflow (=zero) flags for BIT opcode */ static UINT8 SZP[256]; /* zero, sign and parity flags */ @@ -840,8 +783,7 @@ INLINE UINT32 ARG16(z80_state *z80) (Z)->WZ = (Z)->PC; \ /* according to http://www.msxnet.org/tech/z80-documented.pdf */\ (Z)->iff1 = (Z)->iff2; \ - if ((Z)->daisy != NULL) \ - z80daisy_call_reti_device((Z)->daisy); \ + (Z)->daisy.call_reti_device(); \ } while (0) /*************************************************************** @@ -3284,8 +3226,8 @@ static void take_interrupt(z80_state *z80) z80->iff1 = z80->iff2 = 0; /* Daisy chain mode? If so, call the requesting device */ - if (z80->daisy) - irq_vector = z80daisy_call_ack_device(z80->daisy); + if (z80->daisy.present()) + irq_vector = z80->daisy.call_ack_device(); /* else call back the cpu interface to retrieve the vector */ else @@ -3497,20 +3439,77 @@ static CPU_INIT( z80 ) state_save_register_device_item(device, 0, z80->after_ei); /* Reset registers to their initial values */ - memset(z80, 0, sizeof(*z80)); - if (device->baseconfig().static_config != NULL) - z80->daisy = z80daisy_init(device, (const z80_daisy_chain *)device->baseconfig().static_config); + z80->PRVPC = 0; + z80->PCD = 0; + z80->SPD = 0; + z80->AFD = 0; + z80->BCD = 0; + z80->DED = 0; + z80->HLD = 0; + z80->IXD = 0; + z80->IYD = 0; + z80->WZ = 0; + z80->af2.d = 0; + z80->bc2.d = 0; + z80->de2.d = 0; + z80->hl2.d = 0; + z80->r = 0; + z80->r2 = 0; + z80->iff1 = 0; + z80->iff2 = 0; + z80->halt = 0; + z80->im = 0; + z80->i = 0; + z80->nmi_state = 0; + z80->nmi_pending = 0; + z80->irq_state = 0; + z80->after_ei = 0; + z80->ea = 0; + + if (device->baseconfig().static_config() != NULL) + z80->daisy.init(device, (const z80_daisy_config *)device->baseconfig().static_config()); z80->irq_callback = irqcallback; z80->device = device; - z80->program = device->space(AS_PROGRAM); - z80->io = device->space(AS_IO); + z80->program = device_memory(device)->space(AS_PROGRAM); + z80->io = device_memory(device)->space(AS_IO); z80->IX = z80->IY = 0xffff; /* IX and IY are FFFF after a reset! */ z80->F = ZF; /* Zero flag is set */ /* set up the state table */ - z80->state = state_table_template; - z80->state.baseptr = z80; - z80->state.subtypemask = 1; + { + device_state_interface *state; + device->interface(state); + state->state_add(Z80_PC, "PC", z80->pc.w.l); + state->state_add(STATE_GENPC, "GENPC", z80->pc.w.l).noshow(); + state->state_add(STATE_GENPCBASE, "GENPCBASE", z80->prvpc.w.l).noshow(); + state->state_add(Z80_SP, "SP", z80->SP); + state->state_add(STATE_GENSP, "GENSP", z80->SP).noshow(); + state->state_add(STATE_GENFLAGS, "GENFLAGS", z80->F).noshow().formatstr("%8s"); + state->state_add(Z80_A, "A", z80->A).noshow(); + state->state_add(Z80_B, "B", z80->B).noshow(); + state->state_add(Z80_C, "C", z80->C).noshow(); + state->state_add(Z80_D, "D", z80->D).noshow(); + state->state_add(Z80_E, "E", z80->E).noshow(); + state->state_add(Z80_H, "H", z80->H).noshow(); + state->state_add(Z80_L, "L", z80->L).noshow(); + state->state_add(Z80_AF, "AF", z80->AF); + state->state_add(Z80_BC, "BC", z80->BC); + state->state_add(Z80_DE, "DE", z80->DE); + state->state_add(Z80_HL, "HL", z80->HL); + state->state_add(Z80_IX, "IX", z80->IX); + state->state_add(Z80_IY, "IY", z80->IY); + state->state_add(Z80_AF2, "AF2", z80->af2.w.l); + state->state_add(Z80_BC2, "BC2", z80->bc2.w.l); + state->state_add(Z80_DE2, "DE2", z80->de2.w.l); + state->state_add(Z80_HL2, "HL2", z80->hl2.w.l); + state->state_add(Z80_WZ, "WZ", z80->WZ); + state->state_add(Z80_R, "R", z80->rtemp).callimport().callexport(); + state->state_add(Z80_I, "I", z80->i); + state->state_add(Z80_IM, "IM", z80->im).mask(0x3); + state->state_add(Z80_IFF1, "IFF1", z80->iff1).mask(0x1); + state->state_add(Z80_IFF2, "IFF2", z80->iff2).mask(0x1); + state->state_add(Z80_HALT, "HALT", z80->halt).mask(0x1); + } /* setup cycle tables */ z80->cc_op = cc_op; @@ -3544,8 +3543,7 @@ static CPU_RESET( z80 ) z80->irq_state = CLEAR_LINE; z80->after_ei = FALSE; - if (z80->daisy) - z80daisy_reset(z80->daisy); + z80->daisy.reset(); z80->WZ=z80->PCD; } @@ -3685,8 +3683,8 @@ static void set_irq_line(z80_state *z80, int irqline, int state) { /* update the IRQ state via the daisy chain */ z80->irq_state = state; - if (z80->daisy) - z80->irq_state = z80daisy_update_irq_state(z80->daisy); + if (z80->daisy.present()) + z80->irq_state = z80->daisy.update_irq_state(); /* the main execute loop will take the interrupt */ } @@ -3712,8 +3710,8 @@ static void set_irq_line_nsc800(z80_state *z80, int irqline, int state) { /* update the IRQ state via the daisy chain */ z80->irq_state = state; - if (z80->daisy) - z80->irq_state = z80daisy_update_irq_state(z80->daisy); + if (z80->daisy.present()) + z80->irq_state = z80->daisy.update_irq_state(); /* the main execute loop will take the interrupt */ } @@ -3728,7 +3726,7 @@ static CPU_IMPORT_STATE( z80 ) { z80_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z80_R: cpustate->r = cpustate->rtemp & 0x7f; @@ -3746,7 +3744,7 @@ static CPU_EXPORT_STATE( z80 ) { z80_state *cpustate = get_safe_token(device); - switch (entry->index) + switch (entry.index()) { case Z80_R: cpustate->rtemp = (cpustate->r & 0x7f) | (cpustate->r2 & 0x80); @@ -3758,6 +3756,26 @@ static CPU_EXPORT_STATE( z80 ) } } +static CPU_EXPORT_STRING( z80 ) +{ + z80_state *cpustate = get_safe_token(device); + + switch (entry.index()) + { + case STATE_GENFLAGS: + string.printf("%c%c%c%c%c%c%c%c", + cpustate->F & 0x80 ? 'S':'.', + cpustate->F & 0x40 ? 'Z':'.', + cpustate->F & 0x20 ? 'Y':'.', + cpustate->F & 0x10 ? 'H':'.', + cpustate->F & 0x08 ? 'X':'.', + cpustate->F & 0x04 ? 'P':'.', + cpustate->F & 0x02 ? 'N':'.', + cpustate->F & 0x01 ? 'C':'.'); + break; + } +} + /************************************************************************** * Generic set_info @@ -3807,7 +3825,7 @@ void z80_set_cycle_tables(running_device *device, const UINT8 *op, const UINT8 * CPU_GET_INFO( z80 ) { - z80_state *z80 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + z80_state *z80 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ @@ -3841,10 +3859,10 @@ CPU_GET_INFO( z80 ) case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(z80); break; case CPUINFO_FCT_IMPORT_STATE: info->import_state = CPU_IMPORT_STATE_NAME(z80); break; case CPUINFO_FCT_EXPORT_STATE: info->export_state = CPU_EXPORT_STATE_NAME(z80); break; + case CPUINFO_FCT_EXPORT_STRING: info->export_string = CPU_EXPORT_STRING_NAME(z80); break; /* --- the following bits of info are returned as pointers --- */ case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &z80->icount; break; - case CPUINFO_PTR_STATE_TABLE: info->state_table = &z80->state; break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Z80"); break; @@ -3852,24 +3870,12 @@ CPU_GET_INFO( z80 ) case DEVINFO_STR_VERSION: strcpy(info->s, "3.9"); break; case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Juergen Buchmueller, all rights reserved."); break; - - case CPUINFO_STR_FLAGS: - sprintf(info->s, "%c%c%c%c%c%c%c%c", - z80->F & 0x80 ? 'S':'.', - z80->F & 0x40 ? 'Z':'.', - z80->F & 0x20 ? 'Y':'.', - z80->F & 0x10 ? 'H':'.', - z80->F & 0x08 ? 'X':'.', - z80->F & 0x04 ? 'P':'.', - z80->F & 0x02 ? 'N':'.', - z80->F & 0x01 ? 'C':'.'); - break; } } CPU_GET_INFO( nsc800 ) { - z80_state *z80 = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + z80_state *z80 = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { case CPUINFO_INT_INPUT_LINES: info->i = 4; break; diff --git a/src/emu/cpu/z80/z80.h b/src/emu/cpu/z80/z80.h index 684424fe387..0ff4219146d 100644 --- a/src/emu/cpu/z80/z80.h +++ b/src/emu/cpu/z80/z80.h @@ -19,9 +19,9 @@ enum Z80_R, Z80_I, Z80_IM, Z80_IFF1, Z80_IFF2, Z80_HALT, Z80_DC0, Z80_DC1, Z80_DC2, Z80_DC3, Z80_WZ, - Z80_GENPC = REG_GENPC, - Z80_GENSP = REG_GENSP, - Z80_GENPCBASE = REG_GENPCBASE + Z80_GENPC = STATE_GENPC, + Z80_GENSP = STATE_GENSP, + Z80_GENPCBASE = STATE_GENPCBASE }; CPU_GET_INFO( z80 ); diff --git a/src/emu/cpu/z80/z80daisy.c b/src/emu/cpu/z80/z80daisy.c index 06cab99dd04..185a47bc829 100644 --- a/src/emu/cpu/z80/z80daisy.c +++ b/src/emu/cpu/z80/z80daisy.c @@ -10,99 +10,183 @@ #include "z80daisy.h" -struct _z80_daisy_state +//************************************************************************** +// DEVICE CONFIG Z80 DAISY INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_config_z80daisy_interface - constructor +//------------------------------------------------- + +device_config_z80daisy_interface::device_config_z80daisy_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig) +{ +} + + +//------------------------------------------------- +// ~device_config_z80daisy_interface - destructor +//------------------------------------------------- + +device_config_z80daisy_interface::~device_config_z80daisy_interface() +{ +} + + + +//************************************************************************** +// DEVICE Z80 DAISY INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_z80daisy_interface - constructor +//------------------------------------------------- + +device_z80daisy_interface::device_z80daisy_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_z80daisy_config(dynamic_cast(config)) { - z80_daisy_state * next; /* next device */ - running_device * device; /* associated device */ - z80_daisy_irq_state irq_state; /* IRQ state callback */ - z80_daisy_irq_ack irq_ack; /* IRQ ack callback */ - z80_daisy_irq_reti irq_reti; /* IRQ reti callback */ -}; +} + +//------------------------------------------------- +// ~device_z80daisy_interface - destructor +//------------------------------------------------- -z80_daisy_state *z80daisy_init(running_device *cpudevice, const z80_daisy_chain *daisy) +device_z80daisy_interface::~device_z80daisy_interface() { - astring tempstring; - z80_daisy_state *head = NULL; - z80_daisy_state **tailptr = &head; +} - /* create a linked list of devices */ + + +//************************************************************************** +// Z80 DAISY CHAIN +//************************************************************************** + +//------------------------------------------------- +// z80_daisy_chain - constructor +//------------------------------------------------- + +z80_daisy_chain::z80_daisy_chain() + : m_daisy_list(NULL) +{ +} + + +//------------------------------------------------- +// init - allocate the daisy chain based on the +// provided configuration +//------------------------------------------------- + +void z80_daisy_chain::init(device_t *cpudevice, const z80_daisy_config *daisy) +{ + // create a linked list of devices + daisy_entry **tailptr = &m_daisy_list; for ( ; daisy->devname != NULL; daisy++) { - *tailptr = auto_alloc(cpudevice->machine, z80_daisy_state); - (*tailptr)->next = NULL; - (*tailptr)->device = cpudevice->machine->device(cpudevice->siblingtag(tempstring, daisy->devname)); - if ((*tailptr)->device == NULL) + // find the device + device_t *target = cpudevice->siblingdevice(daisy->devname); + if (target == NULL) fatalerror("Unable to locate device '%s'", daisy->devname); - (*tailptr)->irq_state = (z80_daisy_irq_state)(*tailptr)->device->get_config_fct(DEVINFO_FCT_IRQ_STATE); - (*tailptr)->irq_ack = (z80_daisy_irq_ack)(*tailptr)->device->get_config_fct(DEVINFO_FCT_IRQ_ACK); - (*tailptr)->irq_reti = (z80_daisy_irq_reti)(*tailptr)->device->get_config_fct(DEVINFO_FCT_IRQ_RETI); - tailptr = &(*tailptr)->next; + + // make sure it has an interface + device_z80daisy_interface *intf; + if (!target->interface(intf)) + fatalerror("Device '%s' does not implement the z80daisy interface!", daisy->devname); + + // append to the end + *tailptr = auto_alloc(cpudevice->machine, daisy_entry(target)); + tailptr = &(*tailptr)->m_next; } - - return head; } -void z80daisy_reset(z80_daisy_state *daisy) +//------------------------------------------------- +// reset - send a reset signal to all chained +// devices +//------------------------------------------------- + +void z80_daisy_chain::reset() { - /* loop over all devices and call their reset function */ - for ( ; daisy != NULL; daisy = daisy->next) - daisy->device->reset(); + // loop over all devices and call their reset function + for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next) + daisy->m_device->reset(); } -int z80daisy_update_irq_state(z80_daisy_state *daisy) +//------------------------------------------------- +// update_irq_state - update the IRQ state and +// return assert/clear based on the state +//------------------------------------------------- + +int z80_daisy_chain::update_irq_state() { - /* loop over all devices; dev[0] is highest priority */ - for ( ; daisy != NULL; daisy = daisy->next) + // loop over all devices; dev[0] is highest priority + for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next) { - int state = (*daisy->irq_state)(daisy->device); - - /* if this device is asserting the INT line, that's the one we want */ + // if this device is asserting the INT line, that's the one we want + int state = daisy->m_interface->z80daisy_irq_state(); if (state & Z80_DAISY_INT) return ASSERT_LINE; - /* if this device is asserting the IEO line, it blocks everyone else */ + // if this device is asserting the IEO line, it blocks everyone else if (state & Z80_DAISY_IEO) return CLEAR_LINE; } - return CLEAR_LINE; } -int z80daisy_call_ack_device(z80_daisy_state *daisy) +//------------------------------------------------- +// call_ack_device - acknowledge an interrupt +// from a chained device and return the vector +//------------------------------------------------- + +int z80_daisy_chain::call_ack_device() { - /* loop over all devices; dev[0] is the highest priority */ - for ( ; daisy != NULL; daisy = daisy->next) + // loop over all devices; dev[0] is the highest priority + for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next) { - int state = (*daisy->irq_state)(daisy->device); - - /* if this device is asserting the INT line, that's the one we want */ + // if this device is asserting the INT line, that's the one we want + int state = daisy->m_interface->z80daisy_irq_state(); if (state & Z80_DAISY_INT) - return (*daisy->irq_ack)(daisy->device); + return daisy->m_interface->z80daisy_irq_ack(); } - logerror("z80daisy_call_ack_device: failed to find an device to ack!\n"); return 0; } -void z80daisy_call_reti_device(z80_daisy_state *daisy) +//------------------------------------------------- +// call_reti_device - signal a RETI operator to +// the chain +//------------------------------------------------- + +void z80_daisy_chain::call_reti_device() { - /* loop over all devices; dev[0] is the highest priority */ - for ( ; daisy != NULL; daisy = daisy->next) + // loop over all devices; dev[0] is the highest priority + for (daisy_entry *daisy = m_daisy_list; daisy != NULL; daisy = daisy->m_next) { - int state = (*daisy->irq_state)(daisy->device); - - /* if this device is asserting the IEO line, that's the one we want */ + // if this device is asserting the IEO line, that's the one we want + int state = daisy->m_interface->z80daisy_irq_state(); if (state & Z80_DAISY_IEO) { - (*daisy->irq_reti)(daisy->device); + daisy->m_interface->z80daisy_irq_reti(); return; } } - logerror("z80daisy_call_reti_device: failed to find an device to reti!\n"); } + + +//------------------------------------------------- +// daisy_entry - constructor +//------------------------------------------------- + +z80_daisy_chain::daisy_entry::daisy_entry(device_t *device) + : m_next(NULL), + m_device(device), + m_interface(NULL) +{ + device->interface(m_interface); +} diff --git a/src/emu/cpu/z80/z80daisy.h b/src/emu/cpu/z80/z80daisy.h index ad3adcfbc0d..dee7525f44d 100644 --- a/src/emu/cpu/z80/z80daisy.h +++ b/src/emu/cpu/z80/z80daisy.h @@ -13,56 +13,91 @@ -/*************************************************************************** - CONSTANTS -***************************************************************************/ +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// these constants are returned from the irq_state function +const UINT8 Z80_DAISY_INT = 0x01; // interrupt request mask +const UINT8 Z80_DAISY_IEO = 0x02; // interrupt disable mask (IEO) + -/* these constants are returned from the irq_state function */ -#define Z80_DAISY_INT 0x01 /* interrupt request mask */ -#define Z80_DAISY_IEO 0x02 /* interrupt disable mask (IEO) */ +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -enum + +// ======================> z80_daisy_config + +struct z80_daisy_config { - DEVINFO_FCT_IRQ_STATE = DEVINFO_FCT_DEVICE_SPECIFIC, /* R/O: z80_daisy_irq_state */ - DEVINFO_FCT_IRQ_ACK, /* R/O: z80_daisy_irq_ack */ - DEVINFO_FCT_IRQ_RETI /* R/O: z80_daisy_irq_reti */ + const char * devname; // name of the device }; -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +// ======================> device_config_z80daisy_interface -/* per-device callback functions */ -typedef int (*z80_daisy_irq_state)(running_device *device); -typedef int (*z80_daisy_irq_ack)(running_device *device); -typedef int (*z80_daisy_irq_reti)(running_device *device); +// device_config_z80daisy_interface represents configuration information for a z80daisy device +class device_config_z80daisy_interface : public device_config_interface +{ +public: + // construction/destruction + device_config_z80daisy_interface(const machine_config &mconfig, device_config &devconfig); + virtual ~device_config_z80daisy_interface(); +}; -/* opaque internal daisy chain state */ -typedef struct _z80_daisy_state z80_daisy_state; +// ======================> device_z80daisy_interface -/* daisy chain structure */ -typedef struct _z80_daisy_chain z80_daisy_chain; -struct _z80_daisy_chain +class device_z80daisy_interface : public device_interface { - const char * devname; /* name of the device */ +public: + // construction/destruction + device_z80daisy_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_z80daisy_interface(); + + // required operation overrides + virtual int z80daisy_irq_state() = 0; + virtual int z80daisy_irq_ack() = 0; + virtual void z80daisy_irq_reti() = 0; + +protected: + const device_config_z80daisy_interface &m_z80daisy_config; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ +// ======================> z80_daisy_chain -z80_daisy_state *z80daisy_init(running_device *cpudevice, const z80_daisy_chain *daisy); +class z80_daisy_chain +{ +public: + z80_daisy_chain(); + void init(device_t *cpudevice, const z80_daisy_config *daisy); + + bool present() const { return (m_daisy_list != NULL); } + + void reset(); + int update_irq_state(); + int call_ack_device(); + void call_reti_device(); + +protected: + class daisy_entry + { + public: + daisy_entry(device_t *device); + + daisy_entry * m_next; // next device + device_t * m_device; // associated device + device_z80daisy_interface * m_interface; // associated device's daisy interface + }; + + daisy_entry * m_daisy_list; // head of the daisy chain +}; -void z80daisy_reset(z80_daisy_state *daisy); -int z80daisy_update_irq_state(z80_daisy_state *chain); -int z80daisy_call_ack_device(z80_daisy_state *chain); -void z80daisy_call_reti_device(z80_daisy_state *chain); #endif diff --git a/src/emu/cpu/z8000/z8000.c b/src/emu/cpu/z8000/z8000.c index 0aeffe20358..6eed70a3411 100644 --- a/src/emu/cpu/z8000/z8000.c +++ b/src/emu/cpu/z8000/z8000.c @@ -81,7 +81,7 @@ struct _z8000_state z8000_reg_file regs;/* registers */ int nmi_state; /* NMI line state */ int irq_state[2]; /* IRQ line states (NVI, VI) */ - cpu_irq_callback irq_callback; + device_irq_callback irq_callback; running_device *device; const address_space *program; const address_space *io; @@ -93,10 +93,9 @@ struct _z8000_state INLINE z8000_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == CPU); + assert(device->type() == CPU); assert(cpu_get_type(device) == CPU_Z8001 || cpu_get_type(device) == CPU_Z8002); - return (z8000_state *)device->token; + return (z8000_state *)downcast(device)->token(); } /* opcode execution table */ @@ -366,8 +365,8 @@ static CPU_INIT( z8001 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* already initialized? */ if(z8000_exec == NULL) @@ -380,8 +379,8 @@ static CPU_INIT( z8002 ) cpustate->irq_callback = irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); /* already initialized? */ if(z8000_exec == NULL) @@ -392,12 +391,12 @@ static CPU_RESET( z8001 ) { z8000_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback = cpustate->irq_callback; + device_irq_callback save_irqcallback = cpustate->irq_callback; memset(cpustate, 0, sizeof(*cpustate)); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->fcw = RDMEM_W(cpustate, 2); /* get reset cpustate->fcw */ if(cpustate->fcw & F_SEG) { @@ -413,12 +412,12 @@ static CPU_RESET( z8002 ) { z8000_state *cpustate = get_safe_token(device); - cpu_irq_callback save_irqcallback = cpustate->irq_callback; + device_irq_callback save_irqcallback = cpustate->irq_callback; memset(cpustate, 0, sizeof(*cpustate)); cpustate->irq_callback = save_irqcallback; cpustate->device = device; - cpustate->program = device->space(AS_PROGRAM); - cpustate->io = device->space(AS_IO); + cpustate->program = device_memory(device)->space(AS_PROGRAM); + cpustate->io = device_memory(device)->space(AS_IO); cpustate->fcw = RDMEM_W(cpustate, 2); /* get reset cpustate->fcw */ cpustate->pc = RDMEM_W(cpustate, 4); /* get reset cpustate->pc */ } @@ -569,7 +568,7 @@ static CPU_SET_INFO( z8002 ) CPU_GET_INFO( z8002 ) { - z8000_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL; + z8000_state *cpustate = (device != NULL && downcast(device)->token() != NULL) ? get_safe_token(device) : NULL; switch (state) { diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c deleted file mode 100644 index 82f73d49888..00000000000 --- a/src/emu/cpuexec.c +++ /dev/null @@ -1,1998 +0,0 @@ -/*************************************************************************** - - cpuexec.c - - Core multi-CPU execution engine. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#include "emu.h" -#include "profiler.h" -#include "debugger.h" - - -/*************************************************************************** - DEBUGGING -***************************************************************************/ - -#define VERBOSE 0 - -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* internal trigger IDs */ -enum -{ - TRIGGER_INT = -2000, - TRIGGER_YIELDTIME = -3000, - TRIGGER_SUSPENDTIME = -4000 -}; - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* internal information about the state of inputs */ -typedef struct _cpu_input_data cpu_input_data; -struct _cpu_input_data -{ - INT32 vector; /* most recently written vector */ - INT32 curvector; /* most recently processed vector */ - UINT8 curstate; /* most recently processed state */ - INT32 queue[MAX_INPUT_EVENTS]; /* queue of pending events */ - int qindex; /* index within the queue */ -}; - - -/* internal data hanging off of the classtoken */ -typedef struct _cpu_class_data cpu_class_data; -struct _cpu_class_data -{ - /* execution lists */ - running_device *device; /* pointer back to our device */ - cpu_class_data *next; /* pointer to the next CPU to execute, in order */ - cpu_execute_func execute; /* execute function pointer */ - - /* cycle counting and executing */ - int profiler; /* profiler tag */ - int * icount; /* pointer to the icount */ - int cycles_running; /* number of cycles we are executing */ - int cycles_stolen; /* number of cycles we artificially stole */ - - /* input states and IRQ callbacks */ - cpu_irq_callback driver_irq; /* driver-specific IRQ callback */ - cpu_input_data input[MAX_INPUT_LINES]; /* data about inputs */ - - /* suspend states */ - UINT8 suspend; /* suspend reason mask (0 = not suspended) */ - UINT8 nextsuspend; /* pending suspend reason mask */ - UINT8 eatcycles; /* true if we eat cycles while suspended */ - UINT8 nexteatcycles; /* pending value */ - INT32 trigger; /* pending trigger to release a trigger suspension */ - INT32 inttrigger; /* interrupt trigger index */ - - /* clock and timing information */ - UINT64 totalcycles; /* total CPU cycles executed */ - attotime localtime; /* local time, relative to the timer system's global time */ - INT32 clock; /* current active clock */ - double clockscale; /* current active clock scale factor */ - INT32 divisor; /* 32-bit attoseconds_per_cycle divisor */ - UINT8 divshift; /* right shift amount to fit the divisor into 32 bits */ - emu_timer * timedint_timer; /* reference to this CPU's periodic interrupt timer */ - UINT32 cycles_per_second; /* cycles per second, adjusted for multipliers */ - attoseconds_t attoseconds_per_cycle; /* attoseconds per adjusted clock cycle */ - - /* internal state reflection */ - const cpu_state_table *state; /* pointer to the base table */ - const cpu_state_entry *regstate[MAX_REGS];/* pointer to the state entry for each register */ - - /* these below are hacks to support multiple interrupts per frame */ - INT32 iloops; /* number of interrupts remaining this frame */ - emu_timer * partial_frame_timer; /* the timer that triggers partial frame interrupts */ - attotime partial_frame_period; /* the length of one partial frame for interrupt purposes */ -}; - - -/* global data stored in the machine */ -/* In mame.h: typedef struct _cpuexec_private cpuexec_private; */ -struct _cpuexec_private -{ - running_device *executingcpu; /* pointer to the currently executing CPU */ - cpu_class_data *executelist; /* execution list; suspended CPUs are at the back */ - char statebuf[256]; /* string buffer containing state description */ -}; - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static void update_clock_information(running_device *device); -static void compute_perfect_interleave(running_machine *machine); -static void on_vblank(running_device *device, void *param, int vblank_state); -static TIMER_CALLBACK( trigger_partial_frame_interrupt ); -static TIMER_CALLBACK( trigger_periodic_interrupt ); -static TIMER_CALLBACK( triggertime_callback ); -static TIMER_CALLBACK( empty_event_queue ); -static IRQ_CALLBACK( standard_irq_callback ); -static void register_save_states(running_device *device); -static void rebuild_execute_list(running_machine *machine); -static UINT64 get_register_value(running_device *device, void *baseptr, const cpu_state_entry *entry); -static void set_register_value(running_device *device, void *baseptr, const cpu_state_entry *entry, UINT64 value); -static void get_register_string_value(running_device *device, void *baseptr, const cpu_state_entry *entry, char *dest); -#ifdef UNUSED_FUNCTION -static int get_register_string_max_width(running_device *device, void *baseptr, const cpu_state_entry *entry); -#endif - - - -/*************************************************************************** - MACROS -***************************************************************************/ - -/* these are macros to ensure inlining in cpuexec_timeslice */ -#define ATTOTIME_LT(a,b) ((a).seconds < (b).seconds || ((a).seconds == (b).seconds && (a).attoseconds < (b).attoseconds)) -#define ATTOTIME_NORMALIZE(a) do { if ((a).attoseconds >= ATTOSECONDS_PER_SECOND) { (a).seconds++; (a).attoseconds -= ATTOSECONDS_PER_SECOND; } } while (0) - - - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -/*------------------------------------------------- - get_class_data - return a pointer to the - class data --------------------------------------------------*/ - -INLINE cpu_class_data *get_class_data(running_device *device) -{ - assert(device != NULL); - assert(device->devclass == DEVICE_CLASS_CPU_CHIP); - assert(device->token != NULL); - return (cpu_class_data *)cpu_get_class_header(device) - 1; -} - - -/*------------------------------------------------- - get_minimum_quantum - return the minimum - quantum required for a given CPU device --------------------------------------------------*/ - -INLINE attoseconds_t get_minimum_quantum(running_device *device) -{ - attoseconds_t basetick = 0; - - /* fetch the base clock from the classdata if present */ - if (device->token != NULL) - basetick = get_class_data(device)->attoseconds_per_cycle; - - /* otherwise compute it from the raw data */ - if (basetick == 0) - { - UINT32 baseclock = (UINT64)device->clock * cpu_get_clock_multiplier(device) / cpu_get_clock_divider(device); - basetick = HZ_TO_ATTOSECONDS(baseclock); - } - - /* apply the minimum cycle count */ - return basetick * cpu_get_min_cycles(device); -} - - -/*------------------------------------------------- - suspend_until_trigger - suspend execution - until the given trigger fires --------------------------------------------------*/ - -INLINE void suspend_until_trigger(running_device *device, int trigger, int eatcycles) -{ - cpu_class_data *classdata = get_class_data(device); - - /* suspend the CPU immediately if it's not already */ - cpu_suspend(device, SUSPEND_REASON_TRIGGER, eatcycles); - - /* set the trigger */ - classdata->trigger = trigger; -} - - - -/*************************************************************************** - CORE CPU EXECUTION -***************************************************************************/ - -/*------------------------------------------------- - cpuexec_init - initialize internal states of - all CPUs --------------------------------------------------*/ - -void cpuexec_init(running_machine *machine) -{ - attotime min_quantum; - - /* allocate global state */ - machine->cpuexec_data = auto_alloc_clear(machine, cpuexec_private); - - /* set the core scheduling quantum */ - min_quantum = machine->config->minimum_quantum; - if (attotime_compare(min_quantum, attotime_zero) == 0) - min_quantum = ATTOTIME_IN_HZ(60); - if (machine->config->perfect_cpu_quantum != NULL) - { - running_device *cpu = machine->device(machine->config->perfect_cpu_quantum); - attotime cpu_quantum; - - if (cpu == NULL) - fatalerror("CPU '%s' specified for perfect interleave is not present!", machine->config->perfect_cpu_quantum); - cpu_quantum = attotime_make(0, get_minimum_quantum(cpu)); - min_quantum = attotime_min(cpu_quantum, min_quantum); - } - assert(min_quantum.seconds == 0); - timer_add_scheduling_quantum(machine, min_quantum.attoseconds, attotime_never); -} - - -/*------------------------------------------------- - cpuexec_timeslice - execute all CPUs for a - single timeslice --------------------------------------------------*/ - -void cpuexec_timeslice(running_machine *machine) -{ - int call_debugger = ((machine->debug_flags & DEBUG_FLAG_ENABLED) != 0); - timer_execution_state *timerexec = timer_get_execution_state(machine); - cpuexec_private *global = machine->cpuexec_data; - int ran; - - /* build the execution list if we don't have one yet */ - if (global->executelist == NULL) - rebuild_execute_list(machine); - - /* loop until we hit the next timer */ - while (ATTOTIME_LT(timerexec->basetime, timerexec->nextfire)) - { - cpu_class_data *classdata; - UINT32 suspendchanged; - attotime target; - - /* by default, assume our target is the end of the next quantum */ - target.seconds = timerexec->basetime.seconds; - target.attoseconds = timerexec->basetime.attoseconds + timerexec->curquantum; - ATTOTIME_NORMALIZE(target); - - /* however, if the next timer is going to fire before then, override */ - assert(attotime_sub(timerexec->nextfire, target).seconds <= 0); - if (ATTOTIME_LT(timerexec->nextfire, target)) - target = timerexec->nextfire; - - LOG(("------------------\n")); - LOG(("cpu_timeslice: target = %s\n", attotime_string(target, 9))); - - /* apply pending suspension changes */ - suspendchanged = 0; - for (classdata = global->executelist; classdata != NULL; classdata = classdata->next) - { - suspendchanged |= (classdata->suspend ^ classdata->nextsuspend); - classdata->suspend = classdata->nextsuspend; - classdata->nextsuspend &= ~SUSPEND_REASON_TIMESLICE; - classdata->eatcycles = classdata->nexteatcycles; - } - - /* recompute the execute list if any CPUs changed their suspension state */ - if (suspendchanged != 0) - rebuild_execute_list(machine); - - /* loop over non-suspended CPUs */ - for (classdata = global->executelist; classdata != NULL; classdata = classdata->next) - { - /* only process if our target is later than the CPU's current time (coarse check) */ - if (target.seconds >= classdata->localtime.seconds) - { - attoseconds_t delta, actualdelta; - - /* compute how many attoseconds to execute this CPU */ - delta = target.attoseconds - classdata->localtime.attoseconds; - if (delta < 0 && target.seconds > classdata->localtime.seconds) - delta += ATTOSECONDS_PER_SECOND; - assert(delta == attotime_to_attoseconds(attotime_sub(target, classdata->localtime))); - - /* if we have enough for at least 1 cycle, do the math */ - if (delta >= classdata->attoseconds_per_cycle) - { - /* compute how many cycles we want to execute */ - ran = classdata->cycles_running = divu_64x32((UINT64)delta >> classdata->divshift, classdata->divisor); - LOG((" cpu '%s': %d cycles\n", classdata->device->tag(), classdata->cycles_running)); - - /* if we're not suspended, actually execute */ - if (classdata->suspend == 0) - { - profiler_mark_start(classdata->profiler); - - /* note that this global variable cycles_stolen can be modified */ - /* via the call to cpu_execute */ - classdata->cycles_stolen = 0; - global->executingcpu = classdata->device; - *classdata->icount = classdata->cycles_running; - if (!call_debugger) - ran = (*classdata->execute)(classdata->device, classdata->cycles_running); - else - { - debugger_start_cpu_hook(classdata->device, target); - ran = (*classdata->execute)(classdata->device, classdata->cycles_running); - debugger_stop_cpu_hook(classdata->device); - } - - /* adjust for any cycles we took back */ - assert(ran >= classdata->cycles_stolen); - ran -= classdata->cycles_stolen; - profiler_mark_end(); - } - - /* account for these cycles */ - classdata->totalcycles += ran; - - /* update the local time for this CPU */ - actualdelta = classdata->attoseconds_per_cycle * ran; - classdata->localtime.attoseconds += actualdelta; - ATTOTIME_NORMALIZE(classdata->localtime); - LOG((" %d ran, %d total, time = %s\n", ran, (INT32)classdata->totalcycles, attotime_string(classdata->localtime, 9))); - - /* if the new local CPU time is less than our target, move the target up */ - if (ATTOTIME_LT(classdata->localtime, target)) - { - assert(attotime_compare(classdata->localtime, target) < 0); - target = classdata->localtime; - - /* however, if this puts us before the base, clamp to the base as a minimum */ - if (ATTOTIME_LT(target, timerexec->basetime)) - { - assert(attotime_compare(target, timerexec->basetime) < 0); - target = timerexec->basetime; - } - LOG((" (new target)\n")); - } - } - } - } - global->executingcpu = NULL; - - /* update the base time */ - timerexec->basetime = target; - } - - /* execute timers */ - timer_execute_timers(machine); -} - - -/*------------------------------------------------- - cpuexec_boost_interleave - temporarily boosts - the interleave factor --------------------------------------------------*/ - -void cpuexec_boost_interleave(running_machine *machine, attotime timeslice_time, attotime boost_duration) -{ - /* ignore timeslices > 1 second */ - if (timeslice_time.seconds > 0) - return; - timer_add_scheduling_quantum(machine, timeslice_time.attoseconds, boost_duration); -} - - - -/*************************************************************************** - GLOBAL HELPERS -***************************************************************************/ - -/*------------------------------------------------- - cpuexec_abort_timeslice - abort execution - for the current timeslice --------------------------------------------------*/ - -void cpuexec_abort_timeslice(running_machine *machine) -{ - running_device *executingcpu = machine->cpuexec_data->executingcpu; - if (executingcpu != NULL) - cpu_abort_timeslice(executingcpu); -} - - -/*------------------------------------------------- - cpuexec_describe_context - return a string - describing which CPUs are currently executing - and their PC --------------------------------------------------*/ - -const char *cpuexec_describe_context(running_machine *machine) -{ - cpuexec_private *global = machine->cpuexec_data; - running_device *executingcpu = global->executingcpu; - - /* if we have an executing CPU, output data */ - if (executingcpu != NULL) - { - const address_space *space = cpu_get_address_space(executingcpu, ADDRESS_SPACE_PROGRAM); - sprintf(global->statebuf, "'%s' (%s)", executingcpu->tag(), core_i64_hex_format(cpu_get_pc(executingcpu), space->logaddrchars)); - } - else - strcpy(global->statebuf, "(no context)"); - - return global->statebuf; -} - - - -/*************************************************************************** - CPU DEVICE INTERFACE -***************************************************************************/ - -/*------------------------------------------------- - device_start_cpu - device start callback --------------------------------------------------*/ - -static DEVICE_START( cpu ) -{ - int index = cpu_get_index(device); - cpu_class_header *header; - cpu_class_data *classdata; - const cpu_config *config; - cpu_init_func init; - int num_regs; - int line; - - /* validate some basic stuff */ - assert(device != NULL); - assert(device->baseconfig().inline_config != NULL); - assert(device->machine != NULL); - assert(device->machine->config != NULL); - - /* get pointers to our data */ - config = (const cpu_config *)device->baseconfig().inline_config; - header = cpu_get_class_header(device); - classdata = get_class_data(device); - - /* build the header */ - header->debug = NULL; - header->set_info = (cpu_set_info_func)device->get_config_fct(CPUINFO_FCT_SET_INFO); - - /* fill in the input states and IRQ callback information */ - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - /* vector and curvector are initialized later */ - inputline->curstate = CLEAR_LINE; - inputline->qindex = 0; - } - - /* fill in the suspend states */ - classdata->device = device; - classdata->execute = (cpu_execute_func)device->get_config_fct(CPUINFO_FCT_EXECUTE); - classdata->profiler = index + PROFILER_CPU_FIRST; - classdata->suspend = SUSPEND_REASON_RESET; - classdata->inttrigger = index + TRIGGER_INT; - - /* fill in the clock and timing information */ - classdata->clock = (UINT64)device->clock * cpu_get_clock_multiplier(device) / cpu_get_clock_divider(device); - classdata->clockscale = 1.0; - - /* allocate timers if we need them */ - if (config->vblank_interrupts_per_frame > 1) - classdata->partial_frame_timer = timer_alloc(device->machine, trigger_partial_frame_interrupt, (void *)device); - if (config->timed_interrupt_period != 0) - classdata->timedint_timer = timer_alloc(device->machine, trigger_periodic_interrupt, (void *)device); - - /* initialize this CPU */ - num_regs = state_save_get_reg_count(device->machine); - init = (cpu_init_func)device->get_config_fct(CPUINFO_FCT_INIT); - (*init)(device, standard_irq_callback); - num_regs = state_save_get_reg_count(device->machine) - num_regs; - - /* fetch post-initialization data */ - classdata->icount = cpu_get_icount_ptr(device); - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - inputline->vector = cpu_get_default_irq_vector(device); - inputline->curvector = inputline->vector; - } - update_clock_information(device); - - /* fetch information about the CPU states */ - classdata->state = cpu_get_state_table(device); - if (classdata->state != NULL) - { - int stateindex; - - /* loop over all states specified, and work with any that apply */ - for (stateindex = 0; stateindex < classdata->state->entrycount; stateindex++) - { - const cpu_state_entry *entry = &classdata->state->entrylist[stateindex]; - if (entry->validmask == 0 || (entry->validmask & classdata->state->subtypemask) != 0) - { - assert(entry->index < MAX_REGS); - assert(classdata->regstate[entry->index] == NULL); - classdata->regstate[entry->index] = entry; - } - } - } - - /* if no state registered for saving, we can't save */ - if (num_regs == 0) - { - logerror("CPU '%s' did not register any state to save!\n", device->tag()); - if (device->machine->gamedrv->flags & GAME_SUPPORTS_SAVE) - fatalerror("CPU '%s' did not register any state to save!", device->tag()); - } - - /* register some internal states as well */ - register_save_states(device); -} - - -/*------------------------------------------------- - device_reset_cpu - device reset callback --------------------------------------------------*/ - -static DEVICE_RESET( cpu ) -{ - cpu_class_data *classdata = get_class_data(device); - const cpu_config *config = (const cpu_config *)device->baseconfig().inline_config; - cpu_reset_func reset; - int line; - - /* enable all CPUs (except for disabled CPUs) */ - if (!(config->flags & CPU_DISABLE)) - cpu_resume(device, SUSPEND_ANY_REASON); - else - cpu_suspend(device, SUSPEND_REASON_DISABLE, 1); - - /* reset the total number of cycles */ - classdata->totalcycles = 0; - - /* then reset the CPU directly */ - reset = (cpu_reset_func)device->get_config_fct(CPUINFO_FCT_RESET); - if (reset != NULL) - (*reset)(device); - - /* reset the interrupt vectors and queues */ - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - inputline->vector = cpu_get_default_irq_vector(device); - inputline->qindex = 0; - } - - /* reconfingure VBLANK interrupts */ - if (config->vblank_interrupts_per_frame > 0 || config->vblank_interrupt_screen != NULL) - { - running_device *screen; - - /* get the screen that will trigger the VBLANK */ - - /* new style - use screen tag directly */ - if (config->vblank_interrupt_screen != NULL) - screen = device->machine->device(config->vblank_interrupt_screen); - - /* old style 'hack' setup - use screen #0 */ - else - screen = video_screen_first(device->machine); - - assert(screen != NULL); - video_screen_register_vblank_callback(screen, on_vblank, NULL); - } - - /* reconfigure periodic interrupts */ - if (config->timed_interrupt_period != 0) - { - attotime timedint_period = UINT64_ATTOTIME_TO_ATTOTIME(config->timed_interrupt_period); - assert(classdata->timedint_timer != NULL); - timer_adjust_periodic(classdata->timedint_timer, timedint_period, 0, timedint_period); - } -} - - -/*------------------------------------------------- - device_stop_cpu - device stop callback --------------------------------------------------*/ - -static DEVICE_STOP( cpu ) -{ - cpu_exit_func exit; - - /* call the CPU's exit function if present */ - exit = (cpu_exit_func)device->get_config_fct(CPUINFO_FCT_EXIT); - if (exit != NULL) - (*exit)(device); -} - - -/*------------------------------------------------- - cpu_set_info - device set info callback --------------------------------------------------*/ - -void cpu_set_info(running_device *device, UINT32 state, UINT64 value) -{ - cpu_class_header *header = cpu_get_class_header(device); - cpu_set_info_func set_info; - cpuinfo cinfo; - - /* if we are live and have a header, save ourself a call */ - if (header != NULL) - set_info = header->set_info; - else - set_info = (cpu_set_info_func)device->get_config_fct(CPUINFO_FCT_SET_INFO); - - switch (state) - { - /* no parameters to set */ - - default: - /* if we have a state pointer, we can handle some stuff for free */ - if (device->token != NULL) - { - const cpu_class_data *classdata = get_class_data(device); - if (classdata->state != NULL) - { - if (state >= CPUINFO_INT_REGISTER && state <= CPUINFO_INT_REGISTER_LAST) - { - set_register_value(device, classdata->state->baseptr, classdata->regstate[state - CPUINFO_INT_REGISTER], value); - return; - } - } - } - - /* integer data */ - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); - if (state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST) - { - cinfo.i = value; - (*set_info)(device, state, &cinfo); - } - break; - } -} - - -/*------------------------------------------------- - cpu_get_info - device get info - callback --------------------------------------------------*/ - -static DEVICE_GET_RUNTIME_INFO( cpu ) -{ - const cpu_config *config = (device != NULL) ? (const cpu_config *)device->baseconfig().inline_config : NULL; - cpuinfo cinfo = { 0 }; - - /* if we don't have a device pointer, ignore everything else */ - if (device == NULL) - return; - - /* if we have a state pointer, we can handle some stuff for free */ - if (device->token != NULL) - { - const cpu_class_data *classdata = get_class_data(device); - if (classdata->state != NULL) - { - if (state >= CPUINFO_INT_REGISTER && state <= CPUINFO_INT_REGISTER_LAST) - { - info->i = get_register_value(device, classdata->state->baseptr, classdata->regstate[state - CPUINFO_INT_REGISTER]); - return; - } - else if (state >= CPUINFO_STR_REGISTER && state <= CPUINFO_STR_REGISTER_LAST) - { - cinfo.s = info->s; - get_register_string_value(device, classdata->state->baseptr, classdata->regstate[state - CPUINFO_STR_REGISTER], cinfo.s); - info->s = cinfo.s; - return; - } - } - } - - /* integer data */ - if (state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST) - { - cinfo.i = info->i; - (*config->type)(&device->baseconfig(), device, state, &cinfo); - info->i = cinfo.i; - } - - /* pointer data */ - else if ((state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST) || - (state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST) || - (state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST)) - { - cinfo.p = info->p; - (*config->type)(&device->baseconfig(), device, state, &cinfo); - info->p = cinfo.p; - } -} - - -DEVICE_GET_INFO( cpu ) -{ - const cpu_config *config = (const cpu_config *)device->inline_config; - cpuinfo cinfo = { 0 }; - - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: - cinfo.i = 0; - (*config->type)(device, NULL, CPUINFO_INT_CONTEXT_SIZE, &cinfo); - info->i = cinfo.i + sizeof(cpu_class_data) + sizeof(cpu_class_header); - break; - - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(cpu_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_CPU_CHIP; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cpu); break; - case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(cpu); break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cpu); break; - case DEVINFO_FCT_GET_RUNTIME_INFO: info->get_runtime_info = DEVICE_GET_RUNTIME_INFO_NAME(cpu); break; - - default: - /* integer data */ - if (state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST) - { - cinfo.i = info->i; - (*config->type)(device, NULL, state, &cinfo); - info->i = cinfo.i; - } - - /* pointer data */ - else if ((state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST) || - (state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST) || - (state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST)) - { - cinfo.p = info->p; - (*config->type)(device, NULL, state, &cinfo); - info->p = cinfo.p; - } - break; - } -} - - - -/*************************************************************************** - CPU SCHEDULING -***************************************************************************/ - -/*------------------------------------------------- - cpu_suspend - set a suspend reason for the - given CPU --------------------------------------------------*/ - -void cpu_suspend(running_device *device, int reason, int eatcycles) -{ - cpu_class_data *classdata = get_class_data(device); - - /* set the suspend reason and eat cycles flag */ - classdata->nextsuspend |= reason; - classdata->nexteatcycles = eatcycles; - - /* if we're active, synchronize */ - cpu_abort_timeslice(device); -} - - -/*------------------------------------------------- - cpu_resume - clear a suspend reason for the - given CPU --------------------------------------------------*/ - -void cpu_resume(running_device *device, int reason) -{ - cpu_class_data *classdata = get_class_data(device); - - /* clear the suspend reason and eat cycles flag */ - classdata->nextsuspend &= ~reason; - - /* if we're active, synchronize */ - cpu_abort_timeslice(device); -} - - -/*------------------------------------------------- - cpu_is_executing - return TRUE if the given - CPU is within its execute function --------------------------------------------------*/ - -int cpu_is_executing(running_device *device) -{ - return (device == device->machine->cpuexec_data->executingcpu); -} - - -/*------------------------------------------------- - cpu_is_suspended - returns TRUE if the - given CPU is suspended for any of the given - reasons --------------------------------------------------*/ - -int cpu_is_suspended(running_device *device, int reason) -{ - cpu_class_data *classdata = get_class_data(device); - - /* return true if the given reason is indicated */ - return ((classdata->nextsuspend & reason) != 0); -} - - - -/*************************************************************************** - CPU CLOCK MANAGEMENT -***************************************************************************/ - -/*------------------------------------------------- - cpu_get_clock - gets the given CPU's - clock speed --------------------------------------------------*/ - -int cpu_get_clock(running_device *device) -{ - cpu_class_data *classdata; - - /* if we haven't been started yet, compute it manually */ - if (device->token == NULL) - return (UINT64)device->clock * cpu_get_clock_multiplier(device) / cpu_get_clock_divider(device); - - /* return the current clock value */ - classdata = get_class_data(device); - return classdata->clock; -} - - -/*------------------------------------------------- - cpu_set_clock - sets the given CPU's - clock speed --------------------------------------------------*/ - -void cpu_set_clock(running_device *device, int clock) -{ - cpu_class_data *classdata = get_class_data(device); - - /* set the clock and update the information */ - classdata->clock = clock; - update_clock_information(device); -} - - -/*------------------------------------------------- - cpu_get_clockscale - returns the current - scaling factor for a CPU's clock speed --------------------------------------------------*/ - -double cpu_get_clockscale(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - - /* return the current clock scale factor */ - return classdata->clockscale; -} - - -/*------------------------------------------------- - cpu_set_clockscale - sets the current - scaling factor for a CPU's clock speed --------------------------------------------------*/ - -void cpu_set_clockscale(running_device *device, double clockscale) -{ - cpu_class_data *classdata = get_class_data(device); - - /* set the scale factor and update the information */ - classdata->clockscale = clockscale; - update_clock_information(device); -} - - -/*------------------------------------------------- - cpu_clocks_to_attotime - converts a number of - clock ticks to an attotime --------------------------------------------------*/ - -attotime cpu_clocks_to_attotime(running_device *device, UINT64 clocks) -{ - cpu_class_data *classdata = get_class_data(device); - if (clocks < classdata->cycles_per_second) - return attotime_make(0, clocks * classdata->attoseconds_per_cycle); - else - { - UINT32 remainder; - UINT32 quotient = divu_64x32_rem(clocks, classdata->cycles_per_second, &remainder); - return attotime_make(quotient, (UINT64)remainder * (UINT64)classdata->attoseconds_per_cycle); - } -} - - -/*------------------------------------------------- - cpu_attotime_to_clocks - converts a duration - as attotime to CPU clock ticks --------------------------------------------------*/ - -UINT64 cpu_attotime_to_clocks(running_device *device, attotime duration) -{ - cpu_class_data *classdata = get_class_data(device); - return mulu_32x32(duration.seconds, classdata->cycles_per_second) + (UINT64)duration.attoseconds / (UINT64)classdata->attoseconds_per_cycle; -} - - - -/*************************************************************************** - CPU TIMING -***************************************************************************/ - -/*------------------------------------------------- - cpu_get_local_time - returns the current - local time for a CPU --------------------------------------------------*/ - -attotime cpu_get_local_time(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - attotime result; - - /* if we're active, add in the time from the current slice */ - result = classdata->localtime; - if (device == device->machine->cpuexec_data->executingcpu) - { - int cycles = classdata->cycles_running - *classdata->icount; - result = attotime_add(result, cpu_clocks_to_attotime(device, cycles)); - } - return result; -} - - -/*------------------------------------------------- - cpuexec_override_local_time - overrides the - given time with the executing CPU's local - time, if present (this function is private - to timer.c) --------------------------------------------------*/ - -attotime cpuexec_override_local_time(running_machine *machine, attotime default_time) -{ - if (machine->cpuexec_data != NULL && machine->cpuexec_data->executingcpu != NULL) - return cpu_get_local_time(machine->cpuexec_data->executingcpu); - return default_time; -} - - -/*------------------------------------------------- - cpu_get_total_cycles - return the total - number of CPU cycles executed on the active - CPU --------------------------------------------------*/ - -UINT64 cpu_get_total_cycles(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - - if (device == device->machine->cpuexec_data->executingcpu) - return classdata->totalcycles + classdata->cycles_running - *classdata->icount; - else - return classdata->totalcycles; -} - - -/*------------------------------------------------- - cpu_eat_cycles - safely eats cycles so - we don't cross a timeslice boundary --------------------------------------------------*/ - -void cpu_eat_cycles(running_device *device, int cycles) -{ - cpu_class_data *classdata = get_class_data(device); - - /* ignore if not the executing CPU */ - if (device != device->machine->cpuexec_data->executingcpu) - return; - - if (cycles > *classdata->icount) - cycles = *classdata->icount; - *classdata->icount -= cycles; -} - - -/*------------------------------------------------- - cpu_adjust_icount - apply a +/- to the current - icount --------------------------------------------------*/ - -void cpu_adjust_icount(running_device *device, int delta) -{ - cpu_class_data *classdata = get_class_data(device); - - /* ignore if not the executing CPU */ - if (device != device->machine->cpuexec_data->executingcpu) - return; - - *classdata->icount += delta; -} - - -/*------------------------------------------------- - cpu_abort_timeslice - abort execution - for the current timeslice, allowing other - CPUs to run before we run again --------------------------------------------------*/ - -void cpu_abort_timeslice(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - int delta; - - /* ignore if not the executing CPU */ - if (device != device->machine->cpuexec_data->executingcpu) - return; - - /* swallow the remaining cycles */ - if (classdata->icount != NULL) - { - delta = *classdata->icount; - classdata->cycles_stolen += delta; - classdata->cycles_running -= delta; - *classdata->icount -= delta; - } -} - - - -/*************************************************************************** - SYNCHRONIZATION HELPERS -***************************************************************************/ - -/*------------------------------------------------- - cpu_yield - yield the given CPU until the end - of the current timeslice --------------------------------------------------*/ - -void cpu_yield(running_device *device) -{ - /* suspend against the timeslice */ - cpu_suspend(device, SUSPEND_REASON_TIMESLICE, FALSE); -} - - -/*------------------------------------------------- - cpu_spin - burn CPU cycles until our timeslice - is up --------------------------------------------------*/ - -void cpu_spin(running_device *device) -{ - /* suspend against the timeslice */ - cpu_suspend(device, SUSPEND_REASON_TIMESLICE, TRUE); -} - - -/*------------------------------------------------- - cpu_spinuntil_trigger - burn specified CPU - cycles until a timer trigger --------------------------------------------------*/ - -void cpu_spinuntil_trigger(running_device *device, int trigger) -{ - /* suspend until the given trigger fires */ - suspend_until_trigger(device, trigger, TRUE); -} - - -/*------------------------------------------------- - cpu_spinuntil_int - burn CPU cycles until the - next interrupt --------------------------------------------------*/ - -void cpu_spinuntil_int(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - - /* suspend until the given trigger fires */ - suspend_until_trigger(device, classdata->inttrigger, TRUE); -} - - -/*------------------------------------------------- - cpu_spinuntil_time - burn CPU cycles for a - specific period of time --------------------------------------------------*/ - -void cpu_spinuntil_time(running_device *device, attotime duration) -{ - static int timetrig = 0; - - /* suspend until the given trigger fires */ - suspend_until_trigger(device, TRIGGER_SUSPENDTIME + timetrig, TRUE); - - /* then set a timer for it */ - cpuexec_triggertime(device->machine, TRIGGER_SUSPENDTIME + timetrig, duration); - timetrig = (timetrig + 1) % 256; -} - - - -/*************************************************************************** - TRIGGERS -***************************************************************************/ - -/*------------------------------------------------- - cpuexec_trigger - generate a trigger now --------------------------------------------------*/ - -void cpuexec_trigger(running_machine *machine, int trigger) -{ - running_device *cpu; - - /* look for suspended CPUs waiting for this trigger and unsuspend them */ - for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) - { - cpu_class_data *classdata = get_class_data(cpu); - - /* if we're executing, for an immediate abort */ - cpu_abort_timeslice(cpu); - - /* see if this is a matching trigger */ - if ((classdata->nextsuspend & SUSPEND_REASON_TRIGGER) != 0 && classdata->trigger == trigger) - { - cpu_resume(cpu, SUSPEND_REASON_TRIGGER); - classdata->trigger = 0; - } - } -} - - -/*------------------------------------------------- - cpuexec_triggertime - generate a trigger after a - specific period of time --------------------------------------------------*/ - -void cpuexec_triggertime(running_machine *machine, int trigger, attotime duration) -{ - timer_set(machine, duration, NULL, trigger, triggertime_callback); -} - - -/*------------------------------------------------- - cpu_triggerint - generate a trigger - corresponding to an interrupt on the given CPU --------------------------------------------------*/ - -void cpu_triggerint(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - - /* signal this CPU's interrupt trigger */ - cpuexec_trigger(device->machine, classdata->inttrigger); -} - - - -/*************************************************************************** - INTERRUPTS -***************************************************************************/ - -/*------------------------------------------------- - cpu_set_input_line - set the logical state - (ASSERT_LINE/CLEAR_LINE) of an input line - on a CPU --------------------------------------------------*/ - -void cpu_set_input_line(running_device *device, int line, int state) -{ - cpu_class_data *classdata = get_class_data(device); - int vector = (line >= 0 && line < MAX_INPUT_LINES) ? classdata->input[line].vector : 0xff; - cpu_set_input_line_and_vector(device, line, state, vector); -} - - -/*------------------------------------------------- - cpu_set_input_line_vector - set the vector to - be returned during a CPU's interrupt - acknowledge cycle --------------------------------------------------*/ - -void cpu_set_input_line_vector(running_device *device, int line, int vector) -{ - cpu_class_data *classdata = get_class_data(device); - if (line >= 0 && line < MAX_INPUT_LINES) - { - classdata->input[line].vector = vector; - return; - } - LOG(("cpu_set_input_line_vector CPU '%s' line %d > max input lines\n", device->tag(), line)); -} - - -/*------------------------------------------------- - cpu_set_input_line_and_vector - set the logical - state (ASSERT_LINE/CLEAR_LINE) of an input - line on a CPU and its associated vector --------------------------------------------------*/ - -void cpu_set_input_line_and_vector(running_device *device, int line, int state, int vector) -{ - cpu_class_data *classdata = get_class_data(device); - - /* catch errors where people use PULSE_LINE for CPUs that don't support it */ - if (state == PULSE_LINE && line != INPUT_LINE_NMI && line != INPUT_LINE_RESET) - fatalerror("CPU %s: PULSE_LINE can only be used for NMI and RESET lines\n", device->tag()); - - if (line >= 0 && line < MAX_INPUT_LINES) - { - cpu_input_data *inputline = &classdata->input[line]; - INT32 input_event = (state & 0xff) | (vector << 8); - int event_index = inputline->qindex++; - - LOG(("cpu_set_input_line_and_vector('%s',%d,%d,%02x)\n", device->tag(), line, state, vector)); - - /* if we're full of events, flush the queue and log a message */ - if (event_index >= ARRAY_LENGTH(inputline->queue)) - { - inputline->qindex--; - empty_event_queue(device->machine, (void *)device, line); - event_index = inputline->qindex++; - logerror("Exceeded pending input line event queue on CPU '%s'!\n", device->tag()); - } - - /* enqueue the event */ - if (event_index < ARRAY_LENGTH(inputline->queue)) - { - inputline->queue[event_index] = input_event; - - /* if this is the first one, set the timer */ - if (event_index == 0) - timer_call_after_resynch(device->machine, (void *)device, line, empty_event_queue); - } - } -} - - -/*------------------------------------------------- - cpu_set_irq_callback - install a driver- - specific callback for IRQ acknowledge --------------------------------------------------*/ - -void cpu_set_irq_callback(running_device *device, cpu_irq_callback callback) -{ - cpu_class_data *classdata = get_class_data(device); - classdata->driver_irq = callback; -} - - - -/*************************************************************************** - CHEESY FAKE VIDEO TIMING (OBSOLETE) -***************************************************************************/ - -/*------------------------------------------------- - cpu_getiloops - return the cheesy VBLANK - interrupt counter (deprecated) --------------------------------------------------*/ - -int cpu_getiloops(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - return classdata->iloops; -} - - - -/*************************************************************************** - INTERNAL FUNCTIONS -***************************************************************************/ - -/*------------------------------------------------- - update_clock_information - recomputes clock - information for the specified CPU --------------------------------------------------*/ - -static void update_clock_information(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - INT64 attos; - - /* recompute cps and spc */ - classdata->cycles_per_second = (double)classdata->clock * classdata->clockscale; - classdata->attoseconds_per_cycle = HZ_TO_ATTOSECONDS((double)classdata->clock * classdata->clockscale); - - /* update the CPU's divisor */ - attos = classdata->attoseconds_per_cycle; - classdata->divshift = 0; - while (attos >= (1UL << 31)) - { - classdata->divshift++; - attos >>= 1; - } - classdata->divisor = attos; - - /* re-compute the perfect interleave factor */ - compute_perfect_interleave(device->machine); -} - - -/*------------------------------------------------- - compute_perfect_interleave - compute the - "perfect" interleave interval --------------------------------------------------*/ - -static void compute_perfect_interleave(running_machine *machine) -{ - running_device *firstcpu = machine->firstcpu; - if (firstcpu != NULL) - { - attoseconds_t smallest = get_minimum_quantum(firstcpu); - attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; - running_device *cpu; - - /* start with a huge time factor and find the 2nd smallest cycle time */ - for (cpu = cpu_next(firstcpu); cpu != NULL; cpu = cpu_next(cpu)) - { - attoseconds_t curquantum = get_minimum_quantum(cpu); - - /* find the 2nd smallest cycle interval */ - if (curquantum < smallest) - { - perfect = smallest; - smallest = curquantum; - } - else if (curquantum < perfect) - perfect = curquantum; - } - - /* adjust the final value */ - timer_set_minimum_quantum(machine, perfect); - - LOG(("Perfect interleave = %.9f, smallest = %.9f\n", ATTOSECONDS_TO_DOUBLE(perfect), ATTOSECONDS_TO_DOUBLE(smallest))); - } -} - - -/*------------------------------------------------- - on_vblank - calls any external callbacks - for this screen --------------------------------------------------*/ - -static void on_vblank(running_device *device, void *param, int vblank_state) -{ - /* VBLANK starting */ - if (vblank_state) - { - running_device *cpu; - - /* find any CPUs that have this screen as their VBLANK interrupt source */ - for (cpu = device->machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) - { - const cpu_config *config = (const cpu_config *)cpu->baseconfig().inline_config; - cpu_class_data *classdata = get_class_data(cpu); - int cpu_interested; - - /* start the interrupt counter */ - if (!(classdata->suspend & SUSPEND_REASON_DISABLE)) - classdata->iloops = 0; - else - classdata->iloops = -1; - - /* the hack style VBLANK decleration always uses the first screen */ - if (config->vblank_interrupts_per_frame > 1) - cpu_interested = TRUE; - - /* for new style declaration, we need to compare the tags */ - else if (config->vblank_interrupt_screen != NULL) - cpu_interested = (strcmp(config->vblank_interrupt_screen, device->tag()) == 0); - - /* no VBLANK interrupt, not interested */ - else - cpu_interested = FALSE; - - /* if interested, call the interrupt handler */ - if (cpu_interested) - { - if (!(classdata->suspend & (SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))) - (*config->vblank_interrupt)(cpu); - - /* if we have more than one interrupt per frame, start the timer now to trigger the rest of them */ - if (config->vblank_interrupts_per_frame > 1 && !(classdata->suspend & SUSPEND_REASON_DISABLE)) - { - classdata->partial_frame_period = attotime_div(video_screen_get_frame_period(device->machine->primary_screen), config->vblank_interrupts_per_frame); - timer_adjust_oneshot(classdata->partial_frame_timer, classdata->partial_frame_period, 0); - } - } - } - } -} - - -/*------------------------------------------------- - trigger_partial_frame_interrupt - called to - trigger a partial frame interrupt --------------------------------------------------*/ - -static TIMER_CALLBACK( trigger_partial_frame_interrupt ) -{ - running_device *device = (running_device *)ptr; - const cpu_config *config = (const cpu_config *)device->baseconfig().inline_config; - cpu_class_data *classdata = get_class_data(device); - - if (classdata->iloops == 0) - classdata->iloops = config->vblank_interrupts_per_frame; - - classdata->iloops--; - - /* call the interrupt handler */ - if (!cpu_is_suspended(device, SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) - (*config->vblank_interrupt)(device); - - /* more? */ - if (classdata->iloops > 1) - timer_adjust_oneshot(classdata->partial_frame_timer, classdata->partial_frame_period, 0); -} - - -/*------------------------------------------------- - trigger_periodic_interrupt - timer callback for - timed interrupts --------------------------------------------------*/ - -static TIMER_CALLBACK( trigger_periodic_interrupt ) -{ - running_device *device = (running_device *)ptr; - const cpu_config *config = (const cpu_config *)device->baseconfig().inline_config; - - /* bail if there is no routine */ - if (config->timed_interrupt != NULL && !cpu_is_suspended(device, SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) - (*config->timed_interrupt)(device); -} - - -/*------------------------------------------------- - triggertime_callback - signal a global trigger --------------------------------------------------*/ - -static TIMER_CALLBACK( triggertime_callback ) -{ - cpuexec_trigger(machine, param); -} - - -/*------------------------------------------------- - empty_event_queue - empty a CPU's event queue - for a specific input line --------------------------------------------------*/ - -static TIMER_CALLBACK( empty_event_queue ) -{ - running_device *device = (running_device *)ptr; - cpu_class_data *classdata = get_class_data(device); - cpu_input_data *inputline = &classdata->input[param]; - int curevent; - - /* loop over all events */ - for (curevent = 0; curevent < inputline->qindex; curevent++) - { - INT32 input_event = inputline->queue[curevent]; - int state = input_event & 0xff; - int vector = input_event >> 8; - - /* set the input line state and vector */ - inputline->curstate = state; - inputline->curvector = vector; - - /* special case: RESET */ - if (param == INPUT_LINE_RESET) - { - /* if we're asserting the line, just halt the CPU */ - if (state == ASSERT_LINE) - cpu_suspend(device, SUSPEND_REASON_RESET, 1); - else - { - /* if we're clearing the line that was previously asserted, or if we're just */ - /* pulsing the line, reset the CPU */ - if ((state == CLEAR_LINE && cpu_is_suspended(device, SUSPEND_REASON_RESET)) || state == PULSE_LINE) - device->reset(); - - /* if we're clearing the line, make sure the CPU is not halted */ - cpu_resume(device, SUSPEND_REASON_RESET); - } - } - - /* special case: HALT */ - else if (param == INPUT_LINE_HALT) - { - /* if asserting, halt the CPU */ - if (state == ASSERT_LINE) - cpu_suspend(device, SUSPEND_REASON_HALT, 1); - - /* if clearing, unhalt the CPU */ - else if (state == CLEAR_LINE) - cpu_resume(device, SUSPEND_REASON_HALT); - } - - /* all other cases */ - else - { - /* switch off the requested state */ - switch (state) - { - case PULSE_LINE: - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + param, ASSERT_LINE); - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + param, CLEAR_LINE); - break; - - case HOLD_LINE: - case ASSERT_LINE: - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + param, ASSERT_LINE); - break; - - case CLEAR_LINE: - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + param, CLEAR_LINE); - break; - - default: - logerror("empty_event_queue cpu '%s', line %d, unknown state %d\n", device->tag(), param, state); - break; - } - - /* generate a trigger to unsuspend any CPUs waiting on the interrupt */ - if (state != CLEAR_LINE) - cpu_triggerint(device); - } - } - - /* reset counter */ - inputline->qindex = 0; -} - - -/*------------------------------------------------- - standard_irq_callback - IRQ acknowledge - callback; handles HOLD_LINE case and signals - to the debugger --------------------------------------------------*/ - -static IRQ_CALLBACK( standard_irq_callback ) -{ - cpu_class_data *classdata = get_class_data(device); - cpu_input_data *inputline = &classdata->input[irqline]; - int vector = inputline->curvector; - - LOG(("standard_irq_callback('%s', %d) $%04x\n", device->tag(), irqline, vector)); - - /* if the IRQ state is HOLD_LINE, clear it */ - if (inputline->curstate == HOLD_LINE) - { - LOG(("->set_irq_line('%s',%d,%d)\n", device->tag(), irqline, CLEAR_LINE)); - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + irqline, CLEAR_LINE); - inputline->curstate = CLEAR_LINE; - } - - /* if there's a driver callback, run it */ - if (classdata->driver_irq != NULL) - vector = (*classdata->driver_irq)(device, irqline); - - /* notify the debugger */ - debugger_interrupt_hook(device, irqline); - - /* otherwise, just return the current vector */ - return vector; -} - - -/*------------------------------------------------- - register_save_states - register for CPU- - specific save states --------------------------------------------------*/ - -static void register_save_states(running_device *device) -{ - cpu_class_data *classdata = get_class_data(device); - int line; - - state_save_register_device_item(device, 0, classdata->suspend); - state_save_register_device_item(device, 0, classdata->nextsuspend); - state_save_register_device_item(device, 0, classdata->eatcycles); - state_save_register_device_item(device, 0, classdata->nexteatcycles); - state_save_register_device_item(device, 0, classdata->trigger); - - state_save_register_device_item(device, 0, classdata->iloops); - - state_save_register_device_item(device, 0, classdata->totalcycles); - state_save_register_device_item(device, 0, classdata->localtime.seconds); - state_save_register_device_item(device, 0, classdata->localtime.attoseconds); - state_save_register_device_item(device, 0, classdata->clock); - state_save_register_device_item(device, 0, classdata->clockscale); - - for (line = 0; line < ARRAY_LENGTH(classdata->input); line++) - { - cpu_input_data *inputline = &classdata->input[line]; - state_save_register_device_item(device, line, inputline->vector); - state_save_register_device_item(device, line, inputline->curvector); - state_save_register_device_item(device, line, inputline->curstate); - } -} - - -/*------------------------------------------------- - rebuild_execute_list - rebuild the list of - executing CPUs, moving suspended CPUs to the - end --------------------------------------------------*/ - -static void rebuild_execute_list(running_machine *machine) -{ - cpuexec_private *global = machine->cpuexec_data; - running_device *curcpu; - cpu_class_data **tailptr; - - /* start with an empty list */ - tailptr = &global->executelist; - *tailptr = NULL; - - /* first iterate over non-suspended CPUs */ - for (curcpu = machine->firstcpu; curcpu != NULL; curcpu = cpu_next(curcpu)) - { - cpu_class_data *classdata = get_class_data(curcpu); - if (classdata->suspend == 0) - { - *tailptr = classdata; - tailptr = &classdata->next; - classdata->next = NULL; - } - } - - /* then add the suspended CPUs */ - for (curcpu = machine->firstcpu; curcpu != NULL; curcpu = cpu_next(curcpu)) - { - cpu_class_data *classdata = get_class_data(curcpu); - if (classdata->suspend != 0) - { - *tailptr = classdata; - tailptr = &classdata->next; - classdata->next = NULL; - } - } -} - - -/*------------------------------------------------- - get_register_value - return a register value - of a CPU using the state table --------------------------------------------------*/ - -static UINT64 get_register_value(running_device *device, void *baseptr, const cpu_state_entry *entry) -{ - void *dataptr; - UINT64 result; - - /* NULL entry returns 0 */ - if (entry == NULL || baseptr == NULL) - return 0; - - /* if we have an exporter, call it now */ - if ((entry->flags & CPUSTATE_EXPORT) != 0) - { - cpu_state_io_func exportcb = (cpu_state_io_func)device->get_config_fct(CPUINFO_FCT_EXPORT_STATE); - assert(exportcb != NULL); - (*exportcb)(device, baseptr, entry); - } - - /* pick up the value */ - dataptr = (UINT8 *)baseptr + entry->dataoffs; - switch (entry->datasize) - { - default: - case 1: result = *(UINT8 *)dataptr; break; - case 2: result = *(UINT16 *)dataptr; break; - case 4: result = *(UINT32 *)dataptr; break; - case 8: result = *(UINT64 *)dataptr; break; - } - return result & entry->mask; -} - - -/*------------------------------------------------- - set_register_value - set the value of a - CPU register using the state table --------------------------------------------------*/ - -static void set_register_value(running_device *device, void *baseptr, const cpu_state_entry *entry, UINT64 value) -{ - void *dataptr; - - /* NULL entry is a no-op */ - if (entry == NULL || baseptr == NULL) - return; - - /* apply the mask */ - value &= entry->mask; - - /* sign-extend if necessary */ - if ((entry->flags & CPUSTATE_IMPORT_SEXT) != 0 && value > (entry->mask >> 1)) - value |= ~entry->mask; - - /* store the value */ - dataptr = (UINT8 *)baseptr + entry->dataoffs; - switch (entry->datasize) - { - default: - case 1: *(UINT8 *)dataptr = value; break; - case 2: *(UINT16 *)dataptr = value; break; - case 4: *(UINT32 *)dataptr = value; break; - case 8: *(UINT64 *)dataptr = value; break; - } - - /* if we have an importer, call it now */ - if ((entry->flags & CPUSTATE_IMPORT) != 0) - { - cpu_state_io_func importcb = (cpu_state_io_func)device->get_config_fct(CPUINFO_FCT_IMPORT_STATE); - assert(importcb != NULL); - (*importcb)(device, baseptr, entry); - } -} - - -/*------------------------------------------------- - get_register_string_value - return a string - representation of a CPU register using the - state table --------------------------------------------------*/ - -static void get_register_string_value(running_device *device, void *baseptr, const cpu_state_entry *entry, char *dest) -{ - static const UINT64 decdivisor[] = { - 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, - U64(10000000000), U64(100000000000), U64(1000000000000), - U64(10000000000000), U64(100000000000000), U64(1000000000000000), - U64(10000000000000000), U64(100000000000000000), U64(1000000000000000000), - U64(10000000000000000000) - }; - static const char hexchars[] = "0123456789ABCDEF"; - int leadzero = 0, width = 0, percent = 0, explicitsign = 0, hitnonzero = 0, reset; - const char *fptr; - UINT64 result; - - /* NULL entry does nothing */ - if (entry == NULL || entry->symbol == NULL || entry->format == NULL) - return; - - /* fetch the data */ - result = get_register_value(device, baseptr, entry); - - /* start with the basics */ - dest += sprintf(dest, "%s%s:", (entry->flags & CPUSTATE_NOSHOW) ? "~" : "", entry->symbol); - - /* parse the format */ - reset = TRUE; - for (fptr = entry->format; *fptr != 0; fptr++) - { - int digitnum; - - /* reset any accumulated state */ - if (reset) - leadzero = width = percent = explicitsign = reset = 0; - - /* if we're not within a format, then anything other than a % outputs directly */ - if (!percent && *fptr != '%') - { - *dest++ = *fptr; - continue; - } - - /* handle each character in turn */ - switch (*fptr) - { - /* % starts a format; %% outputs a single % */ - case '%': - if (!percent) - percent = TRUE; - else - { - *dest++ = *fptr; - percent = FALSE; - } - break; - - /* 0 means insert leading 0s, unless it follows another width digit */ - case '0': - if (width == 0) - leadzero = TRUE; - else - width *= 10; - break; - - /* 1-9 accumulate into the width */ - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - width = width * 10 + (*fptr - '0'); - break; - - /* + means explicit sign */ - case '+': - explicitsign = TRUE; - break; - - /* X outputs as hexadecimal */ - case 'X': - if (width == 0) - fatalerror("Width required for %%X formats\n"); - hitnonzero = FALSE; - while (leadzero && width > 16) - { - *dest++ = ' '; - width--; - } - for (digitnum = 15; digitnum >= 0; digitnum--) - { - int digit = (result >> (4 * digitnum)) & 0x0f; - if (digit != 0) - *dest++ = hexchars[digit]; - else if (hitnonzero || (leadzero && digitnum < width) || digitnum == 0) - *dest++ = '0'; - hitnonzero |= digit; - } - reset = TRUE; - break; - - /* d outputs as signed decimal */ - case 'd': - if (width == 0) - fatalerror("Width required for %%d formats\n"); - if ((result & entry->mask) > (entry->mask >> 1)) - { - result = -result & entry->mask; - *dest++ = '-'; - width--; - } - else if (explicitsign) - { - *dest++ = '+'; - width--; - } - /* fall through to unsigned case */ - - /* u outputs as unsigned decimal */ - case 'u': - if (width == 0) - fatalerror("Width required for %%u formats\n"); - hitnonzero = FALSE; - while (leadzero && width > ARRAY_LENGTH(decdivisor)) - { - *dest++ = ' '; - width--; - } - for (digitnum = ARRAY_LENGTH(decdivisor) - 1; digitnum >= 0; digitnum--) - { - int digit = (result >= decdivisor[digitnum]) ? (result / decdivisor[digitnum]) % 10 : 0; - if (digit != 0) - *dest++ = '0' + digit; - else if (hitnonzero || (leadzero && digitnum < width) || digitnum == 0) - *dest++ = '0'; - hitnonzero |= digit; - } - reset = TRUE; - break; - - /* s is a custom format */ - case 's': - { - cpu_string_io_func exportstring = (cpu_string_io_func)device->get_config_fct(CPUINFO_FCT_EXPORT_STRING); - assert(exportstring != NULL); - (*exportstring)(device, baseptr, entry, dest); - dest += strlen(dest); - break; - } - - /* other formats unknown */ - default: - fatalerror("Unknown format character '%c'\n", *fptr); - break; - } - } - *dest = 0; -} - - -/*------------------------------------------------- - get_register_string_max_width - return the - maximum width of a string described by a - format --------------------------------------------------*/ - -#ifdef UNUSED_FUNCTION -static int get_register_string_max_width(running_device *device, void *baseptr, const cpu_state_entry *entry) -{ - int /*leadzero = 0,*/ width = 0, percent = 0, explicitsign = 0, reset; - int totalwidth = 0; - const char *fptr; - - /* NULL entry does nothing */ - if (entry == NULL || entry->symbol == NULL || entry->format == NULL) - return 0; - - /* parse the format */ - reset = TRUE; - for (fptr = entry->format; *fptr != 0; fptr++) - { - /* reset any accumulated state */ - if (reset) - /*leadzero =*/ width = percent = explicitsign = reset = 0; - - /* if we're not within a format, then anything other than a % outputs directly */ - if (!percent && *fptr != '%') - { - totalwidth++; - continue; - } - - /* handle each character in turn */ - switch (*fptr) - { - /* % starts a format; %% outputs a single % */ - case '%': - if (!percent) - percent = TRUE; - else - { - totalwidth++; - percent = FALSE; - } - break; - - /* 0 means insert leading 0s, unless it follows another width digit */ - case '0': - if (width == 0) { - //leadzero = TRUE; - } - else - width *= 10; - break; - - /* 1-9 accumulate into the width */ - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - width = width * 10 + (*fptr - '0'); - break; - - /* + means explicit sign */ - case '+': - explicitsign = TRUE; - break; - - /* X outputs as hexadecimal */ - /* d outputs as signed decimal */ - /* u outputs as unsigned decimal */ - /* s outputs as custom format */ - case 'X': - case 'd': - case 'u': - case 's': - totalwidth += width; - reset = TRUE; - break; - - if (width == 0) - fatalerror("Width required for %%d formats\n"); - totalwidth += width; - break; - - /* other formats unknown */ - default: - fatalerror("Unknown format character '%c'\n", *fptr); - break; - } - } - return totalwidth; -} -#endif diff --git a/src/emu/cpuexec.h b/src/emu/cpuexec.h deleted file mode 100644 index 4acf3d1e0a9..00000000000 --- a/src/emu/cpuexec.h +++ /dev/null @@ -1,347 +0,0 @@ -/*************************************************************************** - - cpuexec.h - - Core multi-CPU execution engine. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#pragma once - -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - -#ifndef __CPUEXEC_H__ -#define __CPUEXEC_H__ - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* flags for MDRV_CPU_FLAGS */ -enum -{ - /* set this flag to disable execution of a CPU (if one is there for documentation */ - /* purposes only, for example */ - CPU_DISABLE = 0x0001 -}; - - -/* suspension reasons for cpunum_suspend */ -enum -{ - SUSPEND_REASON_HALT = 0x0001, - SUSPEND_REASON_RESET = 0x0002, - SUSPEND_REASON_SPIN = 0x0004, - SUSPEND_REASON_TRIGGER = 0x0008, - SUSPEND_REASON_DISABLE = 0x0010, - SUSPEND_REASON_TIMESLICE= 0x0020, - SUSPEND_ANY_REASON = ~0 -}; - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* opaque definition of CPU internal and debugging info */ -typedef struct _cpu_debug_data cpu_debug_data; - - -/* interrupt callback for VBLANK and timed interrupts */ -typedef void (*cpu_interrupt_func)(running_device *device); - - -/* CPU description for drivers */ -typedef struct _cpu_config cpu_config; -struct _cpu_config -{ - cpu_type type; /* index for the CPU type */ - UINT32 flags; /* flags; see #defines below */ - cpu_interrupt_func vblank_interrupt; /* for interrupts tied to VBLANK */ - int vblank_interrupts_per_frame;/* usually 1 */ - const char * vblank_interrupt_screen; /* the screen that causes the VBLANK interrupt */ - cpu_interrupt_func timed_interrupt; /* for interrupts not tied to VBLANK */ - UINT64 timed_interrupt_period; /* period for periodic interrupts */ -}; - - -/* public data at the end of the device->token */ -typedef struct _cpu_class_header cpu_class_header; -struct _cpu_class_header -{ - cpu_debug_data * debug; /* debugging data */ - cpu_set_info_func set_info; /* this CPU's set_info function */ -}; - - - -/*************************************************************************** - CPU DEVICE CONFIGURATION MACROS -***************************************************************************/ - -#define MDRV_CPU_ADD(_tag, _type, _clock) \ - MDRV_DEVICE_ADD(_tag, CPU, _clock) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, type, CPU_##_type) - -#define MDRV_CPU_MODIFY(_tag) \ - MDRV_DEVICE_MODIFY(_tag) - -#define MDRV_CPU_TYPE(_type) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, type, CPU_##_type) - -#define MDRV_CPU_CLOCK(_clock) \ - MDRV_DEVICE_CLOCK(_clock) - -#define MDRV_CPU_REPLACE(_tag, _type, _clock) \ - MDRV_DEVICE_MODIFY(_tag) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, type, CPU_##_type) \ - MDRV_DEVICE_CLOCK(_clock) - -#define MDRV_CPU_FLAGS(_flags) \ - MDRV_DEVICE_CONFIG_DATA32(cpu_config, flags, _flags) - -#define MDRV_CPU_CONFIG(_config) \ - MDRV_DEVICE_CONFIG(_config) - -#define MDRV_CPU_PROGRAM_MAP(_map) \ - MDRV_DEVICE_PROGRAM_MAP(_map) - -#define MDRV_CPU_DATA_MAP(_map) \ - MDRV_DEVICE_DATA_MAP(_map) - -#define MDRV_CPU_IO_MAP(_map) \ - MDRV_DEVICE_IO_MAP(_map) - -#define MDRV_CPU_VBLANK_INT(_tag, _func) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt, _func) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt_screen, _tag) \ - MDRV_DEVICE_CONFIG_DATA32(cpu_config, vblank_interrupts_per_frame, 0) - -#define MDRV_CPU_PERIODIC_INT(_func, _rate) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, timed_interrupt, _func) \ - MDRV_DEVICE_CONFIG_DATA64(cpu_config, timed_interrupt_period, UINT64_ATTOTIME_IN_HZ(_rate)) - - - -/*************************************************************************** - MACROS -***************************************************************************/ - -#define INTERRUPT_GEN(func) void func(running_device *device) - -/* helpers for using machine/cputag instead of cpu objects */ -#define cputag_get_address_space(mach, tag, spc) (mach)->device(tag)->space(spc) -#define cputag_suspend(mach, tag, reason, eat) cpu_suspend((mach)->device(tag), reason, eat) -#define cputag_resume(mach, tag, reason) cpu_resume((mach)->device(tag), reason) -#define cputag_is_suspended(mach, tag, reason) cpu_is_suspended((mach)->device(tag), reason) -#define cputag_get_clock(mach, tag) cpu_get_clock((mach)->device(tag)) -#define cputag_set_clock(mach, tag, clock) cpu_set_clock((mach)->device(tag), clock) -#define cputag_clocks_to_attotime(mach, tag, clocks) cpu_clocks_to_attotime((mach)->device(tag), clocks) -#define cputag_attotime_to_clocks(mach, tag, duration) cpu_attotime_to_clocks((mach)->device(tag), duration) -#define cputag_get_local_time(mach, tag) cpu_get_local_time((mach)->device(tag)) -#define cputag_get_total_cycles(mach, tag) cpu_get_total_cycles((mach)->device(tag)) -#define cputag_set_input_line(mach, tag, line, state) cpu_set_input_line((mach)->device(tag), line, state) -#define cputag_set_input_line_and_vector(mach, tag, line, state, vec) cpu_set_input_line_and_vector((mach)->device(tag), line, state, vec) - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - - -/* ----- core CPU execution ----- */ - -/* prepare CPUs for execution */ -void cpuexec_init(running_machine *machine); - -/* execute for a single timeslice */ -void cpuexec_timeslice(running_machine *machine); - -/* temporarily boosts the interleave factor */ -void cpuexec_boost_interleave(running_machine *machine, attotime timeslice_time, attotime boost_duration); - - - -/* ----- CPU device interface ----- */ - -/* device get info callback */ -#define CPU DEVICE_GET_INFO_NAME(cpu) -DEVICE_GET_INFO( cpu ); - - - -/* ----- global helpers ----- */ - -/* abort execution for the current timeslice */ -void cpuexec_abort_timeslice(running_machine *machine); - -/* return a string describing which CPUs are currently executing and their PC */ -const char *cpuexec_describe_context(running_machine *machine); - - - -/* ----- CPU scheduling----- */ - -/* suspend the given CPU for a specific reason */ -void cpu_suspend(running_device *device, int reason, int eatcycles); - -/* resume the given CPU for a specific reason */ -void cpu_resume(running_device *device, int reason); - -/* return TRUE if the given CPU is within its execute function */ -int cpu_is_executing(running_device *device); - -/* returns TRUE if the given CPU is suspended for any of the given reasons */ -int cpu_is_suspended(running_device *device, int reason); - - - -/* ----- CPU clock management ----- */ - -/* returns the current CPU's unscaled running clock speed */ -int cpu_get_clock(running_device *device); - -/* sets the current CPU's clock speed and then adjusts for scaling */ -void cpu_set_clock(running_device *device, int clock); - -/* returns the current scaling factor for a CPU's clock speed */ -double cpu_get_clockscale(running_device *device); - -/* sets the current scaling factor for a CPU's clock speed */ -void cpu_set_clockscale(running_device *device, double clockscale); - -/* converts a number of clock ticks to an attotime */ -attotime cpu_clocks_to_attotime(running_device *device, UINT64 clocks); - -/* converts a duration as attotime to CPU clock ticks */ -UINT64 cpu_attotime_to_clocks(running_device *device, attotime duration); - - - -/* ----- CPU timing ----- */ - -/* returns the current local time for a CPU */ -attotime cpu_get_local_time(running_device *device); - -/* returns the total number of CPU cycles for a given CPU */ -UINT64 cpu_get_total_cycles(running_device *device); - -/* safely eats cycles so we don't cross a timeslice boundary */ -void cpu_eat_cycles(running_device *device, int cycles); - -/* apply a +/- to the current icount */ -void cpu_adjust_icount(running_device *device, int delta); - -/* abort execution for the current timeslice, allowing other CPUs to run before we run again */ -void cpu_abort_timeslice(running_device *device); - - - -/* ----- synchronization helpers ----- */ - -/* yield the given CPU until the end of the current timeslice */ -void cpu_yield(running_device *device); - -/* burn CPU cycles until the end of the current timeslice */ -void cpu_spin(running_device *device); - -/* burn specified CPU cycles until a trigger */ -void cpu_spinuntil_trigger(running_device *device, int trigger); - -/* burn CPU cycles until the next interrupt */ -void cpu_spinuntil_int(running_device *device); - -/* burn CPU cycles for a specific period of time */ -void cpu_spinuntil_time(running_device *device, attotime duration); - - - -/* ----- triggers ----- */ - -/* generate a global trigger now */ -void cpuexec_trigger(running_machine *machine, int trigger); - -/* generate a global trigger after a specific period of time */ -void cpuexec_triggertime(running_machine *machine, int trigger, attotime duration); - -/* generate a trigger corresponding to an interrupt on the given CPU */ -void cpu_triggerint(running_device *device); - - - -/* ----- interrupts ----- */ - -/* set the logical state (ASSERT_LINE/CLEAR_LINE) of the an input line on a CPU */ -void cpu_set_input_line(running_device *cpu, int line, int state); - -/* set the vector to be returned during a CPU's interrupt acknowledge cycle */ -void cpu_set_input_line_vector(running_device *cpu, int irqline, int vector); - -/* set the logical state (ASSERT_LINE/CLEAR_LINE) of the an input line on a CPU and its associated vector */ -void cpu_set_input_line_and_vector(running_device *cpu, int line, int state, int vector); - -/* install a driver-specific callback for IRQ acknowledge */ -void cpu_set_irq_callback(running_device *cpu, cpu_irq_callback callback); - - - -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ - -/*------------------------------------------------- - cpu_get_type - return the type of the - specified CPU --------------------------------------------------*/ - -INLINE cpu_type cpu_get_type(running_device *device) -{ - const cpu_config *config = (const cpu_config *)device->baseconfig().inline_config; - return config->type; -} - - -/*------------------------------------------------- - cpu_get_class_header - return a pointer to - the class header --------------------------------------------------*/ - -INLINE cpu_class_header *cpu_get_class_header(running_device *device) -{ - if (device->token != NULL) - return (cpu_class_header *)((UINT8 *)device->token + device->tokenbytes) - 1; - return NULL; -} - - -/*------------------------------------------------- - cpu_get_debug_data - return a pointer to - the given CPU's debugger data --------------------------------------------------*/ - -INLINE cpu_debug_data *cpu_get_debug_data(running_device *device) -{ - cpu_class_header *classheader = cpu_get_class_header(device); - return classheader->debug; -} - - -/*------------------------------------------------- - cpu_get_address_space - return a pointer to - the given CPU's address space --------------------------------------------------*/ - -INLINE const address_space *cpu_get_address_space(running_device *device, int spacenum) -{ - return device->space(spacenum); -} - -#endif /* __CPUEXEC_H__ */ diff --git a/src/emu/cpuintrf.h b/src/emu/cpuintrf.h deleted file mode 100644 index 4004eac4841..00000000000 --- a/src/emu/cpuintrf.h +++ /dev/null @@ -1,429 +0,0 @@ -/*************************************************************************** - - cpuintrf.h - - Core CPU interface functions and definitions. - - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. - -***************************************************************************/ - -#pragma once - -#ifndef __EMU_H__ -#error Dont include this file directly; include emu.h instead. -#endif - -#ifndef __CPUINTRF_H__ -#define __CPUINTRF_H__ - - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define MAX_INPUT_EVENTS 32 - - -/* alternate address space names for common use */ -enum -{ - ADDRESS_SPACE_PROGRAM = ADDRESS_SPACE_0, /* program address space */ - ADDRESS_SPACE_DATA = ADDRESS_SPACE_1, /* data address space */ - ADDRESS_SPACE_IO = ADDRESS_SPACE_2 /* I/O address space */ -}; - - -/* I/O line states */ -enum -{ - CLEAR_LINE = 0, /* clear (a fired or held) line */ - ASSERT_LINE, /* assert an interrupt immediately */ - HOLD_LINE, /* hold interrupt line until acknowledged */ - PULSE_LINE /* pulse interrupt line instantaneously (only for NMI, RESET) */ -}; - - -/* I/O line definitions */ -enum -{ - /* input lines */ - MAX_INPUT_LINES = 32+3, - INPUT_LINE_IRQ0 = 0, - INPUT_LINE_IRQ1 = 1, - INPUT_LINE_IRQ2 = 2, - INPUT_LINE_IRQ3 = 3, - INPUT_LINE_IRQ4 = 4, - INPUT_LINE_IRQ5 = 5, - INPUT_LINE_IRQ6 = 6, - INPUT_LINE_IRQ7 = 7, - INPUT_LINE_IRQ8 = 8, - INPUT_LINE_IRQ9 = 9, - INPUT_LINE_NMI = MAX_INPUT_LINES - 3, - - /* special input lines that are implemented in the core */ - INPUT_LINE_RESET = MAX_INPUT_LINES - 2, - INPUT_LINE_HALT = MAX_INPUT_LINES - 1, - - /* output lines */ - MAX_OUTPUT_LINES = 32 -}; - - -/* register definitions */ -enum -{ - MAX_REGS = 256, - - REG_GENPCBASE = MAX_REGS - 1, /* generic "base" PC, should point to start of current opcode */ - REG_GENPC = MAX_REGS - 2, /* generic PC, may point within an opcode */ - REG_GENSP = MAX_REGS - 3 /* generic SP, or closest equivalent */ -}; - - -/* CPU information constants */ -enum -{ - /* --- the following bits of info are returned as 64-bit signed integers --- */ - CPUINFO_INT_FIRST = DEVINFO_INT_FIRST, - - /* CPU-specific additions */ - CPUINFO_INT_CONTEXT_SIZE = DEVINFO_INT_CLASS_SPECIFIC, /* R/O: size of CPU context in bytes */ - CPUINFO_INT_INPUT_LINES, /* R/O: number of input lines */ - CPUINFO_INT_OUTPUT_LINES, /* R/O: number of output lines */ - CPUINFO_INT_DEFAULT_IRQ_VECTOR, /* R/O: default IRQ vector */ - CPUINFO_INT_CLOCK_MULTIPLIER, /* R/O: internal clock multiplier */ - CPUINFO_INT_CLOCK_DIVIDER, /* R/O: internal clock divider */ - CPUINFO_INT_MIN_INSTRUCTION_BYTES, /* R/O: minimum bytes per instruction */ - CPUINFO_INT_MAX_INSTRUCTION_BYTES, /* R/O: maximum bytes per instruction */ - CPUINFO_INT_MIN_CYCLES, /* R/O: minimum cycles for a single instruction */ - CPUINFO_INT_MAX_CYCLES, /* R/O: maximum cycles for a single instruction */ - - CPUINFO_INT_LOGADDR_WIDTH, /* R/O: address bus size for logical accesses in each space (0=same as physical) */ - CPUINFO_INT_LOGADDR_WIDTH_PROGRAM = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_PROGRAM, - CPUINFO_INT_LOGADDR_WIDTH_DATA = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_DATA, - CPUINFO_INT_LOGADDR_WIDTH_IO = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_IO, - CPUINFO_INT_LOGADDR_WIDTH_LAST = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACES - 1, - CPUINFO_INT_PAGE_SHIFT, /* R/O: size of a page log 2 (i.e., 12=4096), or 0 if paging not supported */ - CPUINFO_INT_PAGE_SHIFT_PROGRAM = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_PROGRAM, - CPUINFO_INT_PAGE_SHIFT_DATA = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_DATA, - CPUINFO_INT_PAGE_SHIFT_IO = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_IO, - CPUINFO_INT_PAGE_SHIFT_LAST = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACES - 1, - - CPUINFO_INT_INPUT_STATE, /* R/W: states for each input line */ - CPUINFO_INT_INPUT_STATE_LAST = CPUINFO_INT_INPUT_STATE + MAX_INPUT_LINES - 1, - CPUINFO_INT_OUTPUT_STATE, /* R/W: states for each output line */ - CPUINFO_INT_OUTPUT_STATE_LAST = CPUINFO_INT_OUTPUT_STATE + MAX_OUTPUT_LINES - 1, - CPUINFO_INT_REGISTER, /* R/W: values of up to MAX_REGs registers */ - CPUINFO_INT_SP = CPUINFO_INT_REGISTER + REG_GENSP, /* R/W: the current stack pointer value */ - CPUINFO_INT_PC = CPUINFO_INT_REGISTER + REG_GENPC, /* R/W: the current PC value */ - CPUINFO_INT_PREVIOUSPC = CPUINFO_INT_REGISTER + REG_GENPCBASE, /* R/W: the previous PC value */ - CPUINFO_INT_REGISTER_LAST = CPUINFO_INT_REGISTER + MAX_REGS - 1, - - CPUINFO_INT_CPU_SPECIFIC = 0x08000, /* R/W: CPU-specific values start here */ - - /* --- the following bits of info are returned as pointers to data or functions --- */ - CPUINFO_PTR_FIRST = DEVINFO_PTR_FIRST, - - /* CPU-specific additions */ - CPUINFO_PTR_INSTRUCTION_COUNTER = DEVINFO_PTR_CLASS_SPECIFIC, - /* R/O: int *icount */ - CPUINFO_PTR_STATE_TABLE, /* R/O: cpu_state_table *state */ - - CPUINFO_PTR_CPU_SPECIFIC = DEVINFO_PTR_DEVICE_SPECIFIC, /* R/W: CPU-specific values start here */ - - /* --- the following bits of info are returned as pointers to functions --- */ - CPUINFO_FCT_FIRST = DEVINFO_FCT_FIRST, - - /* CPU-specific additions */ - CPUINFO_FCT_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC, /* R/O: void (*set_info)(running_device *device, UINT32 state, INT64 data, void *ptr) */ - CPUINFO_FCT_INIT, /* R/O: void (*init)(running_device *device, int index, int clock, int (*irqcallback)(running_device *device, int)) */ - CPUINFO_FCT_RESET, /* R/O: void (*reset)(running_device *device) */ - CPUINFO_FCT_EXIT, /* R/O: void (*exit)(running_device *device) */ - CPUINFO_FCT_EXECUTE, /* R/O: int (*execute)(running_device *device, int cycles) */ - CPUINFO_FCT_BURN, /* R/O: void (*burn)(running_device *device, int cycles) */ - CPUINFO_FCT_DISASSEMBLE, /* R/O: offs_t (*disassemble)(running_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) */ - CPUINFO_FCT_TRANSLATE, /* R/O: int (*translate)(running_device *device, int space, int intention, offs_t *address) */ - CPUINFO_FCT_READ, /* R/O: int (*read)(running_device *device, int space, UINT32 offset, int size, UINT64 *value) */ - CPUINFO_FCT_WRITE, /* R/O: int (*write)(running_device *device, int space, UINT32 offset, int size, UINT64 value) */ - CPUINFO_FCT_READOP, /* R/O: int (*readop)(running_device *device, UINT32 offset, int size, UINT64 *value) */ - CPUINFO_FCT_DEBUG_INIT, /* R/O: void (*debug_init)(running_device *device) */ - CPUINFO_FCT_VALIDITY_CHECK, /* R/O: int (*validity_check)(const game_driver *driver, const void *config) */ - CPUINFO_FCT_IMPORT_STATE, /* R/O: void (*import_state)(running_device *device, void *baseptr, const cpu_state_entry *entry) */ - CPUINFO_FCT_EXPORT_STATE, /* R/O: void (*export_state)(running_device *device, void *baseptr, const cpu_state_entry *entry) */ - CPUINFO_FCT_IMPORT_STRING, /* R/O: void (*import_string)(running_device *device, void *baseptr, const cpu_state_entry *entry, const char *format, char *string) */ - CPUINFO_FCT_EXPORT_STRING, /* R/O: void (*export_string)(running_device *device, void *baseptr, const cpu_state_entry *entry, const char *format, char *string) */ - - CPUINFO_FCT_CPU_SPECIFIC = DEVINFO_FCT_DEVICE_SPECIFIC, /* R/W: CPU-specific values start here */ - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - CPUINFO_STR_FIRST = DEVINFO_STR_FIRST, - - /* CPU-specific additions */ - CPUINFO_STR_FLAGS = DEVINFO_STR_CLASS_SPECIFIC, /* R/O: string representation of the main flags value */ - CPUINFO_STR_REGISTER, /* R/O: string representation of up to MAX_REGs registers */ - CPUINFO_STR_REGISTER_LAST = CPUINFO_STR_REGISTER + MAX_REGS - 1, - - CPUINFO_STR_CPU_SPECIFIC = DEVINFO_STR_DEVICE_SPECIFIC /* R/W: CPU-specific values start here */ -}; - - -/* Translation intentions */ -#define TRANSLATE_TYPE_MASK 0x03 /* read write or fetch */ -#define TRANSLATE_USER_MASK 0x04 /* user mode or fully privileged */ -#define TRANSLATE_DEBUG_MASK 0x08 /* debug mode (no side effects) */ - -#define TRANSLATE_READ 0 /* translate for read */ -#define TRANSLATE_WRITE 1 /* translate for write */ -#define TRANSLATE_FETCH 2 /* translate for instruction fetch */ -#define TRANSLATE_READ_USER (TRANSLATE_READ | TRANSLATE_USER_MASK) -#define TRANSLATE_WRITE_USER (TRANSLATE_WRITE | TRANSLATE_USER_MASK) -#define TRANSLATE_FETCH_USER (TRANSLATE_FETCH | TRANSLATE_USER_MASK) -#define TRANSLATE_READ_DEBUG (TRANSLATE_READ | TRANSLATE_DEBUG_MASK) -#define TRANSLATE_WRITE_DEBUG (TRANSLATE_WRITE | TRANSLATE_DEBUG_MASK) -#define TRANSLATE_FETCH_DEBUG (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK) - - -/* Disassembler constants */ -#define DASMFLAG_SUPPORTED 0x80000000 /* are disassembly flags supported? */ -#define DASMFLAG_STEP_OUT 0x40000000 /* this instruction should be the end of a step out sequence */ -#define DASMFLAG_STEP_OVER 0x20000000 /* this instruction should be stepped over by setting a breakpoint afterwards */ -#define DASMFLAG_OVERINSTMASK 0x18000000 /* number of extra instructions to skip when stepping over */ -#define DASMFLAG_OVERINSTSHIFT 27 /* bits to shift after masking to get the value */ -#define DASMFLAG_LENGTHMASK 0x0000ffff /* the low 16-bits contain the actual length */ -#define DASMFLAG_STEP_OVER_EXTRA(x) ((x) << DASMFLAG_OVERINSTSHIFT) - - -/* state table flags */ -#define CPUSTATE_NOSHOW 0x01 /* don't display this entry in the registers view */ -#define CPUSTATE_IMPORT 0x02 /* call the import function after writing new data */ -#define CPUSTATE_IMPORT_SEXT 0x04 /* sign-extend the data when writing new data */ -#define CPUSTATE_EXPORT 0x08 /* call the export function prior to fetching the data */ - - - -/*************************************************************************** - MACROS -***************************************************************************/ - -/* device iteration helpers */ -#define cpu_count(config) (config)->devicelist.count(CPU) -#define cpu_first(config) (config)->devicelist.first(CPU) -#define cpu_next(previous) (previous)->typenext() -#define cpu_get_index(cpu) (cpu)->machine->devicelist.index(CPU, (cpu)->tag()) - - -/* IRQ callback to be called by CPU cores when an IRQ is actually taken */ -#define IRQ_CALLBACK(func) int func(running_device *device, int irqline) - - -/* CPU interface functions */ -#define CPU_GET_INFO_NAME(name) cpu_get_info_##name -#define CPU_GET_INFO(name) void CPU_GET_INFO_NAME(name)(const device_config *devconfig, running_device *device, UINT32 state, cpuinfo *info) -#define CPU_GET_INFO_CALL(name) CPU_GET_INFO_NAME(name)(devconfig, device, state, info) - -#define CPU_SET_INFO_NAME(name) cpu_set_info_##name -#define CPU_SET_INFO(name) void CPU_SET_INFO_NAME(name)(running_device *device, UINT32 state, cpuinfo *info) -#define CPU_SET_INFO_CALL(name) CPU_SET_INFO_NAME(name)(device, state, info) - -#define CPU_INIT_NAME(name) cpu_init_##name -#define CPU_INIT(name) void CPU_INIT_NAME(name)(running_device *device, cpu_irq_callback irqcallback) -#define CPU_INIT_CALL(name) CPU_INIT_NAME(name)(device, irqcallback) - -#define CPU_RESET_NAME(name) cpu_reset_##name -#define CPU_RESET(name) void CPU_RESET_NAME(name)(running_device *device) -#define CPU_RESET_CALL(name) CPU_RESET_NAME(name)(device) - -#define CPU_EXIT_NAME(name) cpu_exit_##name -#define CPU_EXIT(name) void CPU_EXIT_NAME(name)(running_device *device) -#define CPU_EXIT_CALL(name) CPU_EXIT_NAME(name)(device) - -#define CPU_EXECUTE_NAME(name) cpu_execute_##name -#define CPU_EXECUTE(name) int CPU_EXECUTE_NAME(name)(running_device *device, int cycles) -#define CPU_EXECUTE_CALL(name) CPU_EXECUTE_NAME(name)(device, cycles) - -#define CPU_BURN_NAME(name) cpu_burn_##name -#define CPU_BURN(name) void CPU_BURN_NAME(name)(running_device *device, int cycles) -#define CPU_BURN_CALL(name) CPU_BURN_NAME(name)(device, cycles) - -#define CPU_TRANSLATE_NAME(name) cpu_translate_##name -#define CPU_TRANSLATE(name) int CPU_TRANSLATE_NAME(name)(running_device *device, int space, int intention, offs_t *address) -#define CPU_TRANSLATE_CALL(name) CPU_TRANSLATE_NAME(name)(device, space, intention, address) - -#define CPU_READ_NAME(name) cpu_read_##name -#define CPU_READ(name) int CPU_READ_NAME(name)(running_device *device, int space, UINT32 offset, int size, UINT64 *value) -#define CPU_READ_CALL(name) CPU_READ_NAME(name)(device, space, offset, size, value) - -#define CPU_WRITE_NAME(name) cpu_write_##name -#define CPU_WRITE(name) int CPU_WRITE_NAME(name)(running_device *device, int space, UINT32 offset, int size, UINT64 value) -#define CPU_WRITE_CALL(name) CPU_WRITE_NAME(name)(device, space, offset, size, value) - -#define CPU_READOP_NAME(name) cpu_readop_##name -#define CPU_READOP(name) int CPU_READOP_NAME(name)(running_device *device, UINT32 offset, int size, UINT64 *value) -#define CPU_READOP_CALL(name) CPU_READOP_NAME(name)(device, offset, size, value) - -#define CPU_DEBUG_INIT_NAME(name) cpu_debug_init_##name -#define CPU_DEBUG_INIT(name) void CPU_DEBUG_INIT_NAME(name)(running_device *device) -#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)(device) - -#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name -#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(running_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) -#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram, options) - -#define CPU_VALIDITY_CHECK_NAME(name) cpu_validity_check_##name -#define CPU_VALIDITY_CHECK(name) int CPU_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const void *config) -#define CPU_VALIDITY_CHECK_CALL(name) CPU_VALIDITY_CHECK_NAME(name)(driver, config) - -#define CPU_IMPORT_STATE_NAME(name) cpu_state_import_##name -#define CPU_IMPORT_STATE(name) void CPU_IMPORT_STATE_NAME(name)(running_device *device, void *baseptr, const cpu_state_entry *entry) -#define CPU_IMPORT_STATE_CALL(name) CPU_IMPORT_STATE_NAME(name)(device, baseptr, entry) - -#define CPU_EXPORT_STATE_NAME(name) cpu_state_export_##name -#define CPU_EXPORT_STATE(name) void CPU_EXPORT_STATE_NAME(name)(running_device *device, void *baseptr, const cpu_state_entry *entry) -#define CPU_EXPORT_STATE_CALL(name) CPU_EXPORT_STATE_NAME(name)(device, baseptr, entry) - -#define CPU_IMPORT_STRING_NAME(name) cpu_string_import_##name -#define CPU_IMPORT_STRING(name) void CPU_IMPORT_STRING_NAME(name)(running_device *device, void *baseptr, const cpu_state_entry *entry, char *string) -#define CPU_IMPORT_STRING_CALL(name) CPU_IMPORT_STRING_NAME(name)(device, baseptr, entry, string) - -#define CPU_EXPORT_STRING_NAME(name) cpu_string_export_##name -#define CPU_EXPORT_STRING(name) void CPU_EXPORT_STRING_NAME(name)(running_device *device, void *baseptr, const cpu_state_entry *entry, char *string) -#define CPU_EXPORT_STRING_CALL(name) CPU_EXPORT_STRING_NAME(name)(device, baseptr, entry, string) - - -/* base macro for defining CPU state entries */ -#define CPU_STATE_ENTRY(_index, _symbol, _format, _struct, _member, _datamask, _validmask, _flags) \ - { _index, _validmask, offsetof(_struct, _member), _datamask, sizeof(((_struct *)0)->_member), _flags, _symbol, _format }, - - -/* helpers for accessing common CPU state */ -#define cpu_get_context_size(cpu) (cpu)->get_config_int(CPUINFO_INT_CONTEXT_SIZE) -#define cpu_get_input_lines(cpu) (cpu)->get_config_int(CPUINFO_INT_INPUT_LINES) -#define cpu_get_output_lines(cpu) (cpu)->get_config_int(CPUINFO_INT_OUTPUT_LINES) -#define cpu_get_default_irq_vector(cpu) (cpu)->get_config_int(CPUINFO_INT_DEFAULT_IRQ_VECTOR) -#define cpu_get_clock_multiplier(cpu) (cpu)->get_config_int(CPUINFO_INT_CLOCK_MULTIPLIER) -#define cpu_get_clock_divider(cpu) (cpu)->get_config_int(CPUINFO_INT_CLOCK_DIVIDER) -#define cpu_get_min_opcode_bytes(cpu) (cpu)->get_config_int(CPUINFO_INT_MIN_INSTRUCTION_BYTES) -#define cpu_get_max_opcode_bytes(cpu) (cpu)->get_config_int(CPUINFO_INT_MAX_INSTRUCTION_BYTES) -#define cpu_get_min_cycles(cpu) (cpu)->get_config_int(CPUINFO_INT_MIN_CYCLES) -#define cpu_get_max_cycles(cpu) (cpu)->get_config_int(CPUINFO_INT_MAX_CYCLES) -#define cpu_get_logaddr_width(cpu, space) (cpu)->get_config_int(CPUINFO_INT_LOGADDR_WIDTH + (space)) -#define cpu_get_page_shift(cpu, space) (cpu)->get_config_int(CPUINFO_INT_PAGE_SHIFT + (space)) -#define cpu_get_reg(cpu, reg) (cpu)->get_runtime_int(CPUINFO_INT_REGISTER + (reg)) -#define cpu_get_previouspc(cpu) ((offs_t)cpu_get_reg(cpu, REG_GENPCBASE)) -#define cpu_get_pc(cpu) ((offs_t)cpu_get_reg(cpu, REG_GENPC)) -#define cpu_get_sp(cpu) cpu_get_reg(cpu, REG_GENSP) -#define cpu_get_icount_ptr(cpu) (int *)(cpu)->get_runtime_ptr(CPUINFO_PTR_INSTRUCTION_COUNTER) -#define cpu_get_state_table(cpu) (const cpu_state_table *)(cpu)->get_runtime_ptr(CPUINFO_PTR_STATE_TABLE) -#define cpu_get_flags_string(cpu) (cpu)->get_runtime_string(CPUINFO_STR_FLAGS) -#define cpu_get_irq_string(cpu, irq) (cpu)->get_runtime_string(CPUINFO_STR_IRQ_STATE + (irq)) -#define cpu_get_reg_string(cpu, reg) (cpu)->get_runtime_string(CPUINFO_STR_REGISTER + (reg)) - -#define cpu_set_reg(cpu, reg, val) cpu_set_info(cpu, CPUINFO_INT_REGISTER + (reg), (val)) - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -/* forward declaration of types */ -typedef union _cpuinfo cpuinfo; -typedef struct _cpu_state_entry cpu_state_entry; - - -/* IRQ callback to be called by CPU cores when an IRQ is actually taken */ -typedef int (*cpu_irq_callback)(running_device *device, int irqnum); - - -/* CPU interface functions */ -typedef void (*cpu_get_info_func)(const device_config *devconfig, running_device *device, UINT32 state, cpuinfo *info); -typedef void (*cpu_set_info_func)(running_device *device, UINT32 state, cpuinfo *info); -typedef void (*cpu_init_func)(running_device *device, cpu_irq_callback irqcallback); -typedef void (*cpu_reset_func)(running_device *device); -typedef void (*cpu_exit_func)(running_device *device); -typedef int (*cpu_execute_func)(running_device *device, int cycles); -typedef void (*cpu_burn_func)(running_device *device, int cycles); -typedef int (*cpu_translate_func)(running_device *device, int space, int intention, offs_t *address); -typedef int (*cpu_read_func)(running_device *device, int space, UINT32 offset, int size, UINT64 *value); -typedef int (*cpu_write_func)(running_device *device, int space, UINT32 offset, int size, UINT64 value); -typedef int (*cpu_readop_func)(running_device *device, UINT32 offset, int size, UINT64 *value); -typedef void (*cpu_debug_init_func)(running_device *device); -typedef offs_t (*cpu_disassemble_func)(running_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); -typedef int (*cpu_validity_check_func)(const game_driver *driver, const void *config); -typedef void (*cpu_state_io_func)(running_device *device, void *baseptr, const cpu_state_entry *entry); -typedef void (*cpu_string_io_func)(running_device *device, void *baseptr, const cpu_state_entry *entry, char *string); - - -/* a cpu_type is just a pointer to the CPU's get_info function */ -typedef cpu_get_info_func cpu_type; - - -/* structure describing a single item of exposed CPU state */ -struct _cpu_state_entry -{ - UINT32 index; /* state index this entry applies to */ - UINT32 validmask; /* mask for which CPU subtypes this entry is valid */ - FPTR dataoffs; /* offset to the data, relative to the baseptr */ - UINT64 mask; /* mask applied to the data */ - UINT8 datasize; /* size of the data item in memory */ - UINT8 flags; /* flags */ - const char * symbol; /* symbol for display; all lower-case version for expressions */ - const char * format; /* supported formats */ -}; - - -/* structure describing a table of exposed CPU state */ -typedef struct _cpu_state_table cpu_state_table; -struct _cpu_state_table -{ - void * baseptr; /* pointer to the base of state (offsets are relative to this) */ - UINT32 subtypemask; /* mask of subtypes that apply to this CPU */ - UINT32 entrycount; /* number of entries */ - const cpu_state_entry * entrylist; /* array of entries */ -}; - - -/* cpuinfo union used to pass data to/from the get_info/set_info functions */ -union _cpuinfo -{ - INT64 i; /* generic integers */ - void * p; /* generic pointers */ - genf * f; /* generic function pointers */ - char * s; /* generic strings */ - - cpu_set_info_func setinfo; /* CPUINFO_FCT_SET_INFO */ - cpu_init_func init; /* CPUINFO_FCT_INIT */ - cpu_reset_func reset; /* CPUINFO_FCT_RESET */ - cpu_exit_func exit; /* CPUINFO_FCT_EXIT */ - cpu_execute_func execute; /* CPUINFO_FCT_EXECUTE */ - cpu_burn_func burn; /* CPUINFO_FCT_BURN */ - cpu_translate_func translate; /* CPUINFO_FCT_TRANSLATE */ - cpu_read_func read; /* CPUINFO_FCT_READ */ - cpu_write_func write; /* CPUINFO_FCT_WRITE */ - cpu_readop_func readop; /* CPUINFO_FCT_READOP */ - cpu_debug_init_func debug_init; /* CPUINFO_FCT_DEBUG_INIT */ - cpu_disassemble_func disassemble; /* CPUINFO_FCT_DISASSEMBLE */ - cpu_validity_check_func validity_check; /* CPUINFO_FCT_VALIDITY_CHECK */ - cpu_state_io_func import_state; /* CPUINFO_FCT_IMPORT_STATE */ - cpu_state_io_func export_state; /* CPUINFO_FCT_EXPORT_STATE */ - cpu_string_io_func import_string; /* CPUINFO_FCT_IMPORT_STRING */ - cpu_string_io_func export_string; /* CPUINFO_FCT_EXPORT_STRING */ - int * icount; /* CPUINFO_PTR_INSTRUCTION_COUNTER */ - const cpu_state_table * state_table; /* CPUINFO_PTR_STATE_TABLE */ - const addrmap8_token * internal_map8; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap16_token * internal_map16; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap32_token * internal_map32; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap64_token * internal_map64; /* DEVINFO_PTR_INTERNAL_MEMORY_MAP */ - const addrmap8_token * default_map8; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap16_token * default_map16; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap32_token * default_map32; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ - const addrmap64_token * default_map64; /* DEVINFO_PTR_DEFAULT_MEMORY_MAP */ -}; - - -void cpu_set_info(running_device *device, UINT32 state, UINT64 value); - -#endif /* __CPUINTRF_H__ */ diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c index b81fa72069c..ccda97d9b54 100644 --- a/src/emu/crsshair.c +++ b/src/emu/crsshair.c @@ -39,7 +39,7 @@ struct _crosshair_global UINT8 visible[MAX_PLAYERS]; /* visibility per player */ bitmap_t * bitmap[MAX_PLAYERS]; /* bitmap per player */ render_texture * texture[MAX_PLAYERS]; /* texture per player */ - running_device *screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */ + device_t *screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */ float x[MAX_PLAYERS]; /* current X position */ float y[MAX_PLAYERS]; /* current Y position */ float last_x[MAX_PLAYERS]; /* last X position */ @@ -135,7 +135,7 @@ static void crosshair_exit(running_machine *machine); static void crosshair_load(running_machine *machine, int config_type, xml_data_node *parentnode); static void crosshair_save(running_machine *machine, int config_type, xml_data_node *parentnode); -static void animate(running_device *device, void *param, int vblank_state); +static void animate(screen_device &device, void *param, bool vblank_state); /*************************************************************************** @@ -179,7 +179,7 @@ static void create_bitmap(running_machine *machine, int player) if (global.bitmap[player] == NULL) { /* allocate a blank bitmap to start with */ - global.bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32); + global.bitmap[player] = global_alloc(bitmap_t(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32)); bitmap_fill(global.bitmap[player], NULL, MAKE_ARGB(0x00,0xff,0xff,0xff)); /* extract the raw source data to it */ @@ -222,7 +222,7 @@ void crosshair_init(running_machine *machine) global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT; /* determine who needs crosshairs */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->crossaxis != CROSSHAIR_AXIS_NONE) { @@ -248,7 +248,7 @@ void crosshair_init(running_machine *machine) /* register the animation callback */ if (machine->primary_screen != NULL) - video_screen_register_vblank_callback(machine->primary_screen, animate, NULL); + machine->primary_screen->register_vblank_callback(animate, NULL); } @@ -331,7 +331,7 @@ void crosshair_set_user_settings(running_machine *machine, UINT8 player, crossha animate - animates the crosshair once a frame -------------------------------------------------*/ -static void animate(running_device *device, void *param, int vblank_state) +static void animate(screen_device &device, void *param, bool vblank_state) { int player; @@ -352,7 +352,7 @@ static void animate(running_device *device, void *param, int vblank_state) { /* read all the lightgun values */ if (global.used[player]) - input_port_get_crosshair_position(device->machine, player, &global.x[player], &global.y[player]); + input_port_get_crosshair_position(device.machine, player, &global.x[player], &global.y[player]); /* auto visibility */ if (global.mode[player] == CROSSHAIR_VISIBILITY_AUTO) @@ -388,17 +388,17 @@ static void animate(running_device *device, void *param, int vblank_state) for the given screen -------------------------------------------------*/ -void crosshair_render(running_device *screen) +void crosshair_render(screen_device &screen) { int player; for (player = 0; player < MAX_PLAYERS; player++) /* draw if visible and the right screen */ if (global.visible[player] && - ((global.screen[player] == screen) || (global.screen[player] == CROSSHAIR_SCREEN_ALL))) + ((global.screen[player] == &screen) || (global.screen[player] == CROSSHAIR_SCREEN_ALL))) { /* add a quad assuming a 4:3 screen (this is not perfect) */ - render_screen_add_quad(screen, + render_screen_add_quad(&screen, global.x[player] - 0.03f, global.y[player] - 0.04f, global.x[player] + 0.03f, global.y[player] + 0.04f, MAKE_ARGB(0xc0, global.fade, global.fade, global.fade), @@ -412,7 +412,7 @@ void crosshair_render(running_device *screen) given player's crosshair -------------------------------------------------*/ -void crosshair_set_screen(running_machine *machine, int player, running_device *screen) +void crosshair_set_screen(running_machine *machine, int player, device_t *screen) { global.screen[player] = screen; } diff --git a/src/emu/crsshair.h b/src/emu/crsshair.h index af6cfa50440..92285c7f2db 100644 --- a/src/emu/crsshair.h +++ b/src/emu/crsshair.h @@ -19,8 +19,8 @@ CONSTANTS ***************************************************************************/ -#define CROSSHAIR_SCREEN_NONE ((running_device *) 0) -#define CROSSHAIR_SCREEN_ALL ((running_device *) ~0) +#define CROSSHAIR_SCREEN_NONE ((device_t *) 0) +#define CROSSHAIR_SCREEN_ALL ((device_t *) ~0) /* user settings for visibility mode */ #define CROSSHAIR_VISIBILITY_OFF 0 @@ -62,10 +62,10 @@ struct _crosshair_user_settings void crosshair_init(running_machine *machine); /* draws crosshair(s) in a given screen, if neccessary */ -void crosshair_render(running_device *screen); +void crosshair_render(screen_device &screen); /* sets the screen(s) for a given player's crosshair */ -void crosshair_set_screen(running_machine *machine, int player, running_device *screen); +void crosshair_set_screen(running_machine *machine, int player, device_t *screen); /* return TRUE if any crosshairs are used */ int crosshair_get_usage(running_machine *machine); diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index d53cac4321d..1998851f001 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -229,7 +229,6 @@ INLINE UINT64 cheat_read_extended(const cheat_system *cheatsys, const address_sp void debug_command_init(running_machine *machine) { symbol_table *symtable = debug_cpu_get_global_symtable(machine); - running_device *cpu; const char *name; int itemnum; @@ -366,14 +365,8 @@ void debug_command_init(running_machine *machine) debug_console_register_command(machine, "softreset", CMDFLAG_NONE, 0, 0, 1, execute_softreset); debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset); - /* ask all the CPUs if they would like to register functions or symbols */ - for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) - { - cpu_debug_init_func debug_init; - debug_init = (cpu_debug_init_func)cpu->get_config_fct(CPUINFO_FCT_DEBUG_INIT); - if (debug_init != NULL) - (*debug_init)(cpu); - } + /* ask all the devices if they would like to register functions or symbols */ + machine->devicelist.debug_setup_all(); add_exit_callback(machine, debug_command_exit); @@ -390,7 +383,7 @@ void debug_command_init(running_machine *machine) static void debug_command_exit(running_machine *machine) { - running_device *cpu; + device_t *cpu; /* turn off all traces */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) @@ -512,7 +505,7 @@ int debug_command_parameter_number(running_machine *machine, const char *param, parameter as a cpu -------------------------------------------------*/ -int debug_command_parameter_cpu(running_machine *machine, const char *param, running_device **result) +int debug_command_parameter_cpu(running_machine *machine, const char *param, device_t **result) { UINT64 cpunum; EXPRERR err; @@ -561,7 +554,7 @@ int debug_command_parameter_cpu(running_machine *machine, const char *param, run int debug_command_parameter_cpu_space(running_machine *machine, const char *param, int spacenum, const address_space **result) { - running_device *cpu; + device_t *cpu; /* first do the standard CPU thing */ if (!debug_command_parameter_cpu(machine, param, &cpu)) @@ -571,7 +564,7 @@ int debug_command_parameter_cpu_space(running_machine *machine, const char *para *result = cpu_get_address_space(cpu, spacenum); if (*result == NULL) { - debug_console_printf(machine, "No %s memory space found for CPU '%s'\n", address_space_names[spacenum], cpu->tag()); + debug_console_printf(machine, "No matching memory space found for CPU '%s'\n", cpu->tag()); return FALSE; } return TRUE; @@ -973,8 +966,8 @@ static void execute_next(running_machine *machine, int ref, int params, const ch static void execute_focus(running_machine *machine, int ref, int params, const char *param[]) { - running_device *scancpu; - running_device *cpu; + device_t *scancpu; + device_t *cpu; /* validate params */ if (!debug_command_parameter_cpu(machine, param[0], &cpu)) @@ -997,8 +990,8 @@ static void execute_focus(running_machine *machine, int ref, int params, const c static void execute_ignore(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpuwhich[MAX_COMMAND_PARAMS]; - running_device *cpu; + device_t *cpuwhich[MAX_COMMAND_PARAMS]; + device_t *cpu; int paramnum; char buffer[100]; int buflen = 0; @@ -1009,10 +1002,10 @@ static void execute_ignore(running_machine *machine, int ref, int params, const /* loop over all CPUs */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); /* build up a comma-separated list */ - if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) == 0) + if ((cpudebug->flags & DEBUG_FLAG_OBSERVING) == 0) { if (buflen == 0) buflen += sprintf(&buffer[buflen], "Currently ignoring CPU '%s'", cpu->tag()); @@ -1061,8 +1054,8 @@ static void execute_ignore(running_machine *machine, int ref, int params, const static void execute_observe(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpuwhich[MAX_COMMAND_PARAMS]; - running_device *cpu; + device_t *cpuwhich[MAX_COMMAND_PARAMS]; + device_t *cpu; int paramnum; char buffer[100]; int buflen = 0; @@ -1073,10 +1066,10 @@ static void execute_observe(running_machine *machine, int ref, int params, const /* loop over all CPUs */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); /* build up a comma-separated list */ - if ((cpuinfo->flags & DEBUG_FLAG_OBSERVING) != 0) + if ((cpudebug->flags & DEBUG_FLAG_OBSERVING) != 0) { if (buflen == 0) buflen += sprintf(&buffer[buflen], "Currently observing CPU '%s'", cpu->tag()); @@ -1115,7 +1108,7 @@ static void execute_observe(running_machine *machine, int ref, int params, const static void execute_comment(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpu; + device_t *cpu; UINT64 address; /* param 1 is the address for the comment */ @@ -1145,7 +1138,7 @@ static void execute_comment(running_machine *machine, int ref, int params, const static void execute_comment_del(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpu; + device_t *cpu; UINT64 address; /* param 1 can either be a command or the address for the comment */ @@ -1182,7 +1175,7 @@ static void execute_comment_save(running_machine *machine, int ref, int params, static void execute_bpset(running_machine *machine, int ref, int params, const char *param[]) { parsed_expression *condition = NULL; - running_device *cpu; + device_t *cpu; const char *action = NULL; UINT64 address; int bpnum; @@ -1221,13 +1214,13 @@ static void execute_bpclear(running_machine *machine, int ref, int params, const /* if 0 parameters, clear all */ if (params == 0) { - running_device *cpu; + device_t *cpu; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); debug_cpu_breakpoint *bp; - while ((bp = cpuinfo->bplist) != NULL) + while ((bp = cpudebug->bplist) != NULL) debug_cpu_breakpoint_clear(machine, bp->index); } debug_console_printf(machine, "Cleared all breakpoints\n"); @@ -1259,13 +1252,13 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c /* if 0 parameters, clear all */ if (params == 0) { - running_device *cpu; + device_t *cpu; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); debug_cpu_breakpoint *bp; - for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) + for (bp = cpudebug->bplist; bp != NULL; bp = bp->next) debug_cpu_breakpoint_enable(machine, bp->index, ref); } if (ref == 0) @@ -1295,24 +1288,24 @@ static void execute_bpdisenable(running_machine *machine, int ref, int params, c static void execute_bplist(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpu; + device_t *cpu; int printed = 0; char buffer[256]; /* loop over all CPUs */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); const address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); - if (cpuinfo->bplist != NULL) + if (cpudebug->bplist != NULL) { debug_cpu_breakpoint *bp; debug_console_printf(machine, "CPU '%s' breakpoints:\n", cpu->tag()); /* loop over the breakpoints */ - for (bp = cpuinfo->bplist; bp != NULL; bp = bp->next) + for (bp = cpudebug->bplist; bp != NULL; bp = bp->next) { int buflen; buflen = sprintf(buffer, "%c%4X @ %s", bp->enabled ? ' ' : 'D', bp->index, core_i64_hex_format(bp->address, space->logaddrchars)); @@ -1396,17 +1389,17 @@ static void execute_wpclear(running_machine *machine, int ref, int params, const /* if 0 parameters, clear all */ if (params == 0) { - running_device *cpu; + device_t *cpu; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); int spacenum; for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { debug_cpu_watchpoint *wp; - while ((wp = cpuinfo->wplist[spacenum]) != NULL) + while ((wp = cpudebug->wplist[spacenum]) != NULL) debug_cpu_watchpoint_clear(machine, wp->index); } } @@ -1439,17 +1432,17 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c /* if 0 parameters, clear all */ if (params == 0) { - running_device *cpu; + device_t *cpu; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); int spacenum; for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { debug_cpu_watchpoint *wp; - for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) + for (wp = cpudebug->wplist[spacenum]; wp != NULL; wp = wp->next) debug_cpu_watchpoint_enable(machine, wp->index, ref); } } @@ -1480,27 +1473,27 @@ static void execute_wpdisenable(running_machine *machine, int ref, int params, c static void execute_wplist(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpu; + device_t *cpu; int printed = 0; char buffer[256]; /* loop over all CPUs */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); int spacenum; for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - if (cpuinfo->wplist[spacenum] != NULL) + if (cpudebug->wplist[spacenum] != NULL) { static const char *const types[] = { "unkn ", "read ", "write", "r/w " }; const address_space *space = cpu_get_address_space(cpu, spacenum); debug_cpu_watchpoint *wp; - debug_console_printf(machine, "CPU '%s' %s space watchpoints:\n", cpu->tag(), address_space_names[spacenum]); + debug_console_printf(machine, "CPU '%s' %s space watchpoints:\n", cpu->tag(), space->name); /* loop over the watchpoints */ - for (wp = cpuinfo->wplist[spacenum]; wp != NULL; wp = wp->next) + for (wp = cpudebug->wplist[spacenum]; wp != NULL; wp = wp->next) { int buflen; buflen = sprintf(buffer, "%c%4X @ %s-%s %s", wp->enabled ? ' ' : 'D', wp->index, @@ -1529,7 +1522,7 @@ static void execute_wplist(running_machine *machine, int ref, int params, const static void execute_hotspot(running_machine *machine, int ref, int params, const char *param[]) { - running_device *cpu; + device_t *cpu; UINT64 threshhold; UINT64 count; @@ -1541,11 +1534,11 @@ static void execute_hotspot(running_machine *machine, int ref, int params, const /* loop over CPUs and find live spots */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - const cpu_debug_data *cpuinfo = cpu_get_debug_data(cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); - if (cpuinfo->hotspots != NULL) + if (cpudebug->hotspots != NULL) { - debug_cpu_hotspot_track(cpuinfo->device, 0, 0); + debug_cpu_hotspot_track(cpudebug->cpudevice, 0, 0); debug_console_printf(machine, "Cleared hotspot tracking on CPU '%s'\n", cpu->tag()); cleared = TRUE; } @@ -2055,7 +2048,7 @@ static void execute_cheatlist(running_machine *machine, int ref, int params, con { char spaceletter, sizeletter; const address_space *space; - running_device *cpu; + device_t *cpu; UINT32 active_cheat = 0; UINT64 cheatindex; UINT64 sizemask; @@ -2264,8 +2257,9 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch return; /* determine the width of the bytes */ - minbytes = cpu_get_min_opcode_bytes(space->cpu); - maxbytes = cpu_get_max_opcode_bytes(space->cpu); + cpu_device *cpudevice = downcast(space->cpu); + minbytes = cpudevice->min_opcode_bytes(); + maxbytes = cpudevice->max_opcode_bytes(); byteswidth = 0; if (bytes) { @@ -2362,7 +2356,7 @@ static void execute_dasm(running_machine *machine, int ref, int params, const ch static void execute_trace_internal(running_machine *machine, int ref, int params, const char *param[], int trace_over) { const char *action = NULL, *filename = param[0]; - running_device *cpu; + device_t *cpu; FILE *f = NULL; const char *mode; @@ -2442,7 +2436,7 @@ static void execute_traceflush(running_machine *machine, int ref, int params, co static void execute_history(running_machine *machine, int ref, int params, const char *param[]) { UINT64 count = DEBUG_HISTORY_SIZE; - const cpu_debug_data *cpuinfo; + const cpu_debug_data *cpudebug; const address_space *space; int i; @@ -2456,13 +2450,14 @@ static void execute_history(running_machine *machine, int ref, int params, const if (count > DEBUG_HISTORY_SIZE) count = DEBUG_HISTORY_SIZE; - cpuinfo = cpu_get_debug_data(space->cpu); + cpu_device *cpudevice = downcast(space->cpu); + cpudebug = cpu_get_debug_data(space->cpu); /* loop over lines */ for (i = 0; i < count; i++) { - offs_t pc = cpuinfo->pc_history[(cpuinfo->pc_history_index + DEBUG_HISTORY_SIZE - count + i) % DEBUG_HISTORY_SIZE]; - int maxbytes = cpu_get_max_opcode_bytes(space->cpu); + offs_t pc = cpudebug->pc_history[(cpudebug->pc_history_index + DEBUG_HISTORY_SIZE - count + i) % DEBUG_HISTORY_SIZE]; + int maxbytes = cpudevice->max_opcode_bytes(); UINT8 opbuf[64], argbuf[64]; char buffer[200]; offs_t pcbyte; @@ -2504,7 +2499,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch const char *filename = param[0]; int scrnum = (params > 1) ? atoi(param[1]) : 0; - running_device *screen = machine->devicelist.find(VIDEO_SCREEN, scrnum); + device_t *screen = machine->devicelist.find(SCREEN, scrnum); if ((screen == NULL) || !render_is_live_screen(screen)) { @@ -2523,7 +2518,7 @@ static void execute_snap(running_machine *machine, int ref, int params, const ch return; } - video_screen_save_snapshot(screen->machine, screen, fp); + screen_save_snapshot(screen->machine, screen, fp); mame_fclose(fp); debug_console_printf(machine, "Saved screen #%d snapshot as '%s'\n", scrnum, filename); } @@ -2610,7 +2605,7 @@ static int CLIB_DECL symbol_sort_compare(const void *item1, const void *item2) static void execute_symlist(running_machine *machine, int ref, int params, const char **param) { - running_device *cpu = NULL; + device_t *cpu = NULL; const char *namelist[1000]; symbol_table *symtable; int symnum, count = 0; diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index 99340fe452a..6a68dfd96b6 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -30,7 +30,7 @@ void debug_command_init(running_machine *machine); int debug_command_parameter_number(running_machine *machine, const char *param, UINT64 *result); /* validates a parameter as a cpu */ -int debug_command_parameter_cpu(running_machine *machine, const char *param, running_device **result); +int debug_command_parameter_cpu(running_machine *machine, const char *param, device_t **result); /* validates a parameter as a cpu and retrieves the given address space */ int debug_command_parameter_cpu_space(running_machine *machine, const char *param, int spacenum, const address_space **result); diff --git a/src/emu/debug/debugcmt.c b/src/emu/debug/debugcmt.c index 950fbcd36e5..69c0c8671e4 100644 --- a/src/emu/debug/debugcmt.c +++ b/src/emu/debug/debugcmt.c @@ -93,7 +93,7 @@ static void debug_comment_exit(running_machine *machine); int debug_comment_init(running_machine *machine) { - running_device *cpu; + device_t *cpu; /* allocate memory for the comments */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) @@ -115,7 +115,7 @@ int debug_comment_init(running_machine *machine) the proper crc32 -------------------------------------------------------------------------*/ -int debug_comment_add(running_device *device, offs_t addr, const char *comment, rgb_t color, UINT32 c_crc) +int debug_comment_add(device_t *device, offs_t addr, const char *comment, rgb_t color, UINT32 c_crc) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int insert_point = comments->comment_count; @@ -182,7 +182,7 @@ int debug_comment_add(running_device *device, offs_t addr, const char *comment, the proper crc32 -------------------------------------------------------------------------*/ -int debug_comment_remove(running_device *device, offs_t addr, UINT32 c_crc) +int debug_comment_remove(device_t *device, offs_t addr, UINT32 c_crc) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int remove_index = -1; @@ -219,7 +219,7 @@ int debug_comment_remove(running_device *device, offs_t addr, UINT32 c_crc) the proper crc32 -------------------------------------------------------------------------*/ -const char *debug_comment_get_text(running_device *device, offs_t addr, UINT32 c_crc) +const char *debug_comment_get_text(device_t *device, offs_t addr, UINT32 c_crc) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int i; @@ -242,7 +242,7 @@ const char *debug_comment_get_text(running_device *device, offs_t addr, UINT32 c for a given cpu number -------------------------------------------------------------------------*/ -int debug_comment_get_count(running_device *device) +int debug_comment_get_count(device_t *device) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; return comments->comment_count; @@ -254,7 +254,7 @@ int debug_comment_get_count(running_device *device) for a given cpu number -------------------------------------------------------------------------*/ -UINT32 debug_comment_get_change_count(running_device *device) +UINT32 debug_comment_get_change_count(device_t *device) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; return comments->change_count; @@ -267,7 +267,7 @@ UINT32 debug_comment_get_change_count(running_device *device) UINT32 debug_comment_all_change_count(running_machine *machine) { - running_device *cpu; + device_t *cpu; UINT32 retVal = 0; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) @@ -285,7 +285,7 @@ UINT32 debug_comment_all_change_count(running_machine *machine) for the opcode at the requested address. -------------------------------------------------------------------------*/ -UINT32 debug_comment_get_opcode_crc32(running_device *device, offs_t address) +UINT32 debug_comment_get_opcode_crc32(device_t *device, offs_t address) { const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM); int i; @@ -293,7 +293,8 @@ UINT32 debug_comment_get_opcode_crc32(running_device *device, offs_t address) UINT8 opbuf[64], argbuf[64]; char buff[256]; offs_t numbytes; - int maxbytes = cpu_get_max_opcode_bytes(device); + cpu_device *cpudevice = downcast(device); + int maxbytes = cpudevice->max_opcode_bytes(); UINT32 addrmask = space->logaddrmask; memset(opbuf, 0x00, sizeof(opbuf)); @@ -319,7 +320,7 @@ UINT32 debug_comment_get_opcode_crc32(running_device *device, offs_t address) debug_comment_dump - debugging function to dump junk to the command line -------------------------------------------------------------------------*/ -void debug_comment_dump(running_device *device, offs_t addr) +void debug_comment_dump(device_t *device, offs_t addr) { debug_cpu_comment_group *comments = cpu_get_debug_data(device)->comments; int i; @@ -367,7 +368,7 @@ int debug_comment_save(running_machine *machine) xml_data_node *root = xml_file_create(); xml_data_node *commentnode, *systemnode; int total_comments = 0; - running_device *cpu; + device_t *cpu; /* if we don't have a root, bail */ if (root == NULL) @@ -483,7 +484,7 @@ static int debug_comment_load_xml(running_machine *machine, mame_file *fp) for (cpunode = xml_get_sibling(systemnode->child, "cpu"); cpunode; cpunode = xml_get_sibling(cpunode->next, "cpu")) { - running_device *cpu = machine->device(xml_get_attribute_string(cpunode, "tag", "")); + device_t *cpu = machine->device(xml_get_attribute_string(cpunode, "tag", "")); if (cpu != NULL) { debug_cpu_comment_group *comments = cpu_get_debug_data(cpu)->comments; diff --git a/src/emu/debug/debugcmt.h b/src/emu/debug/debugcmt.h index c136fdce7a4..1e3e63e1ae0 100644 --- a/src/emu/debug/debugcmt.h +++ b/src/emu/debug/debugcmt.h @@ -25,16 +25,16 @@ int debug_comment_save(running_machine *machine); int debug_comment_load(running_machine *machine); /* comment interface functions */ -int debug_comment_add(running_device *device, offs_t addr, const char *comment, rgb_t color, UINT32 c_crc); -int debug_comment_remove(running_device *device, offs_t addr, UINT32 c_crc); +int debug_comment_add(device_t *device, offs_t addr, const char *comment, rgb_t color, UINT32 c_crc); +int debug_comment_remove(device_t *device, offs_t addr, UINT32 c_crc); -const char *debug_comment_get_text(running_device *device, offs_t addr, UINT32 c_crc); -int debug_comment_get_count(running_device *device); -UINT32 debug_comment_get_change_count(running_device *device); +const char *debug_comment_get_text(device_t *device, offs_t addr, UINT32 c_crc); +int debug_comment_get_count(device_t *device); +UINT32 debug_comment_get_change_count(device_t *device); UINT32 debug_comment_all_change_count(running_machine *machine); /* local functionality */ -UINT32 debug_comment_get_opcode_crc32(running_device *device, offs_t address); /* pull a crc for the opcode at a given address */ -void debug_comment_dump(running_device *device, offs_t addr); /* dump all (or a single) comment to the command line */ +UINT32 debug_comment_get_opcode_crc32(device_t *device, offs_t address); /* pull a crc for the opcode at a given address */ +void debug_comment_dump(device_t *device, offs_t addr); /* dump all (or a single) comment to the command line */ #endif diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index aa57387dc1b..0622cd55bfc 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -51,9 +51,9 @@ enum /* in mame.h: typedef struct _debugcpu_private debugcpu_private; */ struct _debugcpu_private { - running_device *livecpu; - running_device *visiblecpu; - running_device *breakcpu; + device_t *livecpu; + device_t *visiblecpu; + device_t *breakcpu; FILE * source_file; /* script source file */ @@ -84,18 +84,18 @@ struct _debugcpu_private /* internal helpers */ static void debug_cpu_exit(running_machine *machine); -static void on_vblank(running_device *device, void *param, int vblank_state); +static void on_vblank(screen_device &device, void *param, bool vblank_state); static void reset_transient_flags(running_machine *machine); -static void compute_debug_flags(running_device *device); -static void perform_trace(cpu_debug_data *info); -static void prepare_for_step_overout(cpu_debug_data *info); +static void compute_debug_flags(device_t *device); +static void perform_trace(cpu_debug_data *cpudebug); +static void prepare_for_step_overout(cpu_debug_data *cpudebug); static void process_source_file(running_machine *machine); -static void breakpoint_update_flags(cpu_debug_data *info); -static void breakpoint_check(running_machine *machine, cpu_debug_data *info, offs_t pc); +static void breakpoint_update_flags(cpu_debug_data *cpudebug); +static void breakpoint_check(running_machine *machine, cpu_debug_data *cpudebug, offs_t pc); static void watchpoint_update_flags(const address_space *space); static void watchpoint_check(const address_space *space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask); static void check_hotspots(const address_space *space, offs_t address); -static UINT32 dasm_wrapped(running_device *device, char *buffer, offs_t pc); +static UINT32 dasm_wrapped(device_t *device, char *buffer, offs_t pc); /* expression handlers */ static UINT64 expression_read_memory(void *param, const char *name, int space, UINT32 address, int size); @@ -148,9 +148,8 @@ const express_callbacks debug_expression_callbacks = void debug_cpu_init(running_machine *machine) { - running_device *first_screen = video_screen_first(machine); + screen_device *first_screen = screen_first(*machine); debugcpu_private *global; - running_device *cpu; int regnum; /* allocate and reset globals */ @@ -178,70 +177,42 @@ void debug_cpu_init(running_machine *machine) symtable_add_register(global->symtable, symname, &global->tempvar[regnum], get_tempvar, set_tempvar); } - /* loop over CPUs and build up their info */ - for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + /* loop over CPUs and build up their cpudebug */ + for (cpu_device *device = downcast(machine->firstcpu); device != NULL; device = downcast(cpu_next(device))) { - cpu_class_header *classheader = cpu_get_class_header(cpu); - cpu_debug_data *info; - /* allocate some information */ - info = auto_alloc_clear(machine, cpu_debug_data); - classheader->debug = info; + cpu_debug_data *cpudebug = auto_alloc_clear(machine, cpu_debug_data); + device->m_debug = cpudebug; /* reset the PC data */ - info->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; - info->device = cpu; - info->opwidth = cpu_get_min_opcode_bytes(info->device); - - /* fetch the memory accessors */ - info->read = (cpu_read_func)info->device->get_config_fct(CPUINFO_FCT_READ); - info->write = (cpu_write_func)info->device->get_config_fct(CPUINFO_FCT_WRITE); - info->readop = (cpu_readop_func)info->device->get_config_fct(CPUINFO_FCT_READOP); - info->translate = (cpu_translate_func)info->device->get_config_fct(CPUINFO_FCT_TRANSLATE); - info->disassemble = (cpu_disassemble_func)info->device->get_config_fct(CPUINFO_FCT_DISASSEMBLE); + cpudebug->flags = DEBUG_FLAG_OBSERVING | DEBUG_FLAG_HISTORY; + cpudebug->cpudevice = device; + cpudebug->opwidth = device->min_opcode_bytes(); /* allocate a symbol table */ - info->symtable = symtable_alloc(global->symtable, (void *)cpu); + cpudebug->symtable = symtable_alloc(global->symtable, (void *)device); /* add a global symbol for the current instruction pointer */ - symtable_add_register(info->symtable, "cycles", NULL, get_cycles, NULL); - if (cpu->space(AS_PROGRAM) != NULL) - symtable_add_register(info->symtable, "logunmap", (void *)cpu->space(AS_PROGRAM), get_logunmap, set_logunmap); - if (cpu->space(AS_DATA) != NULL) - symtable_add_register(info->symtable, "logunmapd", (void *)cpu->space(AS_DATA), get_logunmap, set_logunmap); - if (cpu->space(AS_IO) != NULL) - symtable_add_register(info->symtable, "logunmapi", (void *)cpu->space(AS_IO), get_logunmap, set_logunmap); + symtable_add_register(cpudebug->symtable, "cycles", NULL, get_cycles, NULL); + if (device->space(AS_PROGRAM) != NULL) + symtable_add_register(cpudebug->symtable, "logunmap", (void *)device->space(AS_PROGRAM), get_logunmap, set_logunmap); + if (device->space(AS_DATA) != NULL) + symtable_add_register(cpudebug->symtable, "logunmapd", (void *)device->space(AS_DATA), get_logunmap, set_logunmap); + if (device->space(AS_IO) != NULL) + symtable_add_register(cpudebug->symtable, "logunmapi", (void *)device->space(AS_IO), get_logunmap, set_logunmap); /* add all registers into it */ - for (regnum = 0; regnum < MAX_REGS; regnum++) + device_state_interface *stateintf; + if (device->interface(stateintf)) { - const char *str = cpu_get_reg_string(info->device, regnum); - const char *colon; - char symname[256]; - int charnum; - - /* skip if we don't get a valid string, or one without a colon */ - if (str == NULL) - continue; - if (str[0] == '~') - str++; - colon = strchr(str, ':'); - if (colon == NULL) - continue; - - /* strip all spaces from the name and convert to lowercase */ - for (charnum = 0; charnum < sizeof(symname) - 1 && str < colon; str++) - if (!isspace((UINT8)*str)) - symname[charnum++] = tolower((UINT8)*str); - symname[charnum] = 0; - - /* add the symbol to the table */ - symtable_add_register(info->symtable, symname, (void *)(FPTR)regnum, get_cpu_reg, set_cpu_reg); + astring tempstr; + for (const device_state_entry *entry = stateintf->state_first(); entry != NULL; entry = entry->next()) + symtable_add_register(cpudebug->symtable, tempstr.cpy(entry->symbol()).tolower(), (void *)(FPTR)entry->index(), get_cpu_reg, set_cpu_reg); } /* if no curpc, add one */ - if (symtable_find(info->symtable, "curpc") == NULL) - symtable_add_register(info->symtable, "curpc", NULL, get_current_pc, 0); + if (symtable_find(cpudebug->symtable, "curpc") == NULL) + symtable_add_register(cpudebug->symtable, "curpc", NULL, get_current_pc, 0); } /* first CPU is visible by default */ @@ -249,7 +220,7 @@ void debug_cpu_init(running_machine *machine) /* add callback for breaking on VBLANK */ if (machine->primary_screen != NULL) - video_screen_register_vblank_callback(machine->primary_screen, on_vblank, NULL); + machine->primary_screen->register_vblank_callback(on_vblank, NULL); add_exit_callback(machine, debug_cpu_exit); } @@ -263,16 +234,16 @@ void debug_cpu_init(running_machine *machine) void debug_cpu_flush_traces(running_machine *machine) { - running_device *cpu; + device_t *cpu; for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); /* this can be called on exit even when no debugging is enabled, so - make sure the info is valid before proceeding */ - if (info != NULL && info->trace.file != NULL) - fflush(info->trace.file); + make sure the cpudebug is valid before proceeding */ + if (cpudebug != NULL && cpudebug->trace.file != NULL) + fflush(cpudebug->trace.file); } } @@ -287,7 +258,7 @@ void debug_cpu_flush_traces(running_machine *machine) device (the one that commands should apply to) -------------------------------------------------*/ -running_device *debug_cpu_get_visible_cpu(running_machine *machine) +device_t *debug_cpu_get_visible_cpu(running_machine *machine) { return machine->debugcpu_data->visiblecpu; } @@ -348,7 +319,7 @@ symbol_table *debug_cpu_get_visible_symtable(running_machine *machine) CPU's symbol table -------------------------------------------------*/ -symbol_table *debug_cpu_get_symtable(running_device *device) +symbol_table *debug_cpu_get_symtable(device_t *device) { return cpu_get_debug_data(device)->symtable; } @@ -367,11 +338,10 @@ symbol_table *debug_cpu_get_symtable(running_device *device) int debug_cpu_translate(const address_space *space, int intention, offs_t *address) { - if (space->cpu != NULL && space->cpu->type == CPU) + if (space->cpu != NULL && space->cpu->type() == CPU) { - cpu_debug_data *info = cpu_get_debug_data(space->cpu); - if (info->translate != NULL) - return (*info->translate)(space->cpu, space->spacenum, intention, address); + cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); + return cpudebug->cpudevice->translate(space->spacenum, intention, *address); } return TRUE; } @@ -382,52 +352,27 @@ int debug_cpu_translate(const address_space *space, int intention, offs_t *addre a given PC on a given CPU -------------------------------------------------*/ -offs_t debug_cpu_disassemble(running_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) +offs_t debug_cpu_disassemble(device_t *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) { - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); offs_t result = 0; /* check for disassembler override */ - if (info->dasm_override != NULL) - result = (*info->dasm_override)(device, buffer, pc, oprom, opram, 0); + if (cpudebug->dasm_override != NULL) + result = (*cpudebug->dasm_override)(device, buffer, pc, oprom, opram, 0); /* if we have a disassembler, run it */ - if (result == 0 && info->disassemble != NULL) - result = (*info->disassemble)(device, buffer, pc, oprom, opram, 0); - - /* if we still have nothing, output vanilla bytes */ if (result == 0) - { - result = cpu_get_min_opcode_bytes(device); - switch (result) - { - case 1: - default: - sprintf(buffer, "$%02X", *(UINT8 *)oprom); - break; - - case 2: - sprintf(buffer, "$%04X", *(UINT16 *)oprom); - break; - - case 4: - sprintf(buffer, "$%08X", *(UINT32 *)oprom); - break; - - case 8: - sprintf(buffer, "$%08X%08X", (UINT32)(*(UINT64 *)oprom >> 32), (UINT32)(*(UINT64 *)oprom >> 0)); - break; - } - } + result = cpudebug->cpudevice->disassemble(buffer, pc, oprom, opram, 0); /* make sure we get good results */ assert((result & DASMFLAG_LENGTHMASK) != 0); #ifdef MAME_DEBUG { - const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM); + const address_space *space = device_memory(device)->space(AS_PROGRAM); int bytes = memory_address_to_byte(space, result & DASMFLAG_LENGTHMASK); - assert(bytes >= cpu_get_min_opcode_bytes(device)); - assert(bytes <= cpu_get_max_opcode_bytes(device)); + assert(bytes >= cpudebug->cpudevice->min_opcode_bytes()); + assert(bytes <= cpudebug->cpudevice->max_opcode_bytes()); (void) bytes; /* appease compiler */ } #endif @@ -441,11 +386,11 @@ offs_t debug_cpu_disassemble(running_device *device, char *buffer, offs_t pc, co handler for disassembly -------------------------------------------------*/ -void debug_cpu_set_dasm_override(running_device *device, cpu_disassemble_func dasm_override) +void debug_cpu_set_dasm_override(device_t *device, cpu_disassemble_func dasm_override) { - cpu_debug_data *info = cpu_get_debug_data(device); - if (info != NULL) - info->dasm_override = dasm_override; + cpu_debug_data *cpudebug = cpu_get_debug_data(device); + if (cpudebug != NULL) + cpudebug->dasm_override = dasm_override; } @@ -460,10 +405,10 @@ void debug_cpu_set_dasm_override(running_device *device, cpu_disassemble_func da execution for the given CPU -------------------------------------------------*/ -void debug_cpu_start_hook(running_device *device, attotime endtime) +void debug_cpu_start_hook(device_t *device, attotime endtime) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); assert((device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0); @@ -472,7 +417,7 @@ void debug_cpu_start_hook(running_device *device, attotime endtime) global->livecpu = device; /* update the target execution end time */ - info->endexectime = endtime; + cpudebug->endexectime = endtime; /* if we're running, do some periodic updating */ if (global->execution_state != EXECUTION_STATE_STOPPED) @@ -498,7 +443,7 @@ void debug_cpu_start_hook(running_device *device, attotime endtime) global->vblank_occurred = FALSE; /* if we were waiting for a VBLANK, signal it now */ - if ((info->flags & DEBUG_FLAG_STOP_VBLANK) != 0) + if ((cpudebug->flags & DEBUG_FLAG_STOP_VBLANK) != 0) { global->execution_state = EXECUTION_STATE_STOPPED; debug_console_printf(device->machine, "Stopped at VBLANK\n"); @@ -521,15 +466,15 @@ void debug_cpu_start_hook(running_device *device, attotime endtime) for the given CPU -------------------------------------------------*/ -void debug_cpu_stop_hook(running_device *device) +void debug_cpu_stop_hook(device_t *device) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); assert(global->livecpu == device); /* if we're stopping on a context switch, handle it now */ - if (info->flags & DEBUG_FLAG_STOP_CONTEXT) + if (cpudebug->flags & DEBUG_FLAG_STOP_CONTEXT) { global->execution_state = EXECUTION_STATE_STOPPED; reset_transient_flags(device->machine); @@ -545,13 +490,13 @@ void debug_cpu_stop_hook(running_device *device) interrupt is acknowledged -------------------------------------------------*/ -void debug_cpu_interrupt_hook(running_device *device, int irqline) +void debug_cpu_interrupt_hook(device_t *device, int irqline) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); /* see if this matches a pending interrupt request */ - if (info != NULL && (info->flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (info->stopirq == -1 || info->stopirq == irqline)) + if (cpudebug != NULL && (cpudebug->flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (cpudebug->stopirq == -1 || cpudebug->stopirq == irqline)) { global->execution_state = EXECUTION_STATE_STOPPED; debug_console_printf(device->machine, "Stopped on interrupt (CPU '%s', IRQ %d)\n", device->tag(), irqline); @@ -565,13 +510,13 @@ void debug_cpu_interrupt_hook(running_device *device, int irqline) exception is generated -------------------------------------------------*/ -void debug_cpu_exception_hook(running_device *device, int exception) +void debug_cpu_exception_hook(device_t *device, int exception) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); /* see if this matches a pending interrupt request */ - if ((info->flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (info->stopexception == -1 || info->stopexception == exception)) + if ((cpudebug->flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (cpudebug->stopexception == -1 || cpudebug->stopexception == exception)) { global->execution_state = EXECUTION_STATE_STOPPED; debug_console_printf(device->machine, "Stopped on exception (CPU '%s', exception %d)\n", device->tag(), exception); @@ -585,41 +530,41 @@ void debug_cpu_exception_hook(running_device *device, int exception) CPU cores before executing each instruction -------------------------------------------------*/ -void debug_cpu_instruction_hook(running_device *device, offs_t curpc) +void debug_cpu_instruction_hook(device_t *device, offs_t curpc) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); /* note that we are in the debugger code */ global->within_instruction_hook = TRUE; /* update the history */ - info->pc_history[info->pc_history_index++ % DEBUG_HISTORY_SIZE] = curpc; + cpudebug->pc_history[cpudebug->pc_history_index++ % DEBUG_HISTORY_SIZE] = curpc; /* are we tracing? */ - if (info->flags & DEBUG_FLAG_TRACING_ANY) - perform_trace(info); + if (cpudebug->flags & DEBUG_FLAG_TRACING_ANY) + perform_trace(cpudebug); /* per-instruction hook? */ - if (global->execution_state != EXECUTION_STATE_STOPPED && (info->flags & DEBUG_FLAG_HOOKED) != 0 && (*info->instrhook)(device, curpc)) + if (global->execution_state != EXECUTION_STATE_STOPPED && (cpudebug->flags & DEBUG_FLAG_HOOKED) != 0 && (*cpudebug->instrhook)(device, curpc)) global->execution_state = EXECUTION_STATE_STOPPED; /* handle single stepping */ - if (global->execution_state != EXECUTION_STATE_STOPPED && (info->flags & DEBUG_FLAG_STEPPING_ANY) != 0) + if (global->execution_state != EXECUTION_STATE_STOPPED && (cpudebug->flags & DEBUG_FLAG_STEPPING_ANY) != 0) { /* is this an actual step? */ - if (info->stepaddr == ~0 || curpc == info->stepaddr) + if (cpudebug->stepaddr == ~0 || curpc == cpudebug->stepaddr) { /* decrement the count and reset the breakpoint */ - info->stepsleft--; - info->stepaddr = ~0; + cpudebug->stepsleft--; + cpudebug->stepaddr = ~0; /* if we hit 0, stop */ - if (info->stepsleft == 0) + if (cpudebug->stepsleft == 0) global->execution_state = EXECUTION_STATE_STOPPED; /* update every 100 steps until we are within 200 of the end */ - else if ((info->flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (info->stepsleft < 200 || info->stepsleft % 100 == 0)) + else if ((cpudebug->flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (cpudebug->stepsleft < 200 || cpudebug->stepsleft % 100 == 0)) { debug_view_update_all(device->machine); debug_view_flush_updates(device->machine); @@ -629,25 +574,25 @@ void debug_cpu_instruction_hook(running_device *device, offs_t curpc) } /* handle breakpoints */ - if (global->execution_state != EXECUTION_STATE_STOPPED && (info->flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) + if (global->execution_state != EXECUTION_STATE_STOPPED && (cpudebug->flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) { /* see if we hit a target time */ - if ((info->flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(device->machine), info->stoptime) >= 0) + if ((cpudebug->flags & DEBUG_FLAG_STOP_TIME) != 0 && attotime_compare(timer_get_time(device->machine), cpudebug->stoptime) >= 0) { debug_console_printf(device->machine, "Stopped at time interval %.1g\n", attotime_to_double(timer_get_time(device->machine))); global->execution_state = EXECUTION_STATE_STOPPED; } /* check the temp running breakpoint and break if we hit it */ - else if ((info->flags & DEBUG_FLAG_STOP_PC) != 0 && info->stopaddr == curpc) + else if ((cpudebug->flags & DEBUG_FLAG_STOP_PC) != 0 && cpudebug->stopaddr == curpc) { - debug_console_printf(device->machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", info->stopaddr, device->tag()); + debug_console_printf(device->machine, "Stopped at temporary breakpoint %X on CPU '%s'\n", cpudebug->stopaddr, device->tag()); global->execution_state = EXECUTION_STATE_STOPPED; } /* check for execution breakpoints */ - else if ((info->flags & DEBUG_FLAG_LIVE_BP) != 0) - breakpoint_check(device->machine, info, curpc); + else if ((cpudebug->flags & DEBUG_FLAG_LIVE_BP) != 0) + breakpoint_check(device->machine, cpudebug, curpc); } /* if we are supposed to halt, do it now */ @@ -702,8 +647,8 @@ void debug_cpu_instruction_hook(running_device *device, offs_t curpc) } /* handle step out/over on the instruction we are about to execute */ - if ((info->flags & (DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT)) != 0 && info->stepaddr == ~0) - prepare_for_step_overout(info); + if ((cpudebug->flags & (DEBUG_FLAG_STEPPING_OVER | DEBUG_FLAG_STEPPING_OUT)) != 0 && cpudebug->stepaddr == ~0) + prepare_for_step_overout(cpudebug); /* no longer in debugger code */ global->within_instruction_hook = FALSE; @@ -718,13 +663,13 @@ void debug_cpu_instruction_hook(running_device *device, offs_t curpc) void debug_cpu_memory_read_hook(const address_space *space, offs_t address, UINT64 mem_mask) { - cpu_debug_data *info = cpu_get_debug_data(space->cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); /* check watchpoints */ watchpoint_check(space, WATCHPOINT_READ, address, 0, mem_mask); /* check hotspots */ - if (info->hotspots != NULL) + if (cpudebug->hotspots != NULL) check_hotspots(space, address); } @@ -751,14 +696,14 @@ void debug_cpu_memory_write_hook(const address_space *space, offs_t address, UIN the debugger on the next instruction -------------------------------------------------*/ -void debug_cpu_halt_on_next_instruction(running_device *device, const char *fmt, ...) +void debug_cpu_halt_on_next_instruction(device_t *device, const char *fmt, ...) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); va_list arg; /* if something is pending on this CPU already, ignore this request */ - if (info != NULL && device == global->breakcpu) + if (cpudebug != NULL && device == global->breakcpu) return; /* output the message to the console */ @@ -783,15 +728,15 @@ void debug_cpu_halt_on_next_instruction(running_device *device, const char *fmt, CPU -------------------------------------------------*/ -void debug_cpu_ignore_cpu(running_device *device, int ignore) +void debug_cpu_ignore_cpu(device_t *device, int ignore) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); if (ignore) - info->flags &= ~DEBUG_FLAG_OBSERVING; + cpudebug->flags &= ~DEBUG_FLAG_OBSERVING; else - info->flags |= DEBUG_FLAG_OBSERVING; + cpudebug->flags |= DEBUG_FLAG_OBSERVING; if (device == global->livecpu && ignore) debug_cpu_next_cpu(device->machine); @@ -806,13 +751,13 @@ void debug_cpu_ignore_cpu(running_device *device, int ignore) void debug_cpu_single_step(running_machine *machine, int numsteps) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stepsleft = numsteps; - info->stepaddr = ~0; - info->flags |= DEBUG_FLAG_STEPPING; + cpudebug->stepsleft = numsteps; + cpudebug->stepaddr = ~0; + cpudebug->flags |= DEBUG_FLAG_STEPPING; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -826,13 +771,13 @@ void debug_cpu_single_step(running_machine *machine, int numsteps) void debug_cpu_single_step_over(running_machine *machine, int numsteps) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stepsleft = numsteps; - info->stepaddr = ~0; - info->flags |= DEBUG_FLAG_STEPPING_OVER; + cpudebug->stepsleft = numsteps; + cpudebug->stepaddr = ~0; + cpudebug->flags |= DEBUG_FLAG_STEPPING_OVER; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -845,13 +790,13 @@ void debug_cpu_single_step_over(running_machine *machine, int numsteps) void debug_cpu_single_step_out(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stepsleft = 100; - info->stepaddr = ~0; - info->flags |= DEBUG_FLAG_STEPPING_OUT; + cpudebug->stepsleft = 100; + cpudebug->stepaddr = ~0; + cpudebug->flags |= DEBUG_FLAG_STEPPING_OUT; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -864,12 +809,12 @@ void debug_cpu_single_step_out(running_machine *machine) void debug_cpu_go(running_machine *machine, offs_t targetpc) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stopaddr = targetpc; - info->flags |= DEBUG_FLAG_STOP_PC; + cpudebug->stopaddr = targetpc; + cpudebug->flags |= DEBUG_FLAG_STOP_PC; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -882,12 +827,12 @@ void debug_cpu_go(running_machine *machine, offs_t targetpc) void debug_cpu_go_vblank(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); global->vblank_occurred = FALSE; - info->flags |= DEBUG_FLAG_STOP_VBLANK; + cpudebug->flags |= DEBUG_FLAG_STOP_VBLANK; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -900,12 +845,12 @@ void debug_cpu_go_vblank(running_machine *machine) void debug_cpu_go_interrupt(running_machine *machine, int irqline) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stopirq = irqline; - info->flags |= DEBUG_FLAG_STOP_INTERRUPT; + cpudebug->stopirq = irqline; + cpudebug->flags |= DEBUG_FLAG_STOP_INTERRUPT; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -918,12 +863,12 @@ void debug_cpu_go_interrupt(running_machine *machine, int irqline) void debug_cpu_go_exception(running_machine *machine, int exception) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stopexception = exception; - info->flags |= DEBUG_FLAG_STOP_EXCEPTION; + cpudebug->stopexception = exception; + cpudebug->flags |= DEBUG_FLAG_STOP_EXCEPTION; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -936,12 +881,12 @@ void debug_cpu_go_exception(running_machine *machine, int exception) void debug_cpu_go_milliseconds(running_machine *machine, UINT64 milliseconds) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->stoptime = attotime_add(timer_get_time(machine), ATTOTIME_IN_MSEC(milliseconds)); - info->flags |= DEBUG_FLAG_STOP_TIME; + cpudebug->stoptime = attotime_add(timer_get_time(machine), ATTOTIME_IN_MSEC(milliseconds)); + cpudebug->flags |= DEBUG_FLAG_STOP_TIME; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -954,11 +899,11 @@ void debug_cpu_go_milliseconds(running_machine *machine, UINT64 milliseconds) void debug_cpu_next_cpu(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(global->visiblecpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(global->visiblecpu); - assert(info != NULL); + assert(cpudebug != NULL); - info->flags |= DEBUG_FLAG_STOP_CONTEXT; + cpudebug->flags |= DEBUG_FLAG_STOP_CONTEXT; global->execution_state = EXECUTION_STATE_RUNNING; } @@ -973,10 +918,10 @@ void debug_cpu_next_cpu(running_machine *machine) breakpoint, returning its index -------------------------------------------------*/ -int debug_cpu_breakpoint_set(running_device *device, offs_t address, parsed_expression *condition, const char *action) +int debug_cpu_breakpoint_set(device_t *device, offs_t address, parsed_expression *condition, const char *action) { debugcpu_private *global = device->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); debug_cpu_breakpoint *bp; assert_always(device != NULL, "debug_cpu_breakpoint_set() called with invalid cpu!"); @@ -995,11 +940,11 @@ int debug_cpu_breakpoint_set(running_device *device, offs_t address, parsed_expr } /* hook us in */ - bp->next = info->bplist; - info->bplist = bp; + bp->next = cpudebug->bplist; + cpudebug->bplist = bp; /* ensure the live breakpoint flag is set */ - breakpoint_update_flags(info); + breakpoint_update_flags(cpudebug); return bp->index; } @@ -1012,18 +957,18 @@ int debug_cpu_breakpoint_set(running_device *device, offs_t address, parsed_expr int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) { debug_cpu_breakpoint *bp, *pbp; - running_device *cpu; + device_t *cpu; /* loop over CPUs and find the requested breakpoint */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); - for (pbp = NULL, bp = info->bplist; bp != NULL; pbp = bp, bp = bp->next) + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); + for (pbp = NULL, bp = cpudebug->bplist; bp != NULL; pbp = bp, bp = bp->next) if (bp->index == bpnum) { /* unlink us from the list */ if (pbp == NULL) - info->bplist = bp->next; + cpudebug->bplist = bp->next; else pbp->next = bp->next; @@ -1035,7 +980,7 @@ int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) auto_free(machine, bp); /* update the flags */ - breakpoint_update_flags(info); + breakpoint_update_flags(cpudebug); return TRUE; } } @@ -1053,17 +998,17 @@ int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum) int debug_cpu_breakpoint_enable(running_machine *machine, int bpnum, int enable) { debug_cpu_breakpoint *bp; - running_device *cpu; + device_t *cpu; /* loop over CPUs and find the requested breakpoint */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); - for (bp = info->bplist; bp != NULL; bp = bp->next) + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); + for (bp = cpudebug->bplist; bp != NULL; bp = bp->next) if (bp->index == bpnum) { bp->enabled = (enable != 0); - breakpoint_update_flags(info); + breakpoint_update_flags(cpudebug); return TRUE; } } @@ -1085,7 +1030,7 @@ int debug_cpu_breakpoint_enable(running_machine *machine, int bpnum, int enable) int debug_cpu_watchpoint_set(const address_space *space, int type, offs_t address, offs_t length, parsed_expression *condition, const char *action) { debugcpu_private *global = space->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(space->cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); debug_cpu_watchpoint *wp = auto_alloc(space->machine, debug_cpu_watchpoint); /* fill in the structure */ @@ -1103,8 +1048,8 @@ int debug_cpu_watchpoint_set(const address_space *space, int type, offs_t addres } /* hook us in */ - wp->next = info->wplist[space->spacenum]; - info->wplist[space->spacenum] = wp; + wp->next = cpudebug->wplist[space->spacenum]; + cpudebug->wplist[space->spacenum] = wp; watchpoint_update_flags(space); @@ -1120,21 +1065,21 @@ int debug_cpu_watchpoint_set(const address_space *space, int type, offs_t addres int debug_cpu_watchpoint_clear(running_machine *machine, int wpnum) { debug_cpu_watchpoint *wp, *pwp; - running_device *cpu; + device_t *cpu; int spacenum; /* loop over CPUs and find the requested watchpoint */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (pwp = NULL, wp = info->wplist[spacenum]; wp != NULL; pwp = wp, wp = wp->next) + for (pwp = NULL, wp = cpudebug->wplist[spacenum]; wp != NULL; pwp = wp, wp = wp->next) if (wp->index == wpnum) { /* unlink us from the list */ if (pwp == NULL) - info->wplist[spacenum] = wp->next; + cpudebug->wplist[spacenum] = wp->next; else pwp->next = wp->next; @@ -1163,16 +1108,16 @@ int debug_cpu_watchpoint_clear(running_machine *machine, int wpnum) int debug_cpu_watchpoint_enable(running_machine *machine, int wpnum, int enable) { debug_cpu_watchpoint *wp; - running_device *cpu; + device_t *cpu; int spacenum; /* loop over CPUs and address spaces and find the requested watchpoint */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - for (wp = info->wplist[spacenum]; wp != NULL; wp = wp->next) + for (wp = cpudebug->wplist[spacenum]; wp != NULL; wp = wp->next) if (wp->index == wpnum) { wp->enabled = (enable != 0); @@ -1225,34 +1170,34 @@ void debug_cpu_source_script(running_machine *machine, const char *file) CPU -------------------------------------------------*/ -void debug_cpu_trace(running_device *device, FILE *file, int trace_over, const char *action) +void debug_cpu_trace(device_t *device, FILE *file, int trace_over, const char *action) { - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); /* close existing files and delete expressions */ - if (info->trace.file != NULL) - fclose(info->trace.file); - info->trace.file = NULL; + if (cpudebug->trace.file != NULL) + fclose(cpudebug->trace.file); + cpudebug->trace.file = NULL; - if (info->trace.action != NULL) - auto_free(device->machine, info->trace.action); - info->trace.action = NULL; + if (cpudebug->trace.action != NULL) + auto_free(device->machine, cpudebug->trace.action); + cpudebug->trace.action = NULL; /* open any new files */ - info->trace.file = file; - info->trace.action = NULL; - info->trace.trace_over_target = ~0; + cpudebug->trace.file = file; + cpudebug->trace.action = NULL; + cpudebug->trace.trace_over_target = ~0; if (action != NULL) { - info->trace.action = auto_alloc_array(device->machine, char, strlen(action) + 1); - strcpy(info->trace.action, action); + cpudebug->trace.action = auto_alloc_array(device->machine, char, strlen(action) + 1); + strcpy(cpudebug->trace.action, action); } /* update flags */ - if (info->trace.file != NULL) - info->flags |= trace_over ? DEBUG_FLAG_TRACING_OVER : DEBUG_FLAG_TRACING; + if (cpudebug->trace.file != NULL) + cpudebug->flags |= trace_over ? DEBUG_FLAG_TRACING_OVER : DEBUG_FLAG_TRACING; else - info->flags &= ~DEBUG_FLAG_TRACING_ANY; + cpudebug->flags &= ~DEBUG_FLAG_TRACING_ANY; } @@ -1261,16 +1206,16 @@ void debug_cpu_trace(running_device *device, FILE *file, int trace_over, const c given CPU's tracefile, if tracing -------------------------------------------------*/ -void debug_cpu_trace_printf(running_device *device, const char *fmt, ...) +void debug_cpu_trace_printf(device_t *device, const char *fmt, ...) { va_list va; - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); - if (info->trace.file) + if (cpudebug->trace.file) { va_start(va, fmt); - vfprintf(info->trace.file, fmt, va); + vfprintf(cpudebug->trace.file, fmt, va); va_end(va); } } @@ -1281,16 +1226,16 @@ void debug_cpu_trace_printf(running_device *device, const char *fmt, ...) be called on each instruction for a given CPU -------------------------------------------------*/ -void debug_cpu_set_instruction_hook(running_device *device, debug_instruction_hook_func hook) +void debug_cpu_set_instruction_hook(device_t *device, debug_instruction_hook_func hook) { - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); /* set the hook and also the CPU's flag for fast knowledge of the hook */ - info->instrhook = hook; + cpudebug->instrhook = hook; if (hook != NULL) - info->flags |= DEBUG_FLAG_HOOKED; + cpudebug->flags |= DEBUG_FLAG_HOOKED; else - info->flags &= ~DEBUG_FLAG_HOOKED; + cpudebug->flags &= ~DEBUG_FLAG_HOOKED; } @@ -1299,25 +1244,25 @@ void debug_cpu_set_instruction_hook(running_device *device, debug_instruction_ho tracking of hotspots -------------------------------------------------*/ -int debug_cpu_hotspot_track(running_device *device, int numspots, int threshhold) +int debug_cpu_hotspot_track(device_t *device, int numspots, int threshhold) { - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); - /* if we already have tracking info, kill it */ - if (info->hotspots) - auto_free(device->machine, info->hotspots); - info->hotspots = NULL; + /* if we already have tracking cpudebug, kill it */ + if (cpudebug->hotspots) + auto_free(device->machine, cpudebug->hotspots); + cpudebug->hotspots = NULL; /* only start tracking if we have a non-zero count */ if (numspots > 0) { /* allocate memory for hotspots */ - info->hotspots = auto_alloc_array(device->machine, debug_hotspot_entry, numspots); - memset(info->hotspots, 0xff, sizeof(*info->hotspots) * numspots); + cpudebug->hotspots = auto_alloc_array(device->machine, debug_hotspot_entry, numspots); + memset(cpudebug->hotspots, 0xff, sizeof(*cpudebug->hotspots) * numspots); - /* fill in the info */ - info->hotspot_count = numspots; - info->hotspot_threshhold = threshhold; + /* fill in the cpudebug */ + cpudebug->hotspot_count = numspots; + cpudebug->hotspot_threshhold = threshhold; } watchpoint_update_flags(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM)); @@ -1337,7 +1282,7 @@ int debug_cpu_hotspot_track(running_device *device, int numspots, int threshhold UINT8 debug_read_byte(const address_space *space, offs_t address, int apply_translation) { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; debugcpu_private *global = space->machine->debugcpu_data; UINT64 custom; UINT8 result; @@ -1353,7 +1298,7 @@ UINT8 debug_read_byte(const address_space *space, offs_t address, int apply_tran result = 0xff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info != NULL && info->read != NULL && (*info->read)(space->cpu, space->spacenum, address, 1, &custom)) + else if (cpudebug != NULL && cpudebug->cpudevice->read(space->spacenum, address, 1, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1395,7 +1340,7 @@ UINT16 debug_read_word(const address_space *space, offs_t address, int apply_tra /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; UINT64 custom; /* all accesses from this point on are for the debugger */ @@ -1406,7 +1351,7 @@ UINT16 debug_read_word(const address_space *space, offs_t address, int apply_tra result = 0xffff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info != NULL && info->read != NULL && (*info->read)(space->cpu, space->spacenum, address, 2, &custom)) + else if (cpudebug != NULL && cpudebug->cpudevice->read(space->spacenum, address, 2, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1450,7 +1395,7 @@ UINT32 debug_read_dword(const address_space *space, offs_t address, int apply_tr /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; UINT64 custom; /* all accesses from this point on are for the debugger */ @@ -1461,7 +1406,7 @@ UINT32 debug_read_dword(const address_space *space, offs_t address, int apply_tr result = 0xffffffff; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info != NULL && info->read != NULL && (*info->read)(space->cpu, space->spacenum, address, 4, &custom)) + else if (cpudebug != NULL && cpudebug->cpudevice->read(space->spacenum, address, 4, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1505,7 +1450,7 @@ UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_tr /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; UINT64 custom; /* all accesses from this point on are for the debugger */ @@ -1516,7 +1461,7 @@ UINT64 debug_read_qword(const address_space *space, offs_t address, int apply_tr result = ~(UINT64)0; /* if there is a custom read handler, and it returns TRUE, use that value */ - else if (info != NULL && info->read != NULL && (*info->read)(space->cpu, space->spacenum, address, 8, &custom)) + else if (cpudebug != NULL && cpudebug->cpudevice->read(space->spacenum, address, 8, custom)) result = custom; /* otherwise, call the byte reading function for the translated address */ @@ -1557,7 +1502,7 @@ UINT64 debug_read_memory(const address_space *space, offs_t address, int size, i void debug_write_byte(const address_space *space, offs_t address, UINT8 data, int apply_translation) { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; debugcpu_private *global = space->machine->debugcpu_data; /* mask against the logical byte mask */ @@ -1571,7 +1516,7 @@ void debug_write_byte(const address_space *space, offs_t address, UINT8 data, in ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info != NULL && info->write != NULL && (*info->write)(space->cpu, space->spacenum, address, 1, data)) + else if (cpudebug != NULL && cpudebug->cpudevice->write(space->spacenum, address, 1, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1614,7 +1559,7 @@ void debug_write_word(const address_space *space, offs_t address, UINT16 data, i /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); @@ -1624,7 +1569,7 @@ void debug_write_word(const address_space *space, offs_t address, UINT16 data, i ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info != NULL && info->write != NULL && (*info->write)(space->cpu, space->spacenum, address, 2, data)) + else if (cpudebug != NULL && cpudebug->cpudevice->write(space->spacenum, address, 2, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1668,7 +1613,7 @@ void debug_write_dword(const address_space *space, offs_t address, UINT32 data, /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); @@ -1678,7 +1623,7 @@ void debug_write_dword(const address_space *space, offs_t address, UINT32 data, ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info != NULL && info->write != NULL && (*info->write)(space->cpu, space->spacenum, address, 4, data)) + else if (cpudebug != NULL && cpudebug->cpudevice->write(space->spacenum, address, 4, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1722,7 +1667,7 @@ void debug_write_qword(const address_space *space, offs_t address, UINT64 data, /* otherwise, this proceeds like the byte case */ else { - cpu_debug_data *info = (space->cpu->type == CPU) ? cpu_get_debug_data(space->cpu) : NULL; + cpu_debug_data *cpudebug = (space->cpu->type() == CPU) ? cpu_get_debug_data(space->cpu) : NULL; /* all accesses from this point on are for the debugger */ memory_set_debugger_access(space, global->debugger_access = TRUE); @@ -1732,7 +1677,7 @@ void debug_write_qword(const address_space *space, offs_t address, UINT64 data, ; /* if there is a custom write handler, and it returns TRUE, use that */ - else if (info != NULL && info->write != NULL && (*info->write)(space->cpu, space->spacenum, address, 8, data)) + else if (cpudebug != NULL && cpudebug->cpudevice->write(space->spacenum, address, 8, data)) ; /* otherwise, call the byte reading function for the translated address */ @@ -1772,21 +1717,17 @@ UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, i { UINT64 result = ~(UINT64)0 & (~(UINT64)0 >> (64 - 8*size)), result2; debugcpu_private *global = space->machine->debugcpu_data; - cpu_debug_data *info = cpu_get_debug_data(space->cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); /* keep in logical range */ address &= space->logbytemask; - /* shortcut if we have a custom routine */ - if (info->readop != NULL) + /* return early if we got the result directly */ + memory_set_debugger_access(space, global->debugger_access = TRUE); + if (cpudebug->cpudevice->readop(address, size, result2)) { - /* return early if we got the result directly */ - memory_set_debugger_access(space, global->debugger_access = TRUE); - if ((*info->readop)(space->cpu, address, size, &result2)) - { - memory_set_debugger_access(space, global->debugger_access = FALSE); - return result2; - } + memory_set_debugger_access(space, global->debugger_access = FALSE); + return result2; } /* if we're bigger than the address bus, break into smaller pieces */ @@ -1929,34 +1870,34 @@ UINT64 debug_read_opcode(const address_space *space, offs_t address, int size, i static void debug_cpu_exit(running_machine *machine) { debugcpu_private *global = machine->debugcpu_data; - running_device *cpu; + device_t *cpu; int spacenum; /* loop over all watchpoints and breakpoints to free their memory */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) { - cpu_debug_data *info = cpu_get_debug_data(cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(cpu); /* close any tracefiles */ - if (info->trace.file != NULL) - fclose(info->trace.file); - if (info->trace.action != NULL) - auto_free(machine, info->trace.action); + if (cpudebug->trace.file != NULL) + fclose(cpudebug->trace.file); + if (cpudebug->trace.action != NULL) + auto_free(machine, cpudebug->trace.action); /* free the symbol table */ - if (info->symtable != NULL) - symtable_free(info->symtable); + if (cpudebug->symtable != NULL) + symtable_free(cpudebug->symtable); /* free all breakpoints */ - while (info->bplist != NULL) - debug_cpu_breakpoint_clear(machine, info->bplist->index); + while (cpudebug->bplist != NULL) + debug_cpu_breakpoint_clear(machine, cpudebug->bplist->index); /* loop over all address spaces */ - for (spacenum = 0; spacenum < ARRAY_LENGTH(info->wplist); spacenum++) + for (spacenum = 0; spacenum < ARRAY_LENGTH(cpudebug->wplist); spacenum++) { /* free all watchpoints */ - while (info->wplist[spacenum] != NULL) - debug_cpu_watchpoint_clear(machine, info->wplist[spacenum]->index); + while (cpudebug->wplist[spacenum] != NULL) + debug_cpu_watchpoint_clear(machine, cpudebug->wplist[spacenum]->index); } } @@ -1970,11 +1911,11 @@ static void debug_cpu_exit(running_machine *machine) on_vblank - called when a VBLANK hits -------------------------------------------------*/ -static void on_vblank(running_device *device, void *param, int vblank_state) +static void on_vblank(screen_device &device, void *param, bool vblank_state) { /* just set a global flag to be consumed later */ if (vblank_state) - device->machine->debugcpu_data->vblank_occurred = TRUE; + device.machine->debugcpu_data->vblank_occurred = TRUE; } @@ -1985,7 +1926,7 @@ static void on_vblank(running_device *device, void *param, int vblank_state) static void reset_transient_flags(running_machine *machine) { - running_device *cpu; + device_t *cpu; /* loop over CPUs and reset the transient flags */ for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) @@ -1998,9 +1939,9 @@ static void reset_transient_flags(running_machine *machine) debug flags for optimal efficiency -------------------------------------------------*/ -static void compute_debug_flags(running_device *device) +static void compute_debug_flags(device_t *device) { - cpu_debug_data *info = cpu_get_debug_data(device); + cpu_debug_data *cpudebug = cpu_get_debug_data(device); running_machine *machine = device->machine; debugcpu_private *global = machine->debugcpu_data; @@ -2009,18 +1950,18 @@ static void compute_debug_flags(running_device *device) machine->debug_flags |= DEBUG_FLAG_ENABLED; /* if we are ignoring this CPU, or if events are pending, we're done */ - if ((info->flags & DEBUG_FLAG_OBSERVING) == 0 || mame_is_scheduled_event_pending(machine) || mame_is_save_or_load_pending(machine)) + if ((cpudebug->flags & DEBUG_FLAG_OBSERVING) == 0 || mame_is_scheduled_event_pending(machine) || mame_is_save_or_load_pending(machine)) return; /* many of our states require us to be called on each instruction */ if (global->execution_state == EXECUTION_STATE_STOPPED) machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; - if ((info->flags & (DEBUG_FLAG_HISTORY | DEBUG_FLAG_TRACING_ANY | DEBUG_FLAG_HOOKED | + if ((cpudebug->flags & (DEBUG_FLAG_HISTORY | DEBUG_FLAG_TRACING_ANY | DEBUG_FLAG_HOOKED | DEBUG_FLAG_STEPPING_ANY | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; /* if we are stopping at a particular time and that time is within the current timeslice, we need to be called */ - if ((info->flags & DEBUG_FLAG_STOP_TIME) && attotime_compare(info->endexectime, info->stoptime) <= 0) + if ((cpudebug->flags & DEBUG_FLAG_STOP_TIME) && attotime_compare(cpudebug->endexectime, cpudebug->stoptime) <= 0) machine->debug_flags |= DEBUG_FLAG_CALL_HOOK; } @@ -2030,70 +1971,70 @@ static void compute_debug_flags(running_device *device) data for a given instruction -------------------------------------------------*/ -static void perform_trace(cpu_debug_data *info) +static void perform_trace(cpu_debug_data *cpudebug) { - offs_t pc = cpu_get_pc(info->device); + offs_t pc = cpu_get_pc(cpudebug->cpudevice); int offset, count, i; char buffer[100]; offs_t dasmresult; /* are we in trace over mode and in a subroutine? */ - if ((info->flags & DEBUG_FLAG_TRACING_OVER) != 0 && info->trace.trace_over_target != ~0) + if ((cpudebug->flags & DEBUG_FLAG_TRACING_OVER) != 0 && cpudebug->trace.trace_over_target != ~0) { - if (info->trace.trace_over_target != pc) + if (cpudebug->trace.trace_over_target != pc) return; - info->trace.trace_over_target = ~0; + cpudebug->trace.trace_over_target = ~0; } /* check for a loop condition */ for (i = count = 0; i < TRACE_LOOPS; i++) - if (info->trace.history[i] == pc) + if (cpudebug->trace.history[i] == pc) count++; /* if no more than 1 hit, process normally */ if (count <= 1) { - const address_space *space = cpu_get_address_space(info->device, ADDRESS_SPACE_PROGRAM); + const address_space *space = cpu_get_address_space(cpudebug->cpudevice, ADDRESS_SPACE_PROGRAM); /* if we just finished looping, indicate as much */ - if (info->trace.loops != 0) - fprintf(info->trace.file, "\n (loops for %d instructions)\n\n", info->trace.loops); - info->trace.loops = 0; + if (cpudebug->trace.loops != 0) + fprintf(cpudebug->trace.file, "\n (loops for %d instructions)\n\n", cpudebug->trace.loops); + cpudebug->trace.loops = 0; /* execute any trace actions first */ - if (info->trace.action != NULL) - debug_console_execute_command(info->device->machine, info->trace.action, 0); + if (cpudebug->trace.action != NULL) + debug_console_execute_command(cpudebug->cpudevice->machine, cpudebug->trace.action, 0); /* print the address */ offset = sprintf(buffer, "%0*X: ", space->logaddrchars, pc); /* print the disassembly */ - dasmresult = dasm_wrapped(info->device, &buffer[offset], pc); + dasmresult = dasm_wrapped(cpudebug->cpudevice, &buffer[offset], pc); /* output the result */ - fprintf(info->trace.file, "%s\n", buffer); + fprintf(cpudebug->trace.file, "%s\n", buffer); /* do we need to step the trace over this instruction? */ - if ((info->flags & DEBUG_FLAG_TRACING_OVER) != 0 && (dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OVER) != 0) + if ((cpudebug->flags & DEBUG_FLAG_TRACING_OVER) != 0 && (dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OVER) != 0) { int extraskip = (dasmresult & DASMFLAG_OVERINSTMASK) >> DASMFLAG_OVERINSTSHIFT; offs_t trace_over_target = pc + (dasmresult & DASMFLAG_LENGTHMASK); /* if we need to skip additional instructions, advance as requested */ while (extraskip-- > 0) - trace_over_target += dasm_wrapped(info->device, buffer, trace_over_target) & DASMFLAG_LENGTHMASK; + trace_over_target += dasm_wrapped(cpudebug->cpudevice, buffer, trace_over_target) & DASMFLAG_LENGTHMASK; - info->trace.trace_over_target = trace_over_target; + cpudebug->trace.trace_over_target = trace_over_target; } /* log this PC */ - info->trace.nextdex = (info->trace.nextdex + 1) % TRACE_LOOPS; - info->trace.history[info->trace.nextdex] = pc; + cpudebug->trace.nextdex = (cpudebug->trace.nextdex + 1) % TRACE_LOOPS; + cpudebug->trace.history[cpudebug->trace.nextdex] = pc; } /* else just count the loop */ else - info->trace.loops++; + cpudebug->trace.loops++; } @@ -2102,14 +2043,14 @@ static void perform_trace(cpu_debug_data *info) stepping over an instruction -------------------------------------------------*/ -static void prepare_for_step_overout(cpu_debug_data *info) +static void prepare_for_step_overout(cpu_debug_data *cpudebug) { - offs_t pc = cpu_get_pc(info->device); + offs_t pc = cpu_get_pc(cpudebug->cpudevice); char dasmbuffer[100]; offs_t dasmresult; /* disassemble the current instruction and get the flags */ - dasmresult = dasm_wrapped(info->device, dasmbuffer, pc); + dasmresult = dasm_wrapped(cpudebug->cpudevice, dasmbuffer, pc); /* if flags are supported and it's a call-style opcode, set a temp breakpoint after that instruction */ if ((dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OVER) != 0) @@ -2119,17 +2060,17 @@ static void prepare_for_step_overout(cpu_debug_data *info) /* if we need to skip additional instructions, advance as requested */ while (extraskip-- > 0) - pc += dasm_wrapped(info->device, dasmbuffer, pc) & DASMFLAG_LENGTHMASK; - info->stepaddr = pc; + pc += dasm_wrapped(cpudebug->cpudevice, dasmbuffer, pc) & DASMFLAG_LENGTHMASK; + cpudebug->stepaddr = pc; } /* if we're stepping out and this isn't a step out instruction, reset the steps until stop to a high number */ - if ((info->flags & DEBUG_FLAG_STEPPING_OUT) != 0) + if ((cpudebug->flags & DEBUG_FLAG_STEPPING_OUT) != 0) { if ((dasmresult & DASMFLAG_SUPPORTED) != 0 && (dasmresult & DASMFLAG_STEP_OUT) == 0) - info->stepsleft = 100; + cpudebug->stepsleft = 100; else - info->stepsleft = 1; + cpudebug->stepsleft = 1; } } @@ -2184,17 +2125,17 @@ static void process_source_file(running_machine *machine) breakpoint flags -------------------------------------------------*/ -static void breakpoint_update_flags(cpu_debug_data *info) +static void breakpoint_update_flags(cpu_debug_data *cpudebug) { - debugcpu_private *global = info->device->machine->debugcpu_data; + debugcpu_private *global = cpudebug->cpudevice->machine->debugcpu_data; debug_cpu_breakpoint *bp; /* see if there are any enabled breakpoints */ - info->flags &= ~DEBUG_FLAG_LIVE_BP; - for (bp = info->bplist; bp != NULL; bp = bp->next) + cpudebug->flags &= ~DEBUG_FLAG_LIVE_BP; + for (bp = cpudebug->bplist; bp != NULL; bp = bp->next) if (bp->enabled) { - info->flags |= DEBUG_FLAG_LIVE_BP; + cpudebug->flags |= DEBUG_FLAG_LIVE_BP; break; } @@ -2209,14 +2150,14 @@ static void breakpoint_update_flags(cpu_debug_data *info) a given CPU -------------------------------------------------*/ -static void breakpoint_check(running_machine *machine, cpu_debug_data *info, offs_t pc) +static void breakpoint_check(running_machine *machine, cpu_debug_data *cpudebug, offs_t pc) { debugcpu_private *global = machine->debugcpu_data; debug_cpu_breakpoint *bp; UINT64 result; /* see if we match */ - for (bp = info->bplist; bp != NULL; bp = bp->next) + for (bp = cpudebug->bplist; bp != NULL; bp = bp->next) if (bp->enabled && bp->address == pc) /* if we do, evaluate the condition */ @@ -2244,17 +2185,17 @@ static void breakpoint_check(running_machine *machine, cpu_debug_data *info, off static void watchpoint_update_flags(const address_space *space) { - const cpu_debug_data *info = cpu_get_debug_data(space->cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); debug_cpu_watchpoint *wp; int enablewrite = FALSE; int enableread = FALSE; /* if hotspots are enabled, turn on all reads */ - if (info->hotspots != NULL) + if (cpudebug->hotspots != NULL) enableread = TRUE; /* see if there are any enabled breakpoints */ - for (wp = info->wplist[space->spacenum]; wp != NULL; wp = wp->next) + for (wp = cpudebug->wplist[space->spacenum]; wp != NULL; wp = wp->next) if (wp->enabled) { if (wp->type & WATCHPOINT_READ) @@ -2276,7 +2217,7 @@ static void watchpoint_update_flags(const address_space *space) static void watchpoint_check(const address_space *space, int type, offs_t address, UINT64 value_to_write, UINT64 mem_mask) { - const cpu_debug_data *info = cpu_get_debug_data(space->cpu); + const cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); debugcpu_private *global = space->machine->debugcpu_data; debug_cpu_watchpoint *wp; offs_t size = 0; @@ -2319,7 +2260,7 @@ static void watchpoint_check(const address_space *space, int type, offs_t addres global->wpdata = value_to_write; /* see if we match */ - for (wp = info->wplist[space->spacenum]; wp != NULL; wp = wp->next) + for (wp = cpudebug->wplist[space->spacenum]; wp != NULL; wp = wp->next) if (wp->enabled && (wp->type & type) != 0 && address + size > wp->address && address < wp->address + wp->length) /* if we do, evaluate the condition */ @@ -2368,40 +2309,40 @@ static void watchpoint_check(const address_space *space, int type, offs_t addres static void check_hotspots(const address_space *space, offs_t address) { - cpu_debug_data *info = cpu_get_debug_data(space->cpu); + cpu_debug_data *cpudebug = cpu_get_debug_data(space->cpu); offs_t pc = cpu_get_pc(space->cpu); int hotindex; /* see if we have a match in our list */ - for (hotindex = 0; hotindex < info->hotspot_count; hotindex++) - if (info->hotspots[hotindex].access == address && info->hotspots[hotindex].pc == pc && info->hotspots[hotindex].space == space) + for (hotindex = 0; hotindex < cpudebug->hotspot_count; hotindex++) + if (cpudebug->hotspots[hotindex].access == address && cpudebug->hotspots[hotindex].pc == pc && cpudebug->hotspots[hotindex].space == space) break; /* if we didn't find any, make a new entry */ - if (hotindex == info->hotspot_count) + if (hotindex == cpudebug->hotspot_count) { /* if the bottom of the list is over the threshhold, print it */ - debug_hotspot_entry *spot = &info->hotspots[info->hotspot_count - 1]; - if (spot->count > info->hotspot_threshhold) + debug_hotspot_entry *spot = &cpudebug->hotspots[cpudebug->hotspot_count - 1]; + if (spot->count > cpudebug->hotspot_threshhold) debug_console_printf(space->machine, "Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", space->name, spot->access, spot->pc, spot->count); /* move everything else down and insert this one at the top */ - memmove(&info->hotspots[1], &info->hotspots[0], sizeof(info->hotspots[0]) * (info->hotspot_count - 1)); - info->hotspots[0].access = address; - info->hotspots[0].pc = pc; - info->hotspots[0].space = space; - info->hotspots[0].count = 1; + memmove(&cpudebug->hotspots[1], &cpudebug->hotspots[0], sizeof(cpudebug->hotspots[0]) * (cpudebug->hotspot_count - 1)); + cpudebug->hotspots[0].access = address; + cpudebug->hotspots[0].pc = pc; + cpudebug->hotspots[0].space = space; + cpudebug->hotspots[0].count = 1; } /* if we did find one, increase the count and move it to the top */ else { - info->hotspots[hotindex].count++; + cpudebug->hotspots[hotindex].count++; if (hotindex != 0) { - debug_hotspot_entry temp = info->hotspots[hotindex]; - memmove(&info->hotspots[1], &info->hotspots[0], sizeof(info->hotspots[0]) * hotindex); - info->hotspots[0] = temp; + debug_hotspot_entry temp = cpudebug->hotspots[hotindex]; + memmove(&cpudebug->hotspots[1], &cpudebug->hotspots[0], sizeof(cpudebug->hotspots[0]) * hotindex); + cpudebug->hotspots[0] = temp; } } } @@ -2413,10 +2354,11 @@ static void check_hotspots(const address_space *space, offs_t address) buffer and then disassembling them -------------------------------------------------*/ -static UINT32 dasm_wrapped(running_device *device, char *buffer, offs_t pc) +static UINT32 dasm_wrapped(device_t *device, char *buffer, offs_t pc) { - const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM); - int maxbytes = cpu_get_max_opcode_bytes(device); + const address_space *space = device_memory(device)->space(AS_PROGRAM); + cpu_device *cpudevice = downcast(device); + int maxbytes = cpudevice->max_opcode_bytes(); UINT8 opbuf[64], argbuf[64]; offs_t pcbyte; int numbytes; @@ -2443,11 +2385,11 @@ static UINT32 dasm_wrapped(running_device *device, char *buffer, offs_t pc) based on a case insensitive tag search -------------------------------------------------*/ -static running_device *expression_get_device(running_machine *machine, const char *tag) +static device_t *expression_get_device(running_machine *machine, const char *tag) { - running_device *device; + device_t *device; - for (device = machine->devicelist.first(); device != NULL; device = device->next) + for (device = machine->devicelist.first(); device != NULL; device = device->next()) if (mame_stricmp(device->tag(), tag) == 0) return device; @@ -2465,7 +2407,7 @@ static UINT64 expression_read_memory(void *param, const char *name, int spacenum { running_machine *machine = (running_machine *)param; UINT64 result = ~(UINT64)0 >> (64 - 8*size); - running_device *device = NULL; + device_t *device = NULL; const address_space *space; switch (spacenum) @@ -2635,7 +2577,7 @@ static UINT64 expression_read_memory_region(running_machine *machine, const char static void expression_write_memory(void *param, const char *name, int spacenum, UINT32 address, int size, UINT64 data) { running_machine *machine = (running_machine *)param; - running_device *device = NULL; + device_t *device = NULL; const address_space *space; switch (spacenum) @@ -2817,7 +2759,7 @@ static void expression_write_memory_region(running_machine *machine, const char static EXPRERR expression_validate(void *param, const char *name, int space) { running_machine *machine = (running_machine *)param; - running_device *device = NULL; + device_t *device = NULL; switch (space) { @@ -2947,8 +2889,8 @@ static void set_tempvar(void *globalref, void *ref, UINT64 value) static UINT64 get_beamx(void *globalref, void *ref) { - running_device *screen = (running_device *)ref; - return (screen != NULL) ? video_screen_get_hpos(screen) : 0; + screen_device *screen = reinterpret_cast(ref); + return (screen != NULL) ? screen->hpos() : 0; } @@ -2958,8 +2900,8 @@ static UINT64 get_beamx(void *globalref, void *ref) static UINT64 get_beamy(void *globalref, void *ref) { - running_device *screen = (running_device *)ref; - return (screen != NULL) ? video_screen_get_vpos(screen) : 0; + screen_device *screen = reinterpret_cast(ref); + return (screen != NULL) ? screen->vpos() : 0; } @@ -2969,8 +2911,8 @@ static UINT64 get_beamy(void *globalref, void *ref) static UINT64 get_frame(void *globalref, void *ref) { - running_device *screen = (running_device *)ref; - return (screen != NULL) ? video_screen_get_frame_number(screen) : 0; + screen_device *screen = reinterpret_cast(ref); + return (screen != NULL) ? screen->frame_number() : 0; } @@ -2981,7 +2923,7 @@ static UINT64 get_frame(void *globalref, void *ref) static UINT64 get_current_pc(void *globalref, void *ref) { - running_device *device = (running_device *)globalref; + cpu_device *device = (cpu_device *)globalref; return cpu_get_pc(device); } @@ -2993,8 +2935,8 @@ static UINT64 get_current_pc(void *globalref, void *ref) static UINT64 get_cycles(void *globalref, void *ref) { - running_device *device = (running_device *)globalref; - return *cpu_get_icount_ptr(device); + cpu_device *device = (cpu_device *)globalref; + return device->cycles_remaining(); } @@ -3030,7 +2972,7 @@ static void set_logunmap(void *globalref, void *ref, UINT64 value) static UINT64 get_cpu_reg(void *globalref, void *ref) { - running_device *device = (running_device *)globalref; + cpu_device *device = (cpu_device *)globalref; return cpu_get_reg(device, (FPTR)ref); } @@ -3042,6 +2984,6 @@ static UINT64 get_cpu_reg(void *globalref, void *ref) static void set_cpu_reg(void *globalref, void *ref, UINT64 value) { - running_device *device = (running_device *)globalref; + cpu_device *device = (cpu_device *)globalref; cpu_set_reg(device, (FPTR)ref, value); } diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 221e1511fbd..c5cec23a91a 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -65,7 +65,7 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef int (*debug_instruction_hook_func)(running_device *device, offs_t curpc); +typedef int (*debug_instruction_hook_func)(device_t *device, offs_t curpc); typedef struct _debug_cpu_breakpoint debug_cpu_breakpoint; @@ -98,9 +98,10 @@ struct _debug_hotspot_entry /* In cpuintrf.h: typedef struct _cpu_debug_data cpu_debug_data; */ -struct _cpu_debug_data +class cpu_debug_data { - running_device * device; /* CPU device object */ +public: + cpu_device * cpudevice; /* CPU device object */ symbol_table * symtable; /* symbol table for expression evaluation */ UINT32 flags; /* debugging flags for this CPU */ UINT8 opwidth; /* width of an opcode */ @@ -118,11 +119,6 @@ struct _cpu_debug_data UINT32 pc_history_index; /* current history index */ int hotspot_count; /* number of hotspots */ int hotspot_threshhold; /* threshhold for the number of hits to print */ - cpu_read_func read; /* memory read routine */ - cpu_write_func write; /* memory write routine */ - cpu_readop_func readop; /* opcode read routine */ - cpu_translate_func translate; /* pointer to CPU's translate function */ - cpu_disassemble_func disassemble; /* pointer to CPU's dissasemble function */ cpu_disassemble_func dasm_override; /* pointer to provided override function */ debug_instruction_hook_func instrhook; /* per-instruction callback hook */ debug_cpu_watchpoint * wplist[ADDRESS_SPACES]; /* watchpoint lists for each address space */ @@ -180,7 +176,7 @@ void debug_cpu_flush_traces(running_machine *machine); /* ----- debugging status & information ----- */ /* return the visible CPU device (the one that commands should apply to) */ -running_device *debug_cpu_get_visible_cpu(running_machine *machine); +device_t *debug_cpu_get_visible_cpu(running_machine *machine); /* TRUE if the debugger is currently stopped within an instruction hook callback */ int debug_cpu_within_instruction_hook(running_machine *machine); @@ -199,7 +195,7 @@ symbol_table *debug_cpu_get_global_symtable(running_machine *machine); symbol_table *debug_cpu_get_visible_symtable(running_machine *machine); /* return a specific CPU's symbol table */ -symbol_table *debug_cpu_get_symtable(running_device *device); +symbol_table *debug_cpu_get_symtable(device_t *device); @@ -209,29 +205,29 @@ symbol_table *debug_cpu_get_symtable(running_device *device); int debug_cpu_translate(const address_space *space, int intention, offs_t *address); /* disassemble a line at a given PC on a given CPU */ -offs_t debug_cpu_disassemble(running_device *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); +offs_t debug_cpu_disassemble(device_t *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); /* set an override handler for disassembly */ -void debug_cpu_set_dasm_override(running_device *device, cpu_disassemble_func dasm_override); +void debug_cpu_set_dasm_override(device_t *device, cpu_disassemble_func dasm_override); /* ----- core debugger hooks ----- */ /* the CPU execution system calls this hook before beginning execution for the given CPU */ -void debug_cpu_start_hook(running_device *device, attotime endtime); +void debug_cpu_start_hook(device_t *device, attotime endtime); /* the CPU execution system calls this hook when ending execution for the given CPU */ -void debug_cpu_stop_hook(running_device *device); +void debug_cpu_stop_hook(device_t *device); /* the CPU execution system calls this hook when an interrupt is acknowledged */ -void debug_cpu_interrupt_hook(running_device *device, int irqline); +void debug_cpu_interrupt_hook(device_t *device, int irqline); /* called by the CPU cores when an exception is generated */ -void debug_cpu_exception_hook(running_device *device, int exception); +void debug_cpu_exception_hook(device_t *device, int exception); /* called by the CPU cores before executing each instruction */ -void debug_cpu_instruction_hook(running_device *device, offs_t curpc); +void debug_cpu_instruction_hook(device_t *device, offs_t curpc); /* the memory system calls this hook when watchpoints are enabled and a memory read happens */ void debug_cpu_memory_read_hook(const address_space *space, offs_t address, UINT64 mem_mask); @@ -244,10 +240,10 @@ void debug_cpu_memory_write_hook(const address_space *space, offs_t address, UIN /* ----- execution control ----- */ /* halt in the debugger on the next instruction */ -void debug_cpu_halt_on_next_instruction(running_device *device, const char *fmt, ...) ATTR_PRINTF(2,3); +void debug_cpu_halt_on_next_instruction(device_t *device, const char *fmt, ...) ATTR_PRINTF(2,3); /* ignore/observe a given CPU */ -void debug_cpu_ignore_cpu(running_device *cpu, int ignore); +void debug_cpu_ignore_cpu(device_t *cpu, int ignore); /* single step the visible CPU past the requested number of instructions */ void debug_cpu_single_step(running_machine *machine, int numsteps); @@ -281,7 +277,7 @@ void debug_cpu_next_cpu(running_machine *machine); /* ----- breakpoints ----- */ /* set a new breakpoint, returning its index */ -int debug_cpu_breakpoint_set(running_device *device, offs_t address, parsed_expression *condition, const char *action); +int debug_cpu_breakpoint_set(device_t *device, offs_t address, parsed_expression *condition, const char *action); /* clear a breakpoint by index */ int debug_cpu_breakpoint_clear(running_machine *machine, int bpnum); @@ -310,16 +306,16 @@ int debug_cpu_watchpoint_enable(running_machine *machine, int wpnum, int enable) void debug_cpu_source_script(running_machine *machine, const char *file); /* trace execution of a given CPU */ -void debug_cpu_trace(running_device *device, FILE *file, int trace_over, const char *action); +void debug_cpu_trace(device_t *device, FILE *file, int trace_over, const char *action); /* output data into the given CPU's tracefile, if tracing */ -void debug_cpu_trace_printf(running_device *device, const char *fmt, ...) ATTR_PRINTF(2,3); +void debug_cpu_trace_printf(device_t *device, const char *fmt, ...) ATTR_PRINTF(2,3); /* set a hook to be called on each instruction for a given CPU */ -void debug_cpu_set_instruction_hook(running_device *device, debug_instruction_hook_func hook); +void debug_cpu_set_instruction_hook(device_t *device, debug_instruction_hook_func hook); /* hotspots */ -int debug_cpu_hotspot_track(running_device *device, int numspots, int threshhold); +int debug_cpu_hotspot_track(device_t *device, int numspots, int threshhold); diff --git a/src/emu/debug/debugvw.c b/src/emu/debug/debugvw.c index 49de5f9c412..7ffa0539dc8 100644 --- a/src/emu/debug/debugvw.c +++ b/src/emu/debug/debugvw.c @@ -38,6 +38,12 @@ enum _view_notification }; typedef enum _view_notification view_notification; +#define REG_DIVIDER -10 +#define REG_CYCLES -11 +#define REG_BEAMX -12 +#define REG_BEAMY -13 +#define REG_FRAME -14 + /*************************************************************************** @@ -123,18 +129,16 @@ struct _debug_view_register { UINT64 lastval; /* last value */ UINT64 currval; /* current value */ - UINT32 regnum; /* index */ - UINT8 tagstart; /* starting tag char */ - UINT8 taglen; /* number of tag chars */ - UINT8 valstart; /* starting value char */ + int regnum; /* index */ UINT8 vallen; /* number of value chars */ + astring symbol; /* symbol */ }; typedef struct _debug_view_registers debug_view_registers; struct _debug_view_registers { - running_device *device; /* CPU device whose registers we are showing */ + const registers_subview_item *subview; /* pointer to our subview */ int divider; /* dividing column */ UINT64 last_update; /* execution counter at last update */ debug_view_register reg[MAX_REGS]; /* register data */ @@ -820,7 +824,7 @@ static void debug_view_expression_set(debug_view_expression *expression, const c changed -------------------------------------------------*/ -static int debug_view_expression_changed_value(debug_view *view, debug_view_expression *expression, running_device *cpu) +static int debug_view_expression_changed_value(debug_view *view, debug_view_expression *expression, device_t *cpu) { int changed = expression->dirty; EXPRERR exprerr; @@ -1029,15 +1033,17 @@ static const registers_subview_item *registers_view_enumerate_subviews(running_m int curindex = 0; /* iterate over CPUs with program address spaces */ - for (running_device *cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + device_state_interface *state; + for (bool gotone = machine->devicelist.first(state); gotone; gotone = state->next(state)) { registers_subview_item *subview = auto_alloc(machine, registers_subview_item); /* populate the subview */ subview->next = NULL; subview->index = curindex++; - subview->name.printf("CPU '%s' (%s)", cpu->tag(), cpu->name()); - subview->device = cpu; + subview->name.printf("CPU '%s' (%s)", state->device().tag(), state->device().name()); + subview->stateintf = state; + state->device().interface(subview->execintf); /* add to the list */ *tailptr = subview; @@ -1063,7 +1069,7 @@ static int registers_view_alloc(debug_view *view) debug_view_registers *regdata = auto_alloc_clear(view->machine, debug_view_registers); /* default to the first subview */ - regdata->device = view->machine->debugvw_data->registers_subviews->device; + regdata->subview = view->machine->debugvw_data->registers_subviews; /* stash the extra data pointer */ view->extra_data = regdata; @@ -1087,65 +1093,6 @@ static void registers_view_free(debug_view *view) } -/*------------------------------------------------- - registers_view_add_register - adds a register - to the registers view --------------------------------------------------*/ - -static void registers_view_add_register(debug_view *view, int regnum, const char *str) -{ - debug_view_registers *regdata = (debug_view_registers *)view->extra_data; - int tagstart, taglen, valstart, vallen; - const char *colon; - - colon = strchr(str, ':'); - - /* if no colon, mark everything as tag */ - if (colon == NULL) - { - tagstart = 0; - taglen = (int)strlen(str); - valstart = 0; - vallen = 0; - } - - /* otherwise, break the string at the colon */ - else - { - tagstart = 0; - taglen = colon - str; - valstart = (colon + 1) - str; - vallen = (int)strlen(colon + 1); - } - - /* now trim spaces */ - while (isspace((UINT8)str[tagstart]) && taglen > 0) - tagstart++, taglen--; - while (isspace((UINT8)str[tagstart + taglen - 1]) && taglen > 0) - taglen--; - while (isspace((UINT8)str[valstart]) && vallen > 0) - valstart++, vallen--; - while (isspace((UINT8)str[valstart + vallen - 1]) && vallen > 0) - vallen--; - if (str[valstart] == '!') - valstart++, vallen--; - - /* note the register number and info */ - regdata->reg[view->total.y].lastval = - regdata->reg[view->total.y].currval = cpu_get_reg(regdata->device, regnum); - regdata->reg[view->total.y].regnum = regnum; - regdata->reg[view->total.y].tagstart = tagstart; - regdata->reg[view->total.y].taglen = taglen; - regdata->reg[view->total.y].valstart = valstart; - regdata->reg[view->total.y].vallen = vallen; - view->total.y++; - - /* adjust the divider and total cols, if necessary */ - regdata->divider = MAX(regdata->divider, 1 + taglen + 1); - view->total.x = MAX(view->total.x, 1 + taglen + 2 + vallen + 1); -} - - /*------------------------------------------------- registers_view_recompute - recompute all info for the registers view @@ -1154,13 +1101,7 @@ static void registers_view_add_register(debug_view *view, int regnum, const char static void registers_view_recompute(debug_view *view) { debug_view_registers *regdata = (debug_view_registers *)view->extra_data; - int regnum, maxtaglen, maxvallen; - const cpu_state_table *table; - - /* if no CPU, reset to the first one */ - if (regdata->device == NULL) - regdata->device = view->machine->firstcpu; - table = cpu_get_state_table(regdata->device); + int maxtaglen, maxvallen; /* reset the view parameters */ view->topleft.y = 0; @@ -1170,100 +1111,84 @@ static void registers_view_recompute(debug_view *view) regdata->divider = 0; /* add a cycles entry: cycles:99999999 */ - regdata->reg[view->total.y].lastval = - regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS + 1; - regdata->reg[view->total.y].tagstart = 0; - regdata->reg[view->total.y].taglen = 6; - regdata->reg[view->total.y].valstart = 7; - regdata->reg[view->total.y].vallen = 8; - maxtaglen = regdata->reg[view->total.y].taglen; - maxvallen = regdata->reg[view->total.y].vallen; - view->total.y++; + maxtaglen = 0; + maxvallen = 0; + if (regdata->subview->execintf != NULL) + { + regdata->reg[view->total.y].lastval = + regdata->reg[view->total.y].currval = 0; + regdata->reg[view->total.y].regnum = REG_CYCLES; + regdata->reg[view->total.y].symbol.cpy("cycles"); + regdata->reg[view->total.y].vallen = 8; + maxtaglen = regdata->reg[view->total.y].symbol.len(); + maxvallen = regdata->reg[view->total.y].vallen; + view->total.y++; + } /* add a beam entry: beamx:123 */ regdata->reg[view->total.y].lastval = regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS + 2; - regdata->reg[view->total.y].tagstart = 0; - regdata->reg[view->total.y].taglen = 5; - regdata->reg[view->total.y].valstart = 6; + regdata->reg[view->total.y].regnum = REG_BEAMX; + regdata->reg[view->total.y].symbol.cpy("beamx"); regdata->reg[view->total.y].vallen = 3; - maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].taglen); + maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].symbol.len()); maxvallen = MAX(maxvallen, regdata->reg[view->total.y].vallen); view->total.y++; /* add a beam entry: beamy:456 */ regdata->reg[view->total.y].lastval = regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS + 3; - regdata->reg[view->total.y].tagstart = 0; - regdata->reg[view->total.y].taglen = 5; - regdata->reg[view->total.y].valstart = 6; + regdata->reg[view->total.y].regnum = REG_BEAMY; + regdata->reg[view->total.y].symbol.cpy("beamy"); regdata->reg[view->total.y].vallen = 3; - maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].taglen); + maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].symbol.len()); maxvallen = MAX(maxvallen, regdata->reg[view->total.y].vallen); view->total.y++; /* add a beam entry: frame:123456 */ regdata->reg[view->total.y].lastval = regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS + 4; - regdata->reg[view->total.y].tagstart = 0; - regdata->reg[view->total.y].taglen = 5; - regdata->reg[view->total.y].valstart = 6; + regdata->reg[view->total.y].regnum = REG_FRAME; + regdata->reg[view->total.y].symbol.cpy("frame"); regdata->reg[view->total.y].vallen = 6; - maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].taglen); + maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].symbol.len()); maxvallen = MAX(maxvallen, regdata->reg[view->total.y].vallen); view->total.y++; /* add a flags entry: flags:xxxxxxxx */ regdata->reg[view->total.y].lastval = regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS + 5; - regdata->reg[view->total.y].tagstart = 0; - regdata->reg[view->total.y].taglen = 5; - regdata->reg[view->total.y].valstart = 6; - regdata->reg[view->total.y].vallen = (UINT32)strlen(cpu_get_flags_string(regdata->device)); - maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].taglen); + regdata->reg[view->total.y].regnum = STATE_GENFLAGS; + regdata->reg[view->total.y].symbol.cpy("flags"); + regdata->reg[view->total.y].vallen = regdata->subview->stateintf->state_string_max_length(regdata->reg[view->total.y].regnum); + maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].symbol.len()); maxvallen = MAX(maxvallen, regdata->reg[view->total.y].vallen); view->total.y++; /* add a divider entry */ regdata->reg[view->total.y].lastval = regdata->reg[view->total.y].currval = 0; - regdata->reg[view->total.y].regnum = MAX_REGS; + regdata->reg[view->total.y].regnum = REG_DIVIDER; view->total.y++; - /* set the current divider and total cols */ - regdata->divider = 1 + maxtaglen + 1; - view->total.x = 1 + maxtaglen + 2 + maxvallen + 1; - /* add all registers into it */ - for (regnum = 0; regnum < MAX_REGS; regnum++) - { - const char *str = NULL; - int regid; - - /* identify the register id */ - if (table != NULL) + for (const device_state_entry *entry = regdata->subview->stateintf->state_first(); entry != NULL; entry = entry->next()) + if (entry->visible()) { - if (regnum >= table->entrycount) - break; - if ((table->entrylist[regnum].validmask & table->subtypemask) == 0) - continue; - regid = table->entrylist[regnum].index; + /* note the register number and info */ + regdata->reg[view->total.y].lastval = + regdata->reg[view->total.y].currval = regdata->subview->stateintf->state_value(entry->index()); + regdata->reg[view->total.y].regnum = entry->index(); + regdata->reg[view->total.y].symbol.cpy(entry->symbol()); + regdata->reg[view->total.y].vallen = regdata->subview->stateintf->state_string_max_length(entry->index()); + maxtaglen = MAX(maxtaglen, regdata->reg[view->total.y].symbol.len()); + maxvallen = MAX(maxvallen, regdata->reg[view->total.y].vallen); + view->total.y++; } - else - regid = regnum; - /* retrieve the string for this register */ - str = cpu_get_reg_string(regdata->device, regid); - - /* did we get a string? */ - if (str != NULL && str[0] != 0 && str[0] != '~') - registers_view_add_register(view, regid, str); - } + /* set the current divider and total cols */ + regdata->divider = 1 + maxtaglen + 1; + view->total.x = 1 + maxtaglen + 2 + maxvallen + 1; /* no longer need to recompute */ view->recompute = FALSE; @@ -1277,18 +1202,20 @@ static void registers_view_recompute(debug_view *view) static void registers_view_update(debug_view *view) { - running_device *screen = view->machine->primary_screen; + screen_device *screen = view->machine->primary_screen; debug_view_registers *regdata = (debug_view_registers *)view->extra_data; debug_view_char *dest = view->viewdata; UINT64 total_cycles; UINT32 row, i; /* if our assumptions changed, revisit them */ - if (view->recompute || regdata->device == NULL) + if (view->recompute) registers_view_recompute(view); /* cannot update if no active CPU */ - total_cycles = cpu_get_total_cycles(regdata->device); + total_cycles = 0; + if (regdata->subview->execintf != NULL) + total_cycles = regdata->subview->execintf->total_cycles(); /* loop over visible rows */ for (row = 0; row < view->visible.y; row++) @@ -1301,57 +1228,62 @@ static void registers_view_update(debug_view *view) { debug_view_register *reg = ®data->reg[effrow]; UINT32 effcol = view->topleft.x; - char temp[256], dummy[100]; UINT8 attrib = DCA_NORMAL; UINT32 len = 0; - char *data = dummy; + astring valstr; /* get the effective string */ - dummy[0] = 0; - if (reg->regnum >= MAX_REGS) + if (reg->regnum >= REG_FRAME && reg->regnum <= REG_DIVIDER) { reg->lastval = reg->currval; switch (reg->regnum) { - case MAX_REGS: - reg->tagstart = reg->valstart = reg->vallen = 0; - reg->taglen = view->total.x; + case REG_DIVIDER: + reg->vallen = 0; + reg->symbol.reset(); for (i = 0; i < view->total.x; i++) - dummy[i] = '-'; - dummy[i] = 0; + reg->symbol.cat("-"); break; - case MAX_REGS + 1: - sprintf(dummy, "cycles:%-8d", *cpu_get_icount_ptr(regdata->device)); - reg->currval = *cpu_get_icount_ptr(regdata->device); + case REG_CYCLES: + if (regdata->subview->execintf != NULL) + { + reg->currval = regdata->subview->execintf->cycles_remaining(); + valstr.printf("%-8d", (UINT32)reg->currval); + } break; - case MAX_REGS + 2: + case REG_BEAMX: if (screen != NULL) - sprintf(dummy, "beamx:%3d", video_screen_get_hpos(screen)); + { + reg->currval = screen->hpos(); + valstr.printf("%3d", (UINT32)reg->currval); + } break; - case MAX_REGS + 3: + case REG_BEAMY: if (screen != NULL) - sprintf(dummy, "beamy:%3d", video_screen_get_vpos(screen)); + { + reg->currval = screen->vpos(); + valstr.printf("%3d", (UINT32)reg->currval); + } break; - case MAX_REGS + 4: + case REG_FRAME: if (screen != NULL) - sprintf(dummy, "frame:%-6d", (UINT32)video_screen_get_frame_number(screen)); - break; - - case MAX_REGS + 5: - sprintf(dummy, "flags:%s", cpu_get_flags_string(regdata->device)); + { + reg->currval = screen->frame_number(); + valstr.printf("%3d", (UINT32)reg->currval); + } break; } } else { - data = (char *)cpu_get_reg_string(regdata->device, reg->regnum); if (regdata->last_update != total_cycles) reg->lastval = reg->currval; - reg->currval = cpu_get_reg(regdata->device, reg->regnum); + reg->currval = regdata->subview->stateintf->state_value(reg->regnum); + regdata->subview->stateintf->state_string(reg->regnum, valstr); } /* see if we changed */ @@ -1359,19 +1291,20 @@ static void registers_view_update(debug_view *view) attrib = DCA_CHANGED; /* build up a string */ - if (reg->taglen < regdata->divider - 1) + char temp[256]; + if (reg->symbol.len() < regdata->divider - 1) { - memset(&temp[len], ' ', regdata->divider - 1 - reg->taglen); - len += regdata->divider - 1 - reg->taglen; + memset(&temp[len], ' ', regdata->divider - 1 - reg->symbol.len()); + len += regdata->divider - 1 - reg->symbol.len(); } - memcpy(&temp[len], &data[reg->tagstart], reg->taglen); - len += reg->taglen; + memcpy(&temp[len], reg->symbol.cstr(), reg->symbol.len()); + len += reg->symbol.len(); temp[len++] = ' '; temp[len++] = ' '; - memcpy(&temp[len], &data[reg->valstart], reg->vallen); + memcpy(&temp[len], valstr.cstr(), reg->vallen); len += reg->vallen; temp[len++] = ' '; @@ -1431,7 +1364,7 @@ int registers_view_get_subview(debug_view *view) for (subview = view->machine->debugvw_data->registers_subviews; subview != NULL; subview = subview->next) { - if (subview->device == regdata->device) + if (regdata->subview == subview) return index; index++; } @@ -1455,10 +1388,10 @@ void registers_view_set_subview(debug_view *view, int index) return; /* handle a change */ - if (subview->device != regdata->device) + if (regdata->subview != subview) { debug_view_begin_update(view); - regdata->device = subview->device; + regdata->subview = subview; view->recompute = view->update_pending = TRUE; debug_view_end_update(view); } @@ -1482,23 +1415,20 @@ static const disasm_subview_item *disasm_view_enumerate_subviews(running_machine int curindex = 0; /* iterate over CPUs with program address spaces */ - for (running_device *cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) + device_execute_interface *exec; + for (bool gotone = machine->devicelist.first(exec); gotone; gotone = exec->next(exec)) { - const address_space *space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM); - if (space != NULL) - { - disasm_subview_item *subview = auto_alloc(machine, disasm_subview_item); + disasm_subview_item *subview = auto_alloc(machine, disasm_subview_item); - /* populate the subview */ - subview->next = NULL; - subview->index = curindex++; - subview->name.printf("CPU '%s' (%s)", cpu->tag(), cpu->name()); - subview->space = space; + /* populate the subview */ + subview->next = NULL; + subview->index = curindex++; + subview->name.printf("%s '%s'", exec->device().name(), exec->device().tag()); + subview->space = cpu_get_address_space(*exec, ADDRESS_SPACE_PROGRAM); - /* add to the list */ - *tailptr = subview; - tailptr = &subview->next; - } + /* add to the list */ + *tailptr = subview; + tailptr = &subview->next; } return head; @@ -1514,7 +1444,7 @@ static int disasm_view_alloc(debug_view *view) { debug_view_disasm *dasmdata; int total_comments = 0; - running_device *cpu; + device_t *cpu; /* fail if no available subviews */ if (view->machine->debugvw_data->disasm_subviews == NULL) @@ -1663,8 +1593,11 @@ static void disasm_view_char(debug_view *view, int chval) static offs_t disasm_view_find_pc_backwards(const address_space *space, offs_t targetpc, int numinstrs) { - int minlen = memory_byte_to_address(space, cpu_get_min_opcode_bytes(space->cpu)); - int maxlen = memory_byte_to_address(space, cpu_get_max_opcode_bytes(space->cpu)); + cpu_device *cpudevice = downcast(space->cpu); + assert(cpudevice != NULL); + + int minlen = memory_byte_to_address(space, cpudevice->min_opcode_bytes()); + int maxlen = memory_byte_to_address(space, cpudevice->max_opcode_bytes()); offs_t targetpcbyte = memory_address_to_byte(space, targetpc) & space->logbytemask; offs_t lastgoodpc = targetpc; offs_t fillpcbyte, curpc; @@ -1778,8 +1711,10 @@ static int disasm_view_recompute(debug_view *view, offs_t pc, int startline, int dasmdata->divider2 = dasmdata->divider1 + 1 + dasmdata->dasm_width + 1; /* determine how many bytes we might need to display */ - minbytes = cpu_get_min_opcode_bytes(space->cpu); - maxbytes = cpu_get_max_opcode_bytes(space->cpu); + cpu_device *cpudevice = downcast(space->cpu); + assert(cpudevice != NULL); + minbytes = cpudevice->min_opcode_bytes(); + maxbytes = cpudevice->max_opcode_bytes(); /* ensure that the PC is aligned to the minimum opcode size */ pc &= ~memory_byte_to_address_end(space, minbytes - 1); @@ -2353,10 +2288,11 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine int curindex = 0; /* first add all the device's address spaces */ - for (running_device *device = machine->devicelist.first(); device != NULL; device = device->next) + device_memory_interface *memintf; + for (bool gotone = machine->devicelist.first(memintf); gotone; gotone = memintf->next(memintf)) for (int spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - const address_space *space = device->space(spacenum); + const address_space *space = memintf->space(spacenum); if (space != NULL) { memory_subview_item *subview = auto_alloc(machine, memory_subview_item); @@ -2364,10 +2300,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine /* populate the subview */ subview->next = NULL; subview->index = curindex++; - if (device->type == CPU) - subview->name.printf("CPU '%s' (%s) %s memory", device->tag(), device->name(), space->name); - else - subview->name.printf("%s '%s' space #%d memory", device->name(), device->tag(), spacenum); + subview->name.printf("%s '%s' %s space memory", memintf->device().name(), memintf->device().tag(), space->name); subview->space = space; subview->endianness = space->endianness; subview->prefsize = space->dbits / 8; @@ -2379,7 +2312,7 @@ static const memory_subview_item *memory_view_enumerate_subviews(running_machine } /* then add all the memory regions */ - for (const region_info *region = machine->regionlist.first(); region != NULL; region = region->next) + for (const region_info *region = machine->regionlist.first(); region != NULL; region = region->next()) { memory_subview_item *subview = auto_alloc(machine, memory_subview_item); @@ -2823,7 +2756,7 @@ static int memory_view_needs_recompute(debug_view *view) int recompute = view->recompute; /* handle expression changes */ - if (debug_view_expression_changed_value(view, &memdata->expression, (space != NULL && space->cpu != NULL && space->cpu->type == CPU) ? space->cpu : NULL)) + if (debug_view_expression_changed_value(view, &memdata->expression, (space != NULL && space->cpu != NULL && space->cpu->type() == CPU) ? space->cpu : NULL)) { offs_t resultbyte; diff --git a/src/emu/debug/debugvw.h b/src/emu/debug/debugvw.h index 1e4a8a00a28..c133da69f95 100644 --- a/src/emu/debug/debugvw.h +++ b/src/emu/debug/debugvw.h @@ -113,12 +113,14 @@ public: registers_subview_item() : next(NULL), index(0), - device(NULL) { } + stateintf(NULL), + execintf(NULL) { } registers_subview_item *next; /* link to next item */ int index; /* index of this item */ astring name; /* name of the subview item */ - running_device * device; /* device to display */ + device_state_interface *stateintf; /* state interface */ + device_execute_interface *execintf; /* execution interface */ }; diff --git a/src/emu/debugger.h b/src/emu/debugger.h index 625a3e6c793..212e671d5be 100644 --- a/src/emu/debugger.h +++ b/src/emu/debugger.h @@ -43,7 +43,7 @@ void debugger_flush_all_traces_on_abnormal_exit(void); this once per instruction from CPU cores -------------------------------------------------*/ -INLINE void debugger_instruction_hook(running_device *device, offs_t curpc) +INLINE void debugger_instruction_hook(device_t *device, offs_t curpc) { if ((device->machine->debug_flags & DEBUG_FLAG_CALL_HOOK) != 0) debug_cpu_instruction_hook(device, curpc); @@ -55,7 +55,7 @@ INLINE void debugger_instruction_hook(running_device *device, offs_t curpc) anytime an exception is generated -------------------------------------------------*/ -INLINE void debugger_exception_hook(running_device *device, int exception) +INLINE void debugger_exception_hook(device_t *device, int exception) { if ((device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) debug_cpu_exception_hook(device, exception); @@ -73,7 +73,7 @@ INLINE void debugger_exception_hook(running_device *device, int exception) execution for the given CPU -------------------------------------------------*/ -INLINE void debugger_start_cpu_hook(running_device *device, attotime endtime) +INLINE void debugger_start_cpu_hook(device_t *device, attotime endtime) { if ((device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) debug_cpu_start_hook(device, endtime); @@ -86,7 +86,7 @@ INLINE void debugger_start_cpu_hook(running_device *device, attotime endtime) for the given CPU -------------------------------------------------*/ -INLINE void debugger_stop_cpu_hook(running_device *device) +INLINE void debugger_stop_cpu_hook(device_t *device) { if ((device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) debug_cpu_stop_hook(device); @@ -99,7 +99,7 @@ INLINE void debugger_stop_cpu_hook(running_device *device) acknowledged -------------------------------------------------*/ -INLINE void debugger_interrupt_hook(running_device *device, int irqline) +INLINE void debugger_interrupt_hook(device_t *device, int irqline) { if ((device->machine->debug_flags & DEBUG_FLAG_ENABLED) != 0) debug_cpu_interrupt_hook(device, irqline); diff --git a/src/emu/debugint/debugint.c b/src/emu/debugint/debugint.c index ff2eaa69c98..7e9741e0d77 100644 --- a/src/emu/debugint/debugint.c +++ b/src/emu/debugint/debugint.c @@ -1138,7 +1138,7 @@ static void render_editor(DView_edit *editor) /* compute our bounds */ x1 = 0.5f - 0.5f * maxwidth; x2 = x1 + maxwidth; - y1 = 0.25; + y1 = 0.25f; y2 = 0.45f - UI_BOX_TB_BORDER; /* draw a box */ @@ -1389,6 +1389,7 @@ static void handle_menus(running_machine *machine) static void followers_set_cpu(running_device *device) { + device_state_interface *stateintf = device_state(device); const registers_subview_item *regsubitem = NULL; const disasm_subview_item *dasmsubitem; char title[256]; @@ -1411,7 +1412,7 @@ static void followers_set_cpu(running_device *device) break; case DVT_REGISTERS: for (regsubitem = registers_view_get_subview_list(dv->view); regsubitem != NULL; regsubitem = regsubitem->next) - if (regsubitem->device == device) + if (regsubitem->stateintf == stateintf) { registers_view_set_subview(dv->view, regsubitem->index); snprintf(title, ARRAY_LENGTH(title), "%s", regsubitem->name.cstr()); diff --git a/src/emu/deprecat.h b/src/emu/deprecat.h index 943bc28d848..934f38c459b 100644 --- a/src/emu/deprecat.h +++ b/src/emu/deprecat.h @@ -31,9 +31,9 @@ *************************************/ #define MDRV_CPU_VBLANK_INT_HACK(_func, _rate) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt, _func) \ - MDRV_DEVICE_CONFIG_DATAPTR(cpu_config, vblank_interrupt_screen, NULL) \ - MDRV_DEVICE_CONFIG_DATA32(cpu_config, vblank_interrupts_per_frame, _rate) + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIEXEC_VBLANK_INT, 8, _rate, 24), \ + TOKEN_PTR(cpu_interrupt, _func), \ + TOKEN_PTR(stringptr, NULL), \ @@ -48,7 +48,7 @@ handlers to synchronize their operation. If you call this from outside an interrupt handler, add 1 to the result, i.e. if it returns 0, it means that the interrupt handler will be called once. */ -int cpu_getiloops(running_device *device); +#define cpu_getiloops(dev) device_execute(dev)->iloops() diff --git a/src/emu/devcb.c b/src/emu/devcb.c index f989ce66ca4..4e78b674d4a 100644 --- a/src/emu/devcb.c +++ b/src/emu/devcb.c @@ -30,10 +30,10 @@ static READ_LINE_DEVICE_HANDLER( trampoline_read_port_to_read_line ) static READ_LINE_DEVICE_HANDLER( trampoline_read8_to_read_line ) { const devcb_resolved_read_line *resolved = (const devcb_resolved_read_line *)device; - return ((*resolved->real.readdevice)((running_device *)resolved->realtarget, 0) & 1) ? ASSERT_LINE : CLEAR_LINE; + return ((*resolved->real.readdevice)((device_t *)resolved->realtarget, 0) & 1) ? ASSERT_LINE : CLEAR_LINE; } -void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, running_device *device) +void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, device_t *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -51,20 +51,19 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->readspace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - running_device *cpu; - if (device->owner != NULL) - cpu = device->owner->subdevice(config->tag); - else - cpu = device->machine->device(config->tag); + device_t *targetdev = device->siblingdevice(config->tag); + if (targetdev == NULL) + fatalerror("devcb_resolve_read_line: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); + device_memory_interface *memory; + if (!targetdev->interface(memory)) + fatalerror("devcb_resolve_read_line: device '%s' (requested by %s '%s') has no memory", config->tag, device->name(), device->tag()); - if (cpu == NULL) - fatalerror("devcb_resolve_read_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); resolved->target = resolved; resolved->read = trampoline_read8_to_read_line; - resolved->realtarget = cpu->space(spacenum); + resolved->realtarget = device_get_space(targetdev, spacenum); if (resolved->realtarget == NULL) - fatalerror("devcb_resolve_read_line: unable to find CPU '%s' %s space (requested by %s '%s')", config->tag, address_space_names[spacenum], device->name(), device->tag()); + fatalerror("devcb_resolve_read_line: unable to find device '%s' space %d (requested by %s '%s')", config->tag, (int)spacenum, device->name(), device->tag()); resolved->real.readspace = config->readspace; } @@ -74,10 +73,8 @@ void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_rea /* locate the device */ if (config->type == DEVCB_TYPE_SELF) resolved->target = device; - else if (device->owner != NULL) - resolved->target = device->owner->subdevice(config->tag); else - resolved->target = device->machine->device(config->tag); + resolved->target = device->siblingdevice(config->tag); if (resolved->target == NULL) fatalerror("devcb_resolve_read_line: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); @@ -111,17 +108,17 @@ static WRITE_LINE_DEVICE_HANDLER( trampoline_write_port_to_write_line ) static WRITE_LINE_DEVICE_HANDLER( trampoline_write8_to_write_line ) { const devcb_resolved_write_line *resolved = (const devcb_resolved_write_line *)device; - (*resolved->real.writedevice)((running_device *)resolved->realtarget, 0, state); + (*resolved->real.writedevice)((device_t *)resolved->realtarget, 0, state); } static WRITE_LINE_DEVICE_HANDLER( trampoline_writecpu_to_write_line ) { const devcb_resolved_write_line *resolved = (const devcb_resolved_write_line *)device; - running_device *cpu = (running_device *)resolved->realtarget; - cpu_set_input_line(cpu, resolved->real.writeline, state ? ASSERT_LINE : CLEAR_LINE); + device_t *targetdev = (device_t *)resolved->realtarget; + cpu_set_input_line(targetdev, resolved->real.writeline, state ? ASSERT_LINE : CLEAR_LINE); } -void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, running_device *device) +void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, device_t *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -138,20 +135,19 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->writespace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - running_device *cpu; - if (device->owner != NULL) - cpu = device->owner->subdevice(config->tag); - else - cpu = device->machine->device(config->tag); + device_t *targetdev = device->siblingdevice(config->tag); + if (targetdev == NULL) + fatalerror("devcb_resolve_write_line: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); + device_memory_interface *memory; + if (!targetdev->interface(memory)) + fatalerror("devcb_resolve_write_line: device '%s' (requested by %s '%s') has no memory", config->tag, device->name(), device->tag()); - if (cpu == NULL) - fatalerror("devcb_resolve_write_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); resolved->target = resolved; resolved->write = trampoline_write8_to_write_line; - resolved->realtarget = cpu->space(spacenum); + resolved->realtarget = device_get_space(targetdev, spacenum); if (resolved->realtarget == NULL) - fatalerror("devcb_resolve_write_line: unable to find CPU '%s' %s space (requested by %s '%s')", config->tag, address_space_names[spacenum], device->name(), device->tag()); + fatalerror("devcb_resolve_write_line: unable to find device '%s' space %d (requested by %s '%s')", config->tag, (int)spacenum, device->name(), device->tag()); resolved->real.writespace = config->writespace; } @@ -159,18 +155,14 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w else if (config->type >= DEVCB_TYPE_CPU_LINE(0) && config->type < DEVCB_TYPE_CPU_LINE(MAX_INPUT_LINES)) { FPTR line = (FPTR)config->type - (FPTR)DEVCB_TYPE_CPU_LINE(0); - running_device *cpu; - if (device->owner != NULL) - cpu = device->owner->subdevice(config->tag); - else - cpu = device->machine->device(config->tag); + device_t *targetdev = device->siblingdevice(config->tag); + if (targetdev == NULL) + fatalerror("devcb_resolve_write_line: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); - if (cpu == NULL) - fatalerror("devcb_resolve_write_line: unable to find CPU '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); resolved->target = resolved; resolved->write = trampoline_writecpu_to_write_line; - resolved->realtarget = cpu; + resolved->realtarget = targetdev; resolved->real.writeline = (int) line; } @@ -180,10 +172,8 @@ void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_w /* locate the device */ if (config->type == DEVCB_TYPE_SELF) resolved->target = device; - else if (device->owner != NULL) - resolved->target = device->owner->subdevice(config->tag); else - resolved->target = device->machine->device(config->tag); + resolved->target = device->siblingdevice(config->tag); if (resolved->target == NULL) fatalerror("devcb_resolve_write_line: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); @@ -217,10 +207,10 @@ static READ8_DEVICE_HANDLER( trampoline_read_port_to_read8 ) static READ8_DEVICE_HANDLER( trampoline_read_line_to_read8 ) { const devcb_resolved_read8 *resolved = (const devcb_resolved_read8 *)device; - return (*resolved->real.readline)((running_device *)resolved->realtarget); + return (*resolved->real.readline)((device_t *)resolved->realtarget); } -void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, running_device *device) +void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, device_t *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -238,18 +228,17 @@ void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *conf else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->readspace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - running_device *cpu; - if (device->owner != NULL) - cpu = device->owner->subdevice(config->tag); - else - cpu = device->machine->device(config->tag); + device_t *targetdev = device->siblingdevice(config->tag); + if (targetdev == NULL) + fatalerror("devcb_resolve_read8: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); + device_memory_interface *memory; + if (!targetdev->interface(memory)) + fatalerror("devcb_resolve_read8: device '%s' (requested by %s '%s') has no memory", config->tag, device->name(), device->tag()); - if (cpu == NULL) - fatalerror("devcb_resolve_read8: unable to find CPU '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); - resolved->target = cpu->space(spacenum); + resolved->target = device_get_space(targetdev, spacenum); if (resolved->target == NULL) - fatalerror("devcb_resolve_read8: unable to find CPU '%s' %s space (requested by %s '%s')", config->tag, address_space_names[spacenum], device->name(), device->tag()); + fatalerror("devcb_resolve_read8: unable to find device '%s' space %d (requested by %s '%s')", config->tag, (int)spacenum, device->name(), device->tag()); resolved->read = (read8_device_func)config->readspace; } @@ -289,10 +278,10 @@ static WRITE8_DEVICE_HANDLER( trampoline_write_port_to_write8 ) static WRITE8_DEVICE_HANDLER( trampoline_write_line_to_write8 ) { const devcb_resolved_write8 *resolved = (const devcb_resolved_write8 *)device; - (*resolved->real.writeline)((running_device *)resolved->realtarget, (data & 1) ? ASSERT_LINE : CLEAR_LINE); + (*resolved->real.writeline)((device_t *)resolved->realtarget, (data & 1) ? ASSERT_LINE : CLEAR_LINE); } -void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, running_device *device) +void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, device_t *device) { /* reset the resolved structure */ memset(resolved, 0, sizeof(*resolved)); @@ -309,18 +298,17 @@ void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *c else if (config->type >= DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM) && config->type < DEVCB_TYPE_MEMORY(ADDRESS_SPACES) && config->writespace != NULL) { FPTR spacenum = (FPTR)config->type - (FPTR)DEVCB_TYPE_MEMORY(ADDRESS_SPACE_PROGRAM); - running_device *cpu; - if (device->owner != NULL) - cpu = device->owner->subdevice(config->tag); - else - cpu = device->machine->device(config->tag); + device_t *targetdev = device->siblingdevice(config->tag); + if (targetdev == NULL) + fatalerror("devcb_resolve_write8: unable to find device '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); + device_memory_interface *memory; + if (!targetdev->interface(memory)) + fatalerror("devcb_resolve_write8: device '%s' (requested by %s '%s') has no memory", config->tag, device->name(), device->tag()); - if (cpu == NULL) - fatalerror("devcb_resolve_write8: unable to find CPU '%s' (requested by %s '%s')", config->tag, device->name(), device->tag()); - resolved->target = cpu->space(spacenum); + resolved->target = device_get_space(targetdev, spacenum); if (resolved->target == NULL) - fatalerror("devcb_resolve_write8: unable to find CPU '%s' %s space (requested by %s '%s')", config->tag, address_space_names[spacenum], device->name(), device->tag()); + fatalerror("devcb_resolve_write8: unable to find device '%s' space %d (requested by %s '%s')", config->tag, (int)spacenum, device->name(), device->tag()); resolved->write = (write8_device_func)config->writespace; } diff --git a/src/emu/devcb.h b/src/emu/devcb.h index 7e2efefb952..b65e8308754 100644 --- a/src/emu/devcb.h +++ b/src/emu/devcb.h @@ -84,8 +84,8 @@ /* macros for defining read_line/write_line functions */ -#define READ_LINE_DEVICE_HANDLER(name) int name(ATTR_UNUSED running_device *device) -#define WRITE_LINE_DEVICE_HANDLER(name) void name(ATTR_UNUSED running_device *device, ATTR_UNUSED int state) +#define READ_LINE_DEVICE_HANDLER(name) int name(ATTR_UNUSED device_t *device) +#define WRITE_LINE_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED int state) /* macros for inline device handler initialization */ @@ -111,8 +111,8 @@ class device_config; /* read/write types for I/O lines (similar to read/write handlers but no offset) */ -typedef int (*read_line_device_func)(running_device *device); -typedef void (*write_line_device_func)(running_device *device, int state); +typedef int (*read_line_device_func)(device_t *device); +typedef void (*write_line_device_func)(device_t *device, int state); /* static structure used for device configuration when the desired callback type is a read_line_device_func */ @@ -227,16 +227,16 @@ struct _devcb_resolved_write8 /* ----- static-to-live conversion ----- */ /* convert a static read line definition to a live definition */ -void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, running_device *device); +void devcb_resolve_read_line(devcb_resolved_read_line *resolved, const devcb_read_line *config, device_t *device); /* convert a static write line definition to a live definition */ -void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, running_device *device); +void devcb_resolve_write_line(devcb_resolved_write_line *resolved, const devcb_write_line *config, device_t *device); /* convert a static 8-bit read definition to a live definition */ -void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, running_device *device); +void devcb_resolve_read8(devcb_resolved_read8 *resolved, const devcb_read8 *config, device_t *device); /* convert a static 8-bit write definition to a live definition */ -void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, running_device *device); +void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *config, device_t *device); @@ -251,7 +251,7 @@ void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *c INLINE int devcb_call_read_line(const devcb_resolved_read_line *resolved) { - return (resolved->read != NULL) ? (*resolved->read)((running_device *)resolved->target) : 0; + return (resolved->read != NULL) ? (*resolved->read)((device_t *)resolved->target) : 0; } @@ -262,7 +262,7 @@ INLINE int devcb_call_read_line(const devcb_resolved_read_line *resolved) INLINE int devcb_call_read8(const devcb_resolved_read8 *resolved, offs_t offset) { - return (resolved->read != NULL) ? (*resolved->read)((running_device *)resolved->target, offset) : 0; + return (resolved->read != NULL) ? (*resolved->read)((device_t *)resolved->target, offset) : 0; } @@ -274,7 +274,7 @@ INLINE int devcb_call_read8(const devcb_resolved_read8 *resolved, offs_t offset) INLINE void devcb_call_write_line(const devcb_resolved_write_line *resolved, int state) { if (resolved->write != NULL) - (*resolved->write)((running_device *)resolved->target, state); + (*resolved->write)((device_t *)resolved->target, state); } @@ -286,7 +286,7 @@ INLINE void devcb_call_write_line(const devcb_resolved_write_line *resolved, int INLINE void devcb_call_write8(const devcb_resolved_write8 *resolved, offs_t offset, UINT8 data) { if (resolved->write != NULL) - (*resolved->write)((running_device *)resolved->target, offset, data); + (*resolved->write)((device_t *)resolved->target, offset, data); } /*------------------------------------------------- diff --git a/src/emu/devconv.h b/src/emu/devconv.h index 3772194c227..a7b81a27827 100644 --- a/src/emu/devconv.h +++ b/src/emu/devconv.h @@ -85,7 +85,7 @@ * *************************************/ -INLINE UINT16 read16be_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT16 mem_mask) +INLINE UINT16 read16be_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT16 mem_mask) { UINT16 result = 0; if (ACCESSING_BITS_8_15) @@ -96,7 +96,7 @@ INLINE UINT16 read16be_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write16be_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT16 data, UINT16 mem_mask) +INLINE void write16be_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT16 data, UINT16 mem_mask) { if (ACCESSING_BITS_8_15) (*handler)(device, offset * 2 + 0, data >> 8); @@ -111,7 +111,7 @@ INLINE void write16be_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT16 read16le_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT16 mem_mask) +INLINE UINT16 read16le_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT16 mem_mask) { UINT16 result = 0; if (ACCESSING_BITS_0_7) @@ -122,7 +122,7 @@ INLINE UINT16 read16le_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write16le_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT16 data, UINT16 mem_mask) +INLINE void write16le_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT16 data, UINT16 mem_mask) { if (ACCESSING_BITS_0_7) (*handler)(device, offset * 2 + 0, data >> 0); @@ -137,7 +137,7 @@ INLINE void write16le_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT32 read32be_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32be_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; if (ACCESSING_BITS_16_31) @@ -148,7 +148,7 @@ INLINE UINT32 read32be_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write32be_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32be_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { if (ACCESSING_BITS_16_31) write16be_with_write8_device_handler(handler, device, offset * 2 + 0, data >> 16, mem_mask >> 16); @@ -163,7 +163,7 @@ INLINE void write32be_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT32 read32le_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32le_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; if (ACCESSING_BITS_0_15) @@ -174,7 +174,7 @@ INLINE UINT32 read32le_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write32le_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32le_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { if (ACCESSING_BITS_0_15) write16le_with_write8_device_handler(handler, device, offset * 2 + 0, data, mem_mask); @@ -189,7 +189,7 @@ INLINE void write32le_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT32 read32be_with_16be_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32be_with_16be_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; if (ACCESSING_BITS_16_31) @@ -200,7 +200,7 @@ INLINE UINT32 read32be_with_16be_device_handler(read16_device_func handler, runn } -INLINE void write32be_with_16be_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32be_with_16be_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { if (ACCESSING_BITS_16_31) (*handler)(device, offset * 2 + 0, data >> 16, mem_mask >> 16); @@ -215,7 +215,7 @@ INLINE void write32be_with_16be_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read32le_with_16le_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32le_with_16le_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; if (ACCESSING_BITS_0_15) @@ -226,7 +226,7 @@ INLINE UINT32 read32le_with_16le_device_handler(read16_device_func handler, runn } -INLINE void write32le_with_16le_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32le_with_16le_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { if (ACCESSING_BITS_0_15) (*handler)(device, offset * 2 + 0, data, mem_mask); @@ -241,7 +241,7 @@ INLINE void write32le_with_16le_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read32be_with_16le_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32be_with_16le_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; mem_mask = FLIPENDIAN_INT32(mem_mask); @@ -250,7 +250,7 @@ INLINE UINT32 read32be_with_16le_device_handler(read16_device_func handler, runn } -INLINE void write32be_with_16le_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32be_with_16le_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { data = FLIPENDIAN_INT32(data); mem_mask = FLIPENDIAN_INT32(mem_mask); @@ -264,7 +264,7 @@ INLINE void write32be_with_16le_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read32le_with_16be_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT32 mem_mask) +INLINE UINT32 read32le_with_16be_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT32 mem_mask) { UINT32 result = 0; mem_mask = FLIPENDIAN_INT32(mem_mask); @@ -273,7 +273,7 @@ INLINE UINT32 read32le_with_16be_device_handler(read16_device_func handler, runn } -INLINE void write32le_with_16be_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT32 data, UINT32 mem_mask) +INLINE void write32le_with_16be_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT32 data, UINT32 mem_mask) { data = FLIPENDIAN_INT32(data); mem_mask = FLIPENDIAN_INT32(mem_mask); @@ -287,7 +287,7 @@ INLINE void write32le_with_16be_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT64 read64be_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64be_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_32_63) @@ -298,7 +298,7 @@ INLINE UINT64 read64be_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write64be_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64be_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_32_63) write32be_with_write8_device_handler(handler, device, offset * 2 + 0, data >> 32, mem_mask >> 32); @@ -313,7 +313,7 @@ INLINE void write64be_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT64 read64le_with_read8_device_handler(read8_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64le_with_read8_device_handler(read8_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_0_31) @@ -324,7 +324,7 @@ INLINE UINT64 read64le_with_read8_device_handler(read8_device_func handler, runn } -INLINE void write64le_with_write8_device_handler(write8_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64le_with_write8_device_handler(write8_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_0_31) write32le_with_write8_device_handler(handler, device, offset * 2 + 0, data >> 0, mem_mask >> 0); @@ -339,7 +339,7 @@ INLINE void write64le_with_write8_device_handler(write8_device_func handler, run * *************************************/ -INLINE UINT32 read64be_with_16be_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT32 read64be_with_16be_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_32_63) @@ -350,7 +350,7 @@ INLINE UINT32 read64be_with_16be_device_handler(read16_device_func handler, runn } -INLINE void write64be_with_16be_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64be_with_16be_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_32_63) write32be_with_16be_device_handler(handler, device, offset * 2 + 0, data >> 32, mem_mask >> 32); @@ -365,7 +365,7 @@ INLINE void write64be_with_16be_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read64le_with_16le_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT32 read64le_with_16le_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_0_31) @@ -376,7 +376,7 @@ INLINE UINT32 read64le_with_16le_device_handler(read16_device_func handler, runn } -INLINE void write64le_with_16le_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64le_with_16le_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_0_31) write32le_with_16le_device_handler(handler, device, offset * 2 + 0, data >> 0, mem_mask >> 0); @@ -391,7 +391,7 @@ INLINE void write64le_with_16le_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read64be_with_16le_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT32 read64be_with_16le_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_32_63) @@ -402,7 +402,7 @@ INLINE UINT32 read64be_with_16le_device_handler(read16_device_func handler, runn } -INLINE void write64be_with_16le_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64be_with_16le_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_32_63) write32be_with_16le_device_handler(handler, device, offset * 2 + 0, data >> 32, mem_mask >> 32); @@ -417,7 +417,7 @@ INLINE void write64be_with_16le_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT32 read64le_with_16be_device_handler(read16_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT32 read64le_with_16be_device_handler(read16_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_0_31) @@ -428,7 +428,7 @@ INLINE UINT32 read64le_with_16be_device_handler(read16_device_func handler, runn } -INLINE void write64le_with_16be_device_handler(write16_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64le_with_16be_device_handler(write16_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_0_31) write32le_with_16be_device_handler(handler, device, offset * 2 + 0, data >> 0, mem_mask >> 0); @@ -443,7 +443,7 @@ INLINE void write64le_with_16be_device_handler(write16_device_func handler, runn * *************************************/ -INLINE UINT64 read64be_with_32be_device_handler(read32_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64be_with_32be_device_handler(read32_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_32_63) @@ -454,7 +454,7 @@ INLINE UINT64 read64be_with_32be_device_handler(read32_device_func handler, runn } -INLINE void write64be_with_32be_device_handler(write32_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64be_with_32be_device_handler(write32_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_32_63) (*handler)(device, offset * 2 + 0, data >> 32, mem_mask >> 32); @@ -469,7 +469,7 @@ INLINE void write64be_with_32be_device_handler(write32_device_func handler, runn * *************************************/ -INLINE UINT64 read64le_with_32le_device_handler(read32_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64le_with_32le_device_handler(read32_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result = 0; if (ACCESSING_BITS_0_31) @@ -480,7 +480,7 @@ INLINE UINT64 read64le_with_32le_device_handler(read32_device_func handler, runn } -INLINE void write64le_with_32le_device_handler(write32_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64le_with_32le_device_handler(write32_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { if (ACCESSING_BITS_0_31) (*handler)(device, offset * 2 + 0, data >> 0, mem_mask >> 0); @@ -495,7 +495,7 @@ INLINE void write64le_with_32le_device_handler(write32_device_func handler, runn * *************************************/ -INLINE UINT64 read64be_with_32le_device_handler(read32_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64be_with_32le_device_handler(read32_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result; mem_mask = FLIPENDIAN_INT64(mem_mask); @@ -504,7 +504,7 @@ INLINE UINT64 read64be_with_32le_device_handler(read32_device_func handler, runn } -INLINE void write64be_with_32le_device_handler(write32_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64be_with_32le_device_handler(write32_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { data = FLIPENDIAN_INT64(data); mem_mask = FLIPENDIAN_INT64(mem_mask); @@ -518,7 +518,7 @@ INLINE void write64be_with_32le_device_handler(write32_device_func handler, runn * *************************************/ -INLINE UINT64 read64le_with_32be_device_handler(read32_device_func handler, running_device *device, offs_t offset, UINT64 mem_mask) +INLINE UINT64 read64le_with_32be_device_handler(read32_device_func handler, device_t *device, offs_t offset, UINT64 mem_mask) { UINT64 result; mem_mask = FLIPENDIAN_INT64(mem_mask); @@ -527,7 +527,7 @@ INLINE UINT64 read64le_with_32be_device_handler(read32_device_func handler, runn } -INLINE void write64le_with_32be_device_handler(write32_device_func handler, running_device *device, offs_t offset, UINT64 data, UINT64 mem_mask) +INLINE void write64le_with_32be_device_handler(write32_device_func handler, device_t *device, offs_t offset, UINT64 data, UINT64 mem_mask) { data = FLIPENDIAN_INT64(data); mem_mask = FLIPENDIAN_INT64(mem_mask); diff --git a/src/emu/devcpu.c b/src/emu/devcpu.c new file mode 100644 index 00000000000..b3a7b2b8458 --- /dev/null +++ b/src/emu/devcpu.c @@ -0,0 +1,550 @@ +/*************************************************************************** + + devcpu.c + + CPU device definitions. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "debugger.h" + + +//************************************************************************** +// CPU DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// cpu_device_config - constructor +//------------------------------------------------- + +cpu_device_config::cpu_device_config(const machine_config &mconfig, device_type _type, const char *_tag, const device_config *_owner, UINT32 _clock) + : device_config(mconfig, _type, _tag, _owner, _clock), + device_config_execute_interface(mconfig, *this), + device_config_memory_interface(mconfig, *this), + device_config_state_interface(mconfig, *this), + device_config_disasm_interface(mconfig, *this), + m_cputype(NULL) +{ + memset(m_space_config, 0, sizeof(m_space_config)); +} + + +//------------------------------------------------- +// static_alloc_device_config - static allocator +//------------------------------------------------- + +device_config *cpu_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(cpu_device_config(mconfig, static_alloc_device_config, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a device based on the +// provided configuration +//------------------------------------------------- + +device_t *cpu_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, cpu_device(machine, *this)); +} + + +//------------------------------------------------- +// device_process_token - custom inline +// config callback for populating class data +//------------------------------------------------- + +bool cpu_device_config::device_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + switch (entrytype) + { + // custom config 1 is the CPU type + case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1: + m_cputype = TOKEN_GET_PTR(tokens, cputype); + + // build up our address spaces; legacy devices don't have logical spaces + memset(m_space_config, 0, sizeof(m_space_config)); + for (int spacenum = 0; spacenum < ARRAY_LENGTH(m_space_config); spacenum++) + { + m_space_config[spacenum].m_name = (spacenum == 1) ? "data" : (spacenum == 2) ? "i/o" : "program"; + m_space_config[spacenum].m_endianness = static_cast(get_legacy_config_int(DEVINFO_INT_ENDIANNESS)); + m_space_config[spacenum].m_databus_width = get_legacy_config_int(DEVINFO_INT_DATABUS_WIDTH + spacenum); + m_space_config[spacenum].m_addrbus_width = get_legacy_config_int(DEVINFO_INT_ADDRBUS_WIDTH + spacenum); + m_space_config[spacenum].m_addrbus_shift = get_legacy_config_int(DEVINFO_INT_ADDRBUS_SHIFT + spacenum); + m_space_config[spacenum].m_logaddr_width = get_legacy_config_int(CPUINFO_INT_LOGADDR_WIDTH + spacenum); + m_space_config[spacenum].m_page_shift = get_legacy_config_int(CPUINFO_INT_PAGE_SHIFT + spacenum); + m_space_config[spacenum].m_internal_map = reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum)); + m_space_config[spacenum].m_default_map = reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum)); + } + return true; + } + + // everything else goes to our parent + return device_config::device_process_token(entrytype, tokens); +} + + +//------------------------------------------------- +// execute_clocks_to_cycles - convert the raw +// clock into cycles per second +//------------------------------------------------- + +UINT32 cpu_device_config::execute_clocks_to_cycles(UINT32 clocks) const +{ + UINT32 multiplier = get_legacy_config_int(CPUINFO_INT_CLOCK_MULTIPLIER); + UINT32 divider = get_legacy_config_int(CPUINFO_INT_CLOCK_DIVIDER); + + if (multiplier == 0) multiplier = 1; + if (divider == 0) divider = 1; + + return (clocks * multiplier + divider - 1) / divider; +} + + +//------------------------------------------------- +// execute_cycles_to_clocks - convert a cycle +// count back to raw clocks +//------------------------------------------------- + +UINT32 cpu_device_config::execute_cycles_to_clocks(UINT32 cycles) const +{ + UINT32 multiplier = get_legacy_config_int(CPUINFO_INT_CLOCK_MULTIPLIER); + UINT32 divider = get_legacy_config_int(CPUINFO_INT_CLOCK_DIVIDER); + + if (multiplier == 0) multiplier = 1; + if (divider == 0) divider = 1; + + return (cycles * divider + multiplier - 1) / multiplier; +} + + +//------------------------------------------------- +// get_legacy_config_int - return a legacy +// integer value +//------------------------------------------------- + +INT64 cpu_device_config::get_legacy_config_int(UINT32 state) const +{ + cpuinfo info = { 0 }; + (*m_cputype)(this, NULL, state, &info); + return info.i; +} + + +//------------------------------------------------- +// get_legacy_config_ptr - return a legacy +// pointer value +//------------------------------------------------- + +void *cpu_device_config::get_legacy_config_ptr(UINT32 state) const +{ + cpuinfo info = { 0 }; + (*m_cputype)(this, NULL, state, &info); + return info.p; +} + + +//------------------------------------------------- +// get_legacy_config_fct - return a legacy +// function value +//------------------------------------------------- + +genf *cpu_device_config::get_legacy_config_fct(UINT32 state) const +{ + cpuinfo info = { 0 }; + (*m_cputype)(this, NULL, state, &info); + return info.f; +} + + +//------------------------------------------------- +// get_legacy_config_string - return a legacy +// string value +//------------------------------------------------- + +const char *cpu_device_config::get_legacy_config_string(UINT32 state) const +{ + cpuinfo info; + info.s = get_temp_string_buffer(); + (*m_cputype)(this, NULL, state, &info); + return info.s; +} + + + +//************************************************************************** +// CPU RUNNING DEVICE +//************************************************************************** + +//------------------------------------------------- +// cpu_device - constructor +//------------------------------------------------- + +cpu_device::cpu_device(running_machine &machine, const cpu_device_config &config) + : device_t(machine, config), + device_execute_interface(machine, config, *this), + device_memory_interface(machine, config, *this), + device_state_interface(machine, config, *this), + device_disasm_interface(machine, config, *this), + m_debug(NULL), + m_cpu_config(config), + m_token(NULL), + m_set_info(NULL), + m_execute(NULL), + m_using_legacy_state(false) +{ + memset(&m_partial_frame_period, 0, sizeof(m_partial_frame_period)); + + // pre-fetch function pointers for frequently-called functions + m_set_info = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_SET_INFO)); + m_execute = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_EXECUTE)); + m_burn = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_BURN)); + m_translate = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_TRANSLATE)); + m_read = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_READ)); + m_write = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_WRITE)); + m_readop = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_READOP)); + m_disassemble = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_DISASSEMBLE)); + m_state_import = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_IMPORT_STATE)); + m_state_export = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_EXPORT_STATE)); + m_string_export = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_EXPORT_STRING)); + + int tokenbytes = m_cpu_config.get_legacy_config_int(CPUINFO_INT_CONTEXT_SIZE); + if (tokenbytes == 0) + throw emu_fatalerror("Device %s specifies a 0 context size!\n", tag()); + + // allocate memory for the token + m_token = auto_alloc_array_clear(&machine, UINT8, tokenbytes); +} + + +//------------------------------------------------- +// cpu_device - destructor +//------------------------------------------------- + +cpu_device::~cpu_device() +{ + // call the CPU's exit function if present + cpu_exit_func exit = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_EXIT)); + if (exit != NULL) + (*exit)(this); +} + + +//------------------------------------------------- +// device_start - start up the device +//------------------------------------------------- + +void cpu_device::device_start() +{ + // standard init + cpu_init_func init = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_INIT)); + (*init)(this, static_standard_irq_callback); + + // fetch information about the CPU states + if (m_state_list == NULL) + { + m_using_legacy_state = true; + for (int index = 0; index < MAX_REGS; index++) + { + const char *string = get_legacy_runtime_string(CPUINFO_STR_REGISTER + index); + if (strchr(string, ':') != NULL) + { + astring tempstr(string); + bool noshow = (tempstr.chr(0, '~') == 0); + if (noshow) + tempstr.substr(1, -1); + + int colon = tempstr.chr(0, ':'); + int length = tempstr.len() - colon - 1; + tempstr.substr(0, colon); + + astring formatstr; + formatstr.printf("%%%ds", length); + device_state_entry &entry = state_add(index, tempstr, m_state_io).callimport().callexport().formatstr(formatstr); + if (noshow) + entry.noshow(); + } + } + state_add(STATE_GENPC, "curpc", m_state_io).callimport().callexport().formatstr("%8s").noshow(); + + const char *string = get_legacy_runtime_string(CPUINFO_STR_FLAGS); + if (string != NULL) + { + astring flagstr; + flagstr.printf("%%%ds", strlen(string)); + state_add(STATE_GENFLAGS, "GENFLAGS", m_state_io).callimport().callexport().formatstr(flagstr).noshow(); + } + } + + // get our icount pointer + m_icount = reinterpret_cast(get_legacy_runtime_ptr(CPUINFO_PTR_INSTRUCTION_COUNTER)); +} + + +//------------------------------------------------- +// device_reset - reset up the device +//------------------------------------------------- + +void cpu_device::device_reset() +{ + cpu_reset_func reset = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_RESET)); + if (reset != NULL) + (*reset)(this); +} + + +//------------------------------------------------- +// execute - execute for the provided number of +// cycles +//------------------------------------------------- + +INT32 cpu_device::execute_run(INT32 cycles) +{ + return (*m_execute)(this, cycles); +} + + +//------------------------------------------------- +// execute_burn - burn the requested number of cycles +//------------------------------------------------- + +void cpu_device::execute_burn(INT32 cycles) +{ + if (m_burn != NULL) + (*m_burn)(this, cycles); +} + + +//------------------------------------------------- +// memory_translate - perform address translation +// on the provided address +//------------------------------------------------- + +bool cpu_device::memory_translate(int spacenum, int intention, offs_t &address) +{ + if (m_translate != NULL) + return (*m_translate)(this, spacenum, intention, &address) ? true : false; + return true; +} + + +//------------------------------------------------- +// memory_read - read device memory, allowing for +// device specific overrides +//------------------------------------------------- + +bool cpu_device::memory_read(int spacenum, offs_t offset, int size, UINT64 &value) +{ + if (m_read != NULL) + return (*m_read)(this, spacenum, offset, size, &value) ? true : false; + return false; +} + + +//------------------------------------------------- +// memory_write - write device memory, allowing +// for device specific overrides +//------------------------------------------------- + +bool cpu_device::memory_write(int spacenum, offs_t offset, int size, UINT64 value) +{ + if (m_write != NULL) + return (*m_write)(this, spacenum, offset, size, value) ? true : false; + return false; +} + + +//------------------------------------------------- +// memory_read - read device opcode memory, +// allowing for device specific overrides +//------------------------------------------------- + +bool cpu_device::memory_readop(offs_t offset, int size, UINT64 &value) +{ + if (m_readop != NULL) + return (*m_readop)(this, offset, size, &value) ? true : false; + return false; +} + + +//------------------------------------------------- +// debug_setup - set up any device-specific +// debugging commands or state +//------------------------------------------------- + +void cpu_device::device_debug_setup() +{ + cpu_debug_init_func init = reinterpret_cast(m_cpu_config.get_legacy_config_fct(CPUINFO_FCT_DEBUG_INIT)); + if (init != NULL) + (*init)(this); +} + + +//------------------------------------------------- +// disassemble - disassemble the provided opcode +// data to a buffer +//------------------------------------------------- + +offs_t cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) +{ + // if we have a callback, just use that + if (m_disassemble != NULL) + return (*m_disassemble)(this, buffer, pc, oprom, opram, options); + + // if not, just output vanilla bytes + int width = min_opcode_bytes(); + switch (width) + { + case 1: + default: + sprintf(buffer, "$%02X", *(UINT8 *)oprom); + break; + + case 2: + sprintf(buffer, "$%04X", *(UINT16 *)oprom); + break; + + case 4: + sprintf(buffer, "$%08X", *(UINT32 *)oprom); + break; + + case 8: + sprintf(buffer, "$%08X%08X", (UINT32)(*(UINT64 *)oprom >> 32), (UINT32)(*(UINT64 *)oprom >> 0)); + break; + } + return width; +} + + +//------------------------------------------------- +// get_legacy_runtime_int - call the get info +// function to retrieve an integer value +//------------------------------------------------- + +INT64 cpu_device::get_legacy_runtime_int(UINT32 state) +{ + cpuinfo info = { 0 }; + (*m_cpu_config.m_cputype)(&m_cpu_config, this, state, &info); + return info.i; +} + + +//------------------------------------------------- +// get_legacy_runtime_ptr - call the get info +// function to retrieve a pointer value +//------------------------------------------------- + +void *cpu_device::get_legacy_runtime_ptr(UINT32 state) +{ + cpuinfo info = { 0 }; + (*m_cpu_config.m_cputype)(&m_cpu_config, this, state, &info); + return info.p; +} + + +//------------------------------------------------- +// get_legacy_runtime_string - call the get info +// function to retrieve a string value +//------------------------------------------------- + +const char *cpu_device::get_legacy_runtime_string(UINT32 state) +{ + cpuinfo info; + info.s = get_temp_string_buffer(); + (*m_cpu_config.m_cputype)(&m_cpu_config, this, state, &info); + return info.s; +} + + +//------------------------------------------------- +// set_legacy_runtime_int - call the get info +// function to set an integer value +//------------------------------------------------- + +void cpu_device::set_legacy_runtime_int(UINT32 state, INT64 value) +{ + cpuinfo info = { 0 }; + info.i = value; + (*m_set_info)(this, state, &info); +} + + + +void cpu_device::state_import(const device_state_entry &entry) +{ + if (m_using_legacy_state) + { + if (entry.index() == STATE_GENFLAGS) + ; // do nothing + else + set_legacy_runtime_int(CPUINFO_INT_REGISTER + entry.index(), m_state_io); + } + else if (m_state_import != NULL) + (*m_state_import)(this, entry); +} + + +void cpu_device::state_export(const device_state_entry &entry) +{ + if (m_using_legacy_state) + { + if (entry.index() == STATE_GENFLAGS) + { + const char *temp = get_legacy_runtime_string(CPUINFO_STR_FLAGS); + m_state_io = 0; + while (*temp != 0) + m_state_io = ((m_state_io << 5) | (m_state_io >> (64-5))) ^ *temp++; + } + else + m_state_io = get_legacy_runtime_int(CPUINFO_INT_REGISTER + entry.index()); + } + else if (m_state_export != NULL) + (*m_state_export)(this, entry); +} + + +void cpu_device::state_string_export(const device_state_entry &entry, astring &string) +{ + if (m_using_legacy_state) + { + if (entry.index() == STATE_GENFLAGS) + string.cpy(get_legacy_runtime_string(CPUINFO_STR_FLAGS)); + else + string.cpy(strchr(get_legacy_runtime_string(CPUINFO_STR_REGISTER + entry.index()), ':') + 1); + } + else if (m_string_export != NULL) + (*m_string_export)(this, entry, string); +} diff --git a/src/emu/devcpu.h b/src/emu/devcpu.h new file mode 100644 index 00000000000..51f70643f60 --- /dev/null +++ b/src/emu/devcpu.h @@ -0,0 +1,557 @@ +/*************************************************************************** + + devcpu.h + + CPU device definitions. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DEVCPU_H__ +#define __DEVCPU_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// alternate address space names for common use +enum +{ + ADDRESS_SPACE_PROGRAM = ADDRESS_SPACE_0, // program address space + ADDRESS_SPACE_DATA = ADDRESS_SPACE_1, // data address space + ADDRESS_SPACE_IO = ADDRESS_SPACE_2 // I/O address space +}; + +// CPU information constants +const int MAX_REGS = 256; +enum +{ + // --- the following bits of info are returned as 64-bit signed integers --- + CPUINFO_INT_FIRST = DEVINFO_INT_FIRST, + + // CPU-specific additionsg + CPUINFO_INT_CONTEXT_SIZE = DEVINFO_INT_CLASS_SPECIFIC, // R/O: size of CPU context in bytes + CPUINFO_INT_INPUT_LINES, // R/O: number of input lines + CPUINFO_INT_DEFAULT_IRQ_VECTOR, // R/O: default IRQ vector + CPUINFO_INT_CLOCK_MULTIPLIER, // R/O: internal clock multiplier + CPUINFO_INT_CLOCK_DIVIDER, // R/O: internal clock divider + CPUINFO_INT_MIN_INSTRUCTION_BYTES, // R/O: minimum bytes per instruction + CPUINFO_INT_MAX_INSTRUCTION_BYTES, // R/O: maximum bytes per instruction + CPUINFO_INT_MIN_CYCLES, // R/O: minimum cycles for a single instruction + CPUINFO_INT_MAX_CYCLES, // R/O: maximum cycles for a single instruction + + CPUINFO_INT_LOGADDR_WIDTH, // R/O: address bus size for logical accesses in each space (0=same as physical) + CPUINFO_INT_LOGADDR_WIDTH_PROGRAM = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_PROGRAM, + CPUINFO_INT_LOGADDR_WIDTH_DATA = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_DATA, + CPUINFO_INT_LOGADDR_WIDTH_IO = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_IO, + CPUINFO_INT_LOGADDR_WIDTH_LAST = CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACES - 1, + CPUINFO_INT_PAGE_SHIFT, // R/O: size of a page log 2 (i.e., 12=4096), or 0 if paging not supported + CPUINFO_INT_PAGE_SHIFT_PROGRAM = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_PROGRAM, + CPUINFO_INT_PAGE_SHIFT_DATA = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_DATA, + CPUINFO_INT_PAGE_SHIFT_IO = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_IO, + CPUINFO_INT_PAGE_SHIFT_LAST = CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACES - 1, + + CPUINFO_INT_INPUT_STATE, // R/W: states for each input line + CPUINFO_INT_INPUT_STATE_LAST = CPUINFO_INT_INPUT_STATE + MAX_INPUT_LINES - 1, + CPUINFO_INT_REGISTER = CPUINFO_INT_INPUT_STATE_LAST + 10, // R/W: values of up to MAX_REGs registers + CPUINFO_INT_SP = CPUINFO_INT_REGISTER + STATE_GENSP, // R/W: the current stack pointer value + CPUINFO_INT_PC = CPUINFO_INT_REGISTER + STATE_GENPC, // R/W: the current PC value + CPUINFO_INT_PREVIOUSPC = CPUINFO_INT_REGISTER + STATE_GENPCBASE, // R/W: the previous PC value + CPUINFO_INT_REGISTER_LAST = CPUINFO_INT_REGISTER + MAX_REGS - 1, + + CPUINFO_INT_CPU_SPECIFIC = 0x08000, // R/W: CPU-specific values start here + + // --- the following bits of info are returned as pointers to data or functions --- + CPUINFO_PTR_FIRST = DEVINFO_PTR_FIRST, + + // CPU-specific additions + CPUINFO_PTR_INSTRUCTION_COUNTER = DEVINFO_PTR_CLASS_SPECIFIC, + // R/O: int *icount + + CPUINFO_PTR_CPU_SPECIFIC = DEVINFO_PTR_DEVICE_SPECIFIC, // R/W: CPU-specific values start here + + // --- the following bits of info are returned as pointers to functions --- + CPUINFO_FCT_FIRST = DEVINFO_FCT_FIRST, + + // CPU-specific additions + CPUINFO_FCT_SET_INFO = DEVINFO_FCT_CLASS_SPECIFIC, // R/O: void (*set_info)(device_t *device, UINT32 state, INT64 data, void *ptr) + CPUINFO_FCT_INIT, // R/O: void (*init)(device_t *device, int index, int clock, int (*irqcallback)(device_t *device, int)) + CPUINFO_FCT_RESET, // R/O: void (*reset)(device_t *device) + CPUINFO_FCT_EXIT, // R/O: void (*exit)(device_t *device) + CPUINFO_FCT_EXECUTE, // R/O: int (*execute)(device_t *device, int cycles) + CPUINFO_FCT_BURN, // R/O: void (*burn)(device_t *device, int cycles) + CPUINFO_FCT_DISASSEMBLE, // R/O: offs_t (*disassemble)(device_t *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) + CPUINFO_FCT_TRANSLATE, // R/O: int (*translate)(device_t *device, int space, int intention, offs_t *address) + CPUINFO_FCT_READ, // R/O: int (*read)(device_t *device, int space, UINT32 offset, int size, UINT64 *value) + CPUINFO_FCT_WRITE, // R/O: int (*write)(device_t *device, int space, UINT32 offset, int size, UINT64 value) + CPUINFO_FCT_READOP, // R/O: int (*readop)(device_t *device, UINT32 offset, int size, UINT64 *value) + CPUINFO_FCT_DEBUG_INIT, // R/O: void (*debug_init)(device_t *device) + CPUINFO_FCT_IMPORT_STATE, // R/O: void (*import_state)(device_t *device, void *baseptr, const cpu_state_entry *entry) + CPUINFO_FCT_EXPORT_STATE, // R/O: void (*export_state)(device_t *device, void *baseptr, const cpu_state_entry *entry) + CPUINFO_FCT_IMPORT_STRING, // R/O: void (*import_string)(device_t *device, void *baseptr, const cpu_state_entry *entry, const char *format, char *string) + CPUINFO_FCT_EXPORT_STRING, // R/O: void (*export_string)(device_t *device, void *baseptr, const cpu_state_entry *entry, const char *format, char *string) + + CPUINFO_FCT_CPU_SPECIFIC = DEVINFO_FCT_DEVICE_SPECIFIC, // R/W: CPU-specific values start here + + // --- the following bits of info are returned as NULL-terminated strings --- + CPUINFO_STR_FIRST = DEVINFO_STR_FIRST, + + // CPU-specific additions + CPUINFO_STR_REGISTER = DEVINFO_STR_CLASS_SPECIFIC + 10, // R/O: string representation of up to MAX_REGs registers + CPUINFO_STR_FLAGS = CPUINFO_STR_REGISTER + STATE_GENFLAGS, // R/O: string representation of the main flags value + CPUINFO_STR_REGISTER_LAST = CPUINFO_STR_REGISTER + MAX_REGS - 1, + + CPUINFO_STR_CPU_SPECIFIC = DEVINFO_STR_DEVICE_SPECIFIC // R/W: CPU-specific values start here +}; + + + +//************************************************************************** +// CPU DEVICE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_CPU_ADD(_tag, _type, _clock) \ + MDRV_DEVICE_ADD(_tag, CPU, _clock) \ + MDRV_CPU_TYPE(_type) + +#define MDRV_CPU_MODIFY(_tag) \ + MDRV_DEVICE_MODIFY(_tag) + +#define MDRV_CPU_TYPE(_type) \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1, 8), \ + TOKEN_PTR(cputype, CPU_##_type), \ + +#define MDRV_CPU_REPLACE(_tag, _type, _clock) \ + MDRV_DEVICE_REPLACE(_tag, CPU, _clock) \ + MDRV_CPU_TYPE(_type) + +#define MDRV_CPU_CLOCK MDRV_DEVICE_CLOCK +#define MDRV_CPU_CONFIG MDRV_DEVICE_CONFIG + +#define MDRV_CPU_PROGRAM_MAP MDRV_DEVICE_PROGRAM_MAP +#define MDRV_CPU_DATA_MAP MDRV_DEVICE_DATA_MAP +#define MDRV_CPU_IO_MAP MDRV_DEVICE_IO_MAP + +#define MDRV_CPU_VBLANK_INT MDRV_DEVICE_VBLANK_INT +#define MDRV_CPU_PERIODIC_INT MDRV_DEVICE_PERIODIC_INT + + + +//************************************************************************** +// MACROS +//************************************************************************** + +// device iteration helpers +#define cpu_count(config) (config)->devicelist.count(CPU) +#define cpu_first(config) (config)->devicelist.first(CPU) +#define cpu_next(previous) (previous)->typenext() +#define cpu_get_index(cpu) (cpu)->machine->devicelist.index(CPU, (cpu)->tag()) + + +// CPU interface functions +#define CPU_GET_INFO_NAME(name) cpu_get_info_##name +#define CPU_GET_INFO(name) void CPU_GET_INFO_NAME(name)(const device_config *devconfig, device_t *device, UINT32 state, cpuinfo *info) +#define CPU_GET_INFO_CALL(name) CPU_GET_INFO_NAME(name)(devconfig, device, state, info) + +#define CPU_SET_INFO_NAME(name) cpu_set_info_##name +#define CPU_SET_INFO(name) void CPU_SET_INFO_NAME(name)(device_t *device, UINT32 state, cpuinfo *info) +#define CPU_SET_INFO_CALL(name) CPU_SET_INFO_NAME(name)(device, state, info) + +#define CPU_INIT_NAME(name) cpu_init_##name +#define CPU_INIT(name) void CPU_INIT_NAME(name)(device_t *device, device_irq_callback irqcallback) +#define CPU_INIT_CALL(name) CPU_INIT_NAME(name)(device, irqcallback) + +#define CPU_RESET_NAME(name) cpu_reset_##name +#define CPU_RESET(name) void CPU_RESET_NAME(name)(device_t *device) +#define CPU_RESET_CALL(name) CPU_RESET_NAME(name)(device) + +#define CPU_EXIT_NAME(name) cpu_exit_##name +#define CPU_EXIT(name) void CPU_EXIT_NAME(name)(device_t *device) +#define CPU_EXIT_CALL(name) CPU_EXIT_NAME(name)(device) + +#define CPU_EXECUTE_NAME(name) cpu_execute_##name +#define CPU_EXECUTE(name) int CPU_EXECUTE_NAME(name)(device_t *device, int cycles) +#define CPU_EXECUTE_CALL(name) CPU_EXECUTE_NAME(name)(device, cycles) + +#define CPU_BURN_NAME(name) cpu_burn_##name +#define CPU_BURN(name) void CPU_BURN_NAME(name)(device_t *device, int cycles) +#define CPU_BURN_CALL(name) CPU_BURN_NAME(name)(device, cycles) + +#define CPU_TRANSLATE_NAME(name) cpu_translate_##name +#define CPU_TRANSLATE(name) int CPU_TRANSLATE_NAME(name)(device_t *device, int space, int intention, offs_t *address) +#define CPU_TRANSLATE_CALL(name) CPU_TRANSLATE_NAME(name)(device, space, intention, address) + +#define CPU_READ_NAME(name) cpu_read_##name +#define CPU_READ(name) int CPU_READ_NAME(name)(device_t *device, int space, UINT32 offset, int size, UINT64 *value) +#define CPU_READ_CALL(name) CPU_READ_NAME(name)(device, space, offset, size, value) + +#define CPU_WRITE_NAME(name) cpu_write_##name +#define CPU_WRITE(name) int CPU_WRITE_NAME(name)(device_t *device, int space, UINT32 offset, int size, UINT64 value) +#define CPU_WRITE_CALL(name) CPU_WRITE_NAME(name)(device, space, offset, size, value) + +#define CPU_READOP_NAME(name) cpu_readop_##name +#define CPU_READOP(name) int CPU_READOP_NAME(name)(device_t *device, UINT32 offset, int size, UINT64 *value) +#define CPU_READOP_CALL(name) CPU_READOP_NAME(name)(device, offset, size, value) + +#define CPU_DEBUG_INIT_NAME(name) cpu_debug_init_##name +#define CPU_DEBUG_INIT(name) void CPU_DEBUG_INIT_NAME(name)(device_t *device) +#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)(device) + +#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name +#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(device_t *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) +#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram, options) + +#define CPU_IMPORT_STATE_NAME(name) cpu_state_import_##name +#define CPU_IMPORT_STATE(name) void CPU_IMPORT_STATE_NAME(name)(device_t *device, const device_state_entry &entry) +#define CPU_IMPORT_STATE_CALL(name) CPU_IMPORT_STATE_NAME(name)(device, entry) + +#define CPU_EXPORT_STATE_NAME(name) cpu_state_export_##name +#define CPU_EXPORT_STATE(name) void CPU_EXPORT_STATE_NAME(name)(device_t *device, const device_state_entry &entry) +#define CPU_EXPORT_STATE_CALL(name) CPU_EXPORT_STATE_NAME(name)(device, entry) + +#define CPU_EXPORT_STRING_NAME(name) cpu_string_export_##name +#define CPU_EXPORT_STRING(name) void CPU_EXPORT_STRING_NAME(name)(device_t *device, const device_state_entry &entry, astring &string) +#define CPU_EXPORT_STRING_CALL(name) CPU_EXPORT_STRING_NAME(name)(device, entry, string) + + +// helpers for accessing common CPU state + +// CPU scheduling +#define cpu_suspend device_suspend +#define cpu_resume device_resume +#define cpu_is_executing device_is_executing +#define cpu_is_suspended device_is_suspended + +// synchronization helpers +#define cpu_yield device_yield +#define cpu_spin device_spin +#define cpu_spinuntil_trigger device_spin_until_trigger +#define cpu_spinuntil_time device_spin_until_time +#define cpu_spinuntil_int device_spin_until_interrupt + +// CPU clock management +#define cpu_get_clock device_get_clock +#define cpu_set_clock device_set_clock +#define cpu_get_clockscale device_get_clock_scale +#define cpu_set_clockscale device_set_clock_scale +#define cpu_clocks_to_attotime device_clocks_to_attotime +#define cpu_attotime_to_clocks device_attotime_to_clocks + +// CPU timing +#define cpu_get_local_time device_get_local_time +#define cpu_get_total_cycles device_get_total_cycles +#define cpu_eat_cycles device_eat_cycles +#define cpu_adjust_icount device_adjust_icount +#define cpu_abort_timeslice device_abort_timeslice + +#define cpu_triggerint device_triggerint +#define cpu_set_input_line device_set_input_line +#define cpu_set_input_line_vector device_set_input_line_vector +#define cpu_set_input_line_and_vector device_set_input_line_and_vector +#define cpu_set_irq_callback device_set_irq_callback +#define cpu_spin_until_int device_spin_until_int + +#define cpu_get_address_space device_get_space + +#define cpu_get_reg(cpu, _reg) device_state(cpu)->state_value(_reg) +#define cpu_get_previouspc(cpu) ((offs_t)device_state(cpu)->state_value(STATE_GENPCBASE)) +#define cpu_get_pc(cpu) ((offs_t)device_state(cpu)->state_value(STATE_GENPC)) +#define cpu_get_sp(cpu) ((offs_t)device_state(cpu)->state_value(STATE_GENSP)) + +#define cpu_set_reg(cpu, _reg, val) device_state(cpu)->state_set_value(_reg, val) + +#define INTERRUPT_GEN(func) void func(device_t *device) + +// helpers for using machine/cputag instead of cpu objects +#define cputag_get_address_space(mach, tag, spc) downcast((mach)->device(tag))->space(spc) +#define cputag_get_clock(mach, tag) (mach)->device(tag)->unscaled_clock() +#define cputag_set_clock(mach, tag, clock) (mach)->device(tag)->set_unscaled_clock(clock) +#define cputag_clocks_to_attotime(mach, tag, clocks) (mach)->device(tag)->clocks_to_attotime(clocks) +#define cputag_attotime_to_clocks(mach, tag, duration) (mach)->device(tag)->attotime_to_clocks(duration) + +#define cputag_suspend(mach, tag, reason, eat) device_suspend((mach)->device(tag), reason, eat) +#define cputag_resume(mach, tag, reason) device_resume((mach)->device(tag), reason) +#define cputag_is_suspended(mach, tag, reason) device_is_suspended((mach)->device(tag), reason) +#define cputag_get_total_cycles(mach, tag) device_get_total_cycles((mach)->device(tag)) + +#define cputag_set_input_line(mach, tag, line, state) downcast((mach)->device(tag))->set_input_line(line, state) +#define cputag_set_input_line_and_vector(mach, tag, line, state, vec) downcast((mach)->device(tag))->set_input_line_and_vector(line, state, vec) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// forward declaration of types +union cpuinfo; +struct cpu_state_entry; +class cpu_debug_data; + + +// CPU interface functions +typedef void (*cpu_get_info_func)(const device_config *devconfig, device_t *device, UINT32 state, cpuinfo *info); +typedef void (*cpu_set_info_func)(device_t *device, UINT32 state, cpuinfo *info); +typedef void (*cpu_init_func)(device_t *device, device_irq_callback irqcallback); +typedef void (*cpu_reset_func)(device_t *device); +typedef void (*cpu_exit_func)(device_t *device); +typedef int (*cpu_execute_func)(device_t *device, int cycles); +typedef void (*cpu_burn_func)(device_t *device, int cycles); +typedef int (*cpu_translate_func)(device_t *device, int space, int intention, offs_t *address); +typedef int (*cpu_read_func)(device_t *device, int space, UINT32 offset, int size, UINT64 *value); +typedef int (*cpu_write_func)(device_t *device, int space, UINT32 offset, int size, UINT64 value); +typedef int (*cpu_readop_func)(device_t *device, UINT32 offset, int size, UINT64 *value); +typedef void (*cpu_debug_init_func)(device_t *device); +typedef offs_t (*cpu_disassemble_func)(device_t *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options); +typedef void (*cpu_state_io_func)(device_t *device, const device_state_entry &entry); +typedef void (*cpu_string_io_func)(device_t *device, const device_state_entry &entry, astring &string); + + +// a cpu_type is just a pointer to the CPU's get_info function +typedef cpu_get_info_func cpu_type; + + +// structure describing a single item of exposed CPU state +struct cpu_state_entry +{ + UINT32 index; // state index this entry applies to + UINT32 validmask; // mask for which CPU subtypes this entry is valid + FPTR dataoffs; // offset to the data, relative to the baseptr + UINT64 mask; // mask applied to the data + UINT8 datasize; // size of the data item in memory + UINT8 flags; // flags + const char * symbol; // symbol for display; all lower-case version for expressions + const char * format; // supported formats +}; + + +// cpuinfo union used to pass data to/from the get_info/set_info functions +union cpuinfo +{ + INT64 i; // generic integers + void * p; // generic pointers + genf * f; // generic function pointers + char * s; // generic strings + + cpu_set_info_func setinfo; // CPUINFO_FCT_SET_INFO + cpu_init_func init; // CPUINFO_FCT_INIT + cpu_reset_func reset; // CPUINFO_FCT_RESET + cpu_exit_func exit; // CPUINFO_FCT_EXIT + cpu_execute_func execute; // CPUINFO_FCT_EXECUTE + cpu_burn_func burn; // CPUINFO_FCT_BURN + cpu_translate_func translate; // CPUINFO_FCT_TRANSLATE + cpu_read_func read; // CPUINFO_FCT_READ + cpu_write_func write; // CPUINFO_FCT_WRITE + cpu_readop_func readop; // CPUINFO_FCT_READOP + cpu_debug_init_func debug_init; // CPUINFO_FCT_DEBUG_INIT + cpu_disassemble_func disassemble; // CPUINFO_FCT_DISASSEMBLE + cpu_state_io_func import_state; // CPUINFO_FCT_IMPORT_STATE + cpu_state_io_func export_state; // CPUINFO_FCT_EXPORT_STATE + cpu_string_io_func import_string; // CPUINFO_FCT_IMPORT_STRING + cpu_string_io_func export_string; // CPUINFO_FCT_EXPORT_STRING + int * icount; // CPUINFO_PTR_INSTRUCTION_COUNTER + const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP +}; + + + +// ======================> cpu_device_config + +class cpu_device_config : public device_config, + public device_config_execute_interface, + public device_config_memory_interface, + public device_config_state_interface, + public device_config_disasm_interface +{ + friend class cpu_device; + + // construction/destruction + cpu_device_config(const machine_config &mconfig, device_type _type, const char *_tag, const device_config *_owner, UINT32 _clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return get_legacy_config_string(DEVINFO_STR_NAME); } + virtual const rom_entry *rom_region() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); } + virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } + +protected: + // device_config overrides + virtual bool device_process_token(UINT32 entrytype, const machine_config_token *&tokens); + + // device_config_execute_interface overrides + virtual UINT32 execute_clocks_to_cycles(UINT32 clocks) const; + virtual UINT32 execute_cycles_to_clocks(UINT32 cycles) const; + virtual UINT32 execute_min_cycles() const { return get_legacy_config_int(CPUINFO_INT_MIN_CYCLES); } + virtual UINT32 execute_max_cycles() const { return get_legacy_config_int(CPUINFO_INT_MAX_CYCLES); } + virtual UINT32 execute_input_lines() const { return get_legacy_config_int(CPUINFO_INT_INPUT_LINES); } + virtual UINT32 execute_default_irq_vector() const { return get_legacy_config_int(CPUINFO_INT_DEFAULT_IRQ_VECTOR); } + + // device_config_memory_interface overrides + virtual const address_space_config *memory_space_config(int spacenum = 0) const { return (spacenum < ARRAY_LENGTH(m_space_config) && m_space_config[spacenum].m_addrbus_width != 0) ? &m_space_config[spacenum] : NULL; } + + // device_config_disasm_interface overrides + virtual UINT32 disasm_min_opcode_bytes() const { return get_legacy_config_int(CPUINFO_INT_MIN_INSTRUCTION_BYTES); } + virtual UINT32 disasm_max_opcode_bytes() const { return get_legacy_config_int(CPUINFO_INT_MAX_INSTRUCTION_BYTES); } + + // legacy interface helpers + INT64 get_legacy_config_int(UINT32 state) const; + void *get_legacy_config_ptr(UINT32 state) const; + genf *get_legacy_config_fct(UINT32 state) const; + const char *get_legacy_config_string(UINT32 state) const; + + // internal state + cpu_type m_cputype; // internal CPU type + address_space_config m_space_config[3]; // array of address space configs +}; + +const device_type CPU = cpu_device_config::static_alloc_device_config; + + + +// ======================> cpu_device + +class cpu_device : public device_t, + public device_execute_interface, + public device_memory_interface, + public device_state_interface, + public device_disasm_interface +{ + + friend class cpu_device_config; + friend resource_pool_object::~resource_pool_object(); + + // construction/destruction + cpu_device(running_machine &machine, const cpu_device_config &config); + virtual ~cpu_device(); + +public: + // additional CPU-specific configuration properties ... pass through to underlying config + cpu_type cputype() const { return m_cpu_config.m_cputype; } + + void *token() const { return m_token; } + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_debug_setup(); + + // device_execute_interface overrides + virtual INT32 execute_run(INT32 cycles); + virtual void execute_burn(INT32 cycles); + virtual void execute_set_input(int inputnum, int state) { set_legacy_runtime_int(CPUINFO_INT_INPUT_STATE + inputnum, state); } + + // device_memory_interface overrides + virtual bool memory_translate(int spacenum, int intention, offs_t &address); + virtual bool memory_read(int spacenum, offs_t offset, int size, UINT64 &value); + virtual bool memory_write(int spacenum, offs_t offset, int size, UINT64 value); + virtual bool memory_readop(offs_t offset, int size, UINT64 &value); + + // device_state_interface overrides + virtual void state_import(const device_state_entry &entry); + virtual void state_export(const device_state_entry &entry); + virtual void state_string_export(const device_state_entry &entry, astring &string); + + // device_disasm_interface overrides + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options); + + // helpers to access data via the legacy get_info functions + INT64 get_legacy_runtime_int(UINT32 state); + void *get_legacy_runtime_ptr(UINT32 state); + const char *get_legacy_runtime_string(UINT32 state); + void set_legacy_runtime_int(UINT32 state, INT64 value); + +public: + cpu_debug_data * m_debug; // debugging data + +protected: + // internal state + const cpu_device_config &m_cpu_config; // reference to the config + void * m_token; // pointer to our state + + cpu_set_info_func m_set_info; // extracted legacy function pointers + cpu_execute_func m_execute; // + cpu_burn_func m_burn; // + cpu_translate_func m_translate; // + cpu_read_func m_read; // + cpu_write_func m_write; // + cpu_readop_func m_readop; // + cpu_disassemble_func m_disassemble; // + cpu_state_io_func m_state_import; // + cpu_state_io_func m_state_export; // + cpu_string_io_func m_string_export; // + + UINT64 m_state_io; // temporary buffer for state I/O + bool m_using_legacy_state; // true if we are using the old-style state access +}; + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +// ======================> additional helpers + +// return the type of the specified CPU +inline cpu_type cpu_get_type(device_t *device) +{ + return downcast(device)->cputype(); +} + +// return a pointer to the given CPU's debugger data +inline cpu_debug_data *cpu_get_debug_data(device_t *device) +{ + return downcast(device)->m_debug; +} + + +#endif /* __CPUINTRF_H__ */ diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 0316a75ad8e..3565f7169ff 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -4,8 +4,36 @@ Device interface functions. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ @@ -13,34 +41,34 @@ -/*************************************************************************** - CONSTANTS -***************************************************************************/ +//************************************************************************** +// CONSTANTS +//************************************************************************** #define TEMP_STRING_POOL_ENTRIES 16 #define MAX_STRING_LENGTH 256 -/*************************************************************************** - GLOBAL VARIABLES -***************************************************************************/ +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** static char temp_string_pool[TEMP_STRING_POOL_ENTRIES][MAX_STRING_LENGTH]; static int temp_string_pool_index; -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +//************************************************************************** +// INLINE FUNCTIONS +//************************************************************************** -/*------------------------------------------------- - get_temp_string_buffer - return a pointer to - a temporary string buffer --------------------------------------------------*/ +//------------------------------------------------- +// get_temp_string_buffer - return a pointer to +// a temporary string buffer +//------------------------------------------------- -static char *get_temp_string_buffer(void) +char *get_temp_string_buffer(void) { char *string = &temp_string_pool[temp_string_pool_index++ % TEMP_STRING_POOL_ENTRIES][0]; string[0] = 0; @@ -48,59 +76,71 @@ static char *get_temp_string_buffer(void) } +resource_pool &machine_get_pool(running_machine &machine) +{ + // temporary to get around include dependencies, until CPUs + // get a proper device class + return machine.respool; +} -/*************************************************************************** - LIVE DEVICE MANAGEMENT -***************************************************************************/ -/*------------------------------------------------- - device_list - device list constructor --------------------------------------------------*/ +//************************************************************************** +// DEVICE LIST MANAGEMENT +//************************************************************************** + +//------------------------------------------------- +// device_list - device list constructor +//------------------------------------------------- -device_list::device_list() - : machine(NULL) +device_list::device_list(resource_pool &pool) + : tagged_device_list(pool), + m_machine(NULL) { } -/*------------------------------------------------- - import_config_list - import a list of device - configs and allocate new devices --------------------------------------------------*/ +//------------------------------------------------- +// import_config_list - import a list of device +// configs and allocate new devices +//------------------------------------------------- -void device_list::import_config_list(const device_config_list &list, running_machine &_machine) +void device_list::import_config_list(const device_config_list &list, running_machine &machine) { // remember the machine for later use - machine = &_machine; - + m_machine = &machine; + // append each device from the configuration list - for (const device_config *devconfig = list.first(); devconfig != NULL; devconfig = devconfig->next) - append(devconfig->tag(), new running_device(_machine, *devconfig)); + for (const device_config *devconfig = list.first(); devconfig != NULL; devconfig = devconfig->next()) + append(devconfig->tag(), devconfig->alloc_device(*m_machine)); } -/*------------------------------------------------- - start_all - start all the devices in the - list --------------------------------------------------*/ +//------------------------------------------------- +// start_all - start all the devices in the +// list +//------------------------------------------------- void device_list::start_all() { // add exit and reset callbacks - assert(machine != NULL); - add_reset_callback(machine, static_reset); - add_exit_callback(machine, static_stop); + assert(m_machine != NULL); + add_reset_callback(m_machine, static_reset); + add_exit_callback(m_machine, static_exit); + + // add pre-save and post-load callbacks + state_save_register_presave(m_machine, static_pre_save, this); + state_save_register_postload(m_machine, static_post_load, this); // iterate until we've started everything int devcount = count(); int numstarted = 0; while (numstarted < devcount) { - // iterate over devices and start them + // iterate over devices and start them int prevstarted = numstarted; - for (running_device *device = first(); device != NULL; device = device->next) - if (!device->started) + for (device_t *device = first(); device != NULL; device = device->next()) + if (!device->started()) { // attempt to start the device, catching any expected exceptions try @@ -120,32 +160,27 @@ void device_list::start_all() } -/*------------------------------------------------- - stop_all - stop all devices in the list --------------------------------------------------*/ +//------------------------------------------------- +// debug_setup_all - tell all the devices to set +// up any debugging they need +//------------------------------------------------- -void device_list::stop_all() +void device_list::debug_setup_all() { // iterate over devices and stop them - for (running_device *device = first(); device != NULL; device = device->next) - device->stop(); -} - - -void device_list::static_stop(running_machine *machine) -{ - machine->devicelist.stop_all(); + for (device_t *device = first(); device != NULL; device = device->next()) + device->debug_setup(); } -/*------------------------------------------------- - reset_all - reset all devices in the list --------------------------------------------------*/ +//------------------------------------------------- +// reset_all - reset all devices in the list +//------------------------------------------------- void device_list::reset_all() { - /* iterate over devices and stop them */ - for (running_device *device = first(); device != NULL; device = device->next) + // iterate over devices and stop them + for (device_t *device = first(); device != NULL; device = device->next()) device->reset(); } @@ -156,227 +191,525 @@ void device_list::static_reset(running_machine *machine) } +//------------------------------------------------- +// static_exit - tear down all the devices +//------------------------------------------------- -/*************************************************************************** - DEVICE CONFIGURATION -***************************************************************************/ +void device_list::static_exit(running_machine *machine) +{ + machine->devicelist.reset(); +} -/*------------------------------------------------- - device_config - constructor for a new - device configuration --------------------------------------------------*/ - -device_config::device_config(const device_config *_owner, device_type _type, const char *_tag, UINT32 _clock) - : next(NULL), - owner(const_cast(_owner)), - type(_type), - devclass(DEVICE_CLASS_GENERAL), - clock(_clock), - static_config(NULL), - inline_config(NULL), - m_tag(_tag) + +//------------------------------------------------- +// static_pre_save - tell all the devices we are +// about to save +//------------------------------------------------- + +void device_list::static_pre_save(running_machine *machine, void *param) { - // initialize remaining members - memset(address_map, 0, sizeof(address_map)); - devclass = (device_class)get_config_int(DEVINFO_INT_CLASS); + device_list *list = reinterpret_cast(param); + for (device_t *device = list->first(); device != NULL; device = device->next()) + device->pre_save(); +} - // derive the clock from our owner if requested - if ((clock & 0xff000000) == 0xff000000) - { - assert(owner != NULL); - clock = owner->clock * ((clock >> 12) & 0xfff) / ((clock >> 0) & 0xfff); - } - // allocate a buffer for the inline configuration - UINT32 configlen = (UINT32)get_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES); - inline_config = (configlen == 0) ? NULL : global_alloc_array_clear(UINT8, configlen); +//------------------------------------------------- +// static_post_load - tell all the devices we just +// completed a load +//------------------------------------------------- + +void device_list::static_post_load(running_machine *machine, void *param) +{ + device_list *list = reinterpret_cast(param); + for (device_t *device = list->first(); device != NULL; device = device->next()) + device->post_load(); } -/*------------------------------------------------- - ~device_config - destructor --------------------------------------------------*/ -device_config::~device_config() +//************************************************************************** +// DEVICE INTERFACE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// device_config_interface - constructor +//------------------------------------------------- + +device_config_interface::device_config_interface(const machine_config &mconfig, device_config &devconfig) + : m_device_config(devconfig), + m_machine_config(mconfig), + m_interface_next(NULL) { - // call the custom config free function first - device_custom_config_func custom = reinterpret_cast(get_config_fct(DEVINFO_FCT_CUSTOM_CONFIG)); - if (custom != NULL) - (*custom)(this, MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, NULL); + device_config_interface **tailptr; + for (tailptr = &devconfig.m_interface_list; *tailptr != NULL; tailptr = &(*tailptr)->m_interface_next) ; + *tailptr = this; +} - // free the inline config - global_free(inline_config); + +//------------------------------------------------- +// ~device_config_interface - destructor +//------------------------------------------------- + +device_config_interface::~device_config_interface() +{ } -/*------------------------------------------------- - device_get_config_int - return an integer state - value from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// interface_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -INT64 device_config::get_config_int(UINT32 state) const +void device_config_interface::interface_config_complete() { - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); + // do nothing by default +} + + +//------------------------------------------------- +// interface_process_token - default token +// processing for a given interface +//------------------------------------------------- + +bool device_config_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + return false; +} + + +//------------------------------------------------- +// interface_validity_check - default validation +// for a device after the configuration has been +// constructed +//------------------------------------------------- - // retrieve the value - deviceinfo info; - info.i = 0; - (*type)(this, state, &info); - return info.i; +bool device_config_interface::interface_validity_check(const game_driver &driver) const +{ + return false; } -/*------------------------------------------------- - device_get_config_ptr - return a pointer state - value from an allocated device --------------------------------------------------*/ -void *device_config::get_config_ptr(UINT32 state) const +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// device_config - constructor for a new +// device configuration +//------------------------------------------------- + +device_config::device_config(const machine_config &mconfig, device_type type, const char *_tag, const device_config *owner, UINT32 clock) + : m_next(NULL), + m_owner(const_cast(owner)), + m_interface_list(NULL), + m_type(type), + m_clock(clock), + m_machine_config(mconfig), + m_static_config(NULL), + m_tag(_tag) { - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST); + memset(m_inline_data, 0, sizeof(m_inline_data)); - // retrieve the value - deviceinfo info; - info.p = NULL; - (*type)(this, state, &info); - return info.p; + // derive the clock from our owner if requested + if ((m_clock & 0xff000000) == 0xff000000) + { + assert(m_owner != NULL); + m_clock = m_owner->m_clock * ((m_clock >> 12) & 0xfff) / ((m_clock >> 0) & 0xfff); + } } -/*------------------------------------------------- - device_get_config_fct - return a function - pointer state value from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// ~device_config - destructor +//------------------------------------------------- -genf *device_config::get_config_fct(UINT32 state) const +device_config::~device_config() { - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_FCT_FIRST && state <= DEVINFO_FCT_LAST); +} - // retrieve the value - deviceinfo info; - info.f = 0; - (*type)(this, state, &info); - return info.f; + +//------------------------------------------------- +// config_complete - called when the +// configuration of a device is complete +//------------------------------------------------- + +void device_config::config_complete() +{ + // first notify the interfaces + for (device_config_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_config_complete(); + + // then notify the device itself + device_config_complete(); } -/*------------------------------------------------- - device_get_config_string - return a string value - from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// process_token - process tokens +//------------------------------------------------- -const char *device_config::get_config_string(UINT32 state) const +void device_config::process_token(UINT32 entrytype, const machine_config_token *&tokens) { - assert(this != NULL); - assert(type != NULL); - assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); + int size, offset, bits, index; + UINT32 data32; + UINT64 data64; + bool processed = false; - // retrieve the value - deviceinfo info; - info.s = get_temp_string_buffer(); - (*type)(this, state, &info); - if (info.s[0] == 0) + // first process stuff we know about + switch (entrytype) { - switch (state) + // specify device clock + case MCONFIG_TOKEN_DEVICE_CLOCK: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, m_clock, 32); + processed = true; + break; + + // specify pointer to static device configuration + case MCONFIG_TOKEN_DEVICE_CONFIG: + m_static_config = TOKEN_GET_PTR(tokens, voidptr); + processed = true; + break; + + // provide inline device data packed into a 16-bit space + case MCONFIG_TOKEN_DEVICE_INLINE_DATA16: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, index, 8, data32, 16); + assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); + m_inline_data[index] = data32; + processed = true; + break; + + // provide inline device data packed into a 32-bit space + case MCONFIG_TOKEN_DEVICE_INLINE_DATA32: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, index, 8); + assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); + m_inline_data[index] = TOKEN_GET_UINT32(tokens); + processed = true; + break; + + // provide inline device data packed into a 64-bit space + case MCONFIG_TOKEN_DEVICE_INLINE_DATA64: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, index, 8); + assert(index >= 0 && index < ARRAY_LENGTH(m_inline_data)); + TOKEN_EXTRACT_UINT64(tokens, m_inline_data[index]); + processed = true; + break; + + // provide inline device data packed into a 32-bit word + case MCONFIG_TOKEN_DEVICE_CONFIG_DATA32: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); + data32 = TOKEN_GET_UINT32(tokens); + switch (size) + { + case 1: *(UINT8 *) ((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; + case 2: *(UINT16 *)((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; + case 4: *(UINT32 *)((UINT8 *)downcast(this)->inline_config() + offset) = data32; break; + } + processed = true; + break; + + // provide inline device data packed into a 64-bit word + case MCONFIG_TOKEN_DEVICE_CONFIG_DATA64: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); + TOKEN_EXTRACT_UINT64(tokens, data64); + switch (size) + { + case 1: *(UINT8 *) ((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; + case 2: *(UINT16 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; + case 4: *(UINT32 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; + case 8: *(UINT64 *)((UINT8 *)downcast(this)->inline_config() + offset) = data64; break; + } + processed = true; + break; + + // provide inline floating-point device data packed into a fixed-point 32-bit word + case MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, size, 4, bits, 6, offset, 12); + data32 = TOKEN_GET_UINT32(tokens); + switch (size) + { + case 4: *(float *)((UINT8 *)downcast(this)->inline_config() + offset) = (float)(INT32)data32 / (float)(1 << bits); break; + case 8: *(double *)((UINT8 *)downcast(this)->inline_config() + offset) = (double)(INT32)data32 / (double)(1 << bits); break; + } + processed = true; + break; + } + + // anything else might be handled by one of our interfaces + for (device_config_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + if (intf->interface_process_token(entrytype, tokens)) { - case DEVINFO_STR_NAME: strcpy(info.s, "Custom"); break; - case DEVINFO_STR_FAMILY: strcpy(info.s, "Custom"); break; - case DEVINFO_STR_VERSION: strcpy(info.s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info.s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info.s, "Copyright Nicola Salmoria and the MAME Team"); break; + assert(!processed); + processed = true; } + + // or it might be processed by the device itself + if (device_process_token(entrytype, tokens)) + { + assert(!processed); + processed = true; } - return info.s; + + // regardless, *somebody* must handle it + if (!processed) + throw emu_fatalerror("Unhandled token %d for device '%s'", entrytype, tag()); } -/*------------------------------------------------- - subtag - create a tag for an object that is - owned by this device --------------------------------------------------*/ +//------------------------------------------------- +// validity_check - validate a device after the +// configuration has been constructed +//------------------------------------------------- -astring &device_config::subtag(astring &dest, const char *_tag) const +bool device_config::validity_check(const game_driver &driver) const { - return (this != NULL) ? dest.cpy(m_tag).cat(":").cat(_tag) : dest.cpy(_tag); + bool error = false; + + // validate via the interfaces + for (device_config_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + if (intf->interface_validity_check(driver)) + error = true; + + // let the device itself validate + if (device_validity_check(driver)) + error = true; + + return error; } -/*------------------------------------------------- - siblingtag - create a tag for an object that - a sibling to this device --------------------------------------------------*/ +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -astring &device_config::siblingtag(astring &dest, const char *_tag) const +void device_config::device_config_complete() { - return (this != NULL && owner != NULL) ? owner->subtag(dest, _tag) : dest.cpy(_tag); + // do nothing by default } +//------------------------------------------------- +// device_process_token - process basic device +// tokens +//------------------------------------------------- + +bool device_config::device_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + // handle nothing by default + return false; +} + + +//------------------------------------------------- +// device_validity_check - validate a device after +// the configuration has been constructed +//------------------------------------------------- + +bool device_config::device_validity_check(const game_driver &driver) const +{ + // indicate no error by default + return false; +} -/*************************************************************************** - LIVE DEVICE MANAGEMENT -***************************************************************************/ -/*------------------------------------------------- - running_device - constructor for a new - running device; initial state is derived - from the provided config --------------------------------------------------*/ +//------------------------------------------------- +// rom_region - return a pointer to the implicit +// rom region description for this device +//------------------------------------------------- -running_device::running_device(running_machine &_machine, const device_config &_config) - : m_baseconfig(_config), - machine(&_machine), - next(NULL), - owner((_config.owner != NULL) ? _machine.devicelist.find(_config.owner->tag()) : NULL), - type(_config.type), - devclass(_config.devclass), - clock(_config.clock), - started(false), - token(NULL), - tokenbytes(_config.get_config_int(DEVINFO_INT_TOKEN_BYTES)), - region(NULL), - execute(NULL), - get_runtime_info(NULL), - m_tag(_config.tag()) +const rom_entry *device_config::rom_region() const { - memset(addrspace, 0, sizeof(addrspace)); + return NULL; +} - if (tokenbytes == 0) - throw emu_fatalerror("Device %s specifies a 0 token length!\n", tag()); - // allocate memory for the token - token = auto_alloc_array_clear(machine, UINT8, tokenbytes); +//------------------------------------------------- +// machine_config_tokens - return a pointer to +// a set of machine configuration tokens +// describing sub-devices for this device +//------------------------------------------------- - // get function pointers - execute = (device_execute_func)get_config_fct(DEVINFO_FCT_EXECUTE); - get_runtime_info = (device_get_runtime_info_func)get_config_fct(DEVINFO_FCT_GET_RUNTIME_INFO); +const machine_config_token *device_config::machine_config_tokens() const +{ + return NULL; } -/*------------------------------------------------- - ~running_device - destructor for a - running_device --------------------------------------------------*/ -running_device::~running_device() +//************************************************************************** +// LIVE DEVICE INTERFACES +//************************************************************************** + +//------------------------------------------------- +// device_interface - constructor +//------------------------------------------------- + +device_interface::device_interface(running_machine &machine, const device_config &config, device_t &device) + : m_interface_next(NULL), + m_device(device) { - // release token memory - auto_free(machine, token); + device_interface **tailptr; + for (tailptr = &device.m_interface_list; *tailptr != NULL; tailptr = &(*tailptr)->m_interface_next) ; + *tailptr = this; } -/*------------------------------------------------- - subregion - return a pointer to the region - info for a given region --------------------------------------------------*/ +//------------------------------------------------- +// ~device_interface - destructor +//------------------------------------------------- -const region_info *running_device::subregion(const char *_tag) const +device_interface::~device_interface() +{ +} + + +//------------------------------------------------- +// interface_pre_start - called before the +// device's own start function +//------------------------------------------------- + +void device_interface::interface_pre_start() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_post_start - called after the +// device's own start function +//------------------------------------------------- + +void device_interface::interface_post_start() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_pre_reset - called before the +// device's own reset function +//------------------------------------------------- + +void device_interface::interface_pre_reset() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_post_reset - called after the +// device's own reset function +//------------------------------------------------- + +void device_interface::interface_post_reset() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_pre_save - called prior to saving the +// state, so that registered variables can be +// properly normalized +//------------------------------------------------- + +void device_interface::interface_pre_save() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_post_load - called after the loading a +// saved state, so that registered variables can +// be expaneded as necessary +//------------------------------------------------- + +void device_interface::interface_post_load() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_clock_changed - called when the +// device clock is altered in any way; designed +// to be overridden by the actual device +// implementation +//------------------------------------------------- + +void device_interface::interface_clock_changed() +{ + // do nothing by default +} + + +//------------------------------------------------- +// interface_debug_setup - called to allow +// interfaces to set up any debugging for this +// device +//------------------------------------------------- + +void device_interface::interface_debug_setup() +{ + // do nothing by default +} + + + +//************************************************************************** +// LIVE DEVICE MANAGEMENT +//************************************************************************** + +//------------------------------------------------- +// device_t - constructor for a new +// running device; initial state is derived +// from the provided config +//------------------------------------------------- + +device_t::device_t(running_machine &_machine, const device_config &config) + : machine(&_machine), + m_machine(_machine), + m_next(NULL), + m_owner((config.m_owner != NULL) ? _machine.devicelist.find(config.m_owner->tag()) : NULL), + m_interface_list(NULL), + m_started(false), + m_clock(config.m_clock), + m_region(NULL), + m_baseconfig(config), + m_unscaled_clock(config.m_clock), + m_clock_scale(1.0), + m_attoseconds_per_clock((config.m_clock == 0) ? 0 : HZ_TO_ATTOSECONDS(config.m_clock)) +{ +} + + +//------------------------------------------------- +// ~device_t - destructor for a device_t +//------------------------------------------------- + +device_t::~device_t() +{ +} + + +//------------------------------------------------- +// subregion - return a pointer to the region +// info for a given region +//------------------------------------------------- + +const region_info *device_t::subregion(const char *_tag) const { // safety first if (this == NULL) @@ -384,16 +717,16 @@ const region_info *running_device::subregion(const char *_tag) const // build a fully-qualified name astring tempstring; - return machine->region(subtag(tempstring, _tag)); + return m_machine.region(subtag(tempstring, _tag)); } -/*------------------------------------------------- - subdevice - return a pointer to the given - device that is owned by us --------------------------------------------------*/ +//------------------------------------------------- +// subdevice - return a pointer to the given +// device that is owned by us +//------------------------------------------------- -running_device *running_device::subdevice(const char *_tag) const +device_t *device_t::subdevice(const char *_tag) const { // safety first if (this == NULL) @@ -401,135 +734,267 @@ running_device *running_device::subdevice(const char *_tag) const // build a fully-qualified name astring tempstring; - return machine->device(subtag(tempstring, _tag)); + return m_machine.device(subtag(tempstring, _tag)); } -/*------------------------------------------------- - set_address_space - connect an address space - to a device --------------------------------------------------*/ +//------------------------------------------------- +// siblingdevice - return a pointer to the given +// device that is owned by our same owner +//------------------------------------------------- -void running_device::set_address_space(int spacenum, const address_space *space) +device_t *device_t::siblingdevice(const char *_tag) const { - addrspace[spacenum] = space; + // safety first + if (this == NULL) + return NULL; + + // build a fully-qualified name + astring tempstring; + return m_machine.device(siblingtag(tempstring, _tag)); } -/*------------------------------------------------- - set_clock - set a device's clock --------------------------------------------------*/ +//------------------------------------------------- +// set_clock - sets the given device's raw clock +//------------------------------------------------- -void running_device::set_clock(UINT32 _clock) +void device_t::set_unscaled_clock(UINT32 clock) { - clock = _clock; + m_unscaled_clock = clock; + m_clock = m_unscaled_clock * m_clock_scale; + m_attoseconds_per_clock = HZ_TO_ATTOSECONDS(m_clock); + notify_clock_changed(); } -/*------------------------------------------------- - start - start a device --------------------------------------------------*/ +//------------------------------------------------- +// set_clockscale - sets a scale factor for the +// device's clock +//------------------------------------------------- -void running_device::start() +void device_t::set_clock_scale(double clockscale) { - // find our region - region = machine->regionlist.find(baseconfig().tag()); + m_clock_scale = clockscale; + m_clock = m_unscaled_clock * m_clock_scale; + m_attoseconds_per_clock = HZ_TO_ATTOSECONDS(m_clock); + notify_clock_changed(); +} + - // start functions are required - device_start_func start = (device_start_func)get_config_fct(DEVINFO_FCT_START); - assert(start != NULL); - (*start)(this); +//------------------------------------------------- +// clocks_to_attotime - converts a number of +// clock ticks to an attotime +//------------------------------------------------- - // if we didn't get any exceptions then we started ok - started = true; +attotime device_t::clocks_to_attotime(UINT64 numclocks) const +{ + if (numclocks < m_clock) + return attotime_make(0, numclocks * m_attoseconds_per_clock); + else + { + UINT32 remainder; + UINT32 quotient = divu_64x32_rem(numclocks, m_clock, &remainder); + return attotime_make(quotient, (UINT64)remainder * (UINT64)m_attoseconds_per_clock); + } } -/*------------------------------------------------- - stop - stop a device --------------------------------------------------*/ +//------------------------------------------------- +// attotime_to_clocks - converts a duration as +// attotime to CPU clock ticks +//------------------------------------------------- -void running_device::stop() +UINT64 device_t::attotime_to_clocks(attotime duration) const { - assert(token != NULL); - assert(type != NULL); + return mulu_32x32(duration.seconds, m_clock) + (UINT64)duration.attoseconds / (UINT64)m_attoseconds_per_clock; +} + + +//------------------------------------------------- +// start - start a device +//------------------------------------------------- - // if we have a stop function, call it - device_stop_func stop = (device_stop_func)get_config_fct(DEVINFO_FCT_STOP); - if (stop != NULL) - (*stop)(this); +void device_t::start() +{ + // populate the region field + m_region = m_machine.region(tag()); + + // let the interfaces do their pre-work + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_pre_start(); + + // remember the number of state registrations + int state_registrations = state_save_get_reg_count(machine); + + // start the device + device_start(); + + // complain if nothing was registered by the device + state_registrations = state_save_get_reg_count(machine) - state_registrations; + device_execute_interface *exec; + device_sound_interface *sound; + if (state_registrations == 0 && (interface(exec) || interface(sound))) + { + logerror("Device '%s' did not register any state to save!\n", tag()); + if ((m_machine.gamedrv->flags & GAME_SUPPORTS_SAVE) != 0) + fatalerror("Device '%s' did not register any state to save!", tag()); + } + + // let the interfaces do their post-work + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_post_start(); + + // force an update of the clock + notify_clock_changed(); + + // register our save states + state_save_register_device_item(this, 0, m_clock); + state_save_register_device_item(this, 0, m_unscaled_clock); + state_save_register_device_item(this, 0, m_clock_scale); + + // we're now officially started + m_started = true; } -/*------------------------------------------------- - reset - reset a device --------------------------------------------------*/ +//------------------------------------------------- +// debug_setup - set up for debugging +//------------------------------------------------- -void running_device::reset() +void device_t::debug_setup() { - assert(this != NULL); - assert(this->token != NULL); - assert(this->type != NULL); + // notify the interface + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_debug_setup(); + + // notify the device + device_debug_setup(); +} + + +//------------------------------------------------- +// reset - reset a device +//------------------------------------------------- - // if we have a reset function, call it - device_reset_func reset = (device_reset_func)get_config_fct(DEVINFO_FCT_RESET); - if (reset != NULL) - (*reset)(this); +void device_t::reset() +{ + // let the interfaces do their pre-work + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_pre_reset(); + + // reset the device + device_reset(); + + // let the interfaces do their post-work + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_post_reset(); } -/*------------------------------------------------- - get_runtime_int - return an integer state - value from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// pre_save - tell the device and its interfaces +// that we are about to save +//------------------------------------------------- -INT64 running_device::get_runtime_int(UINT32 state) +void device_t::pre_save() { - assert(this != NULL); - assert(get_runtime_info != NULL); - assert(state >= DEVINFO_INT_FIRST && state <= DEVINFO_INT_LAST); + // notify the interface + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_pre_save(); + + // notify the device + device_pre_save(); +} - // retrieve the value - deviceinfo info; - info.i = 0; - (*get_runtime_info)(this, state, &info); - return info.i; + +//------------------------------------------------- +// post_load - tell the device and its interfaces +// that we just completed a load +//------------------------------------------------- + +void device_t::post_load() +{ + // notify the interface + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_post_load(); + + // notify the device + device_post_load(); +} + + +//------------------------------------------------- +// device_reset - actually handle resetting of +// a device; designed to be overriden by the +// actual device implementation +//------------------------------------------------- + +void device_t::device_reset() +{ + // do nothing by default +} + + +//------------------------------------------------- +// device_pre_save - called prior to saving the +// state, so that registered variables can be +// properly normalized +//------------------------------------------------- + +void device_t::device_pre_save() +{ + // do nothing by default } -/*------------------------------------------------- - get_runtime_ptr - return a pointer state - value from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// device_post_load - called after the loading a +// saved state, so that registered variables can +// be expaneded as necessary +//------------------------------------------------- -void *running_device::get_runtime_ptr(UINT32 state) +void device_t::device_post_load() { - assert(this != NULL); - assert(get_runtime_info != NULL); - assert(state >= DEVINFO_PTR_FIRST && state <= DEVINFO_PTR_LAST); + // do nothing by default +} - // retrieve the value - deviceinfo info; - info.p = NULL; - (*get_runtime_info)(this, state, &info); - return info.p; + +//------------------------------------------------- +// device_clock_changed - called when the +// device clock is altered in any way; designed +// to be overridden by the actual device +// implementation +//------------------------------------------------- + +void device_t::device_clock_changed() +{ + // do nothing by default +} + + +//------------------------------------------------- +// device_debug_setup - called when the debugger +// is active to allow for device-specific setup +//------------------------------------------------- + +void device_t::device_debug_setup() +{ + // do nothing by default } -/*------------------------------------------------- - get_runtime_string - return a string value - from an allocated device --------------------------------------------------*/ +//------------------------------------------------- +// notify_clock_changed - notify all interfaces +// that the clock has changed +//------------------------------------------------- -const char *running_device::get_runtime_string(UINT32 state) +void device_t::notify_clock_changed() { - assert(this != NULL); - assert(get_runtime_info != NULL); - assert(state >= DEVINFO_STR_FIRST && state <= DEVINFO_STR_LAST); + // first notify interfaces + for (device_interface *intf = m_interface_list; intf != NULL; intf = intf->interface_next()) + intf->interface_clock_changed(); - // retrieve the value - deviceinfo info; - info.s = get_temp_string_buffer(); - (*get_runtime_info)(this, state, &info); - return info.s; + // then notify the device + device_clock_changed(); } diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index d824c1b1626..fa41f383c54 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -4,8 +4,36 @@ Device interface functions. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ @@ -20,231 +48,111 @@ -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -// forward references -struct rom_entry; -union machine_config_token; - - -// device classes -enum device_class -{ - DEVICE_CLASS_GENERAL = 0, // default class for general devices - DEVICE_CLASS_PERIPHERAL, // peripheral devices: PIAs, timers, etc. - DEVICE_CLASS_AUDIO, // audio devices (not sound chips), including speakers - DEVICE_CLASS_VIDEO, // video devices, including screens - DEVICE_CLASS_CPU_CHIP, // CPU chips; only CPU cores should return this class - DEVICE_CLASS_SOUND_CHIP, // sound chips; only sound cores should return this class - DEVICE_CLASS_TIMER, // timer devices - DEVICE_CLASS_OTHER // anything else (the list may expand in the future) -}; - - -// state constants passed to the device_get_config_func -enum -{ - // --- the following bits of info are returned as 64-bit signed integers --- - DEVINFO_INT_FIRST = 0x00000, - - DEVINFO_INT_TOKEN_BYTES = DEVINFO_INT_FIRST, // R/O: bytes to allocate for the token - DEVINFO_INT_INLINE_CONFIG_BYTES, // R/O: bytes to allocate for the inline configuration - DEVINFO_INT_CLASS, // R/O: the device's class - - DEVINFO_INT_ENDIANNESS, // R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE - DEVINFO_INT_DATABUS_WIDTH, // R/O: data bus size for each address space (8,16,32,64) - DEVINFO_INT_DATABUS_WIDTH_0 = DEVINFO_INT_DATABUS_WIDTH + 0, - DEVINFO_INT_DATABUS_WIDTH_1 = DEVINFO_INT_DATABUS_WIDTH + 1, - DEVINFO_INT_DATABUS_WIDTH_2 = DEVINFO_INT_DATABUS_WIDTH + 2, - DEVINFO_INT_DATABUS_WIDTH_3 = DEVINFO_INT_DATABUS_WIDTH + 3, - DEVINFO_INT_DATABUS_WIDTH_LAST = DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACES - 1, - DEVINFO_INT_ADDRBUS_WIDTH, // R/O: address bus size for each address space (12-32) - DEVINFO_INT_ADDRBUS_WIDTH_0 = DEVINFO_INT_ADDRBUS_WIDTH + 0, - DEVINFO_INT_ADDRBUS_WIDTH_1 = DEVINFO_INT_ADDRBUS_WIDTH + 1, - DEVINFO_INT_ADDRBUS_WIDTH_2 = DEVINFO_INT_ADDRBUS_WIDTH + 2, - DEVINFO_INT_ADDRBUS_WIDTH_3 = DEVINFO_INT_ADDRBUS_WIDTH + 3, - DEVINFO_INT_ADDRBUS_WIDTH_LAST = DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACES - 1, - DEVINFO_INT_ADDRBUS_SHIFT, // R/O: shift applied to addresses each address space (+3 means >>3, -1 means <<1) - DEVINFO_INT_ADDRBUS_SHIFT_0 = DEVINFO_INT_ADDRBUS_SHIFT + 0, - DEVINFO_INT_ADDRBUS_SHIFT_1 = DEVINFO_INT_ADDRBUS_SHIFT + 1, - DEVINFO_INT_ADDRBUS_SHIFT_2 = DEVINFO_INT_ADDRBUS_SHIFT + 2, - DEVINFO_INT_ADDRBUS_SHIFT_3 = DEVINFO_INT_ADDRBUS_SHIFT + 3, - DEVINFO_INT_ADDRBUS_SHIFT_LAST = DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACES - 1, - - DEVINFO_INT_CLASS_SPECIFIC = 0x04000, // R/W: device-specific values start here - DEVINFO_INT_DEVICE_SPECIFIC = 0x08000, // R/W: device-specific values start here - DEVINFO_INT_LAST = 0x0ffff, - - // --- the following bits of info are returned as pointers --- - DEVINFO_PTR_FIRST = 0x10000, - - DEVINFO_PTR_ROM_REGION = DEVINFO_PTR_FIRST, // R/O: pointer to device-specific ROM region - DEVINFO_PTR_MACHINE_CONFIG, // R/O: pointer to device-specific machine config - - DEVINFO_PTR_INTERNAL_MEMORY_MAP, // R/O: const addrmap_token *map - DEVINFO_PTR_INTERNAL_MEMORY_MAP_0 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 0, - DEVINFO_PTR_INTERNAL_MEMORY_MAP_1 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 1, - DEVINFO_PTR_INTERNAL_MEMORY_MAP_2 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 2, - DEVINFO_PTR_INTERNAL_MEMORY_MAP_3 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 3, - DEVINFO_PTR_INTERNAL_MEMORY_MAP_LAST = DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1, - - DEVINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: const addrmap_token *map - DEVINFO_PTR_DEFAULT_MEMORY_MAP_0 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 0, - DEVINFO_PTR_DEFAULT_MEMORY_MAP_1 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 1, - DEVINFO_PTR_DEFAULT_MEMORY_MAP_2 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 2, - DEVINFO_PTR_DEFAULT_MEMORY_MAP_3 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 3, - DEVINFO_PTR_DEFAULT_MEMORY_MAP_LAST = DEVINFO_PTR_DEFAULT_MEMORY_MAP + ADDRESS_SPACES - 1, - - DEVINFO_PTR_CLASS_SPECIFIC = 0x14000, // R/W: device-specific values start here - DEVINFO_PTR_DEVICE_SPECIFIC = 0x18000, // R/W: device-specific values start here - DEVINFO_PTR_LAST = 0x1ffff, - - // --- the following bits of info are returned as pointers to functions --- - DEVINFO_FCT_FIRST = 0x20000, - - DEVINFO_FCT_START = DEVINFO_FCT_FIRST, // R/O: device_start_func - DEVINFO_FCT_STOP, // R/O: device_stop_func - DEVINFO_FCT_RESET, // R/O: device_reset_func - DEVINFO_FCT_EXECUTE, // R/O: device_execute_func - DEVINFO_FCT_VALIDITY_CHECK, // R/O: device_validity_check_func - DEVINFO_FCT_NVRAM, // R/O: device_nvram_func - DEVINFO_FCT_CUSTOM_CONFIG, // R/O: device_custom_config_func - DEVINFO_FCT_GET_RUNTIME_INFO, // R/O: device_get_runtime_info_func - - DEVINFO_FCT_CLASS_SPECIFIC = 0x24000, // R/W: device-specific values start here - DEVINFO_FCT_DEVICE_SPECIFIC = 0x28000, // R/W: device-specific values start here - DEVINFO_FCT_LAST = 0x2ffff, - - // --- the following bits of info are returned as NULL-terminated strings --- - DEVINFO_STR_FIRST = 0x30000, - - DEVINFO_STR_NAME = DEVINFO_STR_FIRST, // R/O: name of the device - DEVINFO_STR_FAMILY, // R/O: family of the device - DEVINFO_STR_VERSION, // R/O: version of the device - DEVINFO_STR_SOURCE_FILE, // R/O: file containing the device implementation - DEVINFO_STR_CREDITS, // R/O: credits for the device implementation - - DEVINFO_STR_CLASS_SPECIFIC = 0x34000, // R/W: device-specific values start here - DEVINFO_STR_DEVICE_SPECIFIC = 0x38000, // R/W: device-specific values start here - DEVINFO_STR_LAST = 0x3ffff -}; - - - -/*************************************************************************** - MACROS -***************************************************************************/ +//************************************************************************** +// MACROS +//************************************************************************** -#define DEVICE_GET_INFO_NAME(name) device_get_config_##name -#define DEVICE_GET_INFO(name) void DEVICE_GET_INFO_NAME(name)(const device_config *device, UINT32 state, deviceinfo *info) -#define DEVICE_GET_INFO_CALL(name) DEVICE_GET_INFO_NAME(name)(device, state, info) - -#define DEVICE_VALIDITY_CHECK_NAME(name) device_validity_check_##name -#define DEVICE_VALIDITY_CHECK(name) int DEVICE_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const device_config *device) -#define DEVICE_VALIDITY_CHECK_CALL(name) DEVICE_VALIDITY_CHECK_NAME(name)(driver, device) - -#define DEVICE_CUSTOM_CONFIG_NAME(name) device_custom_config_##name -#define DEVICE_CUSTOM_CONFIG(name) const machine_config_token *DEVICE_CUSTOM_CONFIG_NAME(name)(const device_config *device, UINT32 entrytype, const machine_config_token *tokens) -#define DEVICE_CUSTOM_CONFIG_CALL(name) DEVICE_CUSTOM_CONFIG_NAME(name)(device, entrytype, tokens) +// macro for specifying a clock derived from an owning device +#define DERIVED_CLOCK(num, den) (0xff000000 | ((num) << 12) | ((den) << 0)) +// shorthand for accessing devices by machine/type/tag +#define devtag_get_device(mach,tag) (mach)->device(tag) +#define devtag_reset(mach,tag) (mach)->device(tag)->reset() -#define DEVICE_GET_RUNTIME_INFO_NAME(name) device_get_runtime_info_##name -#define DEVICE_GET_RUNTIME_INFO(name) void DEVICE_GET_RUNTIME_INFO_NAME(name)(running_device *device, UINT32 state, deviceinfo *info) -#define DEVICE_GET_RUNTIME_INFO_CALL(name) DEVICE_GET_RUNTIME_INFO_NAME(name)(device, state, info) -#define DEVICE_START_NAME(name) device_start_##name -#define DEVICE_START(name) void DEVICE_START_NAME(name)(running_device *device) -#define DEVICE_START_CALL(name) DEVICE_START_NAME(name)(device) -#define DEVICE_STOP_NAME(name) device_stop_##name -#define DEVICE_STOP(name) void DEVICE_STOP_NAME(name)(running_device *device) -#define DEVICE_STOP_CALL(name) DEVICE_STOP_NAME(name)(device) +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** -#define DEVICE_RESET_NAME(name) device_reset_##name -#define DEVICE_RESET(name) void DEVICE_RESET_NAME(name)(running_device *device) -#define DEVICE_RESET_CALL(name) DEVICE_RESET_NAME(name)(device) +// configure devices +#define MDRV_DEVICE_CONFIG(_config) \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ + TOKEN_PTR(voidptr, &(_config)), -#define DEVICE_EXECUTE_NAME(name) device_execute_##name -#define DEVICE_EXECUTE(name) INT32 DEVICE_EXECUTE_NAME(name)(running_device *device, INT32 clocks) -#define DEVICE_EXECUTE_CALL(name) DEVICE_EXECUTE_NAME(name)(device, clocks) +#define MDRV_DEVICE_CONFIG_CLEAR() \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ + TOKEN_PTR(voidptr, NULL), -#define DEVICE_NVRAM_NAME(name) device_nvram_##name -#define DEVICE_NVRAM(name) void DEVICE_NVRAM_NAME(name)(running_device *device, mame_file *file, int read_or_write) -#define DEVICE_NVRAM_CALL(name) DEVICE_NVRAM_NAME(name)(device, file, read_or_write) +#define MDRV_DEVICE_CLOCK(_clock) \ + TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32), +#define MDRV_DEVICE_INLINE_DATA16(_index, _data) \ + TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_INLINE_DATA16, 8, _index, 8, (UINT16)(_data), 16), \ -// macro for specifying a clock derived from an owning device -#define DERIVED_CLOCK(num, den) (0xff000000 | ((num) << 12) | ((den) << 0)) +#define MDRV_DEVICE_INLINE_DATA32(_index, _data) \ + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_INLINE_DATA32, 8, _index, 8), \ + TOKEN_UINT32((UINT32)(_data)), +#define MDRV_DEVICE_INLINE_DATA64(_index, _data) \ + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_INLINE_DATA64, 8, _index, 8), \ + TOKEN_UINT64((UINT64)(_data)), -// shorthand for accessing devices by machine/type/tag -#define devtag_get_device(mach,tag) (mach)->device(tag) +#ifdef PTR64 +#define MDRV_DEVICE_INLINE_DATAPTR(_index, _data) MDRV_DEVICE_INLINE_DATA64(_index, (FPTR)(_data)) +#else +#define MDRV_DEVICE_INLINE_DATAPTR(_index, _data) MDRV_DEVICE_INLINE_DATA32(_index, (FPTR)(_data)) +#endif -#define devtag_reset(mach,tag) (mach)->device(tag)->reset() +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -// forward-declare these types +// forward references class region_info; class device_config; -class running_device; -union deviceinfo; +class device_config_interface; +class device_t; +class device_interface; +struct rom_entry; +union machine_config_token; +class machine_config; -// exception types +// exception classes class device_missing_dependencies : public emu_exception { }; -// device interface function types -typedef void (*device_get_config_func)(const device_config *device, UINT32 state, deviceinfo *info); -typedef int (*device_validity_check_func)(const game_driver *driver, const device_config *device); -typedef const machine_config_token *(*device_custom_config_func)(const device_config *device, UINT32 entrytype, const machine_config_token *tokens); +// a device_type is simply a pointer to its alloc function +typedef device_config *(*device_type)(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); -typedef void (*device_start_func)(running_device *device); -typedef void (*device_stop_func)(running_device *device); -typedef INT32 (*device_execute_func)(running_device *device, INT32 clocks); -typedef void (*device_reset_func)(running_device *device); -typedef void (*device_nvram_func)(running_device *device, mame_file *file, int read_or_write); -typedef void (*device_get_runtime_info_func)(running_device *device, UINT32 state, deviceinfo *info); -// a device_type is simply a pointer to its get_info function -typedef device_get_config_func device_type; +// ======================> tagged_device_list - -// tagged_device_list is a tagged_list with additional searching based on type or class -template class tagged_device_list : public tagged_list +// tagged_device_list is a tagged_list with additional searching based on type +template +class tagged_device_list : public tagged_list { typedef tagged_list super; - + public: + tagged_device_list(resource_pool &pool = global_resource_pool) + : tagged_list(pool) { } + // pull the generic forms forward using super::first; using super::count; using super::index; using super::find; - + // provide type-specific overrides T *first(device_type type) const { T *cur; - for (cur = super::first(); cur != NULL && cur->type != type; cur = cur->next) ; + for (cur = super::first(); cur != NULL && cur->type() != type; cur = cur->next()) ; return cur; } - + int count(device_type type) const { int num = 0; for (const T *curdev = first(type); curdev != NULL; curdev = curdev->typenext()) num++; return num; } - + int index(device_type type, T *object) const { int num = 0; @@ -252,13 +160,13 @@ public: if (cur == object) return num; return -1; } - + int index(device_type type, const char *tag) const { T *object = find(tag); - return (object != NULL && object->type == type) ? index(type, object) : -1; + return (object != NULL && object->type() == type) ? index(type, object) : -1; } - + T *find(device_type type, int index) const { for (T *cur = first(type); cur != NULL; cur = cur->typenext()) @@ -266,294 +174,399 @@ public: return NULL; } - // provide class-specific overrides - T *first(device_class devclass) const + // provide interface-specific overrides + template + bool first(I *&intf) const { - T *cur; - for (cur = super::first(); cur != NULL && cur->devclass != devclass; cur = cur->next) ; - return cur; - } - - int count(device_class devclass) const - { - int num = 0; - for (const T *curdev = first(devclass); curdev != NULL; curdev = curdev->classnext()) num++; - return num; - } - - int index(device_class devclass, T *object) const - { - int num = 0; - for (T *cur = first(devclass); cur != NULL; cur = cur->classnext(), num++) - if (cur == object) return num; - return -1; + for (T *cur = super::first(); cur != NULL; cur = cur->next()) + if (cur->interface(intf)) + return true; + return false; } +}; - int index(device_class devclass, const char *tag) const - { - T *object = find(tag); - return (object != NULL && object->devclass == devclass) ? index(devclass, object) : -1; - } - T *find(device_class devclass, int index) const - { - for (T *cur = first(devclass); cur != NULL; cur = cur->classnext()) - if (index-- == 0) return cur; - return NULL; - } -}; +// ======================> device_config_list // device_config_list manages a list of device_configs typedef tagged_device_list device_config_list; -// device_list manages a list of running_devices -class device_list : public tagged_device_list -{ - running_machine *machine; - static void static_reset(running_machine *machine); - static void static_stop(running_machine *machine); +// ======================> device_list +// device_list manages a list of device_ts +class device_list : public tagged_device_list +{ + running_machine *m_machine; + + static void static_reset(running_machine *machine); + static void static_exit(running_machine *machine); + static void static_pre_save(running_machine *machine, void *param); + static void static_post_load(running_machine *machine, void *param); + public: - device_list(); + device_list(resource_pool &pool = global_resource_pool); void import_config_list(const device_config_list &list, running_machine &machine); void start_all(); + void debug_setup_all(); void reset_all(); - void stop_all(); }; -// the actual deviceinfo union -union deviceinfo -{ - INT64 i; // generic integers - void * p; // generic pointers - genf * f; // generic function pointers - char * s; // generic strings - - device_start_func start; // DEVINFO_FCT_START - device_stop_func stop; // DEVINFO_FCT_STOP - device_reset_func reset; // DEVINFO_FCT_RESET - device_execute_func execute; // DEVINFO_FCT_EXECUTE - device_validity_check_func validity_check; // DEVINFO_FCT_VALIDITY_CHECK - device_custom_config_func custom_config; // DEVINFO_FCT_CUSTOM_CONFIG - device_nvram_func nvram; // DEVINFO_FCT_NVRAM - device_get_runtime_info_func get_runtime_info; // DEVINFO_FCT_GET_RUNTIME_INFO - const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION - const machine_config_token *machine_config; // DEVINFO_PTR_MACHINE_CONFIG - const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP - const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP - const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP - const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP - const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP - const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP - const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP - const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP -}; - - -// the configuration for a general device -enum device_space -{ - AS_PROGRAM = 0, - AS_DATA = 1, - AS_IO = 2 -}; - +// ======================> device_config // device_config represents a device configuration that is attached to a machine_config class device_config { DISABLE_COPYING(device_config); - -public: - device_config(const device_config *owner, device_type type, const char *tag, UINT32 clock); + + friend class device_t; + friend class device_config_interface; + template friend class tagged_list; + +protected: + // construction/destruction + device_config(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock); virtual ~device_config(); - device_config *typenext() const +public: + // iteration helpers + device_config *next() const { return m_next; } + device_config *typenext() const; + device_config *owner() const { return m_owner; } + + // interface helpers + template bool interface(const T *&intf) const { intf = dynamic_cast(this); return (intf != NULL); } + template bool next(T *&intf) const { - device_config *cur; - for (cur = this->next; cur != NULL && cur->type != type; cur = cur->next) ; - return cur; + for (device_config *cur = m_next; cur != NULL; cur = cur->m_next) + if (cur->interface(intf)) + return true; + return false; } - device_config *classnext() const - { - device_config *cur; - for (cur = this->next; cur != NULL && cur->devclass != devclass; cur = cur->next) ; - return cur; - } + // owned object helpers + astring &subtag(astring &dest, const char *tag) const; + astring &siblingtag(astring &dest, const char *tag) const; - // get state from a device config - virtual endianness_t endianness() const { return static_cast(get_config_int(DEVINFO_INT_ENDIANNESS)); } - virtual UINT8 databus_width(int spacenum = 0) const { return get_config_int(DEVINFO_INT_DATABUS_WIDTH + spacenum); } - virtual UINT8 addrbus_width(int spacenum = 0) const { return get_config_int(DEVINFO_INT_ADDRBUS_WIDTH + spacenum); } - virtual INT8 addrbus_shift(int spacenum = 0) const { return get_config_int(DEVINFO_INT_ADDRBUS_SHIFT + spacenum); } - - virtual const rom_entry *rom_region() const { return reinterpret_cast(get_config_ptr(DEVINFO_PTR_ROM_REGION)); } - virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast(get_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } - virtual const addrmap_token *internal_map(int spacenum = 0) const { return reinterpret_cast(get_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP + spacenum)); } - virtual const addrmap_token *default_map(int spacenum = 0) const { return reinterpret_cast(get_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP + spacenum)); } - - virtual const char *name() const { return get_config_string(DEVINFO_STR_NAME); } - virtual const char *family() const { return get_config_string(DEVINFO_STR_FAMILY); } - virtual const char *version() const { return get_config_string(DEVINFO_STR_VERSION); } - virtual const char *source_file() const { return get_config_string(DEVINFO_STR_SOURCE_FILE); } - virtual const char *credits() const { return get_config_string(DEVINFO_STR_CREDITS); } + // basic information getters + device_type type() const { return m_type; } + UINT32 clock() const { return m_clock; } const char *tag() const { return m_tag; } + const void *static_config() const { return m_static_config; } - INT64 get_config_int(UINT32 state) const; - void *get_config_ptr(UINT32 state) const; - genf *get_config_fct(UINT32 state) const; - const char *get_config_string(UINT32 state) const; + // methods that wrap both interface-level and device-level behavior + void process_token(UINT32 entrytype, const machine_config_token *&tokens); + void config_complete(); + bool validity_check(const game_driver &driver) const; + + //------------------- begin derived class overrides - astring &subtag(astring &dest, const char *tag) const; - astring &siblingtag(astring &dest, const char *tag) const; + // required operation overrides + virtual device_t *alloc_device(running_machine &machine) const = 0; + // optional operation overrides +protected: + virtual bool device_process_token(UINT32 entrytype, const machine_config_token *&tokens); + virtual void device_config_complete(); + virtual bool device_validity_check(const game_driver &driver) const; + + // required information overrides +public: + virtual const char *name() const = 0; + + // optional information overrides + virtual const rom_entry *rom_region() const; + virtual const machine_config_token *machine_config_tokens() const; + + //------------------- end derived class overrides + +protected: // device relationships - device_config * next; // next device (of any type/class) - device_config * owner; // device that owns us, or NULL if nobody + device_config * m_next; // next device (of any type/class) + device_config * m_owner; // device that owns us, or NULL if nobody + device_config_interface *m_interface_list; // head of interface list - // device properties - device_type type; // device type - device_class devclass; // device class + const device_type m_type; // device type + UINT32 m_clock; // device clock - // device configuration - UINT32 clock; // device clock - const addrmap_token * address_map[ADDRESS_SPACES]; // address maps for each address space - const void * static_config; // static device configuration - void * inline_config; // inline device configuration + const machine_config & m_machine_config; // reference to the machine's configuration + const void * m_static_config; // static device configuration + UINT64 m_inline_data[16]; // array of inline configuration values private: astring m_tag; // tag for this instance }; -// running_device represents a device that is live and attached to a running_machine -class running_device -{ - DISABLE_COPYING(running_device); - const device_config & m_baseconfig; +// ======================> device_config_interface + +// device_config_interface represents configuration information for a particular device interface +class device_config_interface +{ + DISABLE_COPYING(device_config_interface); -public: // private eventually - const address_space * addrspace[ADDRESS_SPACES]; // auto-discovered address spaces +protected: + // construction/destruction + device_config_interface(const machine_config &mconfig, device_config &devconfig); + virtual ~device_config_interface(); public: - running_device(running_machine &machine, const device_config &config); - virtual ~running_device(); + // casting helpers + const device_config &devconfig() const { return m_device_config; } + operator const device_config &() const { return m_device_config; } + operator const device_config *() const { return &m_device_config; } + + // iteration helpers + device_config_interface *interface_next() const { return m_interface_next; } + template bool next(T *&intf) const { return m_device_config.next(intf); } + + // optional operation overrides + virtual void interface_config_complete(); + virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); + virtual bool interface_validity_check(const game_driver &driver) const; + +protected: + const device_config & m_device_config; + const machine_config & m_machine_config; + device_config_interface * m_interface_next; +}; - const device_config &baseconfig() const { return m_baseconfig; } - inline const address_space *space(int index = 0) const; - inline const address_space *space(device_space index) const; - astring &subtag(astring &dest, const char *tag) const { return m_baseconfig.subtag(dest, tag); } - astring &siblingtag(astring &dest, const char *tag) const { return m_baseconfig.siblingtag(dest, tag); } +// ======================> device_t - const region_info *subregion(const char *tag) const; - running_device *subdevice(const char *tag) const; +// device_t represents a device that is live and attached to a running_machine +class device_t +{ + DISABLE_COPYING(device_t); - running_device *typenext() const - { - running_device *cur; - for (cur = this->next; cur != NULL && cur->type != type; cur = cur->next) ; - return cur; - } + friend class device_interface; + template friend class tagged_list; + friend class device_list; - running_device *classnext() const +protected: + // construction/destruction + device_t(running_machine &machine, const device_config &config); + virtual ~device_t(); + +public: + // iteration helpers + device_t *next() const { return m_next; } + device_t *typenext() const; + device_t *owner() const { return m_owner; } + + // interface helpers + template bool interface(T *&intf) { intf = dynamic_cast(this); return (intf != NULL); } + template bool next(T *&intf) const { - running_device *cur; - for (cur = this->next; cur != NULL && cur->devclass != devclass; cur = cur->next) ; - return cur; + for (device_t *cur = m_next; cur != NULL; cur = cur->m_next) + if (cur->interface(intf)) + return true; + return false; } - void start(); + // owned object helpers + astring &subtag(astring &dest, const char *tag) const { return m_baseconfig.subtag(dest, tag); } + astring &siblingtag(astring &dest, const char *tag) const { return m_baseconfig.siblingtag(dest, tag); } + const region_info *subregion(const char *tag) const; + device_t *subdevice(const char *tag) const; + device_t *siblingdevice(const char *tag) const; + + // configuration helpers + const device_config &baseconfig() const { return m_baseconfig; } + const region_info *region() const { return m_region; } + + // state helpers + bool started() const { return m_started; } void reset(); - void stop(); - void set_clock(UINT32 clock); - // get state from a device config - endianness_t endianness() const { return m_baseconfig.endianness(); } - UINT8 databus_width(int spacenum = 0) const { return m_baseconfig.databus_width(spacenum); } - UINT8 addrbus_width(int spacenum = 0) const { return m_baseconfig.addrbus_width(spacenum); } - INT8 addrbus_shift(int spacenum = 0) const { return m_baseconfig.addrbus_shift(spacenum); } + // clock/timing accessors + UINT32 clock() const { return m_clock; } + UINT32 unscaled_clock() const { return m_unscaled_clock; } + void set_unscaled_clock(UINT32 clock); + double clock_scale() const { return m_clock_scale; } + void set_clock_scale(double clockscale); + attotime clocks_to_attotime(UINT64 clocks) const; + UINT64 attotime_to_clocks(attotime duration) const; + + // basic information getters ... pass through to underlying config + device_type type() const { return m_baseconfig.type(); } + const char *name() const { return m_baseconfig.name(); } + const char *tag() const { return m_baseconfig.tag(); } + // machine and ROM configuration getters ... pass through to underlying config const rom_entry *rom_region() const { return m_baseconfig.rom_region(); } const machine_config_token *machine_config_tokens() const { return m_baseconfig.machine_config_tokens(); } - const addrmap_token *internal_map(int spacenum = 0) const { return m_baseconfig.internal_map(spacenum); } - const addrmap_token *default_map(int spacenum = 0) const { return m_baseconfig.default_map(spacenum); } - const char *name() const { return m_baseconfig.name(); } - const char *family() const { return m_baseconfig.family(); } - const char *version() const { return m_baseconfig.version(); } - const char *source_file() const { return m_baseconfig.source_file(); } - const char *credits() const { return m_baseconfig.credits(); } - const char *tag() const { return m_tag; } +public: + running_machine * machine; - INT64 get_config_int(UINT32 state) const { return m_baseconfig.get_config_int(state); } - void *get_config_ptr(UINT32 state) const { return m_baseconfig.get_config_ptr(state); } - genf *get_config_fct(UINT32 state) const { return m_baseconfig.get_config_fct(state); } - const char *get_config_string(UINT32 state) const { return m_baseconfig.get_config_string(state); } +protected: + // miscellaneous helpers + void start(); + void debug_setup(); + void pre_save(); + void post_load(); + void notify_clock_changed(); + + //------------------- begin derived class overrides + + // device-level overrides + virtual void device_start() = 0; + virtual void device_reset(); + virtual void device_pre_save(); + virtual void device_post_load(); + virtual void device_clock_changed(); + virtual void device_debug_setup(); + + //------------------- end derived class overrides + + running_machine & m_machine; + + // device relationships + device_t * m_next; // next device (of any type/class) + device_t * m_owner; // device that owns us, or NULL if nobody + device_interface * m_interface_list; // head of interface list + + bool m_started; // true if the start function has succeeded + UINT32 m_clock; // device clock + const region_info * m_region; // our device-local region + + const device_config & m_baseconfig; // reference to our device_config + UINT32 m_unscaled_clock; // unscaled clock + double m_clock_scale; // clock scale factor + attoseconds_t m_attoseconds_per_clock;// period in attoseconds +}; - INT64 get_runtime_int(UINT32 state); - void *get_runtime_ptr(UINT32 state); - const char *get_runtime_string(UINT32 state); - void set_address_space(int spacenum, const address_space *space); +// running_device is an alias for device_t for now +typedef device_t running_device; - // these fields are only valid once the device is attached to a machine - running_machine * machine; // machine if device is live - // device relationships - running_device * next; // next device (of any type/class) - running_device * owner; // device that owns us, or NULL if nobody - // device properties - device_type type; // device type - device_class devclass; // device class +// ======================> device_interface - // device configuration - UINT32 clock; // device clock +// device_interface represents runtime information for a particular device interface +class device_interface +{ + DISABLE_COPYING(device_interface); - // these fields are only valid if the device is live - bool started; // true if the start function has succeeded - void * token; // token if device is live - UINT32 tokenbytes; // size of the token data allocated - const region_info * region; // our device-local region +protected: + // construction/destruction + device_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_interface(); + +public: + // casting helpers + device_t &device() { return m_device; } + operator device_t &() { return m_device; } + operator device_t *() { return &m_device; } + + // iteration helpers + device_interface *interface_next() const { return m_interface_next; } + template bool next(T *&intf) const { return m_device.next(intf); } + + // optional operation overrides + virtual void interface_pre_start(); + virtual void interface_post_start(); + virtual void interface_pre_reset(); + virtual void interface_post_reset(); + virtual void interface_pre_save(); + virtual void interface_post_load(); + virtual void interface_clock_changed(); + virtual void interface_debug_setup(); + +protected: + device_interface * m_interface_next; + device_t & m_device; +}; - device_execute_func execute; // quick pointer to execute callback - device_get_runtime_info_func get_runtime_info; -private: - astring m_tag; -}; +//************************************************************************** +// INLINE FUNCTIONS +//************************************************************************** -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +// ======================> device config helpers + +// find the next device_config of the same type +inline device_config *device_config::typenext() const +{ + device_config *cur; + for (cur = m_next; cur != NULL && cur->m_type != m_type; cur = cur->m_next) ; + return cur; +} + +// create a tag for an object that is owned by this device +inline astring &device_config::subtag(astring &dest, const char *_tag) const +{ + return (this != NULL) ? dest.cpy(m_tag).cat(":").cat(_tag) : dest.cpy(_tag); +} + +// create a tag for an object that a sibling to this device +inline astring &device_config::siblingtag(astring &dest, const char *_tag) const +{ + return (this != NULL && m_owner != NULL) ? m_owner->subtag(dest, _tag) : dest.cpy(_tag); +} -/*------------------------------------------------- - space - return an address space within a - device --------------------------------------------------*/ -inline const address_space *running_device::space(int index) const + +// ======================> running device helpers + +// find the next device_t of the same type +inline device_t *device_t::typenext() const +{ + device_t *cur; + for (cur = m_next; cur != NULL && cur->type() != type(); cur = cur->m_next) ; + return cur; +} + + + +// ======================> device clock management + +// returns the current device's unscaled running clock speed +inline int device_get_clock(device_t *device) { - return addrspace[index]; + return device->unscaled_clock(); } -inline const address_space *running_device::space(device_space index) const +// sets the current device's clock speed and then adjusts for scaling +inline void device_set_clock(device_t *device, int clock) { - return space(static_cast(index)); + device->set_unscaled_clock(clock); } +// returns the current scaling factor for a device's clock speed +inline double device_get_clock_scale(device_t *device) +{ + return device->clock_scale(); +} + +// sets the current scaling factor for a device's clock speed +inline void device_set_clock_scale(device_t *device, double clockscale) +{ + device->set_clock_scale(clockscale); +} + +// converts a number of clock ticks to an attotime +inline attotime device_clocks_to_attotime(device_t *device, UINT64 clocks) +{ + return device->clocks_to_attotime(clocks); +} + +// converts a duration as attotime to device clock ticks +inline UINT64 device_attotime_to_clocks(device_t *device, attotime duration) +{ + return device->attotime_to_clocks(duration); +} #endif /* __DEVINTRF_H__ */ diff --git a/src/emu/devlegcy.c b/src/emu/devlegcy.c new file mode 100644 index 00000000000..1caaaeada8d --- /dev/null +++ b/src/emu/devlegcy.c @@ -0,0 +1,332 @@ +/*************************************************************************** + + devlegcy.c + + Legacy device helpers. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "devlegcy.h" + + +//************************************************************************** +// LEGACY DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// legacy_device_config_base - constructor +//------------------------------------------------- + +legacy_device_config_base::legacy_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config) + : device_config(mconfig, type, tag, owner, clock), + m_get_config_func(get_config), + m_inline_config(NULL) +{ + // allocate a buffer for the inline configuration + UINT32 configlen = (UINT32)get_legacy_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES); + if (configlen != 0) + m_inline_config = global_alloc_array_clear(UINT8, configlen); +} + + +//------------------------------------------------- +// ~legacy_device_config_base - destructor +//------------------------------------------------- + +legacy_device_config_base::~legacy_device_config_base() +{ + global_free(m_inline_config); +} + + +//------------------------------------------------- +// get_legacy_config_int - return a legacy +// configuration parameter as an integer +//------------------------------------------------- + +INT64 legacy_device_config_base::get_legacy_config_int(UINT32 state) const +{ + deviceinfo info = { 0 }; + (*m_get_config_func)(this, state, &info); + return info.i; +} + + +//------------------------------------------------- +// get_legacy_config_ptr - return a legacy +// configuration parameter as a pointer +//------------------------------------------------- + +void *legacy_device_config_base::get_legacy_config_ptr(UINT32 state) const +{ + deviceinfo info = { 0 }; + (*m_get_config_func)(this, state, &info); + return info.p; +} + + +//------------------------------------------------- +// get_legacy_config_fct - return a legacy +// configuration parameter as a function pointer +//------------------------------------------------- + +genf *legacy_device_config_base::get_legacy_config_fct(UINT32 state) const +{ + deviceinfo info = { 0 }; + (*m_get_config_func)(this, state, &info); + return info.f; +} + + +//------------------------------------------------- +// get_legacy_config_string - return a legacy +// configuration parameter as a string pointer +//------------------------------------------------- + +const char *legacy_device_config_base::get_legacy_config_string(UINT32 state) const +{ + deviceinfo info; + info.s = get_temp_string_buffer(); + (*m_get_config_func)(this, state, &info); + return info.s; +} + + + +//************************************************************************** +// LIVE LEGACY DEVICE +//************************************************************************** + +//------------------------------------------------- +// legacy_device_base - constructor +//------------------------------------------------- + +legacy_device_base::legacy_device_base(running_machine &_machine, const device_config &config) + : device_t(_machine, config), + m_config(downcast(config)), + m_token(NULL) +{ + int tokenbytes = m_config.get_legacy_config_int(DEVINFO_INT_TOKEN_BYTES); + if (tokenbytes != 0) + m_token = auto_alloc_array_clear(machine, UINT8, tokenbytes); +} + + +//------------------------------------------------- +// ~legacy_device_base - destructor +//------------------------------------------------- + +legacy_device_base::~legacy_device_base() +{ + if (m_started) + { + device_stop_func stop_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_STOP)); + if (stop_func != NULL) + (*stop_func)(this); + } +} + + +//------------------------------------------------- +// device_start - called to start up a device +//------------------------------------------------- + +void legacy_device_base::device_start() +{ + device_start_func start_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_START)); + assert(start_func != NULL); + (*start_func)(this); +} + + +//------------------------------------------------- +// device_reset - called to reset a device +//------------------------------------------------- + +void legacy_device_base::device_reset() +{ + device_reset_func reset_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_RESET)); + if (reset_func != NULL) + (*reset_func)(this); +} + + + +//************************************************************************** +// LEGACY SOUND DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// legacy_sound_device_config_base - constructor +//------------------------------------------------- + +legacy_sound_device_config_base::legacy_sound_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config) + : legacy_device_config_base(mconfig, type, tag, owner, clock, get_config), + device_config_sound_interface(mconfig, *this) +{ +} + + + +//************************************************************************** +// LIVE LEGACY SOUND DEVICE +//************************************************************************** + +//------------------------------------------------- +// legacy_sound_device_base - constructor +//------------------------------------------------- + +legacy_sound_device_base::legacy_sound_device_base(running_machine &machine, const device_config &config) + : legacy_device_base(machine, config), + device_sound_interface(machine, config, *this) +{ +} + + + +//************************************************************************** +// LEGACY MEMORY DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// legacy_memory_device_config_base - constructor +//------------------------------------------------- + +legacy_memory_device_config_base::legacy_memory_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config) + : legacy_device_config_base(mconfig, type, tag, owner, clock, get_config), + device_config_memory_interface(mconfig, *this) +{ + memset(&m_space_config, 0, sizeof(m_space_config)); +} + + +//------------------------------------------------- +// device_config_complete - update configuration +// based on completed device setup +//------------------------------------------------- + +void legacy_memory_device_config_base::device_config_complete() +{ + m_space_config.m_name = "memory"; + m_space_config.m_endianness = static_cast(get_legacy_config_int(DEVINFO_INT_ENDIANNESS)); + m_space_config.m_databus_width = get_legacy_config_int(DEVINFO_INT_DATABUS_WIDTH); + m_space_config.m_addrbus_width = get_legacy_config_int(DEVINFO_INT_ADDRBUS_WIDTH); + m_space_config.m_addrbus_shift = get_legacy_config_int(DEVINFO_INT_ADDRBUS_SHIFT); + m_space_config.m_logaddr_width = m_space_config.m_addrbus_width; + m_space_config.m_page_shift = 0; + m_space_config.m_internal_map = reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_INTERNAL_MEMORY_MAP)); + m_space_config.m_default_map = reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_DEFAULT_MEMORY_MAP)); +} + + + +//************************************************************************** +// LIVE LEGACY MEMORY DEVICE +//************************************************************************** + +//------------------------------------------------- +// legacy_memory_device_base - constructor +//------------------------------------------------- + +legacy_memory_device_base::legacy_memory_device_base(running_machine &machine, const device_config &config) + : legacy_device_base(machine, config), + device_memory_interface(machine, config, *this) +{ +} + + + +//************************************************************************** +// LEGACY NVRAM DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// legacy_nvram_device_config_base - constructor +//------------------------------------------------- + +legacy_nvram_device_config_base::legacy_nvram_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config) + : legacy_device_config_base(mconfig, type, tag, owner, clock, get_config), + device_config_nvram_interface(mconfig, *this) +{ +} + + + +//************************************************************************** +// LIVE LEGACY NVRAM DEVICE +//************************************************************************** + +//------------------------------------------------- +// legacy_nvram_device_base - constructor +//------------------------------------------------- + +legacy_nvram_device_base::legacy_nvram_device_base(running_machine &machine, const device_config &config) + : legacy_device_base(machine, config), + device_nvram_interface(machine, config, *this) +{ +} + + +//------------------------------------------------- +// nvram_default - generate the default NVRAM +//------------------------------------------------- + +void legacy_nvram_device_base::nvram_default() +{ + device_nvram_func nvram_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM)); + (*nvram_func)(this, NULL, FALSE); +} + + +//------------------------------------------------- +// nvram_read - read NVRAM from the given file +//------------------------------------------------- + +void legacy_nvram_device_base::nvram_read(mame_file &file) +{ + device_nvram_func nvram_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM)); + (*nvram_func)(this, &file, FALSE); +} + + +//------------------------------------------------- +// nvram_write - write NVRAM to the given file +//------------------------------------------------- + +void legacy_nvram_device_base::nvram_write(mame_file &file) +{ + device_nvram_func nvram_func = reinterpret_cast(m_config.get_legacy_config_fct(DEVINFO_FCT_NVRAM)); + (*nvram_func)(this, &file, TRUE); +} diff --git a/src/emu/devlegcy.h b/src/emu/devlegcy.h new file mode 100644 index 00000000000..2632dccbfd7 --- /dev/null +++ b/src/emu/devlegcy.h @@ -0,0 +1,583 @@ +/*************************************************************************** + + devlegcy.h + + Legacy device helpers. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __DEVLEGCY_H__ +#define __DEVLEGCY_H__ + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// state constants passed to the device_get_config_func +enum +{ + // --- the following bits of info are returned as 64-bit signed integers --- + DEVINFO_INT_FIRST = 0x00000, + + DEVINFO_INT_TOKEN_BYTES = DEVINFO_INT_FIRST, // R/O: bytes to allocate for the token + DEVINFO_INT_INLINE_CONFIG_BYTES, // R/O: bytes to allocate for the inline configuration + + DEVINFO_INT_ENDIANNESS, // R/O: either ENDIANNESS_BIG or ENDIANNESS_LITTLE + DEVINFO_INT_DATABUS_WIDTH, // R/O: data bus size for each address space (8,16,32,64) + DEVINFO_INT_DATABUS_WIDTH_0 = DEVINFO_INT_DATABUS_WIDTH + 0, + DEVINFO_INT_DATABUS_WIDTH_1 = DEVINFO_INT_DATABUS_WIDTH + 1, + DEVINFO_INT_DATABUS_WIDTH_2 = DEVINFO_INT_DATABUS_WIDTH + 2, + DEVINFO_INT_DATABUS_WIDTH_3 = DEVINFO_INT_DATABUS_WIDTH + 3, + DEVINFO_INT_DATABUS_WIDTH_LAST = DEVINFO_INT_DATABUS_WIDTH + ADDRESS_SPACES - 1, + DEVINFO_INT_ADDRBUS_WIDTH, // R/O: address bus size for each address space (12-32) + DEVINFO_INT_ADDRBUS_WIDTH_0 = DEVINFO_INT_ADDRBUS_WIDTH + 0, + DEVINFO_INT_ADDRBUS_WIDTH_1 = DEVINFO_INT_ADDRBUS_WIDTH + 1, + DEVINFO_INT_ADDRBUS_WIDTH_2 = DEVINFO_INT_ADDRBUS_WIDTH + 2, + DEVINFO_INT_ADDRBUS_WIDTH_3 = DEVINFO_INT_ADDRBUS_WIDTH + 3, + DEVINFO_INT_ADDRBUS_WIDTH_LAST = DEVINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACES - 1, + DEVINFO_INT_ADDRBUS_SHIFT, // R/O: shift applied to addresses each address space (+3 means >>3, -1 means <<1) + DEVINFO_INT_ADDRBUS_SHIFT_0 = DEVINFO_INT_ADDRBUS_SHIFT + 0, + DEVINFO_INT_ADDRBUS_SHIFT_1 = DEVINFO_INT_ADDRBUS_SHIFT + 1, + DEVINFO_INT_ADDRBUS_SHIFT_2 = DEVINFO_INT_ADDRBUS_SHIFT + 2, + DEVINFO_INT_ADDRBUS_SHIFT_3 = DEVINFO_INT_ADDRBUS_SHIFT + 3, + DEVINFO_INT_ADDRBUS_SHIFT_LAST = DEVINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACES - 1, + + DEVINFO_INT_CLASS_SPECIFIC = 0x04000, // R/W: device-specific values start here + DEVINFO_INT_DEVICE_SPECIFIC = 0x08000, // R/W: device-specific values start here + DEVINFO_INT_LAST = 0x0ffff, + + // --- the following bits of info are returned as pointers --- + DEVINFO_PTR_FIRST = 0x10000, + + DEVINFO_PTR_ROM_REGION = DEVINFO_PTR_FIRST, // R/O: pointer to device-specific ROM region + DEVINFO_PTR_MACHINE_CONFIG, // R/O: pointer to device-specific machine config + + DEVINFO_PTR_INTERNAL_MEMORY_MAP, // R/O: const addrmap_token *map + DEVINFO_PTR_INTERNAL_MEMORY_MAP_0 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 0, + DEVINFO_PTR_INTERNAL_MEMORY_MAP_1 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 1, + DEVINFO_PTR_INTERNAL_MEMORY_MAP_2 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 2, + DEVINFO_PTR_INTERNAL_MEMORY_MAP_3 = DEVINFO_PTR_INTERNAL_MEMORY_MAP + 3, + DEVINFO_PTR_INTERNAL_MEMORY_MAP_LAST = DEVINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACES - 1, + + DEVINFO_PTR_DEFAULT_MEMORY_MAP, // R/O: const addrmap_token *map + DEVINFO_PTR_DEFAULT_MEMORY_MAP_0 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 0, + DEVINFO_PTR_DEFAULT_MEMORY_MAP_1 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 1, + DEVINFO_PTR_DEFAULT_MEMORY_MAP_2 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 2, + DEVINFO_PTR_DEFAULT_MEMORY_MAP_3 = DEVINFO_PTR_DEFAULT_MEMORY_MAP + 3, + DEVINFO_PTR_DEFAULT_MEMORY_MAP_LAST = DEVINFO_PTR_DEFAULT_MEMORY_MAP + ADDRESS_SPACES - 1, + + DEVINFO_PTR_CLASS_SPECIFIC = 0x14000, // R/W: device-specific values start here + DEVINFO_PTR_DEVICE_SPECIFIC = 0x18000, // R/W: device-specific values start here + DEVINFO_PTR_LAST = 0x1ffff, + + // --- the following bits of info are returned as pointers to functions --- + DEVINFO_FCT_FIRST = 0x20000, + + DEVINFO_FCT_START = DEVINFO_FCT_FIRST, // R/O: device_start_func + DEVINFO_FCT_STOP, // R/O: device_stop_func + DEVINFO_FCT_RESET, // R/O: device_reset_func + DEVINFO_FCT_EXECUTE, // R/O: device_execute_func + DEVINFO_FCT_NVRAM, // R/O: device_nvram_func + + DEVINFO_FCT_CLASS_SPECIFIC = 0x24000, // R/W: device-specific values start here + DEVINFO_FCT_DEVICE_SPECIFIC = 0x28000, // R/W: device-specific values start here + DEVINFO_FCT_LAST = 0x2ffff, + + // --- the following bits of info are returned as NULL-terminated strings --- + DEVINFO_STR_FIRST = 0x30000, + + DEVINFO_STR_NAME = DEVINFO_STR_FIRST, // R/O: name of the device + DEVINFO_STR_FAMILY, // R/O: family of the device + DEVINFO_STR_VERSION, // R/O: version of the device + DEVINFO_STR_SOURCE_FILE, // R/O: file containing the device implementation + DEVINFO_STR_CREDITS, // R/O: credits for the device implementation + + DEVINFO_STR_CLASS_SPECIFIC = 0x34000, // R/W: device-specific values start here + DEVINFO_STR_DEVICE_SPECIFIC = 0x38000, // R/W: device-specific values start here + DEVINFO_STR_LAST = 0x3ffff +}; + + + +//************************************************************************** +// MACROS +//************************************************************************** + +#define DEVICE_GET_INFO_NAME(name) device_get_config_##name +#define DEVICE_GET_INFO(name) void DEVICE_GET_INFO_NAME(name)(const device_config *device, UINT32 state, deviceinfo *info) +#define DEVICE_GET_INFO_CALL(name) DEVICE_GET_INFO_NAME(name)(device, state, info) + +#define DEVICE_START_NAME(name) device_start_##name +#define DEVICE_START(name) void DEVICE_START_NAME(name)(device_t *device) +#define DEVICE_START_CALL(name) DEVICE_START_NAME(name)(device) + +#define DEVICE_STOP_NAME(name) device_stop_##name +#define DEVICE_STOP(name) void DEVICE_STOP_NAME(name)(device_t *device) +#define DEVICE_STOP_CALL(name) DEVICE_STOP_NAME(name)(device) + +#define DEVICE_RESET_NAME(name) device_reset_##name +#define DEVICE_RESET(name) void DEVICE_RESET_NAME(name)(device_t *device) +#define DEVICE_RESET_CALL(name) DEVICE_RESET_NAME(name)(device) + +#define DEVICE_EXECUTE_NAME(name) device_execute_##name +#define DEVICE_EXECUTE(name) INT32 DEVICE_EXECUTE_NAME(name)(device_t *device, INT32 clocks) +#define DEVICE_EXECUTE_CALL(name) DEVICE_EXECUTE_NAME(name)(device, clocks) + +#define DEVICE_NVRAM_NAME(name) device_nvram_##name +#define DEVICE_NVRAM(name) void DEVICE_NVRAM_NAME(name)(device_t *device, mame_file *file, int read_or_write) +#define DEVICE_NVRAM_CALL(name) DEVICE_NVRAM_NAME(name)(device, file, read_or_write) + + +// defined types and such for a standard legacy device +#define DECLARE_LEGACY_DEVICE(name, basename) \ + DEVICE_GET_INFO( basename ); \ + typedef legacy_device< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_device_base \ + > basename##_device; \ + typedef legacy_device_config< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_device_config_base, \ + basename##_device \ + > basename##_device_config; \ + const device_type name = basename##_device_config::static_alloc_device_config + + +// defined types and such for a sound legacy device +#define DECLARE_LEGACY_SOUND_DEVICE(name, basename) \ + DEVICE_GET_INFO( basename ); \ + typedef legacy_device< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_sound_device_base \ + > basename##_sound_device; \ + typedef legacy_device_config< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_sound_device_config_base, \ + basename##_sound_device \ + > basename##_sound_device_config; \ + const device_type SOUND_##name = basename##_sound_device_config::static_alloc_device_config + + +// defined types and such for a memory legacy device +#define DECLARE_LEGACY_MEMORY_DEVICE(name, basename) \ + DEVICE_GET_INFO( basename ); \ + typedef legacy_device< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_memory_device_base \ + > basename##_device; \ + typedef legacy_device_config< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_memory_device_config_base, \ + basename##_device \ + > basename##_device_config; \ + const device_type name = basename##_device_config::static_alloc_device_config + + +// defined types and such for a memory legacy device +#define DECLARE_LEGACY_NVRAM_DEVICE(name, basename) \ + DEVICE_GET_INFO( basename ); \ + typedef legacy_device< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_nvram_device_base \ + > basename##_device; \ + typedef legacy_device_config< \ + DEVICE_GET_INFO_NAME(basename), \ + legacy_nvram_device_config_base, \ + basename##_device \ + > basename##_device_config; \ + const device_type name = basename##_device_config::static_alloc_device_config + + + +//************************************************************************** +// DEVICE_CONFIGURATION_MACROS +//************************************************************************** + +// inline device configurations that require 32 bits of storage in the token +#define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \ + TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, _size, 4, _offset, 12), \ + TOKEN_UINT32((UINT32)(_val)), + +#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) + +#define MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val) + +#define MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val) + +#define MDRV_NEW_DEVICE_CONFIG_DATA32(_struct, _field, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field), DEVCONFIG_OFFSETOF(_struct, _field), _val) + +#define MDRV_NEW_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field[0]), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]), _val) + +#define MDRV_NEW_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ + MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(DEVCONFIG_SIZEOF(_memstruct, _member), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]) + DEVCONFIG_OFFSETOF(_memstruct, _member), _val) + + +// inline device configurations that require 32 bits of fixed-point storage in the token +#define MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(_size, _offset, _val, _fixbits) \ + TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, _size, 4, _fixbits, 6, _offset, 12), \ + TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))), + +#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val, _fixbits) + +#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY(_struct, _field, _index, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val, _fixbits) + +#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val, _fixbits) + +#define MDRV_DEVICE_NEW_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field), DEVCONFIG_OFFSETOF(_struct, _field), _val, _fixbits) + +#define MDRV_DEVICE_NEW_CONFIG_DATAFP32_ARRAY(_struct, _field, _index, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field[0]), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]), _val, _fixbits) + +#define MDRV_DEVICE_NEW_CONFIG_DATAFP32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val, _fixbits) \ + MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(DEVCONFIG_SIZEOF(_memstruct, _member), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]) + DEVCONFIG_OFFSETOF(_memstruct, _member), _val, _fixbits) + + +// inline device configurations that require 64 bits of storage in the token +#define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \ + TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, _size, 4, _offset, 12), \ + TOKEN_UINT64((UINT64)(_val)), + +#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) + +#define MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val) + +#define MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val) + +#define MDRV_DEVICE_NEW_CONFIG_DATA64(_struct, _field, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field), DEVCONFIG_OFFSETOF(_struct, _field), _val) + +#define MDRV_DEVICE_NEW_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(DEVCONFIG_SIZEOF(_struct, _field[0]), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]), _val) + +#define MDRV_DEVICE_NEW_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ + MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(DEVCONFIG_SIZEOF(_memstruct, _member), DEVCONFIG_OFFSETOF(_struct, _field) + (_index) * DEVCONFIG_SIZEOF(_struct, _field[0]) + DEVCONFIG_OFFSETOF(_memstruct, _member), _val) + + +// inline device configurations that require a pointer-sized amount of storage in the token +#ifdef PTR64 +#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_struct, _size, _offset) +#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) +#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) +#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) +#define MDRV_DEVICE_NEW_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_NEW_CONFIG_DATA64(_struct, _field, _val) +#define MDRV_DEVICE_NEW_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_NEW_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) +#define MDRV_DEVICE_NEW_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_NEW_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) +#else +#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_struct, _size, _offset) +#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) +#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) +#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) +#define MDRV_DEVICE_CONFIG_NEW_DATAPTR(_struct, _field, _val) MDRV_DEVICE_NEW_CONFIG_DATA32(_struct, _field, _val) +#define MDRV_DEVICE_CONFIG_NEW_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_NEW_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) +#define MDRV_DEVICE_CONFIG_NEW_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_NEW_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) +#endif + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +union deviceinfo; + +char *get_temp_string_buffer(void); +resource_pool &machine_get_pool(running_machine &machine); + + +// device interface function types +typedef void (*device_get_config_func)(const device_config *device, UINT32 state, deviceinfo *info); + +typedef void (*device_start_func)(device_t *device); +typedef void (*device_stop_func)(device_t *device); +typedef INT32 (*device_execute_func)(device_t *device, INT32 clocks); +typedef void (*device_reset_func)(device_t *device); +typedef void (*device_nvram_func)(device_t *device, mame_file *file, int read_or_write); + + +// the actual deviceinfo union +union deviceinfo +{ + INT64 i; // generic integers + void * p; // generic pointers + genf * f; // generic function pointers + char * s; // generic strings + + device_start_func start; // DEVINFO_FCT_START + device_stop_func stop; // DEVINFO_FCT_STOP + device_reset_func reset; // DEVINFO_FCT_RESET + device_execute_func execute; // DEVINFO_FCT_EXECUTE + device_nvram_func nvram; // DEVINFO_FCT_NVRAM + const rom_entry * romregion; // DEVINFO_PTR_ROM_REGION + const machine_config_token *machine_config; // DEVINFO_PTR_MACHINE_CONFIG + const addrmap8_token * internal_map8; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap16_token * internal_map16; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap32_token * internal_map32; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap64_token * internal_map64; // DEVINFO_PTR_INTERNAL_MEMORY_MAP + const addrmap8_token * default_map8; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap16_token * default_map16; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap32_token * default_map32; // DEVINFO_PTR_DEFAULT_MEMORY_MAP + const addrmap64_token * default_map64; // DEVINFO_PTR_DEFAULT_MEMORY_MAP +}; + + +// ======================> legacy_device_config_base + +// legacy_device_config_base describes a base configuration class for legacy devices +class legacy_device_config_base : public device_config +{ + friend class legacy_device_base; + friend class legacy_nvram_device_base; + +protected: + // construction/destruction + legacy_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config); + virtual ~legacy_device_config_base(); + + // allocators - defined in derived classes + + // basic information getters +public: + virtual const char *name() const { return get_legacy_config_string(DEVINFO_STR_NAME); } + virtual const rom_entry *rom_region() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_ROM_REGION)); } + virtual const machine_config_token *machine_config_tokens() const { return reinterpret_cast(get_legacy_config_ptr(DEVINFO_PTR_MACHINE_CONFIG)); } + + // access to legacy inline configuartion + void *inline_config() const { return m_inline_config; } + +protected: + // access to legacy configuration info + INT64 get_legacy_config_int(UINT32 state) const; + void *get_legacy_config_ptr(UINT32 state) const; + genf *get_legacy_config_fct(UINT32 state) const; + const char *get_legacy_config_string(UINT32 state) const; + + // internal state + device_get_config_func m_get_config_func; + void * m_inline_config; +}; + + + +// ======================> legacy_device_base + +// legacy_device_base serves as a common base class for legacy devices +class legacy_device_base : public device_t +{ +protected: + // construction/destruction + legacy_device_base(running_machine &_machine, const device_config &config); + virtual ~legacy_device_base(); + +public: + // access to legacy token + void *token() const { return m_token; } + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // internal state + const legacy_device_config_base & m_config; + void * m_token; +}; + + + +// ======================> legacy_sound_device_config_base + +// legacy_sound_device_config is a device_config with a sound interface +class legacy_sound_device_config_base : public legacy_device_config_base, + public device_config_sound_interface +{ +protected: + // construction/destruction + legacy_sound_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config); +}; + + + +// ======================> legacy_sound_device_base + +// legacy_sound_device is a legacy_device_base with a sound interface +class legacy_sound_device_base : public legacy_device_base, + public device_sound_interface +{ +protected: + // construction/destruction + legacy_sound_device_base(running_machine &machine, const device_config &config); +}; + + + +// ======================> legacy_memory_device_config_base + +// legacy_memory_device_config is a device_config with a memory interface +class legacy_memory_device_config_base : public legacy_device_config_base, + public device_config_memory_interface +{ +protected: + // construction/destruction + legacy_memory_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config); + + // device_config overrides + virtual void device_config_complete(); + + // device_config_memory_interface overrides + virtual const address_space_config *memory_space_config(int spacenum = 0) const { return (spacenum == 0) ? &m_space_config : NULL; } + + // internal state + address_space_config m_space_config; +}; + + + +// ======================> legacy_memory_device_base + +// legacy_memory_device is a legacy_device_base with a memory interface +class legacy_memory_device_base : public legacy_device_base, + public device_memory_interface +{ +protected: + // construction/destruction + legacy_memory_device_base(running_machine &machine, const device_config &config); +}; + + + +// ======================> legacy_nvram_device_config + +// legacy_nvram_device_config is a device_config with a nvram interface +class legacy_nvram_device_config_base : public legacy_device_config_base, + public device_config_nvram_interface +{ +protected: + // construction/destruction + legacy_nvram_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config); +}; + + + +// ======================> legacy_nvram_device + +// legacy_nvram_device is a legacy_device_base with a nvram interface +class legacy_nvram_device_base : public legacy_device_base, + public device_nvram_interface +{ +protected: + // construction/destruction + legacy_nvram_device_base(running_machine &machine, const device_config &config); + + // device_nvram_interface overrides + virtual void nvram_default(); + virtual void nvram_read(mame_file &file); + virtual void nvram_write(mame_file &file); +}; + + +// ======================> legacy_device_config + +// legacy_device_config template describes a new device_config derivative that implements +// the old device callbacks +template< + device_get_config_func _get_config, + class _config_base, + class _running_class +> +class legacy_device_config : public _config_base +{ + // construction/destruction + legacy_device_config(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock) + : _config_base(mconfig, type, tag, owner, clock, _get_config) + { + } + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + { + return global_alloc(legacy_device_config(mconfig, static_alloc_device_config, tag, owner, clock)); + } + + virtual device_t *alloc_device(running_machine &machine) const + { + return pool_alloc(machine_get_pool(machine), _running_class(machine, *this)); +// return auto_alloc(&machine, device_t(machine, *this)); + } +}; + + + +// ======================> legacy_device + +// legacy_device template describes a new device_t derivative that implements +// the old device callbacks +template< + device_get_config_func _get_config, + class _device_base +> +class legacy_device : public _device_base +{ + template< + device_get_config_func __get_config, + class __config_base, + class __running_class + > + friend class legacy_device_config; + + legacy_device(running_machine &_machine, const legacy_device_config_base &config) + : _device_base(_machine, config) + { + } +}; + + + +#endif /* __DEVLEGCY_H__ */ diff --git a/src/emu/devtempl.h b/src/emu/devtempl.h index af6060919cc..a2f96fea8e8 100644 --- a/src/emu/devtempl.h +++ b/src/emu/devtempl.h @@ -17,8 +17,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_ID(p,s) p##devicenameprefix##s #define DEVTEMPLATE_FEATURES DT_HAS_xxx | DT_HAS_yyy | ... #define DEVTEMPLATE_NAME "Device Name String" -#define DEVTEMPLATE_FAMILY "Device Family String" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_xxxx #include "devtempl.h" // for a derived device.... @@ -41,22 +39,10 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; DEVTEMPLATE_NAME - required - a string describing the device - DEVTEMPLATE_FAMILY - required - a string describing the device family - name - DEVTEMPLATE_STATE - optional - the name of the device's state structure; by default, this is assumed to be DEVTEMPLATE_ID(,_state) - DEVTEMPLATE_CLASS - optional - the device's class (default is - DEVICE_CLASS_PERIPHERAL) - - DEVTEMPLATE_VERSION - optional - the device's version string (default - is "1.0") - - DEVTEMPLATE_CREDITS - optional - the device's credit string (default - is "Copyright Nicola Salmoria and the MAME Team") - ***************************************************************************/ @@ -69,7 +55,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DT_HAS_STOP 0x0004 #define DT_HAS_EXECUTE 0x0008 #define DT_HAS_NVRAM 0x0010 -#define DT_HAS_VALIDITY_CHECK 0x0020 #define DT_HAS_CUSTOM_CONFIG 0x0040 #define DT_HAS_ROM_REGION 0x0080 #define DT_HAS_MACHINE_CONFIG 0x0100 @@ -96,10 +81,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #error DEVTEMPLATE_NAME must be specified! #endif -#ifndef DEVTEMPLATE_FAMILY -#error DEVTEMPLATE_FAMILY must be specified! -#endif - #if (((DEVTEMPLATE_FEATURES) & (DT_HAS_PROGRAM_SPACE | DT_HAS_DATA_SPACE | DT_HAS_IO_SPACE)) != 0) #ifndef DEVTEMPLATE_ENDIANNESS #error DEVTEMPLATE_ENDIANNESS must be specified if an address space is present! @@ -121,11 +102,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_STATE DEVTEMPLATE_ID(,_state) #endif -/* default to DEVICE_CLASS_PERIPHERAL */ -#ifndef DEVTEMPLATE_CLASS -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL -#endif - /* default to version 1.0 */ #ifndef DEVTEMPLATE_VERSION #define DEVTEMPLATE_VERSION "1.0" @@ -150,9 +126,6 @@ static DEVICE_EXECUTE( DEVTEMPLATE_ID(,) ); #if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM) static DEVICE_NVRAM( DEVTEMPLATE_ID(,) ); #endif -#if ((DEVTEMPLATE_FEATURES) & DT_HAS_VALIDITY_CHECK) -static DEVICE_VALIDITY_CHECK( DEVTEMPLATE_ID(,) ); -#endif #if ((DEVTEMPLATE_FEATURES) & DT_HAS_CUSTOM_CONFIG) static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_ID(,) ); #endif @@ -167,7 +140,6 @@ DEVICE_GET_INFO( DEVTEMPLATE_ID(,) ) #if ((DEVTEMPLATE_FEATURES) & DT_HAS_INLINE_CONFIG) case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(DEVTEMPLATE_ID(,_config)); break; #endif - case DEVINFO_INT_CLASS: info->i = DEVTEMPLATE_CLASS; break; #ifdef DEVTEMPLATE_ENDIANNESS case DEVINFO_INT_ENDIANNESS: info->i = DEVTEMPLATE_ENDIANNESS; break; #endif @@ -242,19 +214,9 @@ DEVICE_GET_INFO( DEVTEMPLATE_ID(,) ) #if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM) case DEVINFO_FCT_NVRAM: info->nvram = DEVTEMPLATE_ID1(DEVICE_NVRAM_NAME()); break; #endif -#if ((DEVTEMPLATE_FEATURES) & DT_HAS_VALIDITY_CHECK) - case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVTEMPLATE_ID1(DEVICE_VALIDITY_CHECK_NAME()); break; -#endif -#if ((DEVTEMPLATE_FEATURES) & DT_HAS_CUSTOM_CONFIG) - case DEVINFO_FCT_CUSTOM_CONFIG: info->custom_config = DEVTEMPLATE_ID1(DEVICE_CUSTOM_CONFIG_NAME()); break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, DEVTEMPLATE_NAME); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, DEVTEMPLATE_FAMILY); break; - case DEVINFO_STR_VERSION: strcpy(info->s, DEVTEMPLATE_VERSION); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, DEVTEMPLATE_SOURCE); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, DEVTEMPLATE_CREDITS); break; } } @@ -278,9 +240,6 @@ static DEVICE_EXECUTE( DEVTEMPLATE_DERIVED_ID(,) ); #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM) static DEVICE_NVRAM( DEVTEMPLATE_DERIVED_ID(,) ); #endif -#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_VALIDITY_CHECK) -static DEVICE_VALIDITY_CHECK( DEVTEMPLATE_DERIVED_ID(,) ); -#endif #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_CUSTOM_CONFIG) static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_DERIVED_ID(,) ); #endif @@ -337,12 +296,6 @@ DEVICE_GET_INFO( DEVTEMPLATE_DERIVED_ID(,) ) #if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM) case DEVINFO_FCT_NVRAM: info->nvram = DEVTEMPLATE_DERIVED_ID1(DEVICE_NVRAM_NAME()); break; #endif -#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_VALIDITY_CHECK) - case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVTEMPLATE_DERIVED_ID1(DEVICE_VALIDITY_CHECK_NAME()); break; -#endif -#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_CUSTOM_CONFIG) - case DEVINFO_FCT_CUSTOM_CONFIG: info->custom_config = DEVTEMPLATE_DERIVED_ID1(DEVICE_CUSTOM_CONFIG_NAME()); break; -#endif /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, DEVTEMPLATE_DERIVED_NAME); break; @@ -358,7 +311,6 @@ DEVICE_GET_INFO( DEVTEMPLATE_DERIVED_ID(,) ) #undef DT_HAS_STOP #undef DT_HAS_EXECUTE #undef DT_HAS_NVRAM -#undef DT_HAS_VALIDITY_CHECK #undef DT_HAS_CUSTOM_CONFIG #undef DT_HAS_ROM_REGION #undef DT_HAS_MACHINE_CONFIG diff --git a/src/emu/didisasm.c b/src/emu/didisasm.c new file mode 100644 index 00000000000..0d312a6f4aa --- /dev/null +++ b/src/emu/didisasm.c @@ -0,0 +1,88 @@ +/*************************************************************************** + + didisasm.c + + Device disasm interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" + + +//************************************************************************** +// DEVICE CONFIG DISASM INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_config_disasm_interface - constructor +//------------------------------------------------- + +device_config_disasm_interface::device_config_disasm_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig) +{ +} + + +//------------------------------------------------- +// ~device_config_disasm_interface - destructor +//------------------------------------------------- + +device_config_disasm_interface::~device_config_disasm_interface() +{ +} + + + +//************************************************************************** +// DEVICE DISASM INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_disasm_interface - constructor +//------------------------------------------------- + +device_disasm_interface::device_disasm_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_disasm_config(dynamic_cast(config)) +{ +} + + +//------------------------------------------------- +// ~device_disasm_interface - destructor +//------------------------------------------------- + +device_disasm_interface::~device_disasm_interface() +{ +} diff --git a/src/emu/didisasm.h b/src/emu/didisasm.h new file mode 100644 index 00000000000..8f53eebe9b9 --- /dev/null +++ b/src/emu/didisasm.h @@ -0,0 +1,125 @@ +/*************************************************************************** + + didisasm.h + + Device disassembly interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DIDISASM_H__ +#define __DIDISASM_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// Disassembler constants +const UINT32 DASMFLAG_SUPPORTED = 0x80000000; // are disassembly flags supported? +const UINT32 DASMFLAG_STEP_OUT = 0x40000000; // this instruction should be the end of a step out sequence +const UINT32 DASMFLAG_STEP_OVER = 0x20000000; // this instruction should be stepped over by setting a breakpoint afterwards +const UINT32 DASMFLAG_OVERINSTMASK = 0x18000000; // number of extra instructions to skip when stepping over +const UINT32 DASMFLAG_OVERINSTSHIFT = 27; // bits to shift after masking to get the value +const UINT32 DASMFLAG_LENGTHMASK = 0x0000ffff; // the low 16-bits contain the actual length + + + +//************************************************************************** +// MACROS +//************************************************************************** + +#define DASMFLAG_STEP_OVER_EXTRA(x) ((x) << DASMFLAG_OVERINSTSHIFT) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> device_config_disasm_interface + +// class representing interface-specific configuration disasm +class device_config_disasm_interface : public device_config_interface +{ +public: + // construction/destruction + device_config_disasm_interface(const machine_config &mconfig, device_config &device); + virtual ~device_config_disasm_interface(); + + // required configuration overrides + UINT32 min_opcode_bytes() const { return disasm_min_opcode_bytes(); } + UINT32 max_opcode_bytes() const { return disasm_max_opcode_bytes(); } + +protected: + // required configuration overrides + virtual UINT32 disasm_min_opcode_bytes() const = 0; + virtual UINT32 disasm_max_opcode_bytes() const = 0; +}; + + + +// ======================> device_disasm_interface + +// class representing interface-specific live disasm +class device_disasm_interface : public device_interface +{ +public: + // construction/destruction + device_disasm_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_disasm_interface(); + + // configuration access + const device_config_disasm_interface &disasm_config() const { return m_disasm_config; } + UINT32 min_opcode_bytes() const { return m_disasm_config.min_opcode_bytes(); } + UINT32 max_opcode_bytes() const { return m_disasm_config.max_opcode_bytes(); } + + // interface for disassembly + offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options = 0) { return disasm_disassemble(buffer, pc, oprom, opram, options); } + +protected: + // required operation overrides + virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options) = 0; + + const device_config_disasm_interface & m_disasm_config; // reference to configuration data +}; + + +#endif /* __DIDISASM_H__ */ diff --git a/src/emu/diexec.c b/src/emu/diexec.c new file mode 100644 index 00000000000..02766c063b6 --- /dev/null +++ b/src/emu/diexec.c @@ -0,0 +1,1000 @@ +/*************************************************************************** + + diexec.c + + Device execution interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "profiler.h" +#include "debugger.h" + + +//************************************************************************** +// DEBUGGING +//************************************************************************** + +#define VERBOSE 0 + +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +const int TRIGGER_INT = -2000; +const int TRIGGER_SUSPENDTIME = -4000; + + + +//************************************************************************** +// EXECUTING DEVICE CONFIG +//************************************************************************** + +//------------------------------------------------- +// device_config_execute_interface - constructor +//------------------------------------------------- + +device_config_execute_interface::device_config_execute_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig), + m_disabled(false), + m_vblank_interrupt(NULL), + m_vblank_interrupts_per_frame(0), + m_vblank_interrupt_screen(NULL), + m_timed_interrupt(NULL), + m_timed_interrupt_period(0) +{ +} + + +//------------------------------------------------- +// device_config_execute_interface - destructor +//------------------------------------------------- + +device_config_execute_interface::~device_config_execute_interface() +{ +} + + +//------------------------------------------------- +// execute_clocks_to_cycles - convert the number +// of clocks to cycles, rounding down if necessary +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_clocks_to_cycles(UINT32 clocks) const +{ + return clocks; +} + + +//------------------------------------------------- +// execute_cycles_to_clocks - convert the number +// of cycles to clocks, rounding down if necessary +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_cycles_to_clocks(UINT32 cycles) const +{ + return cycles; +} + + +//------------------------------------------------- +// execute_min_cycles - return the smallest number +// of cycles that a single instruction or +// operation can take +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_min_cycles() const +{ + return 1; +} + + +//------------------------------------------------- +// execute_max_cycles - return the maximum number +// of cycles that a single instruction or +// operation can take +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_max_cycles() const +{ + return 1; +} + + +//------------------------------------------------- +// execute_input_lines - return the total number +// of input lines for the device +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_input_lines() const +{ + return 0; +} + + +//------------------------------------------------- +// execute_default_irq_vector - return the default +// IRQ vector when an acknowledge is processed +//------------------------------------------------- + +UINT32 device_config_execute_interface::execute_default_irq_vector() const +{ + return 0; +} + + +//------------------------------------------------- +// interface_process_token - token processing for +// the sound interface +//------------------------------------------------- + +bool device_config_execute_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + switch (entrytype) + { + // disable a device + case MCONFIG_TOKEN_DIEXEC_DISABLE: + m_disabled = true; + return true; + + // VBLANK interrupt + case MCONFIG_TOKEN_DIEXEC_VBLANK_INT: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, m_vblank_interrupts_per_frame, 24); + m_vblank_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt); + m_vblank_interrupt_screen = TOKEN_GET_STRING(tokens); + return true; + + // timed interrupt + case MCONFIG_TOKEN_DIEXEC_PERIODIC_INT: + m_timed_interrupt = TOKEN_GET_PTR(tokens, cpu_interrupt); + TOKEN_EXTRACT_UINT64(tokens, m_timed_interrupt_period); + return true; + } + + return false; +} + + +//------------------------------------------------- +// interface_validity_check - validation for a +// device after the configuration has been +// constructed +//------------------------------------------------- + +bool device_config_execute_interface::interface_validity_check(const game_driver &driver) const +{ + const device_config *devconfig = crosscast(this); + bool error = false; + + /* validate the interrupts */ + if (m_vblank_interrupt != NULL) + { + if (screen_count(m_machine_config) == 0) + { + mame_printf_error("%s: %s device '%s' has a VBLANK interrupt, but the driver is screenless!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + else if (m_vblank_interrupt_screen != NULL && m_vblank_interrupts_per_frame != 0) + { + mame_printf_error("%s: %s device '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + else if (m_vblank_interrupt_screen != NULL && m_machine_config.devicelist.find(m_vblank_interrupt_screen) == NULL) + { + mame_printf_error("%s: %s device '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver.source_file, driver.name, devconfig->tag(), m_vblank_interrupt_screen); + error = true; + } + else if (m_vblank_interrupt_screen == NULL && m_vblank_interrupts_per_frame == 0) + { + mame_printf_error("%s: %s device '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + } + else if (m_vblank_interrupts_per_frame != 0) + { + mame_printf_error("%s: %s device '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + + if (m_timed_interrupt != NULL && m_timed_interrupt_period == 0) + { + mame_printf_error("%s: %s device '%s' has a timer interrupt handler with 0 period!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + else if (m_timed_interrupt == NULL && m_timed_interrupt_period != 0) + { + mame_printf_error("%s: %s device '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver.source_file, driver.name, devconfig->tag()); + error = true; + } + + return error; +} + + + +//************************************************************************** +// EXECUTING DEVICE MANAGEMENT +//************************************************************************** + +//------------------------------------------------- +// device_execute_interface - constructor +//------------------------------------------------- + +device_execute_interface::device_execute_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_machine(machine), + m_execute_config(dynamic_cast(config)), + m_nextexec(NULL), + m_driver_irq(0), + m_timedint_timer(NULL), + m_iloops(0), + m_partial_frame_timer(NULL), + m_profiler(0), + m_icount(NULL), + m_cycles_running(0), + m_cycles_stolen(0), + m_suspend(0), + m_nextsuspend(0), + m_eatcycles(0), + m_nexteatcycles(0), + m_trigger(0), + m_inttrigger(0), + m_totalcycles(0), + m_divisor(0), + m_divshift(0), + m_cycles_per_second(0), + m_attoseconds_per_cycle(0) +{ + memset(&m_localtime, 0, sizeof(m_localtime)); +} + + +//------------------------------------------------- +// ~device_execute_interface - destructor +//------------------------------------------------- + +device_execute_interface::~device_execute_interface() +{ +} + + +//------------------------------------------------- +// is_executing - return true if this device +// is within its execute function +//------------------------------------------------- + +bool device_execute_interface::is_executing() const +{ + return (this == m_machine.scheduler.currently_executing()); +} + + +//------------------------------------------------- +// cycles_remaining - return the number of cycles +// remaining in this timeslice +//------------------------------------------------- + +INT32 device_execute_interface::cycles_remaining() const +{ + return is_executing() ? *m_icount : 0; +} + + +//------------------------------------------------- +// eat_cycles - safely eats cycles so we don't +// cross a timeslice boundary +//------------------------------------------------- + +void device_execute_interface::eat_cycles(int cycles) +{ + // ignore if not the executing device + if (!is_executing()) + return; + + // clamp cycles to the icount and update + if (cycles > *m_icount) + cycles = *m_icount; + *m_icount -= cycles; +} + + +//------------------------------------------------- +// adjust_icount - apply a +/- to the current +// icount +//------------------------------------------------- + +void device_execute_interface::adjust_icount(int delta) +{ + // ignore if not the executing device + if (!is_executing()) + return; + + // aply the delta directly + *m_icount += delta; +} + + +//------------------------------------------------- +// abort_timeslice - abort execution for the +// current timeslice, allowing other devices to +// run before we run again +//------------------------------------------------- + +void device_execute_interface::abort_timeslice() +{ + // ignore if not the executing device + if (this != m_machine.scheduler.currently_executing()) + return; + + // swallow the remaining cycles + if (m_icount != NULL) + { + int delta = *m_icount; + m_cycles_stolen += delta; + m_cycles_running -= delta; + *m_icount -= delta; + } +} + + +//------------------------------------------------- +// set_irq_callback - install a driver-specific +// callback for IRQ acknowledge +//------------------------------------------------- + +void device_execute_interface::set_irq_callback(device_irq_callback callback) +{ + m_driver_irq = callback; +} + + +//------------------------------------------------- +// suspend - set a suspend reason for this device +//------------------------------------------------- + +void device_execute_interface::suspend(UINT32 reason, bool eatcycles) +{ + // set the suspend reason and eat cycles flag + m_nextsuspend |= reason; + m_nexteatcycles = eatcycles; + + // if we're active, synchronize + abort_timeslice(); +} + + +//------------------------------------------------- +// resume - clear a suspend reason for this +// device +//------------------------------------------------- + +void device_execute_interface::resume(UINT32 reason) +{ + // clear the suspend reason and eat cycles flag + m_nextsuspend &= ~reason; + + // if we're active, synchronize + abort_timeslice(); +} + + +//------------------------------------------------- +// spinuntil_time - burn cycles for a specific +// period of time +//------------------------------------------------- + +void device_execute_interface::spin_until_time(attotime duration) +{ + static int timetrig = 0; + + // suspend until the given trigger fires + suspend_until_trigger(TRIGGER_SUSPENDTIME + timetrig, true); + + // then set a timer for it + timer_set(&m_machine, duration, this, timetrig, static_timed_trigger_callback); + timetrig = (timetrig + 1) % 256; +} + + +//------------------------------------------------- +// suspend_until_trigger - suspend execution +// until the given trigger fires +//------------------------------------------------- + +void device_execute_interface::suspend_until_trigger(int trigid, bool eatcycles) +{ + // suspend the device immediately if it's not already + suspend(SUSPEND_REASON_TRIGGER, eatcycles); + + // set the trigger + m_trigger = trigid; +} + + +//------------------------------------------------- +// trigger - respond to a trigger event +//------------------------------------------------- + +void device_execute_interface::trigger(int trigid) +{ + // if we're executing, for an immediate abort + abort_timeslice(); + + // see if this is a matching trigger + if ((m_nextsuspend & SUSPEND_REASON_TRIGGER) != 0 && m_trigger == trigid) + { + resume(SUSPEND_REASON_TRIGGER); + m_trigger = 0; + } +} + + +//------------------------------------------------- +// local_time - returns the current local time +// for a device +//------------------------------------------------- + +attotime device_execute_interface::local_time() const +{ + // if we're active, add in the time from the current slice + attotime result = m_localtime; + if (is_executing()) + { + int cycles = m_cycles_running - *m_icount; + result = attotime_add(result, m_device.clocks_to_attotime(cycles)); + } + return result; +} + + +//------------------------------------------------- +// total_cycles - return the total number of +// cycles executed on this device +//------------------------------------------------- + +UINT64 device_execute_interface::total_cycles() const +{ + if (is_executing()) + return m_totalcycles + m_cycles_running - *m_icount; + else + return m_totalcycles; +} + + +//------------------------------------------------- +// execute_burn - called after we consume a bunch +// of cycles for artifical reasons (such as +// spinning devices for performance optimization) +//------------------------------------------------- + +void device_execute_interface::execute_burn(INT32 cycles) +{ + // by default, do nothing +} + + +//------------------------------------------------- +// execute_set_input - called when a synchronized +// input is changed +//------------------------------------------------- + +void device_execute_interface::execute_set_input(int linenum, int state) +{ + // by default, do nothing +} + + +//------------------------------------------------- +// interface_pre_start - work to be done prior to +// actually starting a device +//------------------------------------------------- + +void device_execute_interface::interface_pre_start() +{ + // fill in the initial states + int index = m_machine.devicelist.index(&m_device); + m_suspend = SUSPEND_REASON_RESET; + m_profiler = index + PROFILER_DEVICE_FIRST; + m_inttrigger = index + TRIGGER_INT; + + // fill in the input states and IRQ callback information + for (int line = 0; line < ARRAY_LENGTH(m_input); line++) + m_input[line].start(this, line); + + // allocate timers if we need them + if (m_execute_config.m_vblank_interrupts_per_frame > 1) + m_partial_frame_timer = timer_alloc(&m_machine, static_trigger_partial_frame_interrupt, (void *)this); + if (m_execute_config.m_timed_interrupt_period != 0) + m_timedint_timer = timer_alloc(&m_machine, static_trigger_periodic_interrupt, (void *)this); + + // register for save states + state_save_register_device_item(&m_device, 0, m_suspend); + state_save_register_device_item(&m_device, 0, m_nextsuspend); + state_save_register_device_item(&m_device, 0, m_eatcycles); + state_save_register_device_item(&m_device, 0, m_nexteatcycles); + state_save_register_device_item(&m_device, 0, m_trigger); + state_save_register_device_item(&m_device, 0, m_totalcycles); + state_save_register_device_item(&m_device, 0, m_localtime.seconds); + state_save_register_device_item(&m_device, 0, m_localtime.attoseconds); + state_save_register_device_item(&m_device, 0, m_iloops); +} + + +//------------------------------------------------- +// interface_post_start - work to be done after +// actually starting a device +//------------------------------------------------- + +void device_execute_interface::interface_post_start() +{ + // make sure somebody set us up the icount + assert_always(m_icount != NULL, "m_icount never initialized!"); +} + + +//------------------------------------------------- +// interface_pre_reset - work to be done prior to +// actually resetting a device +//------------------------------------------------- + +void device_execute_interface::interface_pre_reset() +{ + // reset the total number of cycles + m_totalcycles = 0; + + // enable all devices (except for disabled devices) + if (!m_execute_config.disabled()) + resume(SUSPEND_ANY_REASON); + else + suspend(SUSPEND_REASON_DISABLE, true); +} + + +//------------------------------------------------- +// interface_post_reset - work to be done after a +// device is reset +//------------------------------------------------- + +void device_execute_interface::interface_post_reset() +{ + // reset the interrupt vectors and queues + for (int line = 0; line < ARRAY_LENGTH(m_input); line++) + m_input[line].reset(); + + // reconfingure VBLANK interrupts + if (m_execute_config.m_vblank_interrupts_per_frame > 0 || m_execute_config.m_vblank_interrupt_screen != NULL) + { + // get the screen that will trigger the VBLANK + + // new style - use screen tag directly + screen_device *screen; + if (m_execute_config.m_vblank_interrupt_screen != NULL) + screen = downcast(m_machine.device(m_execute_config.m_vblank_interrupt_screen)); + + // old style 'hack' setup - use screen #0 + else + screen = screen_first(m_machine); + + assert(screen != NULL); + screen->register_vblank_callback(static_on_vblank, NULL); + } + + // reconfigure periodic interrupts + if (m_execute_config.m_timed_interrupt_period != 0) + { + attotime timedint_period = UINT64_ATTOTIME_TO_ATTOTIME(m_execute_config.m_timed_interrupt_period); + assert(m_timedint_timer != NULL); + timer_adjust_periodic(m_timedint_timer, timedint_period, 0, timedint_period); + } +} + + +//------------------------------------------------- +// interface_clock_changed - recomputes clock +// information for this device +//------------------------------------------------- + +void device_execute_interface::interface_clock_changed() +{ + // recompute cps and spc + m_cycles_per_second = clocks_to_cycles(m_device.clock()); + m_attoseconds_per_cycle = HZ_TO_ATTOSECONDS(m_cycles_per_second); + + // update the device's divisor + INT64 attos = m_attoseconds_per_cycle; + m_divshift = 0; + while (attos >= (1UL << 31)) + { + m_divshift++; + attos >>= 1; + } + m_divisor = attos; + + // re-compute the perfect interleave factor + m_machine.scheduler.compute_perfect_interleave(); +} + + +//------------------------------------------------- +// get_minimum_quantum - return the minimum +// quantum required for this device +//------------------------------------------------- + +attoseconds_t device_execute_interface::minimum_quantum() const +{ + // if we don't have that information, compute it + attoseconds_t basetick = m_attoseconds_per_cycle; + if (basetick == 0) + basetick = HZ_TO_ATTOSECONDS(clocks_to_cycles(m_device.clock())); + + // apply the minimum cycle count + return basetick * min_cycles(); +} + + +//------------------------------------------------- +// static_timed_trigger_callback - signal a timed +// trigger +//------------------------------------------------- + +TIMER_CALLBACK( device_execute_interface::static_timed_trigger_callback ) +{ + device_execute_interface *device = reinterpret_cast(ptr); + device->trigger(param); +} + + +//------------------------------------------------- +// on_vblank - calls any external callbacks +// for this screen +//------------------------------------------------- + +void device_execute_interface::static_on_vblank(screen_device &screen, void *param, bool vblank_state) +{ + // VBLANK starting + if (vblank_state) + { + device_execute_interface *exec; + for (bool gotone = screen.machine->devicelist.first(exec); gotone; gotone = exec->next(exec)) + exec->on_vblank_start(screen); + } +} + +void device_execute_interface::on_vblank_start(screen_device &screen) +{ + // start the interrupt counter + if (!is_suspended(SUSPEND_REASON_DISABLE)) + m_iloops = 0; + else + m_iloops = -1; + + // the hack style VBLANK decleration always uses the first screen + bool interested = false; + if (m_execute_config.m_vblank_interrupts_per_frame > 1) + interested = true; + + // for new style declaration, we need to compare the tags + else if (m_execute_config.m_vblank_interrupt_screen != NULL) + interested = (strcmp(screen.tag(), m_execute_config.m_vblank_interrupt_screen) == 0); + + // if interested, call the interrupt handler + if (interested) + { + if (!is_suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) + (*m_execute_config.m_vblank_interrupt)(&m_device); + + // if we have more than one interrupt per frame, start the timer now to trigger the rest of them + if (m_execute_config.m_vblank_interrupts_per_frame > 1 && !is_suspended(SUSPEND_REASON_DISABLE)) + { + m_partial_frame_period = attotime_div(m_machine.primary_screen->frame_period(), m_execute_config.m_vblank_interrupts_per_frame); + timer_adjust_oneshot(m_partial_frame_timer, m_partial_frame_period, 0); + } + } +} + + +//------------------------------------------------- +// static_trigger_partial_frame_interrupt - +// called to trigger a partial frame interrupt +//------------------------------------------------- + +TIMER_CALLBACK( device_execute_interface::static_trigger_partial_frame_interrupt ) +{ + reinterpret_cast(ptr)->trigger_partial_frame_interrupt(); +} + +void device_execute_interface::trigger_partial_frame_interrupt() +{ + // when we hit 0, reset to the total count + if (m_iloops == 0) + m_iloops = m_execute_config.m_vblank_interrupts_per_frame; + + // count one more "iloop" + m_iloops--; + + // call the interrupt handler if we're not suspended + if (!is_suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) + (*m_execute_config.m_vblank_interrupt)(&m_device); + + // set up to retrigger if there's more interrupts to generate + if (m_iloops > 1) + timer_adjust_oneshot(m_partial_frame_timer, m_partial_frame_period, 0); +} + + +//------------------------------------------------- +// static_trigger_periodic_interrupt - timer +// callback for timed interrupts +//------------------------------------------------- + +TIMER_CALLBACK( device_execute_interface::static_trigger_periodic_interrupt ) +{ + reinterpret_cast(ptr)->trigger_periodic_interrupt(); +} + +void device_execute_interface::trigger_periodic_interrupt() +{ + // bail if there is no routine + if (m_execute_config.m_timed_interrupt != NULL && !is_suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE)) + (*m_execute_config.m_timed_interrupt)(&m_device); +} + + +//------------------------------------------------- +// static_standard_irq_callback - IRQ acknowledge +// callback; handles HOLD_LINE case and signals +// to the debugger +//------------------------------------------------- + +IRQ_CALLBACK( device_execute_interface::static_standard_irq_callback ) +{ + return device_execute(device)->standard_irq_callback(irqline); +} + +int device_execute_interface::standard_irq_callback(int irqline) +{ + // get the default vector and acknowledge the interrupt if needed + int vector = m_input[irqline].default_irq_callback(); + LOG(("static_standard_irq_callback('%s', %d) $%04x\n", m_device.tag(), irqline, vector)); + + // if there's a driver callback, run it to get the vector + if (m_driver_irq != NULL) + vector = (*m_driver_irq)(&m_device, irqline); + + // notify the debugger + debugger_interrupt_hook(&m_device, irqline); + return vector; +} + + + +//************************************************************************** +// DEVICE INPUT +//************************************************************************** + +//------------------------------------------------- +// device_input - constructor +//------------------------------------------------- + +device_execute_interface::device_input::device_input() + : m_execute(NULL), + m_device(NULL), + m_linenum(0), + m_stored_vector(0), + m_curvector(0), + m_curstate(CLEAR_LINE), + m_qindex(0) +{ + memset(m_queue, 0, sizeof(m_queue)); +} + + +//------------------------------------------------- +// start - called by interface_pre_start so we +// can set ourselves up +//------------------------------------------------- + +void device_execute_interface::device_input::start(device_execute_interface *execute, int linenum) +{ + m_execute = execute; + m_device = &m_execute->m_device; + m_linenum = linenum; + + reset(); + + state_save_register_device_item(m_device, m_linenum, m_stored_vector); + state_save_register_device_item(m_device, m_linenum, m_curvector); + state_save_register_device_item(m_device, m_linenum, m_curstate); +} + + +//------------------------------------------------- +// reset - reset our input states +//------------------------------------------------- + +void device_execute_interface::device_input::reset() +{ + m_curvector = m_stored_vector = m_execute->default_irq_vector(); + m_qindex = 0; +} + + +//------------------------------------------------- +// set_state_synced - enqueue an event for later +// execution via timer +//------------------------------------------------- + +void device_execute_interface::device_input::set_state_synced(int state, int vector) +{ + LOG(("set_state_synced('%s',%d,%d,%02x)\n", m_device->tag(), m_linenum, state, vector)); + + // treat PULSE_LINE as ASSERT+CLEAR + if (state == PULSE_LINE) + { + // catch errors where people use PULSE_LINE for devices that don't support it + if (m_linenum != INPUT_LINE_NMI && m_linenum != INPUT_LINE_RESET) + throw emu_fatalerror("device '%s': PULSE_LINE can only be used for NMI and RESET lines\n", m_device->tag()); + + set_state_synced(ASSERT_LINE, vector); + set_state_synced(CLEAR_LINE, vector); + return; + } + + // if we're full of events, flush the queue and log a message + int event_index = m_qindex++; + if (event_index >= ARRAY_LENGTH(m_queue)) + { + m_qindex--; + empty_event_queue(); + event_index = m_qindex++; + logerror("Exceeded pending input line event queue on device '%s'!\n", m_device->tag()); + } + + // enqueue the event + if (event_index < ARRAY_LENGTH(m_queue)) + { + if (vector == USE_STORED_VECTOR) + vector = m_stored_vector; + m_queue[event_index] = (state & 0xff) | (vector << 8); + + // if this is the first one, set the timer + if (event_index == 0) + timer_call_after_resynch(&m_execute->m_machine, (void *)this, 0, static_empty_event_queue); + } +} + + +//------------------------------------------------- +// empty_event_queue - empty our event queue +//------------------------------------------------- + +TIMER_CALLBACK( device_execute_interface::device_input::static_empty_event_queue ) +{ + reinterpret_cast(ptr)->empty_event_queue(); +} + +void device_execute_interface::device_input::empty_event_queue() +{ + // loop over all events + for (int curevent = 0; curevent < m_qindex; curevent++) + { + INT32 input_event = m_queue[curevent]; + + // set the input line state and vector + m_curstate = input_event & 0xff; + m_curvector = input_event >> 8; + + assert(m_curstate == ASSERT_LINE || m_curstate == HOLD_LINE || m_curstate == CLEAR_LINE); + + // special case: RESET + if (m_linenum == INPUT_LINE_RESET) + { + // if we're asserting the line, just halt the device + if (m_curstate == ASSERT_LINE) + m_execute->suspend(SUSPEND_REASON_RESET, true); + + // if we're clearing the line that was previously asserted, reset the device + else if (m_execute->is_suspended(SUSPEND_REASON_RESET)) + { + m_device->reset(); + m_execute->resume(SUSPEND_REASON_RESET); + } + } + + // special case: HALT + else if (m_linenum == INPUT_LINE_HALT) + { + // if asserting, halt the device + if (m_curstate == ASSERT_LINE) + m_execute->suspend(SUSPEND_REASON_HALT, true); + + // if clearing, unhalt the device + else if (m_curstate == CLEAR_LINE) + m_execute->resume(SUSPEND_REASON_HALT); + } + + // all other cases + else + { + // switch off the requested state + switch (m_curstate) + { + case HOLD_LINE: + case ASSERT_LINE: + m_execute->execute_set_input(m_linenum, ASSERT_LINE); + break; + + case CLEAR_LINE: + m_execute->execute_set_input(m_linenum, CLEAR_LINE); + break; + + default: + logerror("empty_event_queue device '%s', line %d, unknown state %d\n", m_device->tag(), m_linenum, m_curstate); + break; + } + + // generate a trigger to unsuspend any devices waiting on the interrupt + if (m_curstate != CLEAR_LINE) + m_execute->signal_interrupt_trigger(); + } + } + + // reset counter + m_qindex = 0; +} + + +//------------------------------------------------- +// default_irq_callback - the default IRQ +// callback for this input line +//------------------------------------------------- + +int device_execute_interface::device_input::default_irq_callback() +{ + int vector = m_curvector; + + // if the IRQ state is HOLD_LINE, clear it + if (m_curstate == HOLD_LINE) + { + LOG(("->set_irq_line('%s',%d,%d)\n", m_device->tag(), m_linenum, CLEAR_LINE)); + m_execute->execute_set_input(m_linenum, CLEAR_LINE); + m_curstate = CLEAR_LINE; + } + return vector; +} diff --git a/src/emu/diexec.h b/src/emu/diexec.h new file mode 100644 index 00000000000..51c828b9d98 --- /dev/null +++ b/src/emu/diexec.h @@ -0,0 +1,519 @@ +/*************************************************************************** + + diexec.h + + Device execution interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DIEXEC_H__ +#define __DIEXEC_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// suspension reasons for executing devices +const UINT32 SUSPEND_REASON_HALT = 0x0001; // HALT line set (or equivalent) +const UINT32 SUSPEND_REASON_RESET = 0x0002; // RESET line set (or equivalent) +const UINT32 SUSPEND_REASON_SPIN = 0x0004; // currently spinning +const UINT32 SUSPEND_REASON_TRIGGER = 0x0008; // waiting for a trigger +const UINT32 SUSPEND_REASON_DISABLE = 0x0010; // disabled (due to disable flag) +const UINT32 SUSPEND_REASON_TIMESLICE = 0x0020; // waiting for the next timeslice +const UINT32 SUSPEND_ANY_REASON = ~0; // all of the above + + +// I/O line states +enum line_state +{ + CLEAR_LINE = 0, // clear (a fired or held) line + ASSERT_LINE, // assert an interrupt immediately + HOLD_LINE, // hold interrupt line until acknowledged + PULSE_LINE // pulse interrupt line instantaneously (only for NMI, RESET) +}; + + +// I/O line definitions +enum +{ + // input lines + MAX_INPUT_LINES = 32+3, + INPUT_LINE_IRQ0 = 0, + INPUT_LINE_IRQ1 = 1, + INPUT_LINE_IRQ2 = 2, + INPUT_LINE_IRQ3 = 3, + INPUT_LINE_IRQ4 = 4, + INPUT_LINE_IRQ5 = 5, + INPUT_LINE_IRQ6 = 6, + INPUT_LINE_IRQ7 = 7, + INPUT_LINE_IRQ8 = 8, + INPUT_LINE_IRQ9 = 9, + INPUT_LINE_NMI = MAX_INPUT_LINES - 3, + + // special input lines that are implemented in the core + INPUT_LINE_RESET = MAX_INPUT_LINES - 2, + INPUT_LINE_HALT = MAX_INPUT_LINES - 1 +}; + + + +//************************************************************************** +// MACROS +//************************************************************************** + +// IRQ callback to be called by device implementations when an IRQ is actually taken +#define IRQ_CALLBACK(func) int func(device_t *device, int irqline) + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_DEVICE_DISABLE() \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DIEXEC_DISABLE, 8), \ + +#define MDRV_DEVICE_VBLANK_INT(_tag, _func) \ + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIEXEC_VBLANK_INT, 8, 0, 24), \ + TOKEN_PTR(device_interrupt, _func), \ + TOKEN_PTR(stringptr, _tag), \ + +#define MDRV_DEVICE_PERIODIC_INT(_func, _rate) \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DIEXEC_PERIODIC_INT, 8), \ + TOKEN_PTR(device_interrupt, _func), \ + TOKEN_UINT64(UINT64_ATTOTIME_IN_HZ(_rate)), \ + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class emu_timer; +class screen_device; + + +// interrupt callback for VBLANK and timed interrupts +typedef void (*device_interrupt_func)(device_t *device); + +// IRQ callback to be called by executing devices when an IRQ is actually taken +typedef int (*device_irq_callback)(device_t *device, int irqnum); + + + +// ======================> device_config_execute_interface + +// class representing interface-specific configuration state +class device_config_execute_interface : public device_config_interface +{ + friend class device_execute_interface; + +public: + // construction/destruction + device_config_execute_interface(const machine_config &mconfig, device_config &devconfig); + virtual ~device_config_execute_interface(); + + // basic information getters + bool disabled() const { return m_disabled; } + + // clock and cycle information getters + UINT32 clocks_to_cycles(UINT32 clocks) const { return execute_clocks_to_cycles(clocks); } + UINT32 cycles_to_clocks(UINT32 cycles) const { return execute_cycles_to_clocks(cycles); } + UINT32 min_cycles() const { return execute_min_cycles(); } + UINT32 max_cycles() const { return execute_max_cycles(); } + + // input line information getters + UINT32 input_lines() const { return execute_input_lines(); } + UINT32 default_irq_vector() const { return execute_default_irq_vector(); } + +protected: + // clock and cycle information getters + virtual UINT32 execute_clocks_to_cycles(UINT32 clocks) const; + virtual UINT32 execute_cycles_to_clocks(UINT32 cycles) const; + virtual UINT32 execute_min_cycles() const; + virtual UINT32 execute_max_cycles() const; + + // input line information getters + virtual UINT32 execute_input_lines() const; + virtual UINT32 execute_default_irq_vector() const; + + // optional operation overrides + virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); + virtual bool interface_validity_check(const game_driver &driver) const; + + bool m_disabled; + device_interrupt_func m_vblank_interrupt; // for interrupts tied to VBLANK + int m_vblank_interrupts_per_frame; // usually 1 + const char * m_vblank_interrupt_screen; // the screen that causes the VBLANK interrupt + device_interrupt_func m_timed_interrupt; // for interrupts not tied to VBLANK + UINT64 m_timed_interrupt_period; // period for periodic interrupts +}; + + + +// ======================> device_execute_interface + +class device_execute_interface : public device_interface +{ + friend class device_scheduler; + +public: + // construction/destruction + device_execute_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_execute_interface(); + + // configuration access + const device_config_execute_interface &execute_config() const { return m_execute_config; } + + // basic information getters + bool disabled() const { return m_execute_config.disabled(); } + + // execution management + bool is_executing() const; + INT32 cycles_remaining() const; + void eat_cycles(int cycles); + void adjust_icount(int delta); + void abort_timeslice(); + + // input and interrupt management + void set_input_line(int linenum, int state) { m_input[linenum].set_state_synced(state); } + void set_input_line_vector(int linenum, int vector) { m_input[linenum].set_vector(vector); } + void set_input_line_and_vector(int linenum, int state, int vector) { m_input[linenum].set_state_synced(state, vector); } + int input_state(int linenum) { return m_input[linenum].m_curstate; } + void set_irq_callback(device_irq_callback callback); + + // deprecated, but still needed for older drivers + int iloops() const { return m_iloops; } + + // suspend/resume + void suspend(UINT32 reason, bool eatcycles); + void resume(UINT32 reason); + bool is_suspended(UINT32 reason = SUSPEND_ANY_REASON) { return (m_nextsuspend & reason) != 0; } + void yield() { suspend(SUSPEND_REASON_TIMESLICE, false); } + void spin() { suspend(SUSPEND_REASON_TIMESLICE, true); } + void spin_until_trigger(int trigid) { suspend_until_trigger(trigid, true); } + void spin_until_time(attotime duration); + void spin_until_interrupt() { spin_until_trigger(m_inttrigger); } + + // triggers + void suspend_until_trigger(int trigid, bool eatcycles); + void trigger(int trigid); + void signal_interrupt_trigger() { trigger(m_inttrigger); } + + // time and cycle accounting + attotime local_time() const; + UINT64 total_cycles() const; + + // clock and cycle information getters ... pass through to underlying config + UINT32 clocks_to_cycles(UINT32 clocks) const { return m_execute_config.clocks_to_cycles(clocks); } + UINT32 cycles_to_clocks(UINT32 cycles) const { return m_execute_config.cycles_to_clocks(cycles); } + UINT32 min_cycles() const { return m_execute_config.min_cycles(); } + UINT32 max_cycles() const { return m_execute_config.max_cycles(); } + + // input line information getters + UINT32 input_lines() const { return m_execute_config.input_lines(); } + UINT32 default_irq_vector() const { return m_execute_config.default_irq_vector(); } + + // required operation overrides + INT32 run(INT32 clocks) { return execute_run(clocks); } + +protected: + // optional operation overrides + virtual INT32 execute_run(INT32 clocks) = 0; + virtual void execute_burn(INT32 cycles); + virtual void execute_set_input(int linenum, int state); + + // interface-level overrides + virtual void interface_pre_start(); + virtual void interface_post_start(); + virtual void interface_pre_reset(); + virtual void interface_post_reset(); + virtual void interface_clock_changed(); + + // for use by devcpu for now... + static IRQ_CALLBACK( static_standard_irq_callback ); + int standard_irq_callback(int irqline); + + // internal information about the state of inputs + class device_input + { + static const int USE_STORED_VECTOR = 0xff000000; + + public: + device_input(); + + void start(device_execute_interface *execute, int linenum); + void reset(); + + void set_state_synced(int state, int vector = USE_STORED_VECTOR); + void set_vector(int vector) { m_stored_vector = vector; } + int default_irq_callback(); + + device_execute_interface *m_execute;// pointer to the execute interface + device_t * m_device; // pointer to our device + int m_linenum; // which input line we are + + INT32 m_stored_vector; // most recently written vector + INT32 m_curvector; // most recently processed vector + UINT8 m_curstate; // most recently processed state + INT32 m_queue[32]; // queue of pending events + int m_qindex; // index within the queue + + private: + static void static_empty_event_queue(running_machine *machine, void *ptr, int param); + void empty_event_queue(); + }; + + // configuration + running_machine & m_machine; // reference to owning machine + const device_config_execute_interface &m_execute_config; // reference to our device_config_execute_interface + + // execution lists + device_execute_interface *m_nextexec; // pointer to the next device to execute, in order + + // input states and IRQ callbacks + device_irq_callback m_driver_irq; // driver-specific IRQ callback + device_input m_input[MAX_INPUT_LINES]; // data about inputs + emu_timer * m_timedint_timer; // reference to this device's periodic interrupt timer + + // these below are hacks to support multiple interrupts per frame + INT32 m_iloops; // number of interrupts remaining this frame + emu_timer * m_partial_frame_timer; // the timer that triggers partial frame interrupts + attotime m_partial_frame_period; // the length of one partial frame for interrupt purposes + + // cycle counting and executing + int m_profiler; // profiler tag + int * m_icount; // pointer to the icount + int m_cycles_running; // number of cycles we are executing + int m_cycles_stolen; // number of cycles we artificially stole + + // suspend states + UINT32 m_suspend; // suspend reason mask (0 = not suspended) + UINT32 m_nextsuspend; // pending suspend reason mask + UINT8 m_eatcycles; // true if we eat cycles while suspended + UINT8 m_nexteatcycles; // pending value + INT32 m_trigger; // pending trigger to release a trigger suspension + INT32 m_inttrigger; // interrupt trigger index + + // clock and timing information + UINT64 m_totalcycles; // total device cycles executed + attotime m_localtime; // local time, relative to the timer system's global time + INT32 m_divisor; // 32-bit attoseconds_per_cycle divisor + UINT8 m_divshift; // right shift amount to fit the divisor into 32 bits + UINT32 m_cycles_per_second; // cycles per second, adjusted for multipliers + attoseconds_t m_attoseconds_per_cycle; // attoseconds per adjusted clock cycle + +private: + // callbacks + static void static_timed_trigger_callback(running_machine *machine, void *ptr, int param); + + static void static_on_vblank(screen_device &screen, void *param, bool vblank_state); + void on_vblank_start(screen_device &screen); + + static void static_trigger_partial_frame_interrupt(running_machine *machine, void *ptr, int param); + void trigger_partial_frame_interrupt(); + + static void static_trigger_periodic_interrupt(running_machine *machine, void *ptr, int param); + void trigger_periodic_interrupt(); + + attoseconds_t minimum_quantum() const; +}; + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// device_execute - return a pointer to the device +// execute interface for this device +//------------------------------------------------- + +inline device_execute_interface *device_execute(device_t *device) +{ + device_execute_interface *intf; + if (!device->interface(intf)) + throw emu_fatalerror("Device '%s' does not have execute interface", device->tag()); + return intf; +} + + + +// ======================> device scheduling + +// suspend the given device for a specific reason +inline void device_suspend(device_t *device, int reason, bool eatcycles) +{ + device_execute(device)->suspend(reason, eatcycles); +} + +// resume the given device for a specific reason +inline void device_resume(device_t *device, int reason) +{ + device_execute(device)->resume(reason); +} + +// return TRUE if the given device is within its execute function +inline bool device_is_executing(device_t *device) +{ + return device_execute(device)->is_executing(); +} + +// returns TRUE if the given device is suspended for any of the given reasons +inline int device_is_suspended(device_t *device, int reason) +{ + return device_execute(device)->is_suspended(reason); +} + + + +// ======================> synchronization helpers + +// yield the given device until the end of the current timeslice +inline void device_yield(device_t *device) +{ + device_execute(device)->yield(); +} + +// burn device cycles until the end of the current timeslice +inline void device_spin(device_t *device) +{ + device_execute(device)->spin(); +} + +// burn specified device cycles until a trigger +inline void device_spin_until_trigger(device_t *device, int trigger) +{ + device_execute(device)->spin_until_trigger(trigger); +} + +// burn device cycles for a specific period of time +inline void device_spin_until_time(device_t *device, attotime duration) +{ + device_execute(device)->spin_until_time(duration); +} + + + +// ======================> device timing + +// returns the current local time for a device +inline attotime device_get_local_time(device_t *device) +{ + return device_execute(device)->local_time(); +} + +// returns the total number of executed cycles for a given device +inline UINT64 device_get_total_cycles(device_t *device) +{ + return device_execute(device)->total_cycles(); +} + +// safely eats cycles so we don't cross a timeslice boundary +inline void device_eat_cycles(device_t *device, int cycles) +{ + device_execute(device)->eat_cycles(cycles); +} + +// apply a +/- to the current icount +inline void device_adjust_icount(device_t *device, int delta) +{ + device_execute(device)->adjust_icount(delta); +} + +// abort execution for the current timeslice, allowing other devices to run before we run again +inline void device_abort_timeslice(device_t *device) +{ + device_execute(device)->abort_timeslice(); +} + + + +// ======================> triggers + +// generate a trigger corresponding to an interrupt on the given device +inline void device_triggerint(device_t *device) +{ + device_execute(device)->signal_interrupt_trigger(); +} + + + +// ======================> interrupts + +// set the logical state (ASSERT_LINE/CLEAR_LINE) of the an input line on a device +inline void device_set_input_line(device_t *device, int line, int state) +{ + device_execute(device)->set_input_line(line, state); +} + +// set the vector to be returned during a device's interrupt acknowledge cycle +inline void device_set_input_line_vector(device_t *device, int line, int vector) +{ + device_execute(device)->set_input_line_vector(line, vector); +} + +// set the logical state (ASSERT_LINE/CLEAR_LINE) of the an input line on a device and its associated vector +inline void device_set_input_line_and_vector(device_t *device, int line, int state, int vector) +{ + device_execute(device)->set_input_line_and_vector(line, state, vector); +} + +// install a driver-specific callback for IRQ acknowledge +inline void device_set_irq_callback(device_t *device, device_irq_callback callback) +{ + device_execute(device)->set_irq_callback(callback); +} + + + +// ======================> additional helpers + +// burn device cycles until the next interrupt +inline void device_spin_until_interrupt(device_t *device) +{ + device_execute(device)->spin_until_interrupt(); +} + + + +#endif /* __DIEXEC_H__ */ diff --git a/src/emu/dimemory.c b/src/emu/dimemory.c new file mode 100644 index 00000000000..e0e6f32549e --- /dev/null +++ b/src/emu/dimemory.c @@ -0,0 +1,368 @@ +/*************************************************************************** + + dimemory.c + + Device memory interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "validity.h" + + +//************************************************************************** +// PARAMETERS +//************************************************************************** + +#define DETECT_OVERLAPPING_MEMORY (0) + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +const int TRIGGER_SUSPENDTIME = -4000; + + + +//************************************************************************** +// MEMORY DEVICE CONFIG +//************************************************************************** + +//------------------------------------------------- +// device_config_memory_interface - constructor +//------------------------------------------------- + +device_config_memory_interface::device_config_memory_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig) +{ + // initialize remaining members + memset(m_address_map, 0, sizeof(m_address_map)); +} + + +//------------------------------------------------- +// device_config_memory_interface - destructor +//------------------------------------------------- + +device_config_memory_interface::~device_config_memory_interface() +{ +} + + +//------------------------------------------------- +// memory_space_config - return configuration for +// the given space by index, or NULL if the space +// does not exist +//------------------------------------------------- + +const address_space_config *device_config_memory_interface::memory_space_config(int spacenum) const +{ + return NULL; +} + + +//------------------------------------------------- +// interface_process_token - token processing for +// the memory interface +//------------------------------------------------- + +bool device_config_memory_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + UINT32 data32; + + switch (entrytype) + { + // specify device address map + case MCONFIG_TOKEN_DIMEMORY_MAP: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 8); + assert(data32 < ARRAY_LENGTH(m_address_map)); + m_address_map[data32] = TOKEN_GET_PTR(tokens, addrmap); + return true; + } + + return false; +} + + +//------------------------------------------------- +// interface_validity_check - perform validity +// checks on the memory configuration +//------------------------------------------------- + +bool device_config_memory_interface::interface_validity_check(const game_driver &driver) const +{ + const device_config *devconfig = crosscast(this); + bool detected_overlap = DETECT_OVERLAPPING_MEMORY ? false : true; + bool error = false; + + // loop over all address spaces + for (int spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) + { + const address_space_config *spaceconfig = space_config(spacenum); + if (spaceconfig != NULL) + { + int datawidth = spaceconfig->m_databus_width; + int alignunit = datawidth / 8; + + // construct the maps + ::address_map *map = address_map_alloc(devconfig, &driver, spacenum, NULL); + + // if this is an empty map, just skip it + if (map->entrylist == NULL) + { + address_map_free(map); + continue; + } + + // validate the global map parameters + if (map->spacenum != spacenum) + { + mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver.source_file, driver.name, devconfig->tag(), spacenum, map->spacenum); + error = true; + } + if (map->databits != datawidth) + { + mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, datawidth, map->databits); + error = true; + } + + // loop over entries and look for errors + for (address_map_entry *entry = map->entrylist; entry != NULL; entry = entry->next) + { + UINT32 bytestart = spaceconfig->addr2byte(entry->addrstart); + UINT32 byteend = spaceconfig->addr2byte_end(entry->addrend); + + // look for overlapping entries + if (!detected_overlap) + { + address_map_entry *scan; + for (scan = map->entrylist; scan != entry; scan = scan->next) + if (entry->addrstart <= scan->addrend && entry->addrend >= scan->addrstart && + ((entry->read.type != AMH_NONE && scan->read.type != AMH_NONE) || + (entry->write.type != AMH_NONE && scan->write.type != AMH_NONE))) + { + mame_printf_warning("%s: %s '%s' %s space has overlapping memory (%X-%X,%d,%d) vs (%X-%X,%d,%d)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->read.type, entry->write.type, scan->addrstart, scan->addrend, scan->read.type, scan->write.type); + detected_overlap = true; + break; + } + } + + // look for inverted start/end pairs + if (byteend < bytestart) + { + mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver.source_file, driver.name, spaceconfig->m_name, entry->addrstart, entry->addrend); + error = true; + } + + // look for misaligned entries + if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1)) + { + mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver.source_file, driver.name, spaceconfig->m_name, entry->addrstart, entry->addrend, alignunit); + error = true; + } + + // if this is a program space, auto-assign implicit ROM entries + if (entry->read.type == AMH_ROM && entry->region == NULL) + { + entry->region = devconfig->tag(); + entry->rgnoffs = entry->addrstart; + } + + // if this entry references a memory region, validate it + if (entry->region != NULL && entry->share == 0) + { + // look for the region + bool found = false; + for (const rom_source *source = rom_first_source(&driver, &m_machine_config); source != NULL && !found; source = rom_next_source(&driver, &m_machine_config, source)) + for (const rom_entry *romp = rom_first_region(&driver, source); !ROMENTRY_ISEND(romp) && !found; romp++) + { + const char *regiontag = ROMREGION_GETTAG(romp); + if (regiontag != NULL) + { + astring fulltag; + rom_region_name(fulltag, &driver, source, romp); + if (fulltag.cmp(entry->region) == 0) + { + // verify the address range is within the region's bounds + offs_t length = ROMREGION_GETLENGTH(romp); + if (entry->rgnoffs + (byteend - bytestart + 1) > length) + { + mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->region, length); + error = true; + } + found = true; + } + } + } + + // error if not found + if (!found) + { + mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->addrstart, entry->addrend, entry->region); + error = true; + } + } + + // make sure all devices exist + if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && m_machine_config.devicelist.find(entry->read.tag) == NULL) || + (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && m_machine_config.devicelist.find(entry->write.tag) == NULL)) + { + mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->write.tag); + error = true; + } + + // make sure ports exist +// if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && portlist.find(entry->read.tag) == NULL) || +// (entry->write.type == AMH_PORT && entry->write.tag != NULL && portlist.find(entry->write.tag) == NULL)) +// { +// mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver.source_file, driver.name, devconfig->tag(), spaceconfig->m_name, entry->read.tag); +// error = true; +// } + + // validate bank and share tags + if (entry->read.type == AMH_BANK && !validate_tag(&driver, "bank", entry->read.tag)) + error = true ; + if (entry->write.type == AMH_BANK && !validate_tag(&driver, "bank", entry->write.tag)) + error = true; + if (entry->share != NULL && !validate_tag(&driver, "share", entry->share)) + error = true; + } + + // release the address map + address_map_free(map); + } + } + return error; +} + + + +//************************************************************************** +// MEMORY DEVICE MANAGEMENT +//************************************************************************** + +//------------------------------------------------- +// device_memory_interface - constructor +//------------------------------------------------- + +device_memory_interface::device_memory_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_memory_config(dynamic_cast(config)) +{ + memset(m_addrspace, 0, sizeof(m_addrspace)); +} + + +//------------------------------------------------- +// ~device_memory_interface - destructor +//------------------------------------------------- + +device_memory_interface::~device_memory_interface() +{ +} + + +//------------------------------------------------- +// set_address_space - connect an address space +// to a device +//------------------------------------------------- + +void device_memory_interface::set_address_space(int spacenum, const address_space *space) +{ + assert(spacenum < ARRAY_LENGTH(m_addrspace)); + m_addrspace[spacenum] = space; +} + + +//------------------------------------------------- +// memory_translate - translate from logical to +// phyiscal addresses; designed to be overridden +// by the actual device implementation if address +// translation is supported +//------------------------------------------------- + +bool device_memory_interface::memory_translate(int spacenum, int intention, offs_t &address) +{ + // by default it maps directly + return true; +} + + +//------------------------------------------------- +// memory_read - perform internal memory +// operations that bypass the memory system; +// designed to be overridden by the actual device +// implementation if internal read operations are +// handled by bypassing the memory system +//------------------------------------------------- + +bool device_memory_interface::memory_read(int spacenum, offs_t offset, int size, UINT64 &value) +{ + // by default, we don't do anything + return false; +} + + +//------------------------------------------------- +// memory_write - perform internal memory +// operations that bypass the memory system; +// designed to be overridden by the actual device +// implementation if internal write operations are +// handled by bypassing the memory system +//------------------------------------------------- + +bool device_memory_interface::memory_write(int spacenum, offs_t offset, int size, UINT64 value) +{ + // by default, we don't do anything + return false; +} + + +//------------------------------------------------- +// memory_readop - perform internal memory +// operations that bypass the memory system; +// designed to be overridden by the actual device +// implementation if internal opcode fetching +// operations are handled by bypassing the memory +// system +//------------------------------------------------- + +bool device_memory_interface::memory_readop(offs_t offset, int size, UINT64 &value) +{ + // by default, we don't do anything + return false; +} diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h new file mode 100644 index 00000000000..30223eedabe --- /dev/null +++ b/src/emu/dimemory.h @@ -0,0 +1,292 @@ +/*************************************************************************** + + dimemory.h + + Device memory interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DIMEMORY_H__ +#define __DIMEMORY_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// the configuration for a general device +enum device_space +{ + AS_PROGRAM = 0, + AS_DATA = 1, + AS_IO = 2 +}; + + +// Translation intentions +const int TRANSLATE_TYPE_MASK = 0x03; // read write or fetch +const int TRANSLATE_USER_MASK = 0x04; // user mode or fully privileged +const int TRANSLATE_DEBUG_MASK = 0x08; // debug mode (no side effects) + +const int TRANSLATE_READ = 0; // translate for read +const int TRANSLATE_WRITE = 1; // translate for write +const int TRANSLATE_FETCH = 2; // translate for instruction fetch +const int TRANSLATE_READ_USER = (TRANSLATE_READ | TRANSLATE_USER_MASK); +const int TRANSLATE_WRITE_USER = (TRANSLATE_WRITE | TRANSLATE_USER_MASK); +const int TRANSLATE_FETCH_USER = (TRANSLATE_FETCH | TRANSLATE_USER_MASK); +const int TRANSLATE_READ_DEBUG = (TRANSLATE_READ | TRANSLATE_DEBUG_MASK); +const int TRANSLATE_WRITE_DEBUG = (TRANSLATE_WRITE | TRANSLATE_DEBUG_MASK); +const int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_DEVICE_ADDRESS_MAP(_space, _map) \ + TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DIMEMORY_MAP, 8, _space, 8), \ + TOKEN_PTR(addrmap, (const addrmap_token *)ADDRESS_MAP_NAME(_map)), + +#define MDRV_DEVICE_PROGRAM_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(AS_PROGRAM, _map) + +#define MDRV_DEVICE_DATA_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(AS_DATA, _map) + +#define MDRV_DEVICE_IO_MAP(_map) \ + MDRV_DEVICE_ADDRESS_MAP(AS_IO, _map) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> address_space_config + +class address_space_config +{ +public: + address_space_config() + : m_name("unknown"), + m_endianness(ENDIANNESS_NATIVE), + m_databus_width(0), + m_addrbus_width(0), + m_addrbus_shift(0), + m_logaddr_width(0), + m_page_shift(0), + m_internal_map(NULL), + m_default_map(NULL) { } + + address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift = 0, const addrmap_token *internal = NULL, const addrmap_token *defmap = NULL) + : m_name(name), + m_endianness(endian), + m_databus_width(datawidth), + m_addrbus_width(addrwidth), + m_addrbus_shift(addrshift), + m_logaddr_width(datawidth), + m_page_shift(0), + m_internal_map(internal), + m_default_map(defmap) { } + + address_space_config(const char *name, endianness_t endian, UINT8 datawidth, UINT8 addrwidth, INT8 addrshift, UINT8 logwidth, UINT8 pageshift = 0, const addrmap_token *internal = NULL, const addrmap_token *defmap = NULL) + : m_name(name), + m_endianness(endian), + m_databus_width(datawidth), + m_addrbus_width(addrwidth), + m_addrbus_shift(addrshift), + m_logaddr_width(datawidth), + m_page_shift(pageshift), + m_internal_map(internal), + m_default_map(defmap) { } + + inline offs_t addr2byte(offs_t address) const + { + return (m_addrbus_shift < 0) ? (address << -m_addrbus_shift) : (address >> m_addrbus_shift); + } + + inline offs_t addr2byte_end(offs_t address) const + { + return (m_addrbus_shift < 0) ? ((address << -m_addrbus_shift) | ((1 << -m_addrbus_shift) - 1)) : (address >> m_addrbus_shift); + } + + inline offs_t byte2addr(offs_t address) const + { + return (m_addrbus_shift > 0) ? (address << m_addrbus_shift) : (address >> -m_addrbus_shift); + } + + inline offs_t byte2addr_end(offs_t address) const + { + return (m_addrbus_shift > 0) ? ((address << m_addrbus_shift) | ((1 << -m_addrbus_shift) - 1)) : (address >> -m_addrbus_shift); + } + + const char * m_name; + endianness_t m_endianness; + UINT8 m_databus_width; + UINT8 m_addrbus_width; + INT8 m_addrbus_shift; + UINT8 m_logaddr_width; + UINT8 m_page_shift; + const addrmap_token *m_internal_map; + const addrmap_token *m_default_map; +}; + + + +// ======================> device_config_memory_interface + +// class representing interface-specific configuration state +class device_config_memory_interface : public device_config_interface +{ + friend class device_memory_interface; + +public: + // construction/destruction + device_config_memory_interface(const machine_config &mconfig, device_config &devconfig); + virtual ~device_config_memory_interface(); + + // basic information getters + const addrmap_token *address_map(int spacenum = 0) const { return (spacenum < ARRAY_LENGTH(m_address_map)) ? m_address_map[spacenum] : NULL; } + const address_space_config *space_config(int spacenum = 0) const { return memory_space_config(spacenum); } + +protected: + // required overrides + virtual const address_space_config *memory_space_config(int spacenum) const = 0; + + // optional operation overrides + virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); + virtual bool interface_validity_check(const game_driver &driver) const; + + const addrmap_token * m_address_map[ADDRESS_SPACES]; // address maps for each address space +}; + + + +// ======================> device_memory_interface + +class device_memory_interface : public device_interface +{ + friend class device_scheduler; + +public: + // construction/destruction + device_memory_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_memory_interface(); + + // configuration access + const device_config_memory_interface &memory_config() const { return m_memory_config; } + + // basic information getters + const address_space_config *space_config(int spacenum = 0) const { return m_memory_config.space_config(spacenum); } + const address_space *space(int index = 0) const { return m_addrspace[index]; } + const address_space *space(device_space index) const { return m_addrspace[static_cast(index)]; } + + // address space accessors + void set_address_space(int spacenum, const address_space *space); + + // address translation + bool translate(int spacenum, int intention, offs_t &address) { return memory_translate(spacenum, intention, address); } + + // read/write access + bool read(int spacenum, offs_t offset, int size, UINT64 &value) { return memory_read(spacenum, offset, size, value); } + bool write(int spacenum, offs_t offset, int size, UINT64 value) { return memory_write(spacenum, offset, size, value); } + bool readop(offs_t offset, int size, UINT64 &value) { return memory_readop(offset, size, value); } + +protected: + // optional operation overrides + virtual bool memory_translate(int spacenum, int intention, offs_t &address); + virtual bool memory_read(int spacenum, offs_t offset, int size, UINT64 &value); + virtual bool memory_write(int spacenum, offs_t offset, int size, UINT64 value); + virtual bool memory_readop(offs_t offset, int size, UINT64 &value); + + // interface-level overrides + + // configuration + const device_config_memory_interface &m_memory_config; // reference to our device_config_execute_interface + const address_space * m_addrspace[ADDRESS_SPACES]; // reported address spaces +}; + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// device_memory - return a pointer to the device +// memory interface for this device +//------------------------------------------------- + +inline device_memory_interface *device_memory(device_t *device) +{ + device_memory_interface *intf; + if (!device->interface(intf)) + throw emu_fatalerror("Device '%s' does not have memory interface", device->tag()); + return intf; +} + + +//------------------------------------------------- +// device_get_space - return a pointer to the +// given address space on this device +//------------------------------------------------- + +inline const address_space *device_get_space(device_t *device, int spacenum = 0) +{ + return device_memory(device)->space(spacenum); +} + + +//------------------------------------------------- +// devconfig_get_space_config - return a pointer +// to sthe given address space's configuration +//------------------------------------------------- + +inline const address_space_config *devconfig_get_space_config(const device_config &devconfig, int spacenum = 0) +{ + const device_config_memory_interface *intf; + if (!devconfig.interface(intf)) + throw emu_fatalerror("Device '%s' does not have memory interface", devconfig.tag()); + return intf->space_config(spacenum); +} + + +#endif /* __DIMEMORY_H__ */ diff --git a/src/emu/dinvram.c b/src/emu/dinvram.c new file mode 100644 index 00000000000..9321f922f03 --- /dev/null +++ b/src/emu/dinvram.c @@ -0,0 +1,89 @@ +/*************************************************************************** + + dinvram.c + + Device NVRAM interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" + + + +//************************************************************************** +// DEVICE CONFIG NVRAM INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_config_nvram_interface - constructor +//------------------------------------------------- + +device_config_nvram_interface::device_config_nvram_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig) +{ +} + + +//------------------------------------------------- +// ~device_config_nvram_interface - destructor +//------------------------------------------------- + +device_config_nvram_interface::~device_config_nvram_interface() +{ +} + + + +//************************************************************************** +// DEVICE NVRAM INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_nvram_interface - constructor +//------------------------------------------------- + +device_nvram_interface::device_nvram_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_nvram_config(dynamic_cast(config)) +{ +} + + +//------------------------------------------------- +// ~device_nvram_interface - destructor +//------------------------------------------------- + +device_nvram_interface::~device_nvram_interface() +{ +} diff --git a/src/emu/dinvram.h b/src/emu/dinvram.h new file mode 100644 index 00000000000..b31edd4eda8 --- /dev/null +++ b/src/emu/dinvram.h @@ -0,0 +1,97 @@ +/*************************************************************************** + + dinvram.h + + Device NVRAM interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DINVRAM_H__ +#define __DINVRAM_H__ + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> device_config_nvram_interface + +// class representing interface-specific configuration nvram +class device_config_nvram_interface : public device_config_interface +{ +public: + // construction/destruction + device_config_nvram_interface(const machine_config &mconfig, device_config &device); + virtual ~device_config_nvram_interface(); +}; + + + +// ======================> device_nvram_interface + +// class representing interface-specific live nvram +class device_nvram_interface : public device_interface +{ +public: + // construction/destruction + device_nvram_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_nvram_interface(); + + // configuration access + const device_config_nvram_interface &nvram_config() const { return m_nvram_config; } + + // public accessors... for now + void nvram_reset() { nvram_default(); } + void nvram_load(mame_file &file) { nvram_read(file); } + void nvram_save(mame_file &file) { nvram_write(file); } + +protected: + // derived class overrides + virtual void nvram_default() = 0; + virtual void nvram_read(mame_file &file) = 0; + virtual void nvram_write(mame_file &file) = 0; + + // configuration + const device_config_nvram_interface &m_nvram_config; // reference to our device_config_execute_interface +}; + + +#endif /* __DINVRAM_H__ */ diff --git a/src/emu/disound.c b/src/emu/disound.c new file mode 100644 index 00000000000..c34523eae4d --- /dev/null +++ b/src/emu/disound.c @@ -0,0 +1,226 @@ +/*************************************************************************** + + disound.c + + Device sound interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "streams.h" + + + +//************************************************************************** +// DEVICE CONFIG SOUND INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_config_sound_interface - constructor +//------------------------------------------------- + +device_config_sound_interface::device_config_sound_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig), + m_route_list(NULL) +{ +} + + +//------------------------------------------------- +// ~device_config_sound_interface - destructor +//------------------------------------------------- + +device_config_sound_interface::~device_config_sound_interface() +{ + reset_routes(); +} + + +//------------------------------------------------- +// interface_process_token - token processing for +// the sound interface +//------------------------------------------------- + +bool device_config_sound_interface::interface_process_token(UINT32 entrytype, const machine_config_token *&tokens) +{ + switch (entrytype) + { + // custom config 1 is a new route + case MCONFIG_TOKEN_DISOUND_ROUTE: + { + // put back the token that was originally fetched so we can grab a packed 64-bit token + TOKEN_UNGET_UINT32(tokens); + + // extract data + int output, input; + UINT32 gain; + TOKEN_GET_UINT64_UNPACK4(tokens, entrytype, 8, output, 12, input, 12, gain, 32); + float fgain = (float)gain * (1.0f / (float)(1 << 24)); + const char *target = TOKEN_GET_STRING(tokens); + + // allocate a new route + sound_route **routeptr; + for (routeptr = &m_route_list; *routeptr != NULL; routeptr = &(*routeptr)->m_next) ; + *routeptr = global_alloc(sound_route(output, input, fgain, target)); + return true; + } + + // custom config 2 resets the sound routes + case MCONFIG_TOKEN_DISOUND_RESET: + reset_routes(); + return true; + } + + return false; +} + + +//------------------------------------------------- +// interface_validity_check - validation for a +// device after the configuration has been +// constructed +//------------------------------------------------- + +bool device_config_sound_interface::interface_validity_check(const game_driver &driver) const +{ + bool error = false; + + // loop over all the routes + for (const sound_route *route = m_route_list; route != NULL; route = route->m_next) + { + // find a device with the requested tag + const device_config *target = m_machine_config.devicelist.find(route->m_target); + if (target == NULL) + { + mame_printf_error("%s: %s attempting to route sound to non-existant device '%s'\n", driver.source_file, driver.name, route->m_target); + error = true; + } + + // if it's not a speaker or a sound device, error + const device_config_sound_interface *sound; + if (target->type() != SPEAKER && !target->interface(sound)) + { + mame_printf_error("%s: %s attempting to route sound to a non-sound device '%s' (%s)\n", driver.source_file, driver.name, route->m_target, target->name()); + error = true; + } + } + return error; +} + + +//------------------------------------------------- +// reset_routes - free up all allocated routes +// in this configuration +//------------------------------------------------- + +void device_config_sound_interface::reset_routes() +{ + // loop until all are gone + while (m_route_list != NULL) + { + sound_route *temp = m_route_list; + m_route_list = temp->m_next; + global_free(temp); + } +} + + +//------------------------------------------------- +// sound_route - constructor +//------------------------------------------------- + +device_config_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target) + : m_next(NULL), + m_output(output), + m_input(input), + m_gain(gain), + m_target(target) +{ +} + + + +//************************************************************************** +// DEVICE CONFIG SOUND INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_sound_interface - constructor +//------------------------------------------------- + +device_sound_interface::device_sound_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_outputs(0), + m_sound_config(dynamic_cast(config)) +{ +} + + +//------------------------------------------------- +// ~device_sound_interface - destructor +//------------------------------------------------- + +device_sound_interface::~device_sound_interface() +{ +} + + +//------------------------------------------------- +// interface_post_start - verify that state was +// properly set up +//------------------------------------------------- + +void device_sound_interface::interface_post_start() +{ + // count the outputs + for (int outputnum = 0; outputnum < MAX_OUTPUTS; outputnum++) + { + // stop when we run out of streams + sound_stream *stream = stream_find_by_device(&m_device, outputnum); + if (stream == NULL) + break; + + // accumulate the number of outputs from this stream + int numoutputs = stream_get_outputs(stream); + assert(m_outputs + numoutputs < MAX_OUTPUTS); + + // fill in the array + for (int curoutput = 0; curoutput < numoutputs; curoutput++) + { + sound_output *output = &m_output[m_outputs++]; + output->stream = stream; + output->output = curoutput; + } + } +} diff --git a/src/emu/disound.h b/src/emu/disound.h new file mode 100644 index 00000000000..5f5a41eba60 --- /dev/null +++ b/src/emu/disound.h @@ -0,0 +1,161 @@ +/*************************************************************************** + + disound.h + + Device sound interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DISOUND_H__ +#define __DISOUND_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +const int MAX_OUTPUTS = 4095; // maximum number of outputs a sound chip can support +const int ALL_OUTPUTS = MAX_OUTPUTS; // special value indicating all outputs for the current chip + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_SOUND_ADD(_tag, _type, _clock) \ + MDRV_DEVICE_ADD(_tag, SOUND_##_type, _clock) \ + +#define MDRV_SOUND_MODIFY(_tag) \ + MDRV_DEVICE_MODIFY(_tag) + +#define MDRV_SOUND_CLOCK(_clock) \ + MDRV_DEVICE_CLOCK(_clock) + +#define MDRV_SOUND_REPLACE(_tag, _type, _clock) \ + MDRV_DEVICE_REPLACE(_tag, SOUND_##_type, _clock) + +#define MDRV_SOUND_CONFIG(_config) \ + MDRV_DEVICE_CONFIG(_config) + +#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \ + TOKEN_UINT64_PACK4(MCONFIG_TOKEN_DISOUND_ROUTE, 8, _output, 12, _input, 12, ((float)(_gain) * (float)(1 << 24)), 32), \ + TOKEN_PTR(stringptr, _target), + +#define MDRV_SOUND_ROUTE(_output, _target, _gain) \ + MDRV_SOUND_ROUTE_EX(_output, _target, _gain, 0) + +#define MDRV_SOUND_ROUTES_RESET() \ + TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DISOUND_RESET, 8), + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class sound_stream; + + +// ======================> device_config_sound_interface + +// device_config_sound_interface represents configuration information for a sound device +class device_config_sound_interface : public device_config_interface +{ +public: + // construction/destruction + device_config_sound_interface(const machine_config &mconfig, device_config &devconfig); + virtual ~device_config_sound_interface(); + + class sound_route + { + public: + sound_route(int output, int input, float gain, const char *target); + + sound_route * m_next; // pointer to next route + UINT32 m_output; // output index, or ALL_OUTPUTS + UINT32 m_input; // target input index + float m_gain; // gain + const char * m_target; // target tag + }; + + sound_route * m_route_list; // list of sound routes + +protected: + // optional operation overrides + virtual bool interface_process_token(UINT32 entrytype, const machine_config_token *&tokens); + virtual bool interface_validity_check(const game_driver &driver) const; + + void reset_routes(); +}; + + + +// ======================> device_sound_interface + +class device_sound_interface : public device_interface +{ +public: + // construction/destruction + device_sound_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_sound_interface(); + + // configuration access + const device_config_sound_interface &sound_config() const { return m_sound_config; } + +protected: + // optional operation overrides + virtual void interface_post_start(); + + struct sound_output + { + sound_stream * stream; // associated stream + int output; // output number + }; + + int m_outputs; // number of outputs from this instance + sound_output m_output[MAX_OUTPUTS]; // array of output information + + const device_config_sound_interface &m_sound_config; +}; + + + +#endif /* __DISOUND_H__ */ diff --git a/src/emu/distate.c b/src/emu/distate.c new file mode 100644 index 00000000000..b9493e9523e --- /dev/null +++ b/src/emu/distate.c @@ -0,0 +1,630 @@ +/*************************************************************************** + + distate.c + + Device state interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +const UINT64 device_state_entry::k_decimal_divisor[] = +{ + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + U64(10000000000), + U64(100000000000), + U64(1000000000000), + U64(10000000000000), + U64(100000000000000), + U64(1000000000000000), + U64(10000000000000000), + U64(100000000000000000), + U64(1000000000000000000), + U64(10000000000000000000) +}; + + + +//************************************************************************** +// DEVICE STATE ENTRY +//************************************************************************** + +//------------------------------------------------- +// device_state_entry - constructor +//------------------------------------------------- + +device_state_entry::device_state_entry(int index, const char *symbol, void *dataptr, UINT8 size) + : m_next(NULL), + m_index(index), + m_datamask(0), + m_datasize(size), + m_flags(0), + m_symbol(symbol), + m_default_format(true), + m_sizemask(0) +{ + // set the data pointer + m_dataptr.v = dataptr; + + // convert the size to a mask + assert(size == 1 || size == 2 || size == 4 || size == 8); + if (size == 1) + m_sizemask = 0xff; + else if (size == 2) + m_sizemask = 0xffff; + else if (size == 4) + m_sizemask = 0xffffffff; + else + m_sizemask = ~U64(0); + + // default the data mask to the same + m_datamask = m_sizemask; + format_from_mask(); + + // override well-known symbols + if (index == STATE_GENPC) + m_symbol.cpy("CURPC"); + else if (index == STATE_GENPCBASE) + m_symbol.cpy("CURPCBASE"); + else if (index == STATE_GENSP) + m_symbol.cpy("CURSP"); + else if (index == STATE_GENFLAGS) + m_symbol.cpy("CURFLAGS"); +} + + +//------------------------------------------------- +// formatstr - specify a format string +//------------------------------------------------- + +device_state_entry &device_state_entry::formatstr(const char *_format) +{ + m_format.cpy(_format); + m_default_format = false; + + // set the DSF_CUSTOM_STRING flag by formatting with a NULL string + m_flags &= ~DSF_CUSTOM_STRING; + astring dummy; + format(dummy, NULL); + + return *this; +} + + +//------------------------------------------------- +// value - return the current value as a UINT64 +//------------------------------------------------- + +UINT64 device_state_entry::value() const +{ + // pick up the value + UINT64 result = ~(UINT64)0; + switch (m_datasize) + { + default: + case 1: result = *m_dataptr.u8; break; + case 2: result = *m_dataptr.u16; break; + case 4: result = *m_dataptr.u32; break; + case 8: result = *m_dataptr.u64; break; + } + return result & m_datamask; +} + + +//------------------------------------------------- +// format - return the value of the given +// pieces of indexed state as a string +//------------------------------------------------- + +astring &device_state_entry::format(astring &dest, const char *string, bool maxout) const +{ + UINT64 result = value(); + + // parse the format + bool leadzero = false; + bool percent = false; + bool explicitsign = false; + bool hitnonzero = false; + bool reset = true; + int width = 0; + for (const char *fptr = m_format; *fptr != 0; fptr++) + { + // reset any accumulated state + if (reset) + { + leadzero = maxout; + percent = explicitsign = reset = false; + width = 0; + } + + // if we're not within a format, then anything other than a % outputs directly + if (!percent && *fptr != '%') + { + dest.cat(fptr, 1); + continue; + } + + // handle each character in turn + switch (*fptr) + { + // % starts a format; %% outputs a single % + case '%': + if (!percent) + percent = true; + else + { + dest.cat(fptr, 1); + percent = false; + } + break; + + // 0 means insert leading 0s, unless it follows another width digit + case '0': + if (width == 0) + leadzero = true; + else + width *= 10; + break; + + // 1-9 accumulate into the width + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + width = width * 10 + (*fptr - '0'); + break; + + // + means explicit sign + case '+': + explicitsign = true; + break; + + // X outputs as hexadecimal + case 'X': + if (width == 0) + throw emu_fatalerror("Width required for %%X formats\n"); + hitnonzero = false; + while (leadzero && width > 16) + { + dest.cat(" "); + width--; + } + for (int digitnum = 15; digitnum >= 0; digitnum--) + { + int digit = (result >> (4 * digitnum)) & 0x0f; + if (digit != 0) + { + static const char hexchars[] = "0123456789ABCDEF"; + dest.cat(&hexchars[digit], 1); + hitnonzero = true; + } + else if (hitnonzero || (leadzero && digitnum < width) || digitnum == 0) + dest.cat("0"); + } + reset = true; + break; + + // d outputs as signed decimal + case 'd': + if (width == 0) + throw emu_fatalerror("Width required for %%d formats\n"); + if ((result & m_datamask) > (m_datamask >> 1)) + { + result = -result & m_datamask; + dest.cat("-"); + width--; + } + else if (explicitsign) + { + dest.cat("+"); + width--; + } + // fall through to unsigned case + + // u outputs as unsigned decimal + case 'u': + if (width == 0) + throw emu_fatalerror("Width required for %%u formats\n"); + hitnonzero = false; + while (leadzero && width > ARRAY_LENGTH(k_decimal_divisor)) + { + dest.cat(" "); + width--; + } + for (int digitnum = ARRAY_LENGTH(k_decimal_divisor) - 1; digitnum >= 0; digitnum--) + { + int digit = (result >= k_decimal_divisor[digitnum]) ? (result / k_decimal_divisor[digitnum]) % 10 : 0; + if (digit != 0) + { + static const char decchars[] = "0123456789"; + dest.cat(&decchars[digit], 1); + hitnonzero = true; + } + else if (hitnonzero || (leadzero && digitnum < width) || digitnum == 0) + dest.cat("0"); + } + reset = true; + break; + + // s outputs a custom string + case 's': + if (width == 0) + throw emu_fatalerror("Width required for %%s formats\n"); + if (string == NULL) + { + const_cast(this)->m_flags |= DSF_CUSTOM_STRING; + return dest; + } + if (strlen(string) <= width) + { + dest.cat(string); + width -= strlen(string); + while (width-- != 0) + dest.cat(" "); + } + else + dest.cat(string, width); + reset = true; + break; + + // other formats unknown + default: + throw emu_fatalerror("Unknown format character '%c'\n", *fptr); + break; + } + } + return dest; +} + + +//------------------------------------------------- +// set_value - set the value from a UINT64 +//------------------------------------------------- + +void device_state_entry::set_value(UINT64 value) const +{ + // apply the mask + value &= m_datamask; + + // sign-extend if necessary + if ((m_flags & DSF_IMPORT_SEXT) != 0 && value > (m_datamask >> 1)) + value |= ~m_datamask; + + // store the value + switch (m_datasize) + { + default: + case 1: *m_dataptr.u8 = value; break; + case 2: *m_dataptr.u16 = value; break; + case 4: *m_dataptr.u32 = value; break; + case 8: *m_dataptr.u64 = value; break; + } +} + + +//------------------------------------------------- +// set_value - set the value from a string +//------------------------------------------------- + +void device_state_entry::set_value(const char *string) const +{ + // not implemented +} + + +//------------------------------------------------- +// format_from_mask - make a format based on +// the data mask +//------------------------------------------------- + +void device_state_entry::format_from_mask() +{ + // skip if we have a user-provided format + if (!m_default_format) + return; + + // make up a format based on the mask + int width = 0; + for (UINT64 tempmask = m_datamask; tempmask != 0; tempmask >>= 4) + width++; + m_format.printf("%%0%dX", width); +} + + + +//************************************************************************** +// DEVICE CONFIG STATE INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_config_state_interface - constructor +//------------------------------------------------- + +device_config_state_interface::device_config_state_interface(const machine_config &mconfig, device_config &devconfig) + : device_config_interface(mconfig, devconfig) +{ +} + + +//------------------------------------------------- +// ~device_config_state_interface - destructor +//------------------------------------------------- + +device_config_state_interface::~device_config_state_interface() +{ +} + + + +//************************************************************************** +// DEVICE STATE INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_state_interface - constructor +//------------------------------------------------- + +device_state_interface::device_state_interface(running_machine &machine, const device_config &config, device_t &device) + : device_interface(machine, config, device), + m_machine(machine), + m_state_config(dynamic_cast(config)), + m_state_list(NULL) +{ + memset(m_fast_state, 0, sizeof(m_fast_state)); +} + + +//------------------------------------------------- +// ~device_state_interface - destructor +//------------------------------------------------- + +device_state_interface::~device_state_interface() +{ +} + + +//------------------------------------------------- +// state_value - return the value of the given +// pieces of indexed state as a UINT64 +//------------------------------------------------- + +UINT64 device_state_interface::state_value(int index) +{ + // NULL or out-of-range entry returns 0 + const device_state_entry *entry = state_find_entry(index); + if (entry == NULL) + return 0; + + // call the exporter before we do anything + if (entry->needs_export()) + state_export(*entry); + + // pick up the value + return entry->value(); +} + + +//------------------------------------------------- +// state_string - return the value of the given +// pieces of indexed state as a string +//------------------------------------------------- + +astring &device_state_interface::state_string(int index, astring &dest) +{ + // NULL or out-of-range entry returns bogus string + const device_state_entry *entry = state_find_entry(index); + if (entry == NULL) + return dest.cpy("???"); + + // get the custom string if needed + astring custom; + if (entry->needs_custom_string()) + state_string_export(*entry, custom); + + // ask the entry to format itself + return entry->format(dest, custom); +} + + +//------------------------------------------------- +// state_string_max_length - return the maximum +// length of the given state string +//------------------------------------------------- + +int device_state_interface::state_string_max_length(int index) +{ + // NULL or out-of-range entry returns bogus string + const device_state_entry *entry = state_find_entry(index); + if (entry == NULL) + return 3; + + // ask the entry to format itself maximally + astring tempstring; + return entry->format(tempstring, "", true).len(); +} + + +//------------------------------------------------- +// state_set_value - set the value of the given +// pieces of indexed state from a UINT64 +//------------------------------------------------- + +void device_state_interface::state_set_value(int index, UINT64 value) +{ + // NULL or out-of-range entry is a no-op + const device_state_entry *entry = state_find_entry(index); + if (entry == NULL) + return; + + // set the value + entry->set_value(value); + + // call the importer to finish up + if (entry->needs_import()) + state_import(*entry); +} + + +//------------------------------------------------- +// state_set_value - set the value of the given +// pieces of indexed state from a string +//------------------------------------------------- + +void device_state_interface::state_set_value(int index, const char *string) +{ + // NULL or out-of-range entry is a no-op + const device_state_entry *entry = state_find_entry(index); + if (entry == NULL) + return; + + // set the value + entry->set_value(string); + + // call the importer to finish up + if (entry->needs_import()) + state_import(*entry); +} + + +//------------------------------------------------- +// state_import - called after new state is +// written to perform any post-processing +//------------------------------------------------- + +void device_state_interface::state_import(const device_state_entry &entry) +{ +} + + +//------------------------------------------------- +// state_export - called prior to new state +// reading the state +//------------------------------------------------- + +void device_state_interface::state_export(const device_state_entry &entry) +{ +} + + +//------------------------------------------------- +// state_string_import - called after new state is +// written to perform any post-processing +//------------------------------------------------- + +void device_state_interface::state_string_import(const device_state_entry &entry, astring &string) +{ +} + + +//------------------------------------------------- +// state_string_export - called after new state is +// written to perform any post-processing +//------------------------------------------------- + +void device_state_interface::state_string_export(const device_state_entry &entry, astring &string) +{ +} + + +//------------------------------------------------- +// state_add - return the value of the given +// pieces of indexed state as a UINT64 +//------------------------------------------------- + +device_state_entry &device_state_interface::state_add(int index, const char *symbol, void *data, UINT8 size) +{ + // assert validity of incoming parameters + assert(size == 1 || size == 2 || size == 4 || size == 8); + assert(symbol != NULL); + + // allocate new entry + device_state_entry *entry = auto_alloc(&m_machine, device_state_entry(index, symbol, data, size)); + + // append to the end of the list + device_state_entry **tailptr; + for (tailptr = &m_state_list; *tailptr != NULL; tailptr = &(*tailptr)->m_next) ; + *tailptr = entry; + + // set the fast entry if applicable + if (index >= k_fast_state_min && index <= k_fast_state_max) + m_fast_state[index - k_fast_state_min] = entry; + + return *entry; +} + + +//------------------------------------------------- +// state_find_entry - return a pointer to the +// state entry for the given index +//------------------------------------------------- + +const device_state_entry *device_state_interface::state_find_entry(int index) +{ + // use fast lookup if possible + if (index >= k_fast_state_min && index <= k_fast_state_max) + return m_fast_state[index - k_fast_state_min]; + + // otherwise, scan the first + for (const device_state_entry *entry = m_state_list; entry != NULL; entry = entry->m_next) + if (entry->m_index == index) + return entry; + + // handle failure by returning NULL + return NULL; +} + + +//------------------------------------------------- +// interface_post_start - verify that state was +// properly set up +//------------------------------------------------- + +void device_state_interface::interface_post_start() +{ + // make sure we got something during startup + if (m_state_list == NULL) + throw emu_fatalerror("No state registered for device '%s' that supports it!", m_device.tag()); +} diff --git a/src/emu/distate.h b/src/emu/distate.h new file mode 100644 index 00000000000..2377d78fd88 --- /dev/null +++ b/src/emu/distate.h @@ -0,0 +1,229 @@ +/*************************************************************************** + + distate.h + + Device state interfaces. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __DISTATE_H__ +#define __DISTATE_H__ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// standard state indexes +enum +{ + STATE_GENPC = -1, // generic program counter (live) + STATE_GENPCBASE = -2, // generic program counter (base of current instruction) + STATE_GENSP = -3, // generic stack pointer + STATE_GENFLAGS = -4 // generic flags +}; + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> device_state_entry + +// class describing a single item of exposed device state +class device_state_entry +{ + friend class device_state_interface; + +private: + // construction/destruction + device_state_entry(int index, const char *symbol, void *dataptr, UINT8 size); + +public: + // post-construction modifiers + device_state_entry &mask(UINT64 _mask) { m_datamask = _mask; format_from_mask(); return *this; } + device_state_entry &signed_mask(UINT64 _mask) { m_datamask = _mask; m_flags |= DSF_IMPORT_SEXT; format_from_mask(); return *this; } + device_state_entry &formatstr(const char *_format); + device_state_entry &callimport() { m_flags |= DSF_IMPORT; return *this; } + device_state_entry &callexport() { m_flags |= DSF_EXPORT; return *this; } + device_state_entry &noshow() { m_flags |= DSF_NOSHOW; return *this; } + + // iteration helpers + const device_state_entry *next() const { return m_next; } + + // query information + int index() const { return m_index; } + void *dataptr() const { return m_dataptr.v; } + const char *symbol() const { return m_symbol; } + bool visible() const { return ((m_flags & DSF_NOSHOW) == 0); } + +protected: + // device state flags + static const UINT8 DSF_NOSHOW = 0x01; // don't display this entry in the registers view + static const UINT8 DSF_IMPORT = 0x02; // call the import function after writing new data + static const UINT8 DSF_IMPORT_SEXT = 0x04; // sign-extend the data when writing new data + static const UINT8 DSF_EXPORT = 0x08; // call the export function prior to fetching the data + static const UINT8 DSF_CUSTOM_STRING = 0x10; // set if the format has a custom string + + // helpers + bool needs_custom_string() const { return ((m_flags & DSF_CUSTOM_STRING) != 0); } + void format_from_mask(); + + // return the current value -- only for our friends who handle export + bool needs_export() const { return ((m_flags & DSF_EXPORT) != 0); } + UINT64 value() const; + astring &format(astring &dest, const char *string, bool maxout = false) const; + + // set the current value -- only for our friends who handle import + bool needs_import() const { return ((m_flags & DSF_IMPORT) != 0); } + void set_value(UINT64 value) const; + void set_value(const char *string) const; + + // statics + static const UINT64 k_decimal_divisor[20]; // divisors for outputting decimal values + + // public state description + device_state_entry * m_next; // link to next item + UINT32 m_index; // index by which this item is referred + generic_ptr m_dataptr; // pointer to where the data lives + UINT64 m_datamask; // mask that applies to the data + UINT8 m_datasize; // size of the data + UINT8 m_flags; // flags for this data + astring m_symbol; // symbol for display; all lower-case version for expressions + astring m_format; // supported formats + bool m_default_format; // true if we are still using default format + UINT64 m_sizemask; // mask derived from the data size +}; + + + +// ======================> device_config_state_interface + +// class representing interface-specific configuration state +class device_config_state_interface : public device_config_interface +{ +public: + // construction/destruction + device_config_state_interface(const machine_config &mconfig, device_config &device); + virtual ~device_config_state_interface(); +}; + + + +// ======================> device_state_interface + +// class representing interface-specific live state +class device_state_interface : public device_interface +{ +public: + // construction/destruction + device_state_interface(running_machine &machine, const device_config &config, device_t &device); + virtual ~device_state_interface(); + + // configuration access + const device_config_state_interface &state_config() const { return m_state_config; } + const device_state_entry *state_first() const { return m_state_list; } + + // state getters + UINT64 state_value(int index); + astring &state_string(int index, astring &dest); + int state_string_max_length(int index); + + // state setters + void state_set_value(int index, UINT64 value); + void state_set_value(int index, const char *string); + +public: // protected eventually + + // add a new state item + template device_state_entry &state_add(int index, const char *symbol, T &data) + { + return state_add(index, symbol, &data, sizeof(data)); + } + device_state_entry &state_add(int index, const char *symbol, void *data, UINT8 size); + +protected: + // derived class overrides + virtual void state_import(const device_state_entry &entry); + virtual void state_export(const device_state_entry &entry); + virtual void state_string_import(const device_state_entry &entry, astring &string); + virtual void state_string_export(const device_state_entry &entry, astring &string); + + // internal operation overrides + virtual void interface_post_start(); + + // find the entry for a given index + const device_state_entry *state_find_entry(int index); + + // constants + static const int k_fast_state_min = -4; // range for fast state + static const int k_fast_state_max = 256; // lookups + + // state + running_machine & m_machine; // reference to owning machine + const device_config_state_interface & m_state_config; // reference to configuration data + device_state_entry * m_state_list; // head of state list + device_state_entry * m_fast_state[k_fast_state_max + 1 - k_fast_state_min]; + // fast access to common entries +}; + + + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// device_state - return a pointer to the device +// state interface for this device +//------------------------------------------------- + +inline device_state_interface *device_state(device_t *device) +{ + device_state_interface *intf; + if (!device->interface(intf)) + throw emu_fatalerror("Device '%s' does not have state interface", device->tag()); + return intf; +} + + +#endif /* __DISTATE_H__ */ diff --git a/src/emu/emu.h b/src/emu/emu.h index 1ed9759c2f3..3086a64b4c6 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -69,6 +69,14 @@ // devices and callbacks #include "devintrf.h" #include "devcb.h" +#include "distate.h" +#include "dimemory.h" +#include "diexec.h" +#include "disound.h" +#include "dinvram.h" +#include "didisasm.h" +#include "timer.h" +#include "schedule.h" // I/O #include "input.h" @@ -77,9 +85,7 @@ #include "output.h" // timers, CPU and scheduling -#include "timer.h" -#include "cpuintrf.h" -#include "cpuexec.h" +#include "devcpu.h" #include "watchdog.h" // machine and driver configuration @@ -105,6 +111,7 @@ #include "video.h" // sound-related +#include "streams.h" #include "sound.h" // generic helpers diff --git a/src/emu/emu.mak b/src/emu/emu.mak index db4b257b64f..7d62845c3d3 100644 --- a/src/emu/emu.mak +++ b/src/emu/emu.mak @@ -42,11 +42,18 @@ EMUOBJS = \ $(EMUOBJ)/cheat.o \ $(EMUOBJ)/clifront.o \ $(EMUOBJ)/config.o \ - $(EMUOBJ)/cpuexec.o \ $(EMUOBJ)/crsshair.o \ $(EMUOBJ)/debugger.o \ $(EMUOBJ)/devcb.o \ + $(EMUOBJ)/devcpu.o \ + $(EMUOBJ)/devlegcy.o \ $(EMUOBJ)/devintrf.o \ + $(EMUOBJ)/didisasm.o \ + $(EMUOBJ)/diexec.o \ + $(EMUOBJ)/dimemory.o \ + $(EMUOBJ)/dinvram.o \ + $(EMUOBJ)/disound.o \ + $(EMUOBJ)/distate.o \ $(EMUOBJ)/drawgfx.o \ $(EMUOBJ)/driver.o \ $(EMUOBJ)/emualloc.o \ @@ -68,6 +75,7 @@ EMUOBJS = \ $(EMUOBJ)/rendlay.o \ $(EMUOBJ)/rendutil.o \ $(EMUOBJ)/romload.o \ + $(EMUOBJ)/schedule.o \ $(EMUOBJ)/sound.o \ $(EMUOBJ)/state.o \ $(EMUOBJ)/streams.o \ diff --git a/src/emu/emualloc.c b/src/emu/emualloc.c index 198fc6508a0..15b0663e0e6 100644 --- a/src/emu/emualloc.c +++ b/src/emu/emualloc.c @@ -165,6 +165,9 @@ void free_file_line(void *memory, const char *file, int line) return; } + // clear memory to a bogus value + memset(memory, 0xfc, entry->m_size); + // free the entry and the memory if (entry != NULL) memory_entry::release(entry); diff --git a/src/emu/emucore.h b/src/emu/emucore.h index c05471fbb69..b7f5c0b40c7 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -29,6 +29,7 @@ // standard C++ includes #include +#include // core system includes #include "osdcomm.h" @@ -40,9 +41,9 @@ -/*************************************************************************** - COMPILER-SPECIFIC NASTINESS -***************************************************************************/ +//************************************************************************** +// COMPILER-SPECIFIC NASTINESS +//************************************************************************** // Suppress warnings about redefining the macro 'PPC' on LinuxPPC. #undef PPC @@ -52,9 +53,9 @@ -/*************************************************************************** - FUNDAMENTAL TYPES -***************************************************************************/ +//************************************************************************** +// FUNDAMENTAL TYPES +//************************************************************************** // genf is a generic function pointer; cast function pointers to this instead of void * typedef void genf(void); @@ -77,9 +78,9 @@ class running_machine; -/*************************************************************************** - USEFUL COMPOSITE TYPES -***************************************************************************/ +//************************************************************************** +// USEFUL COMPOSITE TYPES +//************************************************************************** // generic_ptr is a union of pointers to various sizes union generic_ptr @@ -139,9 +140,9 @@ union PAIR64 -/*************************************************************************** - COMMON CONSTANTS -***************************************************************************/ +//************************************************************************** +// COMMON CONSTANTS +//************************************************************************** // constants for expression endianness enum endianness_t @@ -178,9 +179,9 @@ const endianness_t ENDIANNESS_NATIVE = ENDIANNESS_BIG; -/*************************************************************************** - COMMON MACROS -***************************************************************************/ +//************************************************************************** +// COMMON MACROS +//************************************************************************** // macro for defining a copy constructor and assignment operator to prevent copying #define DISABLE_COPYING(_Type) \ @@ -269,9 +270,9 @@ inline void operator--(_Type &value, int) { value = (_Type)((int)value - 1); } -/*************************************************************************** - EXCEPTION CLASSES -***************************************************************************/ +//************************************************************************** +// EXCEPTION CLASSES +//************************************************************************** // emu_exception is the base class for all emu-related exceptions class emu_exception : public std::exception { }; @@ -315,35 +316,78 @@ private: -/*************************************************************************** - COMMON TEMPLATES -***************************************************************************/ +//************************************************************************** +// CASTING TEMPLATES +//************************************************************************** + +// template function for casting from a base class to a derived class that is checked +// in debug builds and fast in release builds +template +inline _Dest downcast(_Source *src) +{ + assert(dynamic_cast<_Dest>(src) == src); + return static_cast<_Dest>(src); +} + +template +inline _Dest downcast(_Source &src) +{ + assert(&dynamic_cast<_Dest>(src) == &src); + return static_cast<_Dest>(src); +} + + +// template function for cross-casting from one class to another that throws a bad_cast +// exception instead of returning NULL +template +inline _Dest crosscast(_Source *src) +{ + _Dest result = dynamic_cast<_Dest>(src); + assert(result != NULL); + if (result == NULL) + throw std::bad_cast(); + return result; +} -template class tagged_list + + +//************************************************************************** +// COMMON TEMPLATES +//************************************************************************** + +template +class tagged_list { DISABLE_COPYING(tagged_list); - T *head; - T **tailptr; - tagmap_t map; + T *m_head; + T **m_tailptr; + tagmap_t m_map; + resource_pool &m_pool; public: - tagged_list() : - head(NULL), - tailptr(&head) { } + tagged_list(resource_pool &pool = global_resource_pool) : + m_head(NULL), + m_tailptr(&m_head), + m_pool(pool) { } virtual ~tagged_list() { - while (head != NULL) - remove(head); + reset(); } - T *first() const { return head; } + void reset() + { + while (m_head != NULL) + remove(m_head); + } + + T *first() const { return m_head; } int count() const { int num = 0; - for (T *cur = head; cur != NULL; cur = cur->next) + for (T *cur = m_head; cur != NULL; cur = cur->m_next) num++; return num; } @@ -351,7 +395,7 @@ public: int index(T *object) const { int num = 0; - for (T *cur = head; cur != NULL; cur = cur->next) + for (T *cur = m_head; cur != NULL; cur = cur->m_next) if (cur == object) return num; else @@ -365,37 +409,48 @@ public: return (object != NULL) ? index(object) : -1; } - T *prepend(const char *tag, T *object, bool replace_if_duplicate = false) + T *replace(const char *tag, T *object) { - if (map.add_unique_hash(tag, object, replace_if_duplicate) != TMERR_NONE) - throw emu_fatalerror("Error adding object named '%s'", tag); - object->next = head; - head = object; - if (tailptr == &head) - tailptr = &object->next; + T *existing = find(tag); + if (existing == NULL) + return append(tag, object); + + for (T **objectptr = &m_head; *objectptr != NULL; objectptr = &(*objectptr)->m_next) + if (*objectptr == existing) + { + *objectptr = object; + object->m_next = existing->m_next; + if (m_tailptr == &existing->m_next) + m_tailptr = &object->m_next; + m_map.remove(existing); + pool_free(m_pool, existing); + if (m_map.add_unique_hash(tag, object, false) != TMERR_NONE) + throw emu_fatalerror("Error replacing object named '%s'", tag); + break; + } return object; } T *append(const char *tag, T *object, bool replace_if_duplicate = false) { - if (map.add_unique_hash(tag, object, replace_if_duplicate) != TMERR_NONE) + if (m_map.add_unique_hash(tag, object, false) != TMERR_NONE) throw emu_fatalerror("Error adding object named '%s'", tag); - *tailptr = object; - object->next = NULL; - tailptr = &object->next; + *m_tailptr = object; + object->m_next = NULL; + m_tailptr = &object->m_next; return object; } void remove(T *object) { - for (T **objectptr = &head; *objectptr != NULL; objectptr = &(*objectptr)->next) + for (T **objectptr = &m_head; *objectptr != NULL; objectptr = &(*objectptr)->m_next) if (*objectptr == object) { - *objectptr = object->next; - if (tailptr == &object->next) - tailptr = objectptr; - map.remove(object); - global_free(object); + *objectptr = object->m_next; + if (m_tailptr == &object->m_next) + m_tailptr = objectptr; + m_map.remove(object); + pool_free(m_pool, object); return; } } @@ -409,12 +464,12 @@ public: T *find(const char *tag) const { - return map.find_hash_only(tag); + return m_map.find_hash_only(tag); } T *find(int index) const { - for (T *cur = head; cur != NULL; cur = cur->next) + for (T *cur = m_head; cur != NULL; cur = cur->m_next) if (index-- == 0) return cur; return NULL; @@ -423,9 +478,9 @@ public: -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ +//************************************************************************** +// FUNCTION PROTOTYPES +//************************************************************************** DECL_NORETURN void fatalerror(const char *format, ...) ATTR_PRINTF(1,2) ATTR_NORETURN; DECL_NORETURN void fatalerror_exitcode(running_machine *machine, int exitcode, const char *format, ...) ATTR_PRINTF(3,4) ATTR_NORETURN; @@ -448,11 +503,11 @@ inline void fatalerror_exitcode(running_machine *machine, int exitcode, const ch -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +//************************************************************************** +// INLINE FUNCTIONS +//************************************************************************** -/* population count */ +// population count inline int popcount(UINT32 val) { int count; @@ -463,7 +518,7 @@ inline int popcount(UINT32 val) } -/* convert a series of 32 bits into a float */ +// convert a series of 32 bits into a float inline float u2f(UINT32 v) { union { @@ -475,7 +530,7 @@ inline float u2f(UINT32 v) } -/* convert a float into a series of 32 bits */ +// convert a float into a series of 32 bits inline UINT32 f2u(float f) { union { @@ -487,7 +542,7 @@ inline UINT32 f2u(float f) } -/* convert a series of 64 bits into a double */ +// convert a series of 64 bits into a double inline double u2d(UINT64 v) { union { @@ -499,7 +554,7 @@ inline double u2d(UINT64 v) } -/* convert a double into a series of 64 bits */ +// convert a double into a series of 64 bits inline UINT64 d2u(double d) { union { diff --git a/src/emu/emupal.c b/src/emu/emupal.c index bd5cf686c9e..166cf8fe82f 100644 --- a/src/emu/emupal.c +++ b/src/emu/emupal.c @@ -97,17 +97,10 @@ static void configure_rgb_shadows(running_machine *machine, int mode, float fact void palette_init(running_machine *machine) { palette_private *palette = auto_alloc_clear(machine, palette_private); - running_device *device = video_screen_first(machine); - bitmap_format format; + screen_device *device = screen_first(*machine); /* get the format from the first screen, or use BITMAP_FORMAT_INVALID, if screenless */ - if (device != NULL) - { - screen_config *config = (screen_config *)device->baseconfig().inline_config; - format = config->format; - } - else - format = BITMAP_FORMAT_INVALID; + bitmap_format format = (device != NULL) ? device->format() : BITMAP_FORMAT_INVALID; /* request cleanup */ machine->palette_data = palette; diff --git a/src/emu/info.c b/src/emu/info.c index fe9b2ce33bf..eae0d024e4f 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -43,7 +43,7 @@ static void print_game_switches(FILE *out, const game_driver *game, const ioport const input_field_config *field; /* iterate looking for DIP switches */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_DIPSWITCH) { @@ -81,7 +81,7 @@ static void print_game_configs(FILE *out, const game_driver *game, const ioport_ const input_field_config *field; /* iterate looking for configurations */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_CONFIG) { @@ -119,7 +119,7 @@ static void print_game_adjusters(FILE *out, const game_driver *game, const iopor const input_field_config *field; /* iterate looking for Adjusters */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_ADJUSTER) { @@ -175,7 +175,7 @@ enum {cjoy, cdoublejoy, cAD_stick, cdial, ctrackball, cpaddle, clightgun, cpedal control[i].reverse = 0; } - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) { if (nplayer < field->player + 1) @@ -566,12 +566,12 @@ static void print_game_rom(FILE *out, const game_driver *game, const machine_con static void print_game_sampleof(FILE *out, const game_driver *game, const machine_config *config) { - const device_config *devconfig; + const device_config_sound_interface *sound; - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) - if (sound_get_type(devconfig) == SOUND_SAMPLES) + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->devconfig().type() == SOUND_SAMPLES) { - const char *const *samplenames = ((const samples_interface *)devconfig->static_config)->samplenames; + const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; if (samplenames != NULL) { int sampnum; @@ -597,13 +597,13 @@ static void print_game_sampleof(FILE *out, const game_driver *game, const machin static void print_game_sample(FILE *out, const game_driver *game, const machine_config *config) { - const device_config *devconfig; + const device_config_sound_interface *sound; /* iterate over sound chips looking for samples */ - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) - if (sound_get_type(devconfig) == SOUND_SAMPLES) + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->devconfig().type() == SOUND_SAMPLES) { - const char *const *samplenames = ((const samples_interface *)devconfig->static_config)->samplenames; + const char *const *samplenames = ((const samples_interface *)sound->devconfig().static_config())->samplenames; if (samplenames != NULL) { int sampnum; @@ -649,19 +649,20 @@ static void print_game_chips(FILE *out, const game_driver *game, const machine_c fprintf(out, " type=\"cpu\""); fprintf(out, " tag=\"%s\"", xml_normalize_string(devconfig->tag())); fprintf(out, " name=\"%s\"", xml_normalize_string(devconfig->name())); - fprintf(out, " clock=\"%d\"", devconfig->clock); + fprintf(out, " clock=\"%d\"", devconfig->clock()); fprintf(out, "/>\n"); } /* iterate over sound chips */ - for (devconfig = sound_first(config); devconfig != NULL; devconfig = sound_next(devconfig)) + const device_config_sound_interface *sound; + for (bool gotone = config->devicelist.first(sound); gotone; gotone = sound->next(sound)) { fprintf(out, "\t\ttag())); - fprintf(out, " name=\"%s\"", xml_normalize_string(devconfig->name())); - if (devconfig->clock != 0) - fprintf(out, " clock=\"%d\"", devconfig->clock); + fprintf(out, " tag=\"%s\"", xml_normalize_string(sound->devconfig().tag())); + fprintf(out, " name=\"%s\"", xml_normalize_string(sound->devconfig().name())); + if (sound->devconfig().clock() != 0) + fprintf(out, " clock=\"%d\"", sound->devconfig().clock()); fprintf(out, "/>\n"); } } @@ -674,16 +675,14 @@ static void print_game_chips(FILE *out, const game_driver *game, const machine_c static void print_game_display(FILE *out, const game_driver *game, const machine_config *config) { - const device_config *devconfig; + const screen_device_config *devconfig; /* iterate over screens */ - for (devconfig = video_screen_first(config); devconfig != NULL; devconfig = video_screen_next(devconfig)) + for (devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig)) { - const screen_config *scrconfig = (const screen_config *)devconfig->inline_config; - fprintf(out, "\t\ttype) + switch (devconfig->screen_type()) { case SCREEN_TYPE_RASTER: fprintf(out, " type=\"raster\""); break; case SCREEN_TYPE_VECTOR: fprintf(out, " type=\"vector\""); break; @@ -721,31 +720,32 @@ static void print_game_display(FILE *out, const game_driver *game, const machine } /* output width and height only for games that are not vector */ - if (scrconfig->type != SCREEN_TYPE_VECTOR) + if (devconfig->screen_type() != SCREEN_TYPE_VECTOR) { - int dx = scrconfig->visarea.max_x - scrconfig->visarea.min_x + 1; - int dy = scrconfig->visarea.max_y - scrconfig->visarea.min_y + 1; + const rectangle &visarea = devconfig->visible_area(); + int dx = visarea.max_x - visarea.min_x + 1; + int dy = visarea.max_y - visarea.min_y + 1; fprintf(out, " width=\"%d\"", dx); fprintf(out, " height=\"%d\"", dy); } /* output refresh rate */ - fprintf(out, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(scrconfig->refresh)); + fprintf(out, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(devconfig->refresh())); /* output raw video parameters only for games that are not vector */ /* and had raw parameters specified */ - if ((scrconfig->type != SCREEN_TYPE_VECTOR) && !scrconfig->oldstyle_vblank_supplied) + if (devconfig->screen_type() != SCREEN_TYPE_VECTOR && !devconfig->oldstyle_vblank_supplied()) { - int pixclock = scrconfig->width * scrconfig->height * ATTOSECONDS_TO_HZ(scrconfig->refresh); + int pixclock = devconfig->width() * devconfig->height() * ATTOSECONDS_TO_HZ(devconfig->refresh()); fprintf(out, " pixclock=\"%d\"", pixclock); - fprintf(out, " htotal=\"%d\"", scrconfig->width); - fprintf(out, " hbend=\"%d\"", scrconfig->visarea.min_x); - fprintf(out, " hbstart=\"%d\"", scrconfig->visarea.max_x+1); - fprintf(out, " vtotal=\"%d\"", scrconfig->height); - fprintf(out, " vbend=\"%d\"", scrconfig->visarea.min_y); - fprintf(out, " vbstart=\"%d\"", scrconfig->visarea.max_y+1); + fprintf(out, " htotal=\"%d\"", devconfig->width()); + fprintf(out, " hbend=\"%d\"", devconfig->visible_area().min_x); + fprintf(out, " hbstart=\"%d\"", devconfig->visible_area().max_x+1); + fprintf(out, " vtotal=\"%d\"", devconfig->height()); + fprintf(out, " vbend=\"%d\"", devconfig->visible_area().min_y); + fprintf(out, " vbstart=\"%d\"", devconfig->visible_area().max_y+1); } fprintf(out, " />\n"); } @@ -762,7 +762,8 @@ static void print_game_sound(FILE *out, const game_driver *game, const machine_c int speakers = speaker_output_count(config); /* if we have no sound, zero out the speaker count */ - if (sound_first(config) == NULL) + const device_config_sound_interface *sound; + if (!config->devicelist.first(sound)) speakers = 0; fprintf(out, "\t\t\n", speakers); @@ -843,7 +844,7 @@ static void print_game_categories(FILE *out, const game_driver *game, const iopo const input_field_config *field; /* iterate looking for Categories */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_CATEGORY) { diff --git a/src/emu/inptport.c b/src/emu/inptport.c index 028ed3551b5..ac1975cb35b 100644 --- a/src/emu/inptport.c +++ b/src/emu/inptport.c @@ -202,7 +202,7 @@ struct _device_field_info { device_field_info * next; /* linked list of info for this port */ const input_field_config * field; /* pointer to the input field referenced */ - running_device * device; /* device */ + device_t * device; /* device */ UINT8 shift; /* shift to apply to the final result */ input_port_value oldval; /* last value */ }; @@ -888,7 +888,7 @@ INLINE const char *get_port_tag(const input_port_config *port, char *tempbuffer) if (port->tag != NULL) return port->tag; - for (curport = port->machine->portlist.first(); curport != NULL; curport = curport->next) + for (curport = port->machine->portlist.first(); curport != NULL; curport = curport->next()) { if (curport == port) break; @@ -1515,7 +1515,7 @@ input_port_value input_port_read_direct(const input_port_config *port) /* update VBLANK bits */ if (port->state->vblank != 0) { - if (video_screen_get_vblank(port->machine->primary_screen)) + if (port->machine->primary_screen->vblank()) result |= port->state->vblank; else result &= ~port->state->vblank; @@ -1597,7 +1597,7 @@ int input_port_get_crosshair_position(running_machine *machine, int player, floa int gotx = FALSE, goty = FALSE; /* read all the lightgun values */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE) if (input_condition_true(machine, &field->condition)) @@ -1666,7 +1666,7 @@ void input_port_update_defaults(running_machine *machine) const input_port_config *port; /* loop over all input ports */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; @@ -2016,7 +2016,7 @@ static void init_port_state(running_machine *machine) const input_port_config *port; /* allocate live structures to mirror the configuration */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { analog_field_state **analogstatetail; device_field_info **readdevicetail; @@ -2103,7 +2103,7 @@ static void init_port_state(running_machine *machine) /* look for 4-way joysticks and change the default map if we find any */ if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->state->joystick != NULL && field->way == 4) { @@ -2157,7 +2157,7 @@ static void init_autoselect_devices(const ioport_list &portlist, int type1, int /* only scan the list if we haven't already enabled this class of control */ if (portlist.first() != NULL && !input_device_class_enabled(portlist.first()->machine, autoenable)) - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) /* if this port type is in use, apply the autoselect criteria */ @@ -2193,7 +2193,7 @@ static device_field_info *init_field_device_info(const input_field_config *field if (device_name != NULL) info->device = field->port->machine->device(device_name); else - info->device = (running_device *) info; + info->device = (device_t *) info; info->oldval = field->defvalue >> info->shift; return info; @@ -2495,7 +2495,7 @@ profiler_mark_start(PROFILER_INPUT); } /* loop over all input ports */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { const input_field_config *field; device_field_info *device_field; @@ -3515,7 +3515,7 @@ static void port_config_detokenize(ioport_list &portlist, const input_port_token -------------------------------------------------*/ input_port_config::input_port_config(const char *_tag) - : next(NULL), + : m_next(NULL), tag(_tag), fieldlist(NULL), state(NULL), @@ -4068,7 +4068,7 @@ static int load_game_config(running_machine *machine, xml_data_node *portnode, i defvalue = xml_get_attribute_int(portnode, "defvalue", 0); /* find the port we want; if no tag, search them all */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0) for (field = port->fieldlist; field != NULL; field = field->next) @@ -4230,7 +4230,7 @@ static void save_game_inputs(running_machine *machine, xml_data_node *parentnode const input_port_config *port; /* iterate over ports */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (save_this_input_field_type(field->type)) { @@ -4708,7 +4708,7 @@ int input_machine_has_keyboard(running_machine *machine) #ifdef MESS const input_field_config *field; const input_port_config *port; - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { for (field = port->fieldlist; field != NULL; field = field->next) { @@ -4789,7 +4789,7 @@ static int scan_keys(running_machine *machine, const input_port_config *portconf assert(keys < NUM_SIMUL_KEYS); - for (port = portconfig; port != NULL; port = port->next) + for (port = portconfig; port != NULL; port = port->next()) { for (field = port->fieldlist; field != NULL; field = field->next) { @@ -5408,7 +5408,7 @@ int input_has_input_class(running_machine *machine, int inputclass) const input_port_config *port; const input_field_config *field; - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { for (field = port->fieldlist; field != NULL; field = field->next) { @@ -5433,7 +5433,7 @@ int input_count_players(running_machine *machine) int joystick_count; joystick_count = 0; - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { for (field = port->fieldlist; field != NULL; field = field->next) { @@ -5464,7 +5464,7 @@ int input_category_active(running_machine *machine, int category) assert(category >= 1); /* loop through the input ports */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) { for (field = port->fieldlist; field != NULL; field = field->next) { diff --git a/src/emu/inptport.h b/src/emu/inptport.h index 511a346e4b5..38a4dd4c10f 100644 --- a/src/emu/inptport.h +++ b/src/emu/inptport.h @@ -732,8 +732,10 @@ class input_port_config public: input_port_config(const char *tag); ~input_port_config(); + + input_port_config *next() const { return m_next; } - input_port_config * next; /* pointer to next port */ + input_port_config * m_next; /* pointer to next port */ const char * tag; /* pointer to this port's tag */ const input_field_config * fieldlist; /* list of input_field_configs */ diff --git a/src/emu/machine/6522via.c b/src/emu/machine/6522via.c index e35217f96a9..5c539b00ace 100644 --- a/src/emu/machine/6522via.c +++ b/src/emu/machine/6522via.c @@ -183,28 +183,28 @@ static TIMER_CALLBACK( via_t2_timeout ); INLINE via6522_t *get_token(running_device *device) { assert(device != NULL); - assert((device->type == VIA6522)); - return (via6522_t *) device->token; + assert((device->type() == VIA6522)); + return (via6522_t *) downcast(device)->token(); } INLINE const via6522_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == VIA6522)); - return (const via6522_interface *) device->baseconfig().static_config; + assert((device->type() == VIA6522)); + return (const via6522_interface *) device->baseconfig().static_config(); } INLINE attotime v_cycles_to_time(running_device *device, int c) { - return attotime_mul(ATTOTIME_IN_HZ(device->clock), c); + return attotime_mul(ATTOTIME_IN_HZ(device->clock()), c); } INLINE UINT32 v_time_to_cycles(running_device *device, attotime t) { - return attotime_to_double(attotime_mul(t, device->clock)); + return attotime_to_double(attotime_mul(t, device->clock())); } @@ -261,8 +261,8 @@ static DEVICE_START( via6522 ) v->shift_timer = timer_alloc(device->machine, via_shift_callback, (void *) device); /* Default clock is from CPU1 */ - if (device->clock == 0) - device->set_clock(device->machine->firstcpu->clock); + if (device->clock() == 0) + device->set_unscaled_clock(device->machine->firstcpu->clock()); /* save state register */ state_save_register_device_item(device, 0, v->in_a); @@ -1167,7 +1167,6 @@ DEVICE_GET_INFO(via6522) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(via6522_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(via6522); break; diff --git a/src/emu/machine/6522via.h b/src/emu/machine/6522via.h index 16a44f0dc7f..9e26a2d0690 100644 --- a/src/emu/machine/6522via.h +++ b/src/emu/machine/6522via.h @@ -14,13 +14,14 @@ #ifndef __6522VIA_H__ #define __6522VIA_H__ +#include "devlegcy.h" /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define VIA6522 DEVICE_GET_INFO_NAME(via6522) +DECLARE_LEGACY_DEVICE(VIA6522, via6522); #define MDRV_VIA6522_ADD(_tag, _clock, _intrf) \ MDRV_DEVICE_ADD(_tag, VIA6522, _clock) \ @@ -71,8 +72,6 @@ struct _via6522_interface PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO(via6522); - READ8_DEVICE_HANDLER(via_r); WRITE8_DEVICE_HANDLER(via_w); diff --git a/src/emu/machine/6526cia.c b/src/emu/machine/6526cia.c index 5180251970f..4f10566850d 100644 --- a/src/emu/machine/6526cia.c +++ b/src/emu/machine/6526cia.c @@ -118,15 +118,15 @@ static TIMER_CALLBACK( cia_clock_tod_callback ); INLINE cia_state *get_token(running_device *device) { assert(device != NULL); - assert((device->type == MOS6526R1) || (device->type == MOS6526R2) || (device->type == MOS8520)); - return (cia_state *) device->token; + assert((device->type() == MOS6526R1) || (device->type() == MOS6526R2) || (device->type() == MOS8520)); + return (cia_state *) downcast(device)->token(); } INLINE const mos6526_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == MOS6526R1) || (device->type == MOS6526R2) || (device->type == MOS8520)); - return (mos6526_interface *) device->baseconfig().static_config; + assert((device->type() == MOS6526R1) || (device->type() == MOS6526R2) || (device->type() == MOS8520)); + return (mos6526_interface *) device->baseconfig().static_config(); } /*************************************************************************** @@ -194,11 +194,12 @@ static DEVICE_RESET( cia ) DEVICE_VALIDITY_CHECK( cia ) -------------------------------------------------*/ +#if 0 static DEVICE_VALIDITY_CHECK( cia ) { int error = FALSE; - if (device->clock <= 0) + if (device->clock() <= 0) { mame_printf_error("%s: %s has a cia with an invalid clock\n", driver->source_file, driver->name); error = TRUE; @@ -206,6 +207,7 @@ static DEVICE_VALIDITY_CHECK( cia ) return error; } +#endif /*------------------------------------------------- cia_update_pc - pulse /pc output @@ -269,7 +271,7 @@ static void cia_timer_update(cia_timer *timer, INT32 new_count) /* update the timer count, if necessary */ if ((new_count == -1) && is_timer_active(timer->timer)) { - UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->device->clock)); + UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->device->clock())); timer->count = timer->count - MIN(timer->count, current_count); } @@ -281,7 +283,7 @@ static void cia_timer_update(cia_timer *timer, INT32 new_count) if ((timer->mode & 0x01) && ((timer->mode & (which ? 0x60 : 0x20)) == 0x00)) { /* timer is on and is connected to clock */ - attotime period = attotime_mul(ATTOTIME_IN_HZ(timer->cia->device->clock), (timer->count ? timer->count : 0x10000)); + attotime period = attotime_mul(ATTOTIME_IN_HZ(timer->cia->device->clock()), (timer->count ? timer->count : 0x10000)); timer_adjust_oneshot(timer->timer, period, 0); } else @@ -302,7 +304,7 @@ static UINT16 cia_get_timer(cia_timer *timer) if (is_timer_active(timer->timer)) { - UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->device->clock)); + UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->device->clock())); count = timer->count - MIN(timer->count, current_count); } else @@ -489,13 +491,13 @@ static void cia_clock_tod(running_device *device) if (cia->tod_running) { - if ((device->type == MOS6526R1) || (device->type == MOS6526R2)) + if ((device->type() == MOS6526R1) || (device->type() == MOS6526R2)) { /* The 6526 split the value into hours, minutes, seconds and * subseconds */ cia6526_increment(cia); } - else if (device->type == MOS8520) + else if (device->type() == MOS8520) { /* the 8520 has a straight 24-bit counter */ cia->tod++; @@ -695,7 +697,7 @@ READ8_DEVICE_HANDLER( mos6526_r ) case CIA_TOD1: case CIA_TOD2: case CIA_TOD3: - if (device->type == MOS8520) + if (device->type() == MOS8520) { if (offset == CIA_TOD2) { @@ -821,7 +823,7 @@ WRITE8_DEVICE_HANDLER( mos6526_w ) else cia->tod = (cia->tod & ~(0xff << shift)) | (data << shift); - if (device->type == MOS8520) + if (device->type() == MOS8520) { if (offset == CIA_TOD2) cia->tod_running = FALSE; @@ -956,13 +958,12 @@ DEVICE_GET_INFO(cia6526r1) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cia_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cia); break; case DEVINFO_FCT_STOP: /* Nothing */ break; case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(cia); break; - case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(cia); break; +// case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(cia); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "MOS6526 rev1"); break; diff --git a/src/emu/machine/6526cia.h b/src/emu/machine/6526cia.h index 249e0bbb6d7..798a8704977 100644 --- a/src/emu/machine/6526cia.h +++ b/src/emu/machine/6526cia.h @@ -39,9 +39,9 @@ MACROS ***************************************************************************/ -#define MOS6526R1 DEVICE_GET_INFO_NAME(cia6526r1) -#define MOS6526R2 DEVICE_GET_INFO_NAME(cia6526r2) -#define MOS8520 DEVICE_GET_INFO_NAME(cia8520) +DECLARE_LEGACY_DEVICE(MOS6526R1, cia6526r1); +DECLARE_LEGACY_DEVICE(MOS6526R2, cia6526r2); +DECLARE_LEGACY_DEVICE(MOS8520, cia8520); #define MDRV_MOS6526R1_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, MOS6526R1, _clock) \ @@ -86,10 +86,6 @@ struct _mos6526_interface FUNCTION PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO(cia6526r1); -DEVICE_GET_INFO(cia6526r2); -DEVICE_GET_INFO(cia8520); - /* register access */ READ8_DEVICE_HANDLER( mos6526_r ); WRITE8_DEVICE_HANDLER( mos6526_w ); diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c index 1fabf030c7e..a8298803a18 100644 --- a/src/emu/machine/6532riot.c +++ b/src/emu/machine/6532riot.c @@ -82,9 +82,8 @@ struct _riot6532_state INLINE riot6532_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == RIOT6532); - return (riot6532_state *)device->token; + assert(device->type() == RIOT6532); + return (riot6532_state *)downcast(device)->token(); } @@ -148,11 +147,11 @@ INLINE UINT8 get_timer(riot6532_state *riot) /* if counting, return the number of ticks remaining */ else if (riot->timerstate == TIMER_COUNTING) - return attotime_to_ticks(timer_timeleft(riot->timer), riot->device->clock) >> riot->timershift; + return attotime_to_ticks(timer_timeleft(riot->timer), riot->device->clock()) >> riot->timershift; /* if finishing, return the number of ticks without the shift */ else - return attotime_to_ticks(timer_timeleft(riot->timer), riot->device->clock); + return attotime_to_ticks(timer_timeleft(riot->timer), riot->device->clock()); } @@ -177,7 +176,7 @@ static TIMER_CALLBACK( timer_end_callback ) if (riot->timerstate == TIMER_COUNTING) { riot->timerstate = TIMER_FINISHING; - timer_adjust_oneshot(riot->timer, ticks_to_attotime(256, device->clock), 0); + timer_adjust_oneshot(riot->timer, ticks_to_attotime(256, device->clock()), 0); /* signal timer IRQ as well */ riot->irqstate |= TIMER_FLAG; @@ -187,7 +186,7 @@ static TIMER_CALLBACK( timer_end_callback ) /* if we finished finishing, keep spinning */ else if (riot->timerstate == TIMER_FINISHING) { - timer_adjust_oneshot(riot->timer, ticks_to_attotime(256, device->clock), 0); + timer_adjust_oneshot(riot->timer, ticks_to_attotime(256, device->clock()), 0); } } @@ -228,8 +227,8 @@ WRITE8_DEVICE_HANDLER( riot6532_w ) /* update the timer */ riot->timerstate = TIMER_COUNTING; - target = attotime_to_ticks(curtime, device->clock) + 1 + (data << riot->timershift); - timer_adjust_oneshot(riot->timer, attotime_sub(ticks_to_attotime(target, device->clock), curtime), 0); + target = attotime_to_ticks(curtime, device->clock()) + 1 + (data << riot->timershift); + timer_adjust_oneshot(riot->timer, attotime_sub(ticks_to_attotime(target, device->clock()), curtime), 0); } /* if A4 == 0 and A2 == 1, we are writing to the edge detect control */ @@ -432,7 +431,7 @@ static DEVICE_START( riot6532 ) /* set static values */ riot->device = device; - riot->intf = (riot6532_interface *)device->baseconfig().static_config; + riot->intf = (riot6532_interface *)device->baseconfig().static_config(); riot->index = device->machine->devicelist.index(RIOT6532, device->tag()); /* configure the ports */ @@ -499,7 +498,6 @@ DEVICE_GET_INFO( riot6532 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(riot6532_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(riot6532);break; diff --git a/src/emu/machine/6532riot.h b/src/emu/machine/6532riot.h index ca4c0593ed3..7a188cb25d7 100644 --- a/src/emu/machine/6532riot.h +++ b/src/emu/machine/6532riot.h @@ -7,6 +7,8 @@ #ifndef __RIOT6532_H__ #define __RIOT6532_H__ +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -54,7 +56,6 @@ UINT8 riot6532_portb_out_get(running_device *device); /* ----- device interface ----- */ -#define RIOT6532 DEVICE_GET_INFO_NAME(riot6532) -DEVICE_GET_INFO( riot6532 ); +DECLARE_LEGACY_DEVICE(RIOT6532, riot6532); #endif diff --git a/src/emu/machine/6821pia.c b/src/emu/machine/6821pia.c index 4538a52117c..444afaa96a4 100644 --- a/src/emu/machine/6821pia.c +++ b/src/emu/machine/6821pia.c @@ -110,16 +110,16 @@ struct _pia6821_state INLINE pia6821_state *get_token(running_device *device) { assert(device != NULL); - assert((device->type == PIA6821) || (device->type == PIA6822)); - return (pia6821_state *) device->token; + assert((device->type() == PIA6821) || (device->type() == PIA6822)); + return (pia6821_state *) downcast(device)->token(); } INLINE const pia6821_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == PIA6821) || (device->type == PIA6822)); - return (const pia6821_interface *) device->baseconfig().static_config; + assert((device->type() == PIA6821) || (device->type() == PIA6822)); + return (const pia6821_interface *) device->baseconfig().static_config(); } diff --git a/src/emu/machine/6821pia.h b/src/emu/machine/6821pia.h index 58080e02864..4a0a9f44c99 100644 --- a/src/emu/machine/6821pia.h +++ b/src/emu/machine/6821pia.h @@ -18,16 +18,10 @@ **********************************************************************/ -#ifndef __6821NEW_H__ -#define __6821NEW_H__ +#ifndef __6821PIA_H__ +#define __6821PIA_H__ - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define PIA6821 DEVICE_GET_INFO_NAME(pia6821) -#define PIA6822 DEVICE_GET_INFO_NAME(pia6822) +#include "devlegcy.h" /*************************************************************************** @@ -53,14 +47,15 @@ struct _pia6821_interface devcb_write_line irq_b_func; }; +DECLARE_LEGACY_DEVICE(PIA6821, pia6821); +DECLARE_LEGACY_DEVICE(PIA6822, pia6822); + + /*************************************************************************** PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( pia6821 ); -DEVICE_GET_INFO( pia6822 ); - READ8_DEVICE_HANDLER( pia6821_r ); WRITE8_DEVICE_HANDLER( pia6821_w ); diff --git a/src/emu/machine/6840ptm.c b/src/emu/machine/6840ptm.c index ebf8b7c1155..26573634bd5 100644 --- a/src/emu/machine/6840ptm.c +++ b/src/emu/machine/6840ptm.c @@ -113,16 +113,15 @@ struct _ptm6840_state INLINE ptm6840_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == PTM6840)); - return (ptm6840_state *)device->token; + assert((device->type() == PTM6840)); + return (ptm6840_state *)downcast(device)->token(); } INLINE const ptm6840_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == PTM6840)); - return (const ptm6840_interface *) device->baseconfig().static_config; + assert((device->type() == PTM6840)); + return (const ptm6840_interface *) device->baseconfig().static_config(); } @@ -843,6 +842,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_ID(p,s) p##ptm6840##s #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "6840 PTM" -#define DEVTEMPLATE_FAMILY "Motorola Programmable Timer Modules" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/6840ptm.h b/src/emu/machine/6840ptm.h index e4f86f86987..f038ba6981f 100644 --- a/src/emu/machine/6840ptm.h +++ b/src/emu/machine/6840ptm.h @@ -9,12 +9,14 @@ #ifndef __6840PTM_H__ #define __6840PTM_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define PTM6840 DEVICE_GET_INFO_NAME(ptm6840) +DECLARE_LEGACY_DEVICE(PTM6840, ptm6840); #define MDRV_PTM6840_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, PTM6840, 0) \ @@ -41,9 +43,6 @@ struct _ptm6840_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( ptm6840 ); - int ptm6840_get_status( running_device *device, int clock ); // get whether timer is enabled int ptm6840_get_irq( running_device *device ); // get IRQ state UINT16 ptm6840_get_count( running_device *device, int counter );// get counter value diff --git a/src/emu/machine/6850acia.c b/src/emu/machine/6850acia.c index d362e1b350e..2e49c15df89 100644 --- a/src/emu/machine/6850acia.c +++ b/src/emu/machine/6850acia.c @@ -136,16 +136,16 @@ static TIMER_CALLBACK( transmit_event ); INLINE acia6850_t *get_token(running_device *device) { assert(device != NULL); - assert(device->type == ACIA6850); - return (acia6850_t *) device->token; + assert(device->type() == ACIA6850); + return (acia6850_t *) downcast(device)->token(); } INLINE acia6850_interface *get_interface(running_device *device) { assert(device != NULL); - assert(device->type == ACIA6850); - return (acia6850_interface *) device->baseconfig().static_config; + assert(device->type() == ACIA6850); + return (acia6850_interface *) device->baseconfig().static_config(); } @@ -823,7 +823,6 @@ DEVICE_GET_INFO( acia6850 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(acia6850_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(acia6850); break; diff --git a/src/emu/machine/6850acia.h b/src/emu/machine/6850acia.h index 987fe5b48c5..574c91023a8 100644 --- a/src/emu/machine/6850acia.h +++ b/src/emu/machine/6850acia.h @@ -9,12 +9,14 @@ #ifndef __ACIA6850_H__ #define __ACIA6850_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS ***************************************************************************/ -#define ACIA6850 DEVICE_GET_INFO_NAME(acia6850) +DECLARE_LEGACY_DEVICE(ACIA6850, acia6850); #define ACIA6850_STATUS_RDRF 0x01 #define ACIA6850_STATUS_TDRE 0x02 @@ -58,8 +60,6 @@ struct _acia6850_interface FUNCTION PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( acia6850 ); - void acia6850_tx_clock_in(running_device *device) ATTR_NONNULL(1); void acia6850_rx_clock_in(running_device *device) ATTR_NONNULL(1); diff --git a/src/emu/machine/68681.c b/src/emu/machine/68681.c index dabfec5bb8a..f31bc93da36 100644 --- a/src/emu/machine/68681.c +++ b/src/emu/machine/68681.c @@ -102,10 +102,9 @@ typedef struct INLINE duart68681_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DUART68681); + assert(device->type() == DUART68681); - return (duart68681_state *)device->token; + return (duart68681_state *)downcast(device)->token(); } static void duart68681_update_interrupts(duart68681_state *duart68681) @@ -541,13 +540,13 @@ READ8_DEVICE_HANDLER(duart68681_r) /* TODO: implement modes 0,1,2,4,5 */ case 0x03: /* Counter, CLK/16 */ { - attotime rate = ATTOTIME_IN_HZ(2*device->clock/(2*16*16*duart68681->CTR.w.l)); + attotime rate = ATTOTIME_IN_HZ(2*device->clock()/(2*16*16*duart68681->CTR.w.l)); timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); } break; case 0x06: /* Timer, CLK/1 */ { - attotime rate = ATTOTIME_IN_HZ(2*device->clock/(2*16*duart68681->CTR.w.l)); + attotime rate = ATTOTIME_IN_HZ(2*device->clock()/(2*16*duart68681->CTR.w.l)); timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); } break; @@ -555,7 +554,7 @@ READ8_DEVICE_HANDLER(duart68681_r) { //double hz; //attotime rate = attotime_mul(ATTOTIME_IN_HZ(duart68681->clock), 16*duart68681->CTR.w.l); - attotime rate = ATTOTIME_IN_HZ(2*device->clock/(2*16*16*duart68681->CTR.w.l)); + attotime rate = ATTOTIME_IN_HZ(2*device->clock()/(2*16*16*duart68681->CTR.w.l)); //hz = ATTOSECONDS_TO_HZ(rate.attoseconds); timer_adjust_periodic(duart68681->duart_timer, rate, 0, rate); } @@ -690,7 +689,7 @@ static DEVICE_START(duart68681) /* validate arguments */ assert(device != NULL); - duart68681->duart_config = (const duart68681_config *)device->baseconfig().static_config; + duart68681->duart_config = (const duart68681_config *)device->baseconfig().static_config(); duart68681->device = device; duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); @@ -781,7 +780,6 @@ DEVICE_GET_INFO(duart68681) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(duart68681_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(duart68681_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(duart68681); break; diff --git a/src/emu/machine/68681.h b/src/emu/machine/68681.h index 51e85a36ba7..34e5a7ccb96 100644 --- a/src/emu/machine/68681.h +++ b/src/emu/machine/68681.h @@ -1,6 +1,8 @@ #ifndef _68681_H #define _68681_H +#include "devlegcy.h" + typedef struct _duart68681_config duart68681_config; struct _duart68681_config { @@ -13,8 +15,7 @@ struct _duart68681_config INT32 ip3clk, ip4clk, ip5clk, ip6clk; }; -#define DUART68681 DEVICE_GET_INFO_NAME(duart68681) -DEVICE_GET_INFO(duart68681); +DECLARE_LEGACY_DEVICE(DUART68681, duart68681); #define MDRV_DUART68681_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, DUART68681, _clock) \ diff --git a/src/emu/machine/74123.c b/src/emu/machine/74123.c index be4c66cc69c..fd899470fd0 100644 --- a/src/emu/machine/74123.c +++ b/src/emu/machine/74123.c @@ -30,9 +30,8 @@ struct _ttl74123_t INLINE ttl74123_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == TTL74123 ); - return ( ttl74123_t * ) device->token; + assert( device->type() == TTL74123 ); + return ( ttl74123_t * ) downcast(device)->token(); } @@ -191,7 +190,7 @@ static DEVICE_START( ttl74123 ) ttl74123_t *chip = get_safe_token(device); /* validate arguments */ - chip->intf = (ttl74123_config *)device->baseconfig().static_config; + chip->intf = (ttl74123_config *)device->baseconfig().static_config(); assert_always(chip->intf, "No interface specified"); assert_always((chip->intf->connection_type != TTL74123_GROUNDED) || (chip->intf->cap >= CAP_U(0.01)), "Only capacitors >= 0.01uF supported for GROUNDED type"); @@ -224,7 +223,6 @@ DEVICE_GET_INFO( ttl74123 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ttl74123_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ttl74123); break; diff --git a/src/emu/machine/74123.h b/src/emu/machine/74123.h index 9f0349e060b..beea3758d7d 100644 --- a/src/emu/machine/74123.h +++ b/src/emu/machine/74123.h @@ -46,7 +46,9 @@ #ifndef TTL74123_H #define TTL74123_H -#define TTL74123 DEVICE_GET_INFO_NAME(ttl74123) +#include "devlegcy.h" + +DECLARE_LEGACY_DEVICE(TTL74123, ttl74123); #define MDRV_TTL74123_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, TTL74123, 0) \ @@ -72,9 +74,6 @@ struct _ttl74123_config write8_device_func output_changed_cb; }; -/* device interface */ -DEVICE_GET_INFO( ttl74123 ); - /* write inputs */ WRITE8_DEVICE_HANDLER( ttl74123_a_w ); diff --git a/src/emu/machine/74148.c b/src/emu/machine/74148.c index 07c1c9dfae9..7a9ff3cf085 100644 --- a/src/emu/machine/74148.c +++ b/src/emu/machine/74148.c @@ -67,10 +67,9 @@ struct _ttl74148_state INLINE ttl74148_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TTL74148); + assert(device->type() == TTL74148); - return (ttl74148_state *)device->token; + return (ttl74148_state *)downcast(device)->token(); } void ttl74148_update(running_device *device) @@ -181,7 +180,7 @@ int ttl74148_enable_output_r(running_device *device) static DEVICE_START( ttl74148 ) { - ttl74148_config *config = (ttl74148_config *)device->baseconfig().inline_config; + ttl74148_config *config = (ttl74148_config *)downcast(device->baseconfig()).inline_config(); ttl74148_state *state = get_safe_token(device); state->output_cb = config->output_cb; diff --git a/src/emu/machine/74148.h b/src/emu/machine/74148.h index 95f74d56118..a3948b5b410 100644 --- a/src/emu/machine/74148.h +++ b/src/emu/machine/74148.h @@ -41,6 +41,8 @@ #ifndef TTL74148_H #define TTL74148_H +#include "devlegcy.h" + typedef struct _ttl74148_config ttl74148_config; struct _ttl74148_config @@ -63,8 +65,6 @@ int ttl74148_output_r(running_device *device); int ttl74148_output_valid_r(running_device *device); int ttl74148_enable_output_r(running_device *device); -/* device get info callback */ -#define TTL74148 DEVICE_GET_INFO_NAME(ttl74148) -DEVICE_GET_INFO( ttl74148 ); +DECLARE_LEGACY_DEVICE(TTL74148, ttl74148); #endif diff --git a/src/emu/machine/74153.c b/src/emu/machine/74153.c index 38bf3bc2e5c..897d5ea0126 100644 --- a/src/emu/machine/74153.c +++ b/src/emu/machine/74153.c @@ -59,10 +59,9 @@ struct _ttl74153_state INLINE ttl74153_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TTL74153); + assert(device->type() == TTL74153); - return (ttl74153_state *)device->token; + return (ttl74153_state *)downcast(device)->token(); } @@ -137,7 +136,7 @@ int ttl74153_output_r(running_device *device, int section) static DEVICE_START( ttl74153 ) { - ttl74153_config *config = (ttl74153_config *)device->baseconfig().inline_config; + ttl74153_config *config = (ttl74153_config *)downcast(device->baseconfig()).inline_config(); ttl74153_state *state = get_safe_token(device); state->output_cb = config->output_cb; diff --git a/src/emu/machine/74153.h b/src/emu/machine/74153.h index 852547af0b6..d4e73fb01a5 100644 --- a/src/emu/machine/74153.h +++ b/src/emu/machine/74153.h @@ -36,6 +36,8 @@ #ifndef TTL74153_H #define TTL74153_H +#include "devlegcy.h" + typedef struct _ttl74153_config ttl74153_config; struct _ttl74153_config @@ -59,8 +61,6 @@ void ttl74153_input_line_w(running_device *device, int section, int input_line, void ttl74153_enable_w(running_device *device, int section, int data); int ttl74153_output_r(running_device *device, int section); -/* device get info callback */ -#define TTL74153 DEVICE_GET_INFO_NAME(ttl74153) -DEVICE_GET_INFO( ttl74153 ); +DECLARE_LEGACY_DEVICE(TTL74153, ttl74153); #endif diff --git a/src/emu/machine/7474.c b/src/emu/machine/7474.c index fb6e71c409e..4409dcee8d5 100644 --- a/src/emu/machine/7474.c +++ b/src/emu/machine/7474.c @@ -69,10 +69,9 @@ struct _ttl7474_state INLINE ttl7474_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TTL7474); + assert(device->type() == TTL7474); - return (ttl7474_state *)device->token; + return (ttl7474_state *)downcast(device)->token(); } @@ -163,7 +162,7 @@ READ_LINE_DEVICE_HANDLER( ttl7474_output_comp_r ) static DEVICE_START( ttl7474 ) { - ttl7474_config *config = (ttl7474_config *)device->baseconfig().inline_config; + ttl7474_config *config = (ttl7474_config *)downcast(device->baseconfig()).inline_config(); ttl7474_state *state = get_safe_token(device); devcb_resolve_write_line(&state->output_cb, &config->output_cb, device); diff --git a/src/emu/machine/7474.h b/src/emu/machine/7474.h index b18ad656da8..58bf91aa8c2 100644 --- a/src/emu/machine/7474.h +++ b/src/emu/machine/7474.h @@ -40,6 +40,8 @@ #ifndef TTL7474_H #define TTL7474_H +#include "devlegcy.h" + typedef struct _ttl7474_config ttl7474_config; struct _ttl7474_config @@ -62,8 +64,6 @@ WRITE_LINE_DEVICE_HANDLER( ttl7474_d_w ); READ_LINE_DEVICE_HANDLER( ttl7474_output_r ); READ_LINE_DEVICE_HANDLER( ttl7474_output_comp_r ); /* NOT strictly the same as !ttl7474_output_r() */ -/* device get info callback */ -#define TTL7474 DEVICE_GET_INFO_NAME(ttl7474) -DEVICE_GET_INFO( ttl7474 ); +DECLARE_LEGACY_DEVICE(TTL7474, ttl7474); #endif diff --git a/src/emu/machine/8237dma.c b/src/emu/machine/8237dma.c index eb149baea59..bce04b61cf7 100644 --- a/src/emu/machine/8237dma.c +++ b/src/emu/machine/8237dma.c @@ -111,9 +111,8 @@ struct _i8237_t INLINE i8237_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == I8237 ); - return ( i8237_t *) device->token; + assert( device->type() == I8237 ); + return ( i8237_t *) downcast(device)->token(); } @@ -610,7 +609,7 @@ WRITE_LINE_DEVICE_HANDLER( i8237_eop_w ) static DEVICE_START( i8237 ) { i8237_t *i8237 = get_safe_token(device); - i8237_interface *intf = (i8237_interface *)device->baseconfig().static_config; + i8237_interface *intf = (i8237_interface *)device->baseconfig().static_config(); int i; /* resolve callbacks */ @@ -648,9 +647,9 @@ static DEVICE_RESET( i8237 ) { i8237->chan[3].mode = 0; timer_adjust_periodic(i8237->timer, - ATTOTIME_IN_HZ(device->clock), + ATTOTIME_IN_HZ(device->clock()), 0, - ATTOTIME_IN_HZ(device->clock)); + ATTOTIME_IN_HZ(device->clock())); } @@ -659,7 +658,6 @@ DEVICE_GET_INFO( i8237 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8237_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8237); break; diff --git a/src/emu/machine/8237dma.h b/src/emu/machine/8237dma.h index 773bbf1e265..fcdd82c8444 100644 --- a/src/emu/machine/8237dma.h +++ b/src/emu/machine/8237dma.h @@ -33,12 +33,14 @@ #ifndef __I8237__ #define __I8237__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define I8237 DEVICE_GET_INFO_NAME(i8237) +DECLARE_LEGACY_DEVICE(I8237, i8237); #define MDRV_I8237_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, I8237, _clock) \ @@ -90,6 +92,4 @@ WRITE_LINE_DEVICE_HANDLER( i8237_dreq3_w ); /* end of process */ WRITE_LINE_DEVICE_HANDLER( i8237_eop_w ); -DEVICE_GET_INFO( i8237 ); - #endif diff --git a/src/emu/machine/8255ppi.c b/src/emu/machine/8255ppi.c index b4df7273d07..5589fb46f8c 100644 --- a/src/emu/machine/8255ppi.c +++ b/src/emu/machine/8255ppi.c @@ -135,9 +135,8 @@ static void ppi8255_write_port(running_device *device, int port); INLINE ppi8255_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == DEVICE_GET_INFO_NAME(ppi8255) ); - return ( ppi8255_t * ) device->token; + assert( device->type() == PPI8255 ); + return ( ppi8255_t * ) downcast(device)->token(); } @@ -567,7 +566,7 @@ UINT8 ppi8255_get_port_c( running_device *device ) { static DEVICE_START( ppi8255 ) { ppi8255_t *ppi8255 = get_safe_token(device); - ppi8255->intf = (const ppi8255_interface *)device->baseconfig().static_config; + ppi8255->intf = (const ppi8255_interface *)device->baseconfig().static_config(); devcb_resolve_read8(&ppi8255->port_read[0], &ppi8255->intf->port_a_read, device); devcb_resolve_read8(&ppi8255->port_read[1], &ppi8255->intf->port_b_read, device); @@ -626,7 +625,6 @@ DEVICE_GET_INFO(ppi8255) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ppi8255_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ppi8255); break; diff --git a/src/emu/machine/8255ppi.h b/src/emu/machine/8255ppi.h index f975ed4de60..03439fe6799 100644 --- a/src/emu/machine/8255ppi.h +++ b/src/emu/machine/8255ppi.h @@ -9,9 +9,10 @@ #ifndef __8255PPI_H_ #define __8255PPI_H_ +#include "devlegcy.h" -#define PPI8255 DEVICE_GET_INFO_NAME(ppi8255) +DECLARE_LEGACY_DEVICE(PPI8255, ppi8255); /*************************************************************************** @@ -44,9 +45,6 @@ struct _ppi8255_interface -/* device interface */ -DEVICE_GET_INFO(ppi8255); - READ8_DEVICE_HANDLER( ppi8255_r ); WRITE8_DEVICE_HANDLER( ppi8255_w ); diff --git a/src/emu/machine/8257dma.c b/src/emu/machine/8257dma.c index 3d9ce46b1b0..6092244269e 100644 --- a/src/emu/machine/8257dma.c +++ b/src/emu/machine/8257dma.c @@ -85,9 +85,8 @@ static void dma8257_update_status(running_device *device); INLINE i8257_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == I8257 ); - return ( i8257_t * ) device->token; + assert( device->type() == I8257 ); + return ( i8257_t * ) downcast(device)->token(); } static int dma8257_do_operation(running_device *device, int channel) @@ -218,7 +217,7 @@ static void dma8257_update_status(running_device *device) if (pending_transfer) { - next = ATTOTIME_IN_HZ(device->clock / 4 ); + next = ATTOTIME_IN_HZ(device->clock() / 4 ); timer_adjust_periodic(i8257->timer, attotime_zero, 0, @@ -384,7 +383,7 @@ WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w ) { dma8257_drq_w(device, 3, state); } static DEVICE_START( i8257 ) { i8257_t *i8257 = get_safe_token(device); - i8257_interface *intf = (i8257_interface *)device->baseconfig().static_config; + i8257_interface *intf = (i8257_interface *)device->baseconfig().static_config(); int i; /* validate arguments */ @@ -438,7 +437,6 @@ DEVICE_GET_INFO( i8257 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8257_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8257);break; diff --git a/src/emu/machine/8257dma.h b/src/emu/machine/8257dma.h index 1fc4e41ecb0..d15ab11da6c 100644 --- a/src/emu/machine/8257dma.h +++ b/src/emu/machine/8257dma.h @@ -33,12 +33,14 @@ #ifndef __I8257__ #define __I8257__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define I8257 DEVICE_GET_INFO_NAME(i8257) +DECLARE_LEGACY_DEVICE(I8257, i8257); #define MDRV_I8257_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, I8257, _clock) \ @@ -89,6 +91,4 @@ WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w ); WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w ); WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w ); -DEVICE_GET_INFO( i8257 ); - #endif diff --git a/src/emu/machine/adc083x.c b/src/emu/machine/adc083x.c index 02df7fa3579..af8dc183b34 100644 --- a/src/emu/machine/adc083x.c +++ b/src/emu/machine/adc083x.c @@ -74,16 +74,15 @@ struct _adc0831_state INLINE adc0831_state *get_safe_token( running_device *device ) { assert( device != NULL ); - assert( device->token != NULL ); - assert( ( device->type == ADC0831 ) || ( device->type == ADC0832 ) || ( device->type == ADC0834 ) || ( device->type == ADC0838 ) ); - return (adc0831_state *) device->token; + assert( ( device->type() == ADC0831 ) || ( device->type() == ADC0832 ) || ( device->type() == ADC0834 ) || ( device->type() == ADC0838 ) ); + return (adc0831_state *) downcast(device)->token(); } INLINE const adc083x_interface *get_interface( running_device *device ) { assert( device != NULL ); - assert( ( device->type == ADC0831 ) || ( device->type == ADC0832 ) || ( device->type == ADC0834 ) || ( device->type == ADC0838 ) ); - return (const adc083x_interface *) device->baseconfig().static_config; + assert( ( device->type() == ADC0831 ) || ( device->type() == ADC0832 ) || ( device->type() == ADC0834 ) || ( device->type() == ADC0838 ) ); + return (const adc083x_interface *) device->baseconfig().static_config(); } @@ -97,7 +96,7 @@ INLINE const adc083x_interface *get_interface( running_device *device ) static void adc083x_clear_sars( running_device *device, adc0831_state *adc083x ) { - if( device->type == ADC0834 ||device->type == ADC0838 ) + if( device->type() == ADC0834 ||device->type() == ADC0838 ) { adc083x->sars = 1; } @@ -129,7 +128,7 @@ WRITE_LINE_DEVICE_HANDLER( adc083x_cs_write ) if( adc083x->cs != 0 && state == 0 ) { - if( device->type == ADC0831 ) + if( device->type() == ADC0831 ) { adc083x->state = STATE_MUX_SETTLE; } @@ -160,12 +159,12 @@ static UINT8 adc083x_conversion( running_device *device ) double gnd = adc083x->input_callback_r( device, ADC083X_AGND ); double vref = adc083x->input_callback_r( device, ADC083X_VREF ); - if( device->type == ADC0831 ) + if( device->type() == ADC0831 ) { positive_channel = ADC083X_CH0; negative_channel = ADC083X_CH1; } - else if( device->type == ADC0832 ) + else if( device->type() == ADC0832 ) { positive_channel = ADC083X_CH0 + adc083x->odd; if( adc083x->sgl == 0 ) @@ -177,7 +176,7 @@ static UINT8 adc083x_conversion( running_device *device ) negative_channel = ADC083X_AGND; } } - else if( device->type == ADC0834 ) + else if( device->type() == ADC0834 ) { positive_channel = ADC083X_CH0 + adc083x->odd + ( adc083x->sel1 * 2 ); if( adc083x->sgl == 0 ) @@ -189,7 +188,7 @@ static UINT8 adc083x_conversion( running_device *device ) negative_channel = ADC083X_AGND; } } - else if( device->type == ADC0838 ) + else if( device->type() == ADC0838 ) { positive_channel = ADC083X_CH0 + adc083x->odd + ( adc083x->sel0 * 2 ) + ( adc083x->sel1 * 4 ); if( adc083x->sgl == 0 ) @@ -308,7 +307,7 @@ WRITE_LINE_DEVICE_HANDLER( adc083x_clk_write ) case STATE_WAIT_FOR_SE: adc083x->sars = 0; - if( device->type == ADC0838 && adc083x->se != 0 ) + if( device->type() == ADC0838 && adc083x->se != 0 ) { verboselog( 1, device->machine, "adc083x %s not se\n", device->tag() ); } @@ -342,7 +341,7 @@ WRITE_LINE_DEVICE_HANDLER( adc083x_clk_write ) adc083x->bit--; if( adc083x->bit < 0 ) { - if( device->type == ADC0831 ) + if( device->type() == ADC0831 ) { adc083x->state = STATE_FINISHED; } @@ -455,19 +454,19 @@ static DEVICE_START( adc0831 ) adc083x->bit = 0; adc083x->output = 0; - if( device->type == ADC0831 ) + if( device->type() == ADC0831 ) { adc083x->mux_bits = 0; } - else if( device->type == ADC0832 ) + else if( device->type() == ADC0832 ) { adc083x->mux_bits = 2; } - else if( device->type == ADC0834 ) + else if( device->type() == ADC0834 ) { adc083x->mux_bits = 3; } - else if( device->type == ADC0838 ) + else if( device->type() == ADC0838 ) { adc083x->mux_bits = 4; } @@ -516,7 +515,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "A/D Converters 0831" #define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 083x" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" #define DEVTEMPLATE_DERIVED_ID( p, s ) p##adc0832##s diff --git a/src/emu/machine/adc083x.h b/src/emu/machine/adc083x.h index 5963dc9450f..f21affaa6ea 100644 --- a/src/emu/machine/adc083x.h +++ b/src/emu/machine/adc083x.h @@ -9,6 +9,8 @@ #ifndef __ADC083X_H__ #define __ADC083X_H__ +#include "devlegcy.h" + /*************************************************************************** CONSTANTS @@ -30,10 +32,10 @@ MACROS / CONSTANTS ***************************************************************************/ -#define ADC0831 DEVICE_GET_INFO_NAME(adc0831) -#define ADC0832 DEVICE_GET_INFO_NAME(adc0832) -#define ADC0834 DEVICE_GET_INFO_NAME(adc0834) -#define ADC0838 DEVICE_GET_INFO_NAME(adc0838) +DECLARE_LEGACY_DEVICE(ADC0831, adc0831); +DECLARE_LEGACY_DEVICE(ADC0832, adc0832); +DECLARE_LEGACY_DEVICE(ADC0834, adc0834); +DECLARE_LEGACY_DEVICE(ADC0838, adc0838); #define MDRV_ADC0831_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, ADC0831, 0) \ @@ -69,12 +71,6 @@ struct _adc083x_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( adc0831 ); -DEVICE_GET_INFO( adc0832 ); -DEVICE_GET_INFO( adc0834 ); -DEVICE_GET_INFO( adc0838 ); - extern WRITE_LINE_DEVICE_HANDLER( adc083x_cs_write ); extern WRITE_LINE_DEVICE_HANDLER( adc083x_clk_write ); extern WRITE_LINE_DEVICE_HANDLER( adc083x_di_write ); diff --git a/src/emu/machine/adc1038.c b/src/emu/machine/adc1038.c index 29042faaf04..5ffee842037 100644 --- a/src/emu/machine/adc1038.c +++ b/src/emu/machine/adc1038.c @@ -36,17 +36,16 @@ struct _adc1038_state INLINE adc1038_state *adc1038_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == ADC1038); + assert(device->type() == ADC1038); - return (adc1038_state *)device->token; + return (adc1038_state *)downcast(device)->token(); } INLINE const adc1038_interface *adc1038_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == ADC1038)); - return (const adc1038_interface *) device->baseconfig().static_config; + assert((device->type() == ADC1038)); + return (const adc1038_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -172,5 +171,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "A/D Converters 1038" #define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 1038" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/adc1038.h b/src/emu/machine/adc1038.h index b5be502d7c4..855b603379f 100644 --- a/src/emu/machine/adc1038.h +++ b/src/emu/machine/adc1038.h @@ -10,6 +10,8 @@ #ifndef __ADC1038_H__ #define __ADC1038_H__ +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -25,18 +27,11 @@ struct _adc1038_interface }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( adc1038 ); - - /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define ADC1038 DEVICE_GET_INFO_NAME( adc1038 ) +DECLARE_LEGACY_DEVICE(ADC1038, adc1038); #define MDRV_ADC1038_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, ADC1038, 0) \ diff --git a/src/emu/machine/adc1213x.c b/src/emu/machine/adc1213x.c index 0877012881d..bca94ed6606 100644 --- a/src/emu/machine/adc1213x.c +++ b/src/emu/machine/adc1213x.c @@ -57,16 +57,15 @@ struct _adc12138_state INLINE adc12138_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138)); - return (adc12138_state *)device->token; + assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138)); + return (adc12138_state *)downcast(device)->token(); } INLINE const adc12138_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138)); - return (const adc12138_interface *) device->baseconfig().static_config; + assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138)); + return (const adc12138_interface *) device->baseconfig().static_config(); } @@ -360,7 +359,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "A/D Converter 12138" #define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 1213x" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" #define DEVTEMPLATE_DERIVED_ID(p,s) p##adc12130##s diff --git a/src/emu/machine/adc1213x.h b/src/emu/machine/adc1213x.h index b75a0e7f2f2..6846c3bc912 100644 --- a/src/emu/machine/adc1213x.h +++ b/src/emu/machine/adc1213x.h @@ -10,14 +10,16 @@ #ifndef __ADC1213X_H__ #define __ADC1213X_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define ADC12130 DEVICE_GET_INFO_NAME(adc12130) -#define ADC12132 DEVICE_GET_INFO_NAME(adc12132) -#define ADC12138 DEVICE_GET_INFO_NAME(adc12138) +DECLARE_LEGACY_DEVICE(ADC12130, adc12130); +DECLARE_LEGACY_DEVICE(ADC12132, adc12132); +DECLARE_LEGACY_DEVICE(ADC12138, adc12138); #define MDRV_ADC12130_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, ADC12130, 0) \ @@ -48,11 +50,6 @@ struct _adc12138_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( adc12130 ); -DEVICE_GET_INFO( adc12132 ); -DEVICE_GET_INFO( adc12138 ); - extern WRITE8_DEVICE_HANDLER( adc1213x_di_w ); extern WRITE8_DEVICE_HANDLER( adc1213x_cs_w ); extern WRITE8_DEVICE_HANDLER( adc1213x_sclk_w ); diff --git a/src/emu/machine/at28c16.c b/src/emu/machine/at28c16.c index 63277fda5a7..0b241aada45 100644 --- a/src/emu/machine/at28c16.c +++ b/src/emu/machine/at28c16.c @@ -38,10 +38,9 @@ static TIMER_CALLBACK( write_finished ) INLINE at28c16_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == AT28C16); + assert(device->type() == AT28C16); - return (at28c16_state *)device->token; + return (at28c16_state *)downcast(device)->token(); } WRITE8_DEVICE_HANDLER( at28c16_w ) @@ -132,7 +131,7 @@ static DEVICE_START(at28c16) /* validate some basic stuff */ assert(device != NULL); -// assert(device->baseconfig().static_config != NULL); +// assert(device->baseconfig().static_config() != NULL); // assert(device->baseconfig().inline_config == NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -143,9 +142,9 @@ static DEVICE_START(at28c16) c->oe_12v = 0; c->last_write = -1; c->write_timer = timer_alloc(device->machine, write_finished, c ); - c->default_data = *device->region; + c->default_data = *device->region(); - config = (const at28c16_config *)device->baseconfig().inline_config; + config = (const at28c16_config *)downcast(device->baseconfig()).inline_config(); if (config->id != NULL) c->default_id = memory_region( device->machine, config->id ); @@ -215,7 +214,6 @@ DEVICE_GET_INFO(at28c16) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(at28c16_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(at28c16_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(at28c16); break; diff --git a/src/emu/machine/at28c16.h b/src/emu/machine/at28c16.h index e630c859823..9b1f765677f 100644 --- a/src/emu/machine/at28c16.h +++ b/src/emu/machine/at28c16.h @@ -8,14 +8,15 @@ #if !defined( AT28C16_H ) #define AT28C16_H ( 1 ) +#include "devlegcy.h" + typedef struct _at28c16_config at28c16_config; struct _at28c16_config { const char *id; }; -#define AT28C16 DEVICE_GET_INFO_NAME(at28c16) -DEVICE_GET_INFO(at28c16); +DECLARE_LEGACY_NVRAM_DEVICE(AT28C16, at28c16); #define MDRV_AT28C16_ADD(_tag, _id) \ MDRV_DEVICE_ADD(_tag, AT28C16, 0) \ diff --git a/src/emu/machine/cdp1852.c b/src/emu/machine/cdp1852.c index 833cce6b8b4..2ad3b41ea7c 100644 --- a/src/emu/machine/cdp1852.c +++ b/src/emu/machine/cdp1852.c @@ -40,15 +40,14 @@ struct _cdp1852_t INLINE cdp1852_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - return (cdp1852_t *)device->token; + return (cdp1852_t *)downcast(device)->token(); } INLINE const cdp1852_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == CDP1852)); - return (const cdp1852_interface *) device->baseconfig().static_config; + assert((device->type() == CDP1852)); + return (const cdp1852_interface *) device->baseconfig().static_config(); } /*************************************************************************** @@ -120,7 +119,7 @@ READ8_DEVICE_HANDLER( cdp1852_data_r ) { cdp1852_t *cdp1852 = get_safe_token(device); - if (cdp1852->mode == CDP1852_MODE_INPUT && device->clock == 0) + if (cdp1852->mode == CDP1852_MODE_INPUT && device->clock() == 0) { // input data into register cdp1852->data = devcb_call_read8(&cdp1852->in_data_func, 0); @@ -163,11 +162,11 @@ static DEVICE_START( cdp1852 ) /* set initial values */ cdp1852->mode = (cdp1852_mode)intf->mode; - if (device->clock > 0) + if (device->clock() > 0) { /* create the scan timer */ cdp1852->scan_timer = timer_alloc(device->machine, cdp1852_scan_tick, (void *)device); - timer_adjust_periodic(cdp1852->scan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock)); + timer_adjust_periodic(cdp1852->scan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock())); } /* register for state saving */ @@ -215,7 +214,6 @@ DEVICE_GET_INFO( cdp1852 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1852_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1852); break; diff --git a/src/emu/machine/cdp1852.h b/src/emu/machine/cdp1852.h index d36a721159e..7073ee77b3f 100644 --- a/src/emu/machine/cdp1852.h +++ b/src/emu/machine/cdp1852.h @@ -25,6 +25,8 @@ #ifndef __CDP1852__ #define __CDP1852__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS @@ -32,7 +34,7 @@ #define CDP1852_CLOCK_HIGH 0 -#define CDP1852 DEVICE_GET_INFO_NAME(cdp1852) +DECLARE_LEGACY_DEVICE(CDP1852, cdp1852); #define MDRV_CDP1852_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, CDP1852, _clock) \ @@ -70,9 +72,6 @@ struct _cdp1852_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( cdp1852 ); - /* data access */ READ8_DEVICE_HANDLER( cdp1852_data_r ); WRITE8_DEVICE_HANDLER( cdp1852_data_w ); diff --git a/src/emu/machine/ds1302.c b/src/emu/machine/ds1302.c index 5932dc4cf0b..fdad770932f 100644 --- a/src/emu/machine/ds1302.c +++ b/src/emu/machine/ds1302.c @@ -47,9 +47,8 @@ struct _ds1302_state INLINE ds1302_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DS1302); - return (ds1302_state *)device->token; + assert(device->type() == DS1302); + return (ds1302_state *)downcast(device)->token(); } INLINE UINT8 convert_to_bcd(int val) @@ -225,5 +224,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "Dallas DS1302 RTC" #define DEVTEMPLATE_FAMILY "Dallas DS1302 RTC" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/ds1302.h b/src/emu/machine/ds1302.h index dc5725431f0..032fddaa782 100644 --- a/src/emu/machine/ds1302.h +++ b/src/emu/machine/ds1302.h @@ -9,11 +9,13 @@ #ifndef __DS1302_H__ #define __DS1302_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define DS1302 DEVICE_GET_INFO_NAME(ds1302) +DECLARE_LEGACY_DEVICE(DS1302, ds1302); #define MDRV_DS1302_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, DS1302, 0) @@ -23,9 +25,6 @@ PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( ds1302 ); - extern WRITE8_DEVICE_HANDLER( ds1302_dat_w ); extern WRITE8_DEVICE_HANDLER( ds1302_clk_w ); extern READ8_DEVICE_HANDLER( ds1302_read ); diff --git a/src/emu/machine/ds2404.c b/src/emu/machine/ds2404.c index 9ea3017d45e..b8b66bda455 100644 --- a/src/emu/machine/ds2404.c +++ b/src/emu/machine/ds2404.c @@ -33,10 +33,9 @@ struct _ds2404_state { INLINE ds2404_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DS2404); + assert(device->type() == DS2404); - return (ds2404_state *)device->token; + return (ds2404_state *)downcast(device)->token(); } @@ -300,7 +299,7 @@ static TIMER_CALLBACK( ds2404_tick ) static DEVICE_START( ds2404 ) { - ds2404_config *config = (ds2404_config *)device->baseconfig().inline_config; + ds2404_config *config = (ds2404_config *)downcast(device->baseconfig()).inline_config(); ds2404_state *state = get_safe_token(device); struct tm ref_tm; diff --git a/src/emu/machine/ds2404.h b/src/emu/machine/ds2404.h index b5509574743..fa276382573 100644 --- a/src/emu/machine/ds2404.h +++ b/src/emu/machine/ds2404.h @@ -1,6 +1,8 @@ #ifndef DS2404_H #define DS2404_H +#include "devlegcy.h" + typedef struct _ds2404_config ds2404_config; struct _ds2404_config { @@ -28,7 +30,6 @@ WRITE8_DEVICE_HANDLER( ds2404_data_w ); WRITE8_DEVICE_HANDLER( ds2404_clk_w ); /* device get info callback */ -#define DS2404 DEVICE_GET_INFO_NAME(ds2404) -DEVICE_GET_INFO( ds2404 ); +DECLARE_LEGACY_NVRAM_DEVICE(DS2404, ds2404); #endif diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c index fa2b869b757..6dcb3e1302c 100644 --- a/src/emu/machine/eeprom.c +++ b/src/emu/machine/eeprom.c @@ -1,101 +1,28 @@ -/* - * Serial eeproms - * - */ - -#include "emu.h" -#include "machine/eeprom.h" - -#define VERBOSE 0 -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) +/*************************************************************************** -#define SERIAL_BUFFER_LENGTH 40 + eeprom.h -typedef struct _eeprom_state eeprom_state; -struct _eeprom_state -{ - const eeprom_interface *intf; - int serial_count; - UINT8 serial_buffer[SERIAL_BUFFER_LENGTH]; - int data_bits; - int read_address; - int clock_count; - int latch,reset_line,clock_line,sending; - int locked; - int reset_delay; -}; + Serial eeproms. -/*------------------------------------------------- - get_safe_token - makes sure that the passed - in device is, in fact, an I2C memory --------------------------------------------------*/ +***************************************************************************/ -INLINE eeprom_state *get_safe_token(running_device *device) -{ - assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == EEPROM ); +#include "emu.h" +#include "machine/eeprom.h" - return (eeprom_state *)device->token; -} -/* - eeprom_command_match: - Try to match the first (len) digits in the EEPROM serial buffer - string (*buf) with an EEPROM command string (*cmd). - Return non zero if a match was found. +//************************************************************************** +// DEBUGGING +//************************************************************************** - The serial buffer only contains '0' or '1' (e.g. "1001"). - The command can contain: '0' or '1' or these wildcards: - - 'x' : match both '0' and '1' - "*1": match "1", "01", "001", "0001" etc. - "*0": match "0", "10", "110", "1110" etc. +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - Note: (cmd) may be NULL. Return 0 (no match) in this case. -*/ -static int eeprom_command_match(const char *buf, const char *cmd, int len) -{ - if ( cmd == 0 ) return 0; - if ( len == 0 ) return 0; - for (;len>0;) - { - char b = *buf; - char c = *cmd; - - if ((b==0) || (c==0)) - return (b==c); - - switch ( c ) - { - case '0': - case '1': - if (b != c) return 0; - case 'X': - case 'x': - buf++; - len--; - cmd++; - break; - - case '*': - c = cmd[1]; - switch( c ) - { - case '0': - case '1': - if (b == c) { cmd++; } - else { buf++; len--; } - break; - default: return 0; - } - } - } - return (*cmd==0); -} +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** const eeprom_interface eeprom_interface_93C46 = { @@ -127,140 +54,289 @@ const eeprom_interface eeprom_interface_93C66B = // "*10010xxxxxx", // erase all }; -static void eeprom_write(running_device *device, int bit) + +static ADDRESS_MAP_START( eeprom_map8, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x0fff) AM_RAM +ADDRESS_MAP_END + + +static ADDRESS_MAP_START( eeprom_map16, ADDRESS_SPACE_PROGRAM, 16 ) + AM_RANGE(0x0000, 0x07ff) AM_RAM +ADDRESS_MAP_END + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// eeprom_device_config - constructor +//------------------------------------------------- + +eeprom_device_config::eeprom_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_memory_interface(mconfig, *this), + device_config_nvram_interface(mconfig, *this), + m_default_data(NULL), + m_default_data_size(0), + m_default_value(0) { - eeprom_state *eestate = get_safe_token(device); +} - LOG(("EEPROM write bit %d\n",bit)); - if (eestate->serial_count >= SERIAL_BUFFER_LENGTH-1) - { - logerror("error: EEPROM serial buffer overflow\n"); - return; - } +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- - eestate->serial_buffer[eestate->serial_count++] = (bit ? '1' : '0'); - eestate->serial_buffer[eestate->serial_count] = 0; /* nul terminate so we can treat it as a string */ +device_config *eeprom_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(eeprom_device_config(mconfig, tag, owner, clock)); +} - if ( (eestate->serial_count > eestate->intf->address_bits) && - eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_read,strlen((char*)(eestate->serial_buffer))-eestate->intf->address_bits) ) - { - int i,address; - address = 0; - for (i = eestate->serial_count-eestate->intf->address_bits;i < eestate->serial_count;i++) - { - address <<= 1; - if (eestate->serial_buffer[i] == '1') address |= 1; - } - if (eestate->intf->data_bits == 16) - eestate->data_bits = memory_read_word(device->space(), address * 2); - else - eestate->data_bits = memory_read_byte(device->space(), address); - eestate->read_address = address; - eestate->clock_count = 0; - eestate->sending = 1; - eestate->serial_count = 0; -logerror("EEPROM read %04x from address %02x\n",eestate->data_bits,address); - } - else if ( (eestate->serial_count > eestate->intf->address_bits) && - eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_erase,strlen((char*)(eestate->serial_buffer))-eestate->intf->address_bits) ) - { - int i,address; +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- - address = 0; - for (i = eestate->serial_count-eestate->intf->address_bits;i < eestate->serial_count;i++) - { - address <<= 1; - if (eestate->serial_buffer[i] == '1') address |= 1; - } -logerror("EEPROM erase address %02x\n",address); - if (eestate->locked == 0) - { - if (eestate->intf->data_bits == 16) - memory_write_word(device->space(), address * 2, 0x0000); - else - memory_write_byte(device->space(), address, 0x00); - } - else -logerror("Error: EEPROM is locked\n"); - eestate->serial_count = 0; - } - else if ( (eestate->serial_count > (eestate->intf->address_bits + eestate->intf->data_bits)) && - eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_write,strlen((char*)(eestate->serial_buffer))-(eestate->intf->address_bits + eestate->intf->data_bits)) ) - { - int i,address,data; +device_t *eeprom_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, eeprom_device(machine, *this)); +} - address = 0; - for (i = eestate->serial_count-eestate->intf->data_bits-eestate->intf->address_bits;i < (eestate->serial_count-eestate->intf->data_bits);i++) - { - address <<= 1; - if (eestate->serial_buffer[i] == '1') address |= 1; - } - data = 0; - for (i = eestate->serial_count-eestate->intf->data_bits;i < eestate->serial_count;i++) - { - data <<= 1; - if (eestate->serial_buffer[i] == '1') data |= 1; - } -logerror("EEPROM write %04x to address %02x\n",data,address); - if (eestate->locked == 0) - { - if (eestate->intf->data_bits == 16) - memory_write_word(device->space(), address * 2, data); - else - memory_write_byte(device->space(), address, data); - } - else -logerror("Error: EEPROM is locked\n"); - eestate->serial_count = 0; + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void eeprom_device_config::device_config_complete() +{ + // extract inline configuration from raw data + const eeprom_interface *intf = reinterpret_cast(m_inline_data[INLINE_INTERFACE]); + m_default_data = reinterpret_cast(m_inline_data[INLINE_DATAPTR]); + m_default_data_size = m_inline_data[INLINE_DATASIZE]; + m_default_value = m_inline_data[INLINE_DEFVALUE]; + + // inherit a copy of the static data + if (intf != NULL) + *static_cast(this) = *intf; + + // now describe our address space + if (m_data_bits == 8) + m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 8, m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map8)); + else + m_space_config = address_space_config("eeprom", ENDIANNESS_BIG, 16, m_address_bits, 0, *ADDRESS_MAP_NAME(eeprom_map16)); +} + + +//------------------------------------------------- +// device_validity_check - perform validity checks +// on this device +//------------------------------------------------- + +bool eeprom_device_config::device_validity_check(const game_driver &driver) const +{ + bool error = false; + + if (m_inline_data[INLINE_INTERFACE] == 0) + { + mame_printf_error("%s: %s eeprom device '%s' did not specify an interface\n", driver.source_file, driver.name, tag()); + error = true; } - else if ( eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_lock,strlen((char*)(eestate->serial_buffer))) ) + else if (m_data_bits != 8 && m_data_bits != 16) { -logerror("EEPROM lock\n"); - eestate->locked = 1; - eestate->serial_count = 0; + mame_printf_error("%s: %s eeprom device '%s' specified invalid data width %d\n", driver.source_file, driver.name, tag(), m_data_bits); + error = true; } - else if ( eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_unlock,strlen((char*)(eestate->serial_buffer))) ) + + return error; +} + + +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +const address_space_config *eeprom_device_config::memory_space_config(int spacenum) const +{ + return (spacenum == 0) ? &m_space_config : NULL; +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// eeprom_device - constructor +//------------------------------------------------- + +eeprom_device::eeprom_device(running_machine &_machine, const eeprom_device_config &config) + : device_t(_machine, config), + device_memory_interface(_machine, config, *this), + device_nvram_interface(_machine, config, *this), + m_config(config), + m_serial_count(0), + m_data_bits(0), + m_read_address(0), + m_clock_count(0), + m_latch(0), + m_reset_line(CLEAR_LINE), + m_clock_line(CLEAR_LINE), + m_sending(0), + m_locked(m_config.m_cmd_unlock != NULL), + m_reset_delay(0) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void eeprom_device::device_start() +{ + state_save_register_device_item_pointer(this, 0, m_serial_buffer, SERIAL_BUFFER_LENGTH); + state_save_register_device_item(this, 0, m_clock_line); + state_save_register_device_item(this, 0, m_reset_line); + state_save_register_device_item(this, 0, m_locked); + state_save_register_device_item(this, 0, m_serial_count); + state_save_register_device_item(this, 0, m_latch); + state_save_register_device_item(this, 0, m_reset_delay); + state_save_register_device_item(this, 0, m_clock_count); + state_save_register_device_item(this, 0, m_data_bits); + state_save_register_device_item(this, 0, m_read_address); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void eeprom_device::device_reset() +{ +} + + +//------------------------------------------------- +// nvram_default - called to initialize NVRAM to +// its default state +//------------------------------------------------- + +void eeprom_device::nvram_default() +{ + UINT32 eeprom_length = 1 << m_config.m_address_bits; + UINT32 eeprom_bytes = eeprom_length * m_config.m_data_bits / 8; + + /* initialize to the default value */ + UINT16 default_value = 0xffff; + if (m_config.m_default_value != 0) + default_value = m_config.m_default_value; + for (offs_t offs = 0; offs < eeprom_length; offs++) + if (m_config.m_data_bits == 8) + memory_write_byte(m_addrspace[0], offs, default_value); + else + memory_write_word(m_addrspace[0], offs * 2, default_value); + + /* handle hard-coded data from the driver */ + if (m_config.m_default_data != NULL) + for (offs_t offs = 0; offs < m_config.m_default_data_size; offs++) + memory_write_byte(m_addrspace[0], offs, m_config.m_default_data[offs]); + + /* populate from a memory region if present */ + if (m_region != NULL) { -logerror("EEPROM unlock\n"); - eestate->locked = 0; - eestate->serial_count = 0; + if (m_region->length != eeprom_bytes) + fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", tag(), eeprom_bytes); + if (m_config.m_data_bits == 8 && (m_region->flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT) + fatalerror("eeprom region '%s' needs to be an 8-bit region", tag()); + if (m_config.m_data_bits == 16 && ((m_region->flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (m_region->flags & ROMREGION_ENDIANMASK) != ROMREGION_BE)) + fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", tag(), m_region->flags); + + for (offs_t offs = 0; offs < eeprom_length; offs++) + if (m_config.m_data_bits == 8) + memory_write_byte(m_addrspace[0], offs, m_region->base.u8[offs]); + else + memory_write_word(m_addrspace[0], offs * 2, m_region->base.u16[offs]); } } -static void eeprom_reset(eeprom_state *eestate) + +//------------------------------------------------- +// nvram_read - called to read NVRAM from the +// .nv file +//------------------------------------------------- + +void eeprom_device::nvram_read(mame_file &file) { - if (eestate->serial_count) - logerror("EEPROM reset, buffer = %s\n",eestate->serial_buffer); + UINT32 eeprom_length = 1 << m_config.m_address_bits; + UINT32 eeprom_bytes = eeprom_length * m_config.m_data_bits / 8; + + UINT8 *buffer = auto_alloc_array(&m_machine, UINT8, eeprom_bytes); + mame_fread(&file, buffer, eeprom_bytes); + for (offs_t offs = 0; offs < eeprom_bytes; offs++) + memory_write_byte(m_addrspace[0], offs, buffer[offs]); + auto_free(&m_machine, buffer); +} + + +//------------------------------------------------- +// nvram_write - called to write NVRAM to the +// .nv file +//------------------------------------------------- - eestate->serial_count = 0; - eestate->sending = 0; - eestate->reset_delay = eestate->intf->reset_delay; /* delay a little before returning setting data to 1 (needed by wbeachvl) */ +void eeprom_device::nvram_write(mame_file &file) +{ + UINT32 eeprom_length = 1 << m_config.m_address_bits; + UINT32 eeprom_bytes = eeprom_length * m_config.m_data_bits / 8; + + UINT8 *buffer = auto_alloc_array(&m_machine, UINT8, eeprom_bytes); + for (offs_t offs = 0; offs < eeprom_bytes; offs++) + buffer[offs] = memory_read_byte(m_addrspace[0], offs); + mame_fwrite(&file, buffer, eeprom_bytes); + auto_free(&m_machine, buffer); } + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + WRITE_LINE_DEVICE_HANDLER( eeprom_write_bit ) { - eeprom_state *eestate = get_safe_token(device); + downcast(device)->write_bit(state); +} +void eeprom_device::write_bit(int state) +{ LOG(("write bit %d\n",state)); - eestate->latch = state; + m_latch = state; } + READ_LINE_DEVICE_HANDLER( eeprom_read_bit ) { - eeprom_state *eestate = get_safe_token(device); + return downcast(device)->read_bit(); +} + +int eeprom_device::read_bit() +{ int res; - if (eestate->sending) - res = (eestate->data_bits >> eestate->intf->data_bits) & 1; + if (m_sending) + res = (m_data_bits >> m_config.m_data_bits) & 1; else { - if (eestate->reset_delay > 0) + if (m_reset_delay > 0) { /* this is needed by wbeachvl */ - eestate->reset_delay--; + m_reset_delay--; res = 0; } else @@ -272,165 +348,227 @@ READ_LINE_DEVICE_HANDLER( eeprom_read_bit ) return res; } + + WRITE_LINE_DEVICE_HANDLER( eeprom_set_cs_line ) { - eeprom_state *eestate = get_safe_token(device); + downcast(device)->set_cs_line(state); +} +void eeprom_device::set_cs_line(int state) +{ LOG(("set reset line %d\n",state)); - eestate->reset_line = state; + m_reset_line = state; - if (eestate->reset_line != CLEAR_LINE) - eeprom_reset(eestate); + if (m_reset_line != CLEAR_LINE) + { + if (m_serial_count) + logerror("EEPROM reset, buffer = %s\n",m_serial_buffer); + + m_serial_count = 0; + m_sending = 0; + m_reset_delay = m_config.m_reset_delay; /* delay a little before returning setting data to 1 (needed by wbeachvl) */ + } } + + WRITE_LINE_DEVICE_HANDLER( eeprom_set_clock_line ) { - eeprom_state *eestate = get_safe_token(device); + downcast(device)->set_clock_line(state); +} +void eeprom_device::set_clock_line(int state) +{ LOG(("set clock line %d\n",state)); - if (state == PULSE_LINE || (eestate->clock_line == CLEAR_LINE && state != CLEAR_LINE)) + if (state == PULSE_LINE || (m_clock_line == CLEAR_LINE && state != CLEAR_LINE)) { - if (eestate->reset_line == CLEAR_LINE) + if (m_reset_line == CLEAR_LINE) { - if (eestate->sending) + if (m_sending) { - if (eestate->clock_count == eestate->intf->data_bits && eestate->intf->enable_multi_read) + if (m_clock_count == m_config.m_data_bits && m_config.m_enable_multi_read) { - eestate->read_address = (eestate->read_address + 1) & ((1 << eestate->intf->address_bits) - 1); - if (eestate->intf->data_bits == 16) - eestate->data_bits = memory_read_word(device->space(), eestate->read_address * 2); + m_read_address = (m_read_address + 1) & ((1 << m_config.m_address_bits) - 1); + if (m_config.m_data_bits == 16) + m_data_bits = memory_read_word(m_addrspace[0], m_read_address * 2); else - eestate->data_bits = memory_read_byte(device->space(), eestate->read_address); - eestate->clock_count = 0; -logerror("EEPROM read %04x from address %02x\n",eestate->data_bits,eestate->read_address); + m_data_bits = memory_read_byte(m_addrspace[0], m_read_address); + m_clock_count = 0; +logerror("EEPROM read %04x from address %02x\n",m_data_bits,m_read_address); } - eestate->data_bits = (eestate->data_bits << 1) | 1; - eestate->clock_count++; + m_data_bits = (m_data_bits << 1) | 1; + m_clock_count++; } else - eeprom_write(device,eestate->latch); + write(m_latch); } } - eestate->clock_line = state; + m_clock_line = state; } -static DEVICE_NVRAM( eeprom ) + +//************************************************************************** +// INTERNAL HELPERS +//************************************************************************** + +void eeprom_device::write(int bit) { - eeprom_state *eestate = get_safe_token(device); - UINT32 eeprom_length = 1 << eestate->intf->address_bits; - UINT32 eeprom_bytes = eeprom_length * eestate->intf->data_bits / 8; - UINT32 offs; + LOG(("EEPROM write bit %d\n",bit)); - if (read_or_write) + if (m_serial_count >= SERIAL_BUFFER_LENGTH-1) { - UINT8 *buffer = auto_alloc_array(device->machine, UINT8, eeprom_bytes); - for (offs = 0; offs < eeprom_bytes; offs++) - buffer[offs] = memory_read_byte(device->space(), offs); - mame_fwrite(file, buffer, eeprom_bytes); - auto_free(device->machine, buffer); + logerror("error: EEPROM serial buffer overflow\n"); + return; } - else if (file != NULL) + + m_serial_buffer[m_serial_count++] = (bit ? '1' : '0'); + m_serial_buffer[m_serial_count] = 0; /* nul terminate so we can treat it as a string */ + + if ( (m_serial_count > m_config.m_address_bits) && + command_match((char*)(m_serial_buffer),m_config.m_cmd_read,strlen((char*)(m_serial_buffer))-m_config.m_address_bits) ) { - UINT8 *buffer = auto_alloc_array(device->machine, UINT8, eeprom_bytes); - mame_fread(file, buffer, eeprom_bytes); - for (offs = 0; offs < eeprom_bytes; offs++) - memory_write_byte(device->space(), offs, buffer[offs]); - auto_free(device->machine, buffer); + int i,address; + + address = 0; + for (i = m_serial_count-m_config.m_address_bits;i < m_serial_count;i++) + { + address <<= 1; + if (m_serial_buffer[i] == '1') address |= 1; + } + if (m_config.m_data_bits == 16) + m_data_bits = memory_read_word(m_addrspace[0], address * 2); + else + m_data_bits = memory_read_byte(m_addrspace[0], address); + m_read_address = address; + m_clock_count = 0; + m_sending = 1; + m_serial_count = 0; +logerror("EEPROM read %04x from address %02x\n",m_data_bits,address); } - else + else if ( (m_serial_count > m_config.m_address_bits) && + command_match((char*)(m_serial_buffer),m_config.m_cmd_erase,strlen((char*)(m_serial_buffer))-m_config.m_address_bits) ) { - const eeprom_config *config = (const eeprom_config *)device->baseconfig().inline_config; - UINT16 default_value = 0xffff; - int offs; - - /* initialize to the default value */ - if (config->default_value != 0) - default_value = config->default_value; - for (offs = 0; offs < eeprom_length; offs++) - if (eestate->intf->data_bits == 8) - memory_write_byte(device->space(), offs, default_value); - else - memory_write_word(device->space(), offs * 2, default_value); + int i,address; - /* handle hard-coded data from the driver */ - if (config->default_data != NULL) - for (offs = 0; offs < config->default_data_size; offs++) - memory_write_byte(device->space(), offs, config->default_data[offs]); + address = 0; + for (i = m_serial_count-m_config.m_address_bits;i < m_serial_count;i++) + { + address <<= 1; + if (m_serial_buffer[i] == '1') address |= 1; + } +logerror("EEPROM erase address %02x\n",address); + if (m_locked == 0) + { + if (m_config.m_data_bits == 16) + memory_write_word(m_addrspace[0], address * 2, 0x0000); + else + memory_write_byte(m_addrspace[0], address, 0x00); + } + else +logerror("Error: EEPROM is m_locked\n"); + m_serial_count = 0; + } + else if ( (m_serial_count > (m_config.m_address_bits + m_config.m_data_bits)) && + command_match((char*)(m_serial_buffer),m_config.m_cmd_write,strlen((char*)(m_serial_buffer))-(m_config.m_address_bits + m_config.m_data_bits)) ) + { + int i,address,data; - /* populate from a memory region if present */ - if (device->region != NULL) + address = 0; + for (i = m_serial_count-m_config.m_data_bits-m_config.m_address_bits;i < (m_serial_count-m_config.m_data_bits);i++) + { + address <<= 1; + if (m_serial_buffer[i] == '1') address |= 1; + } + data = 0; + for (i = m_serial_count-m_config.m_data_bits;i < m_serial_count;i++) + { + data <<= 1; + if (m_serial_buffer[i] == '1') data |= 1; + } +logerror("EEPROM write %04x to address %02x\n",data,address); + if (m_locked == 0) { - if (device->region->length != eeprom_bytes) - fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", device->tag(), eeprom_bytes); - if (eestate->intf->data_bits == 8 && (device->region->flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT) - fatalerror("eeprom region '%s' needs to be an 8-bit region", device->tag()); - if (eestate->intf->data_bits == 16 && ((device->region->flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (device->region->flags & ROMREGION_ENDIANMASK) != ROMREGION_BE)) - fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", device->tag(), device->region->flags); - - for (offs = 0; offs < eeprom_length; offs++) - if (eestate->intf->data_bits == 8) - memory_write_byte(device->space(), offs, device->region->base.u8[offs]); - else - memory_write_word(device->space(), offs * 2, device->region->base.u16[offs]); + if (m_config.m_data_bits == 16) + memory_write_word(m_addrspace[0], address * 2, data); + else + memory_write_byte(m_addrspace[0], address, data); } + else +logerror("Error: EEPROM is m_locked\n"); + m_serial_count = 0; + } + else if ( command_match((char*)(m_serial_buffer),m_config.m_cmd_lock,strlen((char*)(m_serial_buffer))) ) + { +logerror("EEPROM lock\n"); + m_locked = 1; + m_serial_count = 0; + } + else if ( command_match((char*)(m_serial_buffer),m_config.m_cmd_unlock,strlen((char*)(m_serial_buffer))) ) + { +logerror("EEPROM unlock\n"); + m_locked = 0; + m_serial_count = 0; } } -static DEVICE_START( eeprom ) + +/* + command_match: + + Try to match the first (len) digits in the EEPROM serial buffer + string (*buf) with an EEPROM command string (*cmd). + Return non zero if a match was found. + + The serial buffer only contains '0' or '1' (e.g. "1001"). + The command can contain: '0' or '1' or these wildcards: + + 'x' : match both '0' and '1' + "*1": match "1", "01", "001", "0001" etc. + "*0": match "0", "10", "110", "1110" etc. + + Note: (cmd) may be NULL. Return 0 (no match) in this case. +*/ +bool eeprom_device::command_match(const char *buf, const char *cmd, int len) { - eeprom_state *eestate = get_safe_token(device); - const eeprom_config *config; - - /* validate some basic stuff */ - assert(device != NULL); - assert(device->baseconfig().inline_config != NULL); - assert(device->machine != NULL); - assert(device->machine->config != NULL); - - config = (const eeprom_config *)device->baseconfig().inline_config; - - eestate->intf = config->pinterface; - - eestate->serial_count = 0; - eestate->latch = 0; - eestate->reset_line = CLEAR_LINE; - eestate->clock_line = CLEAR_LINE; - eestate->read_address = 0; - eestate->sending = 0; - if (eestate->intf->cmd_unlock) eestate->locked = 1; - else eestate->locked = 0; - - state_save_register_device_item_pointer( device, 0, eestate->serial_buffer, SERIAL_BUFFER_LENGTH); - state_save_register_device_item( device, 0, eestate->clock_line); - state_save_register_device_item( device, 0, eestate->reset_line); - state_save_register_device_item( device, 0, eestate->locked); - state_save_register_device_item( device, 0, eestate->serial_count); - state_save_register_device_item( device, 0, eestate->latch); - state_save_register_device_item( device, 0, eestate->reset_delay); - state_save_register_device_item( device, 0, eestate->clock_count); - state_save_register_device_item( device, 0, eestate->data_bits); - state_save_register_device_item( device, 0, eestate->read_address); -} + if ( cmd == 0 ) return false; + if ( len == 0 ) return false; -static ADDRESS_MAP_START( eeprom_map8, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_RAM -ADDRESS_MAP_END + for (;len>0;) + { + char b = *buf; + char c = *cmd; -static ADDRESS_MAP_START( eeprom_map16, ADDRESS_SPACE_PROGRAM, 16 ) - AM_RANGE(0x0000, 0x07ff) AM_RAM -ADDRESS_MAP_END + if ((b==0) || (c==0)) + return (b==c); + + switch ( c ) + { + case '0': + case '1': + if (b != c) return false; + case 'X': + case 'x': + buf++; + len--; + cmd++; + break; + + case '*': + c = cmd[1]; + switch( c ) + { + case '0': + case '1': + if (b == c) { cmd++; } + else { buf++; len--; } + break; + default: return false; + } + } + } + return (*cmd==0); +} -static const char DEVTEMPLATE_SOURCE[] = __FILE__; - -#define DEVTEMPLATE_ID(p,s) p##eeprom##s -#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_NVRAM | DT_HAS_INLINE_CONFIG | DT_HAS_PROGRAM_SPACE -#define DEVTEMPLATE_NAME "EEPROM" -#define DEVTEMPLATE_FAMILY "EEPROM" -#define DEVTEMPLATE_ENDIANNESS ENDIANNESS_BIG -#define DEVTEMPLATE_PGM_DATAWIDTH (((const eeprom_config *)device->inline_config)->pinterface->data_bits) -#define DEVTEMPLATE_PGM_ADDRWIDTH (((const eeprom_config *)device->inline_config)->pinterface->address_bits) -#define DEVTEMPLATE_PGM_ADDRSHIFT (((const eeprom_config *)device->inline_config)->pinterface->data_bits == 8 ? 0 : -1) -#define DEVTEMPLATE_PGM_DEFMAP (((const eeprom_config *)device->inline_config)->pinterface->data_bits == 8 ? (const void *)ADDRESS_MAP_NAME(eeprom_map8) : (const void *)ADDRESS_MAP_NAME(eeprom_map16)) -#include "devtempl.h" diff --git a/src/emu/machine/eeprom.h b/src/emu/machine/eeprom.h index 11e793a5496..ffc8066cd95 100644 --- a/src/emu/machine/eeprom.h +++ b/src/emu/machine/eeprom.h @@ -1,47 +1,25 @@ -/* - * Serial eeproms - * - */ +/*************************************************************************** -#if !defined( EEPROMDEV_H ) -#define EEPROMDEV_H ( 1 ) + eeprom.h -typedef struct _eeprom_interface eeprom_interface; -struct _eeprom_interface -{ - int address_bits; /* EEPROM has 2^address_bits cells */ - int data_bits; /* every cell has this many bits (8 or 16) */ - const char *cmd_read; /* read command string, e.g. "0110" */ - const char *cmd_write; /* write command string, e.g. "0111" */ - const char *cmd_erase; /* erase command string, or 0 if n/a */ - const char *cmd_lock; /* lock command string, or 0 if n/a */ - const char *cmd_unlock; /* unlock command string, or 0 if n/a */ - int enable_multi_read; /* set to 1 to enable multiple values to be read from one read command */ - int reset_delay; /* number of times eeprom_read_bit() should return 0 after a reset, */ - /* before starting to return 1. */ -}; + Serial eeproms. -typedef struct _eeprom_config eeprom_config; -struct _eeprom_config -{ - eeprom_interface *pinterface; - UINT8 *default_data; - int default_data_size; - UINT32 default_value; -}; +***************************************************************************/ -/* 93C46 */ -extern const eeprom_interface eeprom_interface_93C46; +#pragma once + +#ifndef __EEPROMDEV_H__ +#define __EEPROMDEV_H__ -/* 93C66B */ -extern const eeprom_interface eeprom_interface_93C66B; -#define EEPROM DEVICE_GET_INFO_NAME(eeprom) -DEVICE_GET_INFO(eeprom); + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** #define MDRV_EEPROM_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, EEPROM, 0) \ - MDRV_DEVICE_CONFIG_DATAPTR(eeprom_config, pinterface, &_interface) + MDRV_DEVICE_INLINE_DATAPTR(eeprom_device_config::INLINE_INTERFACE, &_interface) #define MDRV_EEPROM_93C46_ADD(_tag) \ MDRV_EEPROM_ADD(_tag, eeprom_interface_93C46) @@ -50,11 +28,151 @@ DEVICE_GET_INFO(eeprom); MDRV_EEPROM_ADD(_tag, eeprom_interface_93C66B) #define MDRV_EEPROM_DATA(_data, _size) \ - MDRV_DEVICE_CONFIG_DATAPTR(eeprom_config, default_data, &_data) \ - MDRV_DEVICE_CONFIG_DATA32(eeprom_config, default_data_size, _size) + MDRV_DEVICE_INLINE_DATAPTR(eeprom_device_config::INLINE_DATAPTR, &_data) \ + MDRV_DEVICE_INLINE_DATA16(eeprom_device_config::INLINE_DATASIZE, _size) #define MDRV_EEPROM_DEFAULT_VALUE(_value) \ - MDRV_DEVICE_CONFIG_DATA32(eeprom_config, default_value, 0x10000 | ((_value) & 0xffff)) + MDRV_DEVICE_INLINE_DATA32(eeprom_device_config::INLINE_DEFVALUE, 0x10000 | ((_value) & 0xffff)) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> eeprom_interface + +struct eeprom_interface +{ + UINT8 m_address_bits; // EEPROM has 2^address_bits cells + UINT8 m_data_bits; // every cell has this many bits (8 or 16) + const char *m_cmd_read; // read command string, e.g. "0110" + const char *m_cmd_write; // write command string, e.g. "0111" + const char *m_cmd_erase; // erase command string, or 0 if n/a + const char *m_cmd_lock; // lock command string, or 0 if n/a + const char *m_cmd_unlock; // unlock command string, or 0 if n/a + bool m_enable_multi_read; // set to 1 to enable multiple values to be read from one read command + int m_reset_delay; // number of times eeprom_read_bit() should return 0 after a reset, + // before starting to return 1. +}; + + + +// ======================> eeprom_device_config + +class eeprom_device_config : public device_config, + public device_config_memory_interface, + public device_config_nvram_interface, + public eeprom_interface +{ + friend class eeprom_device; + + // construction/destruction + eeprom_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "EEPROM"; } + + // inline configuration indexes + enum + { + INLINE_INTERFACE, + INLINE_DATAPTR, + INLINE_DATASIZE, + INLINE_DEFVALUE + }; + +protected: + // device_config overrides + virtual void device_config_complete(); + virtual bool device_validity_check(const game_driver &driver) const; + + // device_config_memory_interface overrides + virtual const address_space_config *memory_space_config(int spacenum = 0) const; + + // device-specific configuration + const UINT8 * m_default_data; + int m_default_data_size; + UINT32 m_default_value; + address_space_config m_space_config; +}; + + +// ======================> eeprom_device + +class eeprom_device : public device_t, + public device_memory_interface, + public device_nvram_interface +{ + friend class eeprom_device_config; + + // construction/destruction + eeprom_device(running_machine &_machine, const eeprom_device_config &config); + +public: + // I/O operations + void write_bit(int state); + int read_bit(); + void set_cs_line(int state); + void set_clock_line(int state); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_nvram_interface overrides + virtual void nvram_default(); + virtual void nvram_read(mame_file &file); + virtual void nvram_write(mame_file &file); + + // internal helpers + void write(int bit); + bool command_match(const char *buf, const char *cmd, int len); + + static const int SERIAL_BUFFER_LENGTH = 40; + + // internal state + const eeprom_device_config &m_config; + + int m_serial_count; + UINT8 m_serial_buffer[SERIAL_BUFFER_LENGTH]; + int m_data_bits; + int m_read_address; + int m_clock_count; + int m_latch; + int m_reset_line; + int m_clock_line; + int m_sending; + int m_locked; + int m_reset_delay; +}; + + +// device type definition +const device_type EEPROM = eeprom_device_config::static_alloc_device_config; + + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +extern const eeprom_interface eeprom_interface_93C46; +extern const eeprom_interface eeprom_interface_93C66B; + + + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** WRITE_LINE_DEVICE_HANDLER( eeprom_write_bit ); READ_LINE_DEVICE_HANDLER( eeprom_read_bit ); diff --git a/src/emu/machine/f3853.c b/src/emu/machine/f3853.c index d9136cae409..81af2777716 100644 --- a/src/emu/machine/f3853.c +++ b/src/emu/machine/f3853.c @@ -49,9 +49,8 @@ static TIMER_CALLBACK( f3853_timer_callback ); INLINE f3853_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == DEVICE_GET_INFO_NAME(f3853) ); - return ( f3853_t * ) device->token; + assert( device->type() == F3853 ); + return ( f3853_t * ) downcast(device)->token(); } @@ -75,7 +74,7 @@ static void f3853_timer_start(running_device *device, UINT8 value) { f3853_t *f3853 = get_safe_token( device ); - attotime period = (value != 0xff) ? attotime_mul(ATTOTIME_IN_HZ(device->clock), f3853_value_to_cycle[value]*31) : attotime_never; + attotime period = (value != 0xff) ? attotime_mul(ATTOTIME_IN_HZ(device->clock()), f3853_value_to_cycle[value]*31) : attotime_never; timer_adjust_oneshot(f3853->timer, period, 0); } @@ -167,7 +166,7 @@ static DEVICE_START( f3853 ) UINT8 reg=0xfe; int i; - f3853->config = (const f3853_config *)device->baseconfig().static_config; + f3853->config = (const f3853_config *)device->baseconfig().static_config(); for (i=254/*known to get 0xfe after 255 cycles*/; i>=0; i--) { @@ -215,7 +214,6 @@ DEVICE_GET_INFO( f3853 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(f3853_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(f3853); break; diff --git a/src/emu/machine/f3853.h b/src/emu/machine/f3853.h index fcbc2ef89e6..4f4b93233ac 100644 --- a/src/emu/machine/f3853.h +++ b/src/emu/machine/f3853.h @@ -10,7 +10,9 @@ #ifndef __F3853_H__ #define __F3853_H__ -#define F3853 DEVICE_GET_INFO_NAME(f3853) +#include "devlegcy.h" + +DECLARE_LEGACY_DEVICE(F3853, f3853); /*************************************************************************** TYPE DEFINITIONS @@ -32,9 +34,6 @@ struct _f3853_config MDRV_DEVICE_CONFIG(_intrf) -/* device interface */ -DEVICE_GET_INFO(f3853); - READ8_DEVICE_HANDLER(f3853_r); WRITE8_DEVICE_HANDLER(f3853_w); diff --git a/src/emu/machine/generic.c b/src/emu/machine/generic.c index 74d3b673d1f..806a2b29264 100644 --- a/src/emu/machine/generic.c +++ b/src/emu/machine/generic.c @@ -327,30 +327,38 @@ mame_file *nvram_fopen(running_machine *machine, UINT32 openflags) void nvram_load(running_machine *machine) { - mame_file *nvram_file = NULL; - running_device *device; + // only need to do something if we have an NVRAM device or an nvram_handler + device_nvram_interface *nvram = NULL; + if (!machine->devicelist.first(nvram) && machine->config->nvram_handler == NULL) + return; - /* read data from general NVRAM handler first */ - if (machine->config->nvram_handler != NULL) + // open the file; if it exists, call everyone to read from it + mame_file *nvram_file = nvram_fopen(machine, OPEN_FLAG_READ); + if (nvram_file != NULL) { - nvram_file = nvram_fopen(machine, OPEN_FLAG_READ); - (*machine->config->nvram_handler)(machine, nvram_file, 0); - } + // read data from general NVRAM handler first + if (machine->config->nvram_handler != NULL) + (*machine->config->nvram_handler)(machine, nvram_file, FALSE); - /* find all devices with NVRAM handlers, and read from them next */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) - { - device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM); - if (nvram != NULL) - { - if (nvram_file == NULL) - nvram_file = nvram_fopen(machine, OPEN_FLAG_READ); - (*nvram)(device, nvram_file, 0); - } - } + // find all devices with NVRAM handlers, and read from them next + for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram)) + nvram->nvram_load(*nvram_file); - if (nvram_file != NULL) + // close the file mame_fclose(nvram_file); + } + + // otherwise, tell everyone to initialize their NVRAM areas + else + { + // initialize via the general NVRAM handler first + if (machine->config->nvram_handler != NULL) + (*machine->config->nvram_handler)(machine, NULL, FALSE); + + // find all devices with NVRAM handlers, and read from them next + for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram)) + nvram->nvram_reset(); + } } @@ -360,30 +368,26 @@ void nvram_load(running_machine *machine) void nvram_save(running_machine *machine) { - mame_file *nvram_file = NULL; - running_device *device; + // only need to do something if we have an NVRAM device or an nvram_handler + device_nvram_interface *nvram = NULL; + if (!machine->devicelist.first(nvram) && machine->config->nvram_handler == NULL) + return; - /* write data from general NVRAM handler first */ - if (machine->config->nvram_handler != NULL) + // open the file; if it exists, call everyone to read from it + mame_file *nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); + if (nvram_file != NULL) { - nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - (*machine->config->nvram_handler)(machine, nvram_file, 1); - } + // write data via general NVRAM handler first + if (machine->config->nvram_handler != NULL) + (*machine->config->nvram_handler)(machine, nvram_file, TRUE); - /* find all devices with NVRAM handlers, and write them next */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) - { - device_nvram_func nvram = (device_nvram_func)device->get_config_fct(DEVINFO_FCT_NVRAM); - if (nvram != NULL) - { - if (nvram_file == NULL) - nvram_file = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - (*nvram)(device, nvram_file, 1); - } - } + // find all devices with NVRAM handlers, and tell them to write next + for (bool gotone = (nvram != NULL); gotone; gotone = nvram->next(nvram)) + nvram->nvram_save(*nvram_file); - if (nvram_file != NULL) + // close the file mame_fclose(nvram_file); + } } @@ -633,14 +637,15 @@ static void interrupt_reset(running_machine *machine) static TIMER_CALLBACK( clear_all_lines ) { - running_device *device = (running_device *)ptr; - int inputcount = cpu_get_input_lines(device); - int line; + cpu_device *cpudevice = reinterpret_cast(ptr); + + // clear NMI + cpudevice->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); - /* clear NMI and all inputs */ - cpu_set_input_line(device, INPUT_LINE_NMI, CLEAR_LINE); - for (line = 0; line < inputcount; line++) - cpu_set_input_line(device, line, CLEAR_LINE); + // clear all other inputs + int inputcount = cpudevice->input_lines(); + for (int line = 0; line < inputcount; line++) + cpudevice->set_input_line(line, CLEAR_LINE); } @@ -664,11 +669,12 @@ static TIMER_CALLBACK( irq_pulse_clear ) void generic_pulse_irq_line(running_device *device, int irqline) { - int multiplier = cpu_get_clock_multiplier(device); - int clocks = (cpu_get_min_cycles(device) * cpu_get_clock_divider(device) + multiplier - 1) / multiplier; assert(irqline != INPUT_LINE_NMI && irqline != INPUT_LINE_RESET); cpu_set_input_line(device, irqline, ASSERT_LINE); - timer_set(device->machine, cpu_clocks_to_attotime(device, MAX(clocks, 1)), (void *)device, irqline, irq_pulse_clear); + + cpu_device *cpudevice = downcast(device); + int clocks = cpudevice->cycles_to_clocks(cpudevice->min_cycles()); + timer_set(device->machine, cpudevice->clocks_to_attotime(MAX(clocks, 1)), (void *)device, irqline, irq_pulse_clear); } @@ -693,10 +699,10 @@ void generic_pulse_irq_line_and_vector(running_device *device, int irqline, int void cpu_interrupt_enable(running_device *device, int enabled) { + cpu_device *cpudevice = downcast(device); + generic_machine_private *state = device->machine->generic_machine_data; int cpunum = cpu_get_index(device); - - assert_always(device != NULL, "cpu_interrupt_enable() called for invalid cpu!"); assert_always(cpunum < ARRAY_LENGTH(state->interrupt_enable), "cpu_interrupt_enable() called for a CPU > position 7!"); /* set the new state */ @@ -705,7 +711,7 @@ void cpu_interrupt_enable(running_device *device, int enabled) /* make sure there are no queued interrupts */ if (enabled == 0) - timer_call_after_resynch(device->machine, (void *)device, 0, clear_all_lines); + timer_call_after_resynch(device->machine, (void *)cpudevice, 0, clear_all_lines); } diff --git a/src/emu/machine/i2cmemdev.c b/src/emu/machine/i2cmemdev.c index ded90ea6e07..34ba2d1ae55 100644 --- a/src/emu/machine/i2cmemdev.c +++ b/src/emu/machine/i2cmemdev.c @@ -78,10 +78,9 @@ struct _i2cmem_state INLINE i2cmem_state *get_safe_token( running_device *device ) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == I2CMEM ); + assert( device->type() == I2CMEM ); - return (i2cmem_state *)device->token; + return (i2cmem_state *)downcast(device)->token(); } static int select_device( i2cmem_state *c ) @@ -371,11 +370,11 @@ static DEVICE_START( i2cmem ) /* validate some basic stuff */ assert( device != NULL ); - assert( device->baseconfig().inline_config != NULL ); + assert( downcast(device->baseconfig()).inline_config() != NULL ); assert( device->machine != NULL ); assert( device->machine->config != NULL ); - config = (const i2cmem_config *)device->baseconfig().inline_config; + config = (const i2cmem_config *)downcast(device->baseconfig()).inline_config(); c->scl = 0; c->sdaw = 0; @@ -431,7 +430,7 @@ static DEVICE_RESET( i2cmem ) static DEVICE_NVRAM( i2cmem ) { - const i2cmem_config *config = (const i2cmem_config *)device->baseconfig().inline_config; + const i2cmem_config *config = (const i2cmem_config *)downcast(device->baseconfig()).inline_config(); i2cmem_state *c = get_safe_token( device ); if( read_or_write ) @@ -460,7 +459,6 @@ DEVICE_GET_INFO( i2cmem ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof( i2cmem_state ); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof( i2cmem_config ); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( i2cmem ); break; diff --git a/src/emu/machine/i2cmemdev.h b/src/emu/machine/i2cmemdev.h index 6384854edbd..090b2e0a848 100644 --- a/src/emu/machine/i2cmemdev.h +++ b/src/emu/machine/i2cmemdev.h @@ -6,6 +6,8 @@ #if !defined( I2CMEMDEV_H ) #define I2CMEMDEV_H ( 1 ) +#include "devlegcy.h" + #define I2CMEM_E0 ( 1 ) #define I2CMEM_E1 ( 2 ) #define I2CMEM_E2 ( 3 ) @@ -25,8 +27,7 @@ struct _i2cmem_config const char *data; }; -#define I2CMEM DEVICE_GET_INFO_NAME(i2cmem) -DEVICE_GET_INFO(i2cmem); +DECLARE_LEGACY_NVRAM_DEVICE(I2CMEM, i2cmem); #define MDRV_I2CMEM_ADD(_tag, _slave_address, _page_size, _data_size, _data) \ MDRV_DEVICE_ADD(_tag, I2CMEM, 0) \ diff --git a/src/emu/machine/i8243.c b/src/emu/machine/i8243.c index 83b2281c848..7103977ddce 100644 --- a/src/emu/machine/i8243.c +++ b/src/emu/machine/i8243.c @@ -35,16 +35,16 @@ struct _i8243_state INLINE i8243_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->type == I8243); - return (i8243_state *)device->token; + assert(device->type() == I8243); + return (i8243_state *)downcast(device)->token(); } INLINE i8243_config *get_safe_config(running_device *device) { assert(device != NULL); - assert(device->type == I8243); - return (i8243_config *)device->baseconfig().inline_config; + assert(device->type() == I8243); + return (i8243_config *)downcast(device->baseconfig()).inline_config(); } @@ -171,7 +171,6 @@ DEVICE_GET_INFO( i8243 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8243_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(i8243_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8243); break; diff --git a/src/emu/machine/i8243.h b/src/emu/machine/i8243.h index ff5fea5ebac..587fbbbd125 100644 --- a/src/emu/machine/i8243.h +++ b/src/emu/machine/i8243.h @@ -13,6 +13,7 @@ #ifndef __I8243_H__ #define __I8243_H__ +#include "devlegcy.h" #include "cpu/mcs48/mcs48.h" @@ -33,7 +34,7 @@ struct _i8243_config MACROS ***************************************************************************/ -#define I8243 DEVICE_GET_INFO_NAME( i8243 ) +DECLARE_LEGACY_DEVICE(I8243, i8243); #define MDRV_I8243_ADD(_tag, _read, _write) \ @@ -47,8 +48,6 @@ struct _i8243_config FUNCTION PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( i8243 ); - READ8_DEVICE_HANDLER( i8243_p2_r ); WRITE8_DEVICE_HANDLER( i8243_p2_w ); diff --git a/src/emu/machine/i8255a.c b/src/emu/machine/i8255a.c index 3356a857369..2c7285613ce 100644 --- a/src/emu/machine/i8255a.c +++ b/src/emu/machine/i8255a.c @@ -80,16 +80,15 @@ struct _i8255a_t INLINE i8255a_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - return (i8255a_t *)device->token; + return (i8255a_t *)downcast(device)->token(); } INLINE const i8255a_interface *get_interface(running_device *device) { assert(device != NULL); - assert((device->type == I8255A)); - return (const i8255a_interface *) device->baseconfig().static_config; + assert((device->type() == I8255A)); + return (const i8255a_interface *) device->baseconfig().static_config(); } INLINE int group_mode(i8255a_t *i8255a, int group) @@ -891,7 +890,6 @@ DEVICE_GET_INFO( i8255a ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(i8255a_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(i8255a); break; diff --git a/src/emu/machine/i8255a.h b/src/emu/machine/i8255a.h index 84c9b84a9ba..f74cd509b72 100644 --- a/src/emu/machine/i8255a.h +++ b/src/emu/machine/i8255a.h @@ -33,12 +33,13 @@ #ifndef __I8255A__ #define __I8255A__ +#include "devlegcy.h" /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define I8255A DEVICE_GET_INFO_NAME(i8255a) +DECLARE_LEGACY_DEVICE(I8255A, i8255a); #define MDRV_I8255A_ADD(_tag, _intrf) \ MDRV_DEVICE_ADD(_tag, I8255A, 0) \ @@ -67,9 +68,6 @@ struct _i8255a_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( i8255a ); - /* register access */ READ8_DEVICE_HANDLER( i8255a_r ); WRITE8_DEVICE_HANDLER( i8255a_w ); diff --git a/src/emu/machine/idectrl.c b/src/emu/machine/idectrl.c index ddc3406da94..d2927eb8107 100644 --- a/src/emu/machine/idectrl.c +++ b/src/emu/machine/idectrl.c @@ -198,16 +198,15 @@ static void ide_controller_write(running_device *device, int bank, offs_t offset INLINE ide_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == IDE_CONTROLLER); + assert(device->type() == IDE_CONTROLLER); - return (ide_state *)device->token; + return (ide_state *)downcast(device)->token(); } INLINE void signal_interrupt(ide_state *ide) { - const ide_config *config = (const ide_config *)ide->device->baseconfig().inline_config; + const ide_config *config = (const ide_config *)downcast(ide->device->baseconfig()).inline_config(); LOG(("IDE interrupt assert\n")); @@ -221,7 +220,7 @@ INLINE void signal_interrupt(ide_state *ide) INLINE void clear_interrupt(ide_state *ide) { - const ide_config *config = (const ide_config *)ide->device->baseconfig().inline_config; + const ide_config *config = (const ide_config *)downcast(ide->device->baseconfig()).inline_config(); LOG(("IDE interrupt clear\n")); @@ -1794,8 +1793,8 @@ static DEVICE_START( ide_controller ) /* validate some basic stuff */ assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() != NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -1803,7 +1802,7 @@ static DEVICE_START( ide_controller ) ide->device = device; /* set MAME harddisk handle */ - config = (const ide_config *)device->baseconfig().inline_config; + config = (const ide_config *)downcast(device->baseconfig()).inline_config(); ide->handle = get_disk_handle(device->machine, (config->master != NULL) ? config->master : device->tag()); ide->disk = hard_disk_open(ide->handle); assert_always(config->slave == NULL, "IDE controller does not yet support slave drives\n"); @@ -1811,7 +1810,7 @@ static DEVICE_START( ide_controller ) /* find the bus master space */ if (config->bmcpu != NULL) { - ide->dma_space = device->machine->device(config->bmcpu)->space(config->bmspace); + ide->dma_space = device_memory(device->machine->device(config->bmcpu))->space(config->bmspace); assert_always(ide->dma_space != NULL, "IDE controller bus master space not found!"); ide->dma_address_xor = (ide->dma_space->endianness == ENDIANNESS_LITTLE) ? 0 : 3; } @@ -1959,7 +1958,6 @@ DEVICE_GET_INFO( ide_controller ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ide_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(ide_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ide_controller); break; diff --git a/src/emu/machine/idectrl.h b/src/emu/machine/idectrl.h index efe778cdb39..af287b6aae0 100644 --- a/src/emu/machine/idectrl.h +++ b/src/emu/machine/idectrl.h @@ -14,6 +14,8 @@ #ifndef __IDECTRL_H__ #define __IDECTRL_H__ +#include "devlegcy.h" + #include "harddisk.h" @@ -81,9 +83,7 @@ WRITE16_DEVICE_HANDLER( ide_controller16_w ); /* ----- device interface ----- */ -/* device get info callback */ -#define IDE_CONTROLLER DEVICE_GET_INFO_NAME(ide_controller) -DEVICE_GET_INFO( ide_controller ); +DECLARE_LEGACY_DEVICE(IDE_CONTROLLER, ide_controller); #endif /* __IDECTRL_H__ */ diff --git a/src/emu/machine/ins8154.c b/src/emu/machine/ins8154.c index 13bcdb73b92..ba5173edcb6 100644 --- a/src/emu/machine/ins8154.c +++ b/src/emu/machine/ins8154.c @@ -61,10 +61,9 @@ struct _ins8154_state INLINE ins8154_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == INS8154); + assert(device->type() == INS8154); - return (ins8154_state *)device->token; + return (ins8154_state *)downcast(device)->token(); } @@ -219,7 +218,7 @@ WRITE8_DEVICE_HANDLER( ins8154_w ) static DEVICE_START( ins8154 ) { ins8154_state *ins8154 = get_safe_token(device); - const ins8154_interface *intf = (const ins8154_interface *)device->baseconfig().static_config; + const ins8154_interface *intf = (const ins8154_interface *)device->baseconfig().static_config(); /* validate some basic stuff */ assert(intf != NULL); diff --git a/src/emu/machine/ins8154.h b/src/emu/machine/ins8154.h index 62c15b5527d..7448445b60f 100644 --- a/src/emu/machine/ins8154.h +++ b/src/emu/machine/ins8154.h @@ -31,6 +31,7 @@ #ifndef __INS8154_H__ #define __INS8154_H__ +#include "devlegcy.h" #include "devcb.h" @@ -48,13 +49,13 @@ struct _ins8154_interface devcb_write_line out_irq_func; }; +DECLARE_LEGACY_DEVICE(INS8154, ins8154); + /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( ins8154 ); - READ8_DEVICE_HANDLER( ins8154_r ); WRITE8_DEVICE_HANDLER( ins8154_w ); @@ -66,8 +67,6 @@ WRITE8_DEVICE_HANDLER( ins8154_portb_w ); DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define INS8154 DEVICE_GET_INFO_NAME(ins8154) - #define MDRV_INS8154_ADD(_tag, _intrf) \ MDRV_DEVICE_ADD(_tag, INS8154, 0) \ MDRV_DEVICE_CONFIG(_intrf) diff --git a/src/emu/machine/ins8250.c b/src/emu/machine/ins8250.c index 22e8fcb279b..568f3b7b9d4 100644 --- a/src/emu/machine/ins8250.c +++ b/src/emu/machine/ins8250.c @@ -142,14 +142,13 @@ typedef struct { INLINE ins8250_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( ( device->type == DEVICE_GET_INFO_NAME(ins8250) ) || - ( device->type == DEVICE_GET_INFO_NAME(ins8250a) ) || - ( device->type == DEVICE_GET_INFO_NAME(ns16450) ) || - ( device->type == DEVICE_GET_INFO_NAME(ns16550) ) || - ( device->type == DEVICE_GET_INFO_NAME(ns16550a) ) || - ( device->type == DEVICE_GET_INFO_NAME(pc16550d) ) ); - return ( ins8250_t *) device->token; + assert( ( device->type() == INS8250 ) || + ( device->type() == INS8250A ) || + ( device->type() == NS16450 ) || + ( device->type() == NS16550 ) || + ( device->type() == NS16550A ) || + ( device->type() == PC16550D ) ); + return (ins8250_t *)downcast(device)->token(); } @@ -545,7 +544,7 @@ static void common_start( running_device *device, int device_type ) { ins8250_t *ins8250 = get_safe_token(device); - ins8250->interface = (const ins8250_interface*)device->baseconfig().static_config; + ins8250->interface = (const ins8250_interface*)device->baseconfig().static_config(); ins8250->device_type = device_type; } @@ -611,7 +610,6 @@ DEVICE_GET_INFO( ins8250 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ins8250_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ins8250); break; diff --git a/src/emu/machine/ins8250.h b/src/emu/machine/ins8250.h index d5570ecd775..f440a78c821 100644 --- a/src/emu/machine/ins8250.h +++ b/src/emu/machine/ins8250.h @@ -7,12 +7,14 @@ #ifndef __INS8250_H_ #define __INS8250_H_ -#define INS8250 DEVICE_GET_INFO_NAME(ins8250) -#define INS8250A DEVICE_GET_INFO_NAME(ins8250a) -#define NS16450 DEVICE_GET_INFO_NAME(ns16450) -#define NS16550 DEVICE_GET_INFO_NAME(ns16550) -#define NS16550A DEVICE_GET_INFO_NAME(ns16550a) -#define PC16550D DEVICE_GET_INFO_NAME(pc16550d) +#include "devlegcy.h" + +DECLARE_LEGACY_DEVICE(INS8250, ins8250); +DECLARE_LEGACY_DEVICE(INS8250A, ins8250a); +DECLARE_LEGACY_DEVICE(NS16450, ns16450); +DECLARE_LEGACY_DEVICE(NS16550, ns16550); +DECLARE_LEGACY_DEVICE(NS16550A, ns16550a); +DECLARE_LEGACY_DEVICE(PC16550D, pc16550d); #define UART8250_HANDSHAKE_OUT_DTR 0x01 #define UART8250_HANDSHAKE_OUT_RTS 0x02 @@ -79,13 +81,5 @@ void ins8250_handshake_in(running_device *device, int new_msr); READ8_DEVICE_HANDLER( ins8250_r ); WRITE8_DEVICE_HANDLER( ins8250_w ); -/* device interface */ -DEVICE_GET_INFO( ins8250 ); -DEVICE_GET_INFO( ins8250a ); -DEVICE_GET_INFO( ns16450 ); -DEVICE_GET_INFO( ns16550 ); -DEVICE_GET_INFO( ns16550a ); -DEVICE_GET_INFO( pc16550d ); - #endif /* __INS8250_H_ */ diff --git a/src/emu/machine/k033906.c b/src/emu/machine/k033906.c index dd0d34bcf7b..5b4b4c631c7 100644 --- a/src/emu/machine/k033906.c +++ b/src/emu/machine/k033906.c @@ -30,17 +30,16 @@ struct _k033906_state INLINE k033906_state *k033906_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K033906); + assert(device->type() == K033906); - return (k033906_state *)device->token; + return (k033906_state *)downcast(device)->token(); } INLINE const k033906_interface *k033906_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K033906)); - return (const k033906_interface *) device->baseconfig().static_config; + assert((device->type() == K033906)); + return (const k033906_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -167,5 +166,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START #define DEVTEMPLATE_NAME "Konami 033906" #define DEVTEMPLATE_FAMILY "Konami PCI Bridge 033906" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/k033906.h b/src/emu/machine/k033906.h index 4faba5fda97..42fc29afa61 100644 --- a/src/emu/machine/k033906.h +++ b/src/emu/machine/k033906.h @@ -7,6 +7,8 @@ #ifndef __K033906_H__ #define __K033906_H__ +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -18,19 +20,13 @@ struct _k033906_interface const char *voodoo; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( k033906 ); +DECLARE_LEGACY_DEVICE(K033906, k033906); /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define K033906 DEVICE_GET_INFO_NAME( k033906 ) - #define MDRV_K033906_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, K033906, 0) \ MDRV_DEVICE_CONFIG(_config) diff --git a/src/emu/machine/k056230.c b/src/emu/machine/k056230.c index 9466a5bd867..3d254225346 100644 --- a/src/emu/machine/k056230.c +++ b/src/emu/machine/k056230.c @@ -27,17 +27,16 @@ struct _k056230_state INLINE k056230_state *k056230_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K056230); + assert(device->type() == K056230); - return (k056230_state *)device->token; + return (k056230_state *)downcast(device)->token(); } INLINE const k056230_interface *k056230_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K056230)); - return (const k056230_interface *) device->baseconfig().static_config; + assert((device->type() == K056230)); + return (const k056230_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -141,5 +140,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START #define DEVTEMPLATE_NAME "Konami 056230" #define DEVTEMPLATE_FAMILY "Konami Network Board 056230" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/k056230.h b/src/emu/machine/k056230.h index 4cf7389d9ac..092b517c239 100644 --- a/src/emu/machine/k056230.h +++ b/src/emu/machine/k056230.h @@ -7,6 +7,8 @@ #ifndef __K056230_H__ #define __K056230_H__ +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -19,19 +21,13 @@ struct _k056230_interface int is_thunderh; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( k056230 ); +DECLARE_LEGACY_DEVICE(K056230, k056230); /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define K056230 DEVICE_GET_INFO_NAME( k056230 ) - #define MDRV_K056230_ADD(_tag, _config) \ MDRV_DEVICE_ADD(_tag, K056230, 0) \ MDRV_DEVICE_CONFIG(_config) diff --git a/src/emu/machine/laserdsc.h b/src/emu/machine/laserdsc.h index 3fbc10fbaeb..d5631fbf708 100644 --- a/src/emu/machine/laserdsc.h +++ b/src/emu/machine/laserdsc.h @@ -213,12 +213,10 @@ void laserdisc_set_config(running_device *device, const laserdisc_config *config /* ----- device interface ----- */ /* device get info callback */ -#define LASERDISC DEVICE_GET_INFO_NAME(laserdisc) -DEVICE_GET_INFO( laserdisc ); +DECLARE_LEGACY_DEVICE(LASERDISC, laserdisc); /* audio get info callback */ -#define SOUND_LASERDISC DEVICE_GET_INFO_NAME(laserdisc_sound) -DEVICE_GET_INFO( laserdisc_sound ); +DECLARE_LEGACY_SOUND_DEVICE(LASERDISC, laserdisc_sound); /* type setter */ int laserdisc_get_type(running_device *device); diff --git a/src/emu/machine/latch8.c b/src/emu/machine/latch8.c index 78e650e8dfd..a2b66670bf8 100644 --- a/src/emu/machine/latch8.c +++ b/src/emu/machine/latch8.c @@ -26,9 +26,8 @@ struct _latch8_t INLINE latch8_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == LATCH8 ); - return ( latch8_t * ) device->token; + assert( device->type() == LATCH8 ); + return ( latch8_t * ) downcast(device)->token(); } static void update(running_device *device, UINT8 new_val, UINT8 mask) @@ -188,7 +187,7 @@ static DEVICE_START( latch8 ) int i; /* validate arguments */ - latch8->intf = (latch8_config *)device->baseconfig().inline_config; + latch8->intf = (latch8_config *)downcast(device->baseconfig()).inline_config(); latch8->value = 0x0; @@ -241,7 +240,6 @@ DEVICE_GET_INFO( latch8 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(latch8_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(latch8_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(latch8);break; diff --git a/src/emu/machine/latch8.h b/src/emu/machine/latch8.h index 7db1e67b18c..b4a376b1016 100644 --- a/src/emu/machine/latch8.h +++ b/src/emu/machine/latch8.h @@ -15,7 +15,9 @@ #ifndef __LATCH8_H_ #define __LATCH8_H_ -#define LATCH8 DEVICE_GET_INFO_NAME(latch8) +#include "devlegcy.h" + +DECLARE_LEGACY_DEVICE(LATCH8, latch8); /*************************************************************************** TYPE DEFINITIONS @@ -93,9 +95,6 @@ struct _latch8_config #define AM_LATCH8_READWRITE(_tag) \ AM_DEVREADWRITE(_tag, latch8_r, latch8_w) -/* device interface */ -DEVICE_GET_INFO( latch8 ); - /* write & read full byte */ READ8_DEVICE_HANDLER( latch8_r ); diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index 50d4798f025..365c2eab5f8 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -181,10 +181,9 @@ static const ldplayer_interface *const player_interfaces[] = INLINE laserdisc_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == LASERDISC); + assert(device->type() == LASERDISC); - return (laserdisc_state *)device->token; + return (laserdisc_state *)downcast(device)->token(); } @@ -198,7 +197,7 @@ INLINE void update_audio(laserdisc_state *ld) ldcore_data *ldcore = ld->core; if (ldcore->audiocustom != NULL) { - sound_token *token = (sound_token *)ldcore->audiocustom->token; + sound_token *token = (sound_token *)downcast(ldcore->audiocustom)->token(); stream_update(token->stream); } } @@ -289,12 +288,12 @@ static void update_slider_pos(ldcore_data *ldcore, attotime curtime) change of the VBLANK signal -------------------------------------------------*/ -static void vblank_state_changed(running_device *screen, void *param, int vblank_state) +static void vblank_state_changed(screen_device &screen, void *param, bool vblank_state) { running_device *device = (running_device *)param; laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; - attotime curtime = timer_get_time(screen->machine); + attotime curtime = timer_get_time(screen.machine); /* update current track based on slider speed */ update_slider_pos(ldcore, curtime); @@ -307,7 +306,7 @@ static void vblank_state_changed(running_device *screen, void *param, int vblank (*ldcore->intf.vsync)(ld, &ldcore->metadata[ldcore->fieldnum], ldcore->fieldnum, curtime); /* set a timer to begin fetching the next frame just before the VBI data would be fetched */ - timer_set(screen->machine, video_screen_get_time_until_pos(screen, 16*2, 0), ld, 0, perform_player_update); + timer_set(screen.machine, screen.time_until_pos(16*2), ld, 0, perform_player_update); } } @@ -554,7 +553,7 @@ void ldcore_set_video_squelch(laserdisc_state *ld, UINT8 squelch) void ldcore_set_slider_speed(laserdisc_state *ld, INT32 tracks_per_vsync) { ldcore_data *ldcore = ld->core; - attotime vsyncperiod = video_screen_get_frame_period(ld->screen); + attotime vsyncperiod = ld->screen->frame_period(); update_slider_pos(ldcore, timer_get_time(ld->device->machine)); @@ -965,7 +964,7 @@ static void process_track_data(running_device *device) static DEVICE_START( laserdisc_sound ) { - sound_token *token = (sound_token *)device->token; + sound_token *token = (sound_token *)downcast(device)->token(); token->stream = stream_create(device, 0, 2, 48000, token, custom_stream_callback); token->ld = NULL; } @@ -1128,7 +1127,7 @@ static void configuration_save(running_machine *machine, int config_type, xml_da /* iterate over disc devices */ for (device = machine->devicelist.first(LASERDISC); device != NULL; device = device->typenext()) { - laserdisc_config *origconfig = (laserdisc_config *)device->baseconfig().inline_config; + laserdisc_config *origconfig = (laserdisc_config *)downcast(device->baseconfig()).inline_config(); laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; xml_data_node *overnode; @@ -1219,8 +1218,8 @@ VIDEO_UPDATE( laserdisc ) running_device *laserdisc = screen->machine->devicelist.first(LASERDISC); if (laserdisc != NULL) { - const rectangle *visarea = video_screen_get_visible_area(screen); - laserdisc_state *ld = (laserdisc_state *)laserdisc->token; + const rectangle &visarea = screen->visible_area(); + laserdisc_state *ld = (laserdisc_state *)downcast(laserdisc)->token(); ldcore_data *ldcore = ld->core; bitmap_t *overbitmap = ldcore->overbitmap[ldcore->overindex]; bitmap_t *vidbitmap = NULL; @@ -1234,14 +1233,14 @@ VIDEO_UPDATE( laserdisc ) clip.min_x = ldcore->config.overclip.min_x; clip.max_x = ldcore->config.overclip.max_x; clip.min_y = cliprect->min_y * overbitmap->height / bitmap->height; - if (cliprect->min_y == visarea->min_y) + if (cliprect->min_y == visarea.min_y) clip.min_y = MIN(clip.min_y, ldcore->config.overclip.min_y); clip.max_y = (cliprect->max_y + 1) * overbitmap->height / bitmap->height - 1; (*ldcore->config.overupdate)(screen, overbitmap, &clip); } /* if this is the last update, do the rendering */ - if (cliprect->max_y == visarea->max_y) + if (cliprect->max_y == visarea.max_y) { /* update the texture with the overlay contents */ if (overbitmap != NULL) @@ -1324,7 +1323,7 @@ void laserdisc_set_config(running_device *device, const laserdisc_config *config static void init_disc(running_device *device) { - const laserdisc_config *config = (const laserdisc_config *)device->baseconfig().inline_config; + const laserdisc_config *config = (const laserdisc_config *)downcast(device->baseconfig()).inline_config(); laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore = ld->core; chd_error err; @@ -1395,7 +1394,7 @@ static void init_video(running_device *device) int index; /* register for VBLANK callbacks */ - video_screen_register_vblank_callback(ld->screen, vblank_state_changed, (void *)device); + ld->screen->register_vblank_callback(vblank_state_changed, (void *)device); /* allocate video frames */ for (index = 0; index < ARRAY_LENGTH(ldcore->frame); index++) @@ -1475,16 +1474,16 @@ static void init_audio(running_device *device) static DEVICE_START( laserdisc ) { - const laserdisc_config *config = (const laserdisc_config *)device->baseconfig().inline_config; + const laserdisc_config *config = (const laserdisc_config *)downcast(device->baseconfig()).inline_config(); laserdisc_state *ld = get_safe_token(device); ldcore_data *ldcore; int statesize; int index; /* ensure that our screen is started first */ - ld->screen = device->machine->device(config->screen); + ld->screen = downcast(device->machine->device(config->screen)); assert(ld->screen != NULL); - if (!ld->screen->started) + if (!ld->screen->started()) throw device_missing_dependencies(); /* save a copy of the device pointer */ @@ -1568,7 +1567,7 @@ static DEVICE_RESET( laserdisc ) /* attempt to wire up the audio */ if (ldcore->audiocustom != NULL) { - sound_token *token = (sound_token *)ldcore->audiocustom->token; + sound_token *token = (sound_token *)downcast(ldcore->audiocustom)->token(); token->ld = ld; stream_set_sample_rate(token->stream, ldcore->samplerate); } @@ -1625,7 +1624,7 @@ static const ldplayer_interface *get_interface(const device_config *devconfig) if (devconfig == NULL) return NULL; - const laserdisc_config *config = (const laserdisc_config *)devconfig->inline_config; + const laserdisc_config *config = (const laserdisc_config *)downcast(devconfig)->inline_config(); if (config == NULL) return NULL; @@ -1645,7 +1644,6 @@ DEVICE_GET_INFO( laserdisc ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(laserdisc_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(laserdisc_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers --- */ case DEVINFO_PTR_ROM_REGION: intf = get_interface(device); info->romregion = (intf != NULL) ? intf->romregion : NULL; break; diff --git a/src/emu/machine/ldcore.h b/src/emu/machine/ldcore.h index ae53797da90..12bbc6cb589 100644 --- a/src/emu/machine/ldcore.h +++ b/src/emu/machine/ldcore.h @@ -121,8 +121,8 @@ struct _ldplayer_state typedef struct _laserdisc_state laserdisc_state; struct _laserdisc_state { - running_device * device; /* pointer to owning device */ - running_device * screen; /* pointer to the screen device */ + running_device * device; /* pointer to owning device */ + screen_device * screen; /* pointer to the screen device */ ldcore_data * core; /* private core data */ ldplayer_data * player; /* private player data */ diff --git a/src/emu/machine/ldpr8210.c b/src/emu/machine/ldpr8210.c index dbcfb7b35b4..35228900e34 100644 --- a/src/emu/machine/ldpr8210.c +++ b/src/emu/machine/ldpr8210.c @@ -373,17 +373,17 @@ static void pr8210_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int field if (LOG_VBLANK_VBI) { if ((vbi->line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) - printf("%3d:VSYNC(%d,%05d)\n", video_screen_get_vpos(ld->screen), fieldnum, VBI_CAV_PICTURE(vbi->line1718)); + printf("%3d:VSYNC(%d,%05d)\n", ld->screen->vpos(), fieldnum, VBI_CAV_PICTURE(vbi->line1718)); else - printf("%3d:VSYNC(%d)\n", video_screen_get_vpos(ld->screen), fieldnum); + printf("%3d:VSYNC(%d)\n", ld->screen->vpos(), fieldnum); } /* signal VSYNC and set a timer to turn it off */ player->vsync = TRUE; - timer_set(ld->device->machine, attotime_mul(video_screen_get_scan_period(ld->screen), 4), ld, 0, vsync_off); + timer_set(ld->device->machine, attotime_mul(ld->screen->scan_period(), 4), ld, 0, vsync_off); /* also set a timer to fetch the VBI data when it is ready */ - timer_set(ld->device->machine, video_screen_get_time_until_pos(ld->screen, 19*2, 0), ld, 0, vbi_data_fetch); + timer_set(ld->device->machine, ld->screen->time_until_pos(19*2), ld, 0, vbi_data_fetch); } @@ -399,7 +399,7 @@ static INT32 pr8210_update(laserdisc_state *ld, const vbi_metadata *vbi, int fie /* logging */ if (LOG_VBLANK_VBI) - printf("%3d:Update(%d)\n", video_screen_get_vpos(ld->screen), fieldnum); + printf("%3d:Update(%d)\n", ld->screen->vpos(), fieldnum); /* if the spindle is on, we advance by 1 track after completing field #1 */ return (spdl_on) ? fieldnum : 0; @@ -544,9 +544,9 @@ static TIMER_CALLBACK( vbi_data_fetch ) if (LOG_VBLANK_VBI) { if ((line1718 & VBI_MASK_CAV_PICTURE) == VBI_CODE_CAV_PICTURE) - printf("%3d:VBI(%05d)\n", video_screen_get_vpos(ld->screen), VBI_CAV_PICTURE(line1718)); + printf("%3d:VBI(%05d)\n", ld->screen->vpos(), VBI_CAV_PICTURE(line1718)); else - printf("%3d:VBI()\n", video_screen_get_vpos(ld->screen)); + printf("%3d:VBI()\n", ld->screen->vpos()); } /* update PIA registers based on vbi code */ @@ -587,7 +587,7 @@ static TIMER_CALLBACK( vbi_data_fetch ) static READ8_HANDLER( pr8210_pia_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 result = 0xff; @@ -612,14 +612,14 @@ static READ8_HANDLER( pr8210_pia_r ) /* (C0) VBI decoding state 1 */ case 0xc0: if (LOG_VBLANK_VBI) - printf("%3d:PIA(C0)\n", video_screen_get_vpos(ld->screen)); + printf("%3d:PIA(C0)\n", ld->screen->vpos()); result = player->pia.vbi1; break; /* (E0) VBI decoding state 2 */ case 0xe0: if (LOG_VBLANK_VBI) - printf("%3d:PIA(E0)\n", video_screen_get_vpos(ld->screen)); + printf("%3d:PIA(E0)\n", ld->screen->vpos()); result = player->pia.vbi2; break; @@ -638,7 +638,7 @@ static READ8_HANDLER( pr8210_pia_r ) static WRITE8_HANDLER( pr8210_pia_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 value; @@ -722,7 +722,7 @@ static READ8_HANDLER( pr8210_bus_r ) $02 = (in) FG via op-amp (spindle motor stop detector) $01 = (in) SLOW TIMER OUT */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; slider_position sliderpos = ldcore_get_slider_position(ld); UINT8 focus_on = !(player->port1 & 0x08); @@ -770,7 +770,7 @@ static WRITE8_HANDLER( pr8210_port1_w ) $02 = (out) SCAN A (/SCAN) $01 = (out) JUMP TRG (jump back trigger, clock on high->low) */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->port1; int direction; @@ -788,11 +788,11 @@ static WRITE8_HANDLER( pr8210_port1_w ) if (player->simutrek.cpu == NULL || !player->simutrek.controlthis) { if (LOG_SIMUTREK) - printf("%3d:JUMP TRG\n", video_screen_get_vpos(ld->screen)); + printf("%3d:JUMP TRG\n", ld->screen->vpos()); ldcore_advance_slider(ld, direction); } else if (LOG_SIMUTREK) - printf("%3d:Skipped JUMP TRG\n", video_screen_get_vpos(ld->screen)); + printf("%3d:Skipped JUMP TRG\n", ld->screen->vpos()); } /* bit 1 low enables scanning */ @@ -832,7 +832,7 @@ static WRITE8_HANDLER( pr8210_port2_w ) $02 = (out) ??? $01 = (out) LASER ON */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->port2; @@ -860,7 +860,7 @@ static WRITE8_HANDLER( pr8210_port2_w ) static READ8_HANDLER( pr8210_t0_r ) { /* returns VSYNC state */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); return !ld->player->vsync; } @@ -1098,7 +1098,7 @@ static TIMER_CALLBACK( irq_off ) ldplayer_data *player = ld->player; cpu_set_input_line(player->simutrek.cpu, MCS48_INPUT_IRQ, CLEAR_LINE); if (LOG_SIMUTREK) - printf("%3d:**** Simutrek IRQ clear\n", video_screen_get_vpos(ld->screen)); + printf("%3d:**** Simutrek IRQ clear\n", ld->screen->vpos()); } static void simutrek_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime) @@ -1112,15 +1112,15 @@ static void simutrek_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fie } if (LOG_SIMUTREK) - printf("%3d:VSYNC(%d)\n", video_screen_get_vpos(ld->screen), fieldnum); + printf("%3d:VSYNC(%d)\n", ld->screen->vpos(), fieldnum); pr8210_vsync(ld, vbi, fieldnum, curtime); if (player->simutrek.data_ready) { if (LOG_SIMUTREK) - printf("%3d:VSYNC IRQ\n", video_screen_get_vpos(ld->screen)); + printf("%3d:VSYNC IRQ\n", ld->screen->vpos()); cpu_set_input_line(player->simutrek.cpu, MCS48_INPUT_IRQ, ASSERT_LINE); - timer_set(ld->device->machine, video_screen_get_scan_period(ld->screen), ld, 0, irq_off); + timer_set(ld->device->machine, ld->screen->scan_period(), ld, 0, irq_off); } } @@ -1167,7 +1167,7 @@ static void simutrek_data_w(laserdisc_state *ld, UINT8 prev, UINT8 data) { timer_call_after_resynch(ld->device->machine, ld, data, simutrek_latched_data_w); if (LOG_SIMUTREK) - printf("%03d:**** Simutrek Command = %02X\n", video_screen_get_vpos(ld->screen), data); + printf("%03d:**** Simutrek Command = %02X\n", ld->screen->vpos(), data); } @@ -1194,7 +1194,7 @@ static TIMER_CALLBACK( simutrek_latched_data_w ) static READ8_HANDLER( simutrek_port2_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* bit $80 is the pr8210 video squelch */ @@ -1209,7 +1209,7 @@ static READ8_HANDLER( simutrek_port2_r ) static WRITE8_HANDLER( simutrek_port2_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->simutrek.port2; @@ -1226,13 +1226,13 @@ static WRITE8_HANDLER( simutrek_port2_w ) { int direction = (data & 0x08) ? 1 : -1; if (LOG_SIMUTREK) - printf("%3d:JUMP TRG (Simutrek PC=%03X)\n", video_screen_get_vpos(ld->screen), cpu_get_pc(space->cpu)); + printf("%3d:JUMP TRG (Simutrek PC=%03X)\n", ld->screen->vpos(), cpu_get_pc(space->cpu)); ldcore_advance_slider(ld, direction); } /* bit $04 controls who owns the JUMP TRG command */ if (LOG_SIMUTREK && ((data ^ prev) & 0x04)) - printf("%3d:Simutrek ownership line = %d (Simutrek PC=%03X)\n", video_screen_get_vpos(ld->screen), (data >> 2) & 1, cpu_get_pc(space->cpu)); + printf("%3d:Simutrek ownership line = %d (Simutrek PC=%03X)\n", ld->screen->vpos(), (data >> 2) & 1, cpu_get_pc(space->cpu)); player->simutrek.controlnext = (~data >> 2) & 1; /* bits $03 control something (status?) */ @@ -1248,7 +1248,7 @@ static WRITE8_HANDLER( simutrek_port2_w ) static READ8_HANDLER( simutrek_data_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* acknowledge the read and clear the data ready flag */ @@ -1265,6 +1265,6 @@ static READ8_HANDLER( simutrek_data_r ) static READ8_HANDLER( simutrek_t0_r ) { /* return 1 if data is waiting from main CPU */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); return ld->player->simutrek.data_ready; } diff --git a/src/emu/machine/ldv1000.c b/src/emu/machine/ldv1000.c index a785a1dd6c1..cc8eae2ce51 100644 --- a/src/emu/machine/ldv1000.c +++ b/src/emu/machine/ldv1000.c @@ -57,7 +57,7 @@ struct _ldplayer_data /* low-level emulation data */ running_device *cpu; /* CPU index of the Z80 */ running_device *ctc; /* CTC device */ - running_device *multitimer; /* multi-jump timer device */ + timer_device * multitimer; /* multi-jump timer device */ /* communication status */ UINT8 command; /* command byte to the player */ @@ -159,7 +159,7 @@ static Z80CTC_INTERFACE( ctcintf ) }; -static const z80_daisy_chain daisy_chain[] = +static const z80_daisy_config daisy_chain[] = { { "ldvctc" }, { NULL } @@ -236,8 +236,8 @@ static void ldv1000_init(laserdisc_state *ld) /* find our devices */ player->cpu = ld->device->subdevice("ldv1000"); player->ctc = ld->device->subdevice("ldvctc"); - player->multitimer = ld->device->subdevice("multitimer"); - timer_device_set_ptr(player->multitimer, ld); + player->multitimer = downcast(ld->device->subdevice("multitimer")); + player->multitimer->set_ptr(ld); } @@ -257,10 +257,10 @@ static void ldv1000_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fiel /* signal VSYNC and set a timer to turn it off */ player->vsync = TRUE; - timer_set(ld->device->machine, attotime_mul(video_screen_get_scan_period(ld->screen), 4), ld, 0, vsync_off); + timer_set(ld->device->machine, attotime_mul(ld->screen->scan_period(), 4), ld, 0, vsync_off); /* also set a timer to fetch the VBI data when it is ready */ - timer_set(ld->device->machine, video_screen_get_time_until_pos(ld->screen, 19*2, 0), ld, 0, vbi_data_fetch); + timer_set(ld->device->machine, ld->screen->time_until_pos(19*2), ld, 0, vbi_data_fetch); /* boost interleave for the first 1ms to improve communications */ cpuexec_boost_interleave(ld->device->machine, attotime_zero, ATTOTIME_IN_MSEC(1)); @@ -411,7 +411,7 @@ static TIMER_DEVICE_CALLBACK( multijump_timer ) /* update down counter and reschedule */ if (--player->counter != 0) - timer_device_adjust_oneshot(timer, MULTIJUMP_TRACK_TIME, 0); + timer.adjust(MULTIJUMP_TRACK_TIME); } @@ -422,7 +422,7 @@ static TIMER_DEVICE_CALLBACK( multijump_timer ) static WRITE_LINE_DEVICE_HANDLER( ctc_interrupt ) { - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); cpu_set_input_line(ld->player->cpu, 0, state ? ASSERT_LINE : CLEAR_LINE); } @@ -440,7 +440,7 @@ static WRITE8_HANDLER( decoder_display_port_w ) Display is 6-bit Decoder is 4-bit */ - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* writes to offset 0 select the target for reads/writes of actual data */ @@ -467,7 +467,7 @@ static WRITE8_HANDLER( decoder_display_port_w ) static READ8_HANDLER( decoder_display_port_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 result = 0; @@ -492,7 +492,7 @@ static READ8_HANDLER( decoder_display_port_r ) static READ8_HANDLER( controller_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); /* note that this is a cheesy implementation; the real thing relies on exquisite timing */ UINT8 result = ld->player->command ^ 0xff; @@ -507,7 +507,7 @@ static READ8_HANDLER( controller_r ) static WRITE8_HANDLER( controller_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); if (LOG_STATUS_CHANGES && data != ld->player->status) printf("%04X:CONTROLLER.W=%02X\n", cpu_get_pc(space->cpu), data); ld->player->status = data; @@ -521,7 +521,7 @@ static WRITE8_HANDLER( controller_w ) static WRITE8_DEVICE_HANDLER( ppi0_porta_w ) { - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ld->player->counter_start = data; if (LOG_PORT_IO) printf("%s:PORTA.0=%02X\n", cpuexec_describe_context(device->machine), data); @@ -535,7 +535,7 @@ static WRITE8_DEVICE_HANDLER( ppi0_porta_w ) static READ8_DEVICE_HANDLER( ppi0_portb_r ) { - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); return ld->player->counter; } @@ -553,7 +553,7 @@ static READ8_DEVICE_HANDLER( ppi0_portc_r ) $40 = TRKG LOOP (N24-1) $80 = DUMP (N20-1) -- code reads the state and waits for it to change */ - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ldplayer_data *player = ld->player; UINT8 result = 0x00; @@ -579,7 +579,7 @@ static WRITE8_DEVICE_HANDLER( ppi0_portc_w ) $04 = SCAN MODE $08 = n/c */ - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->portc0; @@ -600,7 +600,7 @@ static WRITE8_DEVICE_HANDLER( ppi0_portc_w ) /* on the falling edge of bit 1, start the multi-jump timer */ if (!(data & 0x02) && (prev & 0x02)) - timer_device_adjust_oneshot(player->multitimer, MULTIJUMP_TRACK_TIME, 0); + player->multitimer->adjust(MULTIJUMP_TRACK_TIME); } @@ -621,7 +621,7 @@ static READ8_DEVICE_HANDLER( ppi1_porta_r ) $40 = /INT LOCK $80 = 8 INCH CHK */ - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ldplayer_data *player = ld->player; slider_position sliderpos = ldcore_get_slider_position(ld); UINT8 focus_on = !(player->portb1 & 0x01); @@ -674,7 +674,7 @@ static WRITE8_DEVICE_HANDLER( ppi1_portb_w ) $40 = /LASER ON $80 = /SYNC ST0 */ - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->portb1; int direction; @@ -731,7 +731,7 @@ static WRITE8_DEVICE_HANDLER( ppi1_portc_w ) $40 = SIZE 8/12 $80 = /LED CAV */ - laserdisc_state *ld = ldcore_get_safe_token(device->owner); + laserdisc_state *ld = ldcore_get_safe_token(device->owner()); ldplayer_data *player = ld->player; UINT8 prev = player->portc1; diff --git a/src/emu/machine/ldvp931.c b/src/emu/machine/ldvp931.c index e6ff82593bb..3ca3c306565 100644 --- a/src/emu/machine/ldvp931.c +++ b/src/emu/machine/ldvp931.c @@ -50,7 +50,7 @@ struct _ldplayer_data { /* low-level emulation data */ running_device *cpu; /* CPU index of the 8049 */ - running_device *tracktimer; /* timer device */ + timer_device * tracktimer; /* timer device */ vp931_data_ready_func data_ready_cb; /* data ready callback */ /* I/O port states */ @@ -216,8 +216,8 @@ static void vp931_init(laserdisc_state *ld) /* find our devices */ player->cpu = ld->device->subdevice("vp931"); - player->tracktimer = ld->device->subdevice("tracktimer"); - timer_device_set_ptr(player->tracktimer, ld); + player->tracktimer = downcast(ld->device->subdevice("tracktimer")); + player->tracktimer->set_ptr(ld); } @@ -233,7 +233,7 @@ static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldn /* set the ERP signal to 1 to indicate start of frame, and set a timer to turn it off */ ld->player->daticerp = 1; - timer_set(ld->device->machine, video_screen_get_time_until_pos(ld->screen, 15*2, 0), ld, 0, erp_off); + timer_set(ld->device->machine, ld->screen->time_until_pos(15*2), ld, 0, erp_off); } @@ -245,7 +245,7 @@ static void vp931_vsync(laserdisc_state *ld, const vbi_metadata *vbi, int fieldn static INT32 vp931_update(laserdisc_state *ld, const vbi_metadata *vbi, int fieldnum, attotime curtime) { /* set the first VBI timer to go at the start of line 16 */ - timer_set(ld->device->machine, video_screen_get_time_until_pos(ld->screen, 16*2, 0), ld, LASERDISC_CODE_LINE16 << 2, vbi_data_fetch); + timer_set(ld->device->machine, ld->screen->time_until_pos(16*2), ld, LASERDISC_CODE_LINE16 << 2, vbi_data_fetch); /* play forward by default */ return fieldnum; @@ -282,7 +282,7 @@ static UINT8 vp931_data_r(laserdisc_state *ld) } /* also boost interleave for 4 scanlines to ensure proper communications */ - cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(video_screen_get_scan_period(ld->screen), 4)); + cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(ld->screen->scan_period(), 4)); return player->tocontroller; } @@ -353,7 +353,7 @@ static TIMER_CALLBACK( vbi_data_fetch ) line++; } if (line <= LASERDISC_CODE_LINE18 + 1) - timer_set(machine, video_screen_get_time_until_pos(ld->screen, line*2, which * 2 * video_screen_get_width(ld->screen) / 4), ld, (line << 2) | which, vbi_data_fetch); + timer_set(machine, ld->screen->time_until_pos(line*2, which * 2 * ld->screen->width() / 4), ld, (line << 2) | which, vbi_data_fetch); } @@ -443,7 +443,7 @@ static TIMER_DEVICE_CALLBACK( track_timer ) static WRITE8_HANDLER( output0_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* @@ -484,7 +484,7 @@ static WRITE8_HANDLER( output0_w ) static WRITE8_HANDLER( output1_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; INT32 speed = 0; @@ -576,7 +576,7 @@ static READ8_HANDLER( keypad_r ) static READ8_HANDLER( datic_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); return ld->player->daticval; } @@ -588,7 +588,7 @@ static READ8_HANDLER( datic_r ) static READ8_HANDLER( from_controller_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* clear the pending flag and return the data */ @@ -604,7 +604,7 @@ static READ8_HANDLER( from_controller_r ) static WRITE8_HANDLER( to_controller_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* set the pending flag and stash the data */ @@ -616,7 +616,7 @@ static WRITE8_HANDLER( to_controller_w ) (*player->data_ready_cb)(ld->device, TRUE); /* also boost interleave for 4 scanlines to ensure proper communications */ - cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(video_screen_get_scan_period(ld->screen), 4)); + cpuexec_boost_interleave(ld->device->machine, attotime_zero, attotime_mul(ld->screen->scan_period(), 4)); } @@ -626,7 +626,7 @@ static WRITE8_HANDLER( to_controller_w ) static READ8_HANDLER( port1_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 result = 0x00; @@ -649,7 +649,7 @@ static READ8_HANDLER( port1_r ) static WRITE8_HANDLER( port1_w ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; /* @@ -700,7 +700,7 @@ static WRITE8_HANDLER( port1_w ) { /* turn it off if we're not tracking */ if (player->trackdir == 0) - timer_device_adjust_periodic(player->tracktimer, attotime_never, 0, attotime_never); + player->tracktimer->reset(); /* if we just started tracking, or if the speed was changed, reprime the timer */ else if (((player->port1 ^ data) & 0x11) != 0) @@ -709,7 +709,7 @@ static WRITE8_HANDLER( port1_w ) attotime speed = (data & 0x10) ? ATTOTIME_IN_USEC(60) : ATTOTIME_IN_USEC(10); /* always start with an initial long delay; the code expects this */ - timer_device_adjust_periodic(player->tracktimer, ATTOTIME_IN_USEC(100), 0, speed); + player->tracktimer->adjust(ATTOTIME_IN_USEC(100), 0, speed); } } @@ -723,7 +723,7 @@ static WRITE8_HANDLER( port1_w ) static READ8_HANDLER( port2_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); ldplayer_data *player = ld->player; UINT8 result = 0x00; @@ -762,7 +762,7 @@ static WRITE8_HANDLER( port2_w ) static READ8_HANDLER( t0_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); return ld->player->datastrobe; } @@ -775,6 +775,6 @@ static READ8_HANDLER( t0_r ) static READ8_HANDLER( t1_r ) { - laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner); + laserdisc_state *ld = ldcore_get_safe_token(space->cpu->owner()); return ld->player->trackstate; } diff --git a/src/emu/machine/mb14241.c b/src/emu/machine/mb14241.c index 9d8a37a1afe..1023951fc9c 100644 --- a/src/emu/machine/mb14241.c +++ b/src/emu/machine/mb14241.c @@ -21,10 +21,9 @@ struct _mb14241_state INLINE mb14241_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == MB14241); + assert(device->type() == MB14241); - return (mb14241_state *)device->token; + return (mb14241_state *)downcast(device)->token(); } /***************************************************************************** @@ -75,5 +74,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "MB14241" #define DEVTEMPLATE_FAMILY "MB14241 Shifter IC" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/emu/machine/mb14241.h b/src/emu/machine/mb14241.h index f517c37d5c6..89d5b1da530 100644 --- a/src/emu/machine/mb14241.h +++ b/src/emu/machine/mb14241.h @@ -7,20 +7,15 @@ #ifndef __MB14241_H__ #define __MB14241_H__ +#include "devlegcy.h" -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( mb14241 ); +DECLARE_LEGACY_DEVICE(MB14241, mb14241); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MB14241 DEVICE_GET_INFO_NAME( mb14241 ) - #define MDRV_MB14241_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, MB14241, 0) diff --git a/src/emu/machine/mb3773.c b/src/emu/machine/mb3773.c index b714043b00e..c0edb5148b8 100644 --- a/src/emu/machine/mb3773.c +++ b/src/emu/machine/mb3773.c @@ -34,9 +34,8 @@ struct _mb3773_state INLINE mb3773_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == MB3773)); - return (mb3773_state *)device->token; + assert((device->type() == MB3773)); + return (mb3773_state *)downcast(device)->token(); } /*************************************************************************** @@ -112,5 +111,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "Fujistu MB3773" #define DEVTEMPLATE_FAMILY "Fujistu Power Supply Monitor" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/mb3773.h b/src/emu/machine/mb3773.h index 1e7880fa78a..a856530b9f7 100644 --- a/src/emu/machine/mb3773.h +++ b/src/emu/machine/mb3773.h @@ -9,12 +9,14 @@ #ifndef __MB3773_H__ #define __MB3773_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define MB3773 DEVICE_GET_INFO_NAME(mb3773) +DECLARE_LEGACY_DEVICE(MB3773, mb3773); #define MDRV_MB3773_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, MB3773, 0) @@ -24,9 +26,6 @@ PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( mb3773 ); - extern WRITE8_DEVICE_HANDLER( mb3773_set_ck ); #endif /* __MB3773_H__ */ diff --git a/src/emu/machine/mb87078.c b/src/emu/machine/mb87078.c index 8803fa73e17..81f518f17e2 100644 --- a/src/emu/machine/mb87078.c +++ b/src/emu/machine/mb87078.c @@ -114,17 +114,16 @@ static const int mb87078_gain_percent[66] = { INLINE mb87078_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == MB87078); + assert(device->type() == MB87078); - return (mb87078_state *)device->token; + return (mb87078_state *)downcast(device)->token(); } INLINE const mb87078_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == MB87078)); - return (const mb87078_interface *) device->baseconfig().static_config; + assert((device->type() == MB87078)); + return (const mb87078_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -273,6 +272,5 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "Fujitsu MB87078" #define DEVTEMPLATE_FAMILY "Fujitsu Volume Controller MB87078" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/mb87078.h b/src/emu/machine/mb87078.h index a4a54a52bda..a5e378bb814 100644 --- a/src/emu/machine/mb87078.h +++ b/src/emu/machine/mb87078.h @@ -8,6 +8,8 @@ #ifndef __MB87078_H__ #define __MB87078_H__ +#include "devlegcy.h" + /*************************************************************************** @@ -22,18 +24,12 @@ struct _mb87078_interface mb87078_gain_changed_cb gain_changed_cb; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( mb87078 ); +DECLARE_LEGACY_DEVICE(MB87078, mb87078); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MB87078 DEVICE_GET_INFO_NAME( mb87078 ) - #define MDRV_MB87078_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, MB87078, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/emu/machine/msm6242.c b/src/emu/machine/msm6242.c index b9b41a73c0a..cd1f1a4d190 100644 --- a/src/emu/machine/msm6242.c +++ b/src/emu/machine/msm6242.c @@ -41,10 +41,9 @@ struct _msm6242_t INLINE msm6242_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DEVICE_GET_INFO_NAME(msm6242)); + assert(device->type() == MSM6242); - return (msm6242_t *)device->token; + return (msm6242_t *)downcast(device)->token(); } @@ -169,7 +168,6 @@ DEVICE_GET_INFO( msm6242 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(msm6242_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_TIMER; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(msm6242); break; diff --git a/src/emu/machine/msm6242.h b/src/emu/machine/msm6242.h index f74e3d84fdb..cffe8dc7167 100644 --- a/src/emu/machine/msm6242.h +++ b/src/emu/machine/msm6242.h @@ -12,16 +12,15 @@ #ifndef __MSM6242_H__ #define __MSM6242_H__ +#include "devlegcy.h" -#define MSM6242 DEVICE_GET_INFO_NAME(msm6242) + +DECLARE_LEGACY_DEVICE(MSM6242, msm6242); #define MDRV_MSM6242_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, MSM6242, 0) -/* device interface */ -DEVICE_GET_INFO( msm6242 ); - READ8_DEVICE_HANDLER( msm6242_r ); WRITE8_DEVICE_HANDLER( msm6242_w ); diff --git a/src/emu/machine/pci.c b/src/emu/machine/pci.c index 35b12f28dcd..5ebe0c3b038 100644 --- a/src/emu/machine/pci.c +++ b/src/emu/machine/pci.c @@ -99,10 +99,9 @@ struct _pci_bus_state INLINE pci_bus_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == PCI_BUS); + assert(device->type() == PCI_BUS); - return (pci_bus_state *)device->token; + return (pci_bus_state *)downcast(device)->token(); } @@ -205,13 +204,13 @@ static DEVICE_START( pci_bus ) /* validate some basic stuff */ assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() != NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); /* store a pointer back to the device */ - pcibus->config = (const pci_bus_config *)device->baseconfig().inline_config; + pcibus->config = (const pci_bus_config *)downcast(device->baseconfig()).inline_config(); pcibus->busdevice = device; pcibus->devicenum = -1; @@ -251,7 +250,6 @@ DEVICE_GET_INFO( pci_bus ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pci_bus_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(pci_bus_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pci_bus); break; diff --git a/src/emu/machine/pci.h b/src/emu/machine/pci.h index 98dbe0b2774..7398077cb78 100644 --- a/src/emu/machine/pci.h +++ b/src/emu/machine/pci.h @@ -9,6 +9,8 @@ #ifndef PCI_H #define PCI_H +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -62,9 +64,7 @@ WRITE64_DEVICE_HANDLER( pci_64be_w ); /* ----- device interface ----- */ -/* device get info callback */ -#define PCI_BUS DEVICE_GET_INFO_NAME(pci_bus) -DEVICE_GET_INFO( pci_bus ); +DECLARE_LEGACY_DEVICE(PCI_BUS, pci_bus); #endif /* PCI_H */ diff --git a/src/emu/machine/pd4990a.c b/src/emu/machine/pd4990a.c index cf6efd601c5..dcb7c62adec 100644 --- a/src/emu/machine/pd4990a.c +++ b/src/emu/machine/pd4990a.c @@ -85,9 +85,8 @@ struct _upd4990a_state INLINE upd4990a_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == UPD4990A)); - return (upd4990a_state *)device->token; + assert((device->type() == UPD4990A)); + return (upd4990a_state *)downcast(device)->token(); } INLINE UINT8 convert_to_bcd(int val) @@ -532,5 +531,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "NEC uPD4990A" #define DEVTEMPLATE_FAMILY "NEC uPD4990A Calendar & Clock" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/pd4990a.h b/src/emu/machine/pd4990a.h index 8b0146d2974..21ea810e028 100644 --- a/src/emu/machine/pd4990a.h +++ b/src/emu/machine/pd4990a.h @@ -9,12 +9,14 @@ #ifndef __PD4990A_H__ #define __PD4990A_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define UPD4990A DEVICE_GET_INFO_NAME(upd4990a) +DECLARE_LEGACY_DEVICE(UPD4990A, upd4990a); #define MDRV_UPD4990A_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, UPD4990A, 0) @@ -24,9 +26,6 @@ PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( upd4990a ); - /* this should be refactored, once RTCs get unified */ extern void upd4990a_addretrace( running_device *device ); diff --git a/src/emu/machine/pic8259.c b/src/emu/machine/pic8259.c index 22b7ff047eb..88fcc9b9d3f 100644 --- a/src/emu/machine/pic8259.c +++ b/src/emu/machine/pic8259.c @@ -72,9 +72,8 @@ struct pic8259 INLINE pic8259_t *get_safe_token(running_device *device) { assert( device != NULL ); - assert( device->token != NULL ); - assert( device->type == DEVICE_GET_INFO_NAME(pic8259) ); - return ( pic8259_t *) device->token; + assert( device->type() == PIC8259 ); + return ( pic8259_t *) downcast(device)->token(); } @@ -401,7 +400,7 @@ WRITE8_DEVICE_HANDLER( pic8259_w ) static DEVICE_START( pic8259 ) { pic8259_t *pic8259 = get_safe_token(device); - const struct pic8259_interface *intf = (const struct pic8259_interface *)device->baseconfig().static_config; + const struct pic8259_interface *intf = (const struct pic8259_interface *)device->baseconfig().static_config(); assert(intf != NULL); @@ -444,7 +443,6 @@ DEVICE_GET_INFO( pic8259 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pic8259_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pic8259); break; diff --git a/src/emu/machine/pic8259.h b/src/emu/machine/pic8259.h index ffd31331a68..43a7627297c 100644 --- a/src/emu/machine/pic8259.h +++ b/src/emu/machine/pic8259.h @@ -25,9 +25,10 @@ #ifndef __PIC8259_H__ #define __PIC8259_H__ +#include "devlegcy.h" #include "devcb.h" -#define PIC8259 DEVICE_GET_INFO_NAME(pic8259) +DECLARE_LEGACY_DEVICE(PIC8259, pic8259); /*************************************************************************** TYPE DEFINITIONS @@ -50,7 +51,6 @@ struct pic8259_interface /* device interface */ -DEVICE_GET_INFO(pic8259); READ8_DEVICE_HANDLER( pic8259_r ); WRITE8_DEVICE_HANDLER( pic8259_w ); int pic8259_acknowledge(running_device *device); diff --git a/src/emu/machine/pit8253.c b/src/emu/machine/pit8253.c index 65cdf4e1dfa..f2e82cd031c 100644 --- a/src/emu/machine/pit8253.c +++ b/src/emu/machine/pit8253.c @@ -105,10 +105,9 @@ struct _pit8253_t INLINE pit8253_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == PIT8253) || (device->type == PIT8254)); + assert((device->type() == PIT8253) || (device->type() == PIT8254)); - return (pit8253_t *) device->token; + return (pit8253_t *) downcast(device)->token(); } @@ -1072,7 +1071,7 @@ static void common_start( running_device *device, int device_type ) { pit8253_t *pit8253 = get_safe_token(device); int timerno; - pit8253->config = (const struct pit8253_config *)device->baseconfig().static_config; + pit8253->config = (const struct pit8253_config *)device->baseconfig().static_config(); pit8253->device_type = device_type; /* register for state saving */ @@ -1162,7 +1161,6 @@ DEVICE_GET_INFO( pit8253 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pit8253_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pit8253); break; diff --git a/src/emu/machine/pit8253.h b/src/emu/machine/pit8253.h index 48cafdfe0c8..26ab9ad7096 100644 --- a/src/emu/machine/pit8253.h +++ b/src/emu/machine/pit8253.h @@ -23,12 +23,10 @@ #ifndef __PIT8253_H__ #define __PIT8253_H__ +#include "devlegcy.h" #include "devcb.h" -#define PIT8253 DEVICE_GET_INFO_NAME(pit8253) -#define PIT8254 DEVICE_GET_INFO_NAME(pit8254) - struct pit8253_config { struct @@ -39,6 +37,9 @@ struct pit8253_config } timer[3]; }; +DECLARE_LEGACY_DEVICE(PIT8253, pit8253); +DECLARE_LEGACY_DEVICE(PIT8254, pit8254); + /*************************************************************************** DEVICE CONFIGURATION MACROS @@ -54,10 +55,6 @@ struct pit8253_config MDRV_DEVICE_CONFIG(_intrf) -/* device interface */ -DEVICE_GET_INFO( pit8253 ); -DEVICE_GET_INFO( pit8254 ); - READ8_DEVICE_HANDLER( pit8253_r ); WRITE8_DEVICE_HANDLER( pit8253_w ); diff --git a/src/emu/machine/rp5h01.c b/src/emu/machine/rp5h01.c index 0ebf8602b4c..08aee97d11c 100644 --- a/src/emu/machine/rp5h01.c +++ b/src/emu/machine/rp5h01.c @@ -44,9 +44,8 @@ struct _rp5h01_state INLINE rp5h01_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == RP5H01)); - return (rp5h01_state *)device->token; + assert((device->type() == RP5H01)); + return (rp5h01_state *)downcast(device)->token(); } /*************************************************************************** @@ -174,10 +173,9 @@ static DEVICE_START( rp5h01 ) { rp5h01_state *rp5h01 = get_safe_token(device); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config == NULL); + assert(device->baseconfig().static_config() == NULL); - rp5h01->data = *device->region; + rp5h01->data = *device->region(); /* register for state saving */ state_save_register_device_item(device, 0, rp5h01->counter); @@ -212,5 +210,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "RP5H01" #define DEVTEMPLATE_FAMILY "RP5H01" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/rp5h01.h b/src/emu/machine/rp5h01.h index 47758207ec8..9b201269d34 100644 --- a/src/emu/machine/rp5h01.h +++ b/src/emu/machine/rp5h01.h @@ -8,11 +8,13 @@ #ifndef __RP5H01_H__ #define __RP5H01_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define RP5H01 DEVICE_GET_INFO_NAME(rp5h01) +DECLARE_LEGACY_DEVICE(RP5H01, rp5h01); #define MDRV_RP5H01_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, RP5H01, 0) @@ -27,9 +29,6 @@ PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( rp5h01 ); - WRITE8_DEVICE_HANDLER( rp5h01_enable_w ); /* /CE */ WRITE8_DEVICE_HANDLER( rp5h01_reset_w ); /* RESET */ WRITE8_DEVICE_HANDLER( rp5h01_clock_w ); /* DATA CLOCK (active low) */ diff --git a/src/emu/machine/rtc65271.c b/src/emu/machine/rtc65271.c index acaebf0953c..0e584d32fb6 100644 --- a/src/emu/machine/rtc65271.c +++ b/src/emu/machine/rtc65271.c @@ -56,10 +56,9 @@ struct _rtc65271_state INLINE rtc65271_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == RTC65271); + assert(device->type() == RTC65271); - return (rtc65271_state *)device->token; + return (rtc65271_state *)downcast(device)->token(); } @@ -686,7 +685,7 @@ static TIMER_CALLBACK( rtc_end_update_callback ) static DEVICE_START( rtc65271 ) { - rtc65271_config *config = (rtc65271_config *)device->baseconfig().inline_config; + rtc65271_config *config = (rtc65271_config *)downcast(device->baseconfig()).inline_config(); rtc65271_state *state = get_safe_token(device); state->update_timer = timer_alloc(device->machine, rtc_begin_update_callback, (void *)device); diff --git a/src/emu/machine/rtc65271.h b/src/emu/machine/rtc65271.h index 57593c848c2..f2095acdefa 100644 --- a/src/emu/machine/rtc65271.h +++ b/src/emu/machine/rtc65271.h @@ -2,6 +2,11 @@ rtc65271.h: include file for rtc65271.c */ +#ifndef __RTC65271_H__ +#define __RTC65271_H__ + +#include "devlegcy.h" + typedef struct _rtc65271_config rtc65271_config; struct _rtc65271_config { @@ -23,6 +28,6 @@ WRITE8_DEVICE_HANDLER( rtc65271_rtc_w ); WRITE8_DEVICE_HANDLER( rtc65271_xram_w ); -/* device get info callback */ -#define RTC65271 DEVICE_GET_INFO_NAME(rtc65271) -DEVICE_GET_INFO( rtc65271 ); +DECLARE_LEGACY_NVRAM_DEVICE(RTC65271, rtc65271); + +#endif diff --git a/src/emu/machine/smc91c9x.c b/src/emu/machine/smc91c9x.c index 24b6b97bc96..8bfc815ef7a 100644 --- a/src/emu/machine/smc91c9x.c +++ b/src/emu/machine/smc91c9x.c @@ -154,10 +154,9 @@ static void update_ethernet_irq(smc91c9x_state *smc); INLINE smc91c9x_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SMC91C94 || device->type == SMC91C96); + assert(device->type() == SMC91C94 || device->type() == SMC91C96); - return (smc91c9x_state *)device->token; + return (smc91c9x_state *)downcast(device)->token(); } @@ -510,13 +509,13 @@ WRITE16_DEVICE_HANDLER( smc91c9x_w ) static DEVICE_START( smc91c9x ) { - const smc91c9x_config *config = (const smc91c9x_config *)device->baseconfig().inline_config; + const smc91c9x_config *config = (const smc91c9x_config *)downcast(device->baseconfig()).inline_config(); smc91c9x_state *smc = get_safe_token(device); /* validate some basic stuff */ assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() != NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -600,7 +599,6 @@ static DEVICE_GET_INFO( smc91c9x ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(smc91c9x_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(smc91c9x_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(smc91c9x); break; diff --git a/src/emu/machine/smc91c9x.h b/src/emu/machine/smc91c9x.h index c1a550dff8e..157202418ce 100644 --- a/src/emu/machine/smc91c9x.h +++ b/src/emu/machine/smc91c9x.h @@ -9,6 +9,8 @@ #ifndef __SMC91C9X__ #define __SMC91C9X__ +#include "devlegcy.h" + /*************************************************************************** TYPE DEFINITIONS @@ -49,10 +51,7 @@ WRITE16_DEVICE_HANDLER( smc91c9x_w ); /* ----- device interface ----- */ -/* device get info callbacks */ -#define SMC91C94 DEVICE_GET_INFO_NAME(smc91c94) -#define SMC91C96 DEVICE_GET_INFO_NAME(smc91c96) -DEVICE_GET_INFO( smc91c94 ); -DEVICE_GET_INFO( smc91c96 ); +DECLARE_LEGACY_DEVICE(SMC91C94, smc91c94); +DECLARE_LEGACY_DEVICE(SMC91C96, smc91c96); #endif diff --git a/src/emu/machine/timekpr.c b/src/emu/machine/timekpr.c index e3b97056792..6de5be00cab 100644 --- a/src/emu/machine/timekpr.c +++ b/src/emu/machine/timekpr.c @@ -201,8 +201,8 @@ static TIMER_CALLBACK( timekeeper_tick ) { carry = inc_bcd( &c->century, MASK_CENTURY, 0x00, 0x99 ); - if( c->device->type == M48T35 || - c->device->type == M48T58 ) + if( c->device->type() == M48T35 || + c->device->type() == M48T58 ) { if( ( c->day & DAY_CEB ) != 0 ) { @@ -225,13 +225,12 @@ static TIMER_CALLBACK( timekeeper_tick ) INLINE timekeeper_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == M48T02) || - (device->type == M48T35) || - (device->type == M48T58) || - (device->type == MK48T08)); + assert((device->type() == M48T02) || + (device->type() == M48T35) || + (device->type() == M48T58) || + (device->type() == MK48T08)); - return (timekeeper_state *)device->token; + return (timekeeper_state *)downcast(device)->token(); } /* memory handlers */ @@ -251,17 +250,17 @@ WRITE8_DEVICE_HANDLER( timekeeper_w ) } else if( offset == c->offset_day ) { - if( c->device->type == M48T35 || - c->device->type == M48T58 ) + if( c->device->type() == M48T35 || + c->device->type() == M48T58 ) { c->day = ( c->day & ~DAY_CEB ) | ( data & DAY_CEB ); } } - else if( offset == c->offset_date && c->device->type == M48T58 ) + else if( offset == c->offset_date && c->device->type() == M48T58 ) { data &= ~DATE_BL; } - else if( offset == c->offset_flags && c->device->type == MK48T08 ) + else if( offset == c->offset_flags && c->device->type() == MK48T08 ) { data &= ~FLAGS_BL; } @@ -291,8 +290,8 @@ static DEVICE_START(timekeeper) /* validate some basic stuff */ assert(device != NULL); -// assert(device->baseconfig().static_config != NULL); - assert(device->baseconfig().inline_config == NULL); +// assert(device->baseconfig().static_config() != NULL); + assert(downcast(device->baseconfig()).inline_config() == NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -310,8 +309,8 @@ static DEVICE_START(timekeeper) c->century = make_bcd( systime.local_time.year / 100 ); c->data = auto_alloc_array( device->machine, UINT8, c->size ); - c->default_data = *device->region; - assert( device->region->bytes() == c->size ); + c->default_data = *device->region(); + assert( device->region()->bytes() == c->size ); state_save_register_device_item( device, 0, c->control ); state_save_register_device_item( device, 0, c->seconds ); @@ -454,7 +453,6 @@ static DEVICE_GET_INFO(timekeeper) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(timekeeper_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; // sizeof(timekeeper_config) - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(timekeeper); break; diff --git a/src/emu/machine/timekpr.h b/src/emu/machine/timekpr.h index 0bfc385de01..653523d13c0 100644 --- a/src/emu/machine/timekpr.h +++ b/src/emu/machine/timekpr.h @@ -12,35 +12,33 @@ #if !defined( TIMEKPR_H ) #define TIMEKPR_H ( 1 ) +#include "devlegcy.h" + typedef struct _timekeeper_config timekeeper_config; struct _timekeeper_config { const char *data; }; -#define M48T02 DEVICE_GET_INFO_NAME(m48t02) -DEVICE_GET_INFO(m48t02); +DECLARE_LEGACY_NVRAM_DEVICE(M48T02, m48t02); #define MDRV_M48T02_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, M48T02, 0) -#define M48T35 DEVICE_GET_INFO_NAME(m48t35) -DEVICE_GET_INFO(m48t35); +DECLARE_LEGACY_NVRAM_DEVICE(M48T35, m48t35); #define MDRV_M48T35_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, M48T35, 0) -#define M48T58 DEVICE_GET_INFO_NAME(m48t58) -DEVICE_GET_INFO(m48t58); +DECLARE_LEGACY_NVRAM_DEVICE(M48T58, m48t58); #define MDRV_M48T58_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, M48T58, 0) -#define MK48T08 DEVICE_GET_INFO_NAME(mk48t08) -DEVICE_GET_INFO(mk48t08); +DECLARE_LEGACY_NVRAM_DEVICE(MK48T08, mk48t08); #define MDRV_MK48T08_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, MK48T08, 0) diff --git a/src/emu/machine/tms6100.c b/src/emu/machine/tms6100.c index 054cf0ca500..863a2219de0 100644 --- a/src/emu/machine/tms6100.c +++ b/src/emu/machine/tms6100.c @@ -105,10 +105,9 @@ struct _tms6100_state INLINE tms6100_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TMS6100 || - device->type == M58819); - return (tms6100_state *)device->token; + assert(device->type() == TMS6100 || + device->type() == M58819); + return (tms6100_state *)downcast(device)->token(); } /********************************************************************************************** @@ -143,7 +142,7 @@ static DEVICE_START( tms6100 ) assert_always(tms != NULL, "Error creating TMS6100 chip"); //tms->intf = device->baseconfig().static_config ? (const tms5110_interface *)device->baseconfig().static_config : &dummy; - tms->rom = *device->region; + tms->rom = *device->region(); tms->device = device; diff --git a/src/emu/machine/tms6100.h b/src/emu/machine/tms6100.h index c6cd625eac7..bd6a1919d20 100644 --- a/src/emu/machine/tms6100.h +++ b/src/emu/machine/tms6100.h @@ -3,6 +3,7 @@ #ifndef __TMS6100_H__ #define __TMS6100_H__ +#include "devlegcy.h" /* TMS 6100 memory controller */ @@ -13,10 +14,7 @@ WRITE8_DEVICE_HANDLER( tms6100_addr_w ); READ_LINE_DEVICE_HANDLER( tms6100_data_r ); -DEVICE_GET_INFO( tms6100 ); -DEVICE_GET_INFO( m58819 ); - -#define TMS6100 DEVICE_GET_INFO_NAME( tms6100 ) -#define M58819 DEVICE_GET_INFO_NAME( m58819 ) +DECLARE_LEGACY_DEVICE(TMS6100, tms6100); +DECLARE_LEGACY_DEVICE(M58819, m58819); #endif /* __TMS6100_H__ */ diff --git a/src/emu/machine/upd4701.c b/src/emu/machine/upd4701.c index cf818e49984..27c8928305d 100644 --- a/src/emu/machine/upd4701.c +++ b/src/emu/machine/upd4701.c @@ -48,9 +48,8 @@ struct _upd4701_state INLINE upd4701_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == UPD4701)); - return (upd4701_state *)device->token; + assert((device->type() == UPD4701)); + return (upd4701_state *)downcast(device)->token(); } @@ -312,5 +311,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "NEC uPD4701 Encoder" #define DEVTEMPLATE_FAMILY "NEC uPD4701 Encoder" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL #include "devtempl.h" diff --git a/src/emu/machine/upd4701.h b/src/emu/machine/upd4701.h index babfe10b535..834aa06fc73 100644 --- a/src/emu/machine/upd4701.h +++ b/src/emu/machine/upd4701.h @@ -9,11 +9,13 @@ #ifndef __UPD4701_H__ #define __UPD4701_H__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define UPD4701 DEVICE_GET_INFO_NAME(upd4701) +DECLARE_LEGACY_DEVICE(UPD4701, upd4701); #define MDRV_UPD4701_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, UPD4701, 0) @@ -23,9 +25,6 @@ PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( upd4701 ); - extern WRITE8_DEVICE_HANDLER( upd4701_cs_w ); extern WRITE8_DEVICE_HANDLER( upd4701_xy_w ); extern WRITE8_DEVICE_HANDLER( upd4701_ul_w ); diff --git a/src/emu/machine/x2212.c b/src/emu/machine/x2212.c index 5bb82f1ed92..735492b0a74 100644 --- a/src/emu/machine/x2212.c +++ b/src/emu/machine/x2212.c @@ -27,10 +27,9 @@ typedef struct INLINE x2212_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == X2212); + assert(device->type() == X2212); - return (x2212_state *)device->token; + return (x2212_state *)downcast(device)->token(); } WRITE8_DEVICE_HANDLER( x2212_write ) @@ -84,8 +83,8 @@ static DEVICE_START(x2212) /* validate some basic stuff */ assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config == NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() == NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -94,7 +93,7 @@ static DEVICE_START(x2212) c->store = 1; c->array_recall = 1; - c->default_data = *device->region; + c->default_data = *device->region(); state_save_register_device_item_pointer( device, 0, c->sram, SIZE_DATA ); state_save_register_device_item_pointer( device, 0, c->e2prom, SIZE_DATA ); diff --git a/src/emu/machine/x2212.h b/src/emu/machine/x2212.h index ab3ce81d5d7..41940d706d8 100644 --- a/src/emu/machine/x2212.h +++ b/src/emu/machine/x2212.h @@ -8,12 +8,13 @@ #if !defined( X2212_H ) #define X2212_H ( 1 ) +#include "devlegcy.h" + /* default nvram contents should be in memory region * with the same tag as device. */ -#define X2212 DEVICE_GET_INFO_NAME(x2212) -DEVICE_GET_INFO(x2212); +DECLARE_LEGACY_NVRAM_DEVICE(X2212, x2212); #define MDRV_X2212_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, X2212, 0) diff --git a/src/emu/machine/z80ctc.c b/src/emu/machine/z80ctc.c index da57ae6fb2f..dcaeee1e7e2 100644 --- a/src/emu/machine/z80ctc.c +++ b/src/emu/machine/z80ctc.c @@ -16,9 +16,9 @@ -/*************************************************************************** - DEBUGGING -***************************************************************************/ +//************************************************************************** +// DEBUGGING +//************************************************************************** #define VERBOSE 0 @@ -26,515 +26,536 @@ -/*************************************************************************** - CONSTANTS -***************************************************************************/ +//************************************************************************** +// CONSTANTS +//************************************************************************** -/* these are the bits of the incoming commands to the CTC */ -#define INTERRUPT 0x80 -#define INTERRUPT_ON 0x80 -#define INTERRUPT_OFF 0x00 +// these are the bits of the incoming commands to the CTC +const int INTERRUPT = 0x80; +const int INTERRUPT_ON = 0x80; +const int INTERRUPT_OFF = 0x00; -#define MODE 0x40 -#define MODE_TIMER 0x00 -#define MODE_COUNTER 0x40 +const int MODE = 0x40; +const int MODE_TIMER = 0x00; +const int MODE_COUNTER = 0x40; -#define PRESCALER 0x20 -#define PRESCALER_256 0x20 -#define PRESCALER_16 0x00 +const int PRESCALER = 0x20; +const int PRESCALER_256 = 0x20; +const int PRESCALER_16 = 0x00; -#define EDGE 0x10 -#define EDGE_FALLING 0x00 -#define EDGE_RISING 0x10 +const int EDGE = 0x10; +const int EDGE_FALLING = 0x00; +const int EDGE_RISING = 0x10; -#define TRIGGER 0x08 -#define TRIGGER_AUTO 0x00 -#define TRIGGER_CLOCK 0x08 +const int TRIGGER = 0x08; +const int TRIGGER_AUTO = 0x00; +const int TRIGGER_CLOCK = 0x08; -#define CONSTANT 0x04 -#define CONSTANT_LOAD 0x04 -#define CONSTANT_NONE 0x00 +const int CONSTANT = 0x04; +const int CONSTANT_LOAD = 0x04; +const int CONSTANT_NONE = 0x00; -#define RESET 0x02 -#define RESET_CONTINUE 0x00 -#define RESET_ACTIVE 0x02 +const int RESET = 0x02; +const int RESET_CONTINUE = 0x00; +const int RESET_ACTIVE = 0x02; -#define CONTROL 0x01 -#define CONTROL_VECTOR 0x00 -#define CONTROL_WORD 0x01 +const int CONTROL = 0x01; +const int CONTROL_VECTOR = 0x00; +const int CONTROL_WORD = 0x01; -/* these extra bits help us keep things accurate */ -#define WAITING_FOR_TRIG 0x100 +// these extra bits help us keep things accurate +const int WAITING_FOR_TRIG = 0x100; -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** -typedef struct _ctc_channel ctc_channel; -struct _ctc_channel +//------------------------------------------------- +// z80ctc_device_config - constructor +//------------------------------------------------- + +z80ctc_device_config::z80ctc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - devcb_resolved_write_line zc; /* zero crossing callbacks */ +} - UINT8 notimer; /* no timer masks */ - UINT16 mode; /* current mode */ - UINT16 tconst; /* time constant */ - UINT16 down; /* down counter (clock mode only) */ - UINT8 extclk; /* current signal from the external clock */ - emu_timer * timer; /* array of active timers */ - UINT8 int_state; /* interrupt status (for daisy chain) */ -}; +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- -typedef struct _z80ctc z80ctc; -struct _z80ctc +device_config *z80ctc_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) { - devcb_resolved_write_line intr; /* interrupt callback */ + return global_alloc(z80ctc_device_config(mconfig, tag, owner, clock)); +} - UINT8 vector; /* interrupt vector */ - attotime period16; /* 16/system clock */ - attotime period256; /* 256/system clock */ - ctc_channel channel[4]; /* data for each channel */ -}; +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- +device_t *z80ctc_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80ctc_device(machine, *this)); +} -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ -static int z80ctc_irq_state(running_device *device); -static int z80ctc_irq_ack(running_device *device); -static void z80ctc_irq_reti(running_device *device); +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void z80ctc_device_config::device_config_complete() +{ + // inherit a copy of the static data + const z80ctc_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_notimer = 0; + memset(&m_intr, 0, sizeof(m_intr)); + memset(&m_zc0, 0, sizeof(m_zc0)); + memset(&m_zc1, 0, sizeof(m_zc1)); + memset(&m_zc2, 0, sizeof(m_zc2)); + } +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +//------------------------------------------------- +// z80ctc_device - constructor +//------------------------------------------------- -INLINE z80ctc *get_safe_token(running_device *device) +z80ctc_device::z80ctc_device(running_machine &_machine, const z80ctc_device_config &_config) + : device_t(_machine, _config), + device_z80daisy_interface(_machine, _config, *this), + m_config(_config) { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80CTC); - return (z80ctc *)device->token; } +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- -/*************************************************************************** - INTERNAL STATE MANAGEMENT -***************************************************************************/ - -static void interrupt_check(running_device *device) +void z80ctc_device::device_start() { - z80ctc *ctc = get_safe_token(device); - int state = (z80ctc_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; + m_period16 = attotime_mul(ATTOTIME_IN_HZ(m_clock), 16); + m_period256 = attotime_mul(ATTOTIME_IN_HZ(m_clock), 256); + + // resolve callbacks + devcb_resolve_write_line(&m_intr, &m_config.m_intr, this); + + // start each channel + m_channel[0].start(this, 0, (m_config.m_notimer & NOTIMER_0) != 0, &m_config.m_zc0); + m_channel[1].start(this, 1, (m_config.m_notimer & NOTIMER_1) != 0, &m_config.m_zc1); + m_channel[2].start(this, 2, (m_config.m_notimer & NOTIMER_2) != 0, &m_config.m_zc2); + m_channel[3].start(this, 3, (m_config.m_notimer & NOTIMER_3) != 0, NULL); + + // register for save states + state_save_register_device_item(this, 0, m_vector); +} + - devcb_call_write_line(&ctc->intr, state); +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void z80ctc_device::device_reset() +{ + // reset each channel + m_channel[0].reset(); + m_channel[1].reset(); + m_channel[2].reset(); + m_channel[3].reset(); + + // check for interrupts + interrupt_check(); + VPRINTF(("CTC Reset\n")); } -static TIMER_CALLBACK( timercallback ) + + +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** + +//------------------------------------------------- +// z80daisy_irq_state - return the overall IRQ +// state for this device +//------------------------------------------------- + +int z80ctc_device::z80daisy_irq_state() { - running_device *device = (running_device *)ptr; - z80ctc *ctc = get_safe_token(device); - ctc_channel *channel = &ctc->channel[param]; + VPRINTF(("CTC IRQ state = %d%d%d%d\n", m_channel[0].m_int_state, m_channel[1].m_int_state, m_channel[2].m_int_state, m_channel[3].m_int_state)); - /* down counter has reached zero - see if we should interrupt */ - if ((channel->mode & INTERRUPT) == INTERRUPT_ON) + // loop over all channels + int state = 0; + for (int ch = 0; ch < 4; ch++) { - channel->int_state |= Z80_DAISY_INT; - VPRINTF(("CTC timer ch%d\n", param)); - interrupt_check(device); - } + ctc_channel &channel = m_channel[ch]; - /* generate the clock pulse */ - devcb_call_write_line(&channel->zc, 1); - devcb_call_write_line(&channel->zc, 0); + // if we're servicing a request, don't indicate more interrupts + if (channel.m_int_state & Z80_DAISY_IEO) + { + state |= Z80_DAISY_IEO; + break; + } + state |= channel.m_int_state; + } - /* reset the down counter */ - channel->down = channel->tconst; + return state; } +//------------------------------------------------- +// z80daisy_irq_ack - acknowledge an IRQ and +// return the appropriate vector +//------------------------------------------------- -/*************************************************************************** - INITIALIZATION/CONFIGURATION -***************************************************************************/ - -attotime z80ctc_getperiod(running_device *device, int ch) +int z80ctc_device::z80daisy_irq_ack() { - z80ctc *ctc = get_safe_token(device); - ctc_channel *channel = &ctc->channel[ch]; - attotime period; + // loop over all channels + for (int ch = 0; ch < 4; ch++) + { + ctc_channel &channel = m_channel[ch]; + + // find the first channel with an interrupt requested + if (channel.m_int_state & Z80_DAISY_INT) + { + VPRINTF(("CTC IRQAck ch%d\n", ch)); + + // clear interrupt, switch to the IEO state, and update the IRQs + channel.m_int_state = Z80_DAISY_IEO; + interrupt_check(); + return m_vector + ch * 2; + } + } + + logerror("z80ctc_irq_ack: failed to find an interrupt to ack!\n"); + return m_vector; +} - /* if reset active, no period */ - if ((channel->mode & RESET) == RESET_ACTIVE) - return attotime_zero; - /* if counter mode, no real period */ - if ((channel->mode & MODE) == MODE_COUNTER) +//------------------------------------------------- +// z80daisy_irq_reti - clear the interrupt +// pending state to allow other interrupts through +//------------------------------------------------- + +void z80ctc_device::z80daisy_irq_reti() +{ + // loop over all channels + for (int ch = 0; ch < 4; ch++) { - logerror("CTC %d is CounterMode : Can't calculate period\n", ch ); - return attotime_zero; + ctc_channel &channel = m_channel[ch]; + + // find the first channel with an IEO pending + if (channel.m_int_state & Z80_DAISY_IEO) + { + VPRINTF(("CTC IRQReti ch%d\n", ch)); + + // clear the IEO state and update the IRQs + channel.m_int_state &= ~Z80_DAISY_IEO; + interrupt_check(); + return; + } } - /* compute the period */ - period = ((channel->mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256; - return attotime_mul(period, channel->tconst); + logerror("z80ctc_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -/*************************************************************************** - WRITE HANDLERS -***************************************************************************/ +//************************************************************************** +// INTERNAL STATE MANAGEMENT +//************************************************************************** -WRITE8_DEVICE_HANDLER( z80ctc_w ) +//------------------------------------------------- +// interrupt_check - look for pending interrupts +// and update the line +//------------------------------------------------- + +void z80ctc_device::interrupt_check() { - z80ctc *ctc = get_safe_token(device); - int ch = offset & 3; - ctc_channel *channel = &ctc->channel[ch]; - int mode; + int state = (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; + devcb_call_write_line(&m_intr, state); +} - /* get the current mode */ - mode = channel->mode; - /* if we're waiting for a time constant, this is it */ - if ((mode & CONSTANT) == CONSTANT_LOAD) - { - VPRINTF(("CTC ch.%d constant = %02x\n", ch, data)); - /* set the time constant (0 -> 0x100) */ - channel->tconst = data ? data : 0x100; +//************************************************************************* +// CTC CHANNELS +//************************************************************************** - /* clear the internal mode -- we're no longer waiting */ - channel->mode &= ~CONSTANT; +//------------------------------------------------- +// ctc_channel - constructor +//------------------------------------------------- - /* also clear the reset, since the constant gets it going again */ - channel->mode &= ~RESET; +z80ctc_device::ctc_channel::ctc_channel() + : m_notimer(false), + m_mode(0), + m_tconst(0), + m_down(0), + m_extclk(0), + m_timer(NULL), + m_int_state(0) +{ + memset(&m_zc, 0, sizeof(m_zc)); +} - /* if we're in timer mode.... */ - if ((mode & MODE) == MODE_TIMER) - { - /* if we're triggering on the time constant, reset the down counter now */ - if ((mode & TRIGGER) == TRIGGER_AUTO) - { - if (!channel->notimer) - { - attotime period = ((mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256; - period = attotime_mul(period, channel->tconst); - timer_adjust_periodic(channel->timer, period, ch, period); - } - else - timer_adjust_oneshot(channel->timer, attotime_never, 0); - } +//------------------------------------------------- +// start - set up at device start time +//------------------------------------------------- - /* else set the bit indicating that we're waiting for the appropriate trigger */ - else - channel->mode |= WAITING_FOR_TRIG; - } +void z80ctc_device::ctc_channel::start(z80ctc_device *device, int index, bool notimer, const devcb_write_line *write_line) +{ + // initialize state + m_device = device; + m_index = index; + if (write_line != NULL) + devcb_resolve_write_line(&m_zc, write_line, m_device); + m_notimer = notimer; + m_timer = timer_alloc(&m_device->m_machine, static_timer_callback, this); + + // register for save states + state_save_register_device_item(m_device, m_index, m_mode); + state_save_register_device_item(m_device, m_index, m_tconst); + state_save_register_device_item(m_device, m_index, m_down); + state_save_register_device_item(m_device, m_index, m_extclk); + state_save_register_device_item(m_device, m_index, m_int_state); +} - /* also set the down counter in case we're clocking externally */ - channel->down = channel->tconst; - /* all done here */ - return; - } +//------------------------------------------------- +// reset - reset the channel +//------------------------------------------------- - /* if we're writing the interrupt vector, handle it specially */ -#if 0 /* Tatsuyuki Satoh changes */ - /* The 'Z80family handbook' wrote, */ - /* interrupt vector is able to set for even channel (0 or 2) */ - if ((data & CONTROL) == CONTROL_VECTOR && (ch&1) == 0) -#else - if ((data & CONTROL) == CONTROL_VECTOR && ch == 0) -#endif - { - ctc->vector = data & 0xf8; - logerror("CTC Vector = %02x\n", ctc->vector); - return; - } +void z80ctc_device::ctc_channel::reset() +{ + m_mode = RESET_ACTIVE; + m_tconst = 0x100; + timer_adjust_oneshot(m_timer, attotime_never, 0); + m_int_state = 0; +} - /* this must be a control word */ - if ((data & CONTROL) == CONTROL_WORD) - { - /* set the new mode */ - channel->mode = data; - VPRINTF(("CTC ch.%d mode = %02x\n", ch, data)); - /* if we're being reset, clear out any pending timers for this channel */ - if ((data & RESET) == RESET_ACTIVE) - { - timer_adjust_oneshot(channel->timer, attotime_never, 0); - /* note that we don't clear the interrupt state here! */ - } +//------------------------------------------------- +// period - return the current channel's period +//------------------------------------------------- + +attotime z80ctc_device::ctc_channel::period() const +{ + // if reset active, no period + if ((m_mode & RESET) == RESET_ACTIVE) + return attotime_zero; - /* all done here */ - return; + // if counter mode, no real period + if ((m_mode & MODE) == MODE_COUNTER) + { + logerror("CTC %d is CounterMode : Can't calculate period\n", m_index); + return attotime_zero; } -} + // compute the period + attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256; + return attotime_mul(period, m_tconst); +} -/*************************************************************************** - READ HANDLERS -***************************************************************************/ +//------------------------------------------------- +// read - read the channel's state +//------------------------------------------------- -READ8_DEVICE_HANDLER( z80ctc_r ) +UINT8 z80ctc_device::ctc_channel::read() { - z80ctc *ctc = get_safe_token(device); - int ch = offset & 3; - ctc_channel *channel = &ctc->channel[ch]; - - /* if we're in counter mode, just return the count */ - if ((channel->mode & MODE) == MODE_COUNTER || (channel->mode & WAITING_FOR_TRIG)) - return channel->down; + // if we're in counter mode, just return the count + if ((m_mode & MODE) == MODE_COUNTER || (m_mode & WAITING_FOR_TRIG)) + return m_down; - /* else compute the down counter value */ + // else compute the down counter value else { - attotime period = ((channel->mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256; + attotime period = ((m_mode & PRESCALER) == PRESCALER_16) ? m_device->m_period16 : m_device->m_period256; VPRINTF(("CTC clock %f\n",ATTOSECONDS_TO_HZ(period.attoseconds))); - if (channel->timer != NULL) - return ((int)(attotime_to_double(timer_timeleft(channel->timer)) / attotime_to_double(period)) + 1) & 0xff; + if (m_timer != NULL) + return ((int)(attotime_to_double(timer_timeleft(m_timer)) / attotime_to_double(period)) + 1) & 0xff; else return 0; } } +//------------------------------------------------- +// write - handle writes to a channel +//------------------------------------------------- -/*************************************************************************** - EXTERNAL TRIGGERS -***************************************************************************/ - -static void z80ctc_trg_w(running_device *device, int ch, UINT8 data) +void z80ctc_device::ctc_channel::write(UINT8 data) { - z80ctc *ctc = get_safe_token(device); - ctc_channel *channel = &ctc->channel[ch]; + // if we're waiting for a time constant, this is it + if ((m_mode & CONSTANT) == CONSTANT_LOAD) + { + VPRINTF(("CTC ch.%d constant = %02x\n", m_index, data)); - /* normalize data */ - data = data ? 1 : 0; + // set the time constant (0 -> 0x100) + m_tconst = data ? data : 0x100; - /* see if the trigger value has changed */ - if (data != channel->extclk) - { - channel->extclk = data; + // clear the internal mode -- we're no longer waiting + m_mode &= ~CONSTANT; - /* see if this is the active edge of the trigger */ - if (((channel->mode & EDGE) == EDGE_RISING && data) || ((channel->mode & EDGE) == EDGE_FALLING && !data)) + // also clear the reset, since the constant gets it going again + m_mode &= ~RESET; + + // if we're in timer mode.... + if ((m_mode & MODE) == MODE_TIMER) { - /* if we're waiting for a trigger, start the timer */ - if ((channel->mode & WAITING_FOR_TRIG) && (channel->mode & MODE) == MODE_TIMER) + // if we're triggering on the time constant, reset the down counter now + if ((m_mode & TRIGGER) == TRIGGER_AUTO) { - if (!channel->notimer) + if (!m_notimer) { - attotime period = ((channel->mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256; - period = attotime_mul(period, channel->tconst); - - VPRINTF(("CTC period %s\n", attotime_string(period, 9))); - timer_adjust_periodic(channel->timer, period, ch, period); + attotime curperiod = period(); + timer_adjust_periodic(m_timer, curperiod, m_index, curperiod); } else - { - VPRINTF(("CTC disabled\n")); - - timer_adjust_oneshot(channel->timer, attotime_never, 0); - } + timer_adjust_oneshot(m_timer, attotime_never, 0); } - /* we're no longer waiting */ - channel->mode &= ~WAITING_FOR_TRIG; - - /* if we're clocking externally, decrement the count */ - if ((channel->mode & MODE) == MODE_COUNTER) - { - channel->down--; - - /* if we hit zero, do the same thing as for a timer interrupt */ - if (!channel->down) - { - void *ptr = (void *)device; - timercallback(device->machine, ptr, ch); - } - } + // else set the bit indicating that we're waiting for the appropriate trigger + else + m_mode |= WAITING_FOR_TRIG; } - } -} -WRITE_LINE_DEVICE_HANDLER( z80ctc_trg0_w ) { z80ctc_trg_w(device, 0, state); } -WRITE_LINE_DEVICE_HANDLER( z80ctc_trg1_w ) { z80ctc_trg_w(device, 1, state); } -WRITE_LINE_DEVICE_HANDLER( z80ctc_trg2_w ) { z80ctc_trg_w(device, 2, state); } -WRITE_LINE_DEVICE_HANDLER( z80ctc_trg3_w ) { z80ctc_trg_w(device, 3, state); } - - -/*************************************************************************** - DAISY CHAIN INTERFACE -***************************************************************************/ - -static int z80ctc_irq_state(running_device *device) -{ - z80ctc *ctc = get_safe_token(device); - int state = 0; - int ch; - - VPRINTF(("CTC IRQ state = %d%d%d%d\n", ctc->channel[0].int_state, ctc->channel[1].int_state, ctc->channel[2].int_state, ctc->channel[3].int_state)); + // also set the down counter in case we're clocking externally + m_down = m_tconst; + } - /* loop over all channels */ - for (ch = 0; ch < 4; ch++) + // if we're writing the interrupt vector, handle it specially +#if 0 /* Tatsuyuki Satoh changes */ + // The 'Z80family handbook' wrote, + // interrupt vector is able to set for even channel (0 or 2) + else if ((data & CONTROL) == CONTROL_VECTOR && (m_index & 1) == 0) +#else + else if ((data & CONTROL) == CONTROL_VECTOR && m_index == 0) +#endif { - ctc_channel *channel = &ctc->channel[ch]; - - /* if we're servicing a request, don't indicate more interrupts */ - if (channel->int_state & Z80_DAISY_IEO) - { - state |= Z80_DAISY_IEO; - break; - } - state |= channel->int_state; + m_device->m_vector = data & 0xf8; + logerror("CTC Vector = %02x\n", m_device->m_vector); } - return state; -} - - -static int z80ctc_irq_ack(running_device *device) -{ - z80ctc *ctc = get_safe_token(device); - int ch; - - /* loop over all channels */ - for (ch = 0; ch < 4; ch++) + // this must be a control word + else if ((data & CONTROL) == CONTROL_WORD) { - ctc_channel *channel = &ctc->channel[ch]; + // set the new mode + m_mode = data; + VPRINTF(("CTC ch.%d mode = %02x\n", m_index, data)); - /* find the first channel with an interrupt requested */ - if (channel->int_state & Z80_DAISY_INT) + // if we're being reset, clear out any pending timers for this channel + if ((data & RESET) == RESET_ACTIVE) { - VPRINTF(("CTC IRQAck ch%d\n", ch)); - - /* clear interrupt, switch to the IEO state, and update the IRQs */ - channel->int_state = Z80_DAISY_IEO; - interrupt_check(device); - return ctc->vector + ch * 2; + timer_adjust_oneshot(m_timer, attotime_never, 0); + // note that we don't clear the interrupt state here! } } - - logerror("z80ctc_irq_ack: failed to find an interrupt to ack!\n"); - return ctc->vector; } -static void z80ctc_irq_reti(running_device *device) +//------------------------------------------------- +// trigger - clock this channel and handle any +// side-effects +//------------------------------------------------- + +void z80ctc_device::ctc_channel::trigger(UINT8 data) { - z80ctc *ctc = get_safe_token(device); - int ch; + // normalize data + data = data ? 1 : 0; - /* loop over all channels */ - for (ch = 0; ch < 4; ch++) + // see if the trigger value has changed + if (data != m_extclk) { - ctc_channel *channel = &ctc->channel[ch]; + m_extclk = data; - /* find the first channel with an IEO pending */ - if (channel->int_state & Z80_DAISY_IEO) + // see if this is the active edge of the trigger + if (((m_mode & EDGE) == EDGE_RISING && data) || ((m_mode & EDGE) == EDGE_FALLING && !data)) { - VPRINTF(("CTC IRQReti ch%d\n", ch)); + // if we're waiting for a trigger, start the timer + if ((m_mode & WAITING_FOR_TRIG) && (m_mode & MODE) == MODE_TIMER) + { + if (!m_notimer) + { + attotime curperiod = period(); + VPRINTF(("CTC period %s\n", attotime_string(curperiod, 9))); + timer_adjust_periodic(m_timer, curperiod, m_index, curperiod); + } + else + { + VPRINTF(("CTC disabled\n")); + timer_adjust_oneshot(m_timer, attotime_never, 0); + } + } - /* clear the IEO state and update the IRQs */ - channel->int_state &= ~Z80_DAISY_IEO; - interrupt_check(device); - return; + // we're no longer waiting + m_mode &= ~WAITING_FOR_TRIG; + + // if we're clocking externally, decrement the count + if ((m_mode & MODE) == MODE_COUNTER) + { + // if we hit zero, do the same thing as for a timer interrupt + if (--m_down == 0) + timer_callback(); + } } } - - logerror("z80ctc_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -static DEVICE_START( z80ctc ) + +//------------------------------------------------- +// trigger - clock this channel and handle any +// side-effects +//------------------------------------------------- + +void z80ctc_device::ctc_channel::timer_callback() { - const z80ctc_interface *intf = (const z80ctc_interface *)device->baseconfig().static_config; - z80ctc *ctc = get_safe_token(device); - astring tempstring; - int ch; - - ctc->period16 = attotime_mul(ATTOTIME_IN_HZ(device->clock), 16); - ctc->period256 = attotime_mul(ATTOTIME_IN_HZ(device->clock), 256); - for (ch = 0; ch < 4; ch++) + // down counter has reached zero - see if we should interrupt + if ((m_mode & INTERRUPT) == INTERRUPT_ON) { - ctc_channel *channel = &ctc->channel[ch]; - void *ptr = (void *)device; - channel->notimer = (intf->notimer >> ch) & 1; - channel->timer = timer_alloc(device->machine, timercallback, ptr); + m_int_state |= Z80_DAISY_INT; + VPRINTF(("CTC timer ch%d\n", m_index)); + m_device->interrupt_check(); } - /* resolve callbacks */ - devcb_resolve_write_line(&ctc->intr, &intf->intr, device); - devcb_resolve_write_line(&ctc->channel[0].zc, &intf->zc0, device); - devcb_resolve_write_line(&ctc->channel[1].zc, &intf->zc1, device); - devcb_resolve_write_line(&ctc->channel[2].zc, &intf->zc2, device); - - /* register for save states */ - state_save_register_device_item(device, 0, ctc->vector); - for (ch = 0; ch < 4; ch++) - { - ctc_channel *channel = &ctc->channel[ch]; - state_save_register_device_item(device, ch, channel->mode); - state_save_register_device_item(device, ch, channel->tconst); - state_save_register_device_item(device, ch, channel->down); - state_save_register_device_item(device, ch, channel->extclk); - state_save_register_device_item(device, ch, channel->int_state); - } + // generate the clock pulse + devcb_call_write_line(&m_zc, 1); + devcb_call_write_line(&m_zc, 0); + + // reset the down counter + m_down = m_tconst; } -static DEVICE_RESET( z80ctc ) -{ - z80ctc *ctc = get_safe_token(device); - int ch; - /* set up defaults */ - for (ch = 0; ch < 4; ch++) - { - ctc_channel *channel = &ctc->channel[ch]; - channel->mode = RESET_ACTIVE; - channel->tconst = 0x100; - timer_adjust_oneshot(channel->timer, attotime_never, 0); - channel->int_state = 0; - } - interrupt_check(device); - VPRINTF(("CTC Reset\n")); -} +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** +WRITE8_DEVICE_HANDLER( z80ctc_w ) { downcast(device)->write(offset & 3, data); } +READ8_DEVICE_HANDLER( z80ctc_r ) { return downcast(device)->read(offset & 3); } -DEVICE_GET_INFO( z80ctc ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80ctc); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80ctc);break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80ctc);break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80ctc_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80ctc_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80ctc_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Zilog Z80 CTC"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; - } -} - +WRITE_LINE_DEVICE_HANDLER( z80ctc_trg0_w ) { downcast(device)->trigger(0, state); } +WRITE_LINE_DEVICE_HANDLER( z80ctc_trg1_w ) { downcast(device)->trigger(1, state); } +WRITE_LINE_DEVICE_HANDLER( z80ctc_trg2_w ) { downcast(device)->trigger(2, state); } +WRITE_LINE_DEVICE_HANDLER( z80ctc_trg3_w ) { downcast(device)->trigger(3, state); } diff --git a/src/emu/machine/z80ctc.h b/src/emu/machine/z80ctc.h index 4b4b7ea2270..5c9e1434e00 100644 --- a/src/emu/machine/z80ctc.h +++ b/src/emu/machine/z80ctc.h @@ -10,68 +10,164 @@ #ifndef __Z80CTC_H__ #define __Z80CTC_H__ +#include "cpu/z80/z80daisy.h" -/*************************************************************************** - CONSTANTS -***************************************************************************/ -#define NOTIMER_0 (1<<0) -#define NOTIMER_1 (1<<1) -#define NOTIMER_2 (1<<2) -#define NOTIMER_3 (1<<3) +//************************************************************************** +// CONSTANTS +//************************************************************************** +const int NOTIMER_0 = (1<<0); +const int NOTIMER_1 = (1<<1); +const int NOTIMER_2 = (1<<2); +const int NOTIMER_3 = (1<<3); -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -typedef struct _z80ctc_interface z80ctc_interface; -struct _z80ctc_interface -{ - int notimer; /* timer disablers */ - devcb_write_line intr; /* callback when change interrupt status */ - devcb_write_line zc0; /* ZC/TO0 callback */ - devcb_write_line zc1; /* ZC/TO1 callback */ - devcb_write_line zc2; /* ZC/TO2 callback */ -}; +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** #define Z80CTC_INTERFACE(name) \ const z80ctc_interface (name)= - -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ - #define MDRV_Z80CTC_ADD(_tag, _clock, _intrf) \ MDRV_DEVICE_ADD(_tag, Z80CTC, _clock) \ MDRV_DEVICE_CONFIG(_intrf) -/*************************************************************************** - INITIALIZATION/CONFIGURATION -***************************************************************************/ +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -attotime z80ctc_getperiod(running_device *device, int ch); +// ======================> z80ctc_interface +struct z80ctc_interface +{ + UINT8 m_notimer; // timer disabler mask + devcb_write_line m_intr; // callback when change interrupt status + devcb_write_line m_zc0; // ZC/TO0 callback + devcb_write_line m_zc1; // ZC/TO1 callback + devcb_write_line m_zc2; // ZC/TO2 callback +}; -/*************************************************************************** - READ/WRITE HANDLERS -***************************************************************************/ -WRITE8_DEVICE_HANDLER( z80ctc_w ); -READ8_DEVICE_HANDLER( z80ctc_r ); +// ======================> z80ctc_device_config +class z80ctc_device_config : public device_config, + public device_config_z80daisy_interface, + public z80ctc_interface +{ + friend class z80ctc_device; -/*************************************************************************** - EXTERNAL TRIGGERS -***************************************************************************/ + // construction/destruction + z80ctc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Zilog Z80 CTC"; } + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + + +// ======================> z80ctc_device + +class z80ctc_device : public device_t, + public device_z80daisy_interface +{ + friend class z80ctc_device_config; + + // construction/destruction + z80ctc_device(running_machine &_machine, const z80ctc_device_config &_config); + +public: + // state getters + attotime period(int ch) const { return m_channel[ch].period(); } + + // I/O operations + UINT8 read(int ch) { return m_channel[ch].read(); } + void write(int ch, UINT8 data) { m_channel[ch].write(data); } + void trigger(int ch, UINT8 data) { m_channel[ch].trigger(data); } + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal helpers + void interrupt_check(); + void timercallback(int chanindex); + + // a single channel within the CTC + class ctc_channel + { + public: + ctc_channel(); + + void start(z80ctc_device *device, int index, bool notimer, const devcb_write_line *write_line); + void reset(); + + UINT8 read(); + void write(UINT8 data); + + attotime period() const; + void trigger(UINT8 data); + void timer_callback(); + + z80ctc_device * m_device; // pointer back to our device + int m_index; // our channel index + devcb_resolved_write_line m_zc; // zero crossing callbacks + bool m_notimer; // timer disabled? + UINT16 m_mode; // current mode + UINT16 m_tconst; // time constant + UINT16 m_down; // down counter (clock mode only) + UINT8 m_extclk; // current signal from the external clock + emu_timer * m_timer; // array of active timers + UINT8 m_int_state; // interrupt status (for daisy chain) + + private: + static TIMER_CALLBACK( static_timer_callback ) { reinterpret_cast(ptr)->timer_callback(); } + }; + + // internal state + const z80ctc_device_config &m_config; + devcb_resolved_write_line m_intr; // interrupt callback + + UINT8 m_vector; // interrupt vector + attotime m_period16; // 16/system clock + attotime m_period256; // 256/system clock + ctc_channel m_channel[4]; // data for each channel +}; + + +// device type definition +const device_type Z80CTC = z80ctc_device_config::static_alloc_device_config; + + + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + +WRITE8_DEVICE_HANDLER( z80ctc_w ); +READ8_DEVICE_HANDLER( z80ctc_r ); WRITE_LINE_DEVICE_HANDLER( z80ctc_trg0_w ); WRITE_LINE_DEVICE_HANDLER( z80ctc_trg1_w ); @@ -79,10 +175,4 @@ WRITE_LINE_DEVICE_HANDLER( z80ctc_trg2_w ); WRITE_LINE_DEVICE_HANDLER( z80ctc_trg3_w ); - -/* ----- device interface ----- */ - -#define Z80CTC DEVICE_GET_INFO_NAME(z80ctc) -DEVICE_GET_INFO( z80ctc ); - #endif diff --git a/src/emu/machine/z80dart.c b/src/emu/machine/z80dart.c index 5a802cac502..c15193823fa 100644 --- a/src/emu/machine/z80dart.c +++ b/src/emu/machine/z80dart.c @@ -23,14 +23,22 @@ #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" -/*************************************************************************** - PARAMETERS -***************************************************************************/ + + +//************************************************************************** +// DEBUGGING +//************************************************************************** #define VERBOSE 0 #define LOG(x) do { if (VERBOSE) logerror x; } while (0) + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + enum { STATE_START = 0, @@ -48,228 +56,476 @@ enum INT_SPECIAL }; -#define Z80DART_RR0_RX_CHAR_AVAILABLE 0x01 -#define Z80DART_RR0_INTERRUPT_PENDING 0x02 -#define Z80DART_RR0_TX_BUFFER_EMPTY 0x04 -#define Z80DART_RR0_DCD 0x08 -#define Z80DART_RR0_RI 0x10 -#define Z80DART_RR0_CTS 0x20 -#define Z80DART_RR0_BREAK 0x80 /* not supported */ - -#define Z80DART_RR1_ALL_SENT 0x01 -#define Z80DART_RR1_PARITY_ERROR 0x10 -#define Z80DART_RR1_RX_OVERRUN_ERROR 0x20 -#define Z80DART_RR1_FRAMING_ERROR 0x40 - -#define Z80DART_WR0_REGISTER_MASK 0x07 -#define Z80DART_WR0_COMMAND_MASK 0x38 -#define Z80DART_WR0_NULL_CODE 0x00 -#define Z80DART_WR0_RESET_EXT_STATUS 0x10 -#define Z80DART_WR0_CHANNEL_RESET 0x18 -#define Z80DART_WR0_ENABLE_INT_NEXT_RX 0x20 -#define Z80DART_WR0_RESET_TX_INT 0x28 /* not supported */ -#define Z80DART_WR0_ERROR_RESET 0x30 -#define Z80DART_WR0_RETURN_FROM_INT 0x38 /* not supported */ - -#define Z80DART_WR1_EXT_INT_ENABLE 0x01 -#define Z80DART_WR1_TX_INT_ENABLE 0x02 -#define Z80DART_WR1_STATUS_VECTOR 0x04 -#define Z80DART_WR1_RX_INT_ENABLE_MASK 0x18 -#define Z80DART_WR1_RX_INT_DISABLE 0x00 -#define Z80DART_WR1_RX_INT_FIRST 0x08 -#define Z80DART_WR1_RX_INT_ALL_PARITY 0x10 /* not supported */ -#define Z80DART_WR1_RX_INT_ALL 0x18 -#define Z80DART_WR1_WRDY_ON_RX_TX 0x20 /* not supported */ -#define Z80DART_WR1_WRDY_FUNCTION 0x40 /* not supported */ -#define Z80DART_WR1_WRDY_ENABLE 0x80 /* not supported */ - -#define Z80DART_WR3_RX_ENABLE 0x01 -#define Z80DART_WR3_AUTO_ENABLES 0x20 -#define Z80DART_WR3_RX_WORD_LENGTH_MASK 0xc0 -#define Z80DART_WR3_RX_WORD_LENGTH_5 0x00 -#define Z80DART_WR3_RX_WORD_LENGTH_7 0x40 -#define Z80DART_WR3_RX_WORD_LENGTH_6 0x80 -#define Z80DART_WR3_RX_WORD_LENGTH_8 0xc0 - -#define Z80DART_WR4_PARITY_ENABLE 0x01 /* not supported */ -#define Z80DART_WR4_PARITY_EVEN 0x02 /* not supported */ -#define Z80DART_WR4_STOP_BITS_MASK 0x0c -#define Z80DART_WR4_STOP_BITS_1 0x04 -#define Z80DART_WR4_STOP_BITS_1_5 0x08 /* not supported */ -#define Z80DART_WR4_STOP_BITS_2 0x0c -#define Z80DART_WR4_CLOCK_MODE_MASK 0xc0 -#define Z80DART_WR4_CLOCK_MODE_X1 0x00 -#define Z80DART_WR4_CLOCK_MODE_X16 0x40 -#define Z80DART_WR4_CLOCK_MODE_X32 0x80 -#define Z80DART_WR4_CLOCK_MODE_X64 0xc0 - -#define Z80DART_WR5_RTS 0x02 -#define Z80DART_WR5_TX_ENABLE 0x08 -#define Z80DART_WR5_SEND_BREAK 0x10 -#define Z80DART_WR5_TX_WORD_LENGTH_MASK 0xc0 -#define Z80DART_WR5_TX_WORD_LENGTH_5 0x00 -#define Z80DART_WR5_TX_WORD_LENGTH_7 0x40 -#define Z80DART_WR5_TX_WORD_LENGTH_6 0x80 -#define Z80DART_WR5_TX_WORD_LENGTH_8 0xc0 -#define Z80DART_WR5_DTR 0x80 +const int Z80DART_RR0_RX_CHAR_AVAILABLE = 0x01; +const int Z80DART_RR0_INTERRUPT_PENDING = 0x02; +const int Z80DART_RR0_TX_BUFFER_EMPTY = 0x04; +const int Z80DART_RR0_DCD = 0x08; +const int Z80DART_RR0_RI = 0x10; +const int Z80DART_RR0_CTS = 0x20; +const int Z80DART_RR0_BREAK = 0x80; // not supported + +const int Z80DART_RR1_ALL_SENT = 0x01; +const int Z80DART_RR1_PARITY_ERROR = 0x10; +const int Z80DART_RR1_RX_OVERRUN_ERROR = 0x20; +const int Z80DART_RR1_FRAMING_ERROR = 0x40; + +const int Z80DART_WR0_REGISTER_MASK = 0x07; +const int Z80DART_WR0_COMMAND_MASK = 0x38; +const int Z80DART_WR0_NULL_CODE = 0x00; +const int Z80DART_WR0_RESET_EXT_STATUS = 0x10; +const int Z80DART_WR0_CHANNEL_RESET = 0x18; +const int Z80DART_WR0_ENABLE_INT_NEXT_RX = 0x20; +const int Z80DART_WR0_RESET_TX_INT = 0x28; // not supported +const int Z80DART_WR0_ERROR_RESET = 0x30; +const int Z80DART_WR0_RETURN_FROM_INT = 0x38; // not supported + +const int Z80DART_WR1_EXT_INT_ENABLE = 0x01; +const int Z80DART_WR1_TX_INT_ENABLE = 0x02; +const int Z80DART_WR1_STATUS_VECTOR = 0x04; +const int Z80DART_WR1_RX_INT_ENABLE_MASK = 0x18; +const int Z80DART_WR1_RX_INT_DISABLE = 0x00; +const int Z80DART_WR1_RX_INT_FIRST = 0x08; +const int Z80DART_WR1_RX_INT_ALL_PARITY = 0x10; // not supported +const int Z80DART_WR1_RX_INT_ALL = 0x18; +const int Z80DART_WR1_WRDY_ON_RX_TX = 0x20; // not supported +const int Z80DART_WR1_WRDY_FUNCTION = 0x40; // not supported +const int Z80DART_WR1_WRDY_ENABLE = 0x80; // not supported + +const int Z80DART_WR3_RX_ENABLE = 0x01; +const int Z80DART_WR3_AUTO_ENABLES = 0x20; +const int Z80DART_WR3_RX_WORD_LENGTH_MASK = 0xc0; +const int Z80DART_WR3_RX_WORD_LENGTH_5 = 0x00; +const int Z80DART_WR3_RX_WORD_LENGTH_7 = 0x40; +const int Z80DART_WR3_RX_WORD_LENGTH_6 = 0x80; +const int Z80DART_WR3_RX_WORD_LENGTH_8 = 0xc0; + +const int Z80DART_WR4_PARITY_ENABLE = 0x01; // not supported +const int Z80DART_WR4_PARITY_EVEN = 0x02; // not supported +const int Z80DART_WR4_STOP_BITS_MASK = 0x0c; +const int Z80DART_WR4_STOP_BITS_1 = 0x04; +const int Z80DART_WR4_STOP_BITS_1_5 = 0x08; // not supported +const int Z80DART_WR4_STOP_BITS_2 = 0x0c; +const int Z80DART_WR4_CLOCK_MODE_MASK = 0xc0; +const int Z80DART_WR4_CLOCK_MODE_X1 = 0x00; +const int Z80DART_WR4_CLOCK_MODE_X16 = 0x40; +const int Z80DART_WR4_CLOCK_MODE_X32 = 0x80; +const int Z80DART_WR4_CLOCK_MODE_X64 = 0xc0; + +const int Z80DART_WR5_RTS = 0x02; +const int Z80DART_WR5_TX_ENABLE = 0x08; +const int Z80DART_WR5_SEND_BREAK = 0x10; +const int Z80DART_WR5_TX_WORD_LENGTH_MASK = 0xc0; +const int Z80DART_WR5_TX_WORD_LENGTH_5 = 0x00; +const int Z80DART_WR5_TX_WORD_LENGTH_7 = 0x40; +const int Z80DART_WR5_TX_WORD_LENGTH_6 = 0x80; +const int Z80DART_WR5_TX_WORD_LENGTH_8 = 0xc0; +const int Z80DART_WR5_DTR = 0x80; + + + +//************************************************************************** +// MACROS +//************************************************************************** -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +#define RXD \ + devcb_call_read_line(&m_in_rxd_func) + +#define TXD(_state) \ + devcb_call_write_line(&m_out_txd_func, _state) + +#define RTS(_state) \ + devcb_call_write_line(&m_out_rts_func, _state) + +#define DTR(_state) \ + devcb_call_write_line(&m_out_dtr_func, _state) + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** -typedef struct _dart_channel dart_channel; -struct _dart_channel +//------------------------------------------------- +// z80dart_device_config - constructor +//------------------------------------------------- + +z80dart_device_config::z80dart_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - devcb_resolved_read_line in_rxd_func; - devcb_resolved_write_line out_txd_func; - devcb_resolved_write_line out_dtr_func; - devcb_resolved_write_line out_rts_func; - devcb_resolved_write_line out_wrdy_func; - - /* register state */ - UINT8 rr[3]; /* read register */ - UINT8 wr[6]; /* write register */ - - /* receiver state */ - UINT8 rx_data_fifo[3]; /* receive data FIFO */ - UINT8 rx_error_fifo[3]; /* receive error FIFO */ - UINT8 rx_shift; /* 8-bit receive shift register */ - UINT8 rx_error; /* current receive error */ - int rx_fifo; /* receive FIFO pointer */ - - int rx_clock; /* receive clock pulse count */ - int rx_state; /* receive state */ - int rx_bits; /* bits received */ - int rx_first; /* first character received */ - int rx_parity; /* received data parity */ - int rx_break; /* receive break condition */ - UINT8 rx_rr0_latch; /* read register 0 latched */ - - int ri; /* ring indicator latch */ - int cts; /* clear to send latch */ - int dcd; /* data carrier detect latch */ - - /* transmitter state */ - UINT8 tx_data; /* transmit data register */ - UINT8 tx_shift; /* transmit shift register */ - - int tx_clock; /* transmit clock pulse count */ - int tx_state; /* transmit state */ - int tx_bits; /* bits transmitted */ - int tx_parity; /* transmitted data parity */ - - int dtr; /* data terminal ready */ - int rts; /* request to send */ -}; +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- -typedef struct _z80dart_t z80dart_t; -struct _z80dart_t +device_config *z80dart_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) { - devcb_resolved_write_line out_int_func; + return global_alloc(z80dart_device_config(mconfig, tag, owner, clock)); +} - dart_channel channel[2]; /* channels */ - int int_state[8]; /* interrupt state */ +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- - /* timers */ - emu_timer *rxca_timer; - emu_timer *txca_timer; - emu_timer *rxtxcb_timer; -}; +device_t *z80dart_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80dart_device(machine, *this)); +} -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ -static int z80dart_irq_state(running_device *device); -static void z80dart_irq_reti(running_device *device); +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +void z80dart_device_config::device_config_complete() +{ + // inherit a copy of the static data + const z80dart_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_rx_clock_a = m_tx_clock_a = m_rx_tx_clock_b = 0; + memset(&m_in_rxda_func, 0, sizeof(m_in_rxda_func)); + memset(&m_out_txda_func, 0, sizeof(m_out_txda_func)); + memset(&m_out_dtra_func, 0, sizeof(m_out_dtra_func)); + memset(&m_out_rtsa_func, 0, sizeof(m_out_rtsa_func)); + memset(&m_out_wrdya_func, 0, sizeof(m_out_wrdya_func)); + memset(&m_in_rxdb_func, 0, sizeof(m_in_rxdb_func)); + memset(&m_out_txdb_func, 0, sizeof(m_out_txdb_func)); + memset(&m_out_dtrb_func, 0, sizeof(m_out_dtrb_func)); + memset(&m_out_rtsb_func, 0, sizeof(m_out_rtsb_func)); + memset(&m_out_wrdyb_func, 0, sizeof(m_out_wrdyb_func)); + memset(&m_out_int_func, 0, sizeof(m_out_int_func)); + } +} -INLINE z80dart_t *get_safe_token(running_device *device) + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// z80dart_device - constructor +//------------------------------------------------- + +z80dart_device::z80dart_device(running_machine &_machine, const z80dart_device_config &config) + : device_t(_machine, config), + device_z80daisy_interface(_machine, config, *this), + m_config(config) { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80DART); - return (z80dart_t *)device->token; } -INLINE const z80dart_interface *get_interface(running_device *device) + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void z80dart_device::device_start() { - assert(device != NULL); - assert((device->type == Z80DART)); - return (const z80dart_interface *) device->baseconfig().static_config; + // resolve callbacks + devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); + + m_channel[Z80DART_CH_A].start(this, Z80DART_CH_A, m_config.m_in_rxda_func, m_config.m_out_txda_func, m_config.m_out_dtra_func, m_config.m_out_rtsa_func, m_config.m_out_wrdya_func); + m_channel[Z80DART_CH_B].start(this, Z80DART_CH_B, m_config.m_in_rxdb_func, m_config.m_out_txdb_func, m_config.m_out_dtrb_func, m_config.m_out_rtsb_func, m_config.m_out_wrdyb_func); + + if (m_config.m_rx_clock_a != 0) + { + // allocate channel A receive timer + m_rxca_timer = timer_alloc(&m_machine, dart_channel::static_rxca_tick, (void *)&m_channel[Z80DART_CH_A]); + timer_adjust_periodic(m_rxca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_rx_clock_a)); + } + + if (m_config.m_tx_clock_a != 0) + { + // allocate channel A transmit timer + m_txca_timer = timer_alloc(&m_machine, dart_channel::static_txca_tick, (void *)&m_channel[Z80DART_CH_A]); + timer_adjust_periodic(m_txca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_tx_clock_a)); + } + + if (m_config.m_rx_tx_clock_b != 0) + { + // allocate channel B receive/transmit timer + m_rxtxcb_timer = timer_alloc(&m_machine, dart_channel::static_rxtxcb_tick, (void *)&m_channel[Z80DART_CH_B]); + timer_adjust_periodic(m_rxtxcb_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_rx_tx_clock_b)); + } + + state_save_register_device_item_array(this, 0, m_int_state); } -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ -#define RXD \ - devcb_call_read_line(&ch->in_rxd_func) +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- -#define TXD(_state) \ - devcb_call_write_line(&ch->out_txd_func, _state) +void z80dart_device::device_reset() +{ + LOG(("Z80DART \"%s\" Reset\n", tag())); + + for (int channel = Z80DART_CH_A; channel <= Z80DART_CH_B; channel++) + { + m_channel[channel].reset(); + } + + check_interrupts(); +} -#define RTS(_state) \ - devcb_call_write_line(&ch->out_rts_func, _state) -#define DTR(_state) \ - devcb_call_write_line(&ch->out_dtr_func, _state) -/*------------------------------------------------- - check_interrupts - control interrupt line --------------------------------------------------*/ +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** -static void check_interrupts(running_device *device) +//------------------------------------------------- +// z80daisy_irq_state - get interrupt status +//------------------------------------------------- + +int z80dart_device::z80daisy_irq_state() { - z80dart_t *z80dart = get_safe_token(device); - int state = (z80dart_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; + int state = 0; + int i; - devcb_call_write_line(&z80dart->out_int_func, state); + LOG(("Z80DART \"%s\" : Interrupt State B:%d%d%d%d A:%d%d%d%d\n", tag(), + m_int_state[0], m_int_state[1], m_int_state[2], m_int_state[3], + m_int_state[4], m_int_state[5], m_int_state[6], m_int_state[7])); + + // loop over all interrupt sources + for (i = 0; i < 8; i++) + { + // if we're servicing a request, don't indicate more interrupts + if (m_int_state[i] & Z80_DAISY_IEO) + { + state |= Z80_DAISY_IEO; + break; + } + state |= m_int_state[i]; + } + + LOG(("Z80DART \"%s\" : Interrupt State %u\n", tag(), state)); + + return state; } -/*------------------------------------------------- - take_interrupt - trigger interrupt --------------------------------------------------*/ -static void take_interrupt(running_device *device, int channel, int level) +//------------------------------------------------- +// z80daisy_irq_ack - interrupt acknowledge +//------------------------------------------------- + +int z80dart_device::z80daisy_irq_ack() { - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; - UINT8 vector = ch->wr[2]; - int priority = (channel << 2) | level; + int i; - LOG(("Z80DART \"%s\" Channel %c : Interrupt Request %u\n", device->tag(), 'A' + channel, level)); + LOG(("Z80DART \"%s\" Interrupt Acknowledge\n", tag())); - if ((channel == Z80DART_CH_B) && (ch->wr[1] & Z80DART_WR1_STATUS_VECTOR)) + // loop over all interrupt sources + for (i = 0; i < 8; i++) { - /* status affects vector */ - vector = (ch->wr[2] & 0xf1) | (!channel << 3) | (level << 1); + // find the first channel with an interrupt requested + if (m_int_state[i] & Z80_DAISY_INT) + { + // clear interrupt, switch to the IEO state, and update the IRQs + m_int_state[i] = Z80_DAISY_IEO; + m_channel[Z80DART_CH_A].m_rr[0] &= ~Z80DART_RR0_INTERRUPT_PENDING; + check_interrupts(); + + LOG(("Z80DART \"%s\" : Interrupt Acknowledge Vector %02x\n", tag(), m_channel[Z80DART_CH_B].m_rr[2])); + + return m_channel[Z80DART_CH_B].m_rr[2]; + } } - /* update vector register */ - ch->rr[2] = vector; + logerror("z80dart_irq_ack: failed to find an interrupt to ack!\n"); + + return m_channel[Z80DART_CH_B].m_rr[2]; +} - /* trigger interrupt */ - z80dart->int_state[priority] |= Z80_DAISY_INT; - z80dart->channel[Z80DART_CH_A].rr[0] |= Z80DART_RR0_INTERRUPT_PENDING; - /* check for interrupt */ - check_interrupts(device); +//------------------------------------------------- +// z80daisy_irq_reti - return from interrupt +//------------------------------------------------- + +void z80dart_device::z80daisy_irq_reti() +{ + int i; + + LOG(("Z80DART \"%s\" Return from Interrupt\n", tag())); + + // loop over all interrupt sources + for (i = 0; i < 8; i++) + { + // find the first channel with an IEO pending + if (m_int_state[i] & Z80_DAISY_IEO) + { + // clear the IEO state and update the IRQs + m_int_state[i] &= ~Z80_DAISY_IEO; + check_interrupts(); + return; + } + } + + logerror("z80dart_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -/*------------------------------------------------- - get_clock_mode - get clock divisor --------------------------------------------------*/ -static int get_clock_mode(dart_channel *ch) + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +//------------------------------------------------- +// check_interrupts - control interrupt line +//------------------------------------------------- + +void z80dart_device::check_interrupts() +{ + int state = (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE; + devcb_call_write_line(&m_out_int_func, state); +} + + +//------------------------------------------------- +// take_interrupt - trigger interrupt +//------------------------------------------------- + +void z80dart_device::take_interrupt(int priority) +{ + m_int_state[priority] |= Z80_DAISY_INT; + m_channel[Z80DART_CH_A].m_rr[0] |= Z80DART_RR0_INTERRUPT_PENDING; + + // check for interrupt + check_interrupts(); +} + + + +//************************************************************************** +// DART CHANNEL +//************************************************************************** + +//------------------------------------------------- +// dart_channel - constructor +//------------------------------------------------- + +z80dart_device::dart_channel::dart_channel() + : m_rx_shift(0), + m_rx_error(0), + m_rx_fifo(0), + m_rx_clock(0), + m_rx_state(0), + m_rx_bits(0), + m_rx_first(0), + m_rx_parity(0), + m_rx_break(0), + m_rx_rr0_latch(0), + m_ri(0), + m_cts(0), + m_dcd(0), + m_tx_data(0), + m_tx_shift(0), + m_tx_clock(0), + m_tx_state(0), + m_tx_bits(0), + m_tx_parity(0), + m_dtr(0), + m_rts(0) +{ + memset(&m_in_rxd_func, 0, sizeof(m_in_rxd_func)); + memset(&m_out_txd_func, 0, sizeof(m_out_txd_func)); + memset(&m_out_dtr_func, 0, sizeof(m_out_dtr_func)); + memset(&m_out_rts_func, 0, sizeof(m_out_rts_func)); + memset(&m_out_wrdy_func, 0, sizeof(m_out_wrdy_func)); + memset(&m_rr, 0, sizeof(m_rr)); + memset(&m_wr, 0, sizeof(m_wr)); + memset(&m_rx_data_fifo, 0, sizeof(m_rx_data_fifo)); + memset(&m_rx_error_fifo, 0, sizeof(m_rx_error_fifo)); +} + + +//------------------------------------------------- +// start - channel startup +//------------------------------------------------- + +void z80dart_device::dart_channel::start(z80dart_device *device, int index, const devcb_read_line &in_rxd, const devcb_write_line &out_txd, const devcb_write_line &out_dtr, const devcb_write_line &out_rts, const devcb_write_line &out_wrdy) +{ + m_index = index; + + devcb_resolve_read_line(&m_in_rxd_func, &in_rxd, m_device); + devcb_resolve_write_line(&m_out_txd_func, &out_txd, m_device); + devcb_resolve_write_line(&m_out_dtr_func, &out_dtr, m_device); + devcb_resolve_write_line(&m_out_rts_func, &out_rts, m_device); + devcb_resolve_write_line(&m_out_wrdy_func, &out_wrdy, m_device); + + state_save_register_device_item_array(m_device, m_index, m_rr); + state_save_register_device_item_array(m_device, m_index, m_wr); + state_save_register_device_item_array(m_device, m_index, m_rx_data_fifo); + state_save_register_device_item_array(m_device, m_index, m_rx_error_fifo); + state_save_register_device_item(m_device, m_index, m_rx_shift); + state_save_register_device_item(m_device, m_index, m_rx_error); + state_save_register_device_item(m_device, m_index, m_rx_fifo); + state_save_register_device_item(m_device, m_index, m_rx_clock); + state_save_register_device_item(m_device, m_index, m_rx_state); + state_save_register_device_item(m_device, m_index, m_rx_bits); + state_save_register_device_item(m_device, m_index, m_rx_first); + state_save_register_device_item(m_device, m_index, m_rx_parity); + state_save_register_device_item(m_device, m_index, m_rx_break); + state_save_register_device_item(m_device, m_index, m_rx_rr0_latch); + state_save_register_device_item(m_device, m_index, m_ri); + state_save_register_device_item(m_device, m_index, m_cts); + state_save_register_device_item(m_device, m_index, m_dcd); + state_save_register_device_item(m_device, m_index, m_tx_data); + state_save_register_device_item(m_device, m_index, m_tx_shift); + state_save_register_device_item(m_device, m_index, m_tx_clock); + state_save_register_device_item(m_device, m_index, m_tx_state); + state_save_register_device_item(m_device, m_index, m_tx_bits); + state_save_register_device_item(m_device, m_index, m_tx_parity); + state_save_register_device_item(m_device, m_index, m_dtr); + state_save_register_device_item(m_device, m_index, m_rts); +} + + +//------------------------------------------------- +// take_interrupt - trigger interrupt +//------------------------------------------------- + +void z80dart_device::dart_channel::take_interrupt(int level) +{ + UINT8 vector = m_wr[2]; + int priority = (m_index << 2) | level; + + LOG(("Z80DART \"%s\" Channel %c : Interrupt Request %u\n", m_device->tag(), 'A' + m_index, level)); + + if ((m_index == Z80DART_CH_B) && (m_wr[1] & Z80DART_WR1_STATUS_VECTOR)) + { + // status affects vector + vector = (m_wr[2] & 0xf1) | (!m_index << 3) | (level << 1); + } + + // update vector register + m_rr[2] = vector; + + // trigger interrupt + m_device->take_interrupt(priority); +} + + +//------------------------------------------------- +// get_clock_mode - get clock divisor +//------------------------------------------------- + +int z80dart_device::dart_channel::get_clock_mode() { int clocks = 1; - switch (ch->wr[4] & Z80DART_WR4_CLOCK_MODE_MASK) + switch (m_wr[4] & Z80DART_WR4_CLOCK_MODE_MASK) { case Z80DART_WR4_CLOCK_MODE_X1: clocks = 1; break; case Z80DART_WR4_CLOCK_MODE_X16: clocks = 16; break; @@ -280,15 +536,16 @@ static int get_clock_mode(dart_channel *ch) return clocks; } -/*------------------------------------------------- - get_stop_bits - get number of stop bits --------------------------------------------------*/ -static float get_stop_bits(dart_channel *ch) +//------------------------------------------------- +// get_stop_bits - get number of stop bits +//------------------------------------------------- + +float z80dart_device::dart_channel::get_stop_bits() { float bits = 1; - switch (ch->wr[4] & Z80DART_WR4_STOP_BITS_MASK) + switch (m_wr[4] & Z80DART_WR4_STOP_BITS_MASK) { case Z80DART_WR4_STOP_BITS_1: bits = 1; break; case Z80DART_WR4_STOP_BITS_1_5: bits = 1.5; break; @@ -298,15 +555,16 @@ static float get_stop_bits(dart_channel *ch) return bits; } -/*------------------------------------------------- - get_rx_word_length - get receive word length --------------------------------------------------*/ -static int get_rx_word_length(dart_channel *ch) +//------------------------------------------------- +// get_rx_word_length - get receive word length +//------------------------------------------------- + +int z80dart_device::dart_channel::get_rx_word_length() { int bits = 5; - switch (ch->wr[3] & Z80DART_WR3_RX_WORD_LENGTH_MASK) + switch (m_wr[3] & Z80DART_WR3_RX_WORD_LENGTH_MASK) { case Z80DART_WR3_RX_WORD_LENGTH_5: bits = 5; break; case Z80DART_WR3_RX_WORD_LENGTH_6: bits = 6; break; @@ -317,15 +575,16 @@ static int get_rx_word_length(dart_channel *ch) return bits; } -/*------------------------------------------------- - get_rx_word_length - get transmit word length --------------------------------------------------*/ -static int get_tx_word_length(dart_channel *ch) +//------------------------------------------------- +// get_tx_word_length - get transmit word length +//------------------------------------------------- + +int z80dart_device::dart_channel::get_tx_word_length() { int bits = 5; - switch (ch->wr[5] & Z80DART_WR5_TX_WORD_LENGTH_MASK) + switch (m_wr[5] & Z80DART_WR5_TX_WORD_LENGTH_MASK) { case Z80DART_WR5_TX_WORD_LENGTH_5: bits = 5; break; case Z80DART_WR5_TX_WORD_LENGTH_6: bits = 6; break; @@ -336,300 +595,293 @@ static int get_tx_word_length(dart_channel *ch) return bits; } -/*------------------------------------------------- - reset_channel - reset channel status --------------------------------------------------*/ -static void reset_channel(running_device *device, int channel) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// reset - reset channel status +//------------------------------------------------- - /* disable receiver */ - ch->wr[3] &= ~Z80DART_WR3_RX_ENABLE; - ch->rx_state = STATE_START; +void z80dart_device::dart_channel::reset() +{ + // disable receiver + m_wr[3] &= ~Z80DART_WR3_RX_ENABLE; + m_rx_state = STATE_START; - /* disable transmitter */ - ch->wr[5] &= ~Z80DART_WR5_TX_ENABLE; - ch->tx_state = STATE_START; + // disable transmitter + m_wr[5] &= ~Z80DART_WR5_TX_ENABLE; + m_tx_state = STATE_START; - /* reset external lines */ + // reset external lines RTS(1); DTR(1); - if (channel == Z80DART_CH_A) + if (m_index == Z80DART_CH_A) { - /* reset interrupt logic */ + // reset interrupt logic int i; for (i = 0; i < 8; i++) { - z80dart->int_state[i] = 0; + m_device->m_int_state[i] = 0; } - check_interrupts(device); + m_device->check_interrupts(); } } -/*------------------------------------------------- - detect_start_bit - detect start bit --------------------------------------------------*/ -static int detect_start_bit(dart_channel *ch) +//------------------------------------------------- +// detect_start_bit - detect start bit +//------------------------------------------------- + +int z80dart_device::dart_channel::detect_start_bit() { - if (!(ch->wr[3] & Z80DART_WR3_RX_ENABLE)) return 0; + if (!(m_wr[3] & Z80DART_WR3_RX_ENABLE)) return 0; return !RXD; } -/*------------------------------------------------- - shift_data_in - shift in serial data --------------------------------------------------*/ -static void shift_data_in(dart_channel *ch) +//------------------------------------------------- +// shift_data_in - shift in serial data +//------------------------------------------------- + +void z80dart_device::dart_channel::shift_data_in() { - if (ch->rx_bits < 8) + if (m_rx_bits < 8) { int rxd = RXD; - ch->rx_shift >>= 1; - ch->rx_shift = (rxd << 7) | (ch->rx_shift & 0x7f); - ch->rx_parity ^= rxd; - ch->rx_bits++; + m_rx_shift >>= 1; + m_rx_shift = (rxd << 7) | (m_rx_shift & 0x7f); + m_rx_parity ^= rxd; + m_rx_bits++; } } -/*------------------------------------------------- - character_completed - check if complete - data word has been transferred --------------------------------------------------*/ -static int character_completed(dart_channel *ch) +//------------------------------------------------- +// character_completed - check if complete +// data word has been transferred +//------------------------------------------------- + +bool z80dart_device::dart_channel::character_completed() { - return ch->rx_bits == get_rx_word_length(ch); + return m_rx_bits == get_rx_word_length(); } -/*------------------------------------------------- - detect_parity_error - detect parity error --------------------------------------------------*/ -static void detect_parity_error(running_device *device, int channel) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// detect_parity_error - detect parity error +//------------------------------------------------- - int parity = (ch->wr[1] & Z80DART_WR4_PARITY_EVEN) ? 1 : 0; +void z80dart_device::dart_channel::detect_parity_error() +{ + int parity = (m_wr[1] & Z80DART_WR4_PARITY_EVEN) ? 1 : 0; - if (RXD != (ch->rx_parity ^ parity)) + if (RXD != (m_rx_parity ^ parity)) { - /* parity error detected */ - ch->rx_error |= Z80DART_RR1_PARITY_ERROR; + // parity error detected + m_rx_error |= Z80DART_RR1_PARITY_ERROR; - switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) + switch (m_wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) { case Z80DART_WR1_RX_INT_FIRST: - if (!ch->rx_first) + if (!m_rx_first) { - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); } break; case Z80DART_WR1_RX_INT_ALL_PARITY: - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); break; case Z80DART_WR1_RX_INT_ALL: - take_interrupt(device, channel, INT_RECEIVE); + take_interrupt(INT_RECEIVE); break; } } } -/*------------------------------------------------- - detect_framing_error - detect framing error --------------------------------------------------*/ -static void detect_framing_error(running_device *device, int channel) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// detect_framing_error - detect framing error +//------------------------------------------------- +void z80dart_device::dart_channel::detect_framing_error() +{ if (!RXD) { - /* framing error detected */ - ch->rx_error |= Z80DART_RR1_FRAMING_ERROR; + // framing error detected + m_rx_error |= Z80DART_RR1_FRAMING_ERROR; - switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) + switch (m_wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) { case Z80DART_WR1_RX_INT_FIRST: - if (!ch->rx_first) + if (!m_rx_first) { - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); } break; case Z80DART_WR1_RX_INT_ALL_PARITY: case Z80DART_WR1_RX_INT_ALL: - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); break; } } } -/*------------------------------------------------- - receive - receive serial data --------------------------------------------------*/ -static void receive(running_device *device, int channel) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// receive - receive serial data +//------------------------------------------------- - float stop_bits = get_stop_bits(ch); +void z80dart_device::dart_channel::receive() +{ + float stop_bits = get_stop_bits(); - switch (ch->rx_state) + switch (m_rx_state) { case STATE_START: - /* check for start bit */ - if (detect_start_bit(ch)) + // check for start bit + if (detect_start_bit()) { - /* start bit detected */ - ch->rx_shift = 0; - ch->rx_error = 0; - ch->rx_bits = 0; - ch->rx_parity = 0; - - /* next bit is a data bit */ - ch->rx_state = STATE_DATA; + // start bit detected + m_rx_shift = 0; + m_rx_error = 0; + m_rx_bits = 0; + m_rx_parity = 0; + + // next bit is a data bit + m_rx_state = STATE_DATA; } break; case STATE_DATA: - /* shift bit into shift register */ - shift_data_in(ch); + // shift bit into shift register + shift_data_in(); - if (character_completed(ch)) + if (character_completed()) { - /* all data bits received */ - if (ch->wr[4] & Z80DART_WR4_PARITY_ENABLE) + // all data bits received + if (m_wr[4] & Z80DART_WR4_PARITY_ENABLE) { - /* next bit is the parity bit */ - ch->rx_state = STATE_PARITY; + // next bit is the parity bit + m_rx_state = STATE_PARITY; } else { - /* next bit is a STOP bit */ + // next bit is a STOP bit if (stop_bits == 1) - ch->rx_state = STATE_STOP2; + m_rx_state = STATE_STOP2; else - ch->rx_state = STATE_STOP; + m_rx_state = STATE_STOP; } } break; case STATE_PARITY: - /* shift bit into shift register */ - shift_data_in(ch); + // shift bit into shift register + shift_data_in(); - /* check for parity error */ - detect_parity_error(device, channel); + // check for parity error + detect_parity_error(); - /* next bit is a STOP bit */ + // next bit is a STOP bit if (stop_bits == 1) - ch->rx_state = STATE_STOP2; + m_rx_state = STATE_STOP2; else - ch->rx_state = STATE_STOP; + m_rx_state = STATE_STOP; break; case STATE_STOP: - /* shift bit into shift register */ - shift_data_in(ch); + // shift bit into shift register + shift_data_in(); - /* check for framing error */ - detect_framing_error(device, channel); + // check for framing error + detect_framing_error(); - /* next bit is the second STOP bit */ - ch->rx_state = STATE_STOP2; + // next bit is the second STOP bit + m_rx_state = STATE_STOP2; break; case STATE_STOP2: - /* shift bit into shift register */ - shift_data_in(ch); + // shift bit into shift register + shift_data_in(); - /* check for framing error */ - detect_framing_error(device, channel); + // check for framing error + detect_framing_error(); - /* store data into FIFO */ - z80dart_receive_data(device, channel, ch->rx_shift); + // store data into FIFO + receive_data(m_rx_shift); - /* next bit is the START bit */ - ch->rx_state = STATE_START; + // next bit is the START bit + m_rx_state = STATE_START; break; } } -/*------------------------------------------------- - transmit - transmit serial data --------------------------------------------------*/ -static void transmit(running_device *device, int channel) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// transmit - transmit serial data +//------------------------------------------------- - int word_length = get_tx_word_length(ch); - float stop_bits = get_stop_bits(ch); +void z80dart_device::dart_channel::transmit() +{ + int word_length = get_tx_word_length(); + float stop_bits = get_stop_bits(); - switch (ch->tx_state) + switch (m_tx_state) { case STATE_START: - if ((ch->wr[5] & Z80DART_WR5_TX_ENABLE) && !(ch->rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY)) + if ((m_wr[5] & Z80DART_WR5_TX_ENABLE) && !(m_rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY)) { - /* transmit start bit */ + // transmit start bit TXD(0); - ch->tx_bits = 0; - ch->tx_shift = ch->tx_data; + m_tx_bits = 0; + m_tx_shift = m_tx_data; - /* empty transmit buffer */ - ch->rr[0] |= Z80DART_RR0_TX_BUFFER_EMPTY; + // empty transmit buffer + m_rr[0] |= Z80DART_RR0_TX_BUFFER_EMPTY; - if (ch->wr[1] & Z80DART_WR1_TX_INT_ENABLE) - take_interrupt(device, channel, INT_TRANSMIT); + if (m_wr[1] & Z80DART_WR1_TX_INT_ENABLE) + take_interrupt(INT_TRANSMIT); - ch->tx_state = STATE_DATA; + m_tx_state = STATE_DATA; } - else if (ch->wr[5] & Z80DART_WR5_SEND_BREAK) + else if (m_wr[5] & Z80DART_WR5_SEND_BREAK) { - /* transmit break */ + // transmit break TXD(0); } else { - /* transmit marking line */ + // transmit marking line TXD(1); } break; case STATE_DATA: - /* transmit data bit */ - TXD(BIT(ch->tx_shift, 0)); + // transmit data bit + TXD(BIT(m_tx_shift, 0)); - /* shift data */ - ch->tx_shift >>= 1; - ch->tx_bits++; + // shift data + m_tx_shift >>= 1; + m_tx_bits++; - if (ch->rx_bits == word_length) + if (m_rx_bits == word_length) { - if (ch->wr[4] & Z80DART_WR4_PARITY_ENABLE) - ch->tx_state = STATE_PARITY; + if (m_wr[4] & Z80DART_WR4_PARITY_ENABLE) + m_tx_state = STATE_PARITY; else { if (stop_bits == 1) - ch->tx_state = STATE_STOP2; + m_tx_state = STATE_STOP2; else - ch->tx_state = STATE_STOP; + m_tx_state = STATE_STOP; } } break; @@ -637,91 +889,86 @@ static void transmit(running_device *device, int channel) case STATE_PARITY: // TODO: calculate parity if (stop_bits == 1) - ch->tx_state = STATE_STOP2; + m_tx_state = STATE_STOP2; else - ch->tx_state = STATE_STOP; + m_tx_state = STATE_STOP; break; case STATE_STOP: - /* transmit stop bit */ + // transmit stop bit TXD(1); - ch->tx_state = STATE_STOP2; + m_tx_state = STATE_STOP2; break; case STATE_STOP2: - /* transmit stop bit */ + // transmit stop bit TXD(1); - /* if transmit buffer is empty */ - if (ch->rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY) + // if transmit buffer is empty + if (m_rr[0] & Z80DART_RR0_TX_BUFFER_EMPTY) { - /* then all characters have been sent */ - ch->rr[1] |= Z80DART_RR1_ALL_SENT; + // then all characters have been sent + m_rr[1] |= Z80DART_RR1_ALL_SENT; - /* when the RTS bit is reset, the _RTS output goes high after the transmitter empties */ - if (!ch->rts) + // when the RTS bit is reset, the _RTS output goes high after the transmitter empties + if (!m_rts) RTS(1); } - ch->tx_state = STATE_START; + m_tx_state = STATE_START; break; } } -/*------------------------------------------------- - z80dart_c_r - read control register --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80dart_c_r ) +//------------------------------------------------- +// control_read - read control register +//------------------------------------------------- + +UINT8 z80dart_device::dart_channel::control_read() { - z80dart_t *z80dart = get_safe_token(device); - int channel = offset & 0x01; - dart_channel *ch = &z80dart->channel[channel]; UINT8 data = 0; - int reg = ch->wr[0] & Z80DART_WR0_REGISTER_MASK; + int reg = m_wr[0] & Z80DART_WR0_REGISTER_MASK; switch (reg) { case 0: case 1: - data = ch->rr[reg]; + data = m_rr[reg]; break; case 2: - /* channel B only */ - if (channel == Z80DART_CH_B) - data = ch->rr[reg]; + // channel B only + if (m_index == Z80DART_CH_B) + data = m_rr[reg]; break; } - LOG(("Z80DART \"%s\" Channel %c : Control Register Read '%02x'\n", device->tag(), 'A' + channel, data)); + LOG(("Z80DART \"%s\" Channel %c : Control Register Read '%02x'\n", m_device->tag(), 'A' + m_index, data)); return data; } -/*------------------------------------------------- - z80dart_c_w - write control register --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80dart_c_w ) -{ - z80dart_t *z80dart = get_safe_token(device); - int channel = offset & 0x01; - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// control_write - write control register +//------------------------------------------------- - int reg = ch->wr[0] & Z80DART_WR0_REGISTER_MASK; +void z80dart_device::dart_channel::control_write(UINT8 data) +{ + int reg = m_wr[0] & Z80DART_WR0_REGISTER_MASK; - LOG(("Z80DART \"%s\" Channel %c : Control Register Write '%02x'\n", device->tag(), 'A' + channel, data)); + LOG(("Z80DART \"%s\" Channel %c : Control Register Write '%02x'\n", m_device->tag(), 'A' + m_index, data)); - /* write data to selected register */ - ch->wr[reg] = data; + // write data to selected register + m_wr[reg] = data; if (reg != 0) { - /* mask out register index */ - ch->wr[0] &= ~Z80DART_WR0_REGISTER_MASK; + // mask out register index + m_wr[0] &= ~Z80DART_WR0_REGISTER_MASK; } switch (reg) @@ -730,621 +977,409 @@ WRITE8_DEVICE_HANDLER( z80dart_c_w ) switch (data & Z80DART_WR0_COMMAND_MASK) { case Z80DART_WR0_RESET_EXT_STATUS: - /* reset external/status interrupt */ - ch->rr[0] &= ~(Z80DART_RR0_DCD | Z80DART_RR0_RI | Z80DART_RR0_CTS | Z80DART_RR0_BREAK); + // reset external/status interrupt + m_rr[0] &= ~(Z80DART_RR0_DCD | Z80DART_RR0_RI | Z80DART_RR0_CTS | Z80DART_RR0_BREAK); - if (!ch->dcd) ch->rr[0] |= Z80DART_RR0_DCD; - if (ch->ri) ch->rr[0] |= Z80DART_RR0_RI; - if (ch->cts) ch->rr[0] |= Z80DART_RR0_CTS; + if (!m_dcd) m_rr[0] |= Z80DART_RR0_DCD; + if (m_ri) m_rr[0] |= Z80DART_RR0_RI; + if (m_cts) m_rr[0] |= Z80DART_RR0_CTS; - ch->rx_rr0_latch = 0; + m_rx_rr0_latch = 0; - LOG(("Z80DART \"%s\" Channel %c : Reset External/Status Interrupt\n", device->tag(), 'A' + channel)); + LOG(("Z80DART \"%s\" Channel %c : Reset External/Status Interrupt\n", m_device->tag(), 'A' + m_index)); break; case Z80DART_WR0_CHANNEL_RESET: - /* channel reset */ - LOG(("Z80DART \"%s\" Channel %c : Channel Reset\n", device->tag(), 'A' + channel)); - reset_channel(device, channel); + // channel reset + LOG(("Z80DART \"%s\" Channel %c : Channel Reset\n", m_device->tag(), 'A' + m_index)); + reset(); break; case Z80DART_WR0_ENABLE_INT_NEXT_RX: - /* enable interrupt on next receive character */ - LOG(("Z80DART \"%s\" Channel %c : Enable Interrupt on Next Received Character\n", device->tag(), 'A' + channel)); - ch->rx_first = 1; + // enable interrupt on next receive character + LOG(("Z80DART \"%s\" Channel %c : Enable Interrupt on Next Received Character\n", m_device->tag(), 'A' + m_index)); + m_rx_first = 1; break; case Z80DART_WR0_RESET_TX_INT: - /* reset transmitter interrupt pending */ - LOG(("Z80DART \"%s\" Channel %c : Reset Transmitter Interrupt Pending\n", device->tag(), 'A' + channel)); + // reset transmitter interrupt pending + LOG(("Z80DART \"%s\" Channel %c : Reset Transmitter Interrupt Pending\n", m_device->tag(), 'A' + m_index)); break; case Z80DART_WR0_ERROR_RESET: - /* error reset */ - LOG(("Z80DART \"%s\" Channel %c : Error Reset\n", device->tag(), 'A' + channel)); - ch->rr[1] &= ~(Z80DART_RR1_FRAMING_ERROR | Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR); + // error reset + LOG(("Z80DART \"%s\" Channel %c : Error Reset\n", m_device->tag(), 'A' + m_index)); + m_rr[1] &= ~(Z80DART_RR1_FRAMING_ERROR | Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR); break; case Z80DART_WR0_RETURN_FROM_INT: - /* return from interrupt */ - LOG(("Z80DART \"%s\" Channel %c : Return from Interrupt\n", device->tag(), 'A' + channel)); - z80dart_irq_reti(device); + // return from interrupt + LOG(("Z80DART \"%s\" Channel %c : Return from Interrupt\n", m_device->tag(), 'A' + m_index)); + m_device->z80daisy_irq_reti(); break; } break; case 1: - LOG(("Z80DART \"%s\" Channel %c : External Interrupt Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR1_EXT_INT_ENABLE) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Transmit Interrupt Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR1_TX_INT_ENABLE) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Status Affects Vector %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR1_STATUS_VECTOR) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Wait/Ready Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR1_WRDY_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : External Interrupt Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR1_EXT_INT_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Transmit Interrupt Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR1_TX_INT_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Status Affects Vector %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR1_STATUS_VECTOR) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Wait/Ready Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR1_WRDY_ENABLE) ? 1 : 0)); switch (data & Z80DART_WR1_RX_INT_ENABLE_MASK) { case Z80DART_WR1_RX_INT_DISABLE: - LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt Disabled\n", device->tag(), 'A' + channel)); + LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt Disabled\n", m_device->tag(), 'A' + m_index)); break; case Z80DART_WR1_RX_INT_FIRST: - LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on First Character\n", device->tag(), 'A' + channel)); + LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on First Character\n", m_device->tag(), 'A' + m_index)); break; case Z80DART_WR1_RX_INT_ALL_PARITY: - LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters, Parity Affects Vector\n", device->tag(), 'A' + channel)); + LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters, Parity Affects Vector\n", m_device->tag(), 'A' + m_index)); break; case Z80DART_WR1_RX_INT_ALL: - LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters\n", device->tag(), 'A' + channel)); + LOG(("Z80DART \"%s\" Channel %c : Receiver Interrupt on All Characters\n", m_device->tag(), 'A' + m_index)); break; } - check_interrupts(device); + m_device->check_interrupts(); break; case 2: - /* interrupt vector */ - check_interrupts(device); - LOG(("Z80DART \"%s\" Channel %c : Interrupt Vector %02x\n", device->tag(), 'A' + channel, data)); + // interrupt vector + m_device->check_interrupts(); + LOG(("Z80DART \"%s\" Channel %c : Interrupt Vector %02x\n", m_device->tag(), 'A' + m_index, data)); break; case 3: - LOG(("Z80DART \"%s\" Channel %c : Receiver Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR3_RX_ENABLE) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Auto Enables %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR3_AUTO_ENABLES) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Receiver Bits/Character %u\n", device->tag(), 'A' + channel, get_rx_word_length(ch))); + LOG(("Z80DART \"%s\" Channel %c : Receiver Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR3_RX_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Auto Enables %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR3_AUTO_ENABLES) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Receiver Bits/Character %u\n", m_device->tag(), 'A' + m_index, get_rx_word_length())); break; case 4: - LOG(("Z80DART \"%s\" Channel %c : Parity Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR4_PARITY_ENABLE) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Parity %s\n", device->tag(), 'A' + channel, (data & Z80DART_WR4_PARITY_EVEN) ? "Even" : "Odd")); - LOG(("Z80DART \"%s\" Channel %c : Stop Bits %f\n", device->tag(), 'A' + channel, get_stop_bits(ch))); - LOG(("Z80DART \"%s\" Channel %c : Clock Mode %uX\n", device->tag(), 'A' + channel, get_clock_mode(ch))); + LOG(("Z80DART \"%s\" Channel %c : Parity Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR4_PARITY_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Parity %s\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR4_PARITY_EVEN) ? "Even" : "Odd")); + LOG(("Z80DART \"%s\" Channel %c : Stop Bits %f\n", m_device->tag(), 'A' + m_index, get_stop_bits())); + LOG(("Z80DART \"%s\" Channel %c : Clock Mode %uX\n", m_device->tag(), 'A' + m_index, get_clock_mode())); break; case 5: - LOG(("Z80DART \"%s\" Channel %c : Transmitter Enable %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR5_TX_ENABLE) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Transmitter Bits/Character %u\n", device->tag(), 'A' + channel, get_tx_word_length(ch))); - LOG(("Z80DART \"%s\" Channel %c : Send Break %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR5_SEND_BREAK) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Request to Send %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR5_RTS) ? 1 : 0)); - LOG(("Z80DART \"%s\" Channel %c : Data Terminal Ready %u\n", device->tag(), 'A' + channel, (data & Z80DART_WR5_DTR) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Transmitter Enable %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR5_TX_ENABLE) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Transmitter Bits/Character %u\n", m_device->tag(), 'A' + m_index, get_tx_word_length())); + LOG(("Z80DART \"%s\" Channel %c : Send Break %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR5_SEND_BREAK) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Request to Send %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR5_RTS) ? 1 : 0)); + LOG(("Z80DART \"%s\" Channel %c : Data Terminal Ready %u\n", m_device->tag(), 'A' + m_index, (data & Z80DART_WR5_DTR) ? 1 : 0)); if (data & Z80DART_WR5_RTS) { - /* when the RTS bit is set, the _RTS output goes low */ + // when the RTS bit is set, the _RTS output goes low RTS(0); - ch->rts = 1; + m_rts = 1; } else { - /* when the RTS bit is reset, the _RTS output goes high after the transmitter empties */ - ch->rts = 0; + // when the RTS bit is reset, the _RTS output goes high after the transmitter empties + m_rts = 0; } - /* data terminal ready output follows the state programmed into the DTR bit*/ - ch->dtr = (data & Z80DART_WR5_DTR) ? 0 : 1; - DTR(ch->dtr); + // data terminal ready output follows the state programmed into the DTR bit*/ + m_dtr = (data & Z80DART_WR5_DTR) ? 0 : 1; + DTR(m_dtr); break; } } -/*------------------------------------------------- - z80dart_d_r - read data register --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80dart_d_r ) +//------------------------------------------------- +// data_read - read data register +//------------------------------------------------- + +UINT8 z80dart_device::dart_channel::data_read() { - z80dart_t *z80dart = get_safe_token(device); - int channel = offset & 0x01; - dart_channel *ch = &z80dart->channel[channel]; UINT8 data = 0; - if (ch->rx_fifo >= 0) + if (m_rx_fifo >= 0) { - /* load data from the FIFO */ - data = ch->rx_data_fifo[ch->rx_fifo]; + // load data from the FIFO + data = m_rx_data_fifo[m_rx_fifo]; - /* load error status from the FIFO, retain overrun and parity errors */ - ch->rr[1] = (ch->rr[1] & (Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR)) | ch->rx_error_fifo[ch->rx_fifo]; + // load error status from the FIFO, retain overrun and parity errors + m_rr[1] = (m_rr[1] & (Z80DART_RR1_RX_OVERRUN_ERROR | Z80DART_RR1_PARITY_ERROR)) | m_rx_error_fifo[m_rx_fifo]; - /* decrease FIFO pointer */ - ch->rx_fifo--; + // decrease FIFO pointer + m_rx_fifo--; - if (ch->rx_fifo < 0) + if (m_rx_fifo < 0) { - /* no more characters available in the FIFO */ - ch->rr[0] &= ~ Z80DART_RR0_RX_CHAR_AVAILABLE; + // no more characters available in the FIFO + m_rr[0] &= ~ Z80DART_RR0_RX_CHAR_AVAILABLE; } } - LOG(("Z80DART \"%s\" Channel %c : Data Register Read '%02x'\n", device->tag(), 'A' + channel, data)); + LOG(("Z80DART \"%s\" Channel %c : Data Register Read '%02x'\n", m_device->tag(), 'A' + m_index, data)); return data; } -/*------------------------------------------------- - z80dart_d_w - write data register --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80dart_d_w ) -{ - z80dart_t *z80dart = get_safe_token(device); - int channel = offset & 0x01; - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// data_write - write data register +//------------------------------------------------- - ch->tx_data = data; +void z80dart_device::dart_channel::data_write(UINT8 data) +{ + m_tx_data = data; - ch->rr[0] &= ~Z80DART_RR0_TX_BUFFER_EMPTY; - ch->rr[1] &= ~Z80DART_RR1_ALL_SENT; + m_rr[0] &= ~Z80DART_RR0_TX_BUFFER_EMPTY; + m_rr[1] &= ~Z80DART_RR1_ALL_SENT; - LOG(("Z80DART \"%s\" Channel %c : Data Register Write '%02x'\n", device->tag(), 'A' + channel, data)); + LOG(("Z80DART \"%s\" Channel %c : Data Register Write '%02x'\n", m_device->tag(), 'A' + m_index, data)); } -/*------------------------------------------------- - z80dart_receive_data - receive data word --------------------------------------------------*/ -void z80dart_receive_data(running_device *device, int channel, UINT8 data) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// receive_data - receive data word +//------------------------------------------------- - LOG(("Z80DART \"%s\" Channel %c : Receive Data Byte '%02x'\n", device->tag(), 'A' + channel, data)); +void z80dart_device::dart_channel::receive_data(UINT8 data) +{ + LOG(("Z80DART \"%s\" Channel %c : Receive Data Byte '%02x'\n", m_device->tag(), 'A' + m_index, data)); - if (ch->rx_fifo == 2) + if (m_rx_fifo == 2) { - /* receive overrun error detected */ - ch->rx_error |= Z80DART_RR1_RX_OVERRUN_ERROR; + // receive overrun error detected + m_rx_error |= Z80DART_RR1_RX_OVERRUN_ERROR; - switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) + switch (m_wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) { case Z80DART_WR1_RX_INT_FIRST: - if (!ch->rx_first) + if (!m_rx_first) { - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); } break; case Z80DART_WR1_RX_INT_ALL_PARITY: case Z80DART_WR1_RX_INT_ALL: - take_interrupt(device, channel, INT_SPECIAL); + take_interrupt(INT_SPECIAL); break; } } else { - ch->rx_fifo++; + m_rx_fifo++; } - /* store received character and error status into FIFO */ - ch->rx_data_fifo[ch->rx_fifo] = data; - ch->rx_error_fifo[ch->rx_fifo] = ch->rx_error; + // store received character and error status into FIFO + m_rx_data_fifo[m_rx_fifo] = data; + m_rx_error_fifo[m_rx_fifo] = m_rx_error; - ch->rr[0] |= Z80DART_RR0_RX_CHAR_AVAILABLE; + m_rr[0] |= Z80DART_RR0_RX_CHAR_AVAILABLE; - /* receive interrupt */ - switch (ch->wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) + // receive interrupt + switch (m_wr[1] & Z80DART_WR1_RX_INT_ENABLE_MASK) { case Z80DART_WR1_RX_INT_FIRST: - if (ch->rx_first) + if (m_rx_first) { - take_interrupt(device, channel, INT_RECEIVE); + take_interrupt(INT_RECEIVE); - ch->rx_first = 0; + m_rx_first = 0; } break; case Z80DART_WR1_RX_INT_ALL_PARITY: case Z80DART_WR1_RX_INT_ALL: - take_interrupt(device, channel, INT_RECEIVE); + take_interrupt(INT_RECEIVE); break; } } -/*------------------------------------------------- - cts_w - clear to send handler --------------------------------------------------*/ -static void cts_w(running_device *device, int channel, int state) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; +//------------------------------------------------- +// cts_w - clear to send handler +//------------------------------------------------- - LOG(("Z80DART \"%s\" Channel %c : CTS %u\n", device->tag(), 'A' + channel, state)); +void z80dart_device::dart_channel::cts_w(int state) +{ + LOG(("Z80DART \"%s\" Channel %c : CTS %u\n", m_device->tag(), 'A' + m_index, state)); - if (ch->cts != state) + if (m_cts != state) { - /* enable transmitter if in auto enables mode */ + // enable transmitter if in auto enables mode if (!state) - if (ch->wr[3] & Z80DART_WR3_AUTO_ENABLES) - ch->wr[5] |= Z80DART_WR5_TX_ENABLE; + if (m_wr[3] & Z80DART_WR3_AUTO_ENABLES) + m_wr[5] |= Z80DART_WR5_TX_ENABLE; - /* set clear to send */ - ch->cts = state; + // set clear to send + m_cts = state; - if (!ch->rx_rr0_latch) + if (!m_rx_rr0_latch) { - if (!ch->cts) - ch->rr[0] |= Z80DART_RR0_CTS; + if (!m_cts) + m_rr[0] |= Z80DART_RR0_CTS; else - ch->rr[0] &= ~Z80DART_RR0_CTS; + m_rr[0] &= ~Z80DART_RR0_CTS; - /* trigger interrupt */ - if (ch->wr[1] & Z80DART_WR1_EXT_INT_ENABLE) + // trigger interrupt + if (m_wr[1] & Z80DART_WR1_EXT_INT_ENABLE) { - /* trigger interrupt */ - take_interrupt(device, channel, INT_EXTERNAL); + // trigger interrupt + take_interrupt(INT_EXTERNAL); - /* latch read register 0 */ - ch->rx_rr0_latch = 1; + // latch read register 0 + m_rx_rr0_latch = 1; } } } } -/*------------------------------------------------- - z80dart_ctsa_w - clear to send (channel A) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_ctsa_w ) -{ - cts_w(device, Z80DART_CH_A, state); -} -/*------------------------------------------------- - z80dart_ctsb_w - clear to send (channel B) --------------------------------------------------*/ +//------------------------------------------------- +// dcd_w - data carrier detected handler +//------------------------------------------------- -WRITE_LINE_DEVICE_HANDLER( z80dart_ctsb_w ) +void z80dart_device::dart_channel::dcd_w(int state) { - cts_w(device, Z80DART_CH_B, state); -} - -/*------------------------------------------------- - dcd_w - data carrier detected handler --------------------------------------------------*/ - -static void dcd_w(running_device *device, int channel, int state) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; - - LOG(("Z80DART \"%s\" Channel %c : DCD %u\n", device->tag(), 'A' + channel, state)); + LOG(("Z80DART \"%s\" Channel %c : DCD %u\n", m_device->tag(), 'A' + m_index, state)); - if (ch->dcd != state) + if (m_dcd != state) { - /* enable receiver if in auto enables mode */ + // enable receiver if in auto enables mode if (!state) - if (ch->wr[3] & Z80DART_WR3_AUTO_ENABLES) - ch->wr[3] |= Z80DART_WR3_RX_ENABLE; + if (m_wr[3] & Z80DART_WR3_AUTO_ENABLES) + m_wr[3] |= Z80DART_WR3_RX_ENABLE; - /* set data carrier detect */ - ch->dcd = state; + // set data carrier detect + m_dcd = state; - if (!ch->rx_rr0_latch) + if (!m_rx_rr0_latch) { - if (ch->dcd) - ch->rr[0] |= Z80DART_RR0_DCD; + if (m_dcd) + m_rr[0] |= Z80DART_RR0_DCD; else - ch->rr[0] &= ~Z80DART_RR0_DCD; + m_rr[0] &= ~Z80DART_RR0_DCD; - if (ch->wr[1] & Z80DART_WR1_EXT_INT_ENABLE) + if (m_wr[1] & Z80DART_WR1_EXT_INT_ENABLE) { - /* trigger interrupt */ - take_interrupt(device, channel, INT_EXTERNAL); + // trigger interrupt + take_interrupt(INT_EXTERNAL); - /* latch read register 0 */ - ch->rx_rr0_latch = 1; + // latch read register 0 + m_rx_rr0_latch = 1; } } } } -/*------------------------------------------------- - z80dart_dcda_w - data carrier detected - (channel A) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_dcda_w ) -{ - dcd_w(device, Z80DART_CH_A, state); -} - -/*------------------------------------------------- - z80dart_dcdb_w - data carrier detected - (channel B) --------------------------------------------------*/ -WRITE_LINE_DEVICE_HANDLER( z80dart_dcdb_w ) -{ - dcd_w(device, Z80DART_CH_B, state); -} - -/*------------------------------------------------- - ri_w - ring indicator handler --------------------------------------------------*/ +//------------------------------------------------- +// ri_w - ring indicator handler +//------------------------------------------------- -static void ri_w(running_device *device, int channel, int state) +void z80dart_device::dart_channel::ri_w(int state) { - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[channel]; + LOG(("Z80DART \"%s\" Channel %c : RI %u\n", m_device->tag(), 'A' + m_index, state)); - LOG(("Z80DART \"%s\" Channel %c : RI %u\n", device->tag(), 'A' + channel, state)); - - if (ch->ri != state) + if (m_ri != state) { - /* set ring indicator state */ - ch->ri = state; + // set ring indicator state + m_ri = state; - if (!ch->rx_rr0_latch) + if (!m_rx_rr0_latch) { - if (ch->ri) - ch->rr[0] |= Z80DART_RR0_RI; + if (m_ri) + m_rr[0] |= Z80DART_RR0_RI; else - ch->rr[0] &= ~Z80DART_RR0_RI; + m_rr[0] &= ~Z80DART_RR0_RI; - if (ch->wr[1] & Z80DART_WR1_EXT_INT_ENABLE) + if (m_wr[1] & Z80DART_WR1_EXT_INT_ENABLE) { - /* trigger interrupt */ - take_interrupt(device, channel, INT_EXTERNAL); + // trigger interrupt + take_interrupt(INT_EXTERNAL); - /* latch read register 0 */ - ch->rx_rr0_latch = 1; + // latch read register 0 + m_rx_rr0_latch = 1; } } } } -/*------------------------------------------------- - z80dart_ria_w - ring indicator (channel A) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_ria_w ) -{ - ri_w(device, Z80DART_CH_A, state); -} - -/*------------------------------------------------- - z80dart_rib_w - ring indicator (channel B) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_rib_w ) -{ - ri_w(device, Z80DART_CH_B, state); -} -/*------------------------------------------------- - z80dart_rxca_w - receive clock (channel A) --------------------------------------------------*/ +//------------------------------------------------- +// rx_w - receive clock +//------------------------------------------------- -WRITE_LINE_DEVICE_HANDLER( z80dart_rxca_w ) +void z80dart_device::dart_channel::rx_w(int state) { - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[Z80DART_CH_A]; - - int clocks = get_clock_mode(ch); + int clocks = get_clock_mode(); if (!state) return; - LOG(("Z80DART \"%s\" Channel A : Receiver Clock Pulse\n", device->tag())); + LOG(("Z80DART \"%s\" Channel %c : Receiver Clock Pulse\n", m_device->tag(), m_index + 'A')); - ch->rx_clock++; - - if (ch->rx_clock == clocks) + m_rx_clock++; + if (m_rx_clock == clocks) { - ch->rx_clock = 0; - - /* receive data */ - receive(device, Z80DART_CH_A); + m_rx_clock = 0; + receive(); } } -/*------------------------------------------------- - z80dart_txca_w - transmit clock (channel A) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_txca_w ) -{ - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[Z80DART_CH_A]; - - int clocks = get_clock_mode(ch); - - if (!state) return; - LOG(("Z80DART \"%s\" Channel A : Transmitter Clock Pulse\n", device->tag())); +//------------------------------------------------- +// tx_w - transmit clock +//------------------------------------------------- - ch->tx_clock++; - - if (ch->tx_clock == clocks) - { - ch->tx_clock = 0; - - /* transmit data */ - transmit(device, Z80DART_CH_A); - } -} - -/*------------------------------------------------- - z80dart_rxtxcb_w - receive/transmit clock - (channel B) --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dart_rxtxcb_w ) +void z80dart_device::dart_channel::tx_w(int state) { - z80dart_t *z80dart = get_safe_token(device); - dart_channel *ch = &z80dart->channel[Z80DART_CH_B]; - - int clocks = get_clock_mode(ch); + int clocks = get_clock_mode(); if (!state) return; - LOG(("Z80DART \"%s\" Channel A : Receiver/Transmitter Clock Pulse\n", device->tag())); - - ch->rx_clock++; - ch->tx_clock++; + LOG(("Z80DART \"%s\" Channel %c : Transmitter Clock Pulse\n", m_device->tag(), m_index + 'A')); - if (ch->rx_clock == clocks) + m_tx_clock++; + if (m_tx_clock == clocks) { - ch->rx_clock = 0; - ch->tx_clock = 0; - - /* receive and transmit data */ - receive(device, Z80DART_CH_B); - transmit(device, Z80DART_CH_B); + m_tx_clock = 0; + transmit(); } } -/*------------------------------------------------- - TIMER_CALLBACK( rxca_tick ) --------------------------------------------------*/ -static TIMER_CALLBACK( rxca_tick ) -{ - z80dart_rxca_w((running_device *)ptr, 1); -} -/*------------------------------------------------- - TIMER_CALLBACK( txca_tick ) --------------------------------------------------*/ +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** -static TIMER_CALLBACK( txca_tick ) -{ - z80dart_txca_w((running_device *)ptr, 1); -} - -/*------------------------------------------------- - TIMER_CALLBACK( rxtxcb_tick ) --------------------------------------------------*/ - -static TIMER_CALLBACK( rxtxcb_tick ) -{ - z80dart_rxtxcb_w((running_device *)ptr, 1); -} +READ8_DEVICE_HANDLER( z80dart_c_r ) { return downcast(device)->control_read(offset & 1); } +READ8_DEVICE_HANDLER( z80dart_d_r ) { return downcast(device)->data_read(offset & 1); } -/*------------------------------------------------- - z80dart_irq_state - get interrupt status --------------------------------------------------*/ +WRITE8_DEVICE_HANDLER( z80dart_c_w ) { downcast(device)->control_write(offset & 1, data); } +WRITE8_DEVICE_HANDLER( z80dart_d_w ) { downcast(device)->data_write(offset & 1, data); } -static int z80dart_irq_state(running_device *device) -{ - z80dart_t *z80dart = get_safe_token( device ); - int state = 0; - int i; +WRITE_LINE_DEVICE_HANDLER( z80dart_ctsa_w ) { downcast(device)->cts_w(Z80DART_CH_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_ctsb_w ) { downcast(device)->cts_w(Z80DART_CH_B, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_dcda_w ) { downcast(device)->dcd_w(Z80DART_CH_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_dcdb_w ) { downcast(device)->dcd_w(Z80DART_CH_B, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_ria_w ) { downcast(device)->ri_w(Z80DART_CH_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_rib_w ) { downcast(device)->ri_w(Z80DART_CH_B, state); } - LOG(("Z80DART \"%s\" : Interrupt State B:%d%d%d%d A:%d%d%d%d\n", device->tag(), - z80dart->int_state[0], z80dart->int_state[1], z80dart->int_state[2], z80dart->int_state[3], - z80dart->int_state[4], z80dart->int_state[5], z80dart->int_state[6], z80dart->int_state[7])); - - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) - { - /* if we're servicing a request, don't indicate more interrupts */ - if (z80dart->int_state[i] & Z80_DAISY_IEO) - { - state |= Z80_DAISY_IEO; - break; - } - state |= z80dart->int_state[i]; - } - - LOG(("Z80DART \"%s\" : Interrupt State %u\n", device->tag(), state)); - - return state; -} - -/*------------------------------------------------- - z80dart_irq_ack - interrupt acknowledge --------------------------------------------------*/ - -static int z80dart_irq_ack(running_device *device) -{ - z80dart_t *z80dart = get_safe_token( device ); - int i; - - LOG(("Z80DART \"%s\" Interrupt Acknowledge\n", device->tag())); - - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) - { - /* find the first channel with an interrupt requested */ - if (z80dart->int_state[i] & Z80_DAISY_INT) - { - /* clear interrupt, switch to the IEO state, and update the IRQs */ - z80dart->int_state[i] = Z80_DAISY_IEO; - z80dart->channel[Z80DART_CH_A].rr[0] &= ~Z80DART_RR0_INTERRUPT_PENDING; - check_interrupts(device); - - LOG(("Z80DART \"%s\" : Interrupt Acknowledge Vector %02x\n", device->tag(), z80dart->channel[Z80DART_CH_B].rr[2])); - - return z80dart->channel[Z80DART_CH_B].rr[2]; - } - } - - logerror("z80dart_irq_ack: failed to find an interrupt to ack!\n"); - - return z80dart->channel[Z80DART_CH_B].rr[2]; -} - -/*------------------------------------------------- - z80dart_irq_reti - return from interrupt --------------------------------------------------*/ - -static void z80dart_irq_reti(running_device *device) -{ - z80dart_t *z80dart = get_safe_token( device ); - int i; - - LOG(("Z80DART \"%s\" Return from Interrupt\n", device->tag())); - - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) - { - /* find the first channel with an IEO pending */ - if (z80dart->int_state[i] & Z80_DAISY_IEO) - { - /* clear the IEO state and update the IRQs */ - z80dart->int_state[i] &= ~Z80_DAISY_IEO; - check_interrupts(device); - return; - } - } - - logerror("z80dart_irq_reti: failed to find an interrupt to clear IEO on!\n"); -} - -/*------------------------------------------------- - z80dart_cd_ba_r - register read --------------------------------------------------*/ +WRITE_LINE_DEVICE_HANDLER( z80dart_rxca_w ) { downcast(device)->rx_w(Z80DART_CH_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_txca_w ) { downcast(device)->tx_w(Z80DART_CH_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80dart_rxtxcb_w ) { downcast(device)->rx_w(Z80DART_CH_B, state); downcast(device)->tx_w(Z80DART_CH_B, state); } READ8_DEVICE_HANDLER( z80dart_cd_ba_r ) { return (offset & 2) ? z80dart_c_r(device, offset & 1) : z80dart_d_r(device, offset & 1); } -/*------------------------------------------------- - z80dart_cd_ba_w - register write --------------------------------------------------*/ - WRITE8_DEVICE_HANDLER( z80dart_cd_ba_w ) { if (offset & 2) @@ -1353,10 +1388,6 @@ WRITE8_DEVICE_HANDLER( z80dart_cd_ba_w ) z80dart_d_w(device, offset & 1, data); } -/*------------------------------------------------- - z80dart_ba_cd_r - register read --------------------------------------------------*/ - READ8_DEVICE_HANDLER( z80dart_ba_cd_r ) { int channel = BIT(offset, 1); @@ -1364,10 +1395,6 @@ READ8_DEVICE_HANDLER( z80dart_ba_cd_r ) return (offset & 1) ? z80dart_c_r(device, channel) : z80dart_d_r(device, channel); } -/*------------------------------------------------- - z80dart_ba_cd_w - register write --------------------------------------------------*/ - WRITE8_DEVICE_HANDLER( z80dart_ba_cd_w ) { int channel = BIT(offset, 1); @@ -1377,128 +1404,3 @@ WRITE8_DEVICE_HANDLER( z80dart_ba_cd_w ) else z80dart_d_w(device, channel, data); } - -/*------------------------------------------------- - DEVICE_START( z80dart ) --------------------------------------------------*/ - -static DEVICE_START( z80dart ) -{ - z80dart_t *z80dart = get_safe_token(device); - const z80dart_interface *intf = (const z80dart_interface *)device->baseconfig().static_config; - int channel; - - /* resolve callbacks */ - devcb_resolve_read_line(&z80dart->channel[Z80DART_CH_A].in_rxd_func, &intf->in_rxda_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_A].out_txd_func, &intf->out_txda_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_A].out_dtr_func, &intf->out_dtra_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_A].out_rts_func, &intf->out_rtsa_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_A].out_wrdy_func, &intf->out_wrdya_func, device); - devcb_resolve_read_line(&z80dart->channel[Z80DART_CH_B].in_rxd_func, &intf->in_rxdb_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_B].out_txd_func, &intf->out_txdb_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_B].out_dtr_func, &intf->out_dtrb_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_B].out_rts_func, &intf->out_rtsb_func, device); - devcb_resolve_write_line(&z80dart->channel[Z80DART_CH_B].out_wrdy_func, &intf->out_wrdyb_func, device); - devcb_resolve_write_line(&z80dart->out_int_func, &intf->out_int_func, device); - - if (intf->rx_clock_a) - { - /* allocate channel A receive timer */ - z80dart->rxca_timer = timer_alloc(device->machine, rxca_tick, (void *)device); - timer_adjust_periodic(z80dart->rxca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(intf->rx_clock_a)); - } - - if (intf->tx_clock_a) - { - /* allocate channel A transmit timer */ - z80dart->txca_timer = timer_alloc(device->machine, txca_tick, (void *)device); - timer_adjust_periodic(z80dart->txca_timer, attotime_zero, 0, ATTOTIME_IN_HZ(intf->tx_clock_a)); - } - - if (intf->rx_tx_clock_b) - { - /* allocate channel B receive/transmit timer */ - z80dart->rxtxcb_timer = timer_alloc(device->machine, rxtxcb_tick, (void *)device); - timer_adjust_periodic(z80dart->rxtxcb_timer, attotime_zero, 0, ATTOTIME_IN_HZ(intf->rx_tx_clock_b)); - } - - /* register for state saving */ - for (channel = Z80DART_CH_A; channel <= Z80DART_CH_B; channel++) - { - state_save_register_device_item_array(device, channel, z80dart->channel[channel].rr); - state_save_register_device_item_array(device, channel, z80dart->channel[channel].wr); - state_save_register_device_item_array(device, channel, z80dart->channel[channel].rx_data_fifo); - state_save_register_device_item_array(device, channel, z80dart->channel[channel].rx_error_fifo); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_shift); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_error); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_fifo); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_clock); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_state); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_bits); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_first); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_parity); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_break); - state_save_register_device_item(device, channel, z80dart->channel[channel].rx_rr0_latch); - state_save_register_device_item(device, channel, z80dart->channel[channel].ri); - state_save_register_device_item(device, channel, z80dart->channel[channel].cts); - state_save_register_device_item(device, channel, z80dart->channel[channel].dcd); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_data); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_shift); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_clock); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_state); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_bits); - state_save_register_device_item(device, channel, z80dart->channel[channel].tx_parity); - state_save_register_device_item(device, channel, z80dart->channel[channel].dtr); - state_save_register_device_item(device, channel, z80dart->channel[channel].rts); - } - - state_save_register_device_item_array(device, 0, z80dart->int_state); -} - -/*------------------------------------------------- - DEVICE_RESET( z80dart ) --------------------------------------------------*/ - -static DEVICE_RESET( z80dart ) -{ - int channel; - - LOG(("Z80DART \"%s\" Reset\n", device->tag())); - - for (channel = Z80DART_CH_A; channel <= Z80DART_CH_B; channel++) - { - reset_channel(device, channel); - } - - check_interrupts(device); -} - -/*------------------------------------------------- - DEVICE_GET_INFO( z80dart ) --------------------------------------------------*/ - -DEVICE_GET_INFO( z80dart ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80dart_t); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80dart); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80dart); break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80dart_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80dart_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80dart_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Zilog Z80 DART"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; - } -} diff --git a/src/emu/machine/z80dart.h b/src/emu/machine/z80dart.h index c6da23f6d6f..9a03dd3907e 100644 --- a/src/emu/machine/z80dart.h +++ b/src/emu/machine/z80dart.h @@ -30,21 +30,28 @@ ***************************************************************************/ -#ifndef __Z80DART_H_ -#define __Z80DART_H_ +#ifndef __Z80DART_H__ +#define __Z80DART_H__ -#include "devcb.h" +#include "cpu/z80/z80daisy.h" -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ -#define Z80DART DEVICE_GET_INFO_NAME(z80dart) -/* -#define Z8470 DEVICE_GET_INFO_NAME(z8470) -#define LH0081 DEVICE_GET_INFO_NAME(lh0088) -#define MK3881 DEVICE_GET_INFO_NAME(mk3888) -*/ + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +enum +{ + Z80DART_CH_A = 0, + Z80DART_CH_B +}; + + + +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_Z80DART_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, Z80DART, _clock) \ @@ -56,77 +63,254 @@ #define Z80DART_INTERFACE(_name) \ const z80dart_interface (_name) = -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -enum + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> z80dart_interface + +struct z80dart_interface { - Z80DART_CH_A = 0, - Z80DART_CH_B + int m_rx_clock_a; // channel A receive clock + int m_tx_clock_a; // channel A transmit clock + int m_rx_tx_clock_b; // channel B receive/transmit clock + + devcb_read_line m_in_rxda_func; + devcb_write_line m_out_txda_func; + devcb_write_line m_out_dtra_func; + devcb_write_line m_out_rtsa_func; + devcb_write_line m_out_wrdya_func; + + devcb_read_line m_in_rxdb_func; + devcb_write_line m_out_txdb_func; + devcb_write_line m_out_dtrb_func; + devcb_write_line m_out_rtsb_func; + devcb_write_line m_out_wrdyb_func; + + devcb_write_line m_out_int_func; +}; + + + +// ======================> z80dart_device_config + +class z80dart_device_config : public device_config, + public device_config_z80daisy_interface, + public z80dart_interface +{ + friend class z80dart_device; + + // construction/destruction + z80dart_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Zilog Z80 DART"; } + +protected: + // device_config overrides + virtual void device_config_complete(); }; -typedef struct _z80dart_interface z80dart_interface; -struct _z80dart_interface + + +// ======================> z80dart_device + +class z80dart_device : public device_t, + public device_z80daisy_interface { - int rx_clock_a; /* channel A receive clock */ - int tx_clock_a; /* channel A transmit clock */ - int rx_tx_clock_b; /* channel B receive/transmit clock */ - - devcb_read_line in_rxda_func; - devcb_write_line out_txda_func; - devcb_write_line out_dtra_func; - devcb_write_line out_rtsa_func; - devcb_write_line out_wrdya_func; - - devcb_read_line in_rxdb_func; - devcb_write_line out_txdb_func; - devcb_write_line out_dtrb_func; - devcb_write_line out_rtsb_func; - devcb_write_line out_wrdyb_func; - - devcb_write_line out_int_func; + friend class z80dart_device_config; + friend class dart_channel; + + // construction/destruction + z80dart_device(running_machine &_machine, const z80dart_device_config &_config); + +public: + // control register access + UINT8 control_read(int which) { return m_channel[which].control_read(); } + void control_write(int which, UINT8 data) { return m_channel[which].control_write(data); } + + // data register access + UINT8 data_read(int which) { return m_channel[which].data_read(); } + void data_write(int which, UINT8 data) { return m_channel[which].data_write(data); } + + // put data on the input lines + void receive_data(int which, UINT8 data) { m_channel[which].receive_data(data); } + + // control line access + void cts_w(int which, int state) { m_channel[which].cts_w(state); } + void dcd_w(int which, int state) { m_channel[which].dcd_w(state); } + void ri_w(int which, int state) { m_channel[which].ri_w(state); } + void rx_w(int which, int state) { m_channel[which].rx_w(state); } + void tx_w(int which, int state) { m_channel[which].tx_w(state); } + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal interrupt management + void check_interrupts(); + void take_interrupt(int priority); + + // a single channel on the DART + class dart_channel + { + friend class z80dart_device; + + public: + dart_channel(); + + void start(z80dart_device *device, int index, const devcb_read_line &in_rxd, const devcb_write_line &out_txd, const devcb_write_line &out_dtr, const devcb_write_line &out_rts, const devcb_write_line &out_wrdy); + void reset(); + + UINT8 control_read(); + void control_write(UINT8 data); + + UINT8 data_read(); + void data_write(UINT8 data); + + void receive_data(UINT8 data); + + void cts_w(int state); + void dcd_w(int state); + void ri_w(int state); + void rx_w(int state); + void tx_w(int state); + + private: + void take_interrupt(int level); + int get_clock_mode(); + float get_stop_bits(); + int get_rx_word_length(); + int get_tx_word_length(); + int detect_start_bit(); + void shift_data_in(); + bool character_completed(); + void detect_parity_error(); + void detect_framing_error(); + void receive(); + void transmit(); + + static TIMER_CALLBACK( static_rxca_tick ) { reinterpret_cast(ptr)->rx_w(1); } + static TIMER_CALLBACK( static_txca_tick ) { reinterpret_cast(ptr)->tx_w(1); } + static TIMER_CALLBACK( static_rxtxcb_tick ) { reinterpret_cast(ptr)->rx_w(1); reinterpret_cast(ptr)->tx_w(1); } + + z80dart_device *m_device; + int m_index; + + devcb_resolved_read_line m_in_rxd_func; + devcb_resolved_write_line m_out_txd_func; + devcb_resolved_write_line m_out_dtr_func; + devcb_resolved_write_line m_out_rts_func; + devcb_resolved_write_line m_out_wrdy_func; + + // register state + UINT8 m_rr[3]; // read register + UINT8 m_wr[6]; // write register + + // receiver state + UINT8 m_rx_data_fifo[3]; // receive data FIFO + UINT8 m_rx_error_fifo[3]; // receive error FIFO + UINT8 m_rx_shift; // 8-bit receive shift register + UINT8 m_rx_error; // current receive error + int m_rx_fifo; // receive FIFO pointer + + int m_rx_clock; // receive clock pulse count + int m_rx_state; // receive state + int m_rx_bits; // bits received + int m_rx_first; // first character received + int m_rx_parity; // received data parity + int m_rx_break; // receive break condition + UINT8 m_rx_rr0_latch; // read register 0 latched + + int m_ri; // ring indicator latch + int m_cts; // clear to send latch + int m_dcd; // data carrier detect latch + + // transmitter state + UINT8 m_tx_data; // transmit data register + UINT8 m_tx_shift; // transmit shift register + + int m_tx_clock; // transmit clock pulse count + int m_tx_state; // transmit state + int m_tx_bits; // bits transmitted + int m_tx_parity; // transmitted data parity + + int m_dtr; // data terminal ready + int m_rts; // request to send + }; + + // internal state + const z80dart_device_config & m_config; + devcb_resolved_write_line m_out_int_func; + dart_channel m_channel[2]; // channels + int m_int_state[8]; // interrupt state + + // timers + emu_timer * m_rxca_timer; + emu_timer * m_txca_timer; + emu_timer * m_rxtxcb_timer; }; -/*************************************************************************** - PROTOTYPES -***************************************************************************/ -/* register access */ +// device type definition +const device_type Z80DART = z80dart_device_config::static_alloc_device_config; +/* +#define Z8470 DEVICE_GET_INFO_NAME(z8470) +#define LH0081 DEVICE_GET_INFO_NAME(lh0088) +#define MK3881 DEVICE_GET_INFO_NAME(mk3888) +*/ + + + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + +// register access READ8_DEVICE_HANDLER( z80dart_cd_ba_r ); WRITE8_DEVICE_HANDLER( z80dart_cd_ba_w ); READ8_DEVICE_HANDLER( z80dart_ba_cd_r ); WRITE8_DEVICE_HANDLER( z80dart_ba_cd_w ); -/* control register access */ +// control register access WRITE8_DEVICE_HANDLER( z80dart_c_w ); READ8_DEVICE_HANDLER( z80dart_c_r ); -/* data register access */ +// data register access WRITE8_DEVICE_HANDLER( z80dart_d_w ); READ8_DEVICE_HANDLER( z80dart_d_r ); -/* serial clocks */ +// serial clocks WRITE_LINE_DEVICE_HANDLER( z80dart_rxca_w ); WRITE_LINE_DEVICE_HANDLER( z80dart_txca_w ); WRITE_LINE_DEVICE_HANDLER( z80dart_rxtxcb_w ); -/* ring indicator */ +// ring indicator WRITE_LINE_DEVICE_HANDLER( z80dart_ria_w ); WRITE_LINE_DEVICE_HANDLER( z80dart_rib_w ); -/* data carrier detected */ +// data carrier detected WRITE_LINE_DEVICE_HANDLER( z80dart_dcda_w ); WRITE_LINE_DEVICE_HANDLER( z80dart_dcdb_w ); -/* clear to send */ +// clear to send WRITE_LINE_DEVICE_HANDLER( z80dart_ctsa_w ); WRITE_LINE_DEVICE_HANDLER( z80dart_ctsb_w ); -/* receive data byte HACK */ -void z80dart_receive_data(running_device *device, int channel, UINT8 data); - -DEVICE_GET_INFO( z80dart ); #endif diff --git a/src/emu/machine/z80dma.c b/src/emu/machine/z80dma.c index c9adc428fe7..2073c7dbe5e 100644 --- a/src/emu/machine/z80dma.c +++ b/src/emu/machine/z80dma.c @@ -24,79 +24,11 @@ #include "z80dma.h" #include "cpu/z80/z80daisy.h" -/*************************************************************************** - PARAMETERS -***************************************************************************/ -#define LOG 0 -#define REGNUM(_m, _s) (((_m)<<3) + (_s)) -#define GET_REGNUM(_c, _r) (&(_r) - &(WR0(_c))) -#define REG(_c, _m, _s) (_c)->regs[REGNUM(_m,_s)] -#define WR0(_c) REG(_c, 0, 0) -#define WR1(_c) REG(_c, 1, 0) -#define WR2(_c) REG(_c, 2, 0) -#define WR3(_c) REG(_c, 3, 0) -#define WR4(_c) REG(_c, 4, 0) -#define WR5(_c) REG(_c, 5, 0) -#define WR6(_c) REG(_c, 6, 0) - -#define PORTA_ADDRESS_L(_c) REG(_c,0,1) -#define PORTA_ADDRESS_H(_c) REG(_c,0,2) - -#define BLOCKLEN_L(_c) REG(_c,0,3) -#define BLOCKLEN_H(_c) REG(_c,0,4) - -#define PORTA_TIMING(_c) REG(_c,1,1) -#define PORTB_TIMING(_c) REG(_c,2,1) - -#define MASK_BYTE(_c) REG(_c,3,1) -#define MATCH_BYTE(_c) REG(_c,3,2) - -#define PORTB_ADDRESS_L(_c) REG(_c,4,1) -#define PORTB_ADDRESS_H(_c) REG(_c,4,2) -#define INTERRUPT_CTRL(_c) REG(_c,4,3) -#define INTERRUPT_VECTOR(_c) REG(_c,4,4) -#define PULSE_CTRL(_c) REG(_c,4,5) - -#define READ_MASK(_c) REG(_c,6,1) - -#define PORTA_ADDRESS(_c) ((PORTA_ADDRESS_H(_c)<<8) | PORTA_ADDRESS_L(_c)) -#define PORTB_ADDRESS(_c) ((PORTB_ADDRESS_H(_c)<<8) | PORTB_ADDRESS_L(_c)) -#define BLOCKLEN(_c) ((BLOCKLEN_H(_c)<<8) | BLOCKLEN_L(_c)) - -#define PORTA_STEP(_c) (((WR1(_c) >> 4) & 0x03)*2-1) -#define PORTB_STEP(_c) (((WR2(_c) >> 4) & 0x03)*2-1) -#define PORTA_INC(_c) (WR1(_c) & 0x10) -#define PORTB_INC(_c) (WR2(_c) & 0x10) -#define PORTA_FIXED(_c) (((WR1(_c) >> 4) & 0x02) == 0x02) -#define PORTB_FIXED(_c) (((WR2(_c) >> 4) & 0x02) == 0x02) -#define PORTA_MEMORY(_c) (((WR1(_c) >> 3) & 0x01) == 0x00) -#define PORTB_MEMORY(_c) (((WR2(_c) >> 3) & 0x01) == 0x00) - -#define PORTA_CYCLE_LEN(_c) (4-(PORTA_TIMING(_c) & 0x03)) -#define PORTB_CYCLE_LEN(_c) (4-(PORTB_TIMING(_c) & 0x03)) - -#define PORTA_IS_SOURCE(_c) ((WR0(_c) >> 2) & 0x01) -#define PORTB_IS_SOURCE(_c) (!PORTA_IS_SOURCE(_c)) -#define TRANSFER_MODE(_c) (WR0(_c) & 0x03) - -#define MATCH_F_SET(_c) (_c->status &= ~0x10) -#define MATCH_F_CLEAR(_c) (_c->status |= 0x10) -#define EOB_F_SET(_c) (_c->status &= ~0x20) -#define EOB_F_CLEAR(_c) (_c->status |= 0x20) - -#define TM_TRANSFER (0x01) -#define TM_SEARCH (0x02) -#define TM_SEARCH_TRANSFER (0x03) - -#define READY_ACTIVE_HIGH(_c) ((WR5(_c)>>3) & 0x01) - -#define INTERRUPT_ENABLE(_c) (WR3(_c) & 0x20) -#define INT_ON_MATCH(_c) (INTERRUPT_CTRL(_c) & 0x01) -#define INT_ON_END_OF_BLOCK(_c) (INTERRUPT_CTRL(_c) & 0x02) -#define INT_ON_READY(_c) (INTERRUPT_CTRL(_c) & 0x40) -#define STATUS_AFFECTS_VECTOR(_c) (INTERRUPT_CTRL(_c) & 0x20) +//************************************************************************** +// CONSTANTS +//************************************************************************** enum { @@ -106,165 +38,413 @@ enum INT_MATCH_END_OF_BLOCK }; -#define COMMAND_RESET 0xc3 -#define COMMAND_RESET_PORT_A_TIMING 0xc7 -#define COMMAND_RESET_PORT_B_TIMING 0xcb -#define COMMAND_LOAD 0xcf -#define COMMAND_CONTINUE 0xd3 -#define COMMAND_DISABLE_INTERRUPTS 0xaf -#define COMMAND_ENABLE_INTERRUPTS 0xab -#define COMMAND_RESET_AND_DISABLE_INTERRUPTS 0xa3 -#define COMMAND_ENABLE_AFTER_RETI 0xb7 -#define COMMAND_READ_STATUS_BYTE 0xbf -#define COMMAND_REINITIALIZE_STATUS_BYTE 0x8b -#define COMMAND_INITIATE_READ_SEQUENCE 0xa7 -#define COMMAND_FORCE_READY 0xb3 -#define COMMAND_ENABLE_DMA 0x87 -#define COMMAND_DISABLE_DMA 0x83 -#define COMMAND_READ_MASK_FOLLOWS 0xbb - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -typedef struct _z80dma_t z80dma_t; -struct _z80dma_t +const int COMMAND_RESET = 0xc3; +const int COMMAND_RESET_PORT_A_TIMING = 0xc7; +const int COMMAND_RESET_PORT_B_TIMING = 0xcb; +const int COMMAND_LOAD = 0xcf; +const int COMMAND_CONTINUE = 0xd3; +const int COMMAND_DISABLE_INTERRUPTS = 0xaf; +const int COMMAND_ENABLE_INTERRUPTS = 0xab; +const int COMMAND_RESET_AND_DISABLE_INTERRUPTS = 0xa3; +const int COMMAND_ENABLE_AFTER_RETI = 0xb7; +const int COMMAND_READ_STATUS_BYTE = 0xbf; +const int COMMAND_REINITIALIZE_STATUS_BYTE = 0x8b; +const int COMMAND_INITIATE_READ_SEQUENCE = 0xa7; +const int COMMAND_FORCE_READY = 0xb3; +const int COMMAND_ENABLE_DMA = 0x87; +const int COMMAND_DISABLE_DMA = 0x83; +const int COMMAND_READ_MASK_FOLLOWS = 0xbb; + +const int TM_TRANSFER = 0x01; +const int TM_SEARCH = 0x02; +const int TM_SEARCH_TRANSFER = 0x03; + + + +//************************************************************************** +// MACROS +//************************************************************************** + +#define LOG 0 + +#define REGNUM(_m, _s) (((_m)<<3) + (_s)) +#define GET_REGNUM(_r) (&(_r) - &(WR0)) +#define REG(_m, _s) m_regs[REGNUM(_m,_s)] +#define WR0 REG(0, 0) +#define WR1 REG(1, 0) +#define WR2 REG(2, 0) +#define WR3 REG(3, 0) +#define WR4 REG(4, 0) +#define WR5 REG(5, 0) +#define WR6 REG(6, 0) + +#define PORTA_ADDRESS_L REG(0,1) +#define PORTA_ADDRESS_H REG(0,2) + +#define BLOCKLEN_L REG(0,3) +#define BLOCKLEN_H REG(0,4) + +#define PORTA_TIMING REG(1,1) +#define PORTB_TIMING REG(2,1) + +#define MASK_BYTE REG(3,1) +#define MATCH_BYTE REG(3,2) + +#define PORTB_ADDRESS_L REG(4,1) +#define PORTB_ADDRESS_H REG(4,2) +#define INTERRUPT_CTRL REG(4,3) +#define INTERRUPT_VECTOR REG(4,4) +#define PULSE_CTRL REG(4,5) + +#define READ_MASK REG(6,1) + +#define PORTA_ADDRESS ((PORTA_ADDRESS_H<<8) | PORTA_ADDRESS_L) +#define PORTB_ADDRESS ((PORTB_ADDRESS_H<<8) | PORTB_ADDRESS_L) +#define BLOCKLEN ((BLOCKLEN_H<<8) | BLOCKLEN_L) + +#define PORTA_STEP (((WR1 >> 4) & 0x03)*2-1) +#define PORTB_STEP (((WR2 >> 4) & 0x03)*2-1) +#define PORTA_INC (WR1 & 0x10) +#define PORTB_INC (WR2 & 0x10) +#define PORTA_FIXED (((WR1 >> 4) & 0x02) == 0x02) +#define PORTB_FIXED (((WR2 >> 4) & 0x02) == 0x02) +#define PORTA_MEMORY (((WR1 >> 3) & 0x01) == 0x00) +#define PORTB_MEMORY (((WR2 >> 3) & 0x01) == 0x00) + +#define PORTA_CYCLE_LEN (4-(PORTA_TIMING & 0x03)) +#define PORTB_CYCLE_LEN (4-(PORTB_TIMING & 0x03)) + +#define PORTA_IS_SOURCE ((WR0 >> 2) & 0x01) +#define PORTB_IS_SOURCE (!PORTA_IS_SOURCE) +#define TRANSFER_MODE (WR0 & 0x03) + +#define MATCH_F_SET (m_status &= ~0x10) +#define MATCH_F_CLEAR (m_status |= 0x10) +#define EOB_F_SET (m_status &= ~0x20) +#define EOB_F_CLEAR (m_status |= 0x20) + +#define READY_ACTIVE_HIGH ((WR5>>3) & 0x01) + +#define INTERRUPT_ENABLE (WR3 & 0x20) +#define INT_ON_MATCH (INTERRUPT_CTRL & 0x01) +#define INT_ON_END_OF_BLOCK (INTERRUPT_CTRL & 0x02) +#define INT_ON_READY (INTERRUPT_CTRL & 0x40) +#define STATUS_AFFECTS_VECTOR (INTERRUPT_CTRL & 0x20) + + + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// z80dma_device_config - constructor +//------------------------------------------------- + +z80dma_device_config::z80dma_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - devcb_resolved_write_line out_busreq_func; - devcb_resolved_write_line out_int_func; - devcb_resolved_write_line out_bao_func; - devcb_resolved_read8 in_mreq_func; - devcb_resolved_write8 out_mreq_func; - devcb_resolved_read8 in_iorq_func; - devcb_resolved_write8 out_iorq_func; - - emu_timer *timer; - - UINT16 regs[REGNUM(6,1)+1]; - UINT8 num_follow; - UINT8 cur_follow; - UINT8 regs_follow[4]; - UINT8 read_num_follow; - UINT8 read_cur_follow; - UINT8 read_regs_follow[7]; - UINT8 status; - UINT8 dma_enabled; - - UINT16 addressA; - UINT16 addressB; - UINT16 count; - - int rdy; - int force_ready; - UINT8 reset_pointer; - - UINT8 is_read; - UINT8 cur_cycle; - UINT8 latch; - - /* interrupts */ - int ip; /* interrupt pending */ - int ius; /* interrupt under service */ - UINT8 vector; /* interrupt vector */ -}; +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *z80dma_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(z80dma_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *z80dma_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80dma_device(machine, *this)); +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void z80dma_device_config::device_config_complete() +{ + // inherit a copy of the static data + const z80dma_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&m_out_busreq_func, 0, sizeof(m_out_busreq_func)); + memset(&m_out_int_func, 0, sizeof(m_out_int_func)); + memset(&m_out_bao_func, 0, sizeof(m_out_bao_func)); + memset(&m_in_mreq_func, 0, sizeof(m_in_mreq_func)); + memset(&m_out_mreq_func, 0, sizeof(m_out_mreq_func)); + memset(&m_in_iorq_func, 0, sizeof(m_in_iorq_func)); + memset(&m_out_iorq_func, 0, sizeof(m_out_iorq_func)); + } +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// z80dma_device - constructor +//------------------------------------------------- + +z80dma_device::z80dma_device(running_machine &_machine, const z80dma_device_config &_config) + : device_t(_machine, _config), + device_z80daisy_interface(_machine, _config, *this), + m_config(_config) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void z80dma_device::device_start() +{ + // resolve callbacks + devcb_resolve_write_line(&m_out_busreq_func, &m_config.m_out_busreq_func, this); + devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); + devcb_resolve_write_line(&m_out_bao_func, &m_config.m_out_bao_func, this); + devcb_resolve_read8(&m_in_mreq_func, &m_config.m_in_mreq_func, this); + devcb_resolve_write8(&m_out_mreq_func, &m_config.m_out_mreq_func, this); + devcb_resolve_read8(&m_in_iorq_func, &m_config.m_in_iorq_func, this); + devcb_resolve_write8(&m_out_iorq_func, &m_config.m_out_iorq_func, this); + + // allocate timer + m_timer = timer_alloc(&m_machine, static_timerproc, (void *)this); + + // register for state saving + state_save_register_device_item_array(this, 0, m_regs); + state_save_register_device_item_array(this, 0, m_regs_follow); + state_save_register_device_item(this, 0, m_num_follow); + state_save_register_device_item(this, 0, m_cur_follow); + state_save_register_device_item(this, 0, m_status); + state_save_register_device_item(this, 0, m_dma_enabled); + state_save_register_device_item(this, 0, m_vector); + state_save_register_device_item(this, 0, m_ip); + state_save_register_device_item(this, 0, m_ius); + state_save_register_device_item(this, 0, m_addressA); + state_save_register_device_item(this, 0, m_addressB); + state_save_register_device_item(this, 0, m_count); + state_save_register_device_item(this, 0, m_rdy); + state_save_register_device_item(this, 0, m_force_ready); + state_save_register_device_item(this, 0, m_is_read); + state_save_register_device_item(this, 0, m_cur_cycle); + state_save_register_device_item(this, 0, m_latch); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void z80dma_device::device_reset() +{ + m_status = 0; + m_rdy = 0; + m_force_ready = 0; + m_num_follow = 0; + m_dma_enabled = 0; + m_read_num_follow = m_read_cur_follow = 0; + m_reset_pointer = 0; + + // disable interrupts + WR3 &= ~0x20; + m_ip = 0; + m_ius = 0; + m_vector = 0; + + update_status(); +} + + + +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** + +//------------------------------------------------- +// z80daisy_irq_state - return the overall IRQ +// state for this device +//------------------------------------------------- + +int z80dma_device::z80daisy_irq_state() +{ + int state = 0; + + if (m_ip) + { + // interrupt pending + state = Z80_DAISY_INT; + } + else if (m_ius) + { + // interrupt under service + state = Z80_DAISY_IEO; + } + + if (LOG) logerror("Z80DMA '%s' Interrupt State: %u\n", tag(), state); + + return state; +} + + +//------------------------------------------------- +// z80daisy_irq_ack - acknowledge an IRQ and +// return the appropriate vector +//------------------------------------------------- + +int z80dma_device::z80daisy_irq_ack() +{ + if (m_ip) + { + if (LOG) logerror("Z80DMA '%s' Interrupt Acknowledge\n", tag()); + + // clear interrupt pending flag + m_ip = 0; + interrupt_check(); + + // set interrupt under service flag + m_ius = 1; + + // disable DMA + m_dma_enabled = 0; + + return m_vector; + } -static TIMER_CALLBACK( z80dma_timerproc ); -static void z80dma_update_status(running_device *device); -static int z80dma_irq_state(running_device *device); + logerror("z80dma_irq_ack: failed to find an interrupt to ack!\n"); -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ + return 0; +} -INLINE z80dma_t *get_safe_token(running_device *device) + +//------------------------------------------------- +// z80daisy_irq_reti - clear the interrupt +// pending state to allow other interrupts through +//------------------------------------------------- + +void z80dma_device::z80daisy_irq_reti() { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80DMA); - return (z80dma_t *) device->token; + if (m_ius) + { + if (LOG) logerror("Z80DMA '%s' Return from Interrupt\n", tag()); + + // clear interrupt under service flag + m_ius = 0; + interrupt_check(); + + return; + } + + logerror("z80dma_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ -/*------------------------------------------------- - interrupt_check - update IRQ line state --------------------------------------------------*/ -static void interrupt_check(z80dma_t *z80dma) +//************************************************************************** +// INTERNAL STATE MANAGEMENT +//************************************************************************** + +//------------------------------------------------- +// interrupt_check - update IRQ line state +//------------------------------------------------- + +int z80dma_device::is_ready() { - devcb_call_write_line(&z80dma->out_int_func, z80dma->ip ? ASSERT_LINE : CLEAR_LINE); + return (m_force_ready) || (m_rdy == READY_ACTIVE_HIGH); } -/*------------------------------------------------- - trigger_interrupt - trigger DMA interrupt --------------------------------------------------*/ -static void trigger_interrupt(running_device *device, int level) +//------------------------------------------------- +// interrupt_check - update IRQ line state +//------------------------------------------------- + +void z80dma_device::interrupt_check() { - z80dma_t *z80dma = get_safe_token(device); + devcb_call_write_line(&m_out_int_func, m_ip ? ASSERT_LINE : CLEAR_LINE); +} + + +//------------------------------------------------- +// trigger_interrupt - trigger DMA interrupt +//------------------------------------------------- - if (!z80dma->ius && INTERRUPT_ENABLE(z80dma)) +void z80dma_device::trigger_interrupt(int level) +{ + if (!m_ius && INTERRUPT_ENABLE) { - /* set interrupt pending flag */ - z80dma->ip = 1; + // set interrupt pending flag + m_ip = 1; - /* set interrupt vector */ - if (STATUS_AFFECTS_VECTOR(z80dma)) + // set interrupt vector + if (STATUS_AFFECTS_VECTOR) { - z80dma->vector = (INTERRUPT_VECTOR(z80dma) & 0xf9) | (level << 1); + m_vector = (INTERRUPT_VECTOR & 0xf9) | (level << 1); } else { - z80dma->vector = INTERRUPT_VECTOR(z80dma); + m_vector = INTERRUPT_VECTOR; } - z80dma->status &= ~0x08; + m_status &= ~0x08; - if (LOG) logerror("Z80DMA '%s' Interrupt Pending\n", device->tag()); + if (LOG) logerror("Z80DMA '%s' Interrupt Pending\n", tag()); - interrupt_check(z80dma); + interrupt_check(); } } -static int is_ready(z80dma_t *z80dma) -{ - return (z80dma->force_ready) || (z80dma->rdy == READY_ACTIVE_HIGH(z80dma)); -} -/*------------------------------------------------- - z80dma_do_read - perform DMA read --------------------------------------------------*/ +//------------------------------------------------- +// do_read - perform DMA read +//------------------------------------------------- -static void z80dma_do_read(running_device *device) +void z80dma_device::do_read() { - z80dma_t *z80dma = get_safe_token(device); UINT8 mode; - mode = TRANSFER_MODE(z80dma); + mode = TRANSFER_MODE; switch(mode) { case TM_TRANSFER: case TM_SEARCH: - if (PORTA_IS_SOURCE(z80dma)) + if (PORTA_IS_SOURCE) { - if (PORTA_MEMORY(z80dma)) - z80dma->latch = devcb_call_read8(&z80dma->in_mreq_func, z80dma->addressA); + if (PORTA_MEMORY) + m_latch = devcb_call_read8(&m_in_mreq_func, m_addressA); else - z80dma->latch = devcb_call_read8(&z80dma->in_iorq_func, z80dma->addressA); + m_latch = devcb_call_read8(&m_in_iorq_func, m_addressA); - if (LOG) logerror("A src: %04x \n",z80dma->addressA); - z80dma->addressA += PORTA_FIXED(z80dma) ? 0 : PORTA_INC(z80dma) ? PORTA_STEP(z80dma) : -PORTA_STEP(z80dma); + if (LOG) logerror("A src: %04x \n",m_addressA); + m_addressA += PORTA_FIXED ? 0 : PORTA_INC ? PORTA_STEP : -PORTA_STEP; } else { - if (PORTB_MEMORY(z80dma)) - z80dma->latch = devcb_call_read8(&z80dma->in_mreq_func, z80dma->addressB); + if (PORTB_MEMORY) + m_latch = devcb_call_read8(&m_in_mreq_func, m_addressB); else - z80dma->latch = devcb_call_read8(&z80dma->in_iorq_func, z80dma->addressB); + m_latch = devcb_call_read8(&m_in_iorq_func, m_addressB); - if (LOG) logerror("B src: %04x \n",z80dma->addressB); - z80dma->addressB += PORTB_FIXED(z80dma) ? 0 : PORTB_INC(z80dma) ? PORTB_STEP(z80dma) : -PORTB_STEP(z80dma); + if (LOG) logerror("B src: %04x \n",m_addressB); + m_addressB += PORTB_FIXED ? 0 : PORTB_INC ? PORTB_STEP : -PORTB_STEP; } break; case TM_SEARCH_TRANSFER: @@ -276,63 +456,63 @@ static void z80dma_do_read(running_device *device) } } -/*------------------------------------------------- - z80dma_do_write - perform DMA write --------------------------------------------------*/ -static int z80dma_do_write(running_device *device) +//------------------------------------------------- +// do_write - perform DMA write +//------------------------------------------------- + +int z80dma_device::do_write() { - z80dma_t *z80dma = get_safe_token(device); int done; UINT8 mode; - mode = TRANSFER_MODE(z80dma); - if (z80dma->count == 0x0000) + mode = TRANSFER_MODE; + if (m_count == 0x0000) { //FIXME: Any signal here } switch(mode) { case TM_TRANSFER: - if (PORTA_IS_SOURCE(z80dma)) + if (PORTA_IS_SOURCE) { - if (PORTB_MEMORY(z80dma)) - devcb_call_write8(&z80dma->out_mreq_func, z80dma->addressB, z80dma->latch); + if (PORTB_MEMORY) + devcb_call_write8(&m_out_mreq_func, m_addressB, m_latch); else - devcb_call_write8(&z80dma->out_iorq_func, z80dma->addressB, z80dma->latch); + devcb_call_write8(&m_out_iorq_func, m_addressB, m_latch); - if (LOG) logerror("B dst: %04x \n",z80dma->addressB); - z80dma->addressB += PORTB_FIXED(z80dma) ? 0 : PORTB_INC(z80dma) ? PORTB_STEP(z80dma) : -PORTB_STEP(z80dma); + if (LOG) logerror("B dst: %04x \n",m_addressB); + m_addressB += PORTB_FIXED ? 0 : PORTB_INC ? PORTB_STEP : -PORTB_STEP; } else { - if (PORTA_MEMORY(z80dma)) - devcb_call_write8(&z80dma->out_mreq_func, z80dma->addressA, z80dma->latch); + if (PORTA_MEMORY) + devcb_call_write8(&m_out_mreq_func, m_addressA, m_latch); else - devcb_call_write8(&z80dma->out_iorq_func, z80dma->addressA, z80dma->latch); + devcb_call_write8(&m_out_iorq_func, m_addressA, m_latch); - if (LOG) logerror("A dst: %04x \n",z80dma->addressA); - z80dma->addressA += PORTA_FIXED(z80dma) ? 0 : PORTA_INC(z80dma) ? PORTA_STEP(z80dma) : -PORTA_STEP(z80dma); + if (LOG) logerror("A dst: %04x \n",m_addressA); + m_addressA += PORTA_FIXED ? 0 : PORTA_INC ? PORTA_STEP : -PORTA_STEP; } - z80dma->count--; - done = (z80dma->count == 0xFFFF); + m_count--; + done = (m_count == 0xFFFF); break; case TM_SEARCH: { UINT8 load_byte,match_byte; - load_byte = z80dma->latch | MASK_BYTE(z80dma); - match_byte = MATCH_BYTE(z80dma) | MASK_BYTE(z80dma); + load_byte = m_latch | MASK_BYTE; + match_byte = MATCH_BYTE | MASK_BYTE; //if (LOG) logerror("%02x %02x\n",load_byte,match_byte)); if (load_byte == match_byte) { - if (INT_ON_MATCH(z80dma)) + if (INT_ON_MATCH) { - trigger_interrupt(device, INT_MATCH); + trigger_interrupt(INT_MATCH); } } - z80dma->count--; - done = (z80dma->count == 0xFFFF); //correct? + m_count--; + done = (m_count == 0xFFFF); //correct? } break; @@ -351,170 +531,174 @@ static int z80dma_do_write(running_device *device) return done; } -/*------------------------------------------------- - TIMER_CALLBACK( z80dma_timerproc ) --------------------------------------------------*/ -static TIMER_CALLBACK( z80dma_timerproc ) +//------------------------------------------------- +// timerproc +//------------------------------------------------- + +void z80dma_device::timerproc() { - running_device *device = (running_device *)ptr; - z80dma_t *z80dma = get_safe_token(device); int done; - if (--z80dma->cur_cycle) + if (--m_cur_cycle) { return; } - if (z80dma->is_read) + if (m_is_read) { - z80dma_do_read(device); + do_read(); done = 0; - z80dma->is_read = 0; - z80dma->cur_cycle = (PORTA_IS_SOURCE(z80dma) ? PORTA_CYCLE_LEN(z80dma) : PORTB_CYCLE_LEN(z80dma)); + m_is_read = false; + m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN); } else { - done = z80dma_do_write(device); - z80dma->is_read = 1; - z80dma->cur_cycle = (PORTB_IS_SOURCE(z80dma) ? PORTA_CYCLE_LEN(z80dma) : PORTB_CYCLE_LEN(z80dma)); + done = do_write(); + m_is_read = true; + m_cur_cycle = (PORTB_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN); } if (done) { - z80dma->dma_enabled = 0; //FIXME: Correct? - z80dma->status = 0x19; - - z80dma->status |= !is_ready(z80dma) << 1; // ready line status - - if(TRANSFER_MODE(z80dma) == TM_TRANSFER) z80dma->status |= 0x10; // no match found - - z80dma_update_status(device); - if (LOG) logerror("Z80DMA '%s' End of Block\n", device->tag()); - - if (INT_ON_END_OF_BLOCK(z80dma)) + m_dma_enabled = 0; //FIXME: Correct? + m_status = 0x19; + + m_status |= !is_ready() << 1; // ready line status + + if(TRANSFER_MODE == TM_TRANSFER) m_status |= 0x10; // no match found + + update_status(); + if (LOG) logerror("Z80DMA '%s' End of Block\n", tag()); + + if (INT_ON_END_OF_BLOCK) { - trigger_interrupt(device, INT_END_OF_BLOCK); + trigger_interrupt(INT_END_OF_BLOCK); } } } -/*------------------------------------------------- - z80dma_update_status - update DMA status --------------------------------------------------*/ -static void z80dma_update_status(running_device *device) +//------------------------------------------------- +// update_status - update DMA status +//------------------------------------------------- + +void z80dma_device::update_status() { - z80dma_t *z80dma = get_safe_token(device); UINT16 pending_transfer; attotime next; - /* no transfer is active right now; is there a transfer pending right now? */ - pending_transfer = is_ready(z80dma) & z80dma->dma_enabled; + // no transfer is active right now; is there a transfer pending right now? + pending_transfer = is_ready() & m_dma_enabled; if (pending_transfer) { - z80dma->is_read = 1; - z80dma->cur_cycle = (PORTA_IS_SOURCE(z80dma) ? PORTA_CYCLE_LEN(z80dma) : PORTB_CYCLE_LEN(z80dma)); - next = ATTOTIME_IN_HZ(device->clock); - timer_adjust_periodic(z80dma->timer, + m_is_read = true; + m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN); + next = ATTOTIME_IN_HZ(clock()); + timer_adjust_periodic(m_timer, attotime_zero, 0, - /* 1 byte transferred in 4 clock cycles */ + // 1 byte transferred in 4 clock cycles next); } else { - if (z80dma->is_read) + if (m_is_read) { - /* no transfers active right now */ - timer_reset(z80dma->timer, attotime_never); + // no transfers active right now + timer_reset(m_timer, attotime_never); } } - /* set the busreq line */ - devcb_call_write_line(&z80dma->out_busreq_func, pending_transfer ? ASSERT_LINE : CLEAR_LINE); + // set the busreq line + devcb_call_write_line(&m_out_busreq_func, pending_transfer ? ASSERT_LINE : CLEAR_LINE); } -/*------------------------------------------------- - z80dma_r - register read --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80dma_r ) + +//************************************************************************** +// READ/WRITE INTERFACES +//************************************************************************** + +//------------------------------------------------- +// read - register read +//------------------------------------------------- + +UINT8 z80dma_device::read() { - z80dma_t *z80dma = get_safe_token(device); UINT8 res; - res = z80dma->read_regs_follow[z80dma->read_cur_follow]; - z80dma->read_cur_follow++; + res = m_read_regs_follow[m_read_cur_follow]; + m_read_cur_follow++; - if(z80dma->read_cur_follow >= z80dma->read_num_follow) - z80dma->read_cur_follow = 0; + if(m_read_cur_follow >= m_read_num_follow) + m_read_cur_follow = 0; return res; } -/*------------------------------------------------- - z80dma_w - register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80dma_w ) -{ - z80dma_t *z80dma = get_safe_token(device); +//------------------------------------------------- +// write - register write +//------------------------------------------------- - if (z80dma->num_follow == 0) +void z80dma_device::write(UINT8 data) +{ + if (m_num_follow == 0) { if ((data & 0x87) == 0) // WR2 { - WR2(z80dma) = data; + WR2 = data; if (data & 0x40) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTB_TIMING(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_TIMING); } else if ((data & 0x87) == 0x04) // WR1 { - WR1(z80dma) = data; + WR1 = data; if (data & 0x40) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTA_TIMING(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_TIMING); } else if ((data & 0x80) == 0) // WR0 { - WR0(z80dma) = data; + WR0 = data; if (data & 0x08) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTA_ADDRESS_L(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_ADDRESS_L); if (data & 0x10) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTA_ADDRESS_H(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTA_ADDRESS_H); if (data & 0x20) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, BLOCKLEN_L(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(BLOCKLEN_L); if (data & 0x40) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, BLOCKLEN_H(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(BLOCKLEN_H); } else if ((data & 0x83) == 0x80) // WR3 { - WR3(z80dma) = data; + WR3 = data; if (data & 0x08) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, MASK_BYTE(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(MASK_BYTE); if (data & 0x10) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, MATCH_BYTE(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(MATCH_BYTE); } else if ((data & 0x83) == 0x81) // WR4 { - WR4(z80dma) = data; + WR4 = data; if (data & 0x04) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTB_ADDRESS_L(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_ADDRESS_L); if (data & 0x08) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PORTB_ADDRESS_H(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PORTB_ADDRESS_H); if (data & 0x10) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, INTERRUPT_CTRL(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(INTERRUPT_CTRL); } else if ((data & 0xC7) == 0x82) // WR5 { - WR5(z80dma) = data; + WR5 = data; } else if ((data & 0x83) == 0x83) // WR6 { - z80dma->dma_enabled = 0; + m_dma_enabled = 0; - WR6(z80dma) = data; + WR6 = data; + switch (data) { @@ -523,95 +707,94 @@ WRITE8_DEVICE_HANDLER( z80dma_w ) break; case COMMAND_READ_STATUS_BYTE: if (LOG) logerror("CMD Read status Byte\n"); - READ_MASK(z80dma) = 0; + READ_MASK = 0; break; case COMMAND_RESET_AND_DISABLE_INTERRUPTS: - WR3(z80dma) &= ~0x20; - z80dma->ip = 0; - z80dma->ius = 0; - z80dma->force_ready = 0; - z80dma->status |= 0x08; + WR3 &= ~0x20; + m_ip = 0; + m_ius = 0; + m_force_ready = 0; + m_status |= 0x08; break; case COMMAND_INITIATE_READ_SEQUENCE: if (LOG) logerror("Initiate Read Sequence\n"); - z80dma->read_cur_follow = z80dma->read_num_follow = 0; - if(READ_MASK(z80dma) & 0x01) { z80dma->read_regs_follow[z80dma->read_num_follow++] = z80dma->status; } - if(READ_MASK(z80dma) & 0x02) { z80dma->read_regs_follow[z80dma->read_num_follow++] = BLOCKLEN_L(z80dma); } //byte counter (low) - if(READ_MASK(z80dma) & 0x04) { z80dma->read_regs_follow[z80dma->read_num_follow++] = BLOCKLEN_H(z80dma); } //byte counter (high) - if(READ_MASK(z80dma) & 0x08) { z80dma->read_regs_follow[z80dma->read_num_follow++] = PORTA_ADDRESS_L(z80dma); } //port A address (low) - if(READ_MASK(z80dma) & 0x10) { z80dma->read_regs_follow[z80dma->read_num_follow++] = PORTA_ADDRESS_H(z80dma); } //port A address (high) - if(READ_MASK(z80dma) & 0x20) { z80dma->read_regs_follow[z80dma->read_num_follow++] = PORTB_ADDRESS_L(z80dma); } //port B address (low) - if(READ_MASK(z80dma) & 0x40) { z80dma->read_regs_follow[z80dma->read_num_follow++] = PORTA_ADDRESS_H(z80dma); } //port B address (high) + m_read_cur_follow = m_read_num_follow = 0; + if(READ_MASK & 0x01) { m_read_regs_follow[m_read_num_follow++] = m_status; } + if(READ_MASK & 0x02) { m_read_regs_follow[m_read_num_follow++] = BLOCKLEN_L; } //byte counter (low) + if(READ_MASK & 0x04) { m_read_regs_follow[m_read_num_follow++] = BLOCKLEN_H; } //byte counter (high) + if(READ_MASK & 0x08) { m_read_regs_follow[m_read_num_follow++] = PORTA_ADDRESS_L; } //port A address (low) + if(READ_MASK & 0x10) { m_read_regs_follow[m_read_num_follow++] = PORTA_ADDRESS_H; } //port A address (high) + if(READ_MASK & 0x20) { m_read_regs_follow[m_read_num_follow++] = PORTB_ADDRESS_L; } //port B address (low) + if(READ_MASK & 0x40) { m_read_regs_follow[m_read_num_follow++] = PORTA_ADDRESS_H; } //port B address (high) break; case COMMAND_RESET: if (LOG) logerror("Reset\n"); - z80dma->dma_enabled = 0; - z80dma->force_ready = 0; - /* Needs six reset commands to reset the DMA */ + m_dma_enabled = 0; + m_force_ready = 0; + // Needs six reset commands to reset the DMA { UINT8 WRi; for(WRi=0;WRi<7;WRi++) - REG(z80dma,WRi,z80dma->reset_pointer) = 0; + REG(WRi,m_reset_pointer) = 0; - z80dma->reset_pointer++; - if(z80dma->reset_pointer >= 6) { z80dma->reset_pointer = 0; } + m_reset_pointer++; + if(m_reset_pointer >= 6) { m_reset_pointer = 0; } } - z80dma->status = 0x38; + m_status = 0x38; break; case COMMAND_LOAD: - z80dma->force_ready = 0; - z80dma->addressA = PORTA_ADDRESS(z80dma); - z80dma->addressB = PORTB_ADDRESS(z80dma); - z80dma->count = BLOCKLEN(z80dma); - z80dma->status |= 0x30; - if (LOG) logerror("Load A: %x B: %x N: %x\n", z80dma->addressA, z80dma->addressB, z80dma->count); + m_force_ready = 0; + m_addressA = PORTA_ADDRESS; + m_addressB = PORTB_ADDRESS; + m_count = BLOCKLEN; + m_status |= 0x30; + if (LOG) logerror("Load A: %x B: %x N: %x\n", m_addressA, m_addressB, m_count); break; case COMMAND_DISABLE_DMA: if (LOG) logerror("Disable DMA\n"); - z80dma->dma_enabled = 0; + m_dma_enabled = 0; break; case COMMAND_ENABLE_DMA: if (LOG) logerror("Enable DMA\n"); - z80dma->dma_enabled = 1; - z80dma_update_status(device); + m_dma_enabled = 1; break; case COMMAND_READ_MASK_FOLLOWS: if (LOG) logerror("Set Read Mask\n"); - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, READ_MASK(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(READ_MASK); break; case COMMAND_CONTINUE: if (LOG) logerror("Continue\n"); - z80dma->count = BLOCKLEN(z80dma); - z80dma->dma_enabled = 1; + m_count = BLOCKLEN; + m_dma_enabled = 1; //"match not found" & "end of block" status flags zeroed here - z80dma->status |= 0x30; + m_status |= 0x30; break; case COMMAND_RESET_PORT_A_TIMING: if (LOG) logerror("Reset Port A Timing\n"); - PORTA_TIMING(z80dma) = 0; + PORTA_TIMING = 0; break; case COMMAND_RESET_PORT_B_TIMING: if (LOG) logerror("Reset Port B Timing\n"); - PORTB_TIMING(z80dma) = 0; + PORTB_TIMING = 0; break; case COMMAND_FORCE_READY: if (LOG) logerror("Force ready\n"); - z80dma->force_ready = 1; - z80dma_update_status(device); + m_force_ready = 1; + update_status(); break; case COMMAND_ENABLE_INTERRUPTS: if (LOG) logerror("Enable IRQ\n"); - WR3(z80dma) |= 0x20; + WR3 |= 0x20; break; case COMMAND_DISABLE_INTERRUPTS: if (LOG) logerror("Disable IRQ\n"); - WR3(z80dma) &= ~0x20; + WR3 &= ~0x20; break; case COMMAND_REINITIALIZE_STATUS_BYTE: if (LOG) logerror("Reinitialize status byte\n"); - z80dma->status |= 0x30; - z80dma->ip = 0; + m_status |= 0x30; + m_ip = 0; break; case 0xFB: if (LOG) logerror("Z80DMA undocumented command triggered 0x%02X!\n",data); @@ -622,146 +805,80 @@ WRITE8_DEVICE_HANDLER( z80dma_w ) } else fatalerror("Unknown base register %02x", data); - z80dma->cur_follow = 0; + m_cur_follow = 0; } else { - int nreg = z80dma->regs_follow[z80dma->cur_follow]; - z80dma->regs[nreg] = data; - z80dma->cur_follow++; - if (z80dma->cur_follow>=z80dma->num_follow) - z80dma->num_follow = 0; + int nreg = m_regs_follow[m_cur_follow]; + m_regs[nreg] = data; + m_cur_follow++; + if (m_cur_follow>=m_num_follow) + m_num_follow = 0; if (nreg == REGNUM(4,3)) { - z80dma->num_follow=0; + m_num_follow=0; if (data & 0x08) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, PULSE_CTRL(z80dma)); + m_regs_follow[m_num_follow++] = GET_REGNUM(PULSE_CTRL); if (data & 0x10) - z80dma->regs_follow[z80dma->num_follow++] = GET_REGNUM(z80dma, INTERRUPT_VECTOR(z80dma)); - z80dma->cur_follow = 0; + m_regs_follow[m_num_follow++] = GET_REGNUM(INTERRUPT_VECTOR); + m_cur_follow = 0; } } } -/*------------------------------------------------- - TIMER_CALLBACK( z80dma_rdy_write_callback ) --------------------------------------------------*/ -static TIMER_CALLBACK( z80dma_rdy_write_callback ) -{ - running_device *device = (running_device *)ptr; - z80dma_t *z80dma = get_safe_token(device); +//------------------------------------------------- +// rdy_write_callback - deferred RDY signal write +//------------------------------------------------- - z80dma->rdy = param; - z80dma->status = (z80dma->status & 0xFD) | (!is_ready(z80dma) << 1); +void z80dma_device::rdy_write_callback(int state) +{ + // normalize state + m_rdy = state; + m_status = (m_status & 0xFD) | (!is_ready() << 1); - z80dma_update_status(device); + update_status(); - if (is_ready(z80dma) && INT_ON_READY(z80dma)) + if (is_ready() && INT_ON_READY) { - trigger_interrupt(device, INT_RDY); + trigger_interrupt(INT_RDY); } } -/*------------------------------------------------- - z80dma_rdy_w - ready input --------------------------------------------------*/ -WRITE_LINE_DEVICE_HANDLER( z80dma_rdy_w ) -{ - z80dma_t *z80dma = get_safe_token(device); +//------------------------------------------------- +// rdy_w - ready input +//------------------------------------------------- - if (LOG) logerror("RDY: %d Active High: %d\n", state, READY_ACTIVE_HIGH(z80dma)); - - timer_call_after_resynch(device->machine, (void *) device, state, z80dma_rdy_write_callback); -} - -/*------------------------------------------------- - z80dma_wait_w - wait input --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dma_wait_w ) +void z80dma_device::rdy_w(int state) { + if (LOG) logerror("RDY: %d Active High: %d\n", state, READY_ACTIVE_HIGH); + timer_call_after_resynch(&m_machine, (void *)this, state, static_rdy_write_callback); } -/*------------------------------------------------- - z80dma_bai_w - bus acknowledge input --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80dma_bai_w ) -{ -} -/*------------------------------------------------- - z80dma_irq_state - read interrupt state --------------------------------------------------*/ +//------------------------------------------------- +// wait_w - wait input +//------------------------------------------------- -static int z80dma_irq_state(running_device *device) +void z80dma_device::wait_w(int state) { - z80dma_t *z80dma = get_safe_token(device); - int state = 0; - - if (z80dma->ip) - { - /* interrupt pending */ - state = Z80_DAISY_INT; - } - else if (z80dma->ius) - { - /* interrupt under service */ - state = Z80_DAISY_IEO; - } - - if (LOG) logerror("Z80DMA '%s' Interrupt State: %u\n", device->tag(), state); - - return state; } -/*------------------------------------------------- - z80dma_irq_ack - interrupt acknowledge --------------------------------------------------*/ - -static int z80dma_irq_ack(running_device *device) -{ - z80dma_t *z80dma = get_safe_token(device); - - if (z80dma->ip) - { - if (LOG) logerror("Z80DMA '%s' Interrupt Acknowledge\n", device->tag()); - - /* clear interrupt pending flag */ - z80dma->ip = 0; - interrupt_check(z80dma); - - /* set interrupt under service flag */ - z80dma->ius = 1; - - /* disable DMA */ - z80dma->dma_enabled = 0; - - return z80dma->vector; - } - - logerror("z80dma_irq_ack: failed to find an interrupt to ack!\n"); - - return 0; -} -/*------------------------------------------------- - z80dma_irq_reti - return from interrupt --------------------------------------------------*/ +//------------------------------------------------- +// bai_w - bus acknowledge input +//------------------------------------------------- -static void z80dma_irq_reti(running_device *device) +void z80dma_device::bai_w(int state) { - z80dma_t *z80dma = get_safe_token(device); - - if (z80dma->ius) + if (m_ius) { - if (LOG) logerror("Z80DMA '%s' Return from Interrupt\n", device->tag()); + if (LOG) logerror("Z80DMA '%s' Return from Interrupt\n", tag()); /* clear interrupt under service flag */ - z80dma->ius = 0; - interrupt_check(z80dma); + m_ius = 0; + interrupt_check(); return; } @@ -769,98 +886,15 @@ static void z80dma_irq_reti(running_device *device) logerror("z80dma_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -/*------------------------------------------------- - DEVICE_START( z80dma ) --------------------------------------------------*/ -static DEVICE_START( z80dma ) -{ - z80dma_t *z80dma = get_safe_token(device); - z80dma_interface *intf = (z80dma_interface *)device->baseconfig().static_config; - - /* resolve callbacks */ - devcb_resolve_write_line(&z80dma->out_busreq_func, &intf->out_busreq_func, device); - devcb_resolve_write_line(&z80dma->out_int_func, &intf->out_int_func, device); - devcb_resolve_write_line(&z80dma->out_bao_func, &intf->out_bao_func, device); - devcb_resolve_read8(&z80dma->in_mreq_func, &intf->in_mreq_func, device); - devcb_resolve_write8(&z80dma->out_mreq_func, &intf->out_mreq_func, device); - devcb_resolve_read8(&z80dma->in_iorq_func, &intf->in_iorq_func, device); - devcb_resolve_write8(&z80dma->out_iorq_func, &intf->out_iorq_func, device); - - /* allocate timer */ - z80dma->timer = timer_alloc(device->machine, z80dma_timerproc, (void *) device); - - /* register for state saving */ - state_save_register_device_item_array(device, 0, z80dma->regs); - state_save_register_device_item_array(device, 0, z80dma->regs_follow); - state_save_register_device_item(device, 0, z80dma->num_follow); - state_save_register_device_item(device, 0, z80dma->cur_follow); - state_save_register_device_item(device, 0, z80dma->status); - state_save_register_device_item(device, 0, z80dma->dma_enabled); - state_save_register_device_item(device, 0, z80dma->vector); - state_save_register_device_item(device, 0, z80dma->ip); - state_save_register_device_item(device, 0, z80dma->ius); - state_save_register_device_item(device, 0, z80dma->addressA); - state_save_register_device_item(device, 0, z80dma->addressB); - state_save_register_device_item(device, 0, z80dma->count); - state_save_register_device_item(device, 0, z80dma->rdy); - state_save_register_device_item(device, 0, z80dma->force_ready); - state_save_register_device_item(device, 0, z80dma->is_read); - state_save_register_device_item(device, 0, z80dma->cur_cycle); - state_save_register_device_item(device, 0, z80dma->latch); -} -/*------------------------------------------------- - DEVICE_RESET( z80dma ) --------------------------------------------------*/ - -static DEVICE_RESET( z80dma ) -{ - z80dma_t *z80dma = get_safe_token(device); - - z80dma->status = 0; - z80dma->rdy = 0; - z80dma->force_ready = 0; - z80dma->num_follow = 0; - z80dma->dma_enabled = 0; - z80dma->read_num_follow = z80dma->read_cur_follow = 0; - z80dma->reset_pointer = 0; - - /* disable interrupts */ - WR3(z80dma) &= ~0x20; - z80dma->ip = 0; - z80dma->ius = 0; - z80dma->vector = 0; - - z80dma_update_status(device); -} +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** -/*------------------------------------------------- - DEVICE_GET_INFO( z80dma ) --------------------------------------------------*/ +READ8_DEVICE_HANDLER( z80dma_r ) { return downcast(device)->read(); } +WRITE8_DEVICE_HANDLER( z80dma_w ) { downcast(device)->write(data); } -DEVICE_GET_INFO( z80dma ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80dma_t); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80dma);break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80dma);break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80dma_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80dma_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80dma_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Z8410"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; - } -} +WRITE_LINE_DEVICE_HANDLER( z80dma_rdy_w ) { downcast(device)->rdy_w(state); } +WRITE_LINE_DEVICE_HANDLER( z80dma_wait_w ) { downcast(device)->wait_w(state); } +WRITE_LINE_DEVICE_HANDLER( z80dma_bai_w ) { downcast(device)->bai_w(state); } diff --git a/src/emu/machine/z80dma.h b/src/emu/machine/z80dma.h index be08236d4bb..9f47ac02996 100644 --- a/src/emu/machine/z80dma.h +++ b/src/emu/machine/z80dma.h @@ -33,11 +33,12 @@ #ifndef __Z80DMA__ #define __Z80DMA__ -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ +#include "cpu/z80/z80daisy.h" -#define Z80DMA DEVICE_GET_INFO_NAME(z80dma) + +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_Z80DMA_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, Z80DMA, _clock) \ @@ -46,43 +47,163 @@ #define Z80DMA_INTERFACE(_name) \ const z80dma_interface (_name) = -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -typedef struct _z80dma_interface z80dma_interface; -struct _z80dma_interface + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> z80dma_interface + +struct z80dma_interface { - devcb_write_line out_busreq_func; - devcb_write_line out_int_func; - devcb_write_line out_bao_func; + devcb_write_line m_out_busreq_func; + devcb_write_line m_out_int_func; + devcb_write_line m_out_bao_func; - /* memory accessors */ - devcb_read8 in_mreq_func; - devcb_write8 out_mreq_func; + // memory accessors + devcb_read8 m_in_mreq_func; + devcb_write8 m_out_mreq_func; - /* I/O accessors */ - devcb_read8 in_iorq_func; - devcb_write8 out_iorq_func; + // I/O accessors + devcb_read8 m_in_iorq_func; + devcb_write8 m_out_iorq_func; }; -/*************************************************************************** - PROTOTYPES -***************************************************************************/ -DEVICE_GET_INFO( z80dma ); -/* register access */ +// ======================> z80dma_device_config + +class z80dma_device_config : public device_config, + public device_config_z80daisy_interface, + public z80dma_interface +{ + friend class z80dma_device; + + // construction/destruction + z80dma_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Z8410"; } + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + + +// ======================> z80dma_device + +class z80dma_device : public device_t, + public device_z80daisy_interface +{ + friend class z80dma_device_config; + + // construction/destruction + z80dma_device(running_machine &_machine, const z80dma_device_config &_config); + +public: + UINT8 read(); + void write(UINT8 data); + + void rdy_w(int state); + void wait_w(int state); + void bai_w(int state); + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal helpers + int is_ready(); + void interrupt_check(); + void trigger_interrupt(int level); + void do_read(); + int do_write(); + + static TIMER_CALLBACK( static_timerproc ) { reinterpret_cast(ptr)->timerproc(); } + void timerproc(); + + void update_status(); + + static TIMER_CALLBACK( static_rdy_write_callback ) { reinterpret_cast(ptr)->rdy_write_callback(param); } + void rdy_write_callback(int state); + + // internal state + const z80dma_device_config &m_config; + + devcb_resolved_write_line m_out_busreq_func; + devcb_resolved_write_line m_out_int_func; + devcb_resolved_write_line m_out_bao_func; + devcb_resolved_read8 m_in_mreq_func; + devcb_resolved_write8 m_out_mreq_func; + devcb_resolved_read8 m_in_iorq_func; + devcb_resolved_write8 m_out_iorq_func; + + emu_timer *m_timer; + + UINT16 m_regs[(6<<3)+1+1]; + UINT8 m_num_follow; + UINT8 m_cur_follow; + UINT8 m_regs_follow[4]; + UINT8 m_read_num_follow; + UINT8 m_read_cur_follow; + UINT8 m_read_regs_follow[7]; + UINT8 m_status; + UINT8 m_dma_enabled; + + UINT16 m_addressA; + UINT16 m_addressB; + UINT16 m_count; + + int m_rdy; + int m_force_ready; + UINT8 m_reset_pointer; + + bool m_is_read; + UINT8 m_cur_cycle; + UINT8 m_latch; + + // interrupts + int m_ip; // interrupt pending + int m_ius; // interrupt under service + UINT8 m_vector; // interrupt vector +}; + + +// device type definition +const device_type Z80DMA = z80dma_device_config::static_alloc_device_config; + + + +//************************************************************************** +// FUNCTION PROTOTYPES +//************************************************************************** + +// register access READ8_DEVICE_HANDLER( z80dma_r ); WRITE8_DEVICE_HANDLER( z80dma_w ); -/* ready */ +// ready WRITE_LINE_DEVICE_HANDLER( z80dma_rdy_w ); -/* wait */ +// wait WRITE_LINE_DEVICE_HANDLER( z80dma_wait_w ); -/* bus acknowledge in */ +// bus acknowledge in WRITE_LINE_DEVICE_HANDLER( z80dma_bai_w ); #endif diff --git a/src/emu/machine/z80pio.c b/src/emu/machine/z80pio.c index b7bf87fc4cf..0e1740bae2a 100644 --- a/src/emu/machine/z80pio.c +++ b/src/emu/machine/z80pio.c @@ -11,9 +11,11 @@ #include "z80pio.h" #include "cpu/z80/z80daisy.h" -/*************************************************************************** - PARAMETERS -***************************************************************************/ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** #define LOG 0 @@ -39,645 +41,511 @@ enum MASK }; -#define ICW_ENABLE_INT 0x80 -#define ICW_AND_OR 0x40 -#define ICW_AND 0x40 -#define ICW_OR 0x00 -#define ICW_HIGH_LOW 0x20 -#define ICW_HIGH 0x20 -#define ICW_LOW 0x00 -#define ICW_MASK_FOLLOWS 0x10 - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +const int ICW_ENABLE_INT = 0x80; +const int ICW_AND_OR = 0x40; +const int ICW_AND = 0x40; +const int ICW_OR = 0x00; +const int ICW_HIGH_LOW = 0x20; +const int ICW_HIGH = 0x20; +const int ICW_LOW = 0x00; +const int ICW_MASK_FOLLOWS = 0x10; -typedef struct _pio_port pio_port; -struct _pio_port -{ - devcb_resolved_read8 in_p_func; - devcb_resolved_write8 out_p_func; - devcb_resolved_write_line out_rdy_func; - - int mode; /* mode register */ - int next_control_word; /* next control word */ - UINT8 input; /* input latch */ - UINT8 output; /* output latch */ - UINT8 ior; /* input/output register */ - int rdy; /* ready */ - int stb; /* strobe */ - - /* interrupts */ - int ie; /* interrupt enabled */ - int ip; /* interrupt pending */ - int ius; /* interrupt under service */ - UINT8 icw; /* interrupt control word */ - UINT8 vector; /* interrupt vector */ - UINT8 mask; /* interrupt mask */ - int match; /* logic equation match */ -}; -typedef struct _z80pio_t z80pio_t; -struct _z80pio_t -{ - pio_port port[PORT_COUNT]; - devcb_resolved_write_line out_int_func; -}; +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +//------------------------------------------------- +// z80pio_device_config - constructor +//------------------------------------------------- -INLINE z80pio_t *get_safe_token(running_device *device) +z80pio_device_config::z80pio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80PIO); - return (z80pio_t *) device->token; } -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ -static void check_interrupts(running_device *device) +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *z80pio_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) { - z80pio_t *z80pio = get_safe_token(device); + return global_alloc(z80pio_device_config(mconfig, tag, owner, clock)); +} - int state = CLEAR_LINE; - for (int index = PORT_A; index < PORT_COUNT; index++) - { - pio_port *port = &z80pio->port[index]; +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- - if (port->mode == MODE_BIT_CONTROL) - { - /* fetch input data (ignore output lines) */ - UINT8 data = (port->input & port->ior) | (port->output & ~port->ior); - UINT8 mask = ~port->mask; - int match = 0; +device_t *z80pio_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80pio_device(machine, *this)); +} - data &= mask; - if ((port->icw & 0x60) == 0 && data != mask) match = 1; - else if ((port->icw & 0x60) == 0x20 && data != 0) match = 1; - else if ((port->icw & 0x60) == 0x40 && data == 0) match = 1; - else if ((port->icw & 0x60) == 0x60 && data == mask) match = 1; +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- - if (!port->match && match) - { - /* trigger interrupt */ - port->ip = 1; - if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", device->tag(), 'A' + index); - } - - port->match = match; - } - - if (port->ie && port->ip && !port->ius) - { - state = ASSERT_LINE; - } +void z80pio_device_config::device_config_complete() +{ + // inherit a copy of the static data + const z80pio_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + memset(&m_out_int_func, 0, sizeof(m_out_int_func)); + memset(&m_in_pa_func, 0, sizeof(m_in_pa_func)); + memset(&m_out_pa_func, 0, sizeof(m_out_pa_func)); + memset(&m_out_ardy_func, 0, sizeof(m_out_ardy_func)); + memset(&m_in_pb_func, 0, sizeof(m_in_pb_func)); + memset(&m_out_pb_func, 0, sizeof(m_out_pb_func)); + memset(&m_out_brdy_func, 0, sizeof(m_out_brdy_func)); } - - devcb_call_write_line(&z80pio->out_int_func, state); } -static void trigger_interrupt(running_device *device, int index) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[index]; - port->ip = 1; - if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", device->tag(), 'A' + index); - check_interrupts(device); -} +//************************************************************************** +// LIVE DEVICE +//************************************************************************** -static void set_rdy(running_device *device, int index, int state) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[index]; - - if (port->rdy == state) return; - - if (LOG) logerror("Z80PIO '%s' Port %c Ready: %u\n", device->tag(), 'A' + index, state); +//------------------------------------------------- +// z80pio_device - constructor +//------------------------------------------------- - port->rdy = state; - devcb_call_write_line(&port->out_rdy_func, state); +z80pio_device::z80pio_device(running_machine &_machine, const z80pio_device_config &config) + : device_t(_machine, config), + device_z80daisy_interface(_machine, config, *this), + m_config(config) +{ } -/*------------------------------------------------- - z80pio_c_r - control register read --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80pio_c_r ) +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void z80pio_device::device_start() { - z80pio_t *z80pio = get_safe_token(device); + m_port[PORT_A].start(this, PORT_A, m_config.m_in_pa_func, m_config.m_out_pa_func, m_config.m_out_ardy_func); + m_port[PORT_B].start(this, PORT_B, m_config.m_in_pb_func, m_config.m_out_pb_func, m_config.m_out_brdy_func); - return (z80pio->port[PORT_A].icw & 0xc0) | (z80pio->port[PORT_B].icw >> 4); + // resolve callbacks + devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); } -/*------------------------------------------------- - set_mode - set port mode --------------------------------------------------*/ -static void set_mode(running_device *device, int index, int mode) +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void z80pio_device::device_reset() { - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[index]; + // loop over ports + for (int index = PORT_A; index < PORT_COUNT; index++) + m_port[index].reset(); +} - if (LOG) logerror("Z80PIO '%s' Port %c Mode: %u\n", device->tag(), 'A' + index, mode); - switch (mode) - { - case MODE_OUTPUT: - /* enable data output */ - devcb_call_write8(&port->out_p_func, 0, port->output); - /* assert ready line */ - set_rdy(device, index, 1); +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** - /* set mode register */ - port->mode = mode; - break; +//------------------------------------------------- +// z80daisy_irq_state - return the overall IRQ +// state for this device +//------------------------------------------------- - case MODE_INPUT: - /* set mode register */ - port->mode = mode; - break; +int z80pio_device::z80daisy_irq_state() +{ + int state = 0; + + for (int index = PORT_A; index < PORT_COUNT; index++) + { + pio_port &port = m_port[index]; - case MODE_BIDIRECTIONAL: - if (index == PORT_B) + if (port.m_ius) { - logerror("Z80PIO '%s' Port %c Invalid Mode: %u!\n", device->tag(), 'A' + index, mode); + // interrupt under service + return Z80_DAISY_IEO; } - else + else if (port.m_ie && port.m_ip) { - /* set mode register */ - port->mode = mode; - } - break; - - case MODE_BIT_CONTROL: - if ((index == PORT_A) || (z80pio->port[PORT_A].mode != MODE_BIDIRECTIONAL)) - { - /* clear ready line */ - set_rdy(device, index, 0); + // interrupt pending + state = Z80_DAISY_INT; } - - /* disable interrupts until IOR is written */ - port->ie = 0; - check_interrupts(device); - - /* set logic equation to false */ - port->match = 0; - - /* next word is I/O register */ - port->next_control_word = IOR; - - /* set mode register */ - port->mode = mode; - break; } + + return state; } -/*------------------------------------------------- - z80pio_c_w - control register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80pio_c_w ) -{ - z80pio_t *z80pio = get_safe_token(device); - int index = offset & 0x01; - pio_port *port = &z80pio->port[index]; +//------------------------------------------------- +// z80daisy_irq_ack - acknowledge an IRQ and +// return the appropriate vector +//------------------------------------------------- - switch (port->next_control_word) +int z80pio_device::z80daisy_irq_ack() +{ + for (int index = PORT_A; index < PORT_COUNT; index++) { - case ANY: - if (!BIT(data, 0)) - { - /* load interrupt vector */ - port->vector = data; - if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Vector: %02x\n", device->tag(), 'A' + index, data); - - /* set interrupt enable */ - port->icw |= ICW_ENABLE_INT; - port->ie = 1; - check_interrupts(device); - } - else - { - switch (data & 0x0f) - { - case 0x0f: /* select operating mode */ - set_mode(device, index, data >> 6); - break; + pio_port &port = m_port[index]; - case 0x07: /* set interrupt control word */ - port->icw = data; - - if (LOG) - { - logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", device->tag(), 'A' + index, BIT(data, 7)); - logerror("Z80PIO '%s' Port %c Logic: %s\n", device->tag(), 'A' + index, BIT(data, 6) ? "AND" : "OR"); - logerror("Z80PIO '%s' Port %c Active %s\n", device->tag(), 'A' + index, BIT(data, 5) ? "High" : "Low"); - logerror("Z80PIO '%s' Port %c Mask Follows: %u\n", device->tag(), 'A' + index, BIT(data, 4)); - } - - if (port->icw & ICW_MASK_FOLLOWS) - { - /* disable interrupts until mask is written */ - port->ie = 0; - - /* reset pending interrupts */ - port->ip = 0; - check_interrupts(device); - - /* set logic equation to false */ - port->match = 0; + if (port.m_ip) + { + if (LOG) logerror("Z80PIO '%s' Interrupt Acknowledge\n", tag()); - /* next word is mask control */ - port->next_control_word = MASK; - } - break; + // clear interrupt pending flag + port.m_ip = 0; - case 0x03: /* set interrupt enable flip-flop */ - port->icw = (data & 0x80) | (port->icw & 0x7f); - if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", device->tag(), 'A' + index, BIT(data, 7)); + // set interrupt under service flag + port.m_ius = 1; - /* set interrupt enable */ - port->ie = BIT(port->icw, 7); - check_interrupts(device); - break; + check_interrupts(); - default: - logerror("Z80PIO '%s' Port %c Invalid Control Word: %02x!\n", device->tag(), 'A' + index, data); - } + return port.m_vector; } - break; - - case IOR: /* data direction register */ - port->ior = data; - if (LOG) logerror("Z80PIO '%s' Port %c IOR: %02x\n", device->tag(), 'A' + index, data); - - /* set interrupt enable */ - port->ie = BIT(port->icw, 7); - check_interrupts(device); - - /* next word is any */ - port->next_control_word = ANY; - break; - - case MASK: /* interrupt mask */ - port->mask = data; - if (LOG) logerror("Z80PIO '%s' Port %c Mask: %02x\n", device->tag(), 'A' + index, data); + } - /* set interrupt enable */ - port->ie = BIT(port->icw, 7); - check_interrupts(device); + logerror("z80pio_irq_ack: failed to find an interrupt to ack!\n"); - /* next word is any */ - port->next_control_word = ANY; - break; - } + return 0; } -/*------------------------------------------------- - z80pio_d_r - data register read --------------------------------------------------*/ - -READ8_DEVICE_HANDLER( z80pio_d_r ) -{ - z80pio_t *z80pio = get_safe_token(device); - int index = offset & 0x01; - pio_port *port = &z80pio->port[index]; - UINT8 data = 0; +//------------------------------------------------- +// z80daisy_irq_reti - clear the interrupt +// pending state to allow other interrupts through +//------------------------------------------------- - switch (port->mode) +void z80pio_device::z80daisy_irq_reti() +{ + for (int index = PORT_A; index < PORT_COUNT; index++) { - case MODE_OUTPUT: - data = port->output; - break; + pio_port &port = m_port[index]; - case MODE_INPUT: - if (!port->stb) + if (port.m_ius) { - /* input port data */ - port->input = devcb_call_read8(&port->in_p_func, 0); - } - - data = port->input; + if (LOG) logerror("Z80PIO '%s' Return from Interrupt\n", tag()); - /* clear ready line */ - set_rdy(device, index, 0); + // clear interrupt under service flag + port.m_ius = 0; + check_interrupts(); - /* assert ready line */ - set_rdy(device, index, 1); - break; + return; + } + } - case MODE_BIDIRECTIONAL: - data = port->input; + logerror("z80pio_irq_reti: failed to find an interrupt to clear IEO on!\n"); +} - /* clear ready line */ - set_rdy(device, PORT_B, 0); - /* assert ready line */ - set_rdy(device, PORT_B, 1); - break; - case MODE_BIT_CONTROL: - /* input port data */ - port->input = devcb_call_read8(&port->in_p_func, 0); +//************************************************************************** +// DEVICE-LEVEL IMPLEMENTATION +//************************************************************************** - data = (port->input & port->ior) | (port->output & (port->ior ^ 0xff)); - break; - } +//------------------------------------------------- +// control_read - control register read +//------------------------------------------------- - return data; +UINT8 z80pio_device::control_read() +{ + return (m_port[PORT_A].m_icw & 0xc0) | (m_port[PORT_B].m_icw >> 4); } -/*------------------------------------------------- - z80pio_d_w - data register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80pio_d_w ) +//------------------------------------------------- +// check_interrupts - update the interrupt state +// over all ports +//------------------------------------------------- + +void z80pio_device::check_interrupts() { - z80pio_t *z80pio = get_safe_token(device); - int index = offset & 0x01; - pio_port *port = &z80pio->port[index]; + int state = CLEAR_LINE; + + for (int index = PORT_A; index < PORT_COUNT; index++) + if (m_port[index].interrupt_signalled()) + state = ASSERT_LINE; - switch (port->mode) - { - case MODE_OUTPUT: - /* clear ready line */ - set_rdy(device, index, 0); + devcb_call_write_line(&m_out_int_func, state); +} - /* latch output data */ - port->output = data; - /* output data to port */ - devcb_call_write8(&port->out_p_func, 0, data); - /* assert ready line */ - set_rdy(device, index, 1); - break; +//************************************************************************** +// PORT-LEVEL IMPLEMENTATION +//************************************************************************** + +//------------------------------------------------- +// pio_port - constructor +//------------------------------------------------- + +z80pio_device::pio_port::pio_port() + : m_device(NULL), + m_index(0), + m_mode(0), + m_next_control_word(0), + m_input(0), + m_output(0), + m_ior(0), + m_rdy(0), + m_stb(0), + m_ie(0), + m_ip(0), + m_ius(0), + m_icw(0), + m_vector(0), + m_mask(0), + m_match(0) +{ + memset(&m_in_p_func, 0, sizeof(m_in_p_func)); + memset(&m_out_p_func, 0, sizeof(m_out_p_func)); + memset(&m_out_rdy_func, 0, sizeof(m_out_rdy_func)); +} - case MODE_INPUT: - /* latch output data */ - port->output = data; - break; - case MODE_BIDIRECTIONAL: - /* clear ready line */ - set_rdy(device, index, 0); +//------------------------------------------------- +// start - set up a port during device startup +//------------------------------------------------- + +void z80pio_device::pio_port::start(z80pio_device *device, int index, const devcb_read8 &infunc, const devcb_write8 &outfunc, const devcb_write_line &rdyfunc) +{ + m_device = device; + m_index = index; + + // resolve callbacks + devcb_resolve_read8(&m_in_p_func, &infunc, m_device); + devcb_resolve_write8(&m_out_p_func, &outfunc, m_device); + devcb_resolve_write_line(&m_out_rdy_func, &rdyfunc, m_device); + + // register for state saving + state_save_register_device_item(m_device, m_index, m_mode); + state_save_register_device_item(m_device, m_index, m_next_control_word); + state_save_register_device_item(m_device, m_index, m_input); + state_save_register_device_item(m_device, m_index, m_output); + state_save_register_device_item(m_device, m_index, m_ior); + state_save_register_device_item(m_device, m_index, m_rdy); + state_save_register_device_item(m_device, m_index, m_stb); + state_save_register_device_item(m_device, m_index, m_ie); + state_save_register_device_item(m_device, m_index, m_ip); + state_save_register_device_item(m_device, m_index, m_ius); + state_save_register_device_item(m_device, m_index, m_icw); + state_save_register_device_item(m_device, m_index, m_vector); + state_save_register_device_item(m_device, m_index, m_mask); + state_save_register_device_item(m_device, m_index, m_match); +} - /* latch output data */ - port->output = data; - if (!port->stb) - { - /* output data to port */ - devcb_call_write8(&port->out_p_func, 0, data); - } +//------------------------------------------------- +// reset - reset a port during device reset +//------------------------------------------------- - /* assert ready line */ - set_rdy(device, index, 1); - break; +void z80pio_device::pio_port::reset() +{ + // set mode 1 + set_mode(MODE_INPUT); - case MODE_BIT_CONTROL: - /* latch output data */ - port->output = data; + // reset interrupt enable flip-flops + m_icw &= ~ICW_ENABLE_INT; + m_ie = 0; + m_ip = 0; + m_ius = 0; + m_match = 0; - /* output data to port */ - devcb_call_write8(&port->out_p_func, 0, port->ior | (port->output & (port->ior ^ 0xff))); - break; - } -} + // reset all bits of the data I/O register + m_ior = 0; -/*------------------------------------------------- - z80pio_cd_ba_r - register read --------------------------------------------------*/ + // set all bits of the mask control register + m_mask = 0xff; -READ8_DEVICE_HANDLER( z80pio_cd_ba_r ) -{ - int index = BIT(offset, 0); + // reset output register + m_output = 0; - return BIT(offset, 1) ? z80pio_c_r(device, index) : z80pio_d_r(device, index); + // clear ready line + set_rdy(0); } -/*------------------------------------------------- - z80pio_cd_ba_w - register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80pio_cd_ba_w ) +//------------------------------------------------- +// interrupt_signalled - return true if an +// interrupt is signalled +//------------------------------------------------- + +bool z80pio_device::pio_port::interrupt_signalled() { - int index = BIT(offset, 0); + if (m_mode == MODE_BIT_CONTROL) + { + // fetch input data (ignore output lines) + UINT8 data = (m_input & m_ior) | (m_output & ~m_ior); + UINT8 mask = ~m_mask; + int match = 0; - BIT(offset, 1) ? z80pio_c_w(device, index, data) : z80pio_d_w(device, index, data); -} + data &= mask; -/*------------------------------------------------- - z80pio_ba_cd_r - register read --------------------------------------------------*/ + if ((m_icw & 0x60) == 0 && data != mask) match = 1; + else if ((m_icw & 0x60) == 0x20 && data != 0) match = 1; + else if ((m_icw & 0x60) == 0x40 && data == 0) match = 1; + else if ((m_icw & 0x60) == 0x60 && data == mask) match = 1; -READ8_DEVICE_HANDLER( z80pio_ba_cd_r ) -{ - int index = BIT(offset, 1); + if (!m_match && match) + { + // trigger interrupt + m_ip = 1; + if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", m_device->tag(), 'A' + m_index); + } - return BIT(offset, 0) ? z80pio_c_r(device, index) : z80pio_d_r(device, index); + m_match = match; + } + + return (m_ie && m_ip && !m_ius); } -/*------------------------------------------------- - z80pio_ba_cd_w - register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80pio_ba_cd_w ) +//------------------------------------------------- +// trigger_interrupt - trigger an interrupt from +// this port +//------------------------------------------------- + +void z80pio_device::pio_port::trigger_interrupt() { - int index = BIT(offset, 1); + m_ip = 1; + if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Pending\n", m_device->tag(), 'A' + m_index); - BIT(offset, 0) ? z80pio_c_w(device, index, data) : z80pio_d_w(device, index, data); + check_interrupts(); } -/*------------------------------------------------- - z80pio_pa_r - port A read --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80pio_pa_r ) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_A]; +//------------------------------------------------- +// set_rdy - set the port's RDY line +//------------------------------------------------- - UINT8 data = 0xff; - - switch (port->mode) - { - case MODE_OUTPUT: - data = port->output; - break; - - case MODE_BIDIRECTIONAL: - data = port->output; - break; +void z80pio_device::pio_port::set_rdy(int state) +{ + if (m_rdy == state) return; - case MODE_BIT_CONTROL: - data = port->ior | (port->output & (port->ior ^ 0xff)); - break; - } + if (LOG) logerror("Z80PIO '%s' Port %c Ready: %u\n", m_device->tag(), 'A' + m_index, state); - return data; + m_rdy = state; + devcb_call_write_line(&m_out_rdy_func, state); } -/*------------------------------------------------- - z80pio_pa_w - port A write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80pio_pa_w ) +//------------------------------------------------- +// set_mode - set the port's mode +//------------------------------------------------- + +void z80pio_device::pio_port::set_mode(int mode) { - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_A]; + if (LOG) logerror("Z80PIO '%s' Port %c Mode: %u\n", m_device->tag(), 'A' + m_index, mode); - if (port->mode == MODE_BIT_CONTROL) + switch (mode) { - /* latch data */ - port->input = data; - check_interrupts(device); - } -} + case MODE_OUTPUT: + // enable data output + devcb_call_write8(&m_out_p_func, 0, m_output); -/*------------------------------------------------- - z80pio_pb_r - port B read --------------------------------------------------*/ + // assert ready line + set_rdy(1); -READ8_DEVICE_HANDLER( z80pio_pb_r ) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_B]; + // set mode register + m_mode = mode; + break; - UINT8 data = 0xff; + case MODE_INPUT: + // set mode register + m_mode = mode; + break; - switch (port->mode) - { - case MODE_OUTPUT: - data = port->output; + case MODE_BIDIRECTIONAL: + if (m_index == PORT_B) + { + logerror("Z80PIO '%s' Port %c Invalid Mode: %u!\n", m_device->tag(), 'A' + m_index, mode); + } + else + { + // set mode register + m_mode = mode; + } break; case MODE_BIT_CONTROL: - data = port->ior | (port->output & (port->ior ^ 0xff)); - break; - } + if ((m_index == PORT_A) || (m_device->m_port[PORT_A].m_mode != MODE_BIDIRECTIONAL)) + { + // clear ready line + set_rdy(0); + } - return data; -} + // disable interrupts until IOR is written + m_ie = 0; + check_interrupts(); -/*------------------------------------------------- - z80pio_pb_w - port B write --------------------------------------------------*/ + // set logic equation to false + m_match = 0; -WRITE8_DEVICE_HANDLER( z80pio_pb_w ) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_B]; + // next word is I/O register + m_next_control_word = IOR; - if (port->mode == MODE_BIT_CONTROL) - { - /* latch data */ - port->input = data; - check_interrupts(device); + // set mode register + m_mode = mode; + break; } } -/*------------------------------------------------- - z80pio_ardy_r - port A ready --------------------------------------------------*/ - -READ_LINE_DEVICE_HANDLER( z80pio_ardy_r ) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_A]; - - return port->rdy; -} -/*------------------------------------------------- - z80pio_brdy_r - port B ready --------------------------------------------------*/ +//------------------------------------------------- +// strobe - strobe data in/out of the port +//------------------------------------------------- -READ_LINE_DEVICE_HANDLER( z80pio_brdy_r ) +void z80pio_device::pio_port::strobe(int state) { - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[PORT_B]; - - return port->rdy; -} - -/*------------------------------------------------- - strobe - handle strobe signal --------------------------------------------------*/ + if (LOG) logerror("Z80PIO '%s' Port %c Strobe: %u\n", m_device->tag(), 'A' + m_index, state); -static void strobe(running_device *device, int index, int state) -{ - z80pio_t *z80pio = get_safe_token(device); - pio_port *port = &z80pio->port[index]; - - if (LOG) logerror("Z80PIO '%s' Port %c Strobe: %u\n", device->tag(), 'A' + index, state); - - if (z80pio->port[PORT_A].mode == MODE_BIDIRECTIONAL) + if (m_device->m_port[PORT_A].m_mode == MODE_BIDIRECTIONAL) { - pio_port *port_a = &z80pio->port[PORT_A]; - - switch (index) + if (m_rdy) // port ready { - case PORT_A: - if (port_a->rdy) /* port A ready */ + if (m_stb && !state) // falling edge { - if (port->stb && !state) /* falling edge */ - { - devcb_call_write8(&port_a->out_p_func, 0, port_a->output); - } - else if (!port->stb && state) /* rising edge */ - { - trigger_interrupt(device, index); - - /* clear ready line */ - set_rdy(device, index, 0); - } + if (m_index == PORT_A) + devcb_call_write8(&m_out_p_func, 0, m_output); + else + m_device->m_port[PORT_A].m_input = devcb_call_read8(&m_device->m_port[PORT_A].m_in_p_func, 0); } - break; - - case PORT_B: - if (port->rdy) /* port B ready */ + else if (!m_stb && state) // rising edge { - if (port->stb && !state) /* falling edge */ - { - port_a->input = devcb_call_read8(&port_a->in_p_func, 0); - } - else if (!port->stb && state) /* rising edge */ - { - trigger_interrupt(device, index); + trigger_interrupt(); - /* clear ready line */ - set_rdy(device, index, 0); - } + // clear ready line + set_rdy(0); } - break; } } else { - switch (port->mode) + switch (m_mode) { case MODE_OUTPUT: - if (port->rdy) + if (m_rdy) { - if (!port->stb && state) /* rising edge */ + if (!m_stb && state) // rising edge { - trigger_interrupt(device, index); + trigger_interrupt(); - /* clear ready line */ - set_rdy(device, index, 0); + // clear ready line + set_rdy(0); } } break; @@ -685,230 +553,335 @@ static void strobe(running_device *device, int index, int state) case MODE_INPUT: if (!state) { - /* input port data */ - port->input = devcb_call_read8(&port->in_p_func, 0); + // input port data + m_input = devcb_call_read8(&m_in_p_func, 0); } - else if (!port->stb && state) /* rising edge */ + else if (!m_stb && state) // rising edge { - trigger_interrupt(device, index); + trigger_interrupt(); - /* clear ready line */ - set_rdy(device, index, 0); + // clear ready line + set_rdy(0); } break; } } - port->stb = state; + m_stb = state; } -/*------------------------------------------------- - z80pio_astb_w - port A strobe --------------------------------------------------*/ -WRITE_LINE_DEVICE_HANDLER( z80pio_astb_w ) +//------------------------------------------------- +// read - port I/O read +//------------------------------------------------- + +UINT8 z80pio_device::pio_port::read() { - strobe(device, PORT_A, state); -} + UINT8 data = 0xff; -/*------------------------------------------------- - z80pio_bstb_w - port B strobe --------------------------------------------------*/ + switch (m_mode) + { + case MODE_OUTPUT: + data = m_output; + break; -WRITE_LINE_DEVICE_HANDLER( z80pio_bstb_w ) -{ - strobe(device, PORT_B, state); + case MODE_BIDIRECTIONAL: + if (m_index == PORT_A) + data = m_output; + break; + + case MODE_BIT_CONTROL: + data = m_ior | (m_output & (m_ior ^ 0xff)); + break; + } + + return data; } -/*------------------------------------------------- - z80pio_irq_state - read interrupt state --------------------------------------------------*/ -static int z80pio_irq_state(running_device *device) +//------------------------------------------------- +// write - port I/O write +//------------------------------------------------- + +void z80pio_device::pio_port::write(UINT8 data) { - z80pio_t *z80pio = get_safe_token(device); + if (m_mode == MODE_BIT_CONTROL) + { + // latch data + m_input = data; + check_interrupts(); + } +} - int state = 0; - for (int index = PORT_A; index < PORT_COUNT; index++) - { - pio_port *port = &z80pio->port[index]; +//------------------------------------------------- +// control_write - control register write +//------------------------------------------------- - if (port->ius) +void z80pio_device::pio_port::control_write(UINT8 data) +{ + switch (m_next_control_word) + { + case ANY: + if (!BIT(data, 0)) { - /* interrupt under service */ - return Z80_DAISY_IEO; + // load interrupt vector + m_vector = data; + if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Vector: %02x\n", m_device->tag(), 'A' + m_index, data); + + // set interrupt enable + m_icw |= ICW_ENABLE_INT; + m_ie = 1; + check_interrupts(); } - else if (port->ie && port->ip) + else { - /* interrupt pending */ - state = Z80_DAISY_INT; - } - } + switch (data & 0x0f) + { + case 0x0f: // select operating mode + set_mode(data >> 6); + break; - return state; -} + case 0x07: // set interrupt control word + m_icw = data; -/*------------------------------------------------- - z80pio_irq_ack - interrupt acknowledge --------------------------------------------------*/ + if (LOG) + { + logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 7)); + logerror("Z80PIO '%s' Port %c Logic: %s\n", m_device->tag(), 'A' + m_index, BIT(data, 6) ? "AND" : "OR"); + logerror("Z80PIO '%s' Port %c Active %s\n", m_device->tag(), 'A' + m_index, BIT(data, 5) ? "High" : "Low"); + logerror("Z80PIO '%s' Port %c Mask Follows: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 4)); + } -static int z80pio_irq_ack(running_device *device) -{ - z80pio_t *z80pio = get_safe_token(device); + if (m_icw & ICW_MASK_FOLLOWS) + { + // disable interrupts until mask is written + m_ie = 0; - for (int index = PORT_A; index < PORT_COUNT; index++) - { - pio_port *port = &z80pio->port[index]; + // reset pending interrupts + m_ip = 0; + check_interrupts(); - if (port->ip) - { - if (LOG) logerror("Z80PIO '%s' Interrupt Acknowledge\n", device->tag()); + // set logic equation to false + m_match = 0; - /* clear interrupt pending flag */ - port->ip = 0; + // next word is mask control + m_next_control_word = MASK; + } + break; - /* set interrupt under service flag */ - port->ius = 1; + case 0x03: // set interrupt enable flip-flop + m_icw = (data & 0x80) | (m_icw & 0x7f); + if (LOG) logerror("Z80PIO '%s' Port %c Interrupt Enable: %u\n", m_device->tag(), 'A' + m_index, BIT(data, 7)); - check_interrupts(device); + // set interrupt enable + m_ie = BIT(m_icw, 7); + check_interrupts(); + break; - return port->vector; + default: + logerror("Z80PIO '%s' Port %c Invalid Control Word: %02x!\n", m_device->tag(), 'A' + m_index, data); + } } - } + break; - logerror("z80pio_irq_ack: failed to find an interrupt to ack!\n"); + case IOR: // data direction register + m_ior = data; + if (LOG) logerror("Z80PIO '%s' Port %c IOR: %02x\n", m_device->tag(), 'A' + m_index, data); - return 0; + // set interrupt enable + m_ie = BIT(m_icw, 7); + check_interrupts(); + + // next word is any + m_next_control_word = ANY; + break; + + case MASK: // interrupt mask + m_mask = data; + if (LOG) logerror("Z80PIO '%s' Port %c Mask: %02x\n", m_device->tag(), 'A' + m_index, data); + + // set interrupt enable + m_ie = BIT(m_icw, 7); + check_interrupts(); + + // next word is any + m_next_control_word = ANY; + break; + } } -/*------------------------------------------------- - z80pio_irq_reti - return from interrupt --------------------------------------------------*/ -static void z80pio_irq_reti(running_device *device) +//------------------------------------------------- +// data_read - data register read +//------------------------------------------------- + +UINT8 z80pio_device::pio_port::data_read() { - z80pio_t *z80pio = get_safe_token(device); + UINT8 data = 0; - for (int index = PORT_A; index < PORT_COUNT; index++) + switch (m_mode) { - pio_port *port = &z80pio->port[index]; + case MODE_OUTPUT: + data = m_output; + break; - if (port->ius) + case MODE_INPUT: + if (!m_stb) { - if (LOG) logerror("Z80PIO '%s' Return from Interrupt\n", device->tag()); + // input port data + m_input = devcb_call_read8(&m_in_p_func, 0); + } - /* clear interrupt under service flag */ - port->ius = 0; - check_interrupts(device); + data = m_input; - return; - } + // clear ready line + set_rdy(0); + + // assert ready line + set_rdy(1); + break; + + case MODE_BIDIRECTIONAL: + data = m_input; + + // clear ready line + m_device->m_port[PORT_B].set_rdy(0); + + // assert ready line + m_device->m_port[PORT_B].set_rdy(1); + break; + + case MODE_BIT_CONTROL: + // input port data + m_input = devcb_call_read8(&m_in_p_func, 0); + + data = (m_input & m_ior) | (m_output & (m_ior ^ 0xff)); + break; } - logerror("z80pio_irq_reti: failed to find an interrupt to clear IEO on!\n"); + return data; } -/*------------------------------------------------- - DEVICE_START( z80pio ) --------------------------------------------------*/ -static DEVICE_START( z80pio ) +//------------------------------------------------- +// data_write - data register write +//------------------------------------------------- + +void z80pio_device::pio_port::data_write(UINT8 data) { - z80pio_t *z80pio = get_safe_token(device); - z80pio_interface *intf = (z80pio_interface *)device->baseconfig().static_config; + switch (m_mode) + { + case MODE_OUTPUT: + // clear ready line + set_rdy(0); - /* resolve callbacks */ - devcb_resolve_write_line(&z80pio->out_int_func, &intf->out_int_func, device); - devcb_resolve_read8(&z80pio->port[PORT_A].in_p_func, &intf->in_pa_func, device); - devcb_resolve_write8(&z80pio->port[PORT_A].out_p_func, &intf->out_pa_func, device); - devcb_resolve_write_line(&z80pio->port[PORT_A].out_rdy_func, &intf->out_ardy_func, device); - devcb_resolve_read8(&z80pio->port[PORT_B].in_p_func, &intf->in_pb_func, device); - devcb_resolve_write8(&z80pio->port[PORT_B].out_p_func, &intf->out_pb_func, device); - devcb_resolve_write_line(&z80pio->port[PORT_B].out_rdy_func, &intf->out_brdy_func, device); + // latch output data + m_output = data; - /* register for state saving */ - for (int index = PORT_A; index < PORT_COUNT; index++) - { - state_save_register_device_item(device, index, z80pio->port[index].mode); - state_save_register_device_item(device, index, z80pio->port[index].next_control_word); - state_save_register_device_item(device, index, z80pio->port[index].input); - state_save_register_device_item(device, index, z80pio->port[index].output); - state_save_register_device_item(device, index, z80pio->port[index].ior); - state_save_register_device_item(device, index, z80pio->port[index].rdy); - state_save_register_device_item(device, index, z80pio->port[index].stb); - state_save_register_device_item(device, index, z80pio->port[index].ie); - state_save_register_device_item(device, index, z80pio->port[index].ip); - state_save_register_device_item(device, index, z80pio->port[index].ius); - state_save_register_device_item(device, index, z80pio->port[index].icw); - state_save_register_device_item(device, index, z80pio->port[index].vector); - state_save_register_device_item(device, index, z80pio->port[index].mask); - state_save_register_device_item(device, index, z80pio->port[index].match); + // output data to port + devcb_call_write8(&m_out_p_func, 0, data); + + // assert ready line + set_rdy(1); + break; + + case MODE_INPUT: + // latch output data + m_output = data; + break; + + case MODE_BIDIRECTIONAL: + // clear ready line + set_rdy(0); + + // latch output data + m_output = data; + + if (!m_stb) + { + // output data to port + devcb_call_write8(&m_out_p_func, 0, data); + } + + // assert ready line + set_rdy(1); + break; + + case MODE_BIT_CONTROL: + // latch output data + m_output = data; + + // output data to port + devcb_call_write8(&m_out_p_func, 0, m_ior | (m_output & (m_ior ^ 0xff))); + break; } } -/*------------------------------------------------- - DEVICE_RESET( z80pio ) --------------------------------------------------*/ -static DEVICE_RESET( z80pio ) + +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** + +READ8_DEVICE_HANDLER( z80pio_c_r ) { return downcast(device)->control_read(); } +WRITE8_DEVICE_HANDLER( z80pio_c_w ) { downcast(device)->control_write(offset & 1, data); } + +READ8_DEVICE_HANDLER( z80pio_d_r ) { return downcast(device)->data_read(offset & 1); } +WRITE8_DEVICE_HANDLER( z80pio_d_w ) { downcast(device)->control_write(offset & 1, data); } + +READ_LINE_DEVICE_HANDLER( z80pio_ardy_r ) { return downcast(device)->rdy(PORT_A); } +READ_LINE_DEVICE_HANDLER( z80pio_brdy_r ) { return downcast(device)->rdy(PORT_B); } + +WRITE_LINE_DEVICE_HANDLER( z80pio_astb_w ) { downcast(device)->strobe(PORT_A, state); } +WRITE_LINE_DEVICE_HANDLER( z80pio_bstb_w ) { downcast(device)->strobe(PORT_B, state); } + +READ8_DEVICE_HANDLER( z80pio_pa_r ) { return downcast(device)->port_read(PORT_A); } +READ8_DEVICE_HANDLER( z80pio_pb_r ) { return downcast(device)->port_read(PORT_B); } + +WRITE8_DEVICE_HANDLER( z80pio_pa_w ) { downcast(device)->port_write(PORT_A, data); } +WRITE8_DEVICE_HANDLER( z80pio_pb_w ) { downcast(device)->port_write(PORT_B, data); } + +//------------------------------------------------- +// z80pio_cd_ba_r - register read +//------------------------------------------------- + +READ8_DEVICE_HANDLER( z80pio_cd_ba_r ) { - z80pio_t *z80pio = get_safe_token(device); + int index = BIT(offset, 0); - for (int index = PORT_A; index < PORT_COUNT; index++) - { - pio_port *port = &z80pio->port[index]; + return BIT(offset, 1) ? z80pio_c_r(device, index) : z80pio_d_r(device, index); +} - /* set mode 1 */ - set_mode(device, index, MODE_INPUT); +//------------------------------------------------- +// z80pio_cd_ba_w - register write +//------------------------------------------------- - /* reset interrupt enable flip-flops */ - port->icw &= ~ICW_ENABLE_INT; - port->ie = 0; - port->ip = 0; - port->ius = 0; - port->match = 0; +WRITE8_DEVICE_HANDLER( z80pio_cd_ba_w ) +{ + int index = BIT(offset, 0); - /* reset all bits of the data I/O register */ - port->ior = 0; + BIT(offset, 1) ? z80pio_c_w(device, index, data) : z80pio_d_w(device, index, data); +} - /* set all bits of the mask control register */ - port->mask = 0xff; +//------------------------------------------------- +// z80pio_ba_cd_r - register read +//------------------------------------------------- - /* reset output register */ - port->output = 0; +READ8_DEVICE_HANDLER( z80pio_ba_cd_r ) +{ + int index = BIT(offset, 1); - /* clear ready line */ - set_rdy(device, index, 0); - } + return BIT(offset, 0) ? z80pio_c_r(device, index) : z80pio_d_r(device, index); } -/*------------------------------------------------- - DEVICE_GET_INFO( z80pio ) --------------------------------------------------*/ +//------------------------------------------------- +// z80pio_ba_cd_w - register write +//------------------------------------------------- -DEVICE_GET_INFO( z80pio ) +WRITE8_DEVICE_HANDLER( z80pio_ba_cd_w ) { - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80pio_t); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80pio);break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80pio);break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80pio_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80pio_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80pio_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Z8420"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; - } + int index = BIT(offset, 1); + + BIT(offset, 0) ? z80pio_c_w(device, index, data) : z80pio_d_w(device, index, data); } diff --git a/src/emu/machine/z80pio.h b/src/emu/machine/z80pio.h index 96accef0c65..526e1d673aa 100644 --- a/src/emu/machine/z80pio.h +++ b/src/emu/machine/z80pio.h @@ -33,11 +33,12 @@ #ifndef __Z80PIO__ #define __Z80PIO__ -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ +#include "cpu/z80/z80daisy.h" -#define Z80PIO DEVICE_GET_INFO_NAME(z80pio) + +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_Z80PIO_ADD(_tag, _clock, _intrf) \ MDRV_DEVICE_ADD(_tag, Z80PIO, _clock) \ @@ -46,57 +47,194 @@ #define Z80PIO_INTERFACE(_name) \ const z80pio_interface (_name) = -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -typedef struct _z80pio_interface z80pio_interface; -struct _z80pio_interface + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> z80pio_interface + +struct z80pio_interface { - devcb_write_line out_int_func; + devcb_write_line m_out_int_func; - devcb_read8 in_pa_func; - devcb_write8 out_pa_func; - devcb_write_line out_ardy_func; + devcb_read8 m_in_pa_func; + devcb_write8 m_out_pa_func; + devcb_write_line m_out_ardy_func; - devcb_read8 in_pb_func; - devcb_write8 out_pb_func; - devcb_write_line out_brdy_func; + devcb_read8 m_in_pb_func; + devcb_write8 m_out_pb_func; + devcb_write_line m_out_brdy_func; }; -/*************************************************************************** - PROTOTYPES -***************************************************************************/ -DEVICE_GET_INFO( z80pio ); -/* control register access */ +// ======================> z80pio_device_config + +class z80pio_device_config : public device_config, + public device_config_z80daisy_interface, + public z80pio_interface +{ + friend class z80pio_device; + + // construction/destruction + z80pio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Z8420"; } + +protected: + // device_config overrides + virtual void device_config_complete(); +}; + + + +// ======================> z80pio_device + +class z80pio_device : public device_t, + public device_z80daisy_interface +{ + friend class z80pio_device_config; + + // construction/destruction + z80pio_device(running_machine &_machine, const z80pio_device_config &config); + +public: + // I/O line access + int rdy(int which) { return m_port[which].rdy(); } + void strobe(int which, int state) { m_port[which].strobe(state); } + + // control register I/O + UINT8 control_read(); + void control_write(int offset, UINT8 data) { m_port[offset & 1].control_write(data); } + + // data register I/O + UINT8 data_read(int offset) { return m_port[offset & 1].data_read(); } + void data_write(int offset, UINT8 data) { m_port[offset & 1].data_write(data); } + + // port I/O + UINT8 port_read(int offset) { return m_port[offset & 1].read(); } + void port_write(int offset, UINT8 data) { m_port[offset & 1].write(data); } + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal helpers + void check_interrupts(); + + // a single PIO port + class pio_port + { + friend class z80pio_device; + + public: + pio_port(); + + void start(z80pio_device *device, int index, const devcb_read8 &infunc, const devcb_write8 &outfunc, const devcb_write_line &rdyfunc); + void reset(); + + bool interrupt_signalled(); + void trigger_interrupt(); + + int rdy() const { return m_rdy; } + void set_rdy(int state); + void set_mode(int mode); + void strobe(int state); + + UINT8 read(); + void write(UINT8 data); + + void control_write(UINT8 data); + + UINT8 data_read(); + void data_write(UINT8 data); + + private: + void check_interrupts() { m_device->check_interrupts(); } + + z80pio_device * m_device; + int m_index; + + devcb_resolved_read8 m_in_p_func; + devcb_resolved_write8 m_out_p_func; + devcb_resolved_write_line m_out_rdy_func; + + int m_mode; // mode register + int m_next_control_word; // next control word + UINT8 m_input; // input latch + UINT8 m_output; // output latch + UINT8 m_ior; // input/output register + int m_rdy; // ready + int m_stb; // strobe + + // interrupts + int m_ie; // interrupt enabled + int m_ip; // interrupt pending + int m_ius; // interrupt under service + UINT8 m_icw; // interrupt control word + UINT8 m_vector; // interrupt vector + UINT8 m_mask; // interrupt mask + int m_match; // logic equation match + }; + + // internal state + const z80pio_device_config &m_config; + pio_port m_port[2]; + devcb_resolved_write_line m_out_int_func; +}; + + +// device type definition +const device_type Z80PIO = z80pio_device_config::static_alloc_device_config; + + + +//************************************************************************** +// FUNCTION PROTOTYPES +//************************************************************************** + +// control register access READ8_DEVICE_HANDLER( z80pio_c_r ); WRITE8_DEVICE_HANDLER( z80pio_c_w ); -/* data register access */ +// data register access READ8_DEVICE_HANDLER( z80pio_d_r ); WRITE8_DEVICE_HANDLER( z80pio_d_w ); -/* register access */ +// register access READ8_DEVICE_HANDLER( z80pio_cd_ba_r ); WRITE8_DEVICE_HANDLER( z80pio_cd_ba_w ); READ8_DEVICE_HANDLER( z80pio_ba_cd_r ); WRITE8_DEVICE_HANDLER( z80pio_ba_cd_w ); -/* port access */ +// port access READ8_DEVICE_HANDLER( z80pio_pa_r ); WRITE8_DEVICE_HANDLER( z80pio_pa_w ); READ8_DEVICE_HANDLER( z80pio_pb_r ); WRITE8_DEVICE_HANDLER( z80pio_pb_w ); -/* ready */ +// ready READ_LINE_DEVICE_HANDLER( z80pio_ardy_r ); READ_LINE_DEVICE_HANDLER( z80pio_brdy_r ); -/* strobe */ +// strobe WRITE_LINE_DEVICE_HANDLER( z80pio_astb_w ); WRITE_LINE_DEVICE_HANDLER( z80pio_bstb_w ); diff --git a/src/emu/machine/z80sio.c b/src/emu/machine/z80sio.c index 0cf01579e41..c791507c42c 100644 --- a/src/emu/machine/z80sio.c +++ b/src/emu/machine/z80sio.c @@ -14,9 +14,9 @@ -/*************************************************************************** - DEBUGGING -***************************************************************************/ +//************************************************************************** +// DEBUGGING +//************************************************************************** #define VERBOSE 0 @@ -24,167 +24,149 @@ -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* interrupt states */ -#define INT_CHB_TRANSMIT 0x00 /* not confirmed */ -#define INT_CHB_STATUS 0x01 -#define INT_CHB_RECEIVE 0x02 -#define INT_CHB_ERROR 0x03 - -#define INT_CHA_TRANSMIT 0x04 /* not confirmed */ -#define INT_CHA_STATUS 0x05 -#define INT_CHA_RECEIVE 0x06 -#define INT_CHA_ERROR 0x07 - -/* SIO write register 0 */ -#define SIO_WR0_RESET_MASK 0xc0 /* D7-D6: Reset control */ -#define SIO_WR0_RESET_NULL 0x00 /* 00 = NULL code */ -#define SIO_WR0_RESET_RX_CRC 0x40 /* 01 = Reset Rx CRC checker */ -#define SIO_WR0_RESET_TX_CRC 0x80 /* 10 = Reset Tx CRC generator */ -#define SIO_WR0_RESET_TX_LATCH 0xc0 /* 11 = Reset Tx Underrun/EOM latch */ -#define SIO_WR0_COMMAND_MASK 0x38 /* D5-D3: Command */ -#define SIO_WR0_COMMAND_NULL 0x00 /* 000 = NULL code */ -#define SIO_WR0_COMMAND_SET_ABORT 0x08 /* 001 = Set abort (SDLC) */ -#define SIO_WR0_COMMAND_RES_STATUS_INT 0x10 /* 010 = reset ext/status interrupts */ -#define SIO_WR0_COMMAND_CH_RESET 0x18 /* 011 = Channel reset */ -#define SIO_WR0_COMMAND_ENA_RX_INT 0x20 /* 100 = Enable int on next Rx character */ -#define SIO_WR0_COMMAND_RES_TX_INT 0x28 /* 101 = Reset Tx int pending */ -#define SIO_WR0_COMMAND_RES_ERROR 0x30 /* 110 = Error reset */ -#define SIO_WR0_COMMAND_RETI 0x38 /* 111 = Return from int (CH-A only) */ -#define SIO_WR0_REGISTER_MASK 0x07 /* D2-D0: Register select (0-7) */ - -/* SIO write register 1 */ -#define SIO_WR1_READY_WAIT_ENA 0x80 /* D7 = READY/WAIT enable */ -#define SIO_WR1_READY_WAIT_FUNCTION 0x40 /* D6 = READY/WAIT function */ -#define SIO_WR1_READY_WAIT_ON_RT 0x20 /* D5 = READY/WAIT on R/T */ -#define SIO_WR1_RXINT_MASK 0x18 /* D4-D3 = Rx int control */ -#define SIO_WR1_RXINT_DISABLE 0x00 /* 00 = Rx int disable */ -#define SIO_WR1_RXINT_FIRST 0x08 /* 01 = Rx int on first character */ -#define SIO_WR1_RXINT_ALL_PARITY 0x10 /* 10 = int on all Rx characters (parity affects vector) */ -#define SIO_WR1_RXINT_ALL_NOPARITY 0x18 /* 11 = int on all Rx characters (parity ignored) */ -#define SIO_WR1_STATUS_AFFECTS_VECTOR 0x04 /* D2 = Status affects vector (CH-B only) */ -#define SIO_WR1_TXINT_ENABLE 0x02 /* D1 = Tx int enable */ -#define SIO_WR1_STATUSINT_ENABLE 0x01 /* D0 = Ext int enable */ - -/* SIO write register 2 (CH-B only) */ -#define SIO_WR2_INT_VECTOR_MASK 0xff /* D7-D0 = interrupt vector */ - -/* SIO write register 3 */ -#define SIO_WR3_RX_DATABITS_MASK 0xc0 /* D7-D6 = Rx Data bits */ -#define SIO_WR3_RX_DATABITS_5 0x00 /* 00 = Rx 5 bits/character */ -#define SIO_WR3_RX_DATABITS_7 0x40 /* 01 = Rx 7 bits/character */ -#define SIO_WR3_RX_DATABITS_6 0x80 /* 10 = Rx 6 bits/character */ -#define SIO_WR3_RX_DATABITS_8 0xc0 /* 11 = Rx 8 bits/character */ -#define SIO_WR3_AUTO_ENABLES 0x20 /* D5 = Auto enables */ -#define SIO_WR3_ENTER_HUNT_PHASE 0x10 /* D4 = Enter hunt phase */ -#define SIO_WR3_RX_CRC_ENABLE 0x08 /* D3 = Rx CRC enable */ -#define SIO_WR3_ADDR_SEARCH_MODE 0x04 /* D2 = Address search mode (SDLC) */ -#define SIO_WR3_SYNC_LOAD_INHIBIT 0x02 /* D1 = Sync character load inhibit */ -#define SIO_WR3_RX_ENABLE 0x01 /* D0 = Rx enable */ - -/* SIO write register 4 */ -#define SIO_WR4_CLOCK_MODE_MASK 0xc0 /* D7-D6 = Clock mode */ -#define SIO_WR4_CLOCK_MODE_x1 0x00 /* 00 = x1 clock mode */ -#define SIO_WR4_CLOCK_MODE_x16 0x40 /* 01 = x16 clock mode */ -#define SIO_WR4_CLOCK_MODE_x32 0x80 /* 10 = x32 clock mode */ -#define SIO_WR4_CLOCK_MODE_x64 0xc0 /* 11 = x64 clock mode */ -#define SIO_WR4_SYNC_MODE_MASK 0x30 /* D5-D4 = Sync mode */ -#define SIO_WR4_SYNC_MODE_8BIT 0x00 /* 00 = 8 bit sync character */ -#define SIO_WR4_SYNC_MODE_16BIT 0x10 /* 01 = 16 bit sync character */ -#define SIO_WR4_SYNC_MODE_SDLC 0x20 /* 10 = SDLC mode (01111110 flag) */ -#define SIO_WR4_SYNC_MODE_EXTERNAL 0x30 /* 11 = External sync mode */ -#define SIO_WR4_STOPBITS_MASK 0x0c /* D3-D2 = Stop bits */ -#define SIO_WR4_STOPBITS_SYNC 0x00 /* 00 = Sync modes enable */ -#define SIO_WR4_STOPBITS_1 0x04 /* 01 = 1 stop bit/character */ -#define SIO_WR4_STOPBITS_15 0x08 /* 10 = 1.5 stop bits/character */ -#define SIO_WR4_STOPBITS_2 0x0c /* 11 = 2 stop bits/character */ -#define SIO_WR4_PARITY_EVEN 0x02 /* D1 = Parity even/odd */ -#define SIO_WR4_PARITY_ENABLE 0x01 /* D0 = Parity enable */ - -/* SIO write register 5 */ -#define SIO_WR5_DTR 0x80 /* D7 = DTR */ -#define SIO_WR5_TX_DATABITS_MASK 0x60 /* D6-D5 = Tx Data bits */ -#define SIO_WR5_TX_DATABITS_5 0x00 /* 00 = Tx 5 bits/character */ -#define SIO_WR5_TX_DATABITS_7 0x20 /* 01 = Tx 7 bits/character */ -#define SIO_WR5_TX_DATABITS_6 0x40 /* 10 = Tx 6 bits/character */ -#define SIO_WR5_TX_DATABITS_8 0x60 /* 11 = Tx 8 bits/character */ -#define SIO_WR5_SEND_BREAK 0x10 /* D4 = Send break */ -#define SIO_WR5_TX_ENABLE 0x08 /* D3 = Tx Enable */ -#define SIO_WR5_CRC16_SDLC 0x04 /* D2 = CRC-16/SDLC */ -#define SIO_WR5_RTS 0x02 /* D1 = RTS */ -#define SIO_WR5_TX_CRC_ENABLE 0x01 /* D0 = Tx CRC enable */ - -/* SIO write register 6 */ -#define SIO_WR6_SYNC_7_0_MASK 0xff /* D7-D0 = Sync bits 7-0 */ - -/* SIO write register 7 */ -#define SIO_WR7_SYNC_15_8_MASK 0xff /* D7-D0 = Sync bits 15-8 */ - -/* SIO read register 0 */ -#define SIO_RR0_BREAK_ABORT 0x80 /* D7 = Break/abort */ -#define SIO_RR0_TX_UNDERRUN 0x40 /* D6 = Tx underrun/EOM */ -#define SIO_RR0_CTS 0x20 /* D5 = CTS */ -#define SIO_RR0_SYNC_HUNT 0x10 /* D4 = Sync/hunt */ -#define SIO_RR0_DCD 0x08 /* D3 = DCD */ -#define SIO_RR0_TX_BUFFER_EMPTY 0x04 /* D2 = Tx buffer empty */ -#define SIO_RR0_INT_PENDING 0x02 /* D1 = int pending (CH-A only) */ -#define SIO_RR0_RX_CHAR_AVAILABLE 0x01 /* D0 = Rx character available */ - -/* SIO read register 1 */ -#define SIO_RR1_END_OF_FRAME 0x80 /* D7 = End of frame (SDLC) */ -#define SIO_RR1_CRC_FRAMING_ERROR 0x40 /* D6 = CRC/Framing error */ -#define SIO_RR1_RX_OVERRUN_ERROR 0x20 /* D5 = Rx overrun error */ -#define SIO_RR1_PARITY_ERROR 0x10 /* D4 = Parity error */ -#define SIO_RR1_IFIELD_BITS_MASK 0x0e /* D3-D1 = I field bits */ - /* 100 = 0 in prev, 3 in 2nd prev */ - /* 010 = 0 in prev, 4 in 2nd prev */ - /* 110 = 0 in prev, 5 in 2nd prev */ - /* 001 = 0 in prev, 6 in 2nd prev */ - /* 101 = 0 in prev, 7 in 2nd prev */ - /* 011 = 0 in prev, 8 in 2nd prev */ - /* 111 = 1 in prev, 8 in 2nd prev */ - /* 000 = 2 in prev, 8 in 2nd prev */ -#define SIO_RR1_ALL_SENT 0x01 /* D0 = All sent */ - -/* SIO read register 2 (CH-B only) */ -#define SIO_RR2_VECTOR_MASK 0xff /* D7-D0 = Interrupt vector */ - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -typedef struct _sio_channel sio_channel; -struct _sio_channel -{ - UINT8 regs[8]; /* 8 writeable registers */ - UINT8 status[4]; /* 3 readable registers */ - int inbuf; /* input buffer */ - int outbuf; /* output buffer */ - UINT8 int_on_next_rx; /* interrupt on next rx? */ - emu_timer * receive_timer; /* timer to clock data in */ - UINT8 receive_buffer[16]; /* buffer for incoming data */ - UINT8 receive_inptr; /* index of data coming in */ - UINT8 receive_outptr; /* index of data going out */ -}; - - -typedef struct _z80sio z80sio; -struct _z80sio +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// interrupt states +const int INT_TRANSMIT = 0x00; // not confirmed +const int INT_STATUS = 0x01; +const int INT_RECEIVE = 0x02; +const int INT_ERROR = 0x03; + +const int INT_CHB_TRANSMIT = 0 + INT_TRANSMIT; +const int INT_CHB_STATUS = 0 + INT_STATUS; +const int INT_CHB_RECEIVE = 0 + INT_RECEIVE; +const int INT_CHB_ERROR = 0 + INT_ERROR; +const int INT_CHA_TRANSMIT = 4 + INT_TRANSMIT; +const int INT_CHA_STATUS = 4 + INT_STATUS; +const int INT_CHA_RECEIVE = 4 + INT_RECEIVE; +const int INT_CHA_ERROR = 4 + INT_ERROR; + +// SIO write register 0 +const int SIO_WR0_RESET_MASK = 0xc0; // D7-D6: Reset control +const int SIO_WR0_RESET_NULL = 0x00; // 00 = NULL code +const int SIO_WR0_RESET_RX_CRC = 0x40; // 01 = Reset Rx CRC checker +const int SIO_WR0_RESET_TX_CRC = 0x80; // 10 = Reset Tx CRC generator +const int SIO_WR0_RESET_TX_LATCH = 0xc0; // 11 = Reset Tx Underrun/EOM latch +const int SIO_WR0_COMMAND_MASK = 0x38; // D5-D3: Command +const int SIO_WR0_COMMAND_NULL = 0x00; // 000 = NULL code +const int SIO_WR0_COMMAND_SET_ABORT = 0x08; // 001 = Set abort (SDLC) +const int SIO_WR0_COMMAND_RES_STATUS_INT = 0x10; // 010 = reset ext/status interrupts +const int SIO_WR0_COMMAND_CH_RESET = 0x18; // 011 = Channel reset +const int SIO_WR0_COMMAND_ENA_RX_INT = 0x20; // 100 = Enable int on next Rx character +const int SIO_WR0_COMMAND_RES_TX_INT = 0x28; // 101 = Reset Tx int pending +const int SIO_WR0_COMMAND_RES_ERROR = 0x30; // 110 = Error reset +const int SIO_WR0_COMMAND_RETI = 0x38; // 111 = Return from int (CH-A only) +const int SIO_WR0_REGISTER_MASK = 0x07; // D2-D0: Register select (0-7) + +// SIO write register 1 +const int SIO_WR1_READY_WAIT_ENA = 0x80; // D7 = READY/WAIT enable +const int SIO_WR1_READY_WAIT_FUNCTION = 0x40; // D6 = READY/WAIT function +const int SIO_WR1_READY_WAIT_ON_RT = 0x20; // D5 = READY/WAIT on R/T +const int SIO_WR1_RXINT_MASK = 0x18; // D4-D3 = Rx int control +const int SIO_WR1_RXINT_DISABLE = 0x00; // 00 = Rx int disable +const int SIO_WR1_RXINT_FIRST = 0x08; // 01 = Rx int on first character +const int SIO_WR1_RXINT_ALL_PARITY = 0x10; // 10 = int on all Rx characters (parity affects vector) +const int SIO_WR1_RXINT_ALL_NOPARITY = 0x18; // 11 = int on all Rx characters (parity ignored) +const int SIO_WR1_STATUS_AFFECTS_VECTOR = 0x04; // D2 = Status affects vector (CH-B only) +const int SIO_WR1_TXINT_ENABLE = 0x02; // D1 = Tx int enable +const int SIO_WR1_STATUSINT_ENABLE = 0x01; // D0 = Ext int enable + +// SIO write register 2 (CH-B only) +const int SIO_WR2_INT_VECTOR_MASK = 0xff; // D7-D0 = interrupt vector + +// SIO write register 3 +const int SIO_WR3_RX_DATABITS_MASK = 0xc0; // D7-D6 = Rx Data bits +const int SIO_WR3_RX_DATABITS_5 = 0x00; // 00 = Rx 5 bits/character +const int SIO_WR3_RX_DATABITS_7 = 0x40; // 01 = Rx 7 bits/character +const int SIO_WR3_RX_DATABITS_6 = 0x80; // 10 = Rx 6 bits/character +const int SIO_WR3_RX_DATABITS_8 = 0xc0; // 11 = Rx 8 bits/character +const int SIO_WR3_AUTO_ENABLES = 0x20; // D5 = Auto enables +const int SIO_WR3_ENTER_HUNT_PHASE = 0x10; // D4 = Enter hunt phase +const int SIO_WR3_RX_CRC_ENABLE = 0x08; // D3 = Rx CRC enable +const int SIO_WR3_ADDR_SEARCH_MODE = 0x04; // D2 = Address search mode (SDLC) +const int SIO_WR3_SYNC_LOAD_INHIBIT = 0x02; // D1 = Sync character load inhibit +const int SIO_WR3_RX_ENABLE = 0x01; // D0 = Rx enable + +// SIO write register 4 +const int SIO_WR4_CLOCK_MODE_MASK = 0xc0; // D7-D6 = Clock mode +const int SIO_WR4_CLOCK_MODE_x1 = 0x00; // 00 = x1 clock mode +const int SIO_WR4_CLOCK_MODE_x16 = 0x40; // 01 = x16 clock mode +const int SIO_WR4_CLOCK_MODE_x32 = 0x80; // 10 = x32 clock mode +const int SIO_WR4_CLOCK_MODE_x64 = 0xc0; // 11 = x64 clock mode +const int SIO_WR4_SYNC_MODE_MASK = 0x30; // D5-D4 = Sync mode +const int SIO_WR4_SYNC_MODE_8BIT = 0x00; // 00 = 8 bit sync character +const int SIO_WR4_SYNC_MODE_16BIT = 0x10; // 01 = 16 bit sync character +const int SIO_WR4_SYNC_MODE_SDLC = 0x20; // 10 = SDLC mode (01111110 flag) +const int SIO_WR4_SYNC_MODE_EXTERNAL = 0x30; // 11 = External sync mode +const int SIO_WR4_STOPBITS_MASK = 0x0c; // D3-D2 = Stop bits +const int SIO_WR4_STOPBITS_SYNC = 0x00; // 00 = Sync modes enable +const int SIO_WR4_STOPBITS_1 = 0x04; // 01 = 1 stop bit/character +const int SIO_WR4_STOPBITS_15 = 0x08; // 10 = 1.5 stop bits/character +const int SIO_WR4_STOPBITS_2 = 0x0c; // 11 = 2 stop bits/character +const int SIO_WR4_PARITY_EVEN = 0x02; // D1 = Parity even/odd +const int SIO_WR4_PARITY_ENABLE = 0x01; // D0 = Parity enable + +// SIO write register 5 +const int SIO_WR5_DTR = 0x80; // D7 = DTR +const int SIO_WR5_TX_DATABITS_MASK = 0x60; // D6-D5 = Tx Data bits +const int SIO_WR5_TX_DATABITS_5 = 0x00; // 00 = Tx 5 bits/character +const int SIO_WR5_TX_DATABITS_7 = 0x20; // 01 = Tx 7 bits/character +const int SIO_WR5_TX_DATABITS_6 = 0x40; // 10 = Tx 6 bits/character +const int SIO_WR5_TX_DATABITS_8 = 0x60; // 11 = Tx 8 bits/character +const int SIO_WR5_SEND_BREAK = 0x10; // D4 = Send break +const int SIO_WR5_TX_ENABLE = 0x08; // D3 = Tx Enable +const int SIO_WR5_CRC16_SDLC = 0x04; // D2 = CRC-16/SDLC +const int SIO_WR5_RTS = 0x02; // D1 = RTS +const int SIO_WR5_TX_CRC_ENABLE = 0x01; // D0 = Tx CRC enable + +// SIO write register 6 +const int SIO_WR6_SYNC_7_0_MASK = 0xff; // D7-D0 = Sync bits 7-0 + +// SIO write register 7 +const int SIO_WR7_SYNC_15_8_MASK = 0xff; // D7-D0 = Sync bits 15-8 + +// SIO read register 0 +const int SIO_RR0_BREAK_ABORT = 0x80; // D7 = Break/abort +const int SIO_RR0_TX_UNDERRUN = 0x40; // D6 = Tx underrun/EOM +const int SIO_RR0_CTS = 0x20; // D5 = CTS +const int SIO_RR0_SYNC_HUNT = 0x10; // D4 = Sync/hunt +const int SIO_RR0_DCD = 0x08; // D3 = DCD +const int SIO_RR0_TX_BUFFER_EMPTY = 0x04; // D2 = Tx buffer empty +const int SIO_RR0_INT_PENDING = 0x02; // D1 = int pending (CH-A only) +const int SIO_RR0_RX_CHAR_AVAILABLE = 0x01; // D0 = Rx character available + +// SIO read register 1 +const int SIO_RR1_END_OF_FRAME = 0x80; // D7 = End of frame (SDLC) +const int SIO_RR1_CRC_FRAMING_ERROR = 0x40; // D6 = CRC/Framing error +const int SIO_RR1_RX_OVERRUN_ERROR = 0x20; // D5 = Rx overrun error +const int SIO_RR1_PARITY_ERROR = 0x10; // D4 = Parity error +const int SIO_RR1_IFIELD_BITS_MASK = 0x0e; // D3-D1 = I field bits + // 100 = 0 in prev, 3 in 2nd prev + // 010 = 0 in prev, 4 in 2nd prev + // 110 = 0 in prev, 5 in 2nd prev + // 001 = 0 in prev, 6 in 2nd prev + // 101 = 0 in prev, 7 in 2nd prev + // 011 = 0 in prev, 8 in 2nd prev + // 111 = 1 in prev, 8 in 2nd prev + // 000 = 2 in prev, 8 in 2nd prev +const int SIO_RR1_ALL_SENT = 0x01; // D0 = All sent + +// SIO read register 2 (CH-B only) +const int SIO_RR2_VECTOR_MASK = 0xff; // D7-D0 = Interrupt vector + + +const UINT8 z80sio_device::k_int_priority[] = { - sio_channel chan[2]; /* 2 channels */ - UINT8 int_state[8]; /* interrupt states */ - - void (*irq_cb)(running_device *device, int state); - write8_device_func dtr_changed_cb; - write8_device_func rts_changed_cb; - write8_device_func break_changed_cb; - write8_device_func transmit_cb; - int (*receive_poll_cb)(running_device *device, int channel); + INT_CHA_RECEIVE, + INT_CHA_TRANSMIT, + INT_CHA_STATUS, + INT_CHA_ERROR, + INT_CHB_RECEIVE, + INT_CHB_TRANSMIT, + INT_CHB_STATUS, + INT_CHB_ERROR }; @@ -193,9 +175,6 @@ struct _z80sio FUNCTION PROTOTYPES ***************************************************************************/ -static TIMER_CALLBACK( serial_callback ); - - /* @@ -249,641 +228,671 @@ static TIMER_CALLBACK( serial_callback ); */ -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ +//************************************************************************** +// INLINE FUNCTIONS +//************************************************************************** -static int z80sio_irq_state(running_device *device); -static int z80sio_irq_ack(running_device *device); -static void z80sio_irq_reti(running_device *device); +//------------------------------------------------- +// update_interrupt_state - update the interrupt +// state to the external world +//------------------------------------------------- +inline void z80sio_device::update_interrupt_state() +{ + // if we have a callback, update it with the current state + if (m_config.m_irq_cb != NULL) + (*m_config.m_irq_cb)(this, (z80daisy_irq_state() & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); +} -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ +//------------------------------------------------- +// set_interrupt - set the given interrupt state +// on this channel and update the overall device +// state +//------------------------------------------------- -INLINE z80sio *get_safe_token(running_device *device) +inline void z80sio_device::sio_channel::set_interrupt(int type) { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80SIO); - return (z80sio *)device->token; + int inum = (this == &m_device->m_channel[0] ? 4 : 0) + type; + m_device->m_int_state[inum] = Z80_DAISY_INT; + m_device->update_interrupt_state(); } -INLINE void interrupt_check(running_device *device) +//------------------------------------------------- +// clear_interrupt - clear the given interrupt +// state on this channel and update the overall +// device state +//------------------------------------------------- + +inline void z80sio_device::sio_channel::clear_interrupt(int type) { - /* if we have a callback, update it with the current state */ - z80sio *sio = get_safe_token(device); - if (sio->irq_cb != NULL) - (*sio->irq_cb)(device, (z80sio_irq_state(device) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); + int inum = (this == &m_device->m_channel[0] ? 4 : 0) + type; + m_device->m_int_state[inum] &= ~Z80_DAISY_INT; + m_device->update_interrupt_state(); } -INLINE attotime compute_time_per_character(z80sio *sio, int which) +//------------------------------------------------- +// compute_time_per_character - compute the +// serial clocking period +//------------------------------------------------- + +inline attotime z80sio_device::sio_channel::compute_time_per_character() { - /* fix me -- should compute properly and include data, stop, parity bits */ + // fix me -- should compute properly and include data, stop, parity bit return attotime_mul(ATTOTIME_IN_HZ(9600), 10); } -/*************************************************************************** - INITIALIZATION/CONFIGURATION -***************************************************************************/ +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** -/*------------------------------------------------- - reset_channel - reset a single SIO channel --------------------------------------------------*/ +//------------------------------------------------- +// z80sio_device_config - constructor +//------------------------------------------------- -static void reset_channel(running_device *device, int ch) +z80sio_device_config::z80sio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - z80sio *sio = get_safe_token(device); - attotime tpc = compute_time_per_character(sio, ch); - sio_channel *chan = &sio->chan[ch]; +} + - chan->status[0] = SIO_RR0_TX_BUFFER_EMPTY; - chan->status[1] = 0x00; - chan->status[2] = 0x00; - chan->int_on_next_rx = 0; - chan->outbuf = -1; +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *z80sio_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(z80sio_device_config(mconfig, tag, owner, clock)); +} - sio->int_state[0 + 4*ch] = 0; - sio->int_state[1 + 4*ch] = 0; - sio->int_state[2 + 4*ch] = 0; - sio->int_state[3 + 4*ch] = 0; - interrupt_check(device); +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- - /* start the receive timer running */ - timer_adjust_periodic(chan->receive_timer, tpc, ch, tpc); +device_t *z80sio_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80sio_device(machine, *this)); } +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -/*************************************************************************** - CONTROL REGISTER READ/WRITE -***************************************************************************/ +void z80sio_device_config::device_config_complete() +{ + // inherit a copy of the static data + const z80sio_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_irq_cb = NULL; + m_dtr_changed_cb = NULL; + m_rts_changed_cb = NULL; + m_break_changed_cb = NULL; + m_transmit_cb = NULL; + m_receive_poll_cb = NULL; + } +} + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// z80sio_device - constructor +//------------------------------------------------- + +z80sio_device::z80sio_device(running_machine &_machine, const z80sio_device_config &config) + : device_t(_machine, config), + device_z80daisy_interface(_machine, config, *this), + m_config(config) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void z80sio_device::device_start() +{ + m_channel[0].start(this, 0); + m_channel[1].start(this, 1); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void z80sio_device::device_reset() +{ + // loop over channels + for (int ch = 0; ch < 2; ch++) + m_channel[ch].reset(); +} + + + +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** + +//------------------------------------------------- +// z80daisy_irq_state - return the overall IRQ +// state for this device +//------------------------------------------------- + +int z80sio_device::z80daisy_irq_state() +{ + int state = 0; + + VPRINTF(("sio IRQ state = B:%d%d%d%d A:%d%d%d%d\n", + m_int_state[0], m_int_state[1], m_int_state[2], m_int_state[3], + m_int_state[4], m_int_state[5], m_int_state[6], m_int_state[7])); + + // loop over all interrupt sources + for (int irqsource = 0; irqsource < 8; irqsource++) + { + int inum = k_int_priority[irqsource]; + + // if we're servicing a request, don't indicate more interrupts + if (m_int_state[inum] & Z80_DAISY_IEO) + { + state |= Z80_DAISY_IEO; + break; + } + state |= m_int_state[inum]; + } + + return state; +} -/*------------------------------------------------- - z80sio_c_w - write to a control register --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80sio_c_w ) +//------------------------------------------------- +// z80daisy_irq_ack - acknowledge an IRQ and +// return the appropriate vector +//------------------------------------------------- + +int z80sio_device::z80daisy_irq_ack() { - z80sio *sio = get_safe_token(device); - int ch = offset & 1; - sio_channel *chan = &sio->chan[ch]; - int reg = chan->regs[0] & 7; - UINT8 old = chan->regs[reg]; + // loop over all interrupt sources + for (int irqsource = 0; irqsource < 8; irqsource++) + { + int inum = k_int_priority[irqsource]; - if (reg != 0 || (reg & 0xf8)) - VPRINTF(("%s:sio_reg_w(%c,%d) = %02X\n", cpuexec_describe_context(device->machine), 'A' + ch, reg, data)); + // find the first channel with an interrupt requested + if (m_int_state[inum] & Z80_DAISY_INT) + { + VPRINTF(("sio IRQAck %d\n", inum)); + + // clear interrupt, switch to the IEO state, and update the IRQs + m_int_state[inum] = Z80_DAISY_IEO; + update_interrupt_state(); + return m_channel[1].m_regs[2] + inum * 2; + } + } + + logerror("z80sio_irq_ack: failed to find an interrupt to ack!\n"); + return m_channel[1].m_regs[2]; +} - /* write a new value to the selected register */ - chan->regs[reg] = data; - /* clear the register number for the next write */ - if (reg != 0) - chan->regs[0] &= ~7; +//------------------------------------------------- +// z80daisy_irq_reti - clear the interrupt +// pending state to allow other interrupts through +//------------------------------------------------- - /* switch off the register for live state changes */ - switch (reg) +void z80sio_device::z80daisy_irq_reti() +{ + // loop over all interrupt sources + for (int irqsource = 0; irqsource < 8; irqsource++) { - /* SIO write register 0 */ + int inum = k_int_priority[irqsource]; + + // find the first channel with an IEO pending + if (m_int_state[inum] & Z80_DAISY_IEO) + { + VPRINTF(("sio IRQReti %d\n", inum)); + + // clear the IEO state and update the IRQs + m_int_state[inum] &= ~Z80_DAISY_IEO; + update_interrupt_state(); + return; + } + } + + logerror("z80sio_irq_reti: failed to find an interrupt to clear IEO on!\n"); +} + + + +//************************************************************************** +// SIO CHANNEL +//************************************************************************** + +//------------------------------------------------- +// sio_channel - constructor +//------------------------------------------------- + +z80sio_device::sio_channel::sio_channel() + : m_device(NULL), + m_index(0), + m_inbuf(-1), + m_outbuf(-1), + m_int_on_next_rx(false), + m_receive_timer(NULL), + m_receive_inptr(0), + m_receive_outptr(0) +{ + memset(m_regs, 0, sizeof(m_regs)); + memset(m_status, 0, sizeof(m_status)); + memset(m_receive_buffer, 0, sizeof(m_receive_buffer)); +} + + +//------------------------------------------------- +// start - channel-specific startup +//------------------------------------------------- + +void z80sio_device::sio_channel::start(z80sio_device *device, int index) +{ + m_device = device; + m_index = index; + m_receive_timer = timer_alloc(&m_device->m_machine, static_serial_callback, this); +} + + +//------------------------------------------------- +// reset - reset a single SIO channel +//------------------------------------------------- + +void z80sio_device::sio_channel::reset() +{ + m_status[0] = SIO_RR0_TX_BUFFER_EMPTY; + m_status[1] = 0x00; + m_status[2] = 0x00; + m_int_on_next_rx = false; + m_outbuf = -1; + + // reset interrupts + clear_interrupt(INT_TRANSMIT); + clear_interrupt(INT_STATUS); + clear_interrupt(INT_RECEIVE); + clear_interrupt(INT_ERROR); + + // start the receive timer running + attotime tpc = compute_time_per_character(); + timer_adjust_periodic(m_receive_timer, tpc, 0, tpc); +} + + +//------------------------------------------------- +// control_write - write to a control register +//------------------------------------------------- + +void z80sio_device::sio_channel::control_write(UINT8 data) +{ + int regnum = m_regs[0] & 7; + + if (regnum != 0 || (regnum & 0xf8) != 0) + VPRINTF(("%s:sio_reg_w(%c,%d) = %02X\n", cpuexec_describe_context(&m_device->m_machine), 'A' + m_index, regnum, data)); + + // write a new value to the selected register + UINT8 old = m_regs[regnum]; + m_regs[regnum] = data; + + // clear the register number for the next write + if (regnum != 0) + m_regs[0] &= ~7; + + // switch off the register for live state changes + switch (regnum) + { + // SIO write register 0 case 0: switch (data & SIO_WR0_COMMAND_MASK) { case SIO_WR0_COMMAND_CH_RESET: - VPRINTF(("%s:SIO reset channel %c\n", cpuexec_describe_context(device->machine), 'A' + ch)); - reset_channel(device, ch); + VPRINTF(("%s:SIO reset channel %c\n", cpuexec_describe_context(&m_device->m_machine), 'A' + m_index)); + reset(); break; case SIO_WR0_COMMAND_RES_STATUS_INT: - sio->int_state[INT_CHA_STATUS - 4*ch] &= ~Z80_DAISY_INT; - interrupt_check(device); + clear_interrupt(INT_STATUS); break; case SIO_WR0_COMMAND_ENA_RX_INT: - chan->int_on_next_rx = TRUE; - interrupt_check(device); + m_int_on_next_rx = true; + m_device->update_interrupt_state(); break; case SIO_WR0_COMMAND_RES_TX_INT: - sio->int_state[INT_CHA_TRANSMIT - 4*ch] &= ~Z80_DAISY_INT; - interrupt_check(device); + clear_interrupt(INT_TRANSMIT); break; case SIO_WR0_COMMAND_RES_ERROR: - sio->int_state[INT_CHA_ERROR - 4*ch] &= ~Z80_DAISY_INT; - interrupt_check(device); + clear_interrupt(INT_ERROR); break; } break; - /* SIO write register 1 */ + // SIO write register 1 case 1: - interrupt_check(device); + m_device->update_interrupt_state(); break; - /* SIO write register 5 */ + // SIO write register 5 case 5: - if (((old ^ data) & SIO_WR5_DTR) && sio->dtr_changed_cb) - (*sio->dtr_changed_cb)(device, ch, (data & SIO_WR5_DTR) != 0); - if (((old ^ data) & SIO_WR5_SEND_BREAK) && sio->break_changed_cb) - (*sio->break_changed_cb)(device, ch, (data & SIO_WR5_SEND_BREAK) != 0); - if (((old ^ data) & SIO_WR5_RTS) && sio->rts_changed_cb) - (*sio->rts_changed_cb)(device, ch, (data & SIO_WR5_RTS) != 0); + if (((old ^ data) & SIO_WR5_DTR) && m_device->m_config.m_dtr_changed_cb) + (*m_device->m_config.m_dtr_changed_cb)(m_device, m_index, (data & SIO_WR5_DTR) != 0); + if (((old ^ data) & SIO_WR5_SEND_BREAK) && m_device->m_config.m_break_changed_cb) + (*m_device->m_config.m_break_changed_cb)(m_device, m_index, (data & SIO_WR5_SEND_BREAK) != 0); + if (((old ^ data) & SIO_WR5_RTS) && m_device->m_config.m_rts_changed_cb) + (*m_device->m_config.m_rts_changed_cb)(m_device, m_index, (data & SIO_WR5_RTS) != 0); break; } } -/*------------------------------------------------- - z80sio_c_r - read from a control register --------------------------------------------------*/ +//------------------------------------------------- +// control_read - read from a control register +//------------------------------------------------- -READ8_DEVICE_HANDLER( z80sio_c_r ) +UINT8 z80sio_device::sio_channel::control_read() { - z80sio *sio = get_safe_token(device); - int ch = offset & 1; - sio_channel *chan = &sio->chan[ch]; - int reg = chan->regs[0] & 7; - UINT8 result = chan->status[reg]; + int regnum = m_regs[0] & 7; + UINT8 result = m_status[regnum]; - /* switch off the register for live state changes */ - switch (reg) + // switch off the register for live state changes + switch (regnum) { - /* SIO read register 0 */ + // SIO read register 0 case 0: result &= ~SIO_RR0_INT_PENDING; - if (z80sio_irq_state(device) & Z80_DAISY_INT) + if (m_device->z80daisy_irq_state() & Z80_DAISY_INT) result |= SIO_RR0_INT_PENDING; break; } - VPRINTF(("%s:sio_reg_r(%c,%d) = %02x\n", cpuexec_describe_context(device->machine), 'A' + ch, reg, chan->status[reg])); + VPRINTF(("%s:sio_reg_r(%c,%d) = %02x\n", cpuexec_describe_context(&m_device->m_machine), 'A' + m_index, regnum, m_status[regnum])); - return chan->status[reg]; + return m_status[regnum]; } +//------------------------------------------------- +// data_write - write to a data register +//------------------------------------------------- - -/*************************************************************************** - DATA REGISTER READ/WRITE -***************************************************************************/ - -/*------------------------------------------------- - z80sio_d_w - write to a data register --------------------------------------------------*/ - -WRITE8_DEVICE_HANDLER( z80sio_d_w ) +void z80sio_device::sio_channel::data_write(UINT8 data) { - z80sio *sio = get_safe_token(device); - int ch = offset & 1; - sio_channel *chan = &sio->chan[ch]; + VPRINTF(("%s:sio_data_w(%c) = %02X\n", cpuexec_describe_context(&m_device->m_machine), 'A' + m_index, data)); - VPRINTF(("%s:sio_data_w(%c) = %02X\n", cpuexec_describe_context(device->machine), 'A' + ch, data)); - - /* if tx not enabled, just ignore it */ - if (!(chan->regs[5] & SIO_WR5_TX_ENABLE)) + // if tx not enabled, just ignore it + if (!(m_regs[5] & SIO_WR5_TX_ENABLE)) return; - /* update the status register */ - chan->status[0] &= ~SIO_RR0_TX_BUFFER_EMPTY; + // update the status register + m_status[0] &= ~SIO_RR0_TX_BUFFER_EMPTY; - /* reset the transmit interrupt */ - sio->int_state[INT_CHA_TRANSMIT - 4*ch] &= ~Z80_DAISY_INT; - interrupt_check(device); + // reset the transmit interrupt + clear_interrupt(INT_TRANSMIT); - /* stash the character */ - chan->outbuf = data; + // stash the character + m_outbuf = data; } -/*------------------------------------------------- - z80sio_d_r - read from a data register --------------------------------------------------*/ +//------------------------------------------------- +// data_read - read from a data register +//------------------------------------------------- -READ8_DEVICE_HANDLER( z80sio_d_r ) +UINT8 z80sio_device::sio_channel::data_read() { - z80sio *sio = get_safe_token(device); - int ch = offset & 1; - sio_channel *chan = &sio->chan[ch]; - - /* update the status register */ - chan->status[0] &= ~SIO_RR0_RX_CHAR_AVAILABLE; + // update the status register + m_status[0] &= ~SIO_RR0_RX_CHAR_AVAILABLE; - /* reset the receive interrupt */ - sio->int_state[INT_CHA_RECEIVE - 4*ch] &= ~Z80_DAISY_INT; - interrupt_check(device); + // reset the receive interrupt + clear_interrupt(INT_RECEIVE); - VPRINTF(("%s:sio_data_r(%c) = %02X\n", cpuexec_describe_context(device->machine), 'A' + ch, chan->inbuf)); + VPRINTF(("%s:sio_data_r(%c) = %02X\n", cpuexec_describe_context(&m_device->m_machine), 'A' + m_index, m_inbuf)); - return chan->inbuf; + return m_inbuf; } -/*************************************************************************** - CONTROL/DATA REGISTER -***************************************************************************/ - -READ8_DEVICE_HANDLER( z80sio_cd_ba_r ) -{ - switch (offset & 3) - { - case 0: return z80sio_d_r(device, 0); - case 1: return z80sio_d_r(device, 1); - case 2: return z80sio_c_r(device, 0); - case 3: return z80sio_c_r(device, 1); - } - - return 0xff; -} +//------------------------------------------------- +// dtr - return the state of the DTR line +//------------------------------------------------- -WRITE8_DEVICE_HANDLER( z80sio_cd_ba_w ) +int z80sio_device::sio_channel::dtr() { - switch (offset & 3) - { - case 0: z80sio_d_w(device, 0, data); break; - case 1: z80sio_d_w(device, 1, data); break; - case 2: z80sio_c_w(device, 0, data); break; - case 3: z80sio_c_w(device, 1, data); break; - } + return ((m_regs[5] & SIO_WR5_DTR) != 0); } -READ8_DEVICE_HANDLER( z80sio_ba_cd_r ) -{ - switch (offset & 3) - { - case 0: return z80sio_d_r(device, 0); - case 1: return z80sio_c_r(device, 0); - case 2: return z80sio_d_r(device, 1); - case 3: return z80sio_c_r(device, 1); - } - return 0xff; -} +//------------------------------------------------- +// rts - return the state of the RTS line +//------------------------------------------------- -WRITE8_DEVICE_HANDLER( z80sio_ba_cd_w ) +int z80sio_device::sio_channel::rts() { - switch (offset & 3) - { - case 0: z80sio_d_w(device, 0, data); break; - case 1: z80sio_c_w(device, 0, data); break; - case 2: z80sio_d_w(device, 1, data); break; - case 3: z80sio_c_w(device, 1, data); break; - } + return ((m_regs[5] & SIO_WR5_RTS) != 0); } -/*************************************************************************** - CONTROL LINE READ/WRITE -***************************************************************************/ - -/*------------------------------------------------- - z80sio_get_dtr - return the state of the DTR - line --------------------------------------------------*/ +//------------------------------------------------- +// set_cts - set the state of the CTS line +//------------------------------------------------- -READ8_DEVICE_HANDLER( z80sio_get_dtr ) +void z80sio_device::sio_channel::set_cts(int state) { - z80sio *sio = get_safe_token(device); - sio_channel *chan = &sio->chan[offset & 1]; - return ((chan->regs[5] & SIO_WR5_DTR) != 0); + timer_call_after_resynch(&m_device->m_machine, this, (SIO_RR0_CTS << 1) + (state != 0), static_change_input_line); } -/*------------------------------------------------- - z80sio_get_rts - return the state of the RTS - line --------------------------------------------------*/ +//------------------------------------------------- +// set_dcd - set the state of the DCD line +//------------------------------------------------- -READ8_DEVICE_HANDLER( z80sio_get_rts ) +void z80sio_device::sio_channel::set_dcd(int state) { - z80sio *sio = get_safe_token(device); - sio_channel *chan = &sio->chan[offset & 1]; - return ((chan->regs[5] & SIO_WR5_RTS) != 0); + timer_call_after_resynch(&m_device->m_machine, this, (SIO_RR0_DCD << 1) + (state != 0), static_change_input_line); } -/*------------------------------------------------- - z80sio_set_cts - set the state of the CTS - line --------------------------------------------------*/ +//------------------------------------------------- +// receive_data - receive data on the input lines +//------------------------------------------------- -static TIMER_CALLBACK( change_input_line ) +void z80sio_device::sio_channel::receive_data(int data) { - running_device *device = (running_device *)ptr; - z80sio *sio = get_safe_token(device); - sio_channel *chan = &sio->chan[param & 1]; - UINT8 line = (param >> 8) & 0xff; - int state = (param >> 7) & 1; - int ch = param & 1; - UINT8 old; - - VPRINTF(("sio_change_input_line(%c, %s) = %d\n", 'A' + ch, (line == SIO_RR0_CTS) ? "CTS" : "DCD", state)); - - /* remember the old value */ - old = chan->status[0]; - - /* set the bit in the status register */ - chan->status[0] &= ~line; - if (state) - chan->status[0] |= line; - - /* if state change interrupts are enabled, signal */ - if (((old ^ chan->status[0]) & line) && (chan->regs[1] & SIO_WR1_STATUSINT_ENABLE)) + // put it on the queue + int newinptr = (m_receive_inptr + 1) % ARRAY_LENGTH(m_receive_buffer); + if (newinptr != m_receive_outptr) { - sio->int_state[INT_CHA_STATUS - 4*ch] |= Z80_DAISY_INT; - interrupt_check(device); + m_receive_buffer[m_receive_inptr] = data; + m_receive_inptr = newinptr; } + else + logerror("z80sio_receive_data: buffer overrun\n"); } -/*------------------------------------------------- - z80sio_set_cts - set the state of the CTS - line --------------------------------------------------*/ - -WRITE8_DEVICE_HANDLER( z80sio_set_cts ) -{ - /* operate deferred */ - void *ptr = (void *)device; - timer_call_after_resynch(device->machine, ptr, (SIO_RR0_CTS << 8) + (data != 0) * 0x80 + (offset & 1), change_input_line); -} - - -/*------------------------------------------------- - z80sio_set_dcd - set the state of the DCD - line --------------------------------------------------*/ +//------------------------------------------------- +// change_input_line - generically change the +// state of an input line; designed to be called +// from a timer callback +//------------------------------------------------- -WRITE8_DEVICE_HANDLER( z80sio_set_dcd ) +void z80sio_device::sio_channel::change_input_line(int line, int state) { - /* operate deferred */ - void *ptr = (void *)device; - timer_call_after_resynch(device->machine, ptr, (SIO_RR0_DCD << 8) + (data != 0) * 0x80 + (offset & 1), change_input_line); -} + VPRINTF(("sio_change_input_line(%c, %s) = %d\n", 'A' + m_index, (line == SIO_RR0_CTS) ? "CTS" : "DCD", state)); + // remember the old value + UINT8 old = m_status[0]; -/*------------------------------------------------- - z80sio_receive_data - receive data on the - input lines --------------------------------------------------*/ - -WRITE8_DEVICE_HANDLER( z80sio_receive_data ) -{ - z80sio *sio = get_safe_token(device); - sio_channel *chan = &sio->chan[offset & 1]; - int newinptr; + // set the bit in the status register + m_status[0] &= ~line; + if (state) + m_status[0] |= line; - /* put it on the queue */ - newinptr = (chan->receive_inptr + 1) % ARRAY_LENGTH(chan->receive_buffer); - if (newinptr != chan->receive_outptr) - { - chan->receive_buffer[chan->receive_inptr] = data; - chan->receive_inptr = newinptr; - } - else - logerror("z80sio_receive_data: buffer overrun\n"); + // if state change interrupts are enabled, signal + if (((old ^ m_status[0]) & line) && (m_regs[1] & SIO_WR1_STATUSINT_ENABLE)) + set_interrupt(INT_STATUS); } -/*------------------------------------------------- - serial_callback - callback to pump - data through --------------------------------------------------*/ +//------------------------------------------------- +// serial_callback - callback to pump +// data through +//------------------------------------------------- -static TIMER_CALLBACK( serial_callback ) +void z80sio_device::sio_channel::serial_callback() { - running_device *device = (running_device *)ptr; - z80sio *sio = get_safe_token(device); - sio_channel *chan = &sio->chan[param]; - int ch = param; int data = -1; - /* first perform any outstanding transmits */ - if (chan->outbuf != -1) + // first perform any outstanding transmits + if (m_outbuf != -1) { - VPRINTF(("serial_callback(%c): Transmitting %02x\n", 'A' + ch, chan->outbuf)); + VPRINTF(("serial_callback(%c): Transmitting %02x\n", 'A' + m_index, m_outbuf)); - /* actually transmit the character */ - if (sio->transmit_cb != NULL) - (*sio->transmit_cb)(device, ch, chan->outbuf); + // actually transmit the character + if (m_device->m_config.m_transmit_cb != NULL) + (*m_device->m_config.m_transmit_cb)(m_device, m_index, m_outbuf); - /* update the status register */ - chan->status[0] |= SIO_RR0_TX_BUFFER_EMPTY; + // update the status register + m_status[0] |= SIO_RR0_TX_BUFFER_EMPTY; - /* set the transmit buffer empty interrupt if enabled */ - if (chan->regs[1] & SIO_WR1_TXINT_ENABLE) - { - sio->int_state[INT_CHA_TRANSMIT - 4*ch] |= Z80_DAISY_INT; - interrupt_check(device); - } + // set the transmit buffer empty interrupt if enabled + if (m_regs[1] & SIO_WR1_TXINT_ENABLE) + set_interrupt(INT_TRANSMIT); - /* reset the output buffer */ - chan->outbuf = -1; + // reset the output buffer + m_outbuf = -1; } - /* ask the polling callback if there is data to receive */ - if (sio->receive_poll_cb != NULL) - data = (*sio->receive_poll_cb)(device, ch); + // ask the polling callback if there is data to receive + if (m_device->m_config.m_receive_poll_cb != NULL) + data = (*m_device->m_config.m_receive_poll_cb)(m_device, m_index); - /* if we have buffered data, pull it */ - if (chan->receive_inptr != chan->receive_outptr) + // if we have buffered data, pull it + if (m_receive_inptr != m_receive_outptr) { - data = chan->receive_buffer[chan->receive_outptr]; - chan->receive_outptr = (chan->receive_outptr + 1) % ARRAY_LENGTH(chan->receive_buffer); + data = m_receive_buffer[m_receive_outptr]; + m_receive_outptr = (m_receive_outptr + 1) % ARRAY_LENGTH(m_receive_buffer); } - /* if we have data, receive it */ + // if we have data, receive it if (data != -1) { - VPRINTF(("serial_callback(%c): Receiving %02x\n", 'A' + ch, data)); + VPRINTF(("serial_callback(%c): Receiving %02x\n", 'A' + m_index, data)); - /* if rx not enabled, just ignore it */ - if (!(chan->regs[3] & SIO_WR3_RX_ENABLE)) + // if rx not enabled, just ignore it + if (!(m_regs[3] & SIO_WR3_RX_ENABLE)) { VPRINTF((" (ignored because receive is disabled)\n")); return; } - /* stash the data and update the status */ - chan->inbuf = data; - chan->status[0] |= SIO_RR0_RX_CHAR_AVAILABLE; + // stash the data and update the status + m_inbuf = data; + m_status[0] |= SIO_RR0_RX_CHAR_AVAILABLE; - /* update our interrupt state */ - switch (chan->regs[1] & SIO_WR1_RXINT_MASK) + // update our interrupt state + switch (m_regs[1] & SIO_WR1_RXINT_MASK) { case SIO_WR1_RXINT_FIRST: - if (!chan->int_on_next_rx) + if (!m_int_on_next_rx) break; case SIO_WR1_RXINT_ALL_NOPARITY: case SIO_WR1_RXINT_ALL_PARITY: - sio->int_state[INT_CHA_RECEIVE - 4*ch] |= Z80_DAISY_INT; - interrupt_check(device); + set_interrupt(INT_RECEIVE); break; } - chan->int_on_next_rx = FALSE; + m_int_on_next_rx = false; } } -/*************************************************************************** - DAISY CHAIN INTERFACE -***************************************************************************/ - -static const UINT8 int_priority[] = -{ - INT_CHA_RECEIVE, - INT_CHA_TRANSMIT, - INT_CHA_STATUS, - INT_CHA_ERROR, - INT_CHB_RECEIVE, - INT_CHB_TRANSMIT, - INT_CHB_STATUS, - INT_CHB_ERROR -}; +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** +WRITE8_DEVICE_HANDLER( z80sio_c_w ) { downcast(device)->control_write(offset & 1, data); } +WRITE8_DEVICE_HANDLER( z80sio_d_w ) { downcast(device)->data_write(offset & 1, data); } +READ8_DEVICE_HANDLER( z80sio_c_r ) { return downcast(device)->control_read(offset & 1); } +READ8_DEVICE_HANDLER( z80sio_d_r ) { return downcast(device)->data_read(offset & 1); } -static int z80sio_irq_state(running_device *device) -{ - z80sio *sio = get_safe_token(device); - int state = 0; - int i; +READ8_DEVICE_HANDLER( z80sio_get_dtr ) { return downcast(device)->dtr(offset & 1); } +READ8_DEVICE_HANDLER( z80sio_get_rts ) { return downcast(device)->rts(offset & 1); } - VPRINTF(("sio IRQ state = B:%d%d%d%d A:%d%d%d%d\n", - sio->int_state[0], sio->int_state[1], sio->int_state[2], sio->int_state[3], - sio->int_state[4], sio->int_state[5], sio->int_state[6], sio->int_state[7])); +WRITE8_DEVICE_HANDLER( z80sio_set_cts ) { downcast(device)->set_cts(offset & 1, data); } +WRITE8_DEVICE_HANDLER( z80sio_set_dcd ) { downcast(device)->set_dcd(offset & 1, data); } +WRITE8_DEVICE_HANDLER( z80sio_receive_data ) { downcast(device)->receive_data(offset & 1, data); } - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) +READ8_DEVICE_HANDLER( z80sio_cd_ba_r ) +{ + switch (offset & 3) { - int inum = int_priority[i]; - - /* if we're servicing a request, don't indicate more interrupts */ - if (sio->int_state[inum] & Z80_DAISY_IEO) - { - state |= Z80_DAISY_IEO; - break; - } - state |= sio->int_state[inum]; + case 0: return z80sio_d_r(device, 0); + case 1: return z80sio_d_r(device, 1); + case 2: return z80sio_c_r(device, 0); + case 3: return z80sio_c_r(device, 1); } - return state; + return 0xff; } - -static int z80sio_irq_ack(running_device *device) +WRITE8_DEVICE_HANDLER( z80sio_cd_ba_w ) { - z80sio *sio = get_safe_token(device); - int i; - - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) + switch (offset & 3) { - int inum = int_priority[i]; - - /* find the first channel with an interrupt requested */ - if (sio->int_state[inum] & Z80_DAISY_INT) - { - VPRINTF(("sio IRQAck %d\n", inum)); - - /* clear interrupt, switch to the IEO state, and update the IRQs */ - sio->int_state[inum] = Z80_DAISY_IEO; - interrupt_check(device); - return sio->chan[1].regs[2] + inum * 2; - } + case 0: z80sio_d_w(device, 0, data); break; + case 1: z80sio_d_w(device, 1, data); break; + case 2: z80sio_c_w(device, 0, data); break; + case 3: z80sio_c_w(device, 1, data); break; } - - logerror("z80sio_irq_ack: failed to find an interrupt to ack!\n"); - return sio->chan[1].regs[2]; } - -static void z80sio_irq_reti(running_device *device) +READ8_DEVICE_HANDLER( z80sio_ba_cd_r ) { - z80sio *sio = get_safe_token(device); - int i; - - /* loop over all interrupt sources */ - for (i = 0; i < 8; i++) + switch (offset & 3) { - int inum = int_priority[i]; - - /* find the first channel with an IEO pending */ - if (sio->int_state[inum] & Z80_DAISY_IEO) - { - VPRINTF(("sio IRQReti %d\n", inum)); - - /* clear the IEO state and update the IRQs */ - sio->int_state[inum] &= ~Z80_DAISY_IEO; - interrupt_check(device); - return; - } + case 0: return z80sio_d_r(device, 0); + case 1: return z80sio_c_r(device, 0); + case 2: return z80sio_d_r(device, 1); + case 3: return z80sio_c_r(device, 1); } - logerror("z80sio_irq_reti: failed to find an interrupt to clear IEO on!\n"); -} - - -static DEVICE_START( z80sio ) -{ - const z80sio_interface *intf = (const z80sio_interface *)device->baseconfig().static_config; - z80sio *sio = get_safe_token(device); - void *ptr = (void *)device; - astring tempstring; - - sio->chan[0].receive_timer = timer_alloc(device->machine, serial_callback, ptr); - sio->chan[1].receive_timer = timer_alloc(device->machine, serial_callback, ptr); - - sio->irq_cb = intf->irq_cb; - sio->dtr_changed_cb = intf->dtr_changed_cb; - sio->rts_changed_cb = intf->rts_changed_cb; - sio->break_changed_cb = intf->break_changed_cb; - sio->transmit_cb = intf->transmit_cb; - sio->receive_poll_cb = intf->receive_poll_cb; -} - - -static DEVICE_RESET( z80sio ) -{ - int ch; - - /* loop over channels */ - for (ch = 0; ch < 2; ch++) - reset_channel(device, ch); + return 0xff; } - -DEVICE_GET_INFO( z80sio ) +WRITE8_DEVICE_HANDLER( z80sio_ba_cd_w ) { - switch (state) + switch (offset & 3) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80sio); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80sio);break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80sio);break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80sio_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80sio_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80sio_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Zilog Z80 SIO"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + case 0: z80sio_d_w(device, 0, data); break; + case 1: z80sio_c_w(device, 0, data); break; + case 2: z80sio_d_w(device, 1, data); break; + case 3: z80sio_c_w(device, 1, data); break; } } - diff --git a/src/emu/machine/z80sio.h b/src/emu/machine/z80sio.h index 93b73e91ab4..34e3d3903c5 100644 --- a/src/emu/machine/z80sio.h +++ b/src/emu/machine/z80sio.h @@ -10,43 +10,173 @@ #ifndef __Z80SIO_H__ #define __Z80SIO_H__ +#include "cpu/z80/z80daisy.h" + + +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_Z80SIO_ADD(_tag, _clock, _intrf) \ + MDRV_DEVICE_ADD(_tag, Z80SIO, _clock) \ + MDRV_DEVICE_CONFIG(_intrf) + -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -typedef struct _z80sio_interface z80sio_interface; -struct _z80sio_interface +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> z80sio_interface + +struct z80sio_interface { - void (*irq_cb)(running_device *device, int state); - write8_device_func dtr_changed_cb; - write8_device_func rts_changed_cb; - write8_device_func break_changed_cb; - write8_device_func transmit_cb; - int (*receive_poll_cb)(running_device *device, int channel); + void (*m_irq_cb)(device_t *device, int state); + write8_device_func m_dtr_changed_cb; + write8_device_func m_rts_changed_cb; + write8_device_func m_break_changed_cb; + write8_device_func m_transmit_cb; + int (*m_receive_poll_cb)(device_t *device, int channel); }; -/*************************************************************************** - DEVICE CONFIGURATION MACROS -***************************************************************************/ +// ======================> z80sio_device_config -#define MDRV_Z80SIO_ADD(_tag, _clock, _intrf) \ - MDRV_DEVICE_ADD(_tag, Z80SIO, _clock) \ - MDRV_DEVICE_CONFIG(_intrf) +class z80sio_device_config : public device_config, + public device_config_z80daisy_interface, + public z80sio_interface +{ + friend class z80sio_device; + + // construction/destruction + z80sio_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Zilog Z80 SIO"; } + +protected: + // device_config overrides + virtual void device_config_complete(); +}; -/*************************************************************************** - CONTROL/DATA REGISTER READ/WRITE -***************************************************************************/ +// ======================> z80sio_device + +class z80sio_device : public device_t, + public device_z80daisy_interface +{ + friend class z80sio_device_config; + + // construction/destruction + z80sio_device(running_machine &_machine, const z80sio_device_config &config); + +public: + // control register I/O + UINT8 control_read(int ch) { return m_channel[ch].control_read(); } + void control_write(int ch, UINT8 data) { m_channel[ch].control_write(data); } + + // data register I/O + UINT8 data_read(int ch) { return m_channel[ch].data_read(); } + void data_write(int ch, UINT8 data) { m_channel[ch].data_write(data); } + + // communication line I/O + int dtr(int ch) { return m_channel[ch].dtr(); } + int rts(int ch) { return m_channel[ch].rts(); } + void set_cts(int ch, int state) { m_channel[ch].set_cts(state); } + void set_dcd(int ch, int state) { m_channel[ch].set_dcd(state); } + void receive_data(int ch, int data) { m_channel[ch].receive_data(data); } + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal helpers + void update_interrupt_state(); + + // a single SIO channel + class sio_channel + { + public: + sio_channel(); + + void start(z80sio_device *device, int index); + void reset(); + + UINT8 control_read(); + UINT8 data_read(); + void control_write(UINT8 data); + void data_write(UINT8 data); + + int dtr(); + int rts(); + void set_cts(int state); + void set_dcd(int state); + void receive_data(int data); + + private: + void set_interrupt(int type); + void clear_interrupt(int type); + attotime compute_time_per_character(); + + static TIMER_CALLBACK( static_change_input_line ) { reinterpret_cast(ptr)->change_input_line(param >> 1, param & 1); } + void change_input_line(int line, int state); + + static TIMER_CALLBACK( static_serial_callback ) { reinterpret_cast(ptr)->serial_callback(); } + void serial_callback(); + + public: + UINT8 m_regs[8]; // 8 writeable registers + + private: + z80sio_device *m_device; // pointer back to our device + int m_index; // our channel index + UINT8 m_status[4]; // 3 readable registers + int m_inbuf; // input buffer + int m_outbuf; // output buffer + bool m_int_on_next_rx; // interrupt on next rx? + emu_timer * m_receive_timer; // timer to clock data in + UINT8 m_receive_buffer[16]; // buffer for incoming data + UINT8 m_receive_inptr; // index of data coming in + UINT8 m_receive_outptr; // index of data going out + }; + + // internal state + const z80sio_device_config &m_config; + sio_channel m_channel[2]; // 2 channels + UINT8 m_int_state[8]; // interrupt states + + static const UINT8 k_int_priority[]; +}; + -/* register access (A1=C/_D A0=B/_A) */ +// device type definition +const device_type Z80SIO = z80sio_device_config::static_alloc_device_config; + + + +//************************************************************************** +// CONTROL/DATA REGISTER READ/WRITE +//************************************************************************** + +// register access (A1=C/_D A0=B/_A) READ8_DEVICE_HANDLER( z80sio_cd_ba_r ); WRITE8_DEVICE_HANDLER( z80sio_cd_ba_w ); -/* register access (A1=B/_A A0=C/_D) */ +// register access (A1=B/_A A0=C/_D) READ8_DEVICE_HANDLER( z80sio_ba_cd_r ); WRITE8_DEVICE_HANDLER( z80sio_ba_cd_w ); @@ -57,9 +187,9 @@ WRITE8_DEVICE_HANDLER( z80sio_d_w ); READ8_DEVICE_HANDLER( z80sio_d_r ); -/*************************************************************************** - CONTROL LINE READ/WRITE -***************************************************************************/ +//************************************************************************** +// CONTROL LINE READ/WRITE +//************************************************************************** READ8_DEVICE_HANDLER( z80sio_get_dtr ); READ8_DEVICE_HANDLER( z80sio_get_rts ); @@ -68,9 +198,4 @@ WRITE8_DEVICE_HANDLER( z80sio_set_dcd ); WRITE8_DEVICE_HANDLER( z80sio_receive_data ); -/* ----- device interface ----- */ - -#define Z80SIO DEVICE_GET_INFO_NAME(z80sio) -DEVICE_GET_INFO( z80sio ); - #endif diff --git a/src/emu/machine/z80sti.c b/src/emu/machine/z80sti.c index bc8961096f3..9692636ecf6 100644 --- a/src/emu/machine/z80sti.c +++ b/src/emu/machine/z80sti.c @@ -22,15 +22,23 @@ #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" -/*************************************************************************** - PARAMETERS -***************************************************************************/ + + +//************************************************************************** +// DEBUGGING +//************************************************************************** #define VERBOSE 0 #define LOG(x) do { if (VERBOSE) logerror x; } while (0) -/* registers */ + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// registers enum { Z80STI_REGISTER_IR = 0, @@ -51,7 +59,7 @@ enum Z80STI_REGISTER_UDR }; -/* variable registers */ +// variable registers enum { Z80STI_REGISTER_IR_SCR = 0, @@ -64,7 +72,7 @@ enum Z80STI_REGISTER_IR_TCDC }; -/* timers */ +// timers enum { TIMER_A = 0, @@ -74,7 +82,7 @@ enum TIMER_COUNT }; -/* interrupt levels */ +// interrupt levels enum { Z80STI_IR_P0 = 0, @@ -95,281 +103,442 @@ enum Z80STI_IR_P7 }; -/* timer C/D control register */ -#define Z80STI_TCDC_TARS 0x80 -#define Z80STI_TCDC_TBRS 0x08 +// timer C/D control register +const int Z80STI_TCDC_TARS = 0x80; +const int Z80STI_TCDC_TBRS = 0x08; -/* interrupt vector register */ -#define Z80STI_PVR_ISE 0x08 -#define Z80STI_PVR_VR4 0x10 +// interrupt vector register +const int Z80STI_PVR_ISE = 0x08; +const int Z80STI_PVR_VR4 = 0x10; -/* general purpose I/O interrupt levels */ +// general purpose I/O interrupt levels static const int INT_LEVEL_GPIP[] = { Z80STI_IR_P0, Z80STI_IR_P1, Z80STI_IR_P2, Z80STI_IR_P3, Z80STI_IR_P4, Z80STI_IR_P5, Z80STI_IR_P6, Z80STI_IR_P7 }; -/* timer interrupt levels */ +// timer interrupt levels static const int INT_LEVEL_TIMER[] = { Z80STI_IR_TA, Z80STI_IR_TB, Z80STI_IR_TC, Z80STI_IR_TD }; -/* interrupt vectors */ +// interrupt vectors static const UINT8 INT_VECTOR[] = { 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e }; -/* timer prescaler divisors */ +// timer prescaler divisors static const int PRESCALER[] = { 0, 4, 10, 16, 50, 64, 100, 200 }; -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -typedef struct _z80sti_t z80sti_t; -struct _z80sti_t + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// z80sti_device_config - constructor +//------------------------------------------------- + +z80sti_device_config::z80sti_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_z80daisy_interface(mconfig, *this) { - /* device callbacks */ - devcb_resolved_read8 in_gpio_func; - devcb_resolved_write8 out_gpio_func; - devcb_resolved_read_line in_si_func; - devcb_resolved_write_line out_so_func; - devcb_resolved_write_line out_tao_func; - devcb_resolved_write_line out_tbo_func; - devcb_resolved_write_line out_tco_func; - devcb_resolved_write_line out_tdo_func; - devcb_resolved_write_line out_int_func; - - /* I/O state */ - UINT8 gpip; /* general purpose I/O register */ - UINT8 aer; /* active edge register */ - UINT8 ddr; /* data direction register */ - - /* interrupt state */ - UINT16 ier; /* interrupt enable register */ - UINT16 ipr; /* interrupt pending register */ - UINT16 isr; /* interrupt in-service register */ - UINT16 imr; /* interrupt mask register */ - UINT8 pvr; /* interrupt vector register */ - int int_state[16]; /* interrupt state */ - - /* timer state */ - UINT8 tabc; /* timer A/B control register */ - UINT8 tcdc; /* timer C/D control register */ - UINT8 tdr[TIMER_COUNT]; /* timer data registers */ - UINT8 tmc[TIMER_COUNT]; /* timer main counters */ - int to[TIMER_COUNT]; /* timer out latch */ - - /* serial state */ - UINT8 scr; /* synchronous character register */ - UINT8 ucr; /* USART control register */ - UINT8 tsr; /* transmitter status register */ - UINT8 rsr; /* receiver status register */ - UINT8 udr; /* USART data register */ - - /* timers */ - emu_timer *timer[TIMER_COUNT]; /* counter timers */ - emu_timer *rx_timer; /* serial receive timer */ - emu_timer *tx_timer; /* serial transmit timer */ -}; +} -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ -static int z80sti_irq_state(running_device *device); -static void z80sti_irq_reti(running_device *device); +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *z80sti_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(z80sti_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *z80sti_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, z80sti_device(machine, *this)); +} -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ -INLINE z80sti_t *get_safe_token(running_device *device) +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void z80sti_device_config::device_config_complete() { - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == Z80STI); - return (z80sti_t *)device->token; + // inherit a copy of the static data + const z80sti_interface *intf = reinterpret_cast(static_config()); + if (intf != NULL) + *static_cast(this) = *intf; + + // or initialize to defaults if none provided + else + { + m_rx_clock = m_tx_clock = 0; + memset(&m_out_int_func, 0, sizeof(m_out_int_func)); + memset(&m_in_gpio_func, 0, sizeof(m_in_gpio_func)); + memset(&m_out_gpio_func, 0, sizeof(m_out_gpio_func)); + memset(&m_in_si_func, 0, sizeof(m_in_si_func)); + memset(&m_out_so_func, 0, sizeof(m_out_so_func)); + memset(&m_out_tao_func, 0, sizeof(m_out_tao_func)); + memset(&m_out_tbo_func, 0, sizeof(m_out_tbo_func)); + memset(&m_out_tco_func, 0, sizeof(m_out_tco_func)); + memset(&m_out_tdo_func, 0, sizeof(m_out_tdo_func)); + } } -INLINE const z80sti_interface *get_interface(running_device *device) + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// z80sti_device - constructor +//------------------------------------------------- + +z80sti_device::z80sti_device(running_machine &_machine, const z80sti_device_config &config) + : device_t(_machine, config), + device_z80daisy_interface(_machine, config, *this), + m_config(config) { - assert(device != NULL); - assert((device->type == Z80STI)); - return (const z80sti_interface *) device->baseconfig().static_config; } -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ -/*------------------------------------------------- - check_interrupts - set the interrupt request - line state --------------------------------------------------*/ +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- -static void check_interrupts(z80sti_t *z80sti) +void z80sti_device::device_start() { - if (z80sti->ipr & z80sti->imr) + // resolve callbacks + devcb_resolve_read8(&m_in_gpio_func, &m_config.m_in_gpio_func, this); + devcb_resolve_write8(&m_out_gpio_func, &m_config.m_out_gpio_func, this); + devcb_resolve_read_line(&m_in_si_func, &m_config.m_in_si_func, this); + devcb_resolve_write_line(&m_out_so_func, &m_config.m_out_so_func, this); + devcb_resolve_write_line(&m_out_timer_func[TIMER_A], &m_config.m_out_tao_func, this); + devcb_resolve_write_line(&m_out_timer_func[TIMER_B], &m_config.m_out_tbo_func, this); + devcb_resolve_write_line(&m_out_timer_func[TIMER_C], &m_config.m_out_tco_func, this); + devcb_resolve_write_line(&m_out_timer_func[TIMER_D], &m_config.m_out_tdo_func, this); + devcb_resolve_write_line(&m_out_int_func, &m_config.m_out_int_func, this); + + // create the counter timers + m_timer[TIMER_A] = timer_alloc(&m_machine, static_timer_count, (void *)this); + m_timer[TIMER_B] = timer_alloc(&m_machine, static_timer_count, (void *)this); + m_timer[TIMER_C] = timer_alloc(&m_machine, static_timer_count, (void *)this); + m_timer[TIMER_D] = timer_alloc(&m_machine, static_timer_count, (void *)this); + + // create serial receive clock timer + if (m_config.m_rx_clock > 0) { - devcb_call_write_line(&z80sti->out_int_func, ASSERT_LINE); + m_rx_timer = timer_alloc(&m_machine, static_rx_tick, (void *)this); + timer_adjust_periodic(m_rx_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_rx_clock)); } - else + + // create serial transmit clock timer + if (m_config.m_tx_clock > 0) { - devcb_call_write_line(&z80sti->out_int_func, CLEAR_LINE); + m_tx_timer = timer_alloc(&m_machine, static_tx_tick, (void *)this); + timer_adjust_periodic(m_tx_timer, attotime_zero, 0, ATTOTIME_IN_HZ(m_config.m_tx_clock)); } + + // register for state saving + state_save_register_device_item(this, 0, m_gpip); + state_save_register_device_item(this, 0, m_aer); + state_save_register_device_item(this, 0, m_ddr); + state_save_register_device_item(this, 0, m_ier); + state_save_register_device_item(this, 0, m_ipr); + state_save_register_device_item(this, 0, m_isr); + state_save_register_device_item(this, 0, m_imr); + state_save_register_device_item(this, 0, m_pvr); + state_save_register_device_item_array(this, 0, m_int_state); + state_save_register_device_item(this, 0, m_tabc); + state_save_register_device_item(this, 0, m_tcdc); + state_save_register_device_item_array(this, 0, m_tdr); + state_save_register_device_item_array(this, 0, m_tmc); + state_save_register_device_item_array(this, 0, m_to); + state_save_register_device_item(this, 0, m_scr); + state_save_register_device_item(this, 0, m_ucr); + state_save_register_device_item(this, 0, m_rsr); + state_save_register_device_item(this, 0, m_tsr); + state_save_register_device_item(this, 0, m_udr); + } -/*------------------------------------------------- - take_interrupt - mark an interrupt pending --------------------------------------------------*/ -static void take_interrupt(z80sti_t *z80sti, int level) +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void z80sti_device::device_reset() { - /* set interrupt pending register bit */ - z80sti->ipr |= 1 << level; +} + + + +//************************************************************************** +// DAISY CHAIN INTERFACE +//************************************************************************** + +//------------------------------------------------- +// z80daisy_irq_state - get interrupt status +//------------------------------------------------- + +int z80sti_device::z80daisy_irq_state() +{ + int state = 0, i; + + // loop over all interrupt sources + for (i = 15; i >= 0; i--) + { + // if we're servicing a request, don't indicate more interrupts + if (m_int_state[i] & Z80_DAISY_IEO) + { + state |= Z80_DAISY_IEO; + break; + } - /* trigger interrupt */ - z80sti->int_state[level] |= Z80_DAISY_INT; + if (BIT(m_imr, i)) + { + state |= m_int_state[i]; + } + } - check_interrupts(z80sti); + LOG(("Z80STI '%s' Interrupt State: %u\n", tag(), state)); + + return state; } -/*------------------------------------------------- - serial_receive - receive serial bit --------------------------------------------------*/ -static void serial_receive(z80sti_t *z80sti) +//------------------------------------------------- +// z80daisy_irq_ack - interrupt acknowledge +//------------------------------------------------- + +int z80sti_device::z80daisy_irq_ack() { + int i; + + // loop over all interrupt sources + for (i = 15; i >= 0; i--) + { + // find the first channel with an interrupt requested + if (m_int_state[i] & Z80_DAISY_INT) + { + UINT8 vector = (m_pvr & 0xe0) | INT_VECTOR[i]; + + // clear interrupt, switch to the IEO state, and update the IRQs + m_int_state[i] = Z80_DAISY_IEO; + + // clear interrupt pending register bit + m_ipr &= ~(1 << i); + + // set interrupt in-service register bit + m_isr |= (1 << i); + + check_interrupts(); + + LOG(("Z80STI '%s' Interrupt Acknowledge Vector: %02x\n", tag(), vector)); + + return vector; + } + } + + logerror("z80sti_irq_ack: failed to find an interrupt to ack!\n"); + + return 0; } -/*------------------------------------------------- - TIMER_CALLBACK( rx_tick ) --------------------------------------------------*/ -static TIMER_CALLBACK( rx_tick ) +//------------------------------------------------- +// z80daisy_irq_reti - return from interrupt +//------------------------------------------------- + +void z80sti_device::z80daisy_irq_reti() { - running_device *device = (running_device *)ptr; - z80sti_t *z80sti = get_safe_token(device); + int i; + + LOG(("Z80STI '%s' Return from Interrupt\n", tag())); + + // loop over all interrupt sources + for (i = 15; i >= 0; i--) + { + // find the first channel with an IEO pending + if (m_int_state[i] & Z80_DAISY_IEO) + { + // clear the IEO state and update the IRQs + m_int_state[i] &= ~Z80_DAISY_IEO; + + // clear interrupt in-service register bit + m_isr &= ~(1 << i); + + check_interrupts(); + return; + } + } - serial_receive(z80sti); + logerror("z80sti_irq_reti: failed to find an interrupt to clear IEO on!\n"); } -/*------------------------------------------------- - serial_transmit - transmit serial bit --------------------------------------------------*/ -static void serial_transmit(z80sti_t *z80sti) + +//************************************************************************** +// IMPLEMENTATION +//************************************************************************** + +//------------------------------------------------- +// check_interrupts - set the interrupt request +// line state +//------------------------------------------------- + +void z80sti_device::check_interrupts() { + if (m_ipr & m_imr) + { + devcb_call_write_line(&m_out_int_func, ASSERT_LINE); + } + else + { + devcb_call_write_line(&m_out_int_func, CLEAR_LINE); + } } -/*------------------------------------------------- - TIMER_CALLBACK( tx_tick ) --------------------------------------------------*/ -static TIMER_CALLBACK( tx_tick ) +//------------------------------------------------- +// take_interrupt - mark an interrupt pending +//------------------------------------------------- + +void z80sti_device::take_interrupt(int level) { - running_device *device = (running_device *)ptr; - z80sti_t *z80sti = get_safe_token(device); + // set interrupt pending register bit + m_ipr |= 1 << level; + + // trigger interrupt + m_int_state[level] |= Z80_DAISY_INT; - serial_transmit(z80sti); + check_interrupts(); } -/*------------------------------------------------- - z80sti_r - register read --------------------------------------------------*/ -READ8_DEVICE_HANDLER( z80sti_r ) +//------------------------------------------------- +// serial_receive - receive serial bit +//------------------------------------------------- + +void z80sti_device::serial_receive() { - z80sti_t *z80sti = get_safe_token(device); +} + + +//------------------------------------------------- +// serial_transmit - transmit serial bit +//------------------------------------------------- + +void z80sti_device::serial_transmit() +{ +} + +//------------------------------------------------- +// read - register read +//------------------------------------------------- + +UINT8 z80sti_device::read(offs_t offset) +{ switch (offset & 0x0f) { case Z80STI_REGISTER_IR: - switch (z80sti->pvr & 0x07) + switch (m_pvr & 0x07) { - case Z80STI_REGISTER_IR_SCR: return z80sti->scr; - case Z80STI_REGISTER_IR_TDDR: return z80sti->tmc[TIMER_D]; - case Z80STI_REGISTER_IR_TCDR: return z80sti->tmc[TIMER_C]; - case Z80STI_REGISTER_IR_AER: return z80sti->aer; - case Z80STI_REGISTER_IR_IERB: return z80sti->ier & 0xff; - case Z80STI_REGISTER_IR_IERA: return z80sti->ier >> 8; - case Z80STI_REGISTER_IR_DDR: return z80sti->ddr; - case Z80STI_REGISTER_IR_TCDC: return z80sti->tcdc; + case Z80STI_REGISTER_IR_SCR: return m_scr; + case Z80STI_REGISTER_IR_TDDR: return m_tmc[TIMER_D]; + case Z80STI_REGISTER_IR_TCDR: return m_tmc[TIMER_C]; + case Z80STI_REGISTER_IR_AER: return m_aer; + case Z80STI_REGISTER_IR_IERB: return m_ier & 0xff; + case Z80STI_REGISTER_IR_IERA: return m_ier >> 8; + case Z80STI_REGISTER_IR_DDR: return m_ddr; + case Z80STI_REGISTER_IR_TCDC: return m_tcdc; } break; - case Z80STI_REGISTER_GPIP: z80sti->gpip = (devcb_call_read8(&z80sti->in_gpio_func, 0) & ~z80sti->ddr) | (z80sti->gpip & z80sti->ddr); return z80sti->gpip; - case Z80STI_REGISTER_IPRB: return z80sti->ipr & 0xff; - case Z80STI_REGISTER_IPRA: return z80sti->ipr >> 8; - case Z80STI_REGISTER_ISRB: return z80sti->isr & 0xff; - case Z80STI_REGISTER_ISRA: return z80sti->isr >> 8; - case Z80STI_REGISTER_IMRB: return z80sti->imr & 0xff; - case Z80STI_REGISTER_IMRA: return z80sti->imr >> 8; - case Z80STI_REGISTER_PVR: return z80sti->pvr; - case Z80STI_REGISTER_TABC: return z80sti->tabc; - case Z80STI_REGISTER_TBDR: return z80sti->tmc[TIMER_B]; - case Z80STI_REGISTER_TADR: return z80sti->tmc[TIMER_A]; - case Z80STI_REGISTER_UCR: return z80sti->ucr; - case Z80STI_REGISTER_RSR: return z80sti->rsr; - case Z80STI_REGISTER_TSR: return z80sti->tsr; - case Z80STI_REGISTER_UDR: return z80sti->udr; + case Z80STI_REGISTER_GPIP: m_gpip = (devcb_call_read8(&m_in_gpio_func, 0) & ~m_ddr) | (m_gpip & m_ddr); return m_gpip; + case Z80STI_REGISTER_IPRB: return m_ipr & 0xff; + case Z80STI_REGISTER_IPRA: return m_ipr >> 8; + case Z80STI_REGISTER_ISRB: return m_isr & 0xff; + case Z80STI_REGISTER_ISRA: return m_isr >> 8; + case Z80STI_REGISTER_IMRB: return m_imr & 0xff; + case Z80STI_REGISTER_IMRA: return m_imr >> 8; + case Z80STI_REGISTER_PVR: return m_pvr; + case Z80STI_REGISTER_TABC: return m_tabc; + case Z80STI_REGISTER_TBDR: return m_tmc[TIMER_B]; + case Z80STI_REGISTER_TADR: return m_tmc[TIMER_A]; + case Z80STI_REGISTER_UCR: return m_ucr; + case Z80STI_REGISTER_RSR: return m_rsr; + case Z80STI_REGISTER_TSR: return m_tsr; + case Z80STI_REGISTER_UDR: return m_udr; } return 0; } -/*------------------------------------------------- - z80sti_w - register write --------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( z80sti_w ) -{ - z80sti_t *z80sti = get_safe_token(device); +//------------------------------------------------- +// write - register write +//------------------------------------------------- +void z80sti_device::write(offs_t offset, UINT8 data) +{ switch (offset & 0x0f) { case Z80STI_REGISTER_IR: - switch (z80sti->pvr & 0x07) + switch (m_pvr & 0x07) { case Z80STI_REGISTER_IR_SCR: - LOG(("Z80STI '%s' Sync Character Register: %x\n", device->tag(), data)); - z80sti->scr = data; + LOG(("Z80STI '%s' Sync Character Register: %x\n", tag(), data)); + m_scr = data; break; case Z80STI_REGISTER_IR_TDDR: - LOG(("Z80STI '%s' Timer D Data Register: %x\n", device->tag(), data)); - z80sti->tdr[TIMER_D] = data; + LOG(("Z80STI '%s' Timer D Data Register: %x\n", tag(), data)); + m_tdr[TIMER_D] = data; break; case Z80STI_REGISTER_IR_TCDR: - LOG(("Z80STI '%s' Timer C Data Register: %x\n", device->tag(), data)); - z80sti->tdr[TIMER_C] = data; + LOG(("Z80STI '%s' Timer C Data Register: %x\n", tag(), data)); + m_tdr[TIMER_C] = data; break; case Z80STI_REGISTER_IR_AER: - LOG(("Z80STI '%s' Active Edge Register: %x\n", device->tag(), data)); - z80sti->aer = data; + LOG(("Z80STI '%s' Active Edge Register: %x\n", tag(), data)); + m_aer = data; break; case Z80STI_REGISTER_IR_IERB: - LOG(("Z80STI '%s' Interrupt Enable Register B: %x\n", device->tag(), data)); - z80sti->ier = (z80sti->ier & 0xff00) | data; - check_interrupts(z80sti); + LOG(("Z80STI '%s' Interrupt Enable Register B: %x\n", tag(), data)); + m_ier = (m_ier & 0xff00) | data; + check_interrupts(); break; case Z80STI_REGISTER_IR_IERA: - LOG(("Z80STI '%s' Interrupt Enable Register A: %x\n", device->tag(), data)); - z80sti->ier = (data << 8) | (z80sti->ier & 0xff); - check_interrupts(z80sti); + LOG(("Z80STI '%s' Interrupt Enable Register A: %x\n", tag(), data)); + m_ier = (data << 8) | (m_ier & 0xff); + check_interrupts(); break; case Z80STI_REGISTER_IR_DDR: - LOG(("Z80STI '%s' Data Direction Register: %x\n", device->tag(), data)); - z80sti->ddr = data; + LOG(("Z80STI '%s' Data Direction Register: %x\n", tag(), data)); + m_ddr = data; break; case Z80STI_REGISTER_IR_TCDC: @@ -377,35 +546,35 @@ WRITE8_DEVICE_HANDLER( z80sti_w ) int tcc = PRESCALER[(data >> 4) & 0x07]; int tdc = PRESCALER[data & 0x07]; - z80sti->tcdc = data; + m_tcdc = data; - LOG(("Z80STI '%s' Timer C Prescaler: %u\n", device->tag(), tcc)); - LOG(("Z80STI '%s' Timer D Prescaler: %u\n", device->tag(), tdc)); + LOG(("Z80STI '%s' Timer C Prescaler: %u\n", tag(), tcc)); + LOG(("Z80STI '%s' Timer D Prescaler: %u\n", tag(), tdc)); if (tcc) - timer_adjust_periodic(z80sti->timer[TIMER_C], ATTOTIME_IN_HZ(device->clock / tcc), 0, ATTOTIME_IN_HZ(device->clock / tcc)); + timer_adjust_periodic(m_timer[TIMER_C], ATTOTIME_IN_HZ(clock() / tcc), TIMER_C, ATTOTIME_IN_HZ(clock() / tcc)); else - timer_enable(z80sti->timer[TIMER_C], 0); + timer_enable(m_timer[TIMER_C], 0); if (tdc) - timer_adjust_periodic(z80sti->timer[TIMER_D], ATTOTIME_IN_HZ(device->clock / tdc), 0, ATTOTIME_IN_HZ(device->clock / tdc)); + timer_adjust_periodic(m_timer[TIMER_D], ATTOTIME_IN_HZ(clock() / tdc), TIMER_D, ATTOTIME_IN_HZ(clock() / tdc)); else - timer_enable(z80sti->timer[TIMER_D], 0); + timer_enable(m_timer[TIMER_D], 0); if (BIT(data, 7)) { - LOG(("Z80STI '%s' Timer A Reset\n", device->tag())); - z80sti->to[TIMER_A] = 0; + LOG(("Z80STI '%s' Timer A Reset\n", tag())); + m_to[TIMER_A] = 0; - devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[TIMER_A]); + devcb_call_write_line(&m_out_timer_func[TIMER_A], m_to[TIMER_A]); } if (BIT(data, 3)) { - LOG(("Z80STI '%s' Timer B Reset\n", device->tag())); - z80sti->to[TIMER_B] = 0; + LOG(("Z80STI '%s' Timer B Reset\n", tag())); + m_to[TIMER_B] = 0; - devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[TIMER_B]); + devcb_call_write_line(&m_out_timer_func[TIMER_B], m_to[TIMER_B]); } } break; @@ -413,69 +582,69 @@ WRITE8_DEVICE_HANDLER( z80sti_w ) break; case Z80STI_REGISTER_GPIP: - LOG(("Z80STI '%s' General Purpose I/O Register: %x\n", device->tag(), data)); - z80sti->gpip = data & z80sti->ddr; - devcb_call_write8(&z80sti->out_gpio_func, 0, z80sti->gpip); + LOG(("Z80STI '%s' General Purpose I/O Register: %x\n", tag(), data)); + m_gpip = data & m_ddr; + devcb_call_write8(&m_out_gpio_func, 0, m_gpip); break; case Z80STI_REGISTER_IPRB: { int i; - LOG(("Z80STI '%s' Interrupt Pending Register B: %x\n", device->tag(), data)); - z80sti->ipr &= (z80sti->ipr & 0xff00) | data; + LOG(("Z80STI '%s' Interrupt Pending Register B: %x\n", tag(), data)); + m_ipr &= (m_ipr & 0xff00) | data; for (i = 0; i < 16; i++) { - if (!BIT(z80sti->ipr, i) && (z80sti->int_state[i] == Z80_DAISY_INT)) z80sti->int_state[i] = 0; + if (!BIT(m_ipr, i) && (m_int_state[i] == Z80_DAISY_INT)) m_int_state[i] = 0; } - check_interrupts(z80sti); + check_interrupts(); } break; case Z80STI_REGISTER_IPRA: { int i; - LOG(("Z80STI '%s' Interrupt Pending Register A: %x\n", device->tag(), data)); - z80sti->ipr &= (data << 8) | (z80sti->ipr & 0xff); + LOG(("Z80STI '%s' Interrupt Pending Register A: %x\n", tag(), data)); + m_ipr &= (data << 8) | (m_ipr & 0xff); for (i = 0; i < 16; i++) { - if (!BIT(z80sti->ipr, i) && (z80sti->int_state[i] == Z80_DAISY_INT)) z80sti->int_state[i] = 0; + if (!BIT(m_ipr, i) && (m_int_state[i] == Z80_DAISY_INT)) m_int_state[i] = 0; } - check_interrupts(z80sti); + check_interrupts(); } break; case Z80STI_REGISTER_ISRB: - LOG(("Z80STI '%s' Interrupt In-Service Register B: %x\n", device->tag(), data)); - z80sti->isr &= (z80sti->isr & 0xff00) | data; + LOG(("Z80STI '%s' Interrupt In-Service Register B: %x\n", tag(), data)); + m_isr &= (m_isr & 0xff00) | data; break; case Z80STI_REGISTER_ISRA: - LOG(("Z80STI '%s' Interrupt In-Service Register A: %x\n", device->tag(), data)); - z80sti->isr &= (data << 8) | (z80sti->isr & 0xff); + LOG(("Z80STI '%s' Interrupt In-Service Register A: %x\n", tag(), data)); + m_isr &= (data << 8) | (m_isr & 0xff); break; case Z80STI_REGISTER_IMRB: - LOG(("Z80STI '%s' Interrupt Mask Register B: %x\n", device->tag(), data)); - z80sti->imr = (z80sti->imr & 0xff00) | data; - z80sti->isr &= z80sti->imr; - check_interrupts(z80sti); + LOG(("Z80STI '%s' Interrupt Mask Register B: %x\n", tag(), data)); + m_imr = (m_imr & 0xff00) | data; + m_isr &= m_imr; + check_interrupts(); break; case Z80STI_REGISTER_IMRA: - LOG(("Z80STI '%s' Interrupt Mask Register A: %x\n", device->tag(), data)); - z80sti->imr = (data << 8) | (z80sti->imr & 0xff); - z80sti->isr &= z80sti->imr; - check_interrupts(z80sti); + LOG(("Z80STI '%s' Interrupt Mask Register A: %x\n", tag(), data)); + m_imr = (data << 8) | (m_imr & 0xff); + m_isr &= m_imr; + check_interrupts(); break; case Z80STI_REGISTER_PVR: - LOG(("Z80STI '%s' Interrupt Vector: %02x\n", device->tag(), data & 0xe0)); - LOG(("Z80STI '%s' IR Address: %01x\n", device->tag(), data & 0x07)); - z80sti->pvr = data; + LOG(("Z80STI '%s' Interrupt Vector: %02x\n", tag(), data & 0xe0)); + LOG(("Z80STI '%s' IR Address: %01x\n", tag(), data & 0x07)); + m_pvr = data; break; case Z80STI_REGISTER_TABC: @@ -483,367 +652,130 @@ WRITE8_DEVICE_HANDLER( z80sti_w ) int tac = PRESCALER[(data >> 4) & 0x07]; int tbc = PRESCALER[data & 0x07]; - z80sti->tabc = data; + m_tabc = data; - LOG(("Z80STI '%s' Timer A Prescaler: %u\n", device->tag(), tac)); - LOG(("Z80STI '%s' Timer B Prescaler: %u\n", device->tag(), tbc)); + LOG(("Z80STI '%s' Timer A Prescaler: %u\n", tag(), tac)); + LOG(("Z80STI '%s' Timer B Prescaler: %u\n", tag(), tbc)); if (tac) - timer_adjust_periodic(z80sti->timer[TIMER_A], ATTOTIME_IN_HZ(device->clock / tac), 0, ATTOTIME_IN_HZ(device->clock / tac)); + timer_adjust_periodic(m_timer[TIMER_A], ATTOTIME_IN_HZ(clock() / tac), TIMER_A, ATTOTIME_IN_HZ(clock() / tac)); else - timer_enable(z80sti->timer[TIMER_A], 0); + timer_enable(m_timer[TIMER_A], 0); if (tbc) - timer_adjust_periodic(z80sti->timer[TIMER_B], ATTOTIME_IN_HZ(device->clock / tbc), 0, ATTOTIME_IN_HZ(device->clock / tbc)); + timer_adjust_periodic(m_timer[TIMER_B], ATTOTIME_IN_HZ(clock() / tbc), TIMER_B, ATTOTIME_IN_HZ(clock() / tbc)); else - timer_enable(z80sti->timer[TIMER_B], 0); + timer_enable(m_timer[TIMER_B], 0); } break; case Z80STI_REGISTER_TBDR: - LOG(("Z80STI '%s' Timer B Data Register: %x\n", device->tag(), data)); - z80sti->tdr[TIMER_B] = data; + LOG(("Z80STI '%s' Timer B Data Register: %x\n", tag(), data)); + m_tdr[TIMER_B] = data; break; case Z80STI_REGISTER_TADR: - LOG(("Z80STI '%s' Timer A Data Register: %x\n", device->tag(), data)); - z80sti->tdr[TIMER_A] = data; + LOG(("Z80STI '%s' Timer A Data Register: %x\n", tag(), data)); + m_tdr[TIMER_A] = data; break; #if 0 case Z80STI_REGISTER_UCR: - z80sti->ucr = data; + m_ucr = data; break; case Z80STI_REGISTER_RSR: - z80sti->rsr = data; + m_rsr = data; break; case Z80STI_REGISTER_TSR: - z80sti->tsr = data; + m_tsr = data; break; case Z80STI_REGISTER_UDR: - z80sti->udr = data; + m_udr = data; break; #endif default: - LOG(("Z80STI '%s' Unsupported Register %x\n", device->tag(), offset & 0x0f)); - } -} - -/*------------------------------------------------- - z80sti_rc_w - receiver clock write --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80sti_rc_w ) -{ - z80sti_t *z80sti = get_safe_token(device); - - if (state) - { - serial_receive(z80sti); + LOG(("Z80STI '%s' Unsupported Register %x\n", tag(), offset & 0x0f)); } } -/*------------------------------------------------- - z80sti_tc_w - transmitter clock write --------------------------------------------------*/ -WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w ) -{ - z80sti_t *z80sti = get_safe_token(device); +//------------------------------------------------- +// timer_count - timer count down +//------------------------------------------------- - if (state) - { - serial_transmit(z80sti); - } -} - -/*------------------------------------------------- - timer_count - timer count down --------------------------------------------------*/ - -static void timer_count(running_device *device, int index) +void z80sti_device::timer_count(int index) { - z80sti_t *z80sti = get_safe_token(device); - - if (z80sti->tmc[index] == 0x01) + if (m_tmc[index] == 0x01) { - //LOG(("Z80STI '%s' Timer %c Expired\n", device->tag, 'A' + index)); + //LOG(("Z80STI '%s' Timer %c Expired\n", tag(), 'A' + index)); - /* toggle timer output signal */ - z80sti->to[index] = !z80sti->to[index]; + // toggle timer output signal + m_to[index] = !m_to[index]; - switch (index) - { - case TIMER_A: devcb_call_write_line(&z80sti->out_tao_func, z80sti->to[index]); break; - case TIMER_B: devcb_call_write_line(&z80sti->out_tbo_func, z80sti->to[index]); break; - case TIMER_C: devcb_call_write_line(&z80sti->out_tco_func, z80sti->to[index]); break; - case TIMER_D: devcb_call_write_line(&z80sti->out_tdo_func, z80sti->to[index]); break; - } + devcb_call_write_line(&m_out_timer_func[index], m_to[index]); - if (z80sti->ier & (1 << INT_LEVEL_TIMER[index])) + if (m_ier & (1 << INT_LEVEL_TIMER[index])) { - LOG(("Z80STI '%s' Interrupt Pending for Timer %c\n", device->tag(), 'A' + index)); + LOG(("Z80STI '%s' Interrupt Pending for Timer %c\n", tag(), 'A' + index)); - /* signal timer elapsed interrupt */ - take_interrupt(z80sti, INT_LEVEL_TIMER[index]); + // signal timer elapsed interrupt + take_interrupt(INT_LEVEL_TIMER[index]); } - /* load timer main counter */ - z80sti->tmc[index] = z80sti->tdr[index]; + // load timer main counter + m_tmc[index] = m_tdr[index]; } else { - /* count down */ - z80sti->tmc[index]--; + // count down + m_tmc[index]--; } } -/*------------------------------------------------- - TIMER_CALLBACK( timer_# ) --------------------------------------------------*/ - -static TIMER_CALLBACK( timer_a ) { timer_count((running_device *)ptr, TIMER_A); } -static TIMER_CALLBACK( timer_b ) { timer_count((running_device *)ptr, TIMER_B); } -static TIMER_CALLBACK( timer_c ) { timer_count((running_device *)ptr, TIMER_C); } -static TIMER_CALLBACK( timer_d ) { timer_count((running_device *)ptr, TIMER_D); } -/*------------------------------------------------- - gpip_input - GPIP input line write --------------------------------------------------*/ +//------------------------------------------------- +// gpip_input - GPIP input line write +//------------------------------------------------- -static void gpip_input(running_device *device, int bit, int state) +void z80sti_device::gpip_input(int bit, int state) { - z80sti_t *z80sti = get_safe_token(device); - - int aer = BIT(z80sti->aer, bit); - int old_state = BIT(z80sti->gpip, bit); + int aer = BIT(m_aer, bit); + int old_state = BIT(m_gpip, bit); if ((old_state ^ aer) && !(state ^ aer)) { - LOG(("Z80STI '%s' Edge Transition Detected on Bit: %u\n", device->tag(), bit)); + LOG(("Z80STI '%s' Edge Transition Detected on Bit: %u\n", tag(), bit)); - if (z80sti->ier & (1 << INT_LEVEL_GPIP[bit])) + if (m_ier & (1 << INT_LEVEL_GPIP[bit])) { - LOG(("Z80STI '%s' Interrupt Pending for P%u\n", device->tag(), bit)); + LOG(("Z80STI '%s' Interrupt Pending for P%u\n", tag(), bit)); - take_interrupt(z80sti, INT_LEVEL_GPIP[bit]); + take_interrupt(INT_LEVEL_GPIP[bit]); } } - z80sti->gpip = (z80sti->gpip & ~(1 << bit)) | (state << bit); + m_gpip = (m_gpip & ~(1 << bit)) | (state << bit); } -/*------------------------------------------------- - z80sti_i#_w - GPIP input line # write --------------------------------------------------*/ - -WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) { gpip_input(device, 0, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ) { gpip_input(device, 1, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ) { gpip_input(device, 2, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ) { gpip_input(device, 3, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ) { gpip_input(device, 4, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ) { gpip_input(device, 5, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ) { gpip_input(device, 6, state); } -WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ) { gpip_input(device, 7, state); } - -/*------------------------------------------------- - z80sti_irq_state - get interrupt status --------------------------------------------------*/ - -static int z80sti_irq_state(running_device *device) -{ - z80sti_t *z80sti = get_safe_token(device); - int state = 0, i; - - /* loop over all interrupt sources */ - for (i = 15; i >= 0; i--) - { - /* if we're servicing a request, don't indicate more interrupts */ - if (z80sti->int_state[i] & Z80_DAISY_IEO) - { - state |= Z80_DAISY_IEO; - break; - } - - if (BIT(z80sti->imr, i)) - { - state |= z80sti->int_state[i]; - } - } - LOG(("Z80STI '%s' Interrupt State: %u\n", device->tag(), state)); - return state; -} +//************************************************************************** +// GLOBAL STUBS +//************************************************************************** -/*------------------------------------------------- - z80sti_irq_ack - interrupt acknowledge --------------------------------------------------*/ +READ8_DEVICE_HANDLER( z80sti_r ) { return downcast(device)->read(offset); } +WRITE8_DEVICE_HANDLER( z80sti_w ) { downcast(device)->write(offset, data); } -static int z80sti_irq_ack(running_device *device) -{ - z80sti_t *z80sti = get_safe_token(device); - int i; +WRITE_LINE_DEVICE_HANDLER( z80sti_rc_w ) { if (state) downcast(device)->serial_receive(); } +WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w ) { if (state) downcast(device)->serial_transmit(); } - /* loop over all interrupt sources */ - for (i = 15; i >= 0; i--) - { - /* find the first channel with an interrupt requested */ - if (z80sti->int_state[i] & Z80_DAISY_INT) - { - UINT8 vector = (z80sti->pvr & 0xe0) | INT_VECTOR[i]; - - /* clear interrupt, switch to the IEO state, and update the IRQs */ - z80sti->int_state[i] = Z80_DAISY_IEO; - - /* clear interrupt pending register bit */ - z80sti->ipr &= ~(1 << i); - - /* set interrupt in-service register bit */ - z80sti->isr |= (1 << i); - - check_interrupts(z80sti); - - LOG(("Z80STI '%s' Interrupt Acknowledge Vector: %02x\n", device->tag(), vector)); - - return vector; - } - } - - logerror("z80sti_irq_ack: failed to find an interrupt to ack!\n"); - - return 0; -} - -/*------------------------------------------------- - z80sti_irq_reti - return from interrupt --------------------------------------------------*/ - -static void z80sti_irq_reti(running_device *device) -{ - z80sti_t *z80sti = get_safe_token(device); - int i; - - LOG(("Z80STI '%s' Return from Interrupt\n", device->tag())); - - /* loop over all interrupt sources */ - for (i = 15; i >= 0; i--) - { - /* find the first channel with an IEO pending */ - if (z80sti->int_state[i] & Z80_DAISY_IEO) - { - /* clear the IEO state and update the IRQs */ - z80sti->int_state[i] &= ~Z80_DAISY_IEO; - - /* clear interrupt in-service register bit */ - z80sti->isr &= ~(1 << i); - - check_interrupts(z80sti); - return; - } - } - - logerror("z80sti_irq_reti: failed to find an interrupt to clear IEO on!\n"); -} - -/*------------------------------------------------- - DEVICE_START( z80sti ) --------------------------------------------------*/ - -static DEVICE_START( z80sti ) -{ - z80sti_t *z80sti = get_safe_token(device); - const z80sti_interface *intf = (const z80sti_interface *)device->baseconfig().static_config; - - /* resolve callbacks */ - devcb_resolve_read8(&z80sti->in_gpio_func, &intf->in_gpio_func, device); - devcb_resolve_write8(&z80sti->out_gpio_func, &intf->out_gpio_func, device); - devcb_resolve_read_line(&z80sti->in_si_func, &intf->in_si_func, device); - devcb_resolve_write_line(&z80sti->out_so_func, &intf->out_so_func, device); - devcb_resolve_write_line(&z80sti->out_tao_func, &intf->out_tao_func, device); - devcb_resolve_write_line(&z80sti->out_tbo_func, &intf->out_tbo_func, device); - devcb_resolve_write_line(&z80sti->out_tco_func, &intf->out_tco_func, device); - devcb_resolve_write_line(&z80sti->out_tdo_func, &intf->out_tdo_func, device); - devcb_resolve_write_line(&z80sti->out_int_func, &intf->out_int_func, device); - - /* create the counter timers */ - z80sti->timer[TIMER_A] = timer_alloc(device->machine, timer_a, (void *)device); - z80sti->timer[TIMER_B] = timer_alloc(device->machine, timer_b, (void *)device); - z80sti->timer[TIMER_C] = timer_alloc(device->machine, timer_c, (void *)device); - z80sti->timer[TIMER_D] = timer_alloc(device->machine, timer_d, (void *)device); - - /* create serial receive clock timer */ - if (intf->rx_clock > 0) - { - z80sti->rx_timer = timer_alloc(device->machine, rx_tick, (void *)device); - timer_adjust_periodic(z80sti->rx_timer, attotime_zero, 0, ATTOTIME_IN_HZ(intf->rx_clock)); - } - - /* create serial transmit clock timer */ - if (intf->tx_clock > 0) - { - z80sti->tx_timer = timer_alloc(device->machine, tx_tick, (void *)device); - timer_adjust_periodic(z80sti->tx_timer, attotime_zero, 0, ATTOTIME_IN_HZ(intf->tx_clock)); - } - - /* register for state saving */ - state_save_register_device_item(device, 0, z80sti->gpip); - state_save_register_device_item(device, 0, z80sti->aer); - state_save_register_device_item(device, 0, z80sti->ddr); - state_save_register_device_item(device, 0, z80sti->ier); - state_save_register_device_item(device, 0, z80sti->ipr); - state_save_register_device_item(device, 0, z80sti->isr); - state_save_register_device_item(device, 0, z80sti->imr); - state_save_register_device_item(device, 0, z80sti->pvr); - state_save_register_device_item_array(device, 0, z80sti->int_state); - state_save_register_device_item(device, 0, z80sti->tabc); - state_save_register_device_item(device, 0, z80sti->tcdc); - state_save_register_device_item_array(device, 0, z80sti->tdr); - state_save_register_device_item_array(device, 0, z80sti->tmc); - state_save_register_device_item_array(device, 0, z80sti->to); - state_save_register_device_item(device, 0, z80sti->scr); - state_save_register_device_item(device, 0, z80sti->ucr); - state_save_register_device_item(device, 0, z80sti->rsr); - state_save_register_device_item(device, 0, z80sti->tsr); - state_save_register_device_item(device, 0, z80sti->udr); -} - -/*------------------------------------------------- - DEVICE_RESET( z80sti ) --------------------------------------------------*/ - -static DEVICE_RESET( z80sti ) -{ -} - -/*------------------------------------------------- - DEVICE_GET_INFO( z80sti ) --------------------------------------------------*/ - -DEVICE_GET_INFO( z80sti ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(z80sti_t); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(z80sti); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(z80sti); break; - case DEVINFO_FCT_IRQ_STATE: info->f = (genf *)z80sti_irq_state; break; - case DEVINFO_FCT_IRQ_ACK: info->f = (genf *)z80sti_irq_ack; break; - case DEVINFO_FCT_IRQ_RETI: info->f = (genf *)z80sti_irq_reti; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Mostek MK3801"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Z80-STI"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; - } -} +WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ) { downcast(device)->gpip_input(0, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ) { downcast(device)->gpip_input(1, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ) { downcast(device)->gpip_input(2, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i3_w ) { downcast(device)->gpip_input(3, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i4_w ) { downcast(device)->gpip_input(4, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ) { downcast(device)->gpip_input(5, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ) { downcast(device)->gpip_input(6, state); } +WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ) { downcast(device)->gpip_input(7, state); } diff --git a/src/emu/machine/z80sti.h b/src/emu/machine/z80sti.h index 4b9df8bd818..a8933d743bc 100644 --- a/src/emu/machine/z80sti.h +++ b/src/emu/machine/z80sti.h @@ -33,14 +33,12 @@ #ifndef __Z80STI__ #define __Z80STI__ -#include "emu.h" -#include "devcb.h" +#include "cpu/z80/z80daisy.h" -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ -#define Z80STI DEVICE_GET_INFO_NAME( z80sti ) +//************************************************************************** +// DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_Z80STI_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD((_tag), Z80STI, _clock) \ @@ -48,62 +46,182 @@ #define Z80STI_INTERFACE(name) const z80sti_interface (name) = -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -typedef struct _z80sti_interface z80sti_interface; -struct _z80sti_interface + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> z80sti_interface + +struct z80sti_interface { - int rx_clock; /* serial receive clock */ - int tx_clock; /* serial transmit clock */ + int m_rx_clock; // serial receive clock + int m_tx_clock; // serial transmit clock + + // this gets called on each change of the _INT pin (pin 17) + devcb_write_line m_out_int_func; + + // this is called on each read of the GPIO pins + devcb_read8 m_in_gpio_func; + + // this is called on each write of the GPIO pins + devcb_write8 m_out_gpio_func; + + // this gets called for each read of the SI pin (pin 38) + devcb_read_line m_in_si_func; + + // this gets called for each change of the SO pin (pin 37) + devcb_write_line m_out_so_func; + + // this gets called for each change of the TAO pin (pin 1) + devcb_write_line m_out_tao_func; - /* this gets called on each change of the _INT pin (pin 17) */ - devcb_write_line out_int_func; + // this gets called for each change of the TBO pin (pin 2) + devcb_write_line m_out_tbo_func; + + // this gets called for each change of the TCO pin (pin 3) + devcb_write_line m_out_tco_func; + + // this gets called for each change of the TDO pin (pin 4) + devcb_write_line m_out_tdo_func; +}; - /* this is called on each read of the GPIO pins */ - devcb_read8 in_gpio_func; - /* this is called on each write of the GPIO pins */ - devcb_write8 out_gpio_func; - /* this gets called for each read of the SI pin (pin 38) */ - devcb_read_line in_si_func; +// ======================> z80sti_device_config - /* this gets called for each change of the SO pin (pin 37) */ - devcb_write_line out_so_func; +class z80sti_device_config : public device_config, + public device_config_z80daisy_interface, + public z80sti_interface +{ + friend class z80sti_device; + + // construction/destruction + z80sti_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Mostek MK3801"; } + +protected: + // device_config overrides + virtual void device_config_complete(); +}; - /* this gets called for each change of the TAO pin (pin 1) */ - devcb_write_line out_tao_func; - /* this gets called for each change of the TBO pin (pin 2) */ - devcb_write_line out_tbo_func; - /* this gets called for each change of the TCO pin (pin 3) */ - devcb_write_line out_tco_func; +// ======================> z80sti_device - /* this gets called for each change of the TDO pin (pin 4) */ - devcb_write_line out_tdo_func; +class z80sti_device : public device_t, + public device_z80daisy_interface +{ + friend class z80sti_device_config; + + // construction/destruction + z80sti_device(running_machine &_machine, const z80sti_device_config &config); + +public: + // I/O accessors + UINT8 read(offs_t offset); + void write(offs_t offset, UINT8 data); + + // communication I/O + void serial_receive(); + void serial_transmit(); + void gpip_input(int bit, int state); + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // device_z80daisy_interface overrides + virtual int z80daisy_irq_state(); + virtual int z80daisy_irq_ack(); + virtual void z80daisy_irq_reti(); + + // internal helpers + void check_interrupts(); + void take_interrupt(int level); + + void timer_count(int index); + + static TIMER_CALLBACK( static_rx_tick ) { reinterpret_cast(ptr)->serial_receive(); } + static TIMER_CALLBACK( static_tx_tick ) { reinterpret_cast(ptr)->serial_transmit(); } + + static TIMER_CALLBACK( static_timer_count ) { reinterpret_cast(ptr)->timer_count(param); } + + // internal state + const z80sti_device_config &m_config; + + // device callbacks + devcb_resolved_read8 m_in_gpio_func; + devcb_resolved_write8 m_out_gpio_func; + devcb_resolved_read_line m_in_si_func; + devcb_resolved_write_line m_out_so_func; + devcb_resolved_write_line m_out_timer_func[4]; + devcb_resolved_write_line m_out_int_func; + + // I/O state + UINT8 m_gpip; // general purpose I/O register + UINT8 m_aer; // active edge register + UINT8 m_ddr; // data direction register + + // interrupt state + UINT16 m_ier; // interrupt enable register + UINT16 m_ipr; // interrupt pending register + UINT16 m_isr; // interrupt in-service register + UINT16 m_imr; // interrupt mask register + UINT8 m_pvr; // interrupt vector register + int m_int_state[16]; // interrupt state + + // timer state + UINT8 m_tabc; // timer A/B control register + UINT8 m_tcdc; // timer C/D control register + UINT8 m_tdr[4]; // timer data registers + UINT8 m_tmc[4]; // timer main counters + int m_to[4]; // timer out latch + + // serial state + UINT8 m_scr; // synchronous character register + UINT8 m_ucr; // USART control register + UINT8 m_tsr; // transmitter status register + UINT8 m_rsr; // receiver status register + UINT8 m_udr; // USART data register + + // timers + emu_timer *m_timer[4]; // counter timers + emu_timer *m_rx_timer; // serial receive timer + emu_timer *m_tx_timer; // serial transmit timer }; -/*************************************************************************** - PROTOTYPES -***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( z80sti ); +// device type definition +const device_type Z80STI = z80sti_device_config::static_alloc_device_config; + + -/* register access */ +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + +// register access READ8_DEVICE_HANDLER( z80sti_r ); WRITE8_DEVICE_HANDLER( z80sti_w ); -/* receive clock */ +// receive clock WRITE_LINE_DEVICE_HANDLER( z80sti_rc_w ); -/* transmit clock */ +// transmit clock WRITE_LINE_DEVICE_HANDLER( z80sti_tc_w ); -/* GPIP input lines */ +// GPIP input lines WRITE_LINE_DEVICE_HANDLER( z80sti_i0_w ); WRITE_LINE_DEVICE_HANDLER( z80sti_i1_w ); WRITE_LINE_DEVICE_HANDLER( z80sti_i2_w ); @@ -113,4 +231,5 @@ WRITE_LINE_DEVICE_HANDLER( z80sti_i5_w ); WRITE_LINE_DEVICE_HANDLER( z80sti_i6_w ); WRITE_LINE_DEVICE_HANDLER( z80sti_i7_w ); + #endif diff --git a/src/emu/mame.c b/src/emu/mame.c index 7ea69e90e20..de617792f5c 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -41,7 +41,6 @@ - calls input_port_init() [inptport.c] to set up the input ports - calls rom_init() [romload.c] to load the game's ROMs - calls memory_init() [memory.c] to process the game's memory maps - - calls cpuexec_init() [cpuexec.c] to initialize the CPUs - calls watchdog_init() [watchdog.c] to initialize the watchdog system - calls the driver's DRIVER_INIT callback - calls device_list_start() [devintrf.c] to start any devices @@ -62,7 +61,7 @@ -------------------( at this point, we're up and running )---------------------- - - calls cpuexec_timeslice() [cpuexec.c] over and over until we exit + - calls scheduler->timeslice() [schedule.c] over and over until we exit - ends resource tracking (level 2), freeing all auto_mallocs and timers - calls the nvram_save() [machine/generic.c] to save NVRAM - calls config_save_settings() [config.c] to save the game's configuration @@ -196,26 +195,6 @@ static void logfile_callback(running_machine *machine, const char *buffer); -/*************************************************************************** - CORE IMPLEMENTATION -***************************************************************************/ - -/*------------------------------------------------- - eat_all_cpu_cycles - eat a ton of cycles on - all CPUs to force a quick exit --------------------------------------------------*/ - -INLINE void eat_all_cpu_cycles(running_machine *machine) -{ - running_device *cpu; - - if(machine->cpuexec_data) - for (cpu = machine->firstcpu; cpu != NULL; cpu = cpu_next(cpu)) - cpu_eat_cycles(cpu, 1000000000); -} - - - /*************************************************************************** CORE IMPLEMENTATION ***************************************************************************/ @@ -258,6 +237,7 @@ int mame_execute(core_options *options) /* otherwise, perform validity checks before anything else */ else if (mame_validitychecks(driver) != 0) return MAMERR_FAILED_VALIDITY; + firstgame = FALSE; /* parse any INI files as the first thing */ @@ -300,7 +280,7 @@ int mame_execute(core_options *options) /* load the configuration settings and NVRAM */ settingsloaded = config_load_settings(machine); nvram_load(machine); - sound_mute(machine, FALSE); + sound_mute(machine, FALSE); /* display the startup screens */ ui_display_startup_screens(machine, firstrun, !settingsloaded); @@ -317,7 +297,7 @@ int mame_execute(core_options *options) /* execute CPUs if not paused */ if (!mame->paused) - cpuexec_timeslice(machine); + machine->scheduler.timeslice(); /* otherwise, just pump video updates through */ else @@ -551,7 +531,7 @@ void mame_schedule_exit(running_machine *machine) mame->exit_pending = TRUE; /* if we're executing, abort out immediately */ - eat_all_cpu_cycles(machine); + machine->scheduler.eat_all_cycles(); /* if we're autosaving on exit, schedule a save as well */ if (options_get_bool(mame_options(), OPTION_AUTOSAVE) && (machine->gamedrv->flags & GAME_SUPPORTS_SAVE)) @@ -570,7 +550,7 @@ void mame_schedule_hard_reset(running_machine *machine) mame->hard_reset_pending = TRUE; /* if we're executing, abort out immediately */ - eat_all_cpu_cycles(machine); + machine->scheduler.eat_all_cycles(); } @@ -589,7 +569,7 @@ void mame_schedule_soft_reset(running_machine *machine) mame_pause(machine, FALSE); /* if we're executing, abort out immediately */ - eat_all_cpu_cycles(machine); + machine->scheduler.eat_all_cycles(); } @@ -605,7 +585,7 @@ void mame_schedule_new_driver(running_machine *machine, const game_driver *drive mame->new_driver_pending = driver; /* if we're executing, abort out immediately */ - eat_all_cpu_cycles(machine); + machine->scheduler.eat_all_cycles(); } @@ -744,7 +724,7 @@ int mame_is_paused(running_machine *machine) region_info::region_info(running_machine *_machine, const char *_name, UINT32 _length, UINT32 _flags) : machine(_machine), - next(NULL), + m_next(NULL), name(_name), length(_length), flags(_flags) @@ -837,7 +817,7 @@ const char *memory_region_next(running_machine *machine, const char *name) if (name == NULL) return (machine->regionlist.first() != NULL) ? machine->regionlist.first()->name.cstr() : NULL; const region_info *region = machine->region(name); - return (region != NULL && region->next != NULL) ? region->next->name.cstr() : NULL; + return (region != NULL && region->next() != NULL) ? region->next()->name.cstr() : NULL; } @@ -1182,7 +1162,6 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver) #ifndef MESS const game_driver *parent = driver_get_clone(driver); const game_driver *gparent = (parent != NULL) ? driver_get_clone(parent) : NULL; - const device_config *device; machine_config *config; /* parse "vertical.ini" or "horizont.ini" */ @@ -1193,15 +1172,12 @@ void mame_parse_ini_files(core_options *options, const game_driver *driver) /* parse "vector.ini" for vector games */ config = machine_config_alloc(driver->machine_config); - for (device = video_screen_first(config); device != NULL; device = video_screen_next(device)) - { - const screen_config *scrconfig = (const screen_config *)device->inline_config; - if (scrconfig->type == SCREEN_TYPE_VECTOR) + for (const screen_device_config *devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig)) + if (devconfig->screen_type() == SCREEN_TYPE_VECTOR) { parse_ini_file(options, "vector", OPTION_PRIORITY_VECTOR_INI); break; } - } machine_config_free(config); /* next parse "source/.ini"; if that doesn't exist, try .ini */ @@ -1257,7 +1233,9 @@ static int parse_ini_file(core_options *options, const char *name, int priority) -------------------------------------------------*/ running_machine::running_machine(const game_driver *driver) - : config(NULL), + : devicelist(respool), + scheduler(*this), + config(NULL), firstcpu(NULL), gamedrv(driver), basename(NULL), @@ -1269,9 +1247,8 @@ running_machine::running_machine(const game_driver *driver) priority_bitmap(NULL), sample_rate(0), debug_flags(0), - ui_active(0), + ui_active(false), mame_data(NULL), - cpuexec_data(NULL), timer_data(NULL), state_data(NULL), memory_data(NULL), @@ -1316,7 +1293,7 @@ running_machine::running_machine(const game_driver *driver) /* find devices */ firstcpu = cpu_first(this); - primary_screen = video_screen_first(this); + primary_screen = screen_first(*this); /* fetch core options */ sample_rate = options_get_int(mame_options(), OPTION_SAMPLERATE); @@ -1356,6 +1333,31 @@ running_machine::~running_machine() } +//------------------------------------------------- +// describe_context - return a string describing +// which device is currently executing and its +// PC +//------------------------------------------------- + +const char *running_machine::describe_context() +{ + device_execute_interface *executing = scheduler.currently_executing(); + if (executing != NULL) + { + cpu_device *cpu = downcast(&executing->device()); + if (cpu != NULL) + m_context.printf("'%s' (%s)", cpu->tag(), core_i64_hex_format(cpu_get_pc(cpu), cpu->space(AS_PROGRAM)->logaddrchars)); + else + m_context.printf("'%s'", cpu->tag()); + } + else + m_context.cpy("(no context)"); + + return m_context; +} + + + /*------------------------------------------------- init_machine - initialize the emulated machine -------------------------------------------------*/ @@ -1408,7 +1410,6 @@ static void init_machine(running_machine *machine) /* these operations must proceed in this order */ rom_init(machine); memory_init(machine); - cpuexec_init(machine); watchdog_init(machine); /* allocate the gfx elements prior to device initialization */ diff --git a/src/emu/mame.h b/src/emu/mame.h index cad5bc05643..1329b7beb1b 100644 --- a/src/emu/mame.h +++ b/src/emu/mame.h @@ -164,13 +164,15 @@ typedef void (*output_callback_func)(void *param, const char *format, va_list ar class region_info { DISABLE_COPYING(region_info); - + running_machine * machine; public: region_info(running_machine *machine, const char *_name, UINT32 _length, UINT32 _flags); ~region_info(); + region_info *next() const { return m_next; } + operator void *() const { return (this != NULL) ? base.v : NULL; } operator INT8 *() const { return (this != NULL) ? base.i8 : NULL; } operator UINT8 *() const { return (this != NULL) ? base.u8 : NULL; } @@ -186,7 +188,7 @@ public: endianness_t endianness() const { return ((flags & ROMREGION_ENDIANMASK) == ROMREGION_LE) ? ENDIANNESS_LITTLE : ENDIANNESS_BIG; } UINT8 width() const { return 1 << ((flags & ROMREGION_WIDTHMASK) >> 8); } - region_info * next; + region_info * m_next; astring name; generic_ptr base; UINT32 length; @@ -223,20 +225,24 @@ public: running_machine(const game_driver *driver); ~running_machine(); - inline running_device *device(const char *tag); + inline device_t *device(const char *tag); + template inline T *device(const char *tag) { return downcast(device(tag)); } inline const input_port_config *port(const char *tag); inline const region_info *region(const char *tag); - resource_pool respool; /* pool of resources for this machine */ - region_list regionlist; /* list of memory regions */ - device_list devicelist; /* list of running devices */ + const char *describe_context(); + + resource_pool respool; // pool of resources for this machine + region_list regionlist; // list of memory regions + device_list devicelist; // list of running devices + device_scheduler scheduler; // scheduler object /* configuration data */ const machine_config * config; /* points to the constructed machine_config */ ioport_list portlist; /* points to a list of input port configurations */ /* CPU information */ - running_device * firstcpu; /* first CPU (allows for quick iteration via typenext) */ + device_t * firstcpu; /* first CPU (allows for quick iteration via typenext) */ /* game-related information */ const game_driver * gamedrv; /* points to the definition of the game machine */ @@ -244,7 +250,7 @@ public: /* video-related information */ gfx_element * gfx[MAX_GFX_ELEMENTS];/* array of pointers to graphic sets (chars, sprites) */ - running_device * primary_screen; /* the primary screen device, or NULL if screenless */ + screen_device * primary_screen; /* the primary screen device, or NULL if screenless */ palette_t * palette; /* global palette object */ /* palette-related information */ @@ -260,14 +266,13 @@ public: UINT32 debug_flags; /* the current debug flags */ /* UI-related */ - int ui_active; /* ui active or not (useful for games / systems with keyboard inputs) */ + bool ui_active; /* ui active or not (useful for games / systems with keyboard inputs) */ /* generic pointers */ generic_pointers generic; /* generic pointers */ /* internal core information */ mame_private * mame_data; /* internal data from mame.c */ - cpuexec_private * cpuexec_data; /* internal data from cpuexec.c */ timer_private * timer_data; /* internal data from timer.c */ state_private * state_data; /* internal data from state.c */ memory_private * memory_data; /* internal data from memory.c */ @@ -292,6 +297,9 @@ public: /* driver-specific information */ void * driver_data; /* drivers can hang data off of here instead of using globals */ + +private: + astring m_context; // context string }; @@ -473,7 +481,7 @@ void mame_get_current_datetime(running_machine *machine, mame_system_time *systi INLINE FUNCTIONS ***************************************************************************/ -inline running_device *running_machine::device(const char *tag) +inline device_t *running_machine::device(const char *tag) { return devicelist.find(tag); } diff --git a/src/emu/mconfig.c b/src/emu/mconfig.c index b86c1d7a919..219eca623ff 100644 --- a/src/emu/mconfig.c +++ b/src/emu/mconfig.c @@ -12,11 +12,12 @@ #include "emu.h" #include + /*************************************************************************** FUNCTION PROTOTYPES ***************************************************************************/ -static void machine_config_detokenize(machine_config *config, const machine_config_token *tokens, const device_config *owner, int depth); +static void machine_config_detokenize(machine_config *config, const machine_config_token *tokens, const device_config *owner); @@ -38,7 +39,19 @@ machine_config *machine_config_alloc(const machine_config_token *tokens) config = global_alloc_clear(machine_config); /* parse tokens into the config */ - machine_config_detokenize(config, tokens, NULL, 0); + machine_config_detokenize(config, tokens, NULL); + + /* process any device-specific machine configurations */ + for (const device_config *device = config->devicelist.first(); device != NULL; device = device->next()) + { + tokens = device->machine_config_tokens(); + if (tokens != NULL) + machine_config_detokenize(config, tokens, device); + } + + // then notify all devices that their configuration is complete + for (device_config *device = config->devicelist.first(); device != NULL; device = device->next()) + device->config_complete(); return config; } @@ -61,7 +74,7 @@ void machine_config_free(machine_config *config) machine config -------------------------------------------------*/ -static void machine_config_detokenize(machine_config *config, const machine_config_token *tokens, const device_config *owner, int depth) +static void machine_config_detokenize(machine_config *config, const machine_config_token *tokens, const device_config *owner) { UINT32 entrytype = MCONFIG_TOKEN_INVALID; device_config *device = NULL; @@ -70,12 +83,10 @@ static void machine_config_detokenize(machine_config *config, const machine_conf /* loop over tokens until we hit the end */ while (entrytype != MCONFIG_TOKEN_END) { - device_custom_config_func custom; - int size, offset, bits; - UINT32 data32, clock; device_type devtype; const char *tag; UINT64 data64; + UINT32 clock; /* unpack the token from the first entry */ TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); @@ -87,7 +98,7 @@ static void machine_config_detokenize(machine_config *config, const machine_conf /* including */ case MCONFIG_TOKEN_INCLUDE: - machine_config_detokenize(config, TOKEN_GET_PTR(tokens, tokenptr), owner, depth + 1); + machine_config_detokenize(config, TOKEN_GET_PTR(tokens, tokenptr), owner); break; /* device management */ @@ -96,7 +107,15 @@ static void machine_config_detokenize(machine_config *config, const machine_conf TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32); devtype = TOKEN_GET_PTR(tokens, devtype); tag = owner->subtag(tempstring, TOKEN_GET_STRING(tokens)); - device = config->devicelist.append(tag, global_alloc(device_config(owner, devtype, tag, clock))); + device = config->devicelist.append(tag, (*devtype)(*config, tag, owner, clock)); + break; + + case MCONFIG_TOKEN_DEVICE_REPLACE: + TOKEN_UNGET_UINT32(tokens); + TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, clock, 32); + devtype = TOKEN_GET_PTR(tokens, devtype); + tag = owner->subtag(tempstring, TOKEN_GET_STRING(tokens)); + device = config->devicelist.replace(tag, (*devtype)(*config, tag, owner, clock)); break; case MCONFIG_TOKEN_DEVICE_REMOVE: @@ -113,22 +132,19 @@ static void machine_config_detokenize(machine_config *config, const machine_conf break; case MCONFIG_TOKEN_DEVICE_CLOCK: - assert(device != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK2(tokens, entrytype, 8, device->clock, 32); - break; + case MCONFIG_TOKEN_DEVICE_CONFIG: + case MCONFIG_TOKEN_DEVICE_INLINE_DATA16: + case MCONFIG_TOKEN_DEVICE_INLINE_DATA32: + case MCONFIG_TOKEN_DEVICE_INLINE_DATA64: - case MCONFIG_TOKEN_DEVICE_MAP: - assert(device != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, data32, 8); - device->address_map[data32] = TOKEN_GET_PTR(tokens, addrmap); - break; + case MCONFIG_TOKEN_DIEXEC_DISABLE: + case MCONFIG_TOKEN_DIEXEC_VBLANK_INT: + case MCONFIG_TOKEN_DIEXEC_PERIODIC_INT: - case MCONFIG_TOKEN_DEVICE_CONFIG: - assert(device != NULL); - device->static_config = TOKEN_GET_PTR(tokens, voidptr); - break; + case MCONFIG_TOKEN_DIMEMORY_MAP: + + case MCONFIG_TOKEN_DISOUND_ROUTE: + case MCONFIG_TOKEN_DISOUND_RESET: case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1: case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_2: @@ -139,50 +155,12 @@ static void machine_config_detokenize(machine_config *config, const machine_conf case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_7: case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_8: case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_9: - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE: - assert(device != NULL); - custom = (device_custom_config_func)device->get_config_fct(DEVINFO_FCT_CUSTOM_CONFIG); - assert(custom != NULL); - tokens = (*custom)(device, entrytype, tokens); - break; - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA32: - assert(device != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); - data32 = TOKEN_GET_UINT32(tokens); - switch (size) - { - case 1: *(UINT8 *) ((UINT8 *)device->inline_config + offset) = data32; break; - case 2: *(UINT16 *)((UINT8 *)device->inline_config + offset) = data32; break; - case 4: *(UINT32 *)((UINT8 *)device->inline_config + offset) = data32; break; - } - break; - case MCONFIG_TOKEN_DEVICE_CONFIG_DATA64: - assert(device != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK3(tokens, entrytype, 8, size, 4, offset, 12); - TOKEN_EXTRACT_UINT64(tokens, data64); - switch (size) - { - case 1: *(UINT8 *) ((UINT8 *)device->inline_config + offset) = data64; break; - case 2: *(UINT16 *)((UINT8 *)device->inline_config + offset) = data64; break; - case 4: *(UINT32 *)((UINT8 *)device->inline_config + offset) = data64; break; - case 8: *(UINT64 *)((UINT8 *)device->inline_config + offset) = data64; break; - } - break; - case MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32: + case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE: assert(device != NULL); - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT32_UNPACK4(tokens, entrytype, 8, size, 4, bits, 6, offset, 12); - data32 = TOKEN_GET_UINT32(tokens); - switch (size) - { - case 4: *(float *)((UINT8 *)device->inline_config + offset) = (float)(INT32)data32 / (float)(1 << bits); break; - case 8: *(double *)((UINT8 *)device->inline_config + offset) = (double)(INT32)data32 / (double)(1 << bits); break; - } + device->process_token(entrytype, tokens); break; @@ -281,13 +259,4 @@ static void machine_config_detokenize(machine_config *config, const machine_conf break; } } - - /* if we are the outermost level, process any device-specific machine configurations */ - if (depth == 0) - for (device = config->devicelist.first(); device != NULL; device = device->next) - { - tokens = device->machine_config_tokens(); - if (tokens != NULL) - machine_config_detokenize(config, tokens, device, depth + 1); - } } diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h index 1f44eabe7fd..b16e30813f4 100644 --- a/src/emu/mconfig.h +++ b/src/emu/mconfig.h @@ -60,7 +60,7 @@ #define VIDEO_EOF_CALL(name) VIDEO_EOF_NAME(name)(machine) #define VIDEO_UPDATE_NAME(name) video_update_##name -#define VIDEO_UPDATE(name) UINT32 VIDEO_UPDATE_NAME(name)(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect) +#define VIDEO_UPDATE(name) UINT32 VIDEO_UPDATE_NAME(name)(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect) #define VIDEO_UPDATE_CALL(name) VIDEO_UPDATE_NAME(name)(screen, bitmap, cliprect) @@ -88,7 +88,7 @@ typedef void (*video_start_func)(running_machine *machine); typedef void (*video_reset_func)(running_machine *machine); typedef void (*palette_init_func)(running_machine *machine, const UINT8 *color_prom); typedef void (*video_eof_func)(running_machine *machine); -typedef UINT32 (*video_update_func)(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect); +typedef UINT32 (*video_update_func)(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); typedef void * (*driver_data_alloc_func)(running_machine &machine); @@ -109,26 +109,6 @@ enum MCONFIG_TOKEN_END, MCONFIG_TOKEN_INCLUDE, - MCONFIG_TOKEN_DEVICE_ADD, - MCONFIG_TOKEN_DEVICE_REMOVE, - MCONFIG_TOKEN_DEVICE_MODIFY, - MCONFIG_TOKEN_DEVICE_CLOCK, - MCONFIG_TOKEN_DEVICE_MAP, - MCONFIG_TOKEN_DEVICE_CONFIG, - MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, - MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, - MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_2, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_3, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_4, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_5, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_6, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_7, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_8, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_9, - MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, - MCONFIG_TOKEN_DRIVER_DATA, MCONFIG_TOKEN_QUANTUM_TIME, MCONFIG_TOKEN_QUANTUM_PERFECT_CPU, @@ -153,6 +133,46 @@ enum MCONFIG_TOKEN_SOUND_START, MCONFIG_TOKEN_SOUND_RESET, + + MCONFIG_TOKEN_DEVICE_ADD, + MCONFIG_TOKEN_DEVICE_REPLACE, + MCONFIG_TOKEN_DEVICE_REMOVE, + MCONFIG_TOKEN_DEVICE_MODIFY, + + // device-specific tokens + MCONFIG_TOKEN_DEVICE_CLOCK, + MCONFIG_TOKEN_DEVICE_CONFIG, + MCONFIG_TOKEN_DEVICE_INLINE_DATA16, + MCONFIG_TOKEN_DEVICE_INLINE_DATA32, + MCONFIG_TOKEN_DEVICE_INLINE_DATA64, + + // execute interface-specific tokens + MCONFIG_TOKEN_DIEXEC_DISABLE, + MCONFIG_TOKEN_DIEXEC_VBLANK_INT, + MCONFIG_TOKEN_DIEXEC_PERIODIC_INT, + + // memory interface-specific tokens + MCONFIG_TOKEN_DIMEMORY_MAP, + + // sound interface-specific tokens + MCONFIG_TOKEN_DISOUND_ROUTE, + MCONFIG_TOKEN_DISOUND_RESET, + + // legacy custom tokens + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_2, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_3, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_4, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_5, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_6, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_7, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_8, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_9, + + MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, + MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, + MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, + MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, }; @@ -190,9 +210,9 @@ enum struct gfx_decode_entry; -typedef struct _machine_config machine_config; -struct _machine_config +class machine_config { +public: driver_data_alloc_func driver_data_alloc; /* allocator for driver data */ attotime minimum_quantum; /* minimum scheduling quantum */ @@ -248,6 +268,8 @@ union machine_config_token palette_init_func palette_init; video_eof_func video_eof; video_update_func video_update; + cpu_type cputype; + device_interrupt_func cpu_interrupt; driver_data_alloc_func driver_data_alloc; }; @@ -255,6 +277,12 @@ union machine_config_token /* helper macro for returning the size of a field within a struct; similar to offsetof() */ #define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field) +#define DEVCONFIG_OFFSETOF(_class, _member) \ + ((FPTR)&static_cast<_class *>(reinterpret_cast(1000000))->_member - 1000000) + +#define DEVCONFIG_SIZEOF(_class, _member) \ + sizeof(reinterpret_cast<_class *>(NULL)->_member) + /* start/end tags for the machine driver */ #define MACHINE_DRIVER_NAME(_name) \ @@ -370,6 +398,11 @@ union machine_config_token TOKEN_PTR(devtype, _type), \ TOKEN_STRING(_tag), +#define MDRV_DEVICE_REPLACE(_tag, _type, _clock) \ + TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_REPLACE, 8, _clock, 32), \ + TOKEN_PTR(devtype, _type), \ + TOKEN_STRING(_tag), + #define MDRV_DEVICE_REMOVE(_tag) \ TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_REMOVE, 8), \ TOKEN_STRING(_tag), @@ -379,92 +412,6 @@ union machine_config_token TOKEN_STRING(_tag), -/* configure devices */ -#define MDRV_DEVICE_CONFIG(_config) \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ - TOKEN_PTR(voidptr, &(_config)), - -#define MDRV_DEVICE_CONFIG_CLEAR() \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \ - TOKEN_PTR(voidptr, NULL), - -#define MDRV_DEVICE_CLOCK(_clock) \ - TOKEN_UINT64_PACK2(MCONFIG_TOKEN_DEVICE_CLOCK, 8, _clock, 32), - -#define MDRV_DEVICE_ADDRESS_MAP(_space, _map) \ - TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DEVICE_MAP, 8, _space, 8), \ - TOKEN_PTR(addrmap, (const addrmap_token *)ADDRESS_MAP_NAME(_map)), - -#define MDRV_DEVICE_PROGRAM_MAP(_map) \ - MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_PROGRAM, _map) - -#define MDRV_DEVICE_DATA_MAP(_map) \ - MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_DATA, _map) - -#define MDRV_DEVICE_IO_MAP(_map) \ - MDRV_DEVICE_ADDRESS_MAP(ADDRESS_SPACE_IO, _map) - - - -/* inline device configurations that require 32 bits of storage in the token */ -#define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \ - TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, _size, 4, _offset, 12), \ - TOKEN_UINT32((UINT32)(_val)), - -#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \ - MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) - -#define MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \ - MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val) - -#define MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ - MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val) - - -/* inline device configurations that require 32 bits of fixed-point storage in the token */ -#define MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(_size, _offset, _val, _fixbits) \ - TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, _size, 4, _fixbits, 6, _offset, 12), \ - TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))), - -#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \ - MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val, _fixbits) - -#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY(_struct, _field, _index, _val, _fixbits) \ - MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val, _fixbits) - -#define MDRV_DEVICE_CONFIG_DATAFP32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val, _fixbits) \ - MDRV_DEVICE_CONFIG_DATAFP32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val, _fixbits) - - -/* inline device configurations that require 64 bits of storage in the token */ -#define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \ - TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, _size, 4, _offset, 12), \ - TOKEN_UINT64((UINT64)(_val)), - -#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \ - MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val) - -#define MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \ - MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val) - -#define MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \ - MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val) - - -/* inline device configurations that require a pointer-sized amount of storage in the token */ -#ifdef PTR64 -#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_struct, _size, _offset) -#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) -#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) -#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) -#else -#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_struct, _size, _offset) -#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) -#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) -#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) -#endif - - /*************************************************************************** FUNCTION PROTOTYPES diff --git a/src/emu/memory.c b/src/emu/memory.c index 3115dcf6d76..4c69d65a122 100644 --- a/src/emu/memory.c +++ b/src/emu/memory.c @@ -380,8 +380,6 @@ static const data_accessors memory_accessors[4][2] = { ACCESSOR_GROUP(64le), ACCESSOR_GROUP(64be) } }; -const char *const address_space_names[ADDRESS_SPACES] = { "program", "data", "I/O" }; - /*************************************************************************** @@ -837,19 +835,23 @@ address_map *address_map_alloc(const device_config *devconfig, const game_driver { address_map *map = global_alloc_clear(address_map); + const device_config_memory_interface *memintf; + if (!devconfig->interface(memintf)) + throw emu_fatalerror("No memory interface defined for device '%s'\n", devconfig->tag()); + + const address_space_config *spaceconfig = memintf->space_config(spacenum); + /* append the internal device map (first so it takes priority) */ - const addrmap_token *internal_map = devconfig->internal_map(spacenum); - if (internal_map != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig, internal_map); + if (spaceconfig != NULL && spaceconfig->m_internal_map != NULL) + map_detokenize((memory_private *)memdata, map, driver, devconfig, spaceconfig->m_internal_map); /* construct the standard map */ - if (devconfig->address_map[spacenum] != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig, devconfig->address_map[spacenum]); + if (memintf->address_map(spacenum) != NULL) + map_detokenize((memory_private *)memdata, map, driver, devconfig, memintf->address_map(spacenum)); /* append the default device map (last so it can be overridden) */ - const addrmap_token *default_map = devconfig->default_map(spacenum); - if (default_map != NULL) - map_detokenize((memory_private *)memdata, map, driver, devconfig, default_map); + if (spaceconfig != NULL && spaceconfig->m_default_map != NULL) + map_detokenize((memory_private *)memdata, map, driver, devconfig, spaceconfig->m_default_map); return map; } @@ -1311,7 +1313,7 @@ UINT64 *_memory_install_handler64(const address_space *space, offs_t addrstart, but explicitly for 8-bit handlers -------------------------------------------------*/ -UINT8 *_memory_install_device_handler8(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask) +UINT8 *_memory_install_device_handler8(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask) { address_space *spacerw = (address_space *)space; if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT) @@ -1332,7 +1334,7 @@ UINT8 *_memory_install_device_handler8(const address_space *space, running_devic above but explicitly for 16-bit handlers -------------------------------------------------*/ -UINT16 *_memory_install_device_handler16(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask) +UINT16 *_memory_install_device_handler16(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask) { address_space *spacerw = (address_space *)space; if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT) @@ -1353,7 +1355,7 @@ UINT16 *_memory_install_device_handler16(const address_space *space, running_dev above but explicitly for 32-bit handlers -------------------------------------------------*/ -UINT32 *_memory_install_device_handler32(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask) +UINT32 *_memory_install_device_handler32(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask) { address_space *spacerw = (address_space *)space; if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT) @@ -1374,7 +1376,7 @@ UINT32 *_memory_install_device_handler32(const address_space *space, running_dev above but explicitly for 64-bit handlers -------------------------------------------------*/ -UINT64 *_memory_install_device_handler64(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask) +UINT64 *_memory_install_device_handler64(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask) { address_space *spacerw = (address_space *)space; if (rhandler != NULL && (FPTR)rhandler < STATIC_COUNT) @@ -1681,7 +1683,7 @@ static void memory_init_spaces(running_machine *machine) { memory_private *memdata = machine->memory_data; address_space **nextptr = (address_space **)&memdata->spacelist; - running_device *device; + device_t *device; int spacenum; /* create a global watchpoint-filled table */ @@ -1689,98 +1691,105 @@ static void memory_init_spaces(running_machine *machine) memset(memdata->wptable, STATIC_WATCHPOINT, 1 << LEVEL1_BITS); /* loop over devices */ - for (device = machine->devicelist.first(); device != NULL; device = device->next) - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - if (device->addrbus_width(spacenum) > 0) + for (device = machine->devicelist.first(); device != NULL; device = device->next()) + { + device_memory_interface *memory; + if (device->interface(memory)) + for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) { - address_space *space = auto_alloc_clear(machine, address_space); - int logbits = cpu_get_logaddr_width(device, spacenum); - int ashift = device->baseconfig().addrbus_shift(spacenum); - int abits = device->addrbus_width(spacenum); - int dbits = device->databus_width(spacenum); - endianness_t endianness = device->endianness(); - int accessorindex = (dbits == 8) ? 0 : (dbits == 16) ? 1 : (dbits == 32) ? 2 : 3; - int entrynum; - - /* if logbits is 0, revert to abits */ - if (logbits == 0) - logbits = abits; - - /* determine the address and data bits */ - space->machine = machine; - space->cpu = device; - space->name = address_space_names[spacenum]; - space->accessors = memory_accessors[accessorindex][(endianness == ENDIANNESS_LITTLE) ? 0 : 1]; - space->addrmask = 0xffffffffUL >> (32 - abits); - space->bytemask = (ashift < 0) ? ((space->addrmask << -ashift) | ((1 << -ashift) - 1)) : (space->addrmask >> ashift); - space->logaddrmask = 0xffffffffUL >> (32 - logbits); - space->logbytemask = (ashift < 0) ? ((space->logaddrmask << -ashift) | ((1 << -ashift) - 1)) : (space->logaddrmask >> ashift); - space->spacenum = spacenum; - space->endianness = endianness; - space->ashift = ashift; - space->abits = abits; - space->dbits = dbits; - space->addrchars = (abits + 3) / 4; - space->logaddrchars = (logbits + 3) / 4; - space->log_unmap = TRUE; - - /* allocate subtable information; we malloc this manually because it will be realloc'ed */ - space->read.subtable = auto_alloc_array_clear(machine, subtable_data, SUBTABLE_COUNT); - space->write.subtable = auto_alloc_array_clear(machine, subtable_data, SUBTABLE_COUNT); - - /* allocate the handler table */ - space->read.handlers[0] = auto_alloc_array_clear(machine, handler_data, ARRAY_LENGTH(space->read.handlers)); - space->write.handlers[0] = auto_alloc_array_clear(machine, handler_data, ARRAY_LENGTH(space->write.handlers)); - for (entrynum = 1; entrynum < ARRAY_LENGTH(space->read.handlers); entrynum++) + const address_space_config *spaceconfig = memory->space_config(spacenum); + if (spaceconfig != NULL) { - space->read.handlers[entrynum] = space->read.handlers[0] + entrynum; - space->write.handlers[entrynum] = space->write.handlers[0] + entrynum; - } + address_space *space = auto_alloc_clear(machine, address_space); + int ashift = spaceconfig->m_addrbus_shift; + int abits = spaceconfig->m_addrbus_width; + int dbits = spaceconfig->m_databus_width; + int logbits = spaceconfig->m_logaddr_width; + endianness_t endianness = spaceconfig->m_endianness; + int accessorindex = (dbits == 8) ? 0 : (dbits == 16) ? 1 : (dbits == 32) ? 2 : 3; + int entrynum; + + /* if logbits is 0, revert to abits */ + if (logbits == 0) + logbits = abits; + + /* determine the address and data bits */ + space->machine = machine; + space->cpu = device; + space->name = spaceconfig->m_name; + space->accessors = memory_accessors[accessorindex][(endianness == ENDIANNESS_LITTLE) ? 0 : 1]; + space->addrmask = 0xffffffffUL >> (32 - abits); + space->bytemask = (ashift < 0) ? ((space->addrmask << -ashift) | ((1 << -ashift) - 1)) : (space->addrmask >> ashift); + space->logaddrmask = 0xffffffffUL >> (32 - logbits); + space->logbytemask = (ashift < 0) ? ((space->logaddrmask << -ashift) | ((1 << -ashift) - 1)) : (space->logaddrmask >> ashift); + space->spacenum = spacenum; + space->endianness = endianness; + space->ashift = ashift; + space->abits = abits; + space->dbits = dbits; + space->addrchars = (abits + 3) / 4; + space->logaddrchars = (logbits + 3) / 4; + space->log_unmap = TRUE; + + /* allocate subtable information; we malloc this manually because it will be realloc'ed */ + space->read.subtable = auto_alloc_array_clear(machine, subtable_data, SUBTABLE_COUNT); + space->write.subtable = auto_alloc_array_clear(machine, subtable_data, SUBTABLE_COUNT); + + /* allocate the handler table */ + space->read.handlers[0] = auto_alloc_array_clear(machine, handler_data, ARRAY_LENGTH(space->read.handlers)); + space->write.handlers[0] = auto_alloc_array_clear(machine, handler_data, ARRAY_LENGTH(space->write.handlers)); + for (entrynum = 1; entrynum < ARRAY_LENGTH(space->read.handlers); entrynum++) + { + space->read.handlers[entrynum] = space->read.handlers[0] + entrynum; + space->write.handlers[entrynum] = space->write.handlers[0] + entrynum; + } - /* init the static handlers */ - for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++) - { - space->read.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 0, entrynum); - space->read.handlers[entrynum]->object = space; - space->write.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 1, entrynum); - space->write.handlers[entrynum]->object = space; - } + /* init the static handlers */ + for (entrynum = 0; entrynum < ENTRY_COUNT; entrynum++) + { + space->read.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 0, entrynum); + space->read.handlers[entrynum]->object = space; + space->write.handlers[entrynum]->handler.generic = get_static_handler(space->dbits, 1, entrynum); + space->write.handlers[entrynum]->object = space; + } - /* make sure we fix up the mask for the unmap and watchpoint handlers */ - space->read.handlers[STATIC_UNMAP]->bytemask = ~0; - space->write.handlers[STATIC_UNMAP]->bytemask = ~0; - space->read.handlers[STATIC_WATCHPOINT]->bytemask = ~0; - space->write.handlers[STATIC_WATCHPOINT]->bytemask = ~0; - - /* allocate memory */ - space->read.machine = machine; - space->read.table = auto_alloc_array(machine, UINT8, 1 << LEVEL1_BITS); - space->write.machine = machine; - space->write.table = auto_alloc_array(machine, UINT8, 1 << LEVEL1_BITS); - - /* initialize everything to unmapped */ - memset(space->read.table, STATIC_UNMAP, 1 << LEVEL1_BITS); - memset(space->write.table, STATIC_UNMAP, 1 << LEVEL1_BITS); - - /* initialize the lookups */ - space->readlookup = space->read.table; - space->writelookup = space->write.table; - - /* set the direct access information base */ - space->direct.raw = space->direct.decrypted = NULL; - space->direct.bytemask = space->bytemask; - space->direct.bytestart = 1; - space->direct.byteend = 0; - space->direct.entry = STATIC_UNMAP; - space->directupdate = NULL; - - /* link us in */ - *nextptr = space; - nextptr = (address_space **)&space->next; - - /* notify the deveice */ - device->set_address_space(spacenum, space); + /* make sure we fix up the mask for the unmap and watchpoint handlers */ + space->read.handlers[STATIC_UNMAP]->bytemask = ~0; + space->write.handlers[STATIC_UNMAP]->bytemask = ~0; + space->read.handlers[STATIC_WATCHPOINT]->bytemask = ~0; + space->write.handlers[STATIC_WATCHPOINT]->bytemask = ~0; + + /* allocate memory */ + space->read.machine = machine; + space->read.table = auto_alloc_array(machine, UINT8, 1 << LEVEL1_BITS); + space->write.machine = machine; + space->write.table = auto_alloc_array(machine, UINT8, 1 << LEVEL1_BITS); + + /* initialize everything to unmapped */ + memset(space->read.table, STATIC_UNMAP, 1 << LEVEL1_BITS); + memset(space->write.table, STATIC_UNMAP, 1 << LEVEL1_BITS); + + /* initialize the lookups */ + space->readlookup = space->read.table; + space->writelookup = space->write.table; + + /* set the direct access information base */ + space->direct.raw = space->direct.decrypted = NULL; + space->direct.bytemask = space->bytemask; + space->direct.bytestart = 1; + space->direct.byteend = 0; + space->direct.entry = STATIC_UNMAP; + space->directupdate = NULL; + + /* link us in */ + *nextptr = space; + nextptr = (address_space **)&space->next; + + /* notify the device */ + memory->set_address_space(spacenum, space); + } } + } } @@ -1907,7 +1916,7 @@ static void memory_init_populate(running_machine *machine) static void memory_init_map_entry(address_space *space, const address_map_entry *entry, read_or_write readorwrite) { const map_handler_data *handler = (readorwrite == ROW_READ) ? &entry->read : &entry->write; - running_device *device; + device_t *device; /* based on the handler type, alter the bits, name, funcptr, and object */ switch (handler->type) diff --git a/src/emu/memory.h b/src/emu/memory.h index 8308a24106a..e634b547965 100644 --- a/src/emu/memory.h +++ b/src/emu/memory.h @@ -87,7 +87,7 @@ enum /* referenced types from other classes */ class device_config; -class running_device; +class device_t; struct game_driver; @@ -137,14 +137,14 @@ typedef void (*write64_space_func)(ATTR_UNUSED const address_space *space, ATTR_ /* device read/write handlers */ -typedef UINT8 (*read8_device_func) (ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset); -typedef void (*write8_device_func) (ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data); -typedef UINT16 (*read16_device_func) (ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask); -typedef void (*write16_device_func)(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask); -typedef UINT32 (*read32_device_func) (ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask); -typedef void (*write32_device_func)(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask); -typedef UINT64 (*read64_device_func) (ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask); -typedef void (*write64_device_func)(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask); +typedef UINT8 (*read8_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset); +typedef void (*write8_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data); +typedef UINT16 (*read16_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask); +typedef void (*write16_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask); +typedef UINT32 (*read32_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask); +typedef void (*write32_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask); +typedef UINT64 (*read64_device_func) (ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask); +typedef void (*write64_device_func)(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask); /* data_accessors is a struct with accessors of all flavors */ @@ -286,7 +286,7 @@ struct _address_space { address_space * next; /* next address space in the global list */ running_machine * machine; /* reference to the owning machine */ - running_device * cpu; /* reference to the owning device */ + device_t * cpu; /* reference to the owning device */ const device_config * devconfig; /* pointer to the owning device's config */ address_map * map; /* original memory map */ const char * name; /* friendly name of the address space */ @@ -341,6 +341,8 @@ union _addrmap8_token write_handler write; /* generic write handlers */ UINT8 ** memptr; /* memory pointer */ size_t * sizeptr; /* size pointer */ + + operator const addrmap_token *() const { return reinterpret_cast(this); } }; @@ -362,6 +364,8 @@ union _addrmap16_token write_handler write; /* generic write handlers */ UINT16 ** memptr; /* memory pointer */ size_t * sizeptr; /* size pointer */ + + operator const addrmap_token *() const { return reinterpret_cast(this); } }; @@ -387,6 +391,8 @@ union _addrmap32_token write_handler write; /* generic write handlers */ UINT32 ** memptr; /* memory pointer */ size_t * sizeptr; /* size pointer */ + + operator const addrmap_token *() const { return reinterpret_cast(this); } }; @@ -416,6 +422,8 @@ union _addrmap64_token write_handler write; /* generic write handlers */ UINT64 ** memptr; /* memory pointer */ size_t * sizeptr; /* size pointer */ + + operator const addrmap_token *() const { return reinterpret_cast(this); } }; @@ -440,14 +448,14 @@ union _addrmap64_token /* device read/write handler function macros */ -#define READ8_DEVICE_HANDLER(name) UINT8 name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset) -#define WRITE8_DEVICE_HANDLER(name) void name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data) -#define READ16_DEVICE_HANDLER(name) UINT16 name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask) -#define WRITE16_DEVICE_HANDLER(name) void name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask) -#define READ32_DEVICE_HANDLER(name) UINT32 name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask) -#define WRITE32_DEVICE_HANDLER(name) void name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask) -#define READ64_DEVICE_HANDLER(name) UINT64 name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask) -#define WRITE64_DEVICE_HANDLER(name) void name(ATTR_UNUSED running_device *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask) +#define READ8_DEVICE_HANDLER(name) UINT8 name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset) +#define WRITE8_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT8 data) +#define READ16_DEVICE_HANDLER(name) UINT16 name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 mem_mask) +#define WRITE16_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT16 data, ATTR_UNUSED UINT16 mem_mask) +#define READ32_DEVICE_HANDLER(name) UINT32 name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 mem_mask) +#define WRITE32_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT32 data, ATTR_UNUSED UINT32 mem_mask) +#define READ64_DEVICE_HANDLER(name) UINT64 name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 mem_mask) +#define WRITE64_DEVICE_HANDLER(name) void name(ATTR_UNUSED device_t *device, ATTR_UNUSED offs_t offset, ATTR_UNUSED UINT64 data, ATTR_UNUSED UINT64 mem_mask) /* helper macro for merging data with the memory mask */ @@ -1011,16 +1019,16 @@ UINT32 *_memory_install_handler32(const address_space *space, offs_t addrstart, UINT64 *_memory_install_handler64(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_space_func rhandler, const char *rhandler_name, write64_space_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1); /* install a new 8-bit device memory handler into the given address space, returning a pointer to the memory backing it, if present */ -UINT8 *_memory_install_device_handler8(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); +UINT8 *_memory_install_device_handler8(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read8_device_func rhandler, const char *rhandler_name, write8_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); /* same as above but explicitly for 16-bit handlers */ -UINT16 *_memory_install_device_handler16(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); +UINT16 *_memory_install_device_handler16(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read16_device_func rhandler, const char *rhandler_name, write16_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); /* same as above but explicitly for 32-bit handlers */ -UINT32 *_memory_install_device_handler32(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); +UINT32 *_memory_install_device_handler32(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read32_device_func rhandler, const char *rhandler_name, write32_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); /* same as above but explicitly for 64-bit handlers */ -UINT64 *_memory_install_device_handler64(const address_space *space, running_device *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); +UINT64 *_memory_install_device_handler64(const address_space *space, device_t *device, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, read64_device_func rhandler, const char *rhandler_name, write64_device_func whandler, const char *whandler_name, int handlerunitmask) ATTR_NONNULL(1, 2); /* install a new port into the given address space */ void _memory_install_port(const address_space *space, offs_t addrstart, offs_t addrend, offs_t addrmask, offs_t addrmirror, const char *rtag, const char *wtag) ATTR_NONNULL(1); diff --git a/src/emu/profiler.c b/src/emu/profiler.c index 402942effac..bac82b5f6e8 100644 --- a/src/emu/profiler.c +++ b/src/emu/profiler.c @@ -52,7 +52,7 @@ void _profiler_mark_start(int type) int index; /* track context switches */ - if (type >= PROFILER_CPU_FIRST && type <= PROFILER_CPU_MAX) + if (type >= PROFILER_DEVICE_FIRST && type <= PROFILER_DEVICE_MAX) data->context_switches++; /* we're starting a new bucket, begin now */ @@ -185,8 +185,8 @@ astring &_profiler_get_text(running_machine *machine, astring &string) string.catprintf("%02d%% ", (int)((computed * 100 + normalize/2) / normalize)); /* and then the text */ - if (curtype >= PROFILER_CPU_FIRST && curtype <= PROFILER_CPU_MAX) - string.catprintf("CPU '%s'", machine->devicelist.find(CPU, curtype - PROFILER_CPU_FIRST)->tag()); + if (curtype >= PROFILER_DEVICE_FIRST && curtype <= PROFILER_DEVICE_MAX) + string.catprintf("'%s'", machine->devicelist.find(curtype - PROFILER_DEVICE_FIRST)->tag()); else for (nameindex = 0; nameindex < ARRAY_LENGTH(names); nameindex++) if (names[nameindex].type == curtype) diff --git a/src/emu/profiler.h b/src/emu/profiler.h index 216e1e0f783..5b28e2cff16 100644 --- a/src/emu/profiler.h +++ b/src/emu/profiler.h @@ -33,8 +33,8 @@ /* profiling */ enum { - PROFILER_CPU_FIRST = 0, - PROFILER_CPU_MAX = PROFILER_CPU_FIRST + 32, + PROFILER_DEVICE_FIRST = 0, + PROFILER_DEVICE_MAX = PROFILER_DEVICE_FIRST + 256, PROFILER_DRC_COMPILE, PROFILER_MEMREAD, PROFILER_MEMWRITE, diff --git a/src/emu/render.c b/src/emu/render.c index 314b7a42598..48aae75a1b3 100644 --- a/src/emu/render.c +++ b/src/emu/render.c @@ -92,7 +92,6 @@ enum TYPE DEFINITIONS ***************************************************************************/ -/* typedef struct _render_texture render_texture; -- defined in render.h */ /* typedef struct _render_container render_container; -- defined in render.h */ typedef struct _object_transform object_transform; typedef struct _scaled_texture scaled_texture; @@ -127,7 +126,7 @@ struct _scaled_texture /* a render_texture is used to track transformations when building an object list */ -struct _render_texture +struct render_texture { render_texture * next; /* next texture (for free list) */ render_texture * base; /* pointer to base of texture group */ @@ -191,7 +190,7 @@ struct _render_container render_container * next; /* the next container in the list */ container_item * itemlist; /* head of the item list */ container_item ** nextitem; /* pointer to the next item to add */ - const device_config *screen; /* the screen device */ + screen_device *screen; /* the screen device */ int orientation; /* orientation of the container */ float brightness; /* brightness of the container */ float contrast; /* contrast of the container */ @@ -543,7 +542,6 @@ INLINE render_container *get_screen_container_by_index(int index) void render_init(running_machine *machine) { - const device_config *screen; render_container **current_container_ptr = &screen_container_list; /* make sure we clean up after ourselves */ @@ -563,7 +561,7 @@ void render_init(running_machine *machine) ui_container = render_container_alloc(machine); /* create a container for each screen and determine its orientation */ - for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) + for (screen_device *screendev = screen_first(*machine); screendev != NULL; screendev = screen_next(screendev)) { render_container *screen_container = render_container_alloc(machine); render_container **temp = &screen_container->next; @@ -577,7 +575,7 @@ void render_init(running_machine *machine) settings.gamma = options_get_float(mame_options(), OPTION_GAMMA); render_container_set_user_settings(screen_container, &settings); - screen_container->screen = screen; + screen_container->screen = screendev; /* link it up */ *current_container_ptr = screen_container; @@ -626,8 +624,7 @@ static void render_exit(running_machine *machine) /* free the screen overlay; similarly, do this before any of the following calls to avoid double-frees */ - if (screen_overlay != NULL) - bitmap_free(screen_overlay); + global_free(screen_overlay); screen_overlay = NULL; /* free the texture groups */ @@ -957,7 +954,7 @@ static void render_save(running_machine *machine, int config_type, xml_data_node is 'live' -------------------------------------------------*/ -int render_is_live_screen(running_device *screen) +int render_is_live_screen(device_t *screen) { render_target *target; int screen_index; @@ -967,7 +964,7 @@ int render_is_live_screen(running_device *screen) assert(screen->machine != NULL); assert(screen->machine->config != NULL); - screen_index = screen->machine->devicelist.index(VIDEO_SCREEN, screen->tag()); + screen_index = screen->machine->devicelist.index(SCREEN, screen->tag()); assert(screen_index != -1); @@ -1470,9 +1467,8 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3 for (item = target->curview->itemlist[layer]; item != NULL; item = item->next) if (item->element == NULL) { - const device_config *screen = target->machine->config->devicelist.find(VIDEO_SCREEN, item->index); - const screen_config *scrconfig = (const screen_config *)screen->inline_config; - running_device *screendev = target->machine->device(screen->tag()); + const screen_device_config *scrconfig = downcast(target->machine->config->devicelist.find(SCREEN, item->index)); + screen_device *screendev = downcast(target->machine->devicelist.find(scrconfig->tag())); const rectangle vectorvis = { 0, 639, 0, 479 }; const rectangle *visarea = NULL; render_container *container = get_screen_container_by_index(item->index); @@ -1480,12 +1476,12 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3 float xscale, yscale; /* we may be called very early, before machine->visible_area is initialized; handle that case */ - if (scrconfig->type == SCREEN_TYPE_VECTOR) + if (scrconfig->screen_type() == SCREEN_TYPE_VECTOR) visarea = &vectorvis; - else if (screendev != NULL && screendev->started) - visarea = video_screen_get_visible_area(screendev); + else if (screendev != NULL && screendev->started()) + visarea = &screendev->visible_area(); else - visarea = &scrconfig->visarea; + visarea = &scrconfig->visible_area(); /* apply target orientation to the bounds */ bounds = item->bounds; @@ -1854,7 +1850,7 @@ static int load_layout_files(render_target *target, const char *layoutfile, int } /* now do the built-in layouts for single-screen games */ - if (video_screen_count(config) == 1) + if (screen_count(*config) == 1) { if (gamedrv->flags & ORIENTATION_SWAP_XY) *nextfile = layout_file_load(config, NULL, layout_vertical); @@ -2502,7 +2498,7 @@ void render_texture_free(render_texture *texture) if (texture->scaled[scalenum].bitmap != NULL) { invalidate_all_render_ref(texture->scaled[scalenum].bitmap); - bitmap_free(texture->scaled[scalenum].bitmap); + global_free(texture->scaled[scalenum].bitmap); } /* invalidate references to the original bitmap as well */ @@ -2567,7 +2563,7 @@ void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const if (texture->scaled[scalenum].bitmap != NULL) { invalidate_all_render_ref(texture->scaled[scalenum].bitmap); - bitmap_free(texture->scaled[scalenum].bitmap); + global_free(texture->scaled[scalenum].bitmap); } texture->scaled[scalenum].bitmap = NULL; texture->scaled[scalenum].seqid = 0; @@ -2636,11 +2632,11 @@ static int texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dhe if (scaled->bitmap != NULL) { invalidate_all_render_ref(scaled->bitmap); - bitmap_free(scaled->bitmap); + global_free(scaled->bitmap); } /* allocate a new bitmap */ - scaled->bitmap = bitmap_alloc(dwidth, dheight, BITMAP_FORMAT_ARGB32); + scaled->bitmap = global_alloc(bitmap_t(dwidth, dheight, BITMAP_FORMAT_ARGB32)); scaled->seqid = ++texture->curseq; /* let the scaler do the work */ @@ -2961,7 +2957,7 @@ render_container *render_container_get_ui(void) to the screen container for this device -------------------------------------------------*/ -render_container *render_container_get_screen(const device_config *screen) +render_container *render_container_get_screen(screen_device *screen) { render_container *container; @@ -2978,12 +2974,6 @@ render_container *render_container_get_screen(const device_config *screen) } -render_container *render_container_get_screen(running_device *screen) -{ - return render_container_get_screen(&screen->baseconfig()); -} - - /*------------------------------------------------- render_container_item_add_generic - add a generic item to a container diff --git a/src/emu/render.h b/src/emu/render.h index ccab0cd78f4..72cd7d467b1 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -162,8 +162,9 @@ enum ***************************************************************************/ // forward definitions -class running_device; +class device_t; class device_config; +class screen_device; /*------------------------------------------------- @@ -181,7 +182,7 @@ typedef void (*texture_scaler_func)(bitmap_t *dest, const bitmap_t *source, cons typedef struct _render_container render_container; class render_target; -typedef struct _render_texture render_texture; +struct render_texture; typedef struct _render_font render_font; typedef struct _render_ref render_ref; @@ -327,7 +328,7 @@ struct _render_container_user_settings void render_init(running_machine *machine); /* return a boolean indicating if the screen is live */ -int render_is_live_screen(running_device *screen); +int render_is_live_screen(device_t *screen); /* return the smallest maximum update rate across all targets */ float render_get_max_update_rate(void); @@ -448,8 +449,7 @@ void render_container_set_overlay(render_container *container, bitmap_t *bitmap) render_container *render_container_get_ui(void); /* return a pointer to the container for the given screen */ -render_container *render_container_get_screen(const device_config *screen); -render_container *render_container_get_screen(running_device *screen); +render_container *render_container_get_screen(screen_device *screen); /* add a line item to the specified container */ void render_container_add_line(render_container *container, float x0, float y0, float x1, float y1, float width, rgb_t argb, UINT32 flags); diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c index 281ca0bc697..933946769ec 100644 --- a/src/emu/rendfont.c +++ b/src/emu/rendfont.c @@ -185,8 +185,7 @@ void render_font_free(render_font *font) render_font_char *ch = &font->chars[tablenum][charnum]; if (ch->texture != NULL) render_texture_free(ch->texture); - if (ch->bitmap != NULL) - bitmap_free(ch->bitmap); + global_free(ch->bitmap); } /* free the subtable itself */ @@ -216,7 +215,7 @@ static void render_font_char_expand(render_font *font, render_font_char *ch) return; /* allocate a new bitmap of the size we need */ - ch->bitmap = bitmap_alloc(ch->bmwidth, font->height, BITMAP_FORMAT_ARGB32); + ch->bitmap = global_alloc(bitmap_t(ch->bmwidth, font->height, BITMAP_FORMAT_ARGB32)); bitmap_fill(ch->bitmap, NULL, 0); /* extract the data */ @@ -816,7 +815,7 @@ static int render_font_save_cached(render_font *font, const char *filename, UINT if (ch->texture != NULL) render_texture_free(ch->texture); ch->texture = NULL; - bitmap_free(ch->bitmap); + global_free(ch->bitmap); ch->bitmap = NULL; } diff --git a/src/emu/rendlay.c b/src/emu/rendlay.c index 590f5c0404b..d1055df8628 100644 --- a/src/emu/rendlay.c +++ b/src/emu/rendlay.c @@ -545,7 +545,7 @@ static void layout_element_draw_text(bitmap_t *dest, const rectangle *bounds, co curx = bounds->min_x + (bounds->max_x - bounds->min_x - width) / 2; /* allocate a temporary bitmap */ - tempbitmap = bitmap_alloc(dest->width, dest->height, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(dest->width, dest->height, BITMAP_FORMAT_ARGB32)); /* loop over characters */ for (s = string; *s != 0; s++) @@ -591,7 +591,7 @@ static void layout_element_draw_text(bitmap_t *dest, const rectangle *bounds, co } /* free the temporary bitmap and font */ - bitmap_free(tempbitmap); + global_free(tempbitmap); render_font_free(font); } @@ -824,7 +824,7 @@ static void layout_element_draw_led7seg(bitmap_t *dest, const rectangle *bounds, skewwidth = 40; /* allocate a temporary bitmap for drawing */ - tempbitmap = bitmap_alloc(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32)); bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff,0x00,0x00,0x00)); /* top bar */ @@ -857,7 +857,7 @@ static void layout_element_draw_led7seg(bitmap_t *dest, const rectangle *bounds, /* resample to the target size */ render_resample_argb_bitmap_hq(dest->base, dest->rowpixels, dest->width, dest->height, tempbitmap, NULL, color); - bitmap_free(tempbitmap); + global_free(tempbitmap); } @@ -880,7 +880,7 @@ static void layout_element_draw_led14seg(bitmap_t *dest, const rectangle *bounds skewwidth = 40; /* allocate a temporary bitmap for drawing */ - tempbitmap = bitmap_alloc(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32)); bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff, 0x00, 0x00, 0x00)); /* top bar */ @@ -963,7 +963,7 @@ static void layout_element_draw_led14seg(bitmap_t *dest, const rectangle *bounds /* resample to the target size */ render_resample_argb_bitmap_hq(dest->base, dest->rowpixels, dest->width, dest->height, tempbitmap, NULL, color); - bitmap_free(tempbitmap); + global_free(tempbitmap); } @@ -986,7 +986,7 @@ static void layout_element_draw_led14segsc(bitmap_t *dest, const rectangle *boun skewwidth = 40; /* allocate a temporary bitmap for drawing, adding some extra space for the tail */ - tempbitmap = bitmap_alloc(bmwidth + skewwidth, bmheight + segwidth, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight + segwidth, BITMAP_FORMAT_ARGB32)); bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff, 0x00, 0x00, 0x00)); /* top bar */ @@ -1078,7 +1078,7 @@ static void layout_element_draw_led14segsc(bitmap_t *dest, const rectangle *boun /* resample to the target size */ render_resample_argb_bitmap_hq(dest->base, dest->rowpixels, dest->width, dest->height, tempbitmap, NULL, color); - bitmap_free(tempbitmap); + global_free(tempbitmap); } @@ -1101,7 +1101,7 @@ static void layout_element_draw_led16seg(bitmap_t *dest, const rectangle *bounds skewwidth = 40; /* allocate a temporary bitmap for drawing */ - tempbitmap = bitmap_alloc(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight, BITMAP_FORMAT_ARGB32)); bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff, 0x00, 0x00, 0x00)); /* top-left bar */ @@ -1194,7 +1194,7 @@ static void layout_element_draw_led16seg(bitmap_t *dest, const rectangle *bounds /* resample to the target size */ render_resample_argb_bitmap_hq(dest->base, dest->rowpixels, dest->width, dest->height, tempbitmap, NULL, color); - bitmap_free(tempbitmap); + global_free(tempbitmap); } @@ -1217,7 +1217,7 @@ static void layout_element_draw_led16segsc(bitmap_t *dest, const rectangle *boun skewwidth = 40; /* allocate a temporary bitmap for drawing */ - tempbitmap = bitmap_alloc(bmwidth + skewwidth, bmheight + segwidth, BITMAP_FORMAT_ARGB32); + tempbitmap = global_alloc(bitmap_t(bmwidth + skewwidth, bmheight + segwidth, BITMAP_FORMAT_ARGB32)); bitmap_fill(tempbitmap, NULL, MAKE_ARGB(0xff, 0x00, 0x00, 0x00)); /* top-left bar */ @@ -1319,7 +1319,7 @@ static void layout_element_draw_led16segsc(bitmap_t *dest, const rectangle *boun /* resample to the target size */ render_resample_argb_bitmap_hq(dest->base, dest->rowpixels, dest->width, dest->height, tempbitmap, NULL, color); - bitmap_free(tempbitmap); + global_free(tempbitmap); } @@ -1335,22 +1335,21 @@ static void layout_element_draw_led16segsc(bitmap_t *dest, const rectangle *boun static int get_variable_value(const machine_config *config, const char *string, char **outputptr) { - const device_config *devconfig; + const screen_device_config *devconfig; int num, den; char temp[100]; /* screen 0 parameters */ - for (devconfig = video_screen_first(config); devconfig != NULL; devconfig = video_screen_next(devconfig)) + for (devconfig = screen_first(*config); devconfig != NULL; devconfig = screen_next(devconfig)) { - int scrnum = config->devicelist.index(VIDEO_SCREEN, devconfig->tag()); - const screen_config *scrconfig = (const screen_config *)devconfig->inline_config; + int scrnum = config->devicelist.index(SCREEN, devconfig->tag()); /* native X aspect factor */ sprintf(temp, "~scr%dnativexaspect~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - num = scrconfig->visarea.max_x + 1 - scrconfig->visarea.min_x; - den = scrconfig->visarea.max_y + 1 - scrconfig->visarea.min_y; + num = devconfig->visible_area().max_x + 1 - devconfig->visible_area().min_x; + den = devconfig->visible_area().max_y + 1 - devconfig->visible_area().min_y; reduce_fraction(&num, &den); *outputptr += sprintf(*outputptr, "%d", num); return strlen(temp); @@ -1360,8 +1359,8 @@ static int get_variable_value(const machine_config *config, const char *string, sprintf(temp, "~scr%dnativeyaspect~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - num = scrconfig->visarea.max_x + 1 - scrconfig->visarea.min_x; - den = scrconfig->visarea.max_y + 1 - scrconfig->visarea.min_y; + num = devconfig->visible_area().max_x + 1 - devconfig->visible_area().min_x; + den = devconfig->visible_area().max_y + 1 - devconfig->visible_area().min_y; reduce_fraction(&num, &den); *outputptr += sprintf(*outputptr, "%d", den); return strlen(temp); @@ -1371,7 +1370,7 @@ static int get_variable_value(const machine_config *config, const char *string, sprintf(temp, "~scr%dwidth~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - *outputptr += sprintf(*outputptr, "%d", scrconfig->visarea.max_x + 1 - scrconfig->visarea.min_x); + *outputptr += sprintf(*outputptr, "%d", devconfig->visible_area().max_x + 1 - devconfig->visible_area().min_x); return strlen(temp); } @@ -1379,7 +1378,7 @@ static int get_variable_value(const machine_config *config, const char *string, sprintf(temp, "~scr%dheight~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - *outputptr += sprintf(*outputptr, "%d", scrconfig->visarea.max_y + 1 - scrconfig->visarea.min_y); + *outputptr += sprintf(*outputptr, "%d", devconfig->visible_area().max_y + 1 - devconfig->visible_area().min_y); return strlen(temp); } } @@ -1892,7 +1891,7 @@ static bitmap_t *load_component_bitmap(const char *dirname, const char *file, co int step, line; /* draw some stripes in the bitmap */ - bitmap = bitmap_alloc(100, 100, BITMAP_FORMAT_ARGB32); + bitmap = global_alloc(bitmap_t(100, 100, BITMAP_FORMAT_ARGB32)); bitmap_fill(bitmap, NULL, 0); for (step = 0; step < 100; step += 25) for (line = 0; line < 100; line++) @@ -2101,8 +2100,7 @@ static void layout_element_free(layout_element *element) global_free(temp->imagefile); if (temp->alphafile != NULL) global_free(temp->alphafile); - if (temp->bitmap != NULL) - bitmap_free(temp->bitmap); + global_free(temp->bitmap); global_free(temp); } diff --git a/src/emu/rendutil.c b/src/emu/rendutil.c index feee0a9dc4a..8377a395a8f 100644 --- a/src/emu/rendutil.c +++ b/src/emu/rendutil.c @@ -610,7 +610,7 @@ bitmap_t *render_load_png(const char *path, const char *dirname, const char *fil /* non-alpha case */ if (alphadest == NULL) { - bitmap = bitmap_alloc(png.width, png.height, BITMAP_FORMAT_ARGB32); + bitmap = global_alloc(bitmap_t(png.width, png.height, BITMAP_FORMAT_ARGB32)); if (bitmap != NULL) copy_png_to_bitmap(bitmap, &png, hasalpha); } diff --git a/src/emu/romload.c b/src/emu/romload.c index 6eb73b695c9..e81d921f92d 100644 --- a/src/emu/romload.c +++ b/src/emu/romload.c @@ -164,7 +164,7 @@ const rom_source *rom_first_source(const game_driver *drv, const machine_config /* otherwise, look through devices */ if (config != NULL) - for (devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next) + for (devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) { const rom_entry *devromp = devconfig->rom_region(); if (devromp != NULL) @@ -187,10 +187,10 @@ const rom_source *rom_next_source(const game_driver *drv, const machine_config * if (rom_source_is_gamedrv(drv, previous)) devconfig = (config != NULL) ? config->devicelist.first() : NULL; else - devconfig = ((const device_config *)previous)->next; + devconfig = ((const device_config *)previous)->next(); /* look for further devices with ROM definitions */ - for ( ; devconfig != NULL; devconfig = devconfig->next) + for ( ; devconfig != NULL; devconfig = devconfig->next()) { const rom_entry *devromp = devconfig->rom_region(); if (devromp != NULL) @@ -1231,29 +1231,34 @@ static void process_disk_entries(rom_load_data *romdata, const char *regiontag, static UINT32 normalize_flags_for_device(running_machine *machine, UINT32 startflags, const char *rgntag) { - running_device *device = machine->device(rgntag); - if (device != NULL && device->databus_width(0) != 0) + device_t *device = machine->device(rgntag); + device_memory_interface *memory; + if (device->interface(memory)) { - int buswidth; + const address_space_config *spaceconfig = memory->space_config(); + if (device != NULL && spaceconfig != NULL) + { + int buswidth; - /* set the endianness */ - startflags &= ~ROMREGION_ENDIANMASK; - if (device->endianness() == ENDIANNESS_LITTLE) - startflags |= ROMREGION_LE; - else - startflags |= ROMREGION_BE; - - /* set the width */ - startflags &= ~ROMREGION_WIDTHMASK; - buswidth = device->databus_width(0); - if (buswidth <= 8) - startflags |= ROMREGION_8BIT; - else if (buswidth <= 16) - startflags |= ROMREGION_16BIT; - else if (buswidth <= 32) - startflags |= ROMREGION_32BIT; - else - startflags |= ROMREGION_64BIT; + /* set the endianness */ + startflags &= ~ROMREGION_ENDIANMASK; + if (spaceconfig->m_endianness == ENDIANNESS_LITTLE) + startflags |= ROMREGION_LE; + else + startflags |= ROMREGION_BE; + + /* set the width */ + startflags &= ~ROMREGION_WIDTHMASK; + buswidth = spaceconfig->m_databus_width; + if (buswidth <= 8) + startflags |= ROMREGION_8BIT; + else if (buswidth <= 16) + startflags |= ROMREGION_16BIT; + else if (buswidth <= 32) + startflags |= ROMREGION_32BIT; + else + startflags |= ROMREGION_64BIT; + } } return startflags; } diff --git a/src/emu/schedule.c b/src/emu/schedule.c new file mode 100644 index 00000000000..61b8a3ce396 --- /dev/null +++ b/src/emu/schedule.c @@ -0,0 +1,413 @@ +/*************************************************************************** + + schedule.c + + Core device execution and scheduling engine. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#include "emu.h" +#include "profiler.h" +#include "debugger.h" + + +//************************************************************************** +// DEBUGGING +//************************************************************************** + +#define VERBOSE 0 + +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// internal trigger IDs +enum +{ + TRIGGER_INT = -2000, + TRIGGER_YIELDTIME = -3000, + TRIGGER_SUSPENDTIME = -4000 +}; + + + +//************************************************************************** +// MACROS +//************************************************************************** + +// these are macros to ensure inlining in device_scheduler::timeslice +#define ATTOTIME_LT(a,b) ((a).seconds < (b).seconds || ((a).seconds == (b).seconds && (a).attoseconds < (b).attoseconds)) +#define ATTOTIME_NORMALIZE(a) do { if ((a).attoseconds >= ATTOSECONDS_PER_SECOND) { (a).seconds++; (a).attoseconds -= ATTOSECONDS_PER_SECOND; } } while (0) + + + +//************************************************************************** +// CORE CPU EXECUTION +//************************************************************************** + +//------------------------------------------------- +// device_scheduler - constructor +//------------------------------------------------- + +device_scheduler::device_scheduler(running_machine &machine) : + m_machine(machine), + m_quantum_set(false), + m_executing_device(NULL), + m_execute_list(NULL) +{ +} + + +//------------------------------------------------- +// device_scheduler - destructor +//------------------------------------------------- + +device_scheduler::~device_scheduler() +{ +} + + +//------------------------------------------------- +// timeslice - execute all devices for a single +// timeslice +//------------------------------------------------- + +void device_scheduler::timeslice() +{ + bool call_debugger = ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0); + timer_execution_state *timerexec = timer_get_execution_state(&m_machine); + + // build the execution list if we don't have one yet + if (m_execute_list == NULL) + rebuild_execute_list(); + + // loop until we hit the next timer + while (ATTOTIME_LT(timerexec->basetime, timerexec->nextfire)) + { + // by default, assume our target is the end of the next quantum + attotime target; + target.seconds = timerexec->basetime.seconds; + target.attoseconds = timerexec->basetime.attoseconds + timerexec->curquantum; + ATTOTIME_NORMALIZE(target); + + // however, if the next timer is going to fire before then, override + assert(attotime_sub(timerexec->nextfire, target).seconds <= 0); + if (ATTOTIME_LT(timerexec->nextfire, target)) + target = timerexec->nextfire; + + LOG(("------------------\n")); + LOG(("cpu_timeslice: target = %s\n", attotime_string(target, 9))); + + // apply pending suspension changes + UINT32 suspendchanged = 0; + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + { + suspendchanged |= (exec->m_suspend ^ exec->m_nextsuspend); + exec->m_suspend = exec->m_nextsuspend; + exec->m_nextsuspend &= ~SUSPEND_REASON_TIMESLICE; + exec->m_eatcycles = exec->m_nexteatcycles; + } + + // recompute the execute list if any CPUs changed their suspension state + if (suspendchanged != 0) + rebuild_execute_list(); + + // loop over non-suspended CPUs + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + { + // only process if our target is later than the CPU's current time (coarse check) + if (target.seconds >= exec->m_localtime.seconds) + { + // compute how many attoseconds to execute this CPU + attoseconds_t delta = target.attoseconds - exec->m_localtime.attoseconds; + if (delta < 0 && target.seconds > exec->m_localtime.seconds) + delta += ATTOSECONDS_PER_SECOND; + assert(delta == attotime_to_attoseconds(attotime_sub(target, exec->m_localtime))); + + // if we have enough for at least 1 cycle, do the math + if (delta >= exec->m_attoseconds_per_cycle) + { + // compute how many cycles we want to execute + int ran = exec->m_cycles_running = divu_64x32((UINT64)delta >> exec->m_divshift, exec->m_divisor); + LOG((" cpu '%s': %d cycles\n", exec->device().tag(), exec->m_cycles_running)); + + // if we're not suspended, actually execute + if (exec->m_suspend == 0) + { + profiler_mark_start(exec->m_profiler); + + // note that this global variable cycles_stolen can be modified + // via the call to cpu_execute + exec->m_cycles_stolen = 0; + m_executing_device = exec; + *exec->m_icount = exec->m_cycles_running; + if (!call_debugger) + ran = exec->execute_run(exec->m_cycles_running); + else + { + debugger_start_cpu_hook(&exec->device(), target); + ran = exec->execute_run(exec->m_cycles_running); + debugger_stop_cpu_hook(&exec->device()); + } + + // adjust for any cycles we took back + assert(ran >= exec->m_cycles_stolen); + ran -= exec->m_cycles_stolen; + profiler_mark_end(); + } + + // account for these cycles + exec->m_totalcycles += ran; + + // update the local time for this CPU + attoseconds_t actualdelta = exec->m_attoseconds_per_cycle * ran; + exec->m_localtime.attoseconds += actualdelta; + ATTOTIME_NORMALIZE(exec->m_localtime); + LOG((" %d ran, %d total, time = %s\n", ran, (INT32)exec->m_totalcycles, attotime_string(exec->m_localtime, 9))); + + // if the new local CPU time is less than our target, move the target up + if (ATTOTIME_LT(exec->m_localtime, target)) + { + assert(attotime_compare(exec->m_localtime, target) < 0); + target = exec->m_localtime; + + // however, if this puts us before the base, clamp to the base as a minimum + if (ATTOTIME_LT(target, timerexec->basetime)) + { + assert(attotime_compare(target, timerexec->basetime) < 0); + target = timerexec->basetime; + } + LOG((" (new target)\n")); + } + } + } + } + m_executing_device = NULL; + + // update the base time + timerexec->basetime = target; + } + + // execute timers + timer_execute_timers(&m_machine); +} + + +//------------------------------------------------- +// boost_interleave - temporarily boosts the +// interleave factor +//------------------------------------------------- + +void device_scheduler::boost_interleave(attotime timeslice_time, attotime boost_duration) +{ + // ignore timeslices > 1 second + if (timeslice_time.seconds > 0) + return; + timer_add_scheduling_quantum(&m_machine, timeslice_time.attoseconds, boost_duration); +} + + +//------------------------------------------------- +// eat_all_cycles - eat a ton of cycles on all +// CPUs to force a quick exit +//------------------------------------------------- + +void device_scheduler::eat_all_cycles() +{ + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + exec->eat_cycles(1000000000); +} + + + +//************************************************************************** +// GLOBAL HELPERS +//************************************************************************** + +//------------------------------------------------- +// cpuexec_abort_timeslice - abort execution +// for the current timeslice +//------------------------------------------------- + +void device_scheduler::abort_timeslice() +{ + if (m_executing_device != NULL) + m_executing_device->abort_timeslice(); +} + + +//------------------------------------------------- +// trigger - generate a global trigger +//------------------------------------------------- + +void device_scheduler::trigger(int trigid, attotime after) +{ + // ensure we have a list of executing devices + if (m_execute_list == NULL) + rebuild_execute_list(); + + // if we have a non-zero time, schedule a timer + if (after.attoseconds != 0 || after.seconds != 0) + timer_set(&m_machine, after, (void *)this, trigid, static_timed_trigger); + + // send the trigger to everyone who cares + for (device_execute_interface *exec = m_execute_list; exec != NULL; exec = exec->m_nextexec) + exec->trigger(trigid); +} + + +//------------------------------------------------- +// static_timed_trigger - generate a trigger +// after a given amount of time +//------------------------------------------------- + +TIMER_CALLBACK( device_scheduler::static_timed_trigger ) +{ + reinterpret_cast(ptr)->trigger(param); +} + + +//------------------------------------------------- +// compute_perfect_interleave - compute the +// "perfect" interleave interval +//------------------------------------------------- + +void device_scheduler::compute_perfect_interleave() +{ + // ensure we have a list of executing devices + if (m_execute_list == NULL) + rebuild_execute_list(); + + // start with the first one + device_execute_interface *first = m_execute_list; + if (first != NULL) + { + attoseconds_t smallest = first->minimum_quantum(); + attoseconds_t perfect = ATTOSECONDS_PER_SECOND - 1; + + // start with a huge time factor and find the 2nd smallest cycle time + for (device_execute_interface *exec = first->m_nextexec; exec != NULL; exec = exec->m_nextexec) + { + attoseconds_t curquantum = exec->minimum_quantum(); + + // find the 2nd smallest cycle interval + if (curquantum < smallest) + { + perfect = smallest; + smallest = curquantum; + } + else if (curquantum < perfect) + perfect = curquantum; + } + + // adjust the final value + timer_set_minimum_quantum(&m_machine, perfect); + + LOG(("Perfect interleave = %.9f, smallest = %.9f\n", ATTOSECONDS_TO_DOUBLE(perfect), ATTOSECONDS_TO_DOUBLE(smallest))); + } +} + + +//------------------------------------------------- +// rebuild_execute_list - rebuild the list of +// executing CPUs, moving suspended CPUs to the +// end +//------------------------------------------------- + +void device_scheduler::rebuild_execute_list() +{ + // if we haven't yet set a scheduling quantum, do it now + if (!m_quantum_set) + { + // set the core scheduling quantum + attotime min_quantum = m_machine.config->minimum_quantum; + + // if none specified default to 60Hz + if (attotime_compare(min_quantum, attotime_zero) == 0) + min_quantum = ATTOTIME_IN_HZ(60); + + // if the configuration specifies a device to make perfect, pick that as the minimum + if (m_machine.config->perfect_cpu_quantum != NULL) + { + device_t *device = m_machine.device(m_machine.config->perfect_cpu_quantum); + if (device == NULL) + fatalerror("Device '%s' specified for perfect interleave is not present!", m_machine.config->perfect_cpu_quantum); + + device_execute_interface *exec; + if (!device->interface(exec)) + fatalerror("Device '%s' specified for perfect interleave is not an executing device!", m_machine.config->perfect_cpu_quantum); + + attotime cpu_quantum = attotime_make(0, exec->minimum_quantum()); + min_quantum = attotime_min(cpu_quantum, min_quantum); + } + + // inform the timer system of our decision + assert(min_quantum.seconds == 0); + timer_add_scheduling_quantum(&m_machine, min_quantum.attoseconds, attotime_never); + m_quantum_set = true; + } + + // start with an empty list + device_execute_interface **active_tailptr = &m_execute_list; + *active_tailptr = NULL; + + // also make an empty list of suspended devices + device_execute_interface *suspend_list = NULL; + device_execute_interface **suspend_tailptr = &suspend_list; + + // iterate over all devices + device_execute_interface *exec; + for (bool gotone = m_machine.devicelist.first(exec); gotone; gotone = exec->next(exec)) + { + // append to the appropriate list + exec->m_nextexec = NULL; + if (exec->m_suspend == 0) + { + *active_tailptr = exec; + active_tailptr = &exec->m_nextexec; + } + else + { + *suspend_tailptr = exec; + suspend_tailptr = &exec->m_nextexec; + } + } + + // append the suspend list to the end of the active list + *active_tailptr = suspend_list; +} diff --git a/src/emu/schedule.h b/src/emu/schedule.h new file mode 100644 index 00000000000..df347a90518 --- /dev/null +++ b/src/emu/schedule.h @@ -0,0 +1,104 @@ +/*************************************************************************** + + schedule.h + + Core device execution and scheduling engine. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + +#pragma once + +#ifndef __EMU_H__ +#error Dont include this file directly; include emu.h instead. +#endif + +#ifndef __SCHEDULE_H__ +#define __SCHEDULE_H__ + + +//************************************************************************** +// MACROS +//************************************************************************** + +// these must be macros because we are included before the running_machine +#define cpuexec_describe_context(mach) (mach)->describe_context() +#define cpuexec_boost_interleave(mach, slice, dur) (mach)->scheduler.boost_interleave(slice, dur) +#define cpuexec_trigger(mach, trigid) (mach)->scheduler.trigger(trigid) +#define cpuexec_triggertime(mach, trigid, dur) (mach)->scheduler.trigger(trigid, dur) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> device_scheduler + +class device_scheduler +{ + friend class device_execute_interface; + +public: + device_scheduler(running_machine &machine); + ~device_scheduler(); + + void timeslice(); + + void trigger(int trigid, attotime after = attotime_zero); + + void boost_interleave(attotime timeslice_time, attotime boost_duration); + void abort_timeslice(); + + device_execute_interface *currently_executing() const { return m_executing_device; } + + // for timer system only! + attotime override_local_time(attotime default_time); + + // for emergencies only! + void eat_all_cycles(); + +private: + void compute_perfect_interleave(); + void rebuild_execute_list(); + + static TIMER_CALLBACK( static_timed_trigger ); + + running_machine & m_machine; // reference to our owner + bool m_quantum_set; // have we set the scheduling quantum yet? + device_execute_interface * m_executing_device; // pointer to currently executing device + device_execute_interface * m_execute_list; // list of devices to be executed +}; + + +#endif /* __SCHEDULE_H__ */ diff --git a/src/emu/sound.c b/src/emu/sound.c index f0c78daeec3..86938e3671a 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -41,46 +41,6 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _sound_output sound_output; -struct _sound_output -{ - sound_stream * stream; /* associated stream */ - int output; /* output number */ -}; - - -typedef struct _sound_class_data sound_class_data; -struct _sound_class_data -{ - int outputs; /* number of outputs from this instance */ - sound_output output[MAX_OUTPUTS]; /* array of output information */ -}; - - -typedef struct _speaker_input speaker_input; -struct _speaker_input -{ - float gain; /* current gain */ - float default_gain; /* default gain */ - char * name; /* name of this input */ -}; - - -typedef struct _speaker_info speaker_info; -struct _speaker_info -{ - const speaker_config *speaker; /* pointer to the speaker info */ - const char * tag; /* speaker tag */ - sound_stream * mixer_stream; /* mixing stream */ - int inputs; /* number of input streams */ - speaker_input * input; /* array of input information */ -#ifdef MAME_DEBUG - INT32 max_sample; /* largest sample value we've seen */ - INT32 clipped_samples; /* total number of clipped samples */ - INT32 total_samples; /* total number of samples */ -#endif -}; - struct _sound_private { emu_timer *update_timer; @@ -113,8 +73,6 @@ static void sound_load(running_machine *machine, int config_type, xml_data_node static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode); static TIMER_CALLBACK( sound_update ); static void route_sound(running_machine *machine); -static STREAM_UPDATE( mixer_update ); -static STATE_POSTLOAD( mixer_postload ); @@ -122,59 +80,25 @@ static STATE_POSTLOAD( mixer_postload ); INLINE FUNCTIONS ***************************************************************************/ -/*------------------------------------------------- - get_class_data - return a pointer to the - class data --------------------------------------------------*/ - -INLINE sound_class_data *get_class_data(running_device *device) -{ - assert(device != NULL); - assert(device->type == SOUND); - assert(device->devclass == DEVICE_CLASS_SOUND_CHIP); - assert(device->token != NULL); - return (sound_class_data *)((UINT8 *)device->token + device->tokenbytes) - 1; -} - - -/*------------------------------------------------- - get_safe_token - makes sure that the passed - in device is, in fact, a timer --------------------------------------------------*/ - -INLINE speaker_info *get_safe_token(running_device *device) -{ - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SPEAKER_OUTPUT); - - return (speaker_info *)device->token; -} - - -/*------------------------------------------------- - index_to_input - map an absolute index to - a particular input --------------------------------------------------*/ +//------------------------------------------------- +// index_to_input - map an absolute index to +// a particular input +//------------------------------------------------- -INLINE speaker_info *index_to_input(running_machine *machine, int index, int *input) +INLINE speaker_device *index_to_input(running_machine *machine, int index, int &input) { - running_device *curspeak; - int count = 0; - - /* scan through the speakers until we find the indexed input */ - for (curspeak = speaker_output_first(machine); curspeak != NULL; curspeak = speaker_output_next(curspeak)) + // scan through the speakers until we find the indexed input + for (speaker_device *speaker = speaker_first(*machine); speaker != NULL; speaker = speaker_next(speaker)) { - speaker_info *info = (speaker_info *)curspeak->token; - if (index < count + info->inputs) + if (index < speaker->inputs()) { - *input = index - count; - return info; + input = index; + return speaker; } - count += info->inputs; + index -= speaker->inputs(); } - /* index out of range */ + // index out of range return NULL; } @@ -253,163 +177,6 @@ static void sound_exit(running_machine *machine) -/*************************************************************************** - SOUND DEVICE INTERFACE -***************************************************************************/ - -/*------------------------------------------------- - device_start_sound - device start callback --------------------------------------------------*/ - -static DEVICE_START( sound ) -{ - sound_class_data *classdata; - const sound_config *config; - deviceinfo devinfo; - int num_regs, outputnum; - - /* validate some basic stuff */ - assert(device != NULL); - assert(device->baseconfig().inline_config != NULL); - assert(device->machine != NULL); - assert(device->machine->config != NULL); - - /* get pointers to our data */ - config = (const sound_config *)device->baseconfig().inline_config; - classdata = get_class_data(device); - - /* get the chip's start function */ - devinfo.start = NULL; - (*config->type)(&device->baseconfig(), DEVINFO_FCT_START, &devinfo); - assert(devinfo.start != NULL); - - /* initialize this sound chip */ - num_regs = state_save_get_reg_count(device->machine); - (*devinfo.start)(device); - num_regs = state_save_get_reg_count(device->machine) - num_regs; - - /* now count the outputs */ - VPRINTF(("Counting outputs\n")); - for (outputnum = 0; outputnum < MAX_OUTPUTS; outputnum++) - { - sound_stream *stream = stream_find_by_device(device, outputnum); - int curoutput, numoutputs; - - /* stop when we run out of streams */ - if (stream == NULL) - break; - - /* accumulate the number of outputs from this stream */ - numoutputs = stream_get_outputs(stream); - assert(classdata->outputs < MAX_OUTPUTS); - - /* fill in the array */ - for (curoutput = 0; curoutput < numoutputs; curoutput++) - { - sound_output *output = &classdata->output[classdata->outputs++]; - output->stream = stream; - output->output = curoutput; - } - } - - /* if no state registered for saving, we can't save */ - if (num_regs == 0) - { - logerror("Sound chip '%s' did not register any state to save!\n", device->tag()); - if (device->machine->gamedrv->flags & GAME_SUPPORTS_SAVE) - fatalerror("Sound chip '%s' did not register any state to save!", device->tag()); - } -} - - -/*------------------------------------------------- - device_custom_config_sound - custom inline - config callback for populating sound routes --------------------------------------------------*/ - -static DEVICE_CUSTOM_CONFIG( sound ) -{ - sound_config *config = (sound_config *)device->inline_config; - - switch (entrytype) - { - /* custom config 1 is a new route */ - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1: - { - sound_route **routeptr; - int output, input; - UINT32 gain; - - /* put back the token that was originally fetched so we can grab a packed 64-bit token */ - TOKEN_UNGET_UINT32(tokens); - TOKEN_GET_UINT64_UNPACK4(tokens, entrytype, 8, output, 12, input, 12, gain, 32); - - /* allocate a new route */ - for (routeptr = &config->routelist; *routeptr != NULL; routeptr = &(*routeptr)->next) ; - *routeptr = global_alloc(sound_route); - (*routeptr)->next = NULL; - (*routeptr)->output = output; - (*routeptr)->input = input; - (*routeptr)->gain = (float)gain * (1.0f / (float)(1 << 24)); - (*routeptr)->target = TOKEN_GET_STRING(tokens); - break; - } - - /* custom config free is also used as a reset of sound routes */ - case MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE: - while (config->routelist != NULL) - { - sound_route *temp = config->routelist; - config->routelist = temp->next; - global_free(temp); - } - break; - } - - return tokens; -} - - -/*------------------------------------------------- - device_get_info_sound - device get info - callback --------------------------------------------------*/ - -DEVICE_GET_INFO( sound ) -{ - const sound_config *config = (device != NULL) ? (const sound_config *)device->inline_config : NULL; - - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: - (*config->type)(device, DEVINFO_INT_TOKEN_BYTES, info); - info->i += sizeof(sound_class_data); - break; - - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(sound_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_SOUND_CHIP; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(sound); break; - case DEVINFO_FCT_CUSTOM_CONFIG: info->custom_config = DEVICE_CUSTOM_CONFIG_NAME(sound); break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: - if (config != NULL) - (*config->type)(device, state, info); - else - strcpy(info->s, "sound"); - break; - - default: - (*config->type)(device, state, info); - break; - } -} - - - /*************************************************************************** INITIALIZATION HELPERS ***************************************************************************/ @@ -421,97 +188,31 @@ DEVICE_GET_INFO( sound ) static void route_sound(running_machine *machine) { - running_device *curspeak; - running_device *sound; - astring tempstring; - int outputnum; - - /* first count up the inputs for each speaker */ - for (sound = sound_first(machine); sound != NULL; sound = sound_next(sound)) - { - const sound_config *config = (const sound_config *)sound->baseconfig().inline_config; - int numoutputs = stream_get_device_outputs(sound); - const sound_route *route; - - /* iterate over all routes */ - for (route = config->routelist; route != NULL; route = route->next) - { - running_device *target_device = machine->device(route->target); - - /* if neither found, it's fatal */ - if (target_device == NULL) - fatalerror("Sound route \"%s\" not found!\n", route->target); - - /* if we got a speaker, bump its input count */ - if (target_device->type == SPEAKER_OUTPUT) - get_safe_token(target_device)->inputs += (route->output == ALL_OUTPUTS) ? numoutputs : 1; - } - } - - /* now allocate the mixers and input data */ - for (curspeak = speaker_output_first(machine); curspeak != NULL; curspeak = speaker_output_next(curspeak)) - { - speaker_info *info = get_safe_token(curspeak); - if (info->inputs != 0) - { - info->mixer_stream = stream_create(curspeak, info->inputs, 1, machine->sample_rate, info, mixer_update); - state_save_register_postload(machine, mixer_postload, info->mixer_stream); - info->input = auto_alloc_array(machine, speaker_input, info->inputs); - info->inputs = 0; - } - else - logerror("Warning: speaker \"%s\" has no inputs\n", info->tag); - } - /* iterate again over all the sound chips */ - for (sound = sound_first(machine); sound != NULL; sound = sound_next(sound)) + device_sound_interface *sound; + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) { - const sound_config *config = (const sound_config *)sound->baseconfig().inline_config; - int numoutputs = stream_get_device_outputs(sound); - const sound_route *route; + int numoutputs = stream_get_device_outputs(*sound); /* iterate over all routes */ - for (route = config->routelist; route != NULL; route = route->next) + for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) { - running_device *target_device = machine->device(route->target); - int inputnum = route->input; - sound_stream *stream; - int streamoutput; + device_t *target_device = machine->device(route->m_target); + if (target_device->type() == SPEAKER) + continue; + + int inputnum = route->m_input; /* iterate over all outputs, matching any that apply */ - for (outputnum = 0; outputnum < numoutputs; outputnum++) - if (route->output == outputnum || route->output == ALL_OUTPUTS) + for (int outputnum = 0; outputnum < numoutputs; outputnum++) + if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS) { - /* if it's a speaker, set the input */ - if (target_device->type == SPEAKER_OUTPUT) - { - speaker_info *speakerinfo = get_safe_token(target_device); + sound_stream *inputstream, *stream; + int streaminput, streamoutput; - /* generate text for the UI */ - tempstring.printf("Speaker '%s': %s '%s'", target_device->tag(), sound->name(), sound->tag()); - if (numoutputs > 1) - tempstring.catprintf(" Ch.%d", outputnum); - - /* fill in the input data on this speaker */ - speakerinfo->input[speakerinfo->inputs].gain = route->gain; - speakerinfo->input[speakerinfo->inputs].default_gain = route->gain; - speakerinfo->input[speakerinfo->inputs].name = auto_strdup(machine, tempstring); - - /* connect the output to the input */ - if (stream_device_output_to_stream_output(sound, outputnum, &stream, &streamoutput)) - stream_set_input(speakerinfo->mixer_stream, speakerinfo->inputs++, stream, streamoutput, route->gain); - } - - /* otherwise, it's a sound chip */ - else - { - sound_stream *inputstream; - int streaminput; - - if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput)) - if (stream_device_output_to_stream_output(sound, outputnum, &stream, &streamoutput)) - stream_set_input(inputstream, streaminput, stream, streamoutput, route->gain); - } + if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput)) + if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput)) + stream_set_input(inputstream, streaminput, stream, streamoutput, route->m_gain); } } } @@ -529,11 +230,11 @@ static void route_sound(running_machine *machine) static void sound_reset(running_machine *machine) { - running_device *sound; + device_sound_interface *sound; /* reset all the sound chips */ - for (sound = sound_first(machine); sound != NULL; sound = sound_next(sound)) - sound->reset(); + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) + sound->device().reset(); } @@ -690,7 +391,6 @@ static void sound_save(running_machine *machine, int config_type, xml_data_node static TIMER_CALLBACK( sound_update ) { UINT32 finalmix_step, finalmix_offset; - running_device *curspeak; int samples_this_update = 0; int sample; sound_private *global = machine->sound_data; @@ -706,67 +406,8 @@ static TIMER_CALLBACK( sound_update ) finalmix = global->finalmix; /* force all the speaker streams to generate the proper number of samples */ - for (curspeak = speaker_output_first(machine); curspeak != NULL; curspeak = speaker_output_next(curspeak)) - { - speaker_info *spk = (speaker_info *)curspeak->token; - const stream_sample_t *stream_buf; - - /* get the output buffer */ - if (spk->mixer_stream != NULL) - { - int numsamples; - - /* update the stream, getting the start/end pointers around the operation */ - stream_buf = stream_get_output_since_last_update(spk->mixer_stream, 0, &numsamples); - - /* set or assert that all streams have the same count */ - if (samples_this_update == 0) - { - samples_this_update = numsamples; - - /* reset the mixing streams */ - memset(leftmix, 0, samples_this_update * sizeof(*leftmix)); - memset(rightmix, 0, samples_this_update * sizeof(*rightmix)); - } - assert(samples_this_update == numsamples); - -#ifdef MAME_DEBUG - /* debug version: keep track of the maximum sample */ - for (sample = 0; sample < samples_this_update; sample++) - { - if (stream_buf[sample] > spk->max_sample) - spk->max_sample = stream_buf[sample]; - else if (-stream_buf[sample] > spk->max_sample) - spk->max_sample = -stream_buf[sample]; - if (stream_buf[sample] > 32767 || stream_buf[sample] < -32768) - spk->clipped_samples++; - spk->total_samples++; - } -#endif - - /* mix if sound is enabled */ - if (global->enabled && !global->nosound_mode) - { - /* if the speaker is centered, send to both left and right */ - if (spk->speaker->x == 0) - for (sample = 0; sample < samples_this_update; sample++) - { - leftmix[sample] += stream_buf[sample]; - rightmix[sample] += stream_buf[sample]; - } - - /* if the speaker is to the left, send only to the left */ - else if (spk->speaker->x < 0) - for (sample = 0; sample < samples_this_update; sample++) - leftmix[sample] += stream_buf[sample]; - - /* if the speaker is to the right, send only to the right */ - else - for (sample = 0; sample < samples_this_update; sample++) - rightmix[sample] += stream_buf[sample]; - } - } - } + for (speaker_device *speaker = speaker_first(*machine); speaker != NULL; speaker = speaker_next(speaker)) + speaker->mix(leftmix, rightmix, samples_this_update, !global->enabled || global->nosound_mode); /* now downmix the final result */ finalmix_step = video_get_speed_factor(); @@ -810,107 +451,280 @@ static TIMER_CALLBACK( sound_update ) } -/*------------------------------------------------- - mixer_update - mix all inputs to one output --------------------------------------------------*/ -static STREAM_UPDATE( mixer_update ) +//************************************************************************** +// SPEAKER DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// speaker_device_config - constructor +//------------------------------------------------- + +speaker_device_config::speaker_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + m_x(0.0), + m_y(0.0), + m_z(0.0) { - speaker_info *speaker = (speaker_info *)param; - int numinputs = speaker->inputs; - int pos; +} - VPRINTF(("Mixer_update(%d)\n", samples)); - /* loop over samples */ - for (pos = 0; pos < samples; pos++) - { - INT32 sample = inputs[0][pos]; - int inp; +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- - /* add up all the inputs */ - for (inp = 1; inp < numinputs; inp++) - sample += inputs[inp][pos]; - outputs[0][pos] = sample; - } +device_config *speaker_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(speaker_device_config(mconfig, tag, owner, clock)); } -/*------------------------------------------------- - mixer_postload - postload function to reset - the mixer stream to the proper sample rate --------------------------------------------------*/ +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- -static STATE_POSTLOAD( mixer_postload ) +device_t *speaker_device_config::alloc_device(running_machine &machine) const { - sound_stream *stream = (sound_stream *)param; - stream_set_sample_rate(stream, machine->sample_rate); + return auto_alloc(&machine, speaker_device(machine, *this)); } +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -/*************************************************************************** - SPEAKER OUTPUT DEVICE INTERFACE -***************************************************************************/ +void speaker_device_config::device_config_complete() +{ + // move inline data into its final home + m_x = static_cast(static_cast(m_inline_data[INLINE_X])) / (double)(1 << 24); + m_y = static_cast(static_cast(m_inline_data[INLINE_Y])) / (double)(1 << 24); + m_z = static_cast(static_cast(m_inline_data[INLINE_Z])) / (double)(1 << 24); +} -/*------------------------------------------------- - speaker_output_start - device start callback - for a speaker --------------------------------------------------*/ -static DEVICE_START( speaker_output ) -{ - speaker_info *info = (speaker_info *)device->token; - /* copy in all the relevant info */ - info->speaker = (const speaker_config *)device->baseconfig().inline_config; - info->tag = device->tag(); +//************************************************************************** +// LIVE SPEAKER DEVICE +//************************************************************************** + +//------------------------------------------------- +// speaker_device - constructor +//------------------------------------------------- + +speaker_device::speaker_device(running_machine &_machine, const speaker_device_config &config) + : device_t(_machine, config), + m_config(config), + m_mixer_stream(NULL), + m_inputs(0), + m_input(NULL) +#ifdef MAME_DEBUG + , + m_max_sample(0), + m_clipped_samples(0), + m_total_samples(0) +#endif +{ } -/*------------------------------------------------- - speaker_output_stop - device stop callback - for a speaker --------------------------------------------------*/ +//------------------------------------------------- +// ~speaker_device - destructor +//------------------------------------------------- -static DEVICE_STOP( speaker_output ) +speaker_device::~speaker_device() { #ifdef MAME_DEBUG - speaker_info *info = (speaker_info *)device->token; - - /* log the maximum sample values for all speakers */ - if (info->max_sample > 0) - mame_printf_debug("Speaker \"%s\" - max = %d (gain *= %f) - %d%% samples clipped\n", info->tag, info->max_sample, 32767.0 / (info->max_sample ? info->max_sample : 1), (int)((double)info->clipped_samples * 100.0 / info->total_samples)); + // log the maximum sample values for all speakers + if (m_max_sample > 0) + mame_printf_debug("Speaker \"%s\" - max = %d (gain *= %f) - %d%% samples clipped\n", tag(), m_max_sample, 32767.0 / (m_max_sample ? m_max_sample : 1), (int)((double)m_clipped_samples * 100.0 / m_total_samples)); #endif /* MAME_DEBUG */ } -/*------------------------------------------------- - speaker_output_get_info - device get info - callback --------------------------------------------------*/ +//------------------------------------------------- +// device_start - perform device-specific +// startup +//------------------------------------------------- + +void speaker_device::device_start() +{ + // scan all the sound devices and count our inputs + int inputs = 0; + device_sound_interface *sound; + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) + { + // scan each route on the device + for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) + { + // if we are the target of this route, accumulate inputs + device_t *target_device = machine->device(route->m_target); + if (target_device == this) + { + // if the sound device is not yet started, bail however -- we need the its stream + if (!sound->device().started()) + throw device_missing_dependencies(); + + // accumulate inputs + inputs += (route->m_output == ALL_OUTPUTS) ? stream_get_device_outputs(*sound) : 1; + } + } + } + + // no inputs? that's weird + if (inputs == 0) + { + logerror("Warning: speaker \"%s\" has no inputs\n", tag()); + return; + } + + // now we know how many inputs; allocate the mixers and input data + m_mixer_stream = stream_create(this, inputs, 1, machine->sample_rate, NULL, static_mixer_update); + m_input = auto_alloc_array(machine, speaker_input, inputs); + m_inputs = 0; + + // iterate again over all the sound devices + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) + { + // scan each route on the device + for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) + { + // if we are the target of this route, hook it up + device_t *target_device = machine->device(route->m_target); + if (target_device == this) + { + // iterate over all outputs, matching any that apply + int numoutputs = stream_get_device_outputs(*sound); + for (int outputnum = 0; outputnum < numoutputs; outputnum++) + if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS) + { + // fill in the input data on this speaker + m_input[m_inputs].m_gain = route->m_gain; + m_input[m_inputs].m_default_gain = route->m_gain; + m_input[m_inputs].m_name.printf("Speaker '%s': %s '%s'", tag(), sound->device().name(), sound->device().tag()); + if (numoutputs > 1) + m_input[m_inputs].m_name.catprintf(" Ch.%d", outputnum); + + // connect the output to the input + sound_stream *stream; + int streamoutput; + if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput)) + stream_set_input(m_mixer_stream, m_inputs++, stream, streamoutput, route->m_gain); + } + } + } + } +} + + +//------------------------------------------------- +// device_post_load - after we load a save state +// be sure to update the mixer stream's output +// sample rate +//------------------------------------------------- + +void speaker_device::device_post_load() +{ + stream_set_sample_rate(m_mixer_stream, machine->sample_rate); +} + + +//------------------------------------------------- +// mixer_update - mix all inputs to one output +//------------------------------------------------- + +void speaker_device::mixer_update(stream_sample_t **inputs, stream_sample_t **outputs, int samples) +{ + VPRINTF(("Mixer_update(%d)\n", samples)); + + // loop over samples + for (int pos = 0; pos < samples; pos++) + { + INT32 sample = inputs[0][pos]; + int inp; + + // add up all the inputs + for (inp = 1; inp < m_inputs; inp++) + sample += inputs[inp][pos]; + outputs[0][pos] = sample; + } +} + -DEVICE_GET_INFO( speaker_output ) +//------------------------------------------------- +// mix - mix in samples from the speaker's stream +//------------------------------------------------- + +void speaker_device::mix(INT32 *leftmix, INT32 *rightmix, int &samples_this_update, bool suppress) { - switch (state) + // skip if no stream + if (m_mixer_stream == NULL) + return; + + // update the stream, getting the start/end pointers around the operation + int numsamples; + const stream_sample_t *stream_buf = stream_get_output_since_last_update(m_mixer_stream, 0, &numsamples); + + // set or assert that all streams have the same count + if (samples_this_update == 0) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(speaker_info); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(speaker_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_AUDIO; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(speaker_output); break; - case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(speaker_output); break; - case DEVINFO_FCT_RESET: /* Nothing */ break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Speaker"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Sound"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + samples_this_update = numsamples; + + /* reset the mixing streams */ + memset(leftmix, 0, samples_this_update * sizeof(*leftmix)); + memset(rightmix, 0, samples_this_update * sizeof(*rightmix)); } + assert(samples_this_update == numsamples); + +#ifdef MAME_DEBUG + // debug version: keep track of the maximum sample + for (int sample = 0; sample < samples_this_update; sample++) + { + if (stream_buf[sample] > m_max_sample) + m_max_sample = stream_buf[sample]; + else if (-stream_buf[sample] > m_max_sample) + m_max_sample = -stream_buf[sample]; + if (stream_buf[sample] > 32767 || stream_buf[sample] < -32768) + m_clipped_samples++; + m_total_samples++; + } +#endif + + // mix if sound is enabled + if (!suppress) + { + // if the speaker is centered, send to both left and right + if (m_config.m_x == 0) + for (int sample = 0; sample < samples_this_update; sample++) + { + leftmix[sample] += stream_buf[sample]; + rightmix[sample] += stream_buf[sample]; + } + + // if the speaker is to the left, send only to the left + else if (m_config.m_x < 0) + for (int sample = 0; sample < samples_this_update; sample++) + leftmix[sample] += stream_buf[sample]; + + // if the speaker is to the right, send only to the right + else + for (int sample = 0; sample < samples_this_update; sample++) + rightmix[sample] += stream_buf[sample]; + } +} + + +//------------------------------------------------- +// set_input_gain - set the gain on a given +// input +//------------------------------------------------- + +void speaker_device::set_input_gain(int inputnum, float gain) +{ + m_input[inputnum].m_gain = gain; + stream_set_input_gain(m_mixer_stream, inputnum, gain); } @@ -924,7 +738,7 @@ DEVICE_GET_INFO( speaker_output ) particular output -------------------------------------------------*/ -void sound_set_output_gain(running_device *device, int output, float gain) +void sound_set_output_gain(device_t *device, int output, float gain) { sound_stream *stream; int outputnum; @@ -946,15 +760,11 @@ void sound_set_output_gain(running_device *device, int output, float gain) int sound_get_user_gain_count(running_machine *machine) { - running_device *curspeak; + // count up the number of speaker inputs int count = 0; + for (speaker_device *speaker = speaker_first(*machine); speaker != NULL; speaker = speaker_next(speaker)) + count += speaker->inputs(); - /* count up the number of speaker inputs */ - for (curspeak = speaker_output_first(machine); curspeak != NULL; curspeak = speaker_output_next(curspeak)) - { - speaker_info *info = (speaker_info *)curspeak->token; - count += info->inputs; - } return count; } @@ -967,13 +777,10 @@ int sound_get_user_gain_count(running_machine *machine) void sound_set_user_gain(running_machine *machine, int index, float gain) { int inputnum; - speaker_info *spk = index_to_input(machine, index, &inputnum); + speaker_device *speaker = index_to_input(machine, index, inputnum); - if (spk != NULL) - { - spk->input[inputnum].gain = gain; - stream_set_input_gain(spk->mixer_stream, inputnum, gain); - } + if (speaker != NULL) + speaker->set_input_gain(inputnum, gain); } @@ -985,8 +792,8 @@ void sound_set_user_gain(running_machine *machine, int index, float gain) float sound_get_user_gain(running_machine *machine, int index) { int inputnum; - speaker_info *spk = index_to_input(machine, index, &inputnum); - return (spk != NULL) ? spk->input[inputnum].gain : 0; + speaker_device *speaker = index_to_input(machine, index, inputnum); + return (speaker != NULL) ? speaker->input_gain(inputnum) : 0; } @@ -998,8 +805,8 @@ float sound_get_user_gain(running_machine *machine, int index) float sound_get_default_gain(running_machine *machine, int index) { int inputnum; - speaker_info *spk = index_to_input(machine, index, &inputnum); - return (spk != NULL) ? spk->input[inputnum].default_gain : 0; + speaker_device *speaker = index_to_input(machine, index, inputnum); + return (speaker != NULL) ? speaker->input_default_gain(inputnum) : 0; } @@ -1011,6 +818,6 @@ float sound_get_default_gain(running_machine *machine, int index) const char *sound_get_user_gain_name(running_machine *machine, int index) { int inputnum; - speaker_info *spk = index_to_input(machine, index, &inputnum); - return (spk != NULL) ? spk->input[inputnum].name : NULL; + speaker_device *speaker = index_to_input(machine, index, inputnum); + return (speaker != NULL) ? speaker->input_name(inputnum) : 0; } diff --git a/src/emu/sound.h b/src/emu/sound.h index a43c15fd7d9..0fddfc5a286 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -19,29 +19,14 @@ #define __SOUND_H__ -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define MAX_OUTPUTS 4095 /* maximum number of outputs a sound chip can support */ -#define ALL_OUTPUTS (MAX_OUTPUTS) /* special value indicating all outputs for the current chip */ - - - /*************************************************************************** MACROS ***************************************************************************/ /* these functions are macros primarily due to include file ordering */ /* plus, they are very simple */ -#define sound_count(config) (config)->devicelist.count(SOUND) -#define sound_first(config) (config)->devicelist.first(SOUND) -#define sound_next(previous) (previous)->typenext() - -/* these functions are macros primarily due to include file ordering */ -/* plus, they are very simple */ -#define speaker_output_count(config) (config)->devicelist.count(SPEAKER_OUTPUT) -#define speaker_output_first(config) (config)->devicelist.first(SPEAKER_OUTPUT) +#define speaker_output_count(config) (config)->devicelist.count(SPEAKER) +#define speaker_output_first(config) (config)->devicelist.first(SPEAKER) #define speaker_output_next(previous) (previous)->typenext() @@ -50,86 +35,110 @@ TYPE DEFINITIONS ***************************************************************************/ -/* sound type is just a device type */ -typedef device_type sound_type; - +// ======================> speaker_device_config -/* Sound route for the machine driver */ -typedef struct _sound_route sound_route; -struct _sound_route +class speaker_device_config : public device_config { - sound_route * next; /* pointer to next route */ - UINT32 output; /* output index, or ALL_OUTPUTS */ - const char * target; /* target tag */ - UINT32 input; /* target input index */ - float gain; /* gain */ + friend class speaker_device; + + // construction/destruction + speaker_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Speaker"; } + + // indexes to inline data + enum + { + INLINE_X, + INLINE_Y, + INLINE_Z + }; + +protected: + // device_config overrides + virtual void device_config_complete(); + + // internal state + double m_x; + double m_y; + double m_z; }; -/* Sound configuration for the machine driver */ -typedef struct _sound_config sound_config; -struct _sound_config -{ - sound_type type; /* type of sound chip */ - sound_route * routelist; /* list of sound routes */ -}; +// ======================> speaker_device -/* Speaker configuration for the machine driver */ -typedef struct _speaker_config speaker_config; -struct _speaker_config +class speaker_device : public device_t { - float x, y, z; /* positioning vector */ + friend class speaker_device_config; + friend resource_pool_object::~resource_pool_object(); + + // construction/destruction + speaker_device(running_machine &_machine, const speaker_device_config &config); + virtual ~speaker_device(); + +public: + // input properties + int inputs() const { return m_inputs; } + float input_gain(int index = 0) const { return m_input[index].m_gain; } + float input_default_gain(int index = 0) const { return m_input[index].m_default_gain; } + const char *input_name(int index = 0) const { return m_input[index].m_name; } + void set_input_gain(int index, float gain); + + // internally for use by the sound system + void mix(INT32 *leftmix, INT32 *rightmix, int &samples_this_update, bool suppress); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_post_load(); + + // internal helpers + static STREAM_UPDATE( static_mixer_update ) { downcast(device)->mixer_update(inputs, outputs, samples); } + void mixer_update(stream_sample_t **inputs, stream_sample_t **outputs, int samples); + + // a single input + struct speaker_input + { + float m_gain; // current gain + float m_default_gain; // default gain + astring m_name; // name of this input + }; + + // internal state + const speaker_device_config &m_config; + sound_stream * m_mixer_stream; // mixing stream + int m_inputs; // number of input streams + speaker_input * m_input; // array of input information +#ifdef MAME_DEBUG + INT32 m_max_sample; // largest sample value we've seen + INT32 m_clipped_samples; // total number of clipped samples + INT32 m_total_samples; // total number of samples +#endif }; +// device type definition +const device_type SPEAKER = speaker_device_config::static_alloc_device_config; + + /*************************************************************************** SOUND DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MDRV_SOUND_ADD(_tag, _type, _clock) \ - MDRV_DEVICE_ADD(_tag, SOUND, _clock) \ - MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type) - -#define MDRV_SOUND_MODIFY(_tag) \ - MDRV_DEVICE_MODIFY(_tag) - -#define MDRV_SOUND_TYPE(_type) \ - MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type) - -#define MDRV_SOUND_CLOCK(_clock) \ - MDRV_DEVICE_CLOCK(_clock) - -#define MDRV_SOUND_REPLACE(_tag, _type, _clock) \ - MDRV_DEVICE_MODIFY(_tag) \ - MDRV_DEVICE_CONFIG_CLEAR() \ - MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_##_type) \ - MDRV_DEVICE_CLOCK(_clock) \ - MDRV_SOUND_ROUTES_RESET() - -#define MDRV_SOUND_CONFIG(_config) \ - MDRV_DEVICE_CONFIG(_config) - - -/* sound routine is too complex for standard decoding, so we use a custom config */ -#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \ - TOKEN_UINT64_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_1, 8, _output, 12, _input, 12, ((float)(_gain) * (float)(1 << 24)), 32), \ - TOKEN_PTR(stringptr, _target), - -#define MDRV_SOUND_ROUTE(_output, _target, _gain) \ - MDRV_SOUND_ROUTE_EX(_output, _target, _gain, 0) - -#define MDRV_SOUND_ROUTES_RESET() \ - TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE, 8), - - /* add/remove speakers */ #define MDRV_SPEAKER_ADD(_tag, _x, _y, _z) \ - MDRV_DEVICE_ADD(_tag, SPEAKER_OUTPUT, 0) \ - MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, x, _x, 24) \ - MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, y, _y, 24) \ - MDRV_DEVICE_CONFIG_DATAFP32(speaker_config, z, _z, 24) + MDRV_DEVICE_ADD(_tag, SPEAKER, 0) \ + MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_X, (_x) * (double)(1 << 24)) \ + MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_Y, (_y) * (double)(1 << 24)) \ + MDRV_DEVICE_INLINE_DATA32(speaker_device_config::INLINE_Z, (_z) * (double)(1 << 24)) #define MDRV_SPEAKER_STANDARD_MONO(_tag) \ MDRV_SPEAKER_ADD(_tag, 0.0, 0.0, 1.0) @@ -151,12 +160,6 @@ void sound_init(running_machine *machine); /* ----- sound device interface ----- */ -/* device get info callback */ -#define SOUND DEVICE_GET_INFO_NAME(sound) -DEVICE_GET_INFO( sound ); - - - /* global sound controls */ void sound_mute(running_machine *machine, int mute); void sound_set_attenuation(running_machine *machine, int attenuation); @@ -172,35 +175,77 @@ const char *sound_get_user_gain_name(running_machine *machine, int index); /* driver gain controls on chip outputs */ -void sound_set_output_gain(running_device *device, int output, float gain); +void sound_set_output_gain(device_t *device, int output, float gain); -/* ----- sound speaker device interface ----- */ -/* device get info callback */ -#define SPEAKER_OUTPUT DEVICE_GET_INFO_NAME(speaker_output) -DEVICE_GET_INFO( speaker_output ); +//************************************************************************** +// INLINE HELPERS +//************************************************************************** +//------------------------------------------------- +// speaker_count - return the number of speaker +// devices in a machine_config +//------------------------------------------------- +inline int speaker_count(const machine_config &config) +{ + return config.devicelist.count(SPEAKER); +} + + +//------------------------------------------------- +// speaker_first - return the first speaker +// device config in a machine_config +//------------------------------------------------- + +inline const speaker_device_config *speaker_first(const machine_config &config) +{ + return downcast(config.devicelist.first(SPEAKER)); +} -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ -/*------------------------------------------------- - sound_get_type - return the type of the - specified sound chip --------------------------------------------------*/ +//------------------------------------------------- +// speaker_next - return the next speaker +// device config in a machine_config +//------------------------------------------------- -INLINE sound_type sound_get_type(const device_config *devconfig) +inline const speaker_device_config *speaker_next(const speaker_device_config *previous) { - const sound_config *config = (const sound_config *)devconfig->inline_config; - return config->type; + return downcast(previous->typenext()); } -INLINE sound_type sound_get_type(running_device *device) + +//------------------------------------------------- +// speaker_count - return the number of speaker +// devices in a machine +//------------------------------------------------- + +inline int speaker_count(running_machine &machine) +{ + return machine.devicelist.count(SPEAKER); +} + + +//------------------------------------------------- +// speaker_first - return the first speaker +// device in a machine +//------------------------------------------------- + +inline speaker_device *speaker_first(running_machine &machine) +{ + return downcast(machine.devicelist.first(SPEAKER)); +} + + +//------------------------------------------------- +// speaker_next - return the next speaker +// device in a machine +//------------------------------------------------- + +inline speaker_device *speaker_next(speaker_device *previous) { - return sound_get_type(&device->baseconfig()); + return downcast(previous->typenext()); } diff --git a/src/emu/sound/2151intf.c b/src/emu/sound/2151intf.c index cdd29c8f0a4..62cf396c4f9 100644 --- a/src/emu/sound/2151intf.c +++ b/src/emu/sound/2151intf.c @@ -27,10 +27,8 @@ struct _ym2151_state INLINE ym2151_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2151); - return (ym2151_state *)device->token; + assert(device->type() == SOUND_YM2151); + return (ym2151_state *)downcast(device)->token(); } @@ -54,14 +52,14 @@ static DEVICE_START( ym2151 ) ym2151_state *info = get_safe_token(device); int rate; - info->intf = device->baseconfig().static_config ? (const ym2151_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const ym2151_interface *)device->baseconfig().static_config() : &dummy; - rate = device->clock/64; + rate = device->clock()/64; /* stream setup */ info->stream = stream_create(device,0,2,rate,info,ym2151_update); - info->chip = ym2151_init(device,device->clock,rate); + info->chip = ym2151_init(device,device->clock(),rate); assert_always(info->chip != NULL, "Error creating YM2151 chip"); state_save_register_postload(device->machine, ym2151intf_postload, info); diff --git a/src/emu/sound/2151intf.h b/src/emu/sound/2151intf.h index f20963e8386..214e6206935 100644 --- a/src/emu/sound/2151intf.h +++ b/src/emu/sound/2151intf.h @@ -3,6 +3,8 @@ #ifndef __2151INTF_H__ #define __2151INTF_H__ +#include "devlegcy.h" + typedef struct _ym2151_interface ym2151_interface; struct _ym2151_interface { @@ -17,7 +19,6 @@ READ8_DEVICE_HANDLER( ym2151_status_port_r ); WRITE8_DEVICE_HANDLER( ym2151_register_port_w ); WRITE8_DEVICE_HANDLER( ym2151_data_port_w ); -DEVICE_GET_INFO( ym2151 ); -#define SOUND_YM2151 DEVICE_GET_INFO_NAME( ym2151 ) +DECLARE_LEGACY_SOUND_DEVICE(YM2151, ym2151); #endif /* __2151INTF_H__ */ diff --git a/src/emu/sound/2203intf.c b/src/emu/sound/2203intf.c index c831095a7d2..87b718d8b09 100644 --- a/src/emu/sound/2203intf.c +++ b/src/emu/sound/2203intf.c @@ -19,10 +19,8 @@ struct _ym2203_state INLINE ym2203_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2203); - return (ym2203_state *)device->token; + assert(device->type() == SOUND_YM2203); + return (ym2203_state *)downcast(device)->token(); } @@ -127,13 +125,13 @@ static DEVICE_START( ym2203 ) }, NULL }; - const ym2203_interface *intf = device->baseconfig().static_config ? (const ym2203_interface *)device->baseconfig().static_config : &generic_2203; + const ym2203_interface *intf = device->baseconfig().static_config() ? (const ym2203_interface *)device->baseconfig().static_config() : &generic_2203; ym2203_state *info = get_safe_token(device); - int rate = device->clock/72; /* ??? */ + int rate = device->clock()/72; /* ??? */ info->intf = intf; info->device = device; - info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, device->clock, &intf->ay8910_intf); + info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, device->clock(), &intf->ay8910_intf); assert_always(info->psg != NULL, "Error creating YM2203/AY8910 chip"); /* Timer Handler set */ @@ -144,7 +142,7 @@ static DEVICE_START( ym2203 ) info->stream = stream_create(device,0,1,rate,info,ym2203_stream_update); /* Initialize FM emurator */ - info->chip = ym2203_init(info,device,device->clock,rate,timer_handler,IRQHandler,&psgintf); + info->chip = ym2203_init(info,device,device->clock(),rate,timer_handler,IRQHandler,&psgintf); assert_always(info->chip != NULL, "Error creating YM2203 chip"); state_save_register_postload(device->machine, ym2203_intf_postload, info); diff --git a/src/emu/sound/2203intf.h b/src/emu/sound/2203intf.h index 9d4f24c7ab3..9c3badb48a8 100644 --- a/src/emu/sound/2203intf.h +++ b/src/emu/sound/2203intf.h @@ -3,6 +3,8 @@ #ifndef __2203INTF_H__ #define __2203INTF_H__ +#include "devlegcy.h" + #include "ay8910.h" void ym2203_update_request(void *param); @@ -22,7 +24,6 @@ READ8_DEVICE_HANDLER( ym2203_read_port_r ); WRITE8_DEVICE_HANDLER( ym2203_control_port_w ); WRITE8_DEVICE_HANDLER( ym2203_write_port_w ); -DEVICE_GET_INFO( ym2203 ); -#define SOUND_YM2203 DEVICE_GET_INFO_NAME( ym2203 ) +DECLARE_LEGACY_SOUND_DEVICE(YM2203, ym2203); #endif /* __2203INTF_H__ */ diff --git a/src/emu/sound/2413intf.c b/src/emu/sound/2413intf.c index b09ccbeb584..f13eda13093 100644 --- a/src/emu/sound/2413intf.c +++ b/src/emu/sound/2413intf.c @@ -22,10 +22,8 @@ struct _ym2413_state INLINE ym2413_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2413); - return (ym2413_state *)device->token; + assert(device->type() == SOUND_YM2413); + return (ym2413_state *)downcast(device)->token(); } @@ -58,10 +56,10 @@ static void _stream_update(void *param, int interval) static DEVICE_START( ym2413 ) { ym2413_state *info = get_safe_token(device); - int rate = device->clock/72; + int rate = device->clock()/72; /* emulator create */ - info->chip = ym2413_init(device, device->clock, rate); + info->chip = ym2413_init(device, device->clock(), rate); assert_always(info->chip != NULL, "Error creating YM2413 chip"); /* stream system initialize */ @@ -86,7 +84,7 @@ static DEVICE_START( ym2413 ) { ym2413_reset (i); - ym2413[i].DAC_stream = stream_create(device, 0, 1, device->clock/72, i, YM2413DAC_update); + ym2413[i].DAC_stream = stream_create(device, 0, 1, device->clock()/72, i, YM2413DAC_update); if (ym2413[i].DAC_stream == -1) return 1; diff --git a/src/emu/sound/2413intf.h b/src/emu/sound/2413intf.h index 80154e52042..6ffaa0cc035 100644 --- a/src/emu/sound/2413intf.h +++ b/src/emu/sound/2413intf.h @@ -3,12 +3,13 @@ #ifndef __2413INTF_H__ #define __2413INTF_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( ym2413_w ); WRITE8_DEVICE_HANDLER( ym2413_register_port_w ); WRITE8_DEVICE_HANDLER( ym2413_data_port_w ); -DEVICE_GET_INFO( ym2413 ); -#define SOUND_YM2413 DEVICE_GET_INFO_NAME( ym2413 ) +DECLARE_LEGACY_SOUND_DEVICE(YM2413, ym2413); #endif /* __2413INTF_H__ */ diff --git a/src/emu/sound/2608intf.c b/src/emu/sound/2608intf.c index 2cecf5824a4..c593c1c80f2 100644 --- a/src/emu/sound/2608intf.c +++ b/src/emu/sound/2608intf.c @@ -32,10 +32,8 @@ struct _ym2608_state INLINE ym2608_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2608); - return (ym2608_state *)device->token; + assert(device->type() == SOUND_YM2608); + return (ym2608_state *)downcast(device)->token(); } @@ -140,8 +138,8 @@ static DEVICE_START( ym2608 ) }, NULL }; - const ym2608_interface *intf = device->baseconfig().static_config ? (const ym2608_interface *)device->baseconfig().static_config : &generic_2608; - int rate = device->clock/72; + const ym2608_interface *intf = device->baseconfig().static_config() ? (const ym2608_interface *)device->baseconfig().static_config() : &generic_2608; + int rate = device->clock()/72; void *pcmbufa; int pcmsizea; @@ -151,7 +149,7 @@ static DEVICE_START( ym2608 ) info->device = device; /* FIXME: Force to use simgle output */ - info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, device->clock, &intf->ay8910_intf); + info->psg = ay8910_start_ym(NULL, SOUND_YM2608, device, device->clock(), &intf->ay8910_intf); assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip"); /* Timer Handler set */ @@ -161,11 +159,11 @@ static DEVICE_START( ym2608 ) /* stream system initialize */ info->stream = stream_create(device,0,2,rate,info,ym2608_stream_update); /* setup adpcm buffers */ - pcmbufa = *device->region; - pcmsizea = device->region->bytes(); + pcmbufa = *device->region(); + pcmsizea = device->region()->bytes(); /* initialize YM2608 */ - info->chip = ym2608_init(info,device,device->clock,rate, + info->chip = ym2608_init(info,device,device->clock(),rate, pcmbufa,pcmsizea, timer_handler,IRQHandler,&psgintf); assert_always(info->chip != NULL, "Error creating YM2608 chip"); diff --git a/src/emu/sound/2608intf.h b/src/emu/sound/2608intf.h index 03ffcd372c1..85a8ff5c4f2 100644 --- a/src/emu/sound/2608intf.h +++ b/src/emu/sound/2608intf.h @@ -3,6 +3,8 @@ #ifndef __2608INTF_H__ #define __2608INTF_H__ +#include "devlegcy.h" + #include "fm.h" #include "ay8910.h" @@ -27,7 +29,6 @@ WRITE8_DEVICE_HANDLER( ym2608_control_port_b_w ); WRITE8_DEVICE_HANDLER( ym2608_data_port_a_w ); WRITE8_DEVICE_HANDLER( ym2608_data_port_b_w ); -DEVICE_GET_INFO( ym2608 ); -#define SOUND_YM2608 DEVICE_GET_INFO_NAME( ym2608 ) +DECLARE_LEGACY_SOUND_DEVICE(YM2608, ym2608); #endif /* __2608INTF_H__ */ diff --git a/src/emu/sound/2610intf.c b/src/emu/sound/2610intf.c index 24d03368e60..6dbb4984f28 100644 --- a/src/emu/sound/2610intf.c +++ b/src/emu/sound/2610intf.c @@ -32,10 +32,8 @@ struct _ym2610_state INLINE ym2610_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2610 || sound_get_type(device) == SOUND_YM2610B); - return (ym2610_state *)device->token; + assert(device->type() == SOUND_YM2610 || device->type() == SOUND_YM2610B); + return (ym2610_state *)downcast(device)->token(); } @@ -145,17 +143,17 @@ static DEVICE_START( ym2610 ) AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; - const ym2610_interface *intf = device->baseconfig().static_config ? (const ym2610_interface *)device->baseconfig().static_config : &generic_2610; - int rate = device->clock/72; + const ym2610_interface *intf = device->baseconfig().static_config() ? (const ym2610_interface *)device->baseconfig().static_config() : &generic_2610; + int rate = device->clock()/72; void *pcmbufa,*pcmbufb; int pcmsizea,pcmsizeb; ym2610_state *info = get_safe_token(device); astring name; - sound_type type = sound_get_type(device); + device_type type = device->type(); info->intf = intf; info->device = device; - info->psg = ay8910_start_ym(NULL, sound_get_type(device), device, device->clock, &generic_ay8910); + info->psg = ay8910_start_ym(NULL, device->type(), device, device->clock(), &generic_ay8910); assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip"); /* Timer Handler set */ @@ -165,8 +163,8 @@ static DEVICE_START( ym2610 ) /* stream system initialize */ info->stream = stream_create(device,0,2,rate,info,(type == SOUND_YM2610) ? ym2610_stream_update : ym2610b_stream_update); /* setup adpcm buffers */ - pcmbufa = *device->region; - pcmsizea = device->region->bytes(); + pcmbufa = *device->region(); + pcmsizea = device->region()->bytes(); name.printf("%s.deltat", device->tag()); pcmbufb = (void *)(memory_region(device->machine, name)); pcmsizeb = memory_region_length(device->machine, name); @@ -177,7 +175,7 @@ static DEVICE_START( ym2610 ) } /**** initialize YM2610 ****/ - info->chip = ym2610_init(info,device,device->clock,rate, + info->chip = ym2610_init(info,device,device->clock(),rate, pcmbufa,pcmsizea,pcmbufb,pcmsizeb, timer_handler,IRQHandler,&psgintf); assert_always(info->chip != NULL, "Error creating YM2610 chip"); diff --git a/src/emu/sound/2610intf.h b/src/emu/sound/2610intf.h index 93fab60de42..e38a5f3a29a 100644 --- a/src/emu/sound/2610intf.h +++ b/src/emu/sound/2610intf.h @@ -3,6 +3,7 @@ #ifndef __2610INTF_H__ #define __2610INTF_H__ +#include "devlegcy.h" #include "fm.h" @@ -27,10 +28,7 @@ WRITE8_DEVICE_HANDLER( ym2610_data_port_a_w ); WRITE8_DEVICE_HANDLER( ym2610_data_port_b_w ); -DEVICE_GET_INFO( ym2610 ); -DEVICE_GET_INFO( ym2610b ); - -#define SOUND_YM2610 DEVICE_GET_INFO_NAME( ym2610 ) -#define SOUND_YM2610B DEVICE_GET_INFO_NAME( ym2610b ) +DECLARE_LEGACY_SOUND_DEVICE(YM2610, ym2610); +DECLARE_LEGACY_SOUND_DEVICE(YM2610B, ym2610b); #endif /* __2610INTF_H__ */ diff --git a/src/emu/sound/2612intf.c b/src/emu/sound/2612intf.c index 0bc9b4e9e6f..79a3d2fab2a 100644 --- a/src/emu/sound/2612intf.c +++ b/src/emu/sound/2612intf.c @@ -31,10 +31,8 @@ struct _ym2612_state INLINE ym2612_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM2612 || sound_get_type(device) == SOUND_YM3438); - return (ym2612_state *)device->token; + assert(device->type() == SOUND_YM2612 || device->type() == SOUND_YM3438); + return (ym2612_state *)downcast(device)->token(); } @@ -104,9 +102,9 @@ static DEVICE_START( ym2612 ) { static const ym2612_interface dummy = { 0 }; ym2612_state *info = get_safe_token(device); - int rate = device->clock/72; + int rate = device->clock()/72; - info->intf = device->baseconfig().static_config ? (const ym2612_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const ym2612_interface *)device->baseconfig().static_config() : &dummy; info->device = device; /* FM init */ @@ -118,7 +116,7 @@ static DEVICE_START( ym2612 ) info->stream = stream_create(device,0,2,rate,info,ym2612_stream_update); /**** initialize YM2612 ****/ - info->chip = ym2612_init(info,device,device->clock,rate,timer_handler,IRQHandler); + info->chip = ym2612_init(info,device,device->clock(),rate,timer_handler,IRQHandler); assert_always(info->chip != NULL, "Error creating YM2612 chip"); state_save_register_postload(device->machine, ym2612_intf_postload, info); diff --git a/src/emu/sound/2612intf.h b/src/emu/sound/2612intf.h index 84f09ded98b..1dad5d815d7 100644 --- a/src/emu/sound/2612intf.h +++ b/src/emu/sound/2612intf.h @@ -3,6 +3,8 @@ #ifndef __2612INTF_H__ #define __2612INTF_H__ +#include "devlegcy.h" + void ym2612_update_request(void *param); typedef struct _ym2612_interface ym2612_interface; @@ -25,8 +27,7 @@ WRITE8_DEVICE_HANDLER( ym2612_data_port_a_w ); WRITE8_DEVICE_HANDLER( ym2612_data_port_b_w ); -DEVICE_GET_INFO( ym2612 ); -#define SOUND_YM2612 DEVICE_GET_INFO_NAME( ym2612 ) +DECLARE_LEGACY_SOUND_DEVICE(YM2612, ym2612); typedef struct _ym3438_interface ym3438_interface; @@ -50,7 +51,6 @@ struct _ym3438_interface #define ym3438_data_port_b_w ym2612_data_port_b_w -DEVICE_GET_INFO( ym3438 ); -#define SOUND_YM3438 DEVICE_GET_INFO_NAME( ym3438 ) +DECLARE_LEGACY_SOUND_DEVICE(YM3438, ym3438); #endif /* __2612INTF_H__ */ diff --git a/src/emu/sound/262intf.c b/src/emu/sound/262intf.c index e83ad4899c1..cd0013a3ed1 100644 --- a/src/emu/sound/262intf.c +++ b/src/emu/sound/262intf.c @@ -25,10 +25,8 @@ struct _ymf262_state INLINE ymf262_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YMF262); - return (ymf262_state *)device->token; + assert(device->type() == SOUND_YMF262); + return (ymf262_state *)downcast(device)->token(); } @@ -82,13 +80,13 @@ static DEVICE_START( ymf262 ) { static const ymf262_interface dummy = { 0 }; ymf262_state *info = get_safe_token(device); - int rate = device->clock/288; + int rate = device->clock()/288; - info->intf = device->baseconfig().static_config ? (const ymf262_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const ymf262_interface *)device->baseconfig().static_config() : &dummy; info->device = device; /* stream system initialize */ - info->chip = ymf262_init(device,device->clock,rate); + info->chip = ymf262_init(device,device->clock(),rate); assert_always(info->chip != NULL, "Error creating YMF262 chip"); info->stream = stream_create(device,0,4,rate,info,ymf262_stream_update); diff --git a/src/emu/sound/262intf.h b/src/emu/sound/262intf.h index 8f7d1d99315..d1c83d9f686 100644 --- a/src/emu/sound/262intf.h +++ b/src/emu/sound/262intf.h @@ -3,6 +3,8 @@ #ifndef __262INTF_H__ #define __262INTF_H__ +#include "devlegcy.h" + typedef struct _ymf262_interface ymf262_interface; struct _ymf262_interface @@ -21,7 +23,6 @@ WRITE8_DEVICE_HANDLER( ymf262_data_a_w ); WRITE8_DEVICE_HANDLER( ymf262_data_b_w ); -DEVICE_GET_INFO( ymf262 ); -#define SOUND_YMF262 DEVICE_GET_INFO_NAME( ymf262 ) +DECLARE_LEGACY_SOUND_DEVICE(YMF262, ymf262); #endif /* __262INTF_H__ */ diff --git a/src/emu/sound/3526intf.c b/src/emu/sound/3526intf.c index 7c05d5ff9d4..c0be65abb6e 100644 --- a/src/emu/sound/3526intf.c +++ b/src/emu/sound/3526intf.c @@ -37,10 +37,8 @@ struct _ym3526_state INLINE ym3526_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM3526); - return (ym3526_state *)device->token; + assert(device->type() == SOUND_YM3526); + return (ym3526_state *)downcast(device)->token(); } @@ -93,13 +91,13 @@ static DEVICE_START( ym3526 ) { static const ym3526_interface dummy = { 0 }; ym3526_state *info = get_safe_token(device); - int rate = device->clock/72; + int rate = device->clock()/72; - info->intf = device->baseconfig().static_config ? (const ym3526_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const ym3526_interface *)device->baseconfig().static_config() : &dummy; info->device = device; /* stream system initialize */ - info->chip = ym3526_init(device,device->clock,rate); + info->chip = ym3526_init(device,device->clock(),rate); assert_always(info->chip != NULL, "Error creating YM3526 chip"); info->stream = stream_create(device,0,1,rate,info,ym3526_stream_update); diff --git a/src/emu/sound/3526intf.h b/src/emu/sound/3526intf.h index 550e441c43a..4e6ff61b000 100644 --- a/src/emu/sound/3526intf.h +++ b/src/emu/sound/3526intf.h @@ -3,6 +3,8 @@ #ifndef __3526INTF_H__ #define __3526INTF_H__ +#include "devlegcy.h" + typedef struct _ym3526_interface ym3526_interface; struct _ym3526_interface { @@ -17,7 +19,6 @@ READ8_DEVICE_HANDLER( ym3526_read_port_r ); WRITE8_DEVICE_HANDLER( ym3526_control_port_w ); WRITE8_DEVICE_HANDLER( ym3526_write_port_w ); -DEVICE_GET_INFO( ym3526 ); -#define SOUND_YM3526 DEVICE_GET_INFO_NAME( ym3526 ) +DECLARE_LEGACY_SOUND_DEVICE(YM3526, ym3526); #endif /* __3526INTF_H__ */ diff --git a/src/emu/sound/3812intf.c b/src/emu/sound/3812intf.c index 14333c293bd..a10be06165d 100644 --- a/src/emu/sound/3812intf.c +++ b/src/emu/sound/3812intf.c @@ -37,10 +37,8 @@ struct _ym3812_state INLINE ym3812_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YM3812); - return (ym3812_state *)device->token; + assert(device->type() == SOUND_YM3812); + return (ym3812_state *)downcast(device)->token(); } @@ -93,13 +91,13 @@ static DEVICE_START( ym3812 ) { static const ym3812_interface dummy = { 0 }; ym3812_state *info = get_safe_token(device); - int rate = device->clock/72; + int rate = device->clock()/72; - info->intf = device->baseconfig().static_config ? (const ym3812_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const ym3812_interface *)device->baseconfig().static_config() : &dummy; info->device = device; /* stream system initialize */ - info->chip = ym3812_init(device,device->clock,rate); + info->chip = ym3812_init(device,device->clock(),rate); assert_always(info->chip != NULL, "Error creating YM3812 chip"); info->stream = stream_create(device,0,1,rate,info,ym3812_stream_update); diff --git a/src/emu/sound/3812intf.h b/src/emu/sound/3812intf.h index c68b93bb15e..b75a10c9765 100644 --- a/src/emu/sound/3812intf.h +++ b/src/emu/sound/3812intf.h @@ -3,6 +3,8 @@ #ifndef __3812INTF_H__ #define __3812INTF_H__ +#include "devlegcy.h" + typedef struct _ym3812_interface ym3812_interface; struct _ym3812_interface { @@ -17,7 +19,6 @@ READ8_DEVICE_HANDLER( ym3812_read_port_r ); WRITE8_DEVICE_HANDLER( ym3812_control_port_w ); WRITE8_DEVICE_HANDLER( ym3812_write_port_w ); -DEVICE_GET_INFO( ym3812 ); -#define SOUND_YM3812 DEVICE_GET_INFO_NAME( ym3812 ) +DECLARE_LEGACY_SOUND_DEVICE(YM3812, ym3812); #endif /* __3812INTF_H__ */ diff --git a/src/emu/sound/8950intf.c b/src/emu/sound/8950intf.c index a9f8561b134..92790fb24ab 100644 --- a/src/emu/sound/8950intf.c +++ b/src/emu/sound/8950intf.c @@ -37,10 +37,8 @@ struct _y8950_state INLINE y8950_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_Y8950); - return (y8950_state *)device->token; + assert(device->type() == SOUND_Y8950); + return (y8950_state *)downcast(device)->token(); } @@ -120,17 +118,17 @@ static DEVICE_START( y8950 ) { static const y8950_interface dummy = { 0 }; y8950_state *info = get_safe_token(device); - int rate = device->clock/72; + int rate = device->clock()/72; - info->intf = device->baseconfig().static_config ? (const y8950_interface *)device->baseconfig().static_config : &dummy; + info->intf = device->baseconfig().static_config() ? (const y8950_interface *)device->baseconfig().static_config() : &dummy; info->device = device; /* stream system initialize */ - info->chip = y8950_init(device,device->clock,rate); + info->chip = y8950_init(device,device->clock(),rate); assert_always(info->chip != NULL, "Error creating Y8950 chip"); /* ADPCM ROM data */ - y8950_set_delta_t_memory(info->chip, *device->region, device->region->bytes()); + y8950_set_delta_t_memory(info->chip, *device->region(), device->region()->bytes()); info->stream = stream_create(device,0,1,rate,info,y8950_stream_update); diff --git a/src/emu/sound/8950intf.h b/src/emu/sound/8950intf.h index a838cf05103..4487ea8a6f6 100644 --- a/src/emu/sound/8950intf.h +++ b/src/emu/sound/8950intf.h @@ -3,6 +3,8 @@ #ifndef __8950INTF_H__ #define __8950INTF_H__ +#include "devlegcy.h" + typedef struct _y8950_interface y8950_interface; struct _y8950_interface { @@ -22,7 +24,6 @@ READ8_DEVICE_HANDLER( y8950_read_port_r ); WRITE8_DEVICE_HANDLER( y8950_control_port_w ); WRITE8_DEVICE_HANDLER( y8950_write_port_w ); -DEVICE_GET_INFO( y8950 ); -#define SOUND_Y8950 DEVICE_GET_INFO_NAME( y8950 ) +DECLARE_LEGACY_SOUND_DEVICE(Y8950, y8950); #endif /* __8950INTF_H__ */ diff --git a/src/emu/sound/aica.c b/src/emu/sound/aica.c index d68d76de816..bab1fe77800 100644 --- a/src/emu/sound/aica.c +++ b/src/emu/sound/aica.c @@ -213,10 +213,8 @@ static signed short *RBUFDST; //this points to where the sample will be stored i INLINE aica_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_AICA); - return (aica_state *)device->token; + assert(device->type() == SOUND_AICA); + return (aica_state *)downcast(device)->token(); } static unsigned char DecodeSCI(aica_state *AICA, unsigned char irq) @@ -508,11 +506,11 @@ static void AICA_Init(running_device *device, aica_state *AICA, const aica_inter { AICA->Master = intf->master; - AICA->AICARAM = *device->region; + AICA->AICARAM = *device->region(); if (AICA->AICARAM) { AICA->AICARAM += intf->roffset; - AICA->AICARAM_LENGTH = device->region->bytes(); + AICA->AICARAM_LENGTH = device->region()->bytes(); AICA->RAM_MASK = AICA->AICARAM_LENGTH-1; AICA->RAM_MASK16 = AICA->RAM_MASK & 0x7ffffe; AICA->DSP.AICARAM = (UINT16 *)AICA->AICARAM; @@ -1248,7 +1246,7 @@ static DEVICE_START( aica ) aica_state *AICA = get_safe_token(device); - intf = (const aica_interface *)device->baseconfig().static_config; + intf = (const aica_interface *)device->baseconfig().static_config(); // init the emulation AICA_Init(device, AICA, intf); diff --git a/src/emu/sound/aica.h b/src/emu/sound/aica.h index 7050426ba7c..e1e575c7a1e 100644 --- a/src/emu/sound/aica.h +++ b/src/emu/sound/aica.h @@ -6,6 +6,8 @@ #ifndef __AICA_H__ #define __AICA_H__ +#include "devlegcy.h" + typedef struct _aica_interface aica_interface; struct _aica_interface { @@ -24,7 +26,6 @@ WRITE16_DEVICE_HANDLER( aica_w ); WRITE16_DEVICE_HANDLER( aica_midi_in ); READ16_DEVICE_HANDLER( aica_midi_out_r ); -DEVICE_GET_INFO( aica ); -#define SOUND_AICA DEVICE_GET_INFO_NAME( aica ) +DECLARE_LEGACY_SOUND_DEVICE(AICA, aica); #endif /* __AICA_H__ */ diff --git a/src/emu/sound/astrocde.c b/src/emu/sound/astrocde.c index c50fd362baf..527350c27e3 100644 --- a/src/emu/sound/astrocde.c +++ b/src/emu/sound/astrocde.c @@ -73,10 +73,8 @@ struct _astrocade_state INLINE astrocade_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ASTROCADE); - return (astrocade_state *)device->token; + assert(device->type() == SOUND_ASTROCADE); + return (astrocade_state *)downcast(device)->token(); } @@ -274,7 +272,7 @@ static DEVICE_START( astrocade ) chip->bitswap[i] = BITSWAP8(i, 0,1,2,3,4,5,6,7); /* allocate a stream for output */ - chip->stream = stream_create(device, 0, 1, device->clock, chip, astrocade_update); + chip->stream = stream_create(device, 0, 1, device->clock(), chip, astrocade_update); /* reset state */ DEVICE_RESET_CALL(astrocade); diff --git a/src/emu/sound/astrocde.h b/src/emu/sound/astrocde.h index 555c549f2ba..afcf03d18e1 100644 --- a/src/emu/sound/astrocde.h +++ b/src/emu/sound/astrocde.h @@ -3,9 +3,10 @@ #ifndef __ASTROCDE_H__ #define __ASTROCDE_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( astrocade_sound_w ); -DEVICE_GET_INFO( astrocade ); -#define SOUND_ASTROCADE DEVICE_GET_INFO_NAME( astrocade ) +DECLARE_LEGACY_SOUND_DEVICE(ASTROCADE, astrocade); #endif /* __ASTROCDE_H__ */ diff --git a/src/emu/sound/ay8910.c b/src/emu/sound/ay8910.c index d8984378c71..78a6f1c9235 100644 --- a/src/emu/sound/ay8910.c +++ b/src/emu/sound/ay8910.c @@ -200,17 +200,15 @@ struct _ay8910_context INLINE ay8910_context *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_AY8910 || - sound_get_type(device) == SOUND_AY8912 || - sound_get_type(device) == SOUND_AY8913 || - sound_get_type(device) == SOUND_AY8930 || - sound_get_type(device) == SOUND_YM2149 || - sound_get_type(device) == SOUND_YM3439 || - sound_get_type(device) == SOUND_YMZ284 || - sound_get_type(device) == SOUND_YMZ294); - return (ay8910_context *)device->token; + assert(device->type() == SOUND_AY8910 || + device->type() == SOUND_AY8912 || + device->type() == SOUND_AY8913 || + device->type() == SOUND_AY8930 || + device->type() == SOUND_YM2149 || + device->type() == SOUND_YM3439 || + device->type() == SOUND_YMZ284 || + device->type() == SOUND_YMZ294); + return (ay8910_context *)downcast(device)->token(); } @@ -736,7 +734,7 @@ static void ay8910_statesave(ay8910_context *psg, running_device *device) * *************************************/ -void *ay8910_start_ym(void *infoptr, sound_type chip_type, running_device *device, int clock, const ay8910_interface *intf) +void *ay8910_start_ym(void *infoptr, device_type chip_type, running_device *device, int clock, const ay8910_interface *intf) { ay8910_context *info = (ay8910_context *)infoptr; @@ -778,9 +776,9 @@ void *ay8910_start_ym(void *infoptr, sound_type chip_type, running_device *devic /* The envelope is pacing twice as fast for the YM2149 as for the AY-3-8910, */ /* This handled by the step parameter. Consequently we use a divider of 8 here. */ - info->channel = stream_create(device, 0, info->streams, device->clock / 8, info, ay8910_update); + info->channel = stream_create(device, 0, info->streams, device->clock() / 8, info, ay8910_update); - ay8910_set_clock_ym(info,device->clock); + ay8910_set_clock_ym(info,device->clock()); ay8910_statesave(info, device); return info; @@ -917,8 +915,8 @@ static DEVICE_START( ay8910 ) AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; - const ay8910_interface *intf = (device->baseconfig().static_config ? (const ay8910_interface *)device->baseconfig().static_config : &generic_ay8910); - ay8910_start_ym(get_safe_token(device), SOUND_AY8910, device, device->clock, intf); + const ay8910_interface *intf = (device->baseconfig().static_config() ? (const ay8910_interface *)device->baseconfig().static_config() : &generic_ay8910); + ay8910_start_ym(get_safe_token(device), SOUND_AY8910, device, device->clock(), intf); } static DEVICE_START( ym2149 ) @@ -929,8 +927,8 @@ static DEVICE_START( ym2149 ) AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL }; - const ay8910_interface *intf = (device->baseconfig().static_config ? (const ay8910_interface *)device->baseconfig().static_config : &generic_ay8910); - ay8910_start_ym(get_safe_token(device), SOUND_YM2149, device, device->clock, intf); + const ay8910_interface *intf = (device->baseconfig().static_config() ? (const ay8910_interface *)device->baseconfig().static_config() : &generic_ay8910); + ay8910_start_ym(get_safe_token(device), SOUND_YM2149, device, device->clock(), intf); } static DEVICE_STOP( ay8910 ) diff --git a/src/emu/sound/ay8910.h b/src/emu/sound/ay8910.h index cb805219836..b89bbe1df4b 100644 --- a/src/emu/sound/ay8910.h +++ b/src/emu/sound/ay8910.h @@ -3,6 +3,8 @@ #ifndef __AY8910_H__ #define __AY8910_H__ +#include "devlegcy.h" + /* AY-3-8910A: 2 I/O ports AY-3-8912A: 1 I/O port @@ -88,7 +90,7 @@ WRITE8_DEVICE_HANDLER( ay8910_address_data_w ); /*********** An interface for SSG of YM2203 ***********/ -void *ay8910_start_ym(void *infoptr, sound_type chip_type, running_device *device, int clock, const ay8910_interface *intf); +void *ay8910_start_ym(void *infoptr, device_type chip_type, running_device *device, int clock, const ay8910_interface *intf); void ay8910_stop_ym(void *chip); void ay8910_reset_ym(void *chip); @@ -96,22 +98,13 @@ void ay8910_set_clock_ym(void *chip, int clock); void ay8910_write_ym(void *chip, int addr, int data); int ay8910_read_ym(void *chip); -DEVICE_GET_INFO( ay8910 ); -DEVICE_GET_INFO( ay8912 ); -DEVICE_GET_INFO( ay8913 ); -DEVICE_GET_INFO( ay8930 ); -DEVICE_GET_INFO( ym2149 ); -DEVICE_GET_INFO( ym3439 ); -DEVICE_GET_INFO( ymz284 ); -DEVICE_GET_INFO( ymz294 ); - -#define SOUND_AY8910 DEVICE_GET_INFO_NAME( ay8910 ) -#define SOUND_AY8912 DEVICE_GET_INFO_NAME( ay8912 ) -#define SOUND_AY8913 DEVICE_GET_INFO_NAME( ay8913 ) -#define SOUND_AY8930 DEVICE_GET_INFO_NAME( ay8930 ) -#define SOUND_YM2149 DEVICE_GET_INFO_NAME( ym2149 ) -#define SOUND_YM3439 DEVICE_GET_INFO_NAME( ym3439 ) -#define SOUND_YMZ284 DEVICE_GET_INFO_NAME( ymz284 ) -#define SOUND_YMZ294 DEVICE_GET_INFO_NAME( ymz294 ) +DECLARE_LEGACY_SOUND_DEVICE(AY8910, ay8910); +DECLARE_LEGACY_SOUND_DEVICE(AY8912, ay8912); +DECLARE_LEGACY_SOUND_DEVICE(AY8913, ay8913); +DECLARE_LEGACY_SOUND_DEVICE(AY8930, ay8930); +DECLARE_LEGACY_SOUND_DEVICE(YM2149, ym2149); +DECLARE_LEGACY_SOUND_DEVICE(YM3439, ym3439); +DECLARE_LEGACY_SOUND_DEVICE(YMZ284, ymz284); +DECLARE_LEGACY_SOUND_DEVICE(YMZ294, ymz294); #endif /* __AY8910_H__ */ diff --git a/src/emu/sound/beep.c b/src/emu/sound/beep.c index 6e9c8e67962..c4df30a1889 100644 --- a/src/emu/sound/beep.c +++ b/src/emu/sound/beep.c @@ -32,10 +32,8 @@ struct _beep_state INLINE beep_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_BEEP); - return (beep_state *)device->token; + assert(device->type() == SOUND_BEEP); + return (beep_state *)downcast(device)->token(); } diff --git a/src/emu/sound/beep.h b/src/emu/sound/beep.h index b2e6bcd6399..bc9f11a7b3b 100644 --- a/src/emu/sound/beep.h +++ b/src/emu/sound/beep.h @@ -3,11 +3,12 @@ #ifndef __BEEP_H__ #define __BEEP_H__ +#include "devlegcy.h" + void beep_set_state(running_device *device, int on); void beep_set_frequency(running_device *device, int frequency); void beep_set_volume(running_device *device, int volume); -DEVICE_GET_INFO( beep ); -#define SOUND_BEEP DEVICE_GET_INFO_NAME( beep ) +DECLARE_LEGACY_SOUND_DEVICE(BEEP, beep); #endif /* __BEEP_H__ */ diff --git a/src/emu/sound/bsmt2000.c b/src/emu/sound/bsmt2000.c index d7791c91cba..d9255cb1f7f 100644 --- a/src/emu/sound/bsmt2000.c +++ b/src/emu/sound/bsmt2000.c @@ -98,10 +98,8 @@ static void set_regmap(bsmt2000_chip *chip, UINT8 posbase, UINT8 ratebase, UINT8 INLINE bsmt2000_chip *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_BSMT2000); - return (bsmt2000_chip *)device->token; + assert(device->type() == SOUND_BSMT2000); + return (bsmt2000_chip *)downcast(device)->token(); } @@ -120,12 +118,12 @@ static DEVICE_START( bsmt2000 ) int voicenum; /* create a stream at a nominal sample rate (real one specified later) */ - chip->stream = stream_create(device, 0, 2, device->clock / 1000, chip, bsmt2000_update); - chip->clock = device->clock; + chip->stream = stream_create(device, 0, 2, device->clock() / 1000, chip, bsmt2000_update); + chip->clock = device->clock(); /* initialize the regions */ - chip->region_base = *device->region; - chip->total_banks = device->region->bytes() / 0x10000; + chip->region_base = *device->region(); + chip->total_banks = device->region()->bytes() / 0x10000; /* register chip-wide data for save states */ state_save_register_device_item(device, 0, chip->last_register); diff --git a/src/emu/sound/bsmt2000.h b/src/emu/sound/bsmt2000.h index 02f7a9418fe..acd37756687 100644 --- a/src/emu/sound/bsmt2000.h +++ b/src/emu/sound/bsmt2000.h @@ -10,9 +10,10 @@ #ifndef __BSMT2000_H__ #define __BSMT2000_H__ +#include "devlegcy.h" + WRITE16_DEVICE_HANDLER( bsmt2000_data_w ); -DEVICE_GET_INFO( bsmt2000 ); -#define SOUND_BSMT2000 DEVICE_GET_INFO_NAME( bsmt2000 ) +DECLARE_LEGACY_SOUND_DEVICE(BSMT2000, bsmt2000); #endif /* __BSMT2000_H__ */ diff --git a/src/emu/sound/c140.c b/src/emu/sound/c140.c index cb632cb096d..7ede0d62d15 100644 --- a/src/emu/sound/c140.c +++ b/src/emu/sound/c140.c @@ -109,10 +109,8 @@ struct _c140_state INLINE c140_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_C140); - return (c140_state *)device->token; + assert(device->type() == SOUND_C140); + return (c140_state *)downcast(device)->token(); } @@ -466,16 +464,16 @@ static STREAM_UPDATE( update_stereo ) static DEVICE_START( c140 ) { - const c140_interface *intf = (const c140_interface *)device->baseconfig().static_config; + const c140_interface *intf = (const c140_interface *)device->baseconfig().static_config(); c140_state *info = get_safe_token(device); - info->sample_rate=info->baserate=device->clock; + info->sample_rate=info->baserate=device->clock(); info->banking_type = intf->banking_type; info->stream = stream_create(device,0,2,info->sample_rate,info,update_stereo); - info->pRom=*device->region; + info->pRom=*device->region(); /* make decompress pcm table */ //2000.06.26 CAB { diff --git a/src/emu/sound/c140.h b/src/emu/sound/c140.h index 2c1cef40316..b09acf1b4c0 100644 --- a/src/emu/sound/c140.h +++ b/src/emu/sound/c140.h @@ -5,6 +5,8 @@ #ifndef __C140_H__ #define __C140_H__ +#include "devlegcy.h" + READ8_DEVICE_HANDLER( c140_r ); WRITE8_DEVICE_HANDLER( c140_w ); @@ -23,7 +25,6 @@ struct _c140_interface { int banking_type; }; -DEVICE_GET_INFO( c140 ); -#define SOUND_C140 DEVICE_GET_INFO_NAME( c140 ) +DECLARE_LEGACY_SOUND_DEVICE(C140, c140); #endif /* __C140_H__ */ diff --git a/src/emu/sound/c352.c b/src/emu/sound/c352.c index 30582389b00..44e6c42dbcc 100644 --- a/src/emu/sound/c352.c +++ b/src/emu/sound/c352.c @@ -85,10 +85,8 @@ struct _c352_state INLINE c352_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_C352); - return (c352_state *)device->token; + assert(device->type() == SOUND_C352); + return (c352_state *)downcast(device)->token(); } // noise generator @@ -543,10 +541,10 @@ static DEVICE_START( c352 ) { c352_state *info = get_safe_token(device); - info->c352_rom_samples = *device->region; - info->c352_rom_length = device->region->bytes(); + info->c352_rom_samples = *device->region(); + info->c352_rom_length = device->region()->bytes(); - info->sample_rate_base = device->clock / 192; + info->sample_rate_base = device->clock() / 192; info->stream = stream_create(device, 0, 4, info->sample_rate_base, info, c352_update); diff --git a/src/emu/sound/c352.h b/src/emu/sound/c352.h index 6d3b970821a..17987ff5f78 100644 --- a/src/emu/sound/c352.h +++ b/src/emu/sound/c352.h @@ -3,11 +3,12 @@ #ifndef __C352_H__ #define __C352_H__ +#include "devlegcy.h" + READ16_DEVICE_HANDLER( c352_r ); WRITE16_DEVICE_HANDLER( c352_w ); -DEVICE_GET_INFO( c352 ); -#define SOUND_C352 DEVICE_GET_INFO_NAME( c352 ) +DECLARE_LEGACY_SOUND_DEVICE(C352, c352); #endif /* __C352_H__ */ diff --git a/src/emu/sound/c6280.c b/src/emu/sound/c6280.c index 7537ac3aaaf..1898cca7bd8 100644 --- a/src/emu/sound/c6280.c +++ b/src/emu/sound/c6280.c @@ -86,10 +86,8 @@ typedef struct { INLINE c6280_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_C6280); - return (c6280_t *)device->token; + assert(device->type() == SOUND_C6280); + return (c6280_t *)downcast(device)->token(); } @@ -99,7 +97,7 @@ INLINE c6280_t *get_safe_token(running_device *device) static void c6280_init(running_device *device, c6280_t *p, double clk, double rate) { - const c6280_interface *intf = (const c6280_interface *)device->baseconfig().static_config; + const c6280_interface *intf = (const c6280_interface *)device->baseconfig().static_config(); int i; double step; @@ -324,11 +322,11 @@ static STREAM_UPDATE( c6280_update ) static DEVICE_START( c6280 ) { - int rate = device->clock/16; + int rate = device->clock()/16; c6280_t *info = get_safe_token(device); /* Initialize PSG emulator */ - c6280_init(device, info, device->clock, rate); + c6280_init(device, info, device->clock(), rate); /* Create stereo stream */ info->stream = stream_create(device, 0, 2, rate, info, c6280_update); diff --git a/src/emu/sound/c6280.h b/src/emu/sound/c6280.h index c04fb7f3322..fe61983268c 100644 --- a/src/emu/sound/c6280.h +++ b/src/emu/sound/c6280.h @@ -3,6 +3,8 @@ #ifndef __C6280_H__ #define __C6280_H__ +#include "devlegcy.h" + typedef struct _c6280_interface c6280_interface; struct _c6280_interface { @@ -13,7 +15,6 @@ struct _c6280_interface WRITE8_DEVICE_HANDLER( c6280_w ); READ8_DEVICE_HANDLER( c6280_r ); -DEVICE_GET_INFO( c6280 ); -#define SOUND_C6280 DEVICE_GET_INFO_NAME( c6280 ) +DECLARE_LEGACY_SOUND_DEVICE(C6280, c6280); #endif /* __C6280_H__ */ diff --git a/src/emu/sound/cdda.c b/src/emu/sound/cdda.c index 533a9b130af..a0b2eb353af 100644 --- a/src/emu/sound/cdda.c +++ b/src/emu/sound/cdda.c @@ -25,10 +25,8 @@ struct _cdda_info INLINE cdda_info *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_CDDA); - return (cdda_info *)device->token; + assert(device->type() == SOUND_CDDA); + return (cdda_info *)downcast(device)->token(); } #define MAX_SECTORS ( 4 ) @@ -59,7 +57,7 @@ static DEVICE_START( cdda ) /* allocate an audio cache */ info->audio_cache = auto_alloc_array( device->machine, UINT8, CD_MAX_SECTOR_DATA * MAX_SECTORS ); - //intf = (const struct CDDAinterface *)device->baseconfig().static_config; + //intf = (const struct CDDAinterface *)device->baseconfig().static_config(); info->stream = stream_create(device, 0, 2, 44100, info, cdda_update); @@ -93,14 +91,14 @@ void cdda_set_cdrom(running_device *device, void *file) running_device *cdda_from_cdrom(running_machine *machine, void *file) { - running_device *device; + device_sound_interface *sound; - for (device = sound_first(machine); device != NULL; device = sound_next(device)) - if (sound_get_type(device) == SOUND_CDDA) + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->device().type() == SOUND_CDDA) { - cdda_info *info = get_safe_token(device); + cdda_info *info = get_safe_token(*sound); if (info->disc == file) - return device; + return *sound; } return NULL; diff --git a/src/emu/sound/cdda.h b/src/emu/sound/cdda.h index 951cbda4068..157a54609a3 100644 --- a/src/emu/sound/cdda.h +++ b/src/emu/sound/cdda.h @@ -1,7 +1,9 @@ #pragma once #ifndef __CDDA_H__ -#define _CDDA_H_ +#define __CDDA_H__ + +#include "devlegcy.h" void cdda_set_cdrom(running_device *device, void *file); running_device *cdda_from_cdrom(running_machine *machine, void *file); @@ -15,7 +17,6 @@ int cdda_audio_active(running_device *device); int cdda_audio_paused(running_device *device); int cdda_audio_ended(running_device *device); -DEVICE_GET_INFO( cdda ); -#define SOUND_CDDA DEVICE_GET_INFO_NAME( cdda ) +DECLARE_LEGACY_SOUND_DEVICE(CDDA, cdda); #endif /* __CDDA_H__ */ diff --git a/src/emu/sound/cdp1863.c b/src/emu/sound/cdp1863.c index 6b5830ffd98..fb438e70141 100644 --- a/src/emu/sound/cdp1863.c +++ b/src/emu/sound/cdp1863.c @@ -52,14 +52,13 @@ struct _cdp1863_t INLINE cdp1863_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - return (cdp1863_t *)device->token; + return (cdp1863_t *)downcast(device)->token(); } INLINE cdp1863_config *get_safe_config(running_device *device) { assert(device != NULL); - return (cdp1863_config *)device->baseconfig().inline_config; + return (cdp1863_config *)downcast(device->baseconfig()).inline_config(); } /*************************************************************************** @@ -179,7 +178,7 @@ static DEVICE_START( cdp1863 ) /* set initial values */ cdp1863->stream = stream_create(device, 0, 1, device->machine->sample_rate, cdp1863, cdp1863_stream_update); - cdp1863->clock1 = device->clock; + cdp1863->clock1 = device->clock(); cdp1863->clock2 = config->clock2; cdp1863->oe = 1; diff --git a/src/emu/sound/cdp1863.h b/src/emu/sound/cdp1863.h index 042e6db0111..0c291cb75ab 100644 --- a/src/emu/sound/cdp1863.h +++ b/src/emu/sound/cdp1863.h @@ -21,16 +21,16 @@ #ifndef __CDP1863__ #define __CDP1863__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -#define CDP1863 DEVICE_GET_INFO_NAME(cdp1863) -#define SOUND_CDP1863 CDP1863 +DECLARE_LEGACY_SOUND_DEVICE(CDP1863, cdp1863); #define MDRV_CDP1863_ADD(_tag, _clock1, _clock2) \ MDRV_DEVICE_ADD(_tag, SOUND, _clock1) \ - MDRV_DEVICE_CONFIG_DATAPTR(cdp1863_config, type, SOUND_CDP1863) \ MDRV_DEVICE_CONFIG_DATA32(cdp1863_config, clock2, _clock2) #define CDP1863_INTERFACE(name) \ @@ -43,8 +43,6 @@ typedef struct _cdp1863_config cdp1863_config; struct _cdp1863_config { - const sound_config *type; - int clock2; /* the clock 2 (pin 2) of the chip */ }; @@ -52,9 +50,6 @@ struct _cdp1863_config PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( cdp1863 ); - /* load tone latch */ WRITE8_DEVICE_HANDLER( cdp1863_str_w ); diff --git a/src/emu/sound/cdp1864.c b/src/emu/sound/cdp1864.c index 0fc6c53f282..6326020d202 100644 --- a/src/emu/sound/cdp1864.c +++ b/src/emu/sound/cdp1864.c @@ -53,7 +53,7 @@ struct _cdp1864_t devcb_resolved_write_line out_dmao_func; devcb_resolved_write_line out_efx_func; - running_device *screen; /* screen */ + screen_device *screen; /* screen */ bitmap_t *bitmap; /* bitmap */ sound_stream *stream; /* sound output */ @@ -84,8 +84,7 @@ struct _cdp1864_t INLINE cdp1864_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - return (cdp1864_t *)device->token; + return (cdp1864_t *)downcast(device)->token(); } /*************************************************************************** @@ -101,7 +100,7 @@ static TIMER_CALLBACK( cdp1864_int_tick ) running_device *device = (running_device *) ptr; cdp1864_t *cdp1864 = get_safe_token(device); - int scanline = video_screen_get_vpos(cdp1864->screen); + int scanline = cdp1864->screen->vpos(); if (scanline == CDP1864_SCANLINE_INT_START) { @@ -110,7 +109,7 @@ static TIMER_CALLBACK( cdp1864_int_tick ) devcb_call_write_line(&cdp1864->out_int_func, ASSERT_LINE); } - timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_END, 0), 0); + timer_adjust_oneshot(cdp1864->int_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_END), 0); } else { @@ -119,7 +118,7 @@ static TIMER_CALLBACK( cdp1864_int_tick ) devcb_call_write_line(&cdp1864->out_int_func, CLEAR_LINE); } - timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0); + timer_adjust_oneshot(cdp1864->int_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_START), 0); } } @@ -132,28 +131,28 @@ static TIMER_CALLBACK( cdp1864_efx_tick ) running_device *device = (running_device *) ptr; cdp1864_t *cdp1864 = get_safe_token(device); - int scanline = video_screen_get_vpos(cdp1864->screen); + int scanline = cdp1864->screen->vpos(); switch (scanline) { case CDP1864_SCANLINE_EFX_TOP_START: devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE); - timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_END, 0), 0); + timer_adjust_oneshot(cdp1864->efx_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_END), 0); break; case CDP1864_SCANLINE_EFX_TOP_END: devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE); - timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0); + timer_adjust_oneshot(cdp1864->efx_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_START), 0); break; case CDP1864_SCANLINE_EFX_BOTTOM_START: devcb_call_write_line(&cdp1864->out_efx_func, ASSERT_LINE); - timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0); + timer_adjust_oneshot(cdp1864->efx_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_BOTTOM_END), 0); break; case CDP1864_SCANLINE_EFX_BOTTOM_END: devcb_call_write_line(&cdp1864->out_efx_func, CLEAR_LINE); - timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); + timer_adjust_oneshot(cdp1864->efx_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START), 0); break; } } @@ -167,7 +166,7 @@ static TIMER_CALLBACK( cdp1864_dma_tick ) running_device *device = (running_device *) ptr; cdp1864_t *cdp1864 = get_safe_token(device); - int scanline = video_screen_get_vpos(cdp1864->screen); + int scanline = cdp1864->screen->vpos(); if (cdp1864->dmaout) { @@ -325,8 +324,8 @@ WRITE8_DEVICE_HANDLER( cdp1864_dma_w ) cdp1864_t *cdp1864 = get_safe_token(device); int rdata = 1, bdata = 1, gdata = 1; - int sx = video_screen_get_hpos(cdp1864->screen) + 4; - int y = video_screen_get_vpos(cdp1864->screen); + int sx = cdp1864->screen->hpos() + 4; + int y = cdp1864->screen->vpos(); int x; if (!cdp1864->con) @@ -424,7 +423,7 @@ void cdp1864_update(running_device *device, bitmap_t *bitmap, const rectangle *c static DEVICE_START( cdp1864 ) { cdp1864_t *cdp1864 = get_safe_token(device); - const cdp1864_interface *intf = (const cdp1864_interface *) device->baseconfig().static_config; + const cdp1864_interface *intf = (const cdp1864_interface *) device->baseconfig().static_config(); /* resolve callbacks */ devcb_resolve_read_line(&cdp1864->in_rdata_func, &intf->in_rdata_func, device); @@ -438,11 +437,11 @@ static DEVICE_START( cdp1864 ) cdp1864->cpu = device->machine->device(intf->cpu_tag); /* get the screen device */ - cdp1864->screen = device->machine->device(intf->screen_tag); + cdp1864->screen = downcast(device->machine->device(intf->screen_tag)); assert(cdp1864->screen != NULL); /* allocate the temporary bitmap */ - cdp1864->bitmap = auto_bitmap_alloc(device->machine, video_screen_get_width(cdp1864->screen), video_screen_get_height(cdp1864->screen), video_screen_get_format(cdp1864->screen)); + cdp1864->bitmap = auto_bitmap_alloc(device->machine, cdp1864->screen->width(), cdp1864->screen->height(), cdp1864->screen->format()); bitmap_fill(cdp1864->bitmap, 0, CDP1864_BACKGROUND_COLOR_SEQUENCE[cdp1864->bgcolor] + 8); /* initialize the palette */ @@ -478,8 +477,8 @@ static DEVICE_RESET( cdp1864 ) { cdp1864_t *cdp1864 = get_safe_token(device); - timer_adjust_oneshot(cdp1864->int_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_INT_START, 0), 0); - timer_adjust_oneshot(cdp1864->efx_timer, video_screen_get_time_until_pos(cdp1864->screen, CDP1864_SCANLINE_EFX_TOP_START, 0), 0); + timer_adjust_oneshot(cdp1864->int_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_INT_START), 0); + timer_adjust_oneshot(cdp1864->efx_timer, cdp1864->screen->time_until_pos(CDP1864_SCANLINE_EFX_TOP_START), 0); timer_adjust_oneshot(cdp1864->dma_timer, cpu_clocks_to_attotime(device->machine->firstcpu, CDP1864_CYCLES_DMA_START), 0); cdp1864->disp = 0; @@ -505,7 +504,6 @@ DEVICE_GET_INFO( cdp1864 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(cdp1864_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(cdp1864); break; diff --git a/src/emu/sound/cdp1864.h b/src/emu/sound/cdp1864.h index 7e3dbcbe8d6..eecab81c458 100644 --- a/src/emu/sound/cdp1864.h +++ b/src/emu/sound/cdp1864.h @@ -36,6 +36,8 @@ #ifndef __CDP1864__ #define __CDP1864__ +#include "devlegcy.h" + /*************************************************************************** PARAMETERS @@ -73,8 +75,7 @@ MACROS / CONSTANTS ***************************************************************************/ -#define CDP1864 DEVICE_GET_INFO_NAME(cdp1864) -#define SOUND_CDP1864 CDP1864 +DECLARE_LEGACY_SOUND_DEVICE(CDP1864, cdp1864); #define MDRV_CDP1864_ADD(_tag, _clock, _config) \ MDRV_DEVICE_ADD(_tag, SOUND, _clock) \ @@ -130,9 +131,6 @@ struct _cdp1864_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( cdp1864 ); - /* display on (0x69) */ READ8_DEVICE_HANDLER( cdp1864_dispon_r ) ATTR_NONNULL(1); diff --git a/src/emu/sound/cdp1869.c b/src/emu/sound/cdp1869.c index f8bef3d70ef..fca2cabcc6b 100644 --- a/src/emu/sound/cdp1869.c +++ b/src/emu/sound/cdp1869.c @@ -55,7 +55,7 @@ struct _cdp1869_t running_device *device; const cdp1869_interface *intf; /* interface */ - running_device *screen; /* screen */ + screen_device *screen; /* screen */ running_device *cpu; /* CPU */ sound_stream *stream; /* sound output */ int color_clock; @@ -97,8 +97,7 @@ struct _cdp1869_t INLINE cdp1869_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - return (cdp1869_t *)device->token; + return (cdp1869_t *)downcast(device)->token(); } /*************************************************************************** @@ -119,7 +118,7 @@ static void update_prd_changed_timer(cdp1869_t *cdp1869) { attotime duration; int start, end, level; - int scanline = video_screen_get_vpos(cdp1869->screen); + int scanline = cdp1869->screen->vpos(); int next_scanline; if (CDP1869_IS_NTSC) @@ -154,7 +153,7 @@ static void update_prd_changed_timer(cdp1869_t *cdp1869) level = 1; } - duration = video_screen_get_time_until_pos(cdp1869->screen, next_scanline, 0); + duration = cdp1869->screen->time_until_pos(next_scanline); timer_adjust_oneshot(cdp1869->prd_changed_timer, duration, level); } } @@ -805,7 +804,7 @@ static STREAM_UPDATE( cdp1869_stream_update ) if (!cdp1869->toneoff && cdp1869->toneamp) { - double frequency = (cdp1869->device->clock / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1); + double frequency = (cdp1869->device->clock() / 2) / (512 >> cdp1869->tonefreq) / (cdp1869->tonediv + 1); // double amplitude = cdp1869->toneamp * ((0.78*5) / 15); int rate = cdp1869->device->machine->sample_rate / 2; @@ -861,7 +860,7 @@ static DEVICE_START( cdp1869 ) cdp1869_t *cdp1869 = get_safe_token(device); /* validate arguments */ - cdp1869->intf = (const cdp1869_interface *)device->baseconfig().static_config; + cdp1869->intf = (const cdp1869_interface *)device->baseconfig().static_config(); assert(cdp1869->intf->pcb_r != NULL); assert(cdp1869->intf->char_ram_r != NULL); @@ -881,7 +880,7 @@ static DEVICE_START( cdp1869 ) cdp1869->wnoff = 1; /* get the screen device */ - cdp1869->screen = device->machine->device(cdp1869->intf->screen_tag); + cdp1869->screen = downcast(device->machine->device(cdp1869->intf->screen_tag)); assert(cdp1869->screen != NULL); /* get the CPU device */ diff --git a/src/emu/sound/cdp1869.h b/src/emu/sound/cdp1869.h index 2a39f4a217f..9fcb86dd7bd 100644 --- a/src/emu/sound/cdp1869.h +++ b/src/emu/sound/cdp1869.h @@ -34,6 +34,8 @@ #ifndef __CDP1869__ #define __CDP1869__ +#include "devlegcy.h" + /*************************************************************************** MACROS / CONSTANTS @@ -83,12 +85,10 @@ #define CDP1869_PALETTE_LENGTH 8+64 -#define CDP1869 DEVICE_GET_INFO_NAME(cdp1869) -#define SOUND_CDP1869 CDP1869 +DECLARE_LEGACY_SOUND_DEVICE(CDP1869, cdp1869); #define MDRV_CDP1869_ADD(_tag, _pixclock, _config) \ - MDRV_DEVICE_ADD(_tag, SOUND, _pixclock) \ - MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_CDP1869) \ + MDRV_DEVICE_ADD(_tag, SOUND_CDP1869, _pixclock) \ MDRV_DEVICE_CONFIG(_config) #define MDRV_CDP1869_SCREEN_PAL_ADD(_tag, _clock) \ @@ -162,9 +162,6 @@ struct _cdp1869_interface PROTOTYPES ***************************************************************************/ -/* device interface */ -DEVICE_GET_INFO( cdp1869 ); - /* palette initialization */ PALETTE_INIT( cdp1869 ); diff --git a/src/emu/sound/cem3394.c b/src/emu/sound/cem3394.c index 89fdcb45f1d..7a8ddd6e4f5 100644 --- a/src/emu/sound/cem3394.c +++ b/src/emu/sound/cem3394.c @@ -141,10 +141,8 @@ struct _cem3394_state INLINE cem3394_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_CEM3394); - return (cem3394_state *)device->token; + assert(device->type() == SOUND_CEM3394); + return (cem3394_state *)downcast(device)->token(); } @@ -327,7 +325,7 @@ static STREAM_UPDATE( cem3394_update ) static DEVICE_START( cem3394 ) { - const cem3394_interface *intf = (const cem3394_interface *)device->baseconfig().static_config; + const cem3394_interface *intf = (const cem3394_interface *)device->baseconfig().static_config(); cem3394_state *chip = get_safe_token(device); chip->device = device; diff --git a/src/emu/sound/cem3394.h b/src/emu/sound/cem3394.h index 110f8132129..b2012bb007f 100644 --- a/src/emu/sound/cem3394.h +++ b/src/emu/sound/cem3394.h @@ -3,6 +3,8 @@ #ifndef __CEM3394_H__ #define __CEM3394_H__ +#include "devlegcy.h" + #define CEM3394_SAMPLE_RATE (44100*4) @@ -43,7 +45,6 @@ void cem3394_set_voltage(running_device *device, int input, double voltage); CEM3394_FINAL_GAIN: gain, in dB */ double cem3394_get_parameter(running_device *device, int input); -DEVICE_GET_INFO( cem3394 ); -#define SOUND_CEM3394 DEVICE_GET_INFO_NAME( cem3394 ) +DECLARE_LEGACY_SOUND_DEVICE(CEM3394, cem3394); #endif /* __CEM3394_H__ */ diff --git a/src/emu/sound/dac.c b/src/emu/sound/dac.c index 45a24f33bc1..04febd88d40 100644 --- a/src/emu/sound/dac.c +++ b/src/emu/sound/dac.c @@ -20,10 +20,8 @@ struct _dac_state INLINE dac_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_DAC); - return (dac_state *)device->token; + assert(device->type() == SOUND_DAC); + return (dac_state *)downcast(device)->token(); } @@ -113,7 +111,7 @@ static DEVICE_START( dac ) DAC_build_voltable(info); - info->channel = stream_create(device,0,1,device->clock ? device->clock : DEFAULT_SAMPLE_RATE,info,DAC_update); + info->channel = stream_create(device,0,1,device->clock() ? device->clock() : DEFAULT_SAMPLE_RATE,info,DAC_update); info->output = 0; state_save_register_device_item(device, 0, info->output); diff --git a/src/emu/sound/dac.h b/src/emu/sound/dac.h index 68573ba2049..a7c1499e4e2 100644 --- a/src/emu/sound/dac.h +++ b/src/emu/sound/dac.h @@ -3,6 +3,8 @@ #ifndef __DAC_H__ #define __DAC_H__ +#include "devlegcy.h" + void dac_data_w(running_device *device, UINT8 data) ATTR_NONNULL(1); void dac_signed_data_w(running_device *device, UINT8 data) ATTR_NONNULL(1); void dac_data_16_w(running_device *device, UINT16 data) ATTR_NONNULL(1); @@ -11,7 +13,6 @@ void dac_signed_data_16_w(running_device *device, UINT16 data) ATTR_NONNULL(1); WRITE8_DEVICE_HANDLER( dac_w ); WRITE8_DEVICE_HANDLER( dac_signed_w ); -DEVICE_GET_INFO( dac ); -#define SOUND_DAC DEVICE_GET_INFO_NAME( dac ) +DECLARE_LEGACY_SOUND_DEVICE(DAC, dac); #endif /* __DAC_H__ */ diff --git a/src/emu/sound/digitalk.c b/src/emu/sound/digitalk.c index 784dd1d6eb3..1e2aa70b0f9 100644 --- a/src/emu/sound/digitalk.c +++ b/src/emu/sound/digitalk.c @@ -288,10 +288,8 @@ static const int pitch_vals[32] = { INLINE digitalker *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_DIGITALKER); - return (digitalker *)device->token; + assert(device->type() == SOUND_DIGITALKER); + return (digitalker *)downcast(device)->token(); } @@ -652,7 +650,7 @@ static DEVICE_START(digitalker) digitalker *dg = get_safe_token(device); dg->device = device; dg->rom = memory_region(device->machine, device->tag()); - dg->stream = stream_create(device, 0, 1, device->clock/4, dg, digitalker_update); + dg->stream = stream_create(device, 0, 1, device->clock()/4, dg, digitalker_update); dg->dac_index = 128; dg->data = 0xff; dg->cs = dg->cms = dg->wr = 1; diff --git a/src/emu/sound/digitalk.h b/src/emu/sound/digitalk.h index 4138124ccab..637635cf7f6 100644 --- a/src/emu/sound/digitalk.h +++ b/src/emu/sound/digitalk.h @@ -1,13 +1,14 @@ #ifndef _DIGITALKER_H_ #define _DIGITALKER_H_ +#include "devlegcy.h" + void digitalker_0_cs_w(running_device *device, int line); void digitalker_0_cms_w(running_device *device, int line); void digitalker_0_wr_w(running_device *device, int line); int digitalker_0_intr_r(running_device *device); WRITE8_DEVICE_HANDLER(digitalker_data_w); -DEVICE_GET_INFO(digitalker); -#define SOUND_DIGITALKER DEVICE_GET_INFO_NAME(digitalker) +DECLARE_LEGACY_SOUND_DEVICE(DIGITALKER, digitalker); #endif diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c index e5e1b2b8312..0220db13fba 100644 --- a/src/emu/sound/disc_inp.c +++ b/src/emu/sound/disc_inp.c @@ -47,10 +47,8 @@ struct dss_input_context INLINE discrete_info *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_DISCRETE); - return (discrete_info *)device->token; + assert(device->type() == SOUND_DISCRETE); + return (discrete_info *)downcast(device)->token(); } READ8_DEVICE_HANDLER(discrete_sound_r) diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index 29cef238ffb..907f0cf9e32 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -478,15 +478,15 @@ static DEVICE_START( discrete ) { linked_list_entry **intf; const linked_list_entry *entry; - const discrete_sound_block *intf_start = (discrete_sound_block *)device->baseconfig().static_config; + const discrete_sound_block *intf_start = (discrete_sound_block *)device->baseconfig().static_config(); discrete_info *info = get_safe_token(device); char name[32]; info->device = device; /* If a clock is specified we will use it, otherwise run at the audio sample rate. */ - if (device->clock) - info->sample_rate = device->clock; + if (device->clock()) + info->sample_rate = device->clock(); else info->sample_rate = device->machine->sample_rate; info->sample_time = 1.0 / info->sample_rate; diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index f5d2e3b0d15..c16ee450785 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -3,6 +3,7 @@ #ifndef __DISCRETE_H__ #define __DISCRETE_H__ +#include "devlegcy.h" #include "machine/rescap.h" /*********************************************************************** @@ -4563,7 +4564,6 @@ enum WRITE8_DEVICE_HANDLER( discrete_sound_w ); READ8_DEVICE_HANDLER( discrete_sound_r ); -DEVICE_GET_INFO( discrete ); -#define SOUND_DISCRETE DEVICE_GET_INFO_NAME( discrete ) +DECLARE_LEGACY_SOUND_DEVICE(DISCRETE, discrete); #endif /* __DISCRETE_H__ */ diff --git a/src/emu/sound/dmadac.c b/src/emu/sound/dmadac.c index 3f864dfc3b0..7d6ccef08b0 100644 --- a/src/emu/sound/dmadac.c +++ b/src/emu/sound/dmadac.c @@ -59,10 +59,8 @@ struct _dmadac_state INLINE dmadac_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_DMADAC); - return (dmadac_state *)device->token; + assert(device->type() == SOUND_DMADAC); + return (dmadac_state *)downcast(device)->token(); } @@ -134,7 +132,7 @@ static DEVICE_START( dmadac ) * *************************************/ -void dmadac_transfer(running_device **devlist, UINT8 num_channels, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, INT16 *data) +void dmadac_transfer(dmadac_sound_device **devlist, UINT8 num_channels, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, INT16 *data) { int i, j; @@ -181,7 +179,7 @@ void dmadac_transfer(running_device **devlist, UINT8 num_channels, offs_t channe * *************************************/ -void dmadac_enable(running_device **devlist, UINT8 num_channels, UINT8 enable) +void dmadac_enable(dmadac_sound_device **devlist, UINT8 num_channels, UINT8 enable) { int i; @@ -204,7 +202,7 @@ void dmadac_enable(running_device **devlist, UINT8 num_channels, UINT8 enable) * *************************************/ -void dmadac_set_frequency(running_device **devlist, UINT8 num_channels, double frequency) +void dmadac_set_frequency(dmadac_sound_device **devlist, UINT8 num_channels, double frequency) { int i; @@ -224,7 +222,7 @@ void dmadac_set_frequency(running_device **devlist, UINT8 num_channels, double f * *************************************/ -void dmadac_set_volume(running_device **devlist, UINT8 num_channels, UINT16 volume) +void dmadac_set_volume(dmadac_sound_device **devlist, UINT8 num_channels, UINT16 volume) { int i; diff --git a/src/emu/sound/dmadac.h b/src/emu/sound/dmadac.h index 651a52eabfc..d467beda2ad 100644 --- a/src/emu/sound/dmadac.h +++ b/src/emu/sound/dmadac.h @@ -10,12 +10,13 @@ #ifndef __DMADAC_H__ #define __DMADAC_H__ -void dmadac_transfer(running_device **devlist, UINT8 num_channels, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, INT16 *data); -void dmadac_enable(running_device **devlist, UINT8 num_channels, UINT8 enable); -void dmadac_set_frequency(running_device **devlist, UINT8 num_channels, double frequency); -void dmadac_set_volume(running_device **devlist, UINT8 num_channels, UINT16 volume); +#include "devlegcy.h" -DEVICE_GET_INFO( dmadac ); -#define SOUND_DMADAC DEVICE_GET_INFO_NAME( dmadac ) +DECLARE_LEGACY_SOUND_DEVICE(DMADAC, dmadac); + +void dmadac_transfer(dmadac_sound_device **devlist, UINT8 num_channels, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, INT16 *data); +void dmadac_enable(dmadac_sound_device **devlist, UINT8 num_channels, UINT8 enable); +void dmadac_set_frequency(dmadac_sound_device **devlist, UINT8 num_channels, double frequency); +void dmadac_set_volume(dmadac_sound_device **devlist, UINT8 num_channels, UINT16 volume); #endif /* __DMADAC_H__ */ diff --git a/src/emu/sound/es5503.c b/src/emu/sound/es5503.c index f9d63471310..82cb295016f 100644 --- a/src/emu/sound/es5503.c +++ b/src/emu/sound/es5503.c @@ -79,10 +79,8 @@ typedef struct INLINE ES5503Chip *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ES5503); - return (ES5503Chip *)device->token; + assert(device->type() == SOUND_ES5503); + return (ES5503Chip *)downcast(device)->token(); } static const UINT16 wavesizes[8] = { 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 }; @@ -235,12 +233,12 @@ static DEVICE_START( es5503 ) int osc; ES5503Chip *chip = get_safe_token(device); - intf = (const es5503_interface *)device->baseconfig().static_config; + intf = (const es5503_interface *)device->baseconfig().static_config(); chip->irq_callback = intf->irq_callback; chip->adc_read = intf->adc_read; chip->docram = intf->wave_memory; - chip->clock = device->clock; + chip->clock = device->clock(); chip->device = device; chip->rege0 = 0x80; @@ -268,7 +266,7 @@ static DEVICE_START( es5503 ) chip->oscsenabled = 1; - chip->output_rate = (device->clock/8)/34; // (input clock / 8) / # of oscs. enabled + 2 + chip->output_rate = (device->clock()/8)/34; // (input clock / 8) / # of oscs. enabled + 2 chip->stream = stream_create(device, 0, 2, chip->output_rate, chip, es5503_pcm_update); } diff --git a/src/emu/sound/es5503.h b/src/emu/sound/es5503.h index a21c29e1252..c68f9f6d79c 100644 --- a/src/emu/sound/es5503.h +++ b/src/emu/sound/es5503.h @@ -3,6 +3,8 @@ #ifndef __ES5503_H__ #define __ES5503_H__ +#include "devlegcy.h" + typedef struct _es5503_interface es5503_interface; struct _es5503_interface { @@ -15,7 +17,6 @@ READ8_DEVICE_HANDLER( es5503_r ); WRITE8_DEVICE_HANDLER( es5503_w ); void es5503_set_base(running_device *device, UINT8 *wavemem); -DEVICE_GET_INFO( es5503 ); -#define SOUND_ES5503 DEVICE_GET_INFO_NAME( es5503 ) +DECLARE_LEGACY_SOUND_DEVICE(ES5503, es5503); #endif /* __ES5503_H__ */ diff --git a/src/emu/sound/es5506.c b/src/emu/sound/es5506.c index 793a8af3cf4..49e7ced6d6b 100644 --- a/src/emu/sound/es5506.c +++ b/src/emu/sound/es5506.c @@ -130,10 +130,8 @@ struct _es5506_state INLINE es5506_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ES5505 || sound_get_type(device) == SOUND_ES5506); - return (es5506_state *)device->token; + assert(device->type() == SOUND_ES5505 || device->type() == SOUND_ES5506); + return (es5506_state *)downcast(device)->token(); } @@ -826,7 +824,7 @@ static STREAM_UPDATE( es5506_update ) ***********************************************************************************************/ -static void es5506_start_common(running_device *device, const void *config, sound_type sndtype) +static void es5506_start_common(running_device *device, const void *config, device_type sndtype) { const es5506_interface *intf = (const es5506_interface *)config; es5506_state *chip = get_safe_token(device); @@ -838,7 +836,7 @@ static void es5506_start_common(running_device *device, const void *config, soun eslog = fopen("es.log", "w"); /* create the stream */ - chip->stream = stream_create(device, 0, 2, device->clock / (16*32), chip, es5506_update); + chip->stream = stream_create(device, 0, 2, device->clock() / (16*32), chip, es5506_update); /* initialize the regions */ chip->region_base[0] = intf->region0 ? (UINT16 *)memory_region(device->machine, intf->region0) : NULL; @@ -848,7 +846,7 @@ static void es5506_start_common(running_device *device, const void *config, soun /* initialize the rest of the structure */ chip->device = device; - chip->master_clock = device->clock; + chip->master_clock = device->clock(); chip->irq_callback = intf->irq_callback; chip->irqv = 0x80; @@ -917,7 +915,7 @@ static void es5506_start_common(running_device *device, const void *config, soun static DEVICE_START( es5506 ) { - es5506_start_common(device, device->baseconfig().static_config, SOUND_ES5506); + es5506_start_common(device, device->baseconfig().static_config(), SOUND_ES5506); } @@ -1482,7 +1480,7 @@ void es5506_voice_bank_w(running_device *device, int voice, int bank) static DEVICE_START( es5505 ) { - const es5505_interface *intf = (const es5505_interface *)device->baseconfig().static_config; + const es5505_interface *intf = (const es5505_interface *)device->baseconfig().static_config(); es5506_interface es5506intf; memset(&es5506intf, 0, sizeof(es5506intf)); diff --git a/src/emu/sound/es5506.h b/src/emu/sound/es5506.h index ece48c1d4ca..82f5d62ae2d 100644 --- a/src/emu/sound/es5506.h +++ b/src/emu/sound/es5506.h @@ -10,6 +10,8 @@ #ifndef __ES5506_H__ #define __ES5506_H__ +#include "devlegcy.h" + typedef struct _es5505_interface es5505_interface; struct _es5505_interface { @@ -23,8 +25,7 @@ READ16_DEVICE_HANDLER( es5505_r ); WRITE16_DEVICE_HANDLER( es5505_w ); void es5505_voice_bank_w(running_device *device, int voice, int bank); -DEVICE_GET_INFO( es5505 ); -#define SOUND_ES5505 DEVICE_GET_INFO_NAME( es5505 ) +DECLARE_LEGACY_SOUND_DEVICE(ES5505, es5505); typedef struct _es5506_interface es5506_interface; @@ -42,7 +43,6 @@ READ8_DEVICE_HANDLER( es5506_r ); WRITE8_DEVICE_HANDLER( es5506_w ); void es5506_voice_bank_w(running_device *device, int voice, int bank); -DEVICE_GET_INFO( es5506 ); -#define SOUND_ES5506 DEVICE_GET_INFO_NAME( es5506 ) +DECLARE_LEGACY_SOUND_DEVICE(ES5506, es5506); #endif /* __ES5506_H__ */ diff --git a/src/emu/sound/es8712.c b/src/emu/sound/es8712.c index 2e9829426d2..355faaf7bd4 100644 --- a/src/emu/sound/es8712.c +++ b/src/emu/sound/es8712.c @@ -51,10 +51,8 @@ static int diff_lookup[49*16]; INLINE es8712_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ES8712); - return (es8712_state *)device->token; + assert(device->type() == SOUND_ES8712); + return (es8712_state *)downcast(device)->token(); } @@ -227,10 +225,10 @@ static DEVICE_START( es8712 ) chip->repeat = 0; chip->bank_offset = 0; - chip->region_base = *device->region; + chip->region_base = *device->region(); /* generate the name and create the stream */ - chip->stream = stream_create(device, 0, 1, device->clock, chip, es8712_update); + chip->stream = stream_create(device, 0, 1, device->clock(), chip, es8712_update); /* initialize the rest of the structure */ chip->signal = -2; diff --git a/src/emu/sound/es8712.h b/src/emu/sound/es8712.h index 85ef903a514..1c820914e6b 100644 --- a/src/emu/sound/es8712.h +++ b/src/emu/sound/es8712.h @@ -3,6 +3,8 @@ #ifndef __ES8712_H__ #define __ES8712_H__ +#include "devlegcy.h" + /* An interface for the ES8712 ADPCM chip */ void es8712_play(running_device *device); @@ -11,7 +13,6 @@ void es8712_set_frequency(running_device *device, int frequency); WRITE8_DEVICE_HANDLER( es8712_w ); -DEVICE_GET_INFO( es8712 ); -#define SOUND_ES8712 DEVICE_GET_INFO_NAME( es8712 ) +DECLARE_LEGACY_SOUND_DEVICE(ES8712, es8712); #endif /* __ES8712_H__ */ diff --git a/src/emu/sound/flt_rc.c b/src/emu/sound/flt_rc.c index b54dce460cb..097a03586f7 100644 --- a/src/emu/sound/flt_rc.c +++ b/src/emu/sound/flt_rc.c @@ -15,10 +15,8 @@ struct _filter_rc_state INLINE filter_rc_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_FILTER_RC); - return (filter_rc_state *)device->token; + assert(device->type() == SOUND_FILTER_RC); + return (filter_rc_state *)downcast(device)->token(); } const flt_rc_config flt_rc_ac_default = {FLT_RC_AC, 10000, 0, 0, CAP_U(1)}; @@ -93,7 +91,7 @@ static void set_RC_info(filter_rc_state *info, int type, double R1, double R2, d static DEVICE_START( filter_rc ) { filter_rc_state *info = get_safe_token(device); - const flt_rc_config *conf = (const flt_rc_config *)device->baseconfig().static_config; + const flt_rc_config *conf = (const flt_rc_config *)device->baseconfig().static_config(); info->device = device; info->stream = stream_create(device, 1, 1, device->machine->sample_rate, info, filter_rc_update); diff --git a/src/emu/sound/flt_rc.h b/src/emu/sound/flt_rc.h index 5900462b1ec..32b179aa453 100644 --- a/src/emu/sound/flt_rc.h +++ b/src/emu/sound/flt_rc.h @@ -4,6 +4,7 @@ #define FLT_RC_H #include "machine/rescap.h" +#include "devlegcy.h" #define FLT_RC_LOWPASS 0 #define FLT_RC_HIGHPASS 1 @@ -58,7 +59,6 @@ extern const flt_rc_config flt_rc_ac_default; void filter_rc_set_RC(running_device *device, int type, double R1, double R2, double R3, double C); -DEVICE_GET_INFO( filter_rc ); -#define SOUND_FILTER_RC DEVICE_GET_INFO_NAME( filter_rc ) +DECLARE_LEGACY_SOUND_DEVICE(FILTER_RC, filter_rc); #endif /* __FLT_RC_H__ */ diff --git a/src/emu/sound/flt_vol.c b/src/emu/sound/flt_vol.c index e5bf08611e7..1f4311db1e4 100644 --- a/src/emu/sound/flt_vol.c +++ b/src/emu/sound/flt_vol.c @@ -13,10 +13,8 @@ struct _filter_volume_state INLINE filter_volume_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_FILTER_VOLUME); - return (filter_volume_state *)device->token; + assert(device->type() == SOUND_FILTER_VOLUME); + return (filter_volume_state *)downcast(device)->token(); } diff --git a/src/emu/sound/flt_vol.h b/src/emu/sound/flt_vol.h index 1db138e2cd4..ad00f26ff9b 100644 --- a/src/emu/sound/flt_vol.h +++ b/src/emu/sound/flt_vol.h @@ -3,9 +3,11 @@ #ifndef __FLT_VOL_H__ #define __FLT_VOL_H__ +#include "devlegcy.h" + + void flt_volume_set_volume(running_device *device, float volume); -DEVICE_GET_INFO( filter_volume ); -#define SOUND_FILTER_VOLUME DEVICE_GET_INFO_NAME( filter_volume ) +DECLARE_LEGACY_SOUND_DEVICE(FILTER_VOLUME, filter_volume); #endif /* __FLT_VOL_H__ */ diff --git a/src/emu/sound/gaelco.c b/src/emu/sound/gaelco.c index 1a60b0adce6..bcfa8ed731c 100644 --- a/src/emu/sound/gaelco.c +++ b/src/emu/sound/gaelco.c @@ -51,9 +51,6 @@ Registers per channel: UINT16 *gaelco_sndregs; -/* fix me -- asumes that only one type can be active at a time */ -static sound_type chip_type; - /* this structure defines a channel */ typedef struct _gaelco_sound_channel gaelco_sound_channel; struct _gaelco_sound_channel @@ -81,10 +78,8 @@ static wav_file * wavraw; /* raw waveform */ INLINE gaelco_sound_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_GAELCO_GAE1 || sound_get_type(device) == SOUND_GAELCO_CG1V); - return (gaelco_sound_state *)device->token; + assert(device->type() == SOUND_GAELCO_GAE1 || device->type() == SOUND_GAELCO_CG1V); + return (gaelco_sound_state *)downcast(device)->token(); } /*============================================================================ @@ -255,12 +250,10 @@ WRITE16_DEVICE_HANDLER( gaelcosnd_w ) static DEVICE_START( gaelco ) { int j, vol; - const gaelcosnd_interface *intf = (const gaelcosnd_interface *)device->baseconfig().static_config; + const gaelcosnd_interface *intf = (const gaelcosnd_interface *)device->baseconfig().static_config(); gaelco_sound_state *info = get_safe_token(device); - chip_type = sound_get_type(device); - /* copy rom banks */ for (j = 0; j < 4; j++){ info->banks[j] = intf->banks[j]; @@ -268,7 +261,7 @@ static DEVICE_START( gaelco ) info->stream = stream_create(device, 0, 2, 8000, info, gaelco_update); info->snd_data = (UINT8 *)memory_region(device->machine, intf->gfxregion); if (info->snd_data == NULL) - info->snd_data = *device->region; + info->snd_data = *device->region(); /* init volume table */ for (vol = 0; vol < VOLUME_LEVELS; vol++){ diff --git a/src/emu/sound/gaelco.h b/src/emu/sound/gaelco.h index f6716b0e710..334e782b132 100644 --- a/src/emu/sound/gaelco.h +++ b/src/emu/sound/gaelco.h @@ -3,6 +3,8 @@ #ifndef __GALELCO_H__ #define __GALELCO_H__ +#include "devlegcy.h" + typedef struct _gaelcosnd_interface gaelcosnd_interface; struct _gaelcosnd_interface { @@ -15,10 +17,7 @@ extern UINT16 *gaelco_sndregs; WRITE16_DEVICE_HANDLER( gaelcosnd_w ); READ16_DEVICE_HANDLER( gaelcosnd_r ); -DEVICE_GET_INFO( gaelco_gae1 ); -DEVICE_GET_INFO( gaelco_cg1v ); - -#define SOUND_GAELCO_GAE1 DEVICE_GET_INFO_NAME( gaelco_gae1 ) -#define SOUND_GAELCO_CG1V DEVICE_GET_INFO_NAME( gaelco_cg1v ) +DECLARE_LEGACY_SOUND_DEVICE(GAELCO_GAE1, gaelco_gae1); +DECLARE_LEGACY_SOUND_DEVICE(GAELCO_CG1V, gaelco_cg1v); #endif /* __GALELCO_H__ */ diff --git a/src/emu/sound/hc55516.c b/src/emu/sound/hc55516.c index 756cf2b56ad..d719d136d2e 100644 --- a/src/emu/sound/hc55516.c +++ b/src/emu/sound/hc55516.c @@ -55,12 +55,10 @@ static STREAM_UPDATE( hc55516_update ); INLINE hc55516_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_HC55516 || - sound_get_type(device) == SOUND_MC3417 || - sound_get_type(device) == SOUND_MC3418); - return (hc55516_state *)device->token; + assert(device->type() == SOUND_HC55516 || + device->type() == SOUND_MC3417 || + device->type() == SOUND_MC3418); + return (hc55516_state *)downcast(device)->token(); } @@ -73,7 +71,7 @@ static void start_common(running_device *device, UINT8 _shiftreg_mask, int _acti decay = pow(exp(-1.0), 1.0 / (FILTER_DECAY_TC * 16000.0)); leak = pow(exp(-1.0), 1.0 / (INTEGRATOR_LEAK_TC * 16000.0)); - chip->clock = device->clock; + chip->clock = device->clock(); chip->shiftreg_mask = _shiftreg_mask; chip->active_clock_hi = _active_clock_hi; chip->last_clock_state = 0; diff --git a/src/emu/sound/hc55516.h b/src/emu/sound/hc55516.h index f7db0b26093..7673ef14550 100644 --- a/src/emu/sound/hc55516.h +++ b/src/emu/sound/hc55516.h @@ -3,6 +3,8 @@ #ifndef __HC55516_H__ #define __HC55516_H__ +#include "devlegcy.h" + /* sets the digit (0 or 1) */ void hc55516_digit_w(running_device *device, int digit); @@ -13,12 +15,8 @@ void hc55516_clock_w(running_device *device, int state); /* returns whether the clock is currently LO or HI */ int hc55516_clock_state_r(running_device *device); -DEVICE_GET_INFO( hc55516 ); -DEVICE_GET_INFO( mc3417 ); -DEVICE_GET_INFO( mc3418 ); - -#define SOUND_HC55516 DEVICE_GET_INFO_NAME( hc55516 ) -#define SOUND_MC3417 DEVICE_GET_INFO_NAME( mc3417 ) -#define SOUND_MC3418 DEVICE_GET_INFO_NAME( mc3418 ) +DECLARE_LEGACY_SOUND_DEVICE(HC55516, hc55516); +DECLARE_LEGACY_SOUND_DEVICE(MC3417, mc3417); +DECLARE_LEGACY_SOUND_DEVICE(MC3418, mc3418); #endif /* __HC55516_H__ */ diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index b6a1594d291..d86dc101b84 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -68,10 +68,8 @@ struct _ics2115_state INLINE ics2115_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ICS2115); - return (ics2115_state *)device->token; + assert(device->type() == SOUND_ICS2115); + return (ics2115_state *)downcast(device)->token(); } static void recalc_irq(ics2115_state *chip) @@ -476,8 +474,8 @@ static DEVICE_START( ics2115 ) int i, vv; chip->device = device; - chip->intf = (const ics2115_interface *)device->baseconfig().static_config; - chip->rom = *device->region; + chip->intf = (const ics2115_interface *)device->baseconfig().static_config(); + chip->rom = *device->region(); chip->timer[0].timer = timer_alloc(device->machine, timer_cb_0, chip); chip->timer[1].timer = timer_alloc(device->machine, timer_cb_1, chip); chip->ulaw = auto_alloc_array(device->machine, INT16, 256); diff --git a/src/emu/sound/ics2115.h b/src/emu/sound/ics2115.h index 30d2d71a07a..cde826ec340 100644 --- a/src/emu/sound/ics2115.h +++ b/src/emu/sound/ics2115.h @@ -3,6 +3,8 @@ #ifndef __ICS2115_H__ #define __ICS2115_H__ +#include "devlegcy.h" + typedef struct _ics2115_interface ics2115_interface; struct _ics2115_interface { void (*irq_cb)(running_device *, int); @@ -11,7 +13,6 @@ struct _ics2115_interface { READ8_DEVICE_HANDLER( ics2115_r ); WRITE8_DEVICE_HANDLER( ics2115_w ); -DEVICE_GET_INFO( ics2115 ); -#define SOUND_ICS2115 DEVICE_GET_INFO_NAME( ics2115 ) +DECLARE_LEGACY_SOUND_DEVICE(ICS2115, ics2115); #endif /* __ICS2115_H__ */ diff --git a/src/emu/sound/iremga20.c b/src/emu/sound/iremga20.c index 456439d9376..6bf09c152c4 100644 --- a/src/emu/sound/iremga20.c +++ b/src/emu/sound/iremga20.c @@ -60,10 +60,8 @@ struct _ga20_state INLINE ga20_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_IREMGA20); - return (ga20_state *)device->token; + assert(device->type() == SOUND_IREMGA20); + return (ga20_state *)downcast(device)->token(); } @@ -242,15 +240,15 @@ static DEVICE_START( iremga20 ) int i; /* Initialize our chip structure */ - chip->rom = *device->region; - chip->rom_size = device->region->bytes(); + chip->rom = *device->region(); + chip->rom_size = device->region()->bytes(); iremga20_reset(chip); for ( i = 0; i < 0x40; i++ ) chip->regs[i] = 0; - chip->stream = stream_create( device, 0, 2, device->clock/4, chip, IremGA20_update ); + chip->stream = stream_create( device, 0, 2, device->clock()/4, chip, IremGA20_update ); state_save_register_device_item_array(device, 0, chip->regs); for (i = 0; i < 4; i++) diff --git a/src/emu/sound/iremga20.h b/src/emu/sound/iremga20.h index f5fffa85c01..b0b0f9e7cc6 100644 --- a/src/emu/sound/iremga20.h +++ b/src/emu/sound/iremga20.h @@ -8,10 +8,11 @@ #ifndef __IREMGA20_H__ #define __IREMGA20_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( irem_ga20_w ); READ8_DEVICE_HANDLER( irem_ga20_r ); -DEVICE_GET_INFO( iremga20 ); -#define SOUND_IREMGA20 DEVICE_GET_INFO_NAME( iremga20 ) +DECLARE_LEGACY_SOUND_DEVICE(IREMGA20, iremga20); #endif /* __IREMGA20_H__ */ diff --git a/src/emu/sound/k005289.c b/src/emu/sound/k005289.c index d9244360355..11cceaed88d 100644 --- a/src/emu/sound/k005289.c +++ b/src/emu/sound/k005289.c @@ -64,10 +64,8 @@ struct _k005289_state INLINE k005289_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_K005289); - return (k005289_state *)device->token; + assert(device->type() == SOUND_K005289); + return (k005289_state *)downcast(device)->token(); } /* build a table to divide by the number of voices */ @@ -166,9 +164,9 @@ static DEVICE_START( k005289 ) voice = info->channel_list; /* get stream channels */ - info->rate = device->clock/16; + info->rate = device->clock()/16; info->stream = stream_create(device, 0, 1, info->rate, info, K005289_update); - info->mclock = device->clock; + info->mclock = device->clock(); /* allocate a pair of buffers to mix into - 1 second's worth should be more than enough */ info->mixer_buffer = auto_alloc_array(device->machine, short, 2 * info->rate); @@ -176,7 +174,7 @@ static DEVICE_START( k005289 ) /* build the mixer table */ make_mixer_table(device->machine, info, 2); - info->sound_prom = *device->region; + info->sound_prom = *device->region(); /* reset all the voices */ voice[0].frequency = 0; diff --git a/src/emu/sound/k005289.h b/src/emu/sound/k005289.h index 23d49701b07..b730b678da5 100644 --- a/src/emu/sound/k005289.h +++ b/src/emu/sound/k005289.h @@ -3,6 +3,8 @@ #ifndef __K005289_H__ #define __K005289_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( k005289_control_A_w ); WRITE8_DEVICE_HANDLER( k005289_control_B_w ); WRITE8_DEVICE_HANDLER( k005289_pitch_A_w ); @@ -10,7 +12,6 @@ WRITE8_DEVICE_HANDLER( k005289_pitch_B_w ); WRITE8_DEVICE_HANDLER( k005289_keylatch_A_w ); WRITE8_DEVICE_HANDLER( k005289_keylatch_B_w ); -DEVICE_GET_INFO( k005289 ); -#define SOUND_K005289 DEVICE_GET_INFO_NAME( k005289 ) +DECLARE_LEGACY_SOUND_DEVICE(K005289, k005289); #endif /* __K005289_H__ */ diff --git a/src/emu/sound/k007232.c b/src/emu/sound/k007232.c index 5ba6eaa1d3f..f22f19179c8 100644 --- a/src/emu/sound/k007232.c +++ b/src/emu/sound/k007232.c @@ -58,10 +58,8 @@ typedef struct kdacApcm INLINE KDAC_A_PCM *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_K007232); - return (KDAC_A_PCM *)device->token; + assert(device->type() == SOUND_K007232); + return (KDAC_A_PCM *)downcast(device)->token(); } @@ -307,15 +305,15 @@ static DEVICE_START( k007232 ) int i; KDAC_A_PCM *info = get_safe_token(device); - info->intf = (device->baseconfig().static_config != NULL) ? (const k007232_interface *)device->baseconfig().static_config : &defintrf; + info->intf = (device->baseconfig().static_config() != NULL) ? (const k007232_interface *)device->baseconfig().static_config() : &defintrf; /* Set up the chips */ - info->pcmbuf[0] = *device->region; - info->pcmbuf[1] = *device->region; - info->pcmlimit = device->region->bytes(); + info->pcmbuf[0] = *device->region(); + info->pcmbuf[1] = *device->region(); + info->pcmlimit = device->region()->bytes(); - info->clock = device->clock; + info->clock = device->clock(); for( i = 0; i < KDAC_A_PCM_MAX; i++ ) { @@ -331,7 +329,7 @@ static DEVICE_START( k007232 ) for( i = 0; i < 0x10; i++ ) info->wreg[i] = 0; - info->stream = stream_create(device,0,2,device->clock/128,info,KDAC_A_update); + info->stream = stream_create(device,0,2,device->clock()/128,info,KDAC_A_update); KDAC_A_make_fncode(info); } diff --git a/src/emu/sound/k007232.h b/src/emu/sound/k007232.h index 7fc40b8a1fb..8702104dbeb 100644 --- a/src/emu/sound/k007232.h +++ b/src/emu/sound/k007232.h @@ -7,6 +7,8 @@ #ifndef __K007232_H__ #define __K007232_H__ +#include "devlegcy.h" + typedef struct _k007232_interface k007232_interface; struct _k007232_interface { @@ -28,7 +30,6 @@ void k007232_set_bank( running_device *device, int chABank, int chBBank ); */ void k007232_set_volume(running_device *device,int channel,int volumeA,int volumeB); -DEVICE_GET_INFO( k007232 ); -#define SOUND_K007232 DEVICE_GET_INFO_NAME( k007232 ) +DECLARE_LEGACY_SOUND_DEVICE(K007232, k007232); #endif /* __K007232_H__ */ diff --git a/src/emu/sound/k051649.c b/src/emu/sound/k051649.c index d3240a66d73..d16a13ba430 100644 --- a/src/emu/sound/k051649.c +++ b/src/emu/sound/k051649.c @@ -58,10 +58,8 @@ struct _k051649_state INLINE k051649_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_K051649); - return (k051649_state *)device->token; + assert(device->type() == SOUND_K051649); + return (k051649_state *)downcast(device)->token(); } /* build a table to divide by the number of voices */ @@ -140,9 +138,9 @@ static DEVICE_START( k051649 ) k051649_state *info = get_safe_token(device); /* get stream channels */ - info->rate = device->clock/16; + info->rate = device->clock()/16; info->stream = stream_create(device, 0, 1, info->rate, info, k051649_update); - info->mclock = device->clock; + info->mclock = device->clock(); /* allocate a buffer to mix into - 1 second's worth should be more than enough */ info->mixer_buffer = auto_alloc_array(device->machine, short, 2 * info->rate); diff --git a/src/emu/sound/k051649.h b/src/emu/sound/k051649.h index ae598570bad..46469f9dcfa 100644 --- a/src/emu/sound/k051649.h +++ b/src/emu/sound/k051649.h @@ -3,6 +3,8 @@ #ifndef __K051649_H__ #define __K051649_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( k051649_waveform_w ); READ8_DEVICE_HANDLER( k051649_waveform_r ); WRITE8_DEVICE_HANDLER( k051649_volume_w ); @@ -11,7 +13,6 @@ WRITE8_DEVICE_HANDLER( k051649_keyonoff_w ); WRITE8_DEVICE_HANDLER( k052539_waveform_w ); -DEVICE_GET_INFO( k051649 ); -#define SOUND_K051649 DEVICE_GET_INFO_NAME( k051649 ) +DECLARE_LEGACY_SOUND_DEVICE(K051649, k051649); #endif /* __K051649_H__ */ diff --git a/src/emu/sound/k053260.c b/src/emu/sound/k053260.c index d37682f0f9b..a85398ccb43 100644 --- a/src/emu/sound/k053260.c +++ b/src/emu/sound/k053260.c @@ -46,10 +46,8 @@ struct _k053260_state { INLINE k053260_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_K053260); - return (k053260_state *)device->token; + assert(device->type() == SOUND_K053260); + return (k053260_state *)downcast(device)->token(); } @@ -210,16 +208,16 @@ static DEVICE_START( k053260 ) { static const k053260_interface defintrf = { 0 }; k053260_state *ic = get_safe_token(device); - int rate = device->clock / 32; + int rate = device->clock() / 32; int i; /* Initialize our chip structure */ ic->device = device; - ic->intf = (device->baseconfig().static_config != NULL) ? (const k053260_interface *)device->baseconfig().static_config : &defintrf; + ic->intf = (device->baseconfig().static_config() != NULL) ? (const k053260_interface *)device->baseconfig().static_config() : &defintrf; ic->mode = 0; - const region_info *region = (ic->intf->rgnoverride != NULL) ? device->machine->region(ic->intf->rgnoverride) : device->region; + const region_info *region = (ic->intf->rgnoverride != NULL) ? device->machine->region(ic->intf->rgnoverride) : device->region(); ic->rom = *region; ic->rom_size = region->bytes(); @@ -233,11 +231,11 @@ static DEVICE_START( k053260 ) ic->channel = stream_create( device, 0, 2, rate, ic, k053260_update ); - InitDeltaTable( ic, rate, device->clock ); + InitDeltaTable( ic, rate, device->clock() ); /* setup SH1 timer if necessary */ if ( ic->intf->irq ) - timer_pulse( device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock), 32), NULL, 0, ic->intf->irq ); + timer_pulse( device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock()), 32), NULL, 0, ic->intf->irq ); } INLINE void check_bounds( k053260_state *ic, int channel ) { diff --git a/src/emu/sound/k053260.h b/src/emu/sound/k053260.h index 4aae1dd1b9f..468973b024a 100644 --- a/src/emu/sound/k053260.h +++ b/src/emu/sound/k053260.h @@ -9,6 +9,8 @@ #ifndef __K053260_H__ #define __K053260_H__ +#include "devlegcy.h" + typedef struct _k053260_interface k053260_interface; struct _k053260_interface { const char *rgnoverride; @@ -19,7 +21,6 @@ struct _k053260_interface { WRITE8_DEVICE_HANDLER( k053260_w ); READ8_DEVICE_HANDLER( k053260_r ); -DEVICE_GET_INFO( k053260 ); -#define SOUND_K053260 DEVICE_GET_INFO_NAME( k053260 ) +DECLARE_LEGACY_SOUND_DEVICE(K053260, k053260); #endif /* __K053260_H__ */ diff --git a/src/emu/sound/k054539.c b/src/emu/sound/k054539.c index 97d8b943305..b80b80fc0ec 100644 --- a/src/emu/sound/k054539.c +++ b/src/emu/sound/k054539.c @@ -94,10 +94,8 @@ struct _k054539_state { INLINE k054539_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_K054539); - return (k054539_state *)device->token; + assert(device->type() == SOUND_K054539); + return (k054539_state *)downcast(device)->token(); } //* @@ -454,12 +452,12 @@ static void k054539_init_chip(running_device *device, k054539_state *info) info->k054539_flags |= K054539_UPDATE_AT_KEYON; //* make it default until proven otherwise // Real size of 0x4000, the addon is to simplify the reverb buffer computations - info->ram = auto_alloc_array(device->machine, unsigned char, 0x4000*2+device->clock/50*2); + info->ram = auto_alloc_array(device->machine, unsigned char, 0x4000*2+device->clock()/50*2); info->reverb_pos = 0; info->cur_ptr = 0; - memset(info->ram, 0, 0x4000*2+device->clock/50*2); + memset(info->ram, 0, 0x4000*2+device->clock()/50*2); - const region_info *region = (info->intf->rgnoverride != NULL) ? device->machine->region(info->intf->rgnoverride) : device->region; + const region_info *region = (info->intf->rgnoverride != NULL) ? device->machine->region(info->intf->rgnoverride) : device->region(); info->rom = *region; info->rom_size = region->bytes(); info->rom_mask = 0xffffffffU; @@ -475,7 +473,7 @@ static void k054539_init_chip(running_device *device, k054539_state *info) // 480 hz is TRUSTED by gokuparo disco stage - the looping sample doesn't line up otherwise timer_pulse(device->machine, ATTOTIME_IN_HZ(480), info, 0, k054539_irq); - info->stream = stream_create(device, 0, 2, device->clock, info, k054539_update); + info->stream = stream_create(device, 0, 2, device->clock(), info, k054539_update); state_save_register_device_item_array(device, 0, info->regs); state_save_register_device_item_pointer(device, 0, info->ram, 0x4000); @@ -651,7 +649,7 @@ static DEVICE_START( k054539 ) info->k054539_gain[i] = 1.0; info->k054539_flags = K054539_RESET_FLAGS; - info->intf = (device->baseconfig().static_config != NULL) ? (const k054539_interface *)device->baseconfig().static_config : &defintrf; + info->intf = (device->baseconfig().static_config() != NULL) ? (const k054539_interface *)device->baseconfig().static_config() : &defintrf; /* I've tried various equations on volume control but none worked consistently. diff --git a/src/emu/sound/k054539.h b/src/emu/sound/k054539.h index 5aeb45ca170..9062b395ee3 100644 --- a/src/emu/sound/k054539.h +++ b/src/emu/sound/k054539.h @@ -9,6 +9,8 @@ #ifndef __K054539_H__ #define __K054539_H__ +#include "devlegcy.h" + typedef struct _k054539_interface k054539_interface; struct _k054539_interface { @@ -43,7 +45,6 @@ void k054539_init_flags(running_device *device, int flags); */ void k054539_set_gain(running_device *device, int channel, double gain); -DEVICE_GET_INFO( k054539 ); -#define SOUND_K054539 DEVICE_GET_INFO_NAME( k054539 ) +DECLARE_LEGACY_SOUND_DEVICE(K054539, k054539); #endif /* __K054539_H__ */ diff --git a/src/emu/sound/k056800.c b/src/emu/sound/k056800.c index e15bcaaa879..959c426fb5b 100644 --- a/src/emu/sound/k056800.c +++ b/src/emu/sound/k056800.c @@ -27,17 +27,16 @@ struct _k056800_state INLINE k056800_state *k056800_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K056800); + assert(device->type() == K056800); - return (k056800_state *)device->token; + return (k056800_state *)downcast(device)->token(); } INLINE const k056800_interface *k056800_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K056800)); - return (const k056800_interface *) device->baseconfig().static_config; + assert((device->type() == K056800)); + return (const k056800_interface *) device->baseconfig().static_config(); } /***************************************************************************** diff --git a/src/emu/sound/k056800.h b/src/emu/sound/k056800.h index 739d8039df7..bef69e59495 100644 --- a/src/emu/sound/k056800.h +++ b/src/emu/sound/k056800.h @@ -7,6 +7,7 @@ #ifndef __K056800_H__ #define __K056800_H__ +#include "devlegcy.h" /*************************************************************************** @@ -22,20 +23,13 @@ struct _k056800_interface k056800_irq_cb irq_cb; }; - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( k056800 ); +DECLARE_LEGACY_DEVICE(K056800, k056800); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define K056800 DEVICE_GET_INFO_NAME( k056800 ) - #define MDRV_K056800_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K056800, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/emu/sound/mos6560.c b/src/emu/sound/mos6560.c index a5e1b353a54..63c73d383b1 100644 --- a/src/emu/sound/mos6560.c +++ b/src/emu/sound/mos6560.c @@ -69,7 +69,7 @@ struct _mos6560_state { mos6560_type type; - running_device *screen; + screen_device *screen; UINT8 reg[16]; @@ -123,20 +123,17 @@ struct _mos6560_state INLINE mos6560_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == MOS656X); + assert(device->type() == MOS656X); - return (mos6560_state *)device->token; + return (mos6560_state *)downcast(device)->token(); } INLINE const mos6560_interface *get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == MOS656X); + assert((device->type() == MOS656X)); - return (const mos6560_interface *) device->baseconfig().static_config; + return (const mos6560_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -803,12 +800,12 @@ static void mos6560_sound_start( running_device *device ) static DEVICE_START( mos6560 ) { mos6560_state *mos6560 = get_safe_token(device); - const mos6560_interface *intf = (mos6560_interface *)device->baseconfig().static_config; + const mos6560_interface *intf = (mos6560_interface *)device->baseconfig().static_config(); int width, height; - mos6560->screen = devtag_get_device(device->machine, intf->screen); - width = video_screen_get_width(mos6560->screen); - height = video_screen_get_height(mos6560->screen); + mos6560->screen = downcast(devtag_get_device(device->machine, intf->screen)); + width = mos6560->screen->width(); + height = mos6560->screen->height(); mos6560->type = intf->type; diff --git a/src/emu/sound/mos6560.h b/src/emu/sound/mos6560.h index 3892bfc6b88..76bdca43fce 100644 --- a/src/emu/sound/mos6560.h +++ b/src/emu/sound/mos6560.h @@ -7,6 +7,7 @@ #ifndef __MOS6560_H__ #define __MOS6560_H__ +#include "devlegcy.h" #include "devcb.h" @@ -87,18 +88,15 @@ struct _mos6560_interface INFO PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( mos6560 ); +DECLARE_LEGACY_SOUND_DEVICE(MOS656X, mos6560); +#define MOS656X SOUND_MOS656X /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define MOS656X DEVICE_GET_INFO_NAME( mos6560 ) -#define SOUND_MOS656X MOS656X - #define MDRV_MOS656X_ADD(_tag, _interface) \ - MDRV_DEVICE_ADD(_tag, SOUND, 0) \ - MDRV_DEVICE_CONFIG_DATAPTR(sound_config, type, SOUND_MOS656X) \ + MDRV_DEVICE_ADD(_tag, SOUND_MOS656X, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/emu/sound/msm5205.c b/src/emu/sound/msm5205.c index 789a44cbedb..071a4d69214 100644 --- a/src/emu/sound/msm5205.c +++ b/src/emu/sound/msm5205.c @@ -49,10 +49,8 @@ struct _msm5205_state INLINE msm5205_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_MSM5205); - return (msm5205_state *)device->token; + assert(device->type() == SOUND_MSM5205); + return (msm5205_state *)downcast(device)->token(); } @@ -182,15 +180,15 @@ static DEVICE_START( msm5205 ) msm5205_state *voice = get_safe_token(device); /* save a global pointer to our interface */ - voice->intf = (const msm5205_interface *)device->baseconfig().static_config; + voice->intf = (const msm5205_interface *)device->baseconfig().static_config(); voice->device = device; - voice->clock = device->clock; + voice->clock = device->clock(); /* compute the difference tables */ ComputeTables (voice); /* stream system initialize */ - voice->stream = stream_create(device,0,1,device->clock,voice,MSM5205_update); + voice->stream = stream_create(device,0,1,device->clock(),voice,MSM5205_update); voice->timer = timer_alloc(device->machine, MSM5205_vclk_callback, voice); /* initialize */ diff --git a/src/emu/sound/msm5205.h b/src/emu/sound/msm5205.h index 4a3be8bdb86..fe9114cfd19 100644 --- a/src/emu/sound/msm5205.h +++ b/src/emu/sound/msm5205.h @@ -3,6 +3,8 @@ #ifndef __MSM5205_H__ #define __MSM5205_H__ +#include "devlegcy.h" + /* an interface for the MSM5205 and similar chips */ /* prescaler selector defines */ @@ -36,7 +38,6 @@ void msm5205_playmode_w(running_device *device, int _select); void msm5205_set_volume(running_device *device,int volume); -DEVICE_GET_INFO( msm5205 ); -#define SOUND_MSM5205 DEVICE_GET_INFO_NAME( msm5205 ) +DECLARE_LEGACY_SOUND_DEVICE(MSM5205, msm5205); #endif /* __MSM5205_H__ */ diff --git a/src/emu/sound/msm5232.c b/src/emu/sound/msm5232.c index b5acdc527f4..14d4d119624 100644 --- a/src/emu/sound/msm5232.c +++ b/src/emu/sound/msm5232.c @@ -78,10 +78,8 @@ typedef struct { INLINE MSM5232 *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_MSM5232); - return (MSM5232 *)device->token; + assert(device->type() == SOUND_MSM5232); + return (MSM5232 *)downcast(device)->token(); } @@ -785,13 +783,13 @@ static STREAM_UPDATE( MSM5232_update_one ) static DEVICE_START( msm5232 ) { - const msm5232_interface *intf = (const msm5232_interface *)device->baseconfig().static_config; - int rate = device->clock/CLOCK_RATE_DIVIDER; + const msm5232_interface *intf = (const msm5232_interface *)device->baseconfig().static_config(); + int rate = device->clock()/CLOCK_RATE_DIVIDER; MSM5232 *chip = get_safe_token(device); chip->device = device; - msm5232_init(chip, intf, device->clock, rate); + msm5232_init(chip, intf, device->clock(), rate); chip->stream = stream_create(device,0,11,rate,chip,MSM5232_update_one); } diff --git a/src/emu/sound/msm5232.h b/src/emu/sound/msm5232.h index ad1bfb003d2..2ac58f2131c 100644 --- a/src/emu/sound/msm5232.h +++ b/src/emu/sound/msm5232.h @@ -3,6 +3,8 @@ #ifndef __MSM5232_H__ #define __MSM5232_H__ +#include "devlegcy.h" + typedef struct _msm5232_interface msm5232_interface; struct _msm5232_interface { @@ -14,7 +16,6 @@ WRITE8_DEVICE_HANDLER( msm5232_w ); void msm5232_set_clock(running_device *device, int clock); -DEVICE_GET_INFO( msm5232 ); -#define SOUND_MSM5232 DEVICE_GET_INFO_NAME( msm5232 ) +DECLARE_LEGACY_SOUND_DEVICE(MSM5232, msm5232); #endif /* __MSM5232_H__ */ diff --git a/src/emu/sound/multipcm.c b/src/emu/sound/multipcm.c index 557cf02da50..8f9ccf56dc6 100644 --- a/src/emu/sound/multipcm.c +++ b/src/emu/sound/multipcm.c @@ -129,10 +129,8 @@ static const int val2chan[] = INLINE MultiPCM *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_MULTIPCM); - return (MultiPCM *)device->token; + assert(device->type() == SOUND_MULTIPCM); + return (MultiPCM *)downcast(device)->token(); } @@ -502,8 +500,8 @@ static DEVICE_START( multipcm ) MultiPCM *ptChip = get_safe_token(device); int i; - ptChip->ROM=*device->region; - ptChip->Rate=(float) device->clock / MULTIPCM_CLOCKDIV; + ptChip->ROM=*device->region(); + ptChip->Rate=(float) device->clock() / MULTIPCM_CLOCKDIV; ptChip->stream = stream_create(device, 0, 2, ptChip->Rate, ptChip, MultiPCM_update); diff --git a/src/emu/sound/multipcm.h b/src/emu/sound/multipcm.h index 9c20693d9fd..e0cdae87ccf 100644 --- a/src/emu/sound/multipcm.h +++ b/src/emu/sound/multipcm.h @@ -3,12 +3,13 @@ #ifndef __MULTIPCM_H__ #define __MULTIPCM_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( multipcm_w ); READ8_DEVICE_HANDLER( multipcm_r ); void multipcm_set_bank(running_device *device, UINT32 leftoffs, UINT32 rightoffs); -DEVICE_GET_INFO( multipcm ); -#define SOUND_MULTIPCM DEVICE_GET_INFO_NAME( multipcm ) +DECLARE_LEGACY_SOUND_DEVICE(MULTIPCM, multipcm); #endif /* __MULTIPCM_H__ */ diff --git a/src/emu/sound/n63701x.c b/src/emu/sound/n63701x.c index 56a26029f45..5cbbb7510c4 100644 --- a/src/emu/sound/n63701x.c +++ b/src/emu/sound/n63701x.c @@ -50,10 +50,8 @@ static const int vol_table[4] = { 26, 84, 200, 258 }; INLINE namco_63701x *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_NAMCO_63701X); - return (namco_63701x *)device->token; + assert(device->type() == SOUND_NAMCO_63701X); + return (namco_63701x *)downcast(device)->token(); } @@ -115,9 +113,9 @@ static DEVICE_START( namco_63701x ) { namco_63701x *chip = get_safe_token(device); - chip->rom = *device->region; + chip->rom = *device->region(); - chip->stream = stream_create(device, 0, 2, device->clock/1000, chip, namco_63701x_update); + chip->stream = stream_create(device, 0, 2, device->clock()/1000, chip, namco_63701x_update); } diff --git a/src/emu/sound/n63701x.h b/src/emu/sound/n63701x.h index 82ed30cf6ce..c6c0f57cbc4 100644 --- a/src/emu/sound/n63701x.h +++ b/src/emu/sound/n63701x.h @@ -3,9 +3,10 @@ #ifndef __N63701X_H__ #define __N63701X_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( namco_63701x_w ); -DEVICE_GET_INFO( namco_63701x ); -#define SOUND_NAMCO_63701X DEVICE_GET_INFO_NAME( namco_63701x ) +DECLARE_LEGACY_SOUND_DEVICE(NAMCO_63701X, namco_63701x); #endif /* __N63701X_H__ */ diff --git a/src/emu/sound/namco.c b/src/emu/sound/namco.c index 4bafd0d6f4a..ac42f5cf3e8 100644 --- a/src/emu/sound/namco.c +++ b/src/emu/sound/namco.c @@ -80,12 +80,10 @@ struct _namco_sound INLINE namco_sound *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_NAMCO || - sound_get_type(device) == SOUND_NAMCO_15XX || - sound_get_type(device) == SOUND_NAMCO_CUS30); - return (namco_sound *)device->token; + assert(device->type() == SOUND_NAMCO || + device->type() == SOUND_NAMCO_15XX || + device->type() == SOUND_NAMCO_CUS30); + return (namco_sound *)downcast(device)->token(); } /* update the decoded waveform data */ @@ -366,7 +364,7 @@ static STREAM_UPDATE( namco_update_stereo ) static DEVICE_START( namco ) { sound_channel *voice; - const namco_interface *intf = (const namco_interface *)device->baseconfig().static_config; + const namco_interface *intf = (const namco_interface *)device->baseconfig().static_config(); int clock_multiple; namco_sound *chip = get_safe_token(device); @@ -376,7 +374,7 @@ static DEVICE_START( namco ) chip->stereo = intf->stereo; /* adjust internal clock */ - chip->namco_clock = device->clock; + chip->namco_clock = device->clock(); for (clock_multiple = 0; chip->namco_clock < INTERNAL_RATE; clock_multiple++) chip->namco_clock *= 2; @@ -388,7 +386,7 @@ static DEVICE_START( namco ) logerror("Namco: freq fractional bits = %d: internal freq = %d, output freq = %d\n", chip->f_fracbits, chip->namco_clock, chip->sample_rate); /* build the waveform table */ - build_decoded_waveform(device->machine, chip, *device->region); + build_decoded_waveform(device->machine, chip, *device->region()); /* get stream channels */ if (intf->stereo) diff --git a/src/emu/sound/namco.h b/src/emu/sound/namco.h index 1135f7c0ec1..39d485cdf0d 100644 --- a/src/emu/sound/namco.h +++ b/src/emu/sound/namco.h @@ -3,6 +3,8 @@ #ifndef __NAMCO_H__ #define __NAMCO_H__ +#include "devlegcy.h" + typedef struct _namco_interface namco_interface; struct _namco_interface { @@ -30,13 +32,9 @@ extern UINT8 *namco_wavedata; #define pacman_soundregs namco_soundregs #define polepos_soundregs namco_soundregs -DEVICE_GET_INFO( namco ); -DEVICE_GET_INFO( namco_15xx ); -DEVICE_GET_INFO( namco_cus30 ); - -#define SOUND_NAMCO DEVICE_GET_INFO_NAME( namco ) -#define SOUND_NAMCO_15XX DEVICE_GET_INFO_NAME( namco_15xx ) -#define SOUND_NAMCO_CUS30 DEVICE_GET_INFO_NAME( namco_cus30 ) +DECLARE_LEGACY_SOUND_DEVICE(NAMCO, namco); +DECLARE_LEGACY_SOUND_DEVICE(NAMCO_15XX, namco_15xx); +DECLARE_LEGACY_SOUND_DEVICE(NAMCO_CUS30, namco_cus30); #endif /* __NAMCO_H__ */ diff --git a/src/emu/sound/nes_apu.c b/src/emu/sound/nes_apu.c index 19269003c95..8190538a055 100644 --- a/src/emu/sound/nes_apu.c +++ b/src/emu/sound/nes_apu.c @@ -75,10 +75,8 @@ struct _nesapu_state INLINE nesapu_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_NES); - return (nesapu_state *)device->token; + assert(device->type() == SOUND_NES); + return (nesapu_state *)downcast(device)->token(); } /* INTERNAL FUNCTIONS */ @@ -687,16 +685,16 @@ static STREAM_UPDATE( nes_psg_update_sound ) /* INITIALIZE APU SYSTEM */ static DEVICE_START( nesapu ) { - const nes_interface *intf = (const nes_interface *)device->baseconfig().static_config; + const nes_interface *intf = (const nes_interface *)device->baseconfig().static_config(); nesapu_state *info = get_safe_token(device); - int rate = device->clock / 4; + int rate = device->clock() / 4; int i; /* Initialize global variables */ - info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(video_screen_get_frame_period(device->machine->primary_screen).attoseconds); + info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(device->machine->primary_screen->frame_period().attoseconds); info->buffer_size = info->samps_per_sync; - info->real_rate = info->samps_per_sync * ATTOSECONDS_TO_HZ(video_screen_get_frame_period(device->machine->primary_screen).attoseconds); - info->apu_incsize = (float) (device->clock / (float) info->real_rate); + info->real_rate = info->samps_per_sync * ATTOSECONDS_TO_HZ(device->machine->primary_screen->frame_period().attoseconds); + info->apu_incsize = (float) (device->clock() / (float) info->real_rate); /* Use initializer calls */ create_noise(info->noise_lut, 13, NOISE_LONG); diff --git a/src/emu/sound/nes_apu.h b/src/emu/sound/nes_apu.h index cda9e93c1ec..994d3d273f8 100644 --- a/src/emu/sound/nes_apu.h +++ b/src/emu/sound/nes_apu.h @@ -26,6 +26,8 @@ #ifndef __NES_APU_H__ #define __NES_APU_H__ +#include "devlegcy.h" + /* AN EXPLANATION * @@ -44,7 +46,6 @@ struct _nes_interface READ8_DEVICE_HANDLER( nes_psg_r ); WRITE8_DEVICE_HANDLER( nes_psg_w ); -DEVICE_GET_INFO( nesapu ); -#define SOUND_NES DEVICE_GET_INFO_NAME( nesapu ) +DECLARE_LEGACY_SOUND_DEVICE(NES, nesapu); #endif /* __NES_APU_H__ */ diff --git a/src/emu/sound/nile.c b/src/emu/sound/nile.c index 1c2be8ee84f..5b4ebfaf1aa 100644 --- a/src/emu/sound/nile.c +++ b/src/emu/sound/nile.c @@ -66,10 +66,8 @@ struct _nile_state INLINE nile_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_NILE); - return (nile_state *)device->token; + assert(device->type() == SOUND_NILE); + return (nile_state *)downcast(device)->token(); } @@ -229,7 +227,7 @@ static DEVICE_START( nile ) { nile_state *info = get_safe_token(device); - info->sound_ram = *device->region; + info->sound_ram = *device->region(); info->stream = stream_create(device, 0, 2, 44100, info, nile_update); } diff --git a/src/emu/sound/nile.h b/src/emu/sound/nile.h index 840dda109ef..029a0a9d0d4 100644 --- a/src/emu/sound/nile.h +++ b/src/emu/sound/nile.h @@ -3,6 +3,8 @@ #ifndef __NILE_H__ #define __NILE_H__ +#include "devlegcy.h" + extern UINT16 *nile_sound_regs; WRITE16_DEVICE_HANDLER( nile_snd_w ); @@ -10,7 +12,6 @@ READ16_DEVICE_HANDLER( nile_snd_r ); WRITE16_DEVICE_HANDLER( nile_sndctrl_w ); READ16_DEVICE_HANDLER( nile_sndctrl_r ); -DEVICE_GET_INFO( nile ); -#define SOUND_NILE DEVICE_GET_INFO_NAME( nile ) +DECLARE_LEGACY_SOUND_DEVICE(NILE, nile); #endif /* __NILE_H__ */ diff --git a/src/emu/sound/okim6258.c b/src/emu/sound/okim6258.c index 3b4beb49290..6cd2f1464b8 100644 --- a/src/emu/sound/okim6258.c +++ b/src/emu/sound/okim6258.c @@ -52,10 +52,8 @@ static int tables_computed = 0; INLINE okim6258_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_OKIM6258); - return (okim6258_state *)device->token; + assert(device->type() == SOUND_OKIM6258); + return (okim6258_state *)downcast(device)->token(); } /********************************************************************************************** @@ -192,19 +190,19 @@ static void okim6258_state_save_register(okim6258_state *info, running_device *d static DEVICE_START( okim6258 ) { - const okim6258_interface *intf = (const okim6258_interface *)device->baseconfig().static_config; + const okim6258_interface *intf = (const okim6258_interface *)device->baseconfig().static_config(); okim6258_state *info = get_safe_token(device); compute_tables(); - info->master_clock = device->clock; + info->master_clock = device->clock(); info->adpcm_type = intf->adpcm_type; /* D/A precision is 10-bits but 12-bit data can be output serially to an external DAC */ info->output_bits = intf->output_12bits ? 12 : 10; info->divider = dividers[intf->divider]; - info->stream = stream_create(device, 0, 1, device->clock/info->divider, info, okim6258_update); + info->stream = stream_create(device, 0, 1, device->clock()/info->divider, info, okim6258_update); info->signal = -2; info->step = 0; diff --git a/src/emu/sound/okim6258.h b/src/emu/sound/okim6258.h index 82cb0f84708..56c044871c1 100644 --- a/src/emu/sound/okim6258.h +++ b/src/emu/sound/okim6258.h @@ -3,6 +3,8 @@ #ifndef __OKIM6258_H__ #define __OKIM6258_H__ +#include "devlegcy.h" + /* an interface for the OKIM6258 and similar chips */ typedef struct _okim6258_interface okim6258_interface; @@ -32,7 +34,6 @@ READ8_DEVICE_HANDLER( okim6258_status_r ); WRITE8_DEVICE_HANDLER( okim6258_data_w ); WRITE8_DEVICE_HANDLER( okim6258_ctrl_w ); -DEVICE_GET_INFO( okim6258 ); -#define SOUND_OKIM6258 DEVICE_GET_INFO_NAME( okim6258 ) +DECLARE_LEGACY_SOUND_DEVICE(OKIM6258, okim6258); #endif /* __OKIM6258_H__ */ diff --git a/src/emu/sound/okim6295.c b/src/emu/sound/okim6295.c index 8a6ba3224c8..b80fe419b51 100644 --- a/src/emu/sound/okim6295.c +++ b/src/emu/sound/okim6295.c @@ -1,69 +1,58 @@ -/********************************************************************************************** - * - * streaming ADPCM driver - * by Aaron Giles - * - * Library to transcode from an ADPCM source to raw PCM. - * Written by Buffoni Mirko in 08/06/97 - * References: various sources and documents. - * - * HJB 08/31/98 - * modified to use an automatically selected oversampling factor - * for the current sample rate - * - * Mish 21/7/99 - * Updated to allow multiple OKI chips with different sample rates - * - * R. Belmont 31/10/2003 - * Updated to allow a driver to use both MSM6295s and "raw" ADPCM voices (gcpinbal) - * Also added some error trapping for MAME_DEBUG builds - * - **********************************************************************************************/ +/*************************************************************************** + okim6295.h -#include "emu.h" -#include "streams.h" -#include "okim6295.h" + OKIM 6295 ADCPM sound chip. -#define MAX_SAMPLE_CHUNK 10000 +**************************************************************************** + Library to transcode from an ADPCM source to raw PCM. + Written by Buffoni Mirko in 08/06/97 + References: various sources and documents. -/* struct describing a single playing ADPCM voice */ -struct ADPCMVoice -{ - UINT8 playing; /* 1 if we are actively playing */ + R. Belmont 31/10/2003 + Updated to allow a driver to use both MSM6295s and "raw" ADPCM voices + (gcpinbal). Also added some error trapping for MAME_DEBUG builds - UINT32 base_offset; /* pointer to the base memory location */ - UINT32 sample; /* current sample number */ - UINT32 count; /* total samples to play */ +**************************************************************************** - struct adpcm_state adpcm;/* current ADPCM state */ - UINT32 volume; /* output volume */ -}; + OKIM 6295 ADPCM chip: -typedef struct _okim6295_state okim6295_state; -struct _okim6295_state -{ - #define OKIM6295_VOICES 4 - struct ADPCMVoice voice[OKIM6295_VOICES]; - running_device *device; - INT32 command; - UINT8 bank_installed; - INT32 bank_offs; - sound_stream *stream; /* which stream are we playing on? */ - UINT32 master_clock; /* master clock frequency */ -}; + Command bytes are sent: + + 1xxx xxxx = start of 2-byte command sequence, xxxxxxx is the sample + number to trigger + abcd vvvv = second half of command; one of the abcd bits is set to + indicate which voice the v bits seem to be volumed + + 0abc d000 = stop playing; one or more of the abcd bits is set to + indicate which voice(s) -/* step size index shift table */ -static const int index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 }; + Status is read: -/* lookup table for the precomputed difference */ -static int diff_lookup[49*16]; + ???? abcd = one bit per voice, set to 0 if nothing is playing, or + 1 if it is active -/* volume lookup table. The manual lists only 9 steps, ~3dB per step. Given the dB values, - that seems to map to a 5-bit volume control. Any volume parameter beyond the 9th index - results in silent playback. */ -static const int volume_table[16] = +***************************************************************************/ + +#include "emu.h" +#include "streams.h" +#include "okim6295.h" + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// ADPCM state and tables +bool adpcm_state::s_tables_computed = false; +const INT8 adpcm_state::s_index_shift[8] = { -1, -1, -1, -1, 2, 4, 6, 8 }; +int adpcm_state::s_diff_lookup[49*16]; + +// volume lookup table. The manual lists only 9 steps, ~3dB per step. Given the dB values, +// that seems to map to a 5-bit volume control. Any volume parameter beyond the 9th index +// results in silent playback. +const UINT8 okim6295_device::s_volume_table[16] = { 0x20, // 0 dB 0x16, // -3.2 dB @@ -83,516 +72,460 @@ static const int volume_table[16] = 0x00, }; -/* tables computed? */ -static int tables_computed = 0; - -/* useful interfaces */ -const okim6295_interface okim6295_interface_pin7high = { 1 }; -const okim6295_interface okim6295_interface_pin7low = { 0 }; - -/* default address map */ +// default address map static ADDRESS_MAP_START( okim6295, 0, 8 ) AM_RANGE(0x00000, 0x3ffff) AM_ROM ADDRESS_MAP_END -INLINE okim6295_state *get_safe_token(running_device *device) -{ - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_OKIM6295); - return (okim6295_state *)device->token; -} +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** -/********************************************************************************************** +//------------------------------------------------- +// okim6295_device_config - constructor +//------------------------------------------------- - compute_tables -- compute the difference tables - -***********************************************************************************************/ - -static void compute_tables(void) +okim6295_device_config::okim6295_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + device_config_sound_interface(mconfig, *this), + device_config_memory_interface(mconfig, *this), + m_space_config("samples", ENDIANNESS_LITTLE, 8, 18, 0, NULL, *ADDRESS_MAP_NAME(okim6295)) { - /* nibble to bit map */ - static const int nbl2bit[16][4] = - { - { 1, 0, 0, 0}, { 1, 0, 0, 1}, { 1, 0, 1, 0}, { 1, 0, 1, 1}, - { 1, 1, 0, 0}, { 1, 1, 0, 1}, { 1, 1, 1, 0}, { 1, 1, 1, 1}, - {-1, 0, 0, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 0, 1, 1}, - {-1, 1, 0, 0}, {-1, 1, 0, 1}, {-1, 1, 1, 0}, {-1, 1, 1, 1} - }; - - int step, nib; - - /* loop over all possible steps */ - for (step = 0; step <= 48; step++) - { - /* compute the step value */ - int stepval = floor(16.0 * pow(11.0 / 10.0, (double)step)); - - /* loop over all nibbles and compute the difference */ - for (nib = 0; nib < 16; nib++) - { - diff_lookup[step*16 + nib] = nbl2bit[nib][0] * - (stepval * nbl2bit[nib][1] + - stepval/2 * nbl2bit[nib][2] + - stepval/4 * nbl2bit[nib][3] + - stepval/8); - } - } - - tables_computed = 1; } +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- -/********************************************************************************************** - - reset_adpcm -- reset the ADPCM stream - -***********************************************************************************************/ - -void reset_adpcm(struct adpcm_state *state) +device_config *okim6295_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) { - /* make sure we have our tables */ - if (!tables_computed) - compute_tables(); - - /* reset the signal/step */ - state->signal = -2; - state->step = 0; + return global_alloc(okim6295_device_config(mconfig, tag, owner, clock)); } +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- -/********************************************************************************************** - - clock_adpcm -- clock the next ADPCM byte - -***********************************************************************************************/ - -INT16 clock_adpcm(struct adpcm_state *state, UINT8 nibble) +device_t *okim6295_device_config::alloc_device(running_machine &machine) const { - state->signal += diff_lookup[state->step * 16 + (nibble & 15)]; - - /* clamp to the maximum */ - if (state->signal > 2047) - state->signal = 2047; - else if (state->signal < -2048) - state->signal = -2048; - - /* adjust the step size and clamp */ - state->step += index_shift[nibble & 7]; - if (state->step > 48) - state->step = 48; - else if (state->step < 0) - state->step = 0; - - /* return the signal */ - return state->signal; + return auto_alloc(&machine, okim6295_device(machine, *this)); } +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -/********************************************************************************************** - - generate_adpcm -- general ADPCM decoding routine - -***********************************************************************************************/ - -static void generate_adpcm(okim6295_state *chip, struct ADPCMVoice *voice, INT16 *buffer, int samples) +void okim6295_device_config::device_config_complete() { - /* if this voice is active */ - if (voice->playing) - { - offs_t base = voice->base_offset; - int sample = voice->sample; - int count = voice->count; - - /* loop while we still have samples to generate */ - while (samples) - { - /* compute the new amplitude and update the current step */ - int nibble = memory_raw_read_byte(chip->device->space(), base + sample / 2) >> (((sample & 1) << 2) ^ 4); - - /* output to the buffer, scaling by the volume */ - /* signal in range -2048..2047, volume in range 2..32 => signal * volume / 2 in range -32768..32767 */ - *buffer++ = clock_adpcm(&voice->adpcm, nibble) * voice->volume / 2; - samples--; + // copy the pin7 state from inline data + m_pin7 = m_inline_data[INLINE_PIN7]; +} - /* next! */ - if (++sample >= count) - { - voice->playing = 0; - break; - } - } - /* update the parameters */ - voice->sample = sample; - } +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- - /* fill the rest with silence */ - while (samples--) - *buffer++ = 0; +const address_space_config *okim6295_device_config::memory_space_config(int spacenum) const +{ + return (spacenum == 0) ? &m_space_config : NULL; } -/********************************************************************************************** - * - * OKIM 6295 ADPCM chip: - * - * Command bytes are sent: - * - * 1xxx xxxx = start of 2-byte command sequence, xxxxxxx is the sample number to trigger - * abcd vvvv = second half of command; one of the abcd bits is set to indicate which voice - * the v bits seem to be volumed - * - * 0abc d000 = stop playing; one or more of the abcd bits is set to indicate which voice(s) - * - * Status is read: - * - * ???? abcd = one bit per voice, set to 0 if nothing is playing, or 1 if it is active - * -***********************************************************************************************/ +//************************************************************************** +// LIVE DEVICE +//************************************************************************** +//------------------------------------------------- +// okim6295_device - constructor +//------------------------------------------------- -/********************************************************************************************** +okim6295_device::okim6295_device(running_machine &_machine, const okim6295_device_config &config) + : device_t(_machine, config), + device_sound_interface(_machine, config, *this), + device_memory_interface(_machine, config, *this), + m_config(config), + m_command(-1), + m_bank_installed(false), + m_bank_offs(0), + m_stream(NULL), + m_pin7_state(m_config.m_pin7) +{ +} - okim6295_update -- update the sound chip so that it is in sync with CPU execution -***********************************************************************************************/ +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- -static STREAM_UPDATE( okim6295_update ) +void okim6295_device::device_start() { - okim6295_state *chip = (okim6295_state *)param; - int i; + // create the stream + int divisor = m_config.m_pin7 ? 132 : 165; + m_stream = stream_create(this, 0, 1, clock() / divisor, this, static_stream_generate); - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - - for (i = 0; i < OKIM6295_VOICES; i++) + state_save_register_device_item(this, 0, m_command); + state_save_register_device_item(this, 0, m_bank_offs); + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) { - struct ADPCMVoice *voice = &chip->voice[i]; - stream_sample_t *buffer = outputs[0]; - INT16 sample_data[MAX_SAMPLE_CHUNK]; - int remaining = samples; - - /* loop while we have samples remaining */ - while (remaining) - { - int samples = (remaining > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : remaining; - int samp; - - generate_adpcm(chip, voice, sample_data, samples); - for (samp = 0; samp < samples; samp++) - *buffer++ += sample_data[samp]; - - remaining -= samples; - } + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_playing); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_sample); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_count); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_adpcm.m_signal); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_adpcm.m_step); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_volume); + state_save_register_device_item(this, voicenum, m_voice[voicenum].m_base_offset); } } +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- -/********************************************************************************************** - - state save support for MAME - -***********************************************************************************************/ - -static void adpcm_state_save_register(struct ADPCMVoice *voice, running_device *device, int index) -{ - state_save_register_device_item(device, index, voice->playing); - state_save_register_device_item(device, index, voice->sample); - state_save_register_device_item(device, index, voice->count); - state_save_register_device_item(device, index, voice->adpcm.signal); - state_save_register_device_item(device, index, voice->adpcm.step); - state_save_register_device_item(device, index, voice->volume); - state_save_register_device_item(device, index, voice->base_offset); -} - -static STATE_POSTLOAD( okim6295_postload ) +void okim6295_device::device_reset() { - running_device *device = (running_device *)param; - okim6295_state *info = get_safe_token(device); - okim6295_set_bank_base(device, info->bank_offs); + stream_update(m_stream); + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) + m_voice[voicenum].m_playing = false; } -static void okim6295_state_save_register(okim6295_state *info, running_device *device) -{ - int j; - state_save_register_device_item(device, 0, info->command); - state_save_register_device_item(device, 0, info->bank_offs); - for (j = 0; j < OKIM6295_VOICES; j++) - adpcm_state_save_register(&info->voice[j], device, j); +//------------------------------------------------- +// device_post_load - device-specific post-load +//------------------------------------------------- - state_save_register_postload(device->machine, okim6295_postload, (void *)device); +void okim6295_device::device_post_load() +{ + set_bank_base(m_bank_offs); } +//------------------------------------------------- +// device_clock_changed - called if the clock +// changes +//------------------------------------------------- -/********************************************************************************************** - - DEVICE_START( okim6295 ) -- start emulation of an OKIM6295-compatible chip - -***********************************************************************************************/ - -static DEVICE_START( okim6295 ) +void okim6295_device::device_clock_changed() { - const okim6295_interface *intf = (const okim6295_interface *)device->baseconfig().static_config; - okim6295_state *info = get_safe_token(device); - int divisor = intf->pin7 ? 132 : 165; - int voice; - - compute_tables(); - - info->command = -1; - info->bank_installed = FALSE; - info->bank_offs = 0; - info->device = device; - - info->master_clock = device->clock; - - /* generate the name and create the stream */ - info->stream = stream_create(device, 0, 1, device->clock/divisor, info, okim6295_update); - - /* initialize the voices */ - for (voice = 0; voice < OKIM6295_VOICES; voice++) - { - /* initialize the rest of the structure */ - info->voice[voice].volume = 0; - reset_adpcm(&info->voice[voice].adpcm); - } - - okim6295_state_save_register(info, device); + int divisor = m_pin7_state ? 132 : 165; + stream_set_sample_rate(m_stream, clock() / divisor); } +//------------------------------------------------- +// stream_generate - handle update requests for +// our sound stream +//------------------------------------------------- -/********************************************************************************************** - - DEVICE_RESET( okim6295 ) -- stop emulation of an OKIM6295-compatible chip - -***********************************************************************************************/ - -static DEVICE_RESET( okim6295 ) +STREAM_UPDATE( okim6295_device::static_stream_generate ) { - okim6295_state *info = get_safe_token(device); - int i; - - stream_update(info->stream); - for (i = 0; i < OKIM6295_VOICES; i++) - info->voice[i].playing = 0; + reinterpret_cast(param)->stream_generate(inputs, outputs, samples); } +void okim6295_device::stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples) +{ + // reset the output stream + memset(outputs[0], 0, samples * sizeof(*outputs[0])); + // iterate over voices and accumulate sample data + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) + m_voice[voicenum].generate_adpcm(space(), outputs[0], samples); +} -/********************************************************************************************** - - okim6295_set_bank_base -- set the base of the bank for a given voice on a given chip -***********************************************************************************************/ +//------------------------------------------------- +// set_bank_base - old-style bank management; +// assumes multiple 256k banks +//------------------------------------------------- -void okim6295_set_bank_base(running_device *device, int base) +void okim6295_device::set_bank_base(offs_t base) { - okim6295_state *info = get_safe_token(device); - stream_update(info->stream); + // flush out anything pending + stream_update(m_stream); - /* if we are setting a non-zero base, and we have no bank, allocate one */ - if (!info->bank_installed && base != 0) + // if we are setting a non-zero base, and we have no bank, allocate one + if (!m_bank_installed && base != 0) { - /* override our memory map with a bank */ - memory_install_read_bank(device->space(), 0x00000, 0x3ffff, 0, 0, device->tag()); - info->bank_installed = TRUE; + // override our memory map with a bank + memory_install_read_bank(space(), 0x00000, 0x3ffff, 0, 0, tag()); + m_bank_installed = true; } - /* if we have a bank number, set the base pointer */ - if (info->bank_installed) + // if we have a bank number, set the base pointer + if (m_bank_installed) { - info->bank_offs = base; - memory_set_bankptr(device->machine, device->tag(), device->region->base.u8 + base); + m_bank_offs = base; + memory_set_bankptr(&m_machine, tag(), m_region->base.u8 + base); } } +//------------------------------------------------- +// set_pin7 - change the state of pin 7, which +// alters the frequency we output +//------------------------------------------------- -/********************************************************************************************** - - okim6295_set_pin7 -- adjust pin 7, which controls the internal clock division - -***********************************************************************************************/ - -void okim6295_set_pin7(running_device *device, int pin7) +void okim6295_device::set_pin7(int pin7) { - okim6295_state *info = get_safe_token(device); - int divisor = pin7 ? 132 : 165; - - stream_set_sample_rate(info->stream, info->master_clock/divisor); + m_pin7_state = pin7; + device_clock_changed(); } -/********************************************************************************************** - - okim6295_status_r -- read the status port of an OKIM6295-compatible chip - -***********************************************************************************************/ +//------------------------------------------------- +// status_read - read the status register +//------------------------------------------------- READ8_DEVICE_HANDLER( okim6295_r ) { - okim6295_state *info = get_safe_token(device); - int i, result; - - result = 0xf0; /* naname expects bits 4-7 to be 1 */ + return downcast(device)->status_read(); +} - /* set the bit to 1 if something is playing on a given channel */ - stream_update(info->stream); - for (i = 0; i < OKIM6295_VOICES; i++) - { - struct ADPCMVoice *voice = &info->voice[i]; +UINT8 okim6295_device::status_read() +{ + UINT8 result = 0xf0; // naname expects bits 4-7 to be 1 - /* set the bit if it's playing */ - if (voice->playing) - result |= 1 << i; - } + // set the bit to 1 if something is playing on a given channel + stream_update(m_stream); + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++) + if (m_voice[voicenum].m_playing) + result |= 1 << voicenum; return result; } - -/********************************************************************************************** - - okim6295_data_w -- write to the data port of an OKIM6295-compatible chip - -***********************************************************************************************/ +//------------------------------------------------- +// data_write - write to the command/data register +//------------------------------------------------- WRITE8_DEVICE_HANDLER( okim6295_w ) { - okim6295_state *info = get_safe_token(device); + downcast(device)->data_write(data); +} - /* if a command is pending, process the second half */ - if (info->command != -1) +void okim6295_device::data_write(UINT8 data) +{ + // if a command is pending, process the second half + if (m_command != -1) { - int temp = data >> 4, i, start, stop; - offs_t base; - - /* the manual explicitly says that it's not possible to start multiple voices at the same time */ - if (temp != 0 && temp != 1 && temp != 2 && temp != 4 && temp != 8) - popmessage("OKI6295 start %x contact MAMEDEV", temp); + // the manual explicitly says that it's not possible to start multiple voices at the same time + int voicemask = data >> 4; + if (voicemask != 0 && voicemask != 1 && voicemask != 2 && voicemask != 4 && voicemask != 8) + popmessage("OKI6295 start %x contact MAMEDEV", voicemask); - /* update the stream */ - stream_update(info->stream); + // update the stream + stream_update(m_stream); - /* determine which voice(s) (voice is set by a 1 bit in the upper 4 bits of the second byte) */ - for (i = 0; i < OKIM6295_VOICES; i++, temp >>= 1) - { - if (temp & 1) + // determine which voice(s) (voice is set by a 1 bit in the upper 4 bits of the second byte) + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++, voicemask >>= 1) + if (voicemask & 1) { - struct ADPCMVoice *voice = &info->voice[i]; + okim_voice &voice = m_voice[voicenum]; - /* determine the start/stop positions */ - base = info->command * 8; + // determine the start/stop positions + offs_t base = m_command * 8; - start = memory_raw_read_byte(device->space(), base + 0) << 16; - start |= memory_raw_read_byte(device->space(), base + 1) << 8; - start |= memory_raw_read_byte(device->space(), base + 2) << 0; + offs_t start = memory_raw_read_byte(space(), base + 0) << 16; + start |= memory_raw_read_byte(space(), base + 1) << 8; + start |= memory_raw_read_byte(space(), base + 2) << 0; start &= 0x3ffff; - stop = memory_raw_read_byte(device->space(), base + 3) << 16; - stop |= memory_raw_read_byte(device->space(), base + 4) << 8; - stop |= memory_raw_read_byte(device->space(), base + 5) << 0; + offs_t stop = memory_raw_read_byte(space(), base + 3) << 16; + stop |= memory_raw_read_byte(space(), base + 4) << 8; + stop |= memory_raw_read_byte(space(), base + 5) << 0; stop &= 0x3ffff; - /* set up the voice to play this sample */ + // set up the voice to play this sample if (start < stop) { - if (!voice->playing) /* fixes Got-cha and Steel Force */ + if (!voice.m_playing) // fixes Got-cha and Steel Force { - voice->playing = 1; - voice->base_offset = start; - voice->sample = 0; - voice->count = 2 * (stop - start + 1); - - /* also reset the ADPCM parameters */ - reset_adpcm(&voice->adpcm); - voice->volume = volume_table[data & 0x0f]; + voice.m_playing = true; + voice.m_base_offset = start; + voice.m_sample = 0; + voice.m_count = 2 * (stop - start + 1); + + // also reset the ADPCM parameters + voice.m_adpcm.reset(); + voice.m_volume = s_volume_table[data & 0x0f]; } else - { - logerror("OKIM6295:'%s' requested to play sample %02x on non-stopped voice\n",device->tag(),info->command); - } + logerror("OKIM6295:'%s' requested to play sample %02x on non-stopped voice\n",tag(),m_command); } - /* invalid samples go here */ + + // invalid samples go here else { - logerror("OKIM6295:'%s' requested to play invalid sample %02x\n",device->tag(),info->command); - voice->playing = 0; + logerror("OKIM6295:'%s' requested to play invalid sample %02x\n",tag(),m_command); + voice.m_playing = false; } } - } - /* reset the command */ - info->command = -1; + // reset the command + m_command = -1; } - /* if this is the start of a command, remember the sample number for next time */ + // if this is the start of a command, remember the sample number for next time else if (data & 0x80) + m_command = data & 0x7f; + + // otherwise, see if this is a silence command + else { - info->command = data & 0x7f; + // update the stream, then turn it off + stream_update(m_stream); + + // determine which voice(s) (voice is set by a 1 bit in bits 3-6 of the command + int voicemask = data >> 3; + for (int voicenum = 0; voicenum < OKIM6295_VOICES; voicenum++, voicemask >>= 1) + if (voicemask & 1) + m_voice[voicenum].m_playing = false; } +} - /* otherwise, see if this is a silence command */ - else + + +//************************************************************************** +// OKIM VOICE +//************************************************************************** + +//------------------------------------------------- +// okim_voice - constructor +//------------------------------------------------- + +okim6295_device::okim_voice::okim_voice() + : m_playing(false), + m_base_offset(0), + m_sample(0), + m_count(0), + m_volume(0) +{ +} + + +//------------------------------------------------- +// generate_adpcm - generate ADPCM samples and +// add them to an output stream +//------------------------------------------------- + +void okim6295_device::okim_voice::generate_adpcm(const address_space *space, stream_sample_t *buffer, int samples) +{ + // skip if not active + if (!m_playing) + return; + + // loop while we still have samples to generate + while (samples-- != 0) { - int temp = data >> 3, i; + // fetch the next sample byte + int nibble = memory_raw_read_byte(space, m_base_offset + m_sample / 2) >> (((m_sample & 1) << 2) ^ 4); - /* update the stream, then turn it off */ - stream_update(info->stream); + // output to the buffer, scaling by the volume + // signal in range -2048..2047, volume in range 2..32 => signal * volume / 2 in range -32768..32767 + *buffer++ += m_adpcm.clock(nibble) * m_volume / 2; - /* determine which voice(s) (voice is set by a 1 bit in bits 3-6 of the command */ - for (i = 0; i < OKIM6295_VOICES; i++, temp >>= 1) + // next! + if (++m_sample >= m_count) { - if (temp & 1) - { - struct ADPCMVoice *voice = &info->voice[i]; - - voice->playing = 0; - } + m_playing = false; + break; } } } -/************************************************************************** - * Generic get_info - **************************************************************************/ +//************************************************************************** +// ADPCM STATE HELPER +//************************************************************************** + +//------------------------------------------------- +// reset - reset the ADPCM state +//------------------------------------------------- + +void adpcm_state::reset() +{ + // reset the signal/step + m_signal = -2; + m_step = 0; +} + -DEVICE_GET_INFO( okim6295 ) +//------------------------------------------------- +// device_clock_changed - called if the clock +// changes +//------------------------------------------------- + +INT16 adpcm_state::clock(UINT8 nibble) { - switch (state) + // update the signal + m_signal += s_diff_lookup[m_step * 16 + (nibble & 15)]; + + // clamp to the maximum + if (m_signal > 2047) + m_signal = 2047; + else if (m_signal < -2048) + m_signal = -2048; + + // adjust the step size and clamp + m_step += s_index_shift[nibble & 7]; + if (m_step > 48) + m_step = 48; + else if (m_step < 0) + m_step = 0; + + // return the signal + return m_signal; +} + + +//------------------------------------------------- +// compute_tables - precompute tables for faster +// sound generation +//------------------------------------------------- + +void adpcm_state::compute_tables() +{ + // skip if we already did it + if (s_tables_computed) + return; + s_tables_computed = true; + + // nibble to bit map + static const INT8 nbl2bit[16][4] = + { + { 1, 0, 0, 0}, { 1, 0, 0, 1}, { 1, 0, 1, 0}, { 1, 0, 1, 1}, + { 1, 1, 0, 0}, { 1, 1, 0, 1}, { 1, 1, 1, 0}, { 1, 1, 1, 1}, + {-1, 0, 0, 0}, {-1, 0, 0, 1}, {-1, 0, 1, 0}, {-1, 0, 1, 1}, + {-1, 1, 0, 0}, {-1, 1, 0, 1}, {-1, 1, 1, 0}, {-1, 1, 1, 1} + }; + + // loop over all possible steps + for (int step = 0; step <= 48; step++) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(okim6295_state); break; - case DEVINFO_INT_DATABUS_WIDTH_0: info->i = 8; break; - case DEVINFO_INT_ADDRBUS_WIDTH_0: info->i = 18; break; - case DEVINFO_INT_ADDRBUS_SHIFT_0: info->i = 0; break; - - /* --- the following bits of info are returned as pointers to data --- */ - case DEVINFO_PTR_DEFAULT_MEMORY_MAP_0: info->default_map8 = ADDRESS_MAP_NAME(okim6295);break; - - /* --- the following bits of info are returned as pointers to functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( okim6295 ); break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( okim6295 ); break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "OKI6295"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "OKI ADPCM"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + // compute the step value + int stepval = floor(16.0 * pow(11.0 / 10.0, (double)step)); + + // loop over all nibbles and compute the difference + for (int nib = 0; nib < 16; nib++) + { + s_diff_lookup[step*16 + nib] = nbl2bit[nib][0] * + (stepval * nbl2bit[nib][1] + + stepval/2 * nbl2bit[nib][2] + + stepval/4 * nbl2bit[nib][3] + + stepval/8); + } } } diff --git a/src/emu/sound/okim6295.h b/src/emu/sound/okim6295.h index f5b5b566eff..b0ead224399 100644 --- a/src/emu/sound/okim6295.h +++ b/src/emu/sound/okim6295.h @@ -1,44 +1,186 @@ +/*************************************************************************** + + okim6295.h + + OKIM 6295 ADCPM sound chip. + +***************************************************************************/ + #pragma once #ifndef __OKIM6295_H__ #define __OKIM6295_H__ -/* an interface for the OKIM6295 and similar chips */ +#include "streams.h" + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** -/* - Note about the playback frequency: the external clock is internally divided, - depending on pin 7, by 132 (high) or 165 (low). -*/ -typedef struct _okim6295_interface okim6295_interface; -struct _okim6295_interface +enum { - int pin7; + OKIM6295_PIN7_LOW = 0, + OKIM6295_PIN7_HIGH = 1 }; -extern const okim6295_interface okim6295_interface_pin7high; -extern const okim6295_interface okim6295_interface_pin7low; +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** -void okim6295_set_bank_base(running_device *device, int base); -void okim6295_set_pin7(running_device *device, int pin7); +#define MDRV_OKIM6295_ADD(_tag, _clock, _pin7) \ + MDRV_DEVICE_ADD(_tag, SOUND_OKIM6295, _clock) \ + MDRV_OKIM6295_PIN7(_pin7) -READ8_DEVICE_HANDLER( okim6295_r ); -WRITE8_DEVICE_HANDLER( okim6295_w ); +#define MDRV_OKIM6295_REPLACE(_tag, _clock, _pin7) \ + MDRV_DEVICE_REPLACE(_tag, SOUND_OKIM6295, _clock) \ + MDRV_OKIM6295_PIN7(_pin7) + +#define MDRV_OKIM6295_PIN7(_pin7) \ + MDRV_DEVICE_INLINE_DATA16(okim6295_device_config::INLINE_PIN7, _pin7) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -/* - To help the various custom ADPCM generators out there, - the following routines may be used. -*/ -struct adpcm_state + +// ======================> adpcm_state + +// Internal ADPCM state, used by external ADPCM generators with compatible specs to the OKIM 6295. +class adpcm_state { - INT32 signal; - INT32 step; +public: + adpcm_state() { compute_tables(); reset(); } + + void reset(); + INT16 clock(UINT8 nibble); + + INT32 m_signal; + INT32 m_step; + +private: + static const INT8 s_index_shift[8]; + static int s_diff_lookup[49*16]; + + static void compute_tables(); + static bool s_tables_computed; }; -void reset_adpcm(struct adpcm_state *state); -INT16 clock_adpcm(struct adpcm_state *state, UINT8 nibble); -DEVICE_GET_INFO( okim6295 ); -#define SOUND_OKIM6295 DEVICE_GET_INFO_NAME( okim6295 ) + + +// ======================> okim6295_device_config + +class okim6295_device_config : public device_config, + public device_config_sound_interface, + public device_config_memory_interface +{ + friend class okim6295_device; + + // construction/destruction + okim6295_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "OKI6295"; } + + // inline configuration indexes + enum + { + INLINE_PIN7 + }; + +protected: + // device_config overrides + virtual void device_config_complete(); + virtual const address_space_config *memory_space_config(int spacenum = 0) const; + + // internal state + const address_space_config m_space_config; + UINT8 m_pin7; +}; + + + +// ======================> okim6295_device + +class okim6295_device : public device_t, + public device_sound_interface, + public device_memory_interface +{ + friend class okim6295_device_config; + + // construction/destruction + okim6295_device(running_machine &_machine, const okim6295_device_config &config); + +public: + void set_bank_base(offs_t base); + void set_pin7(int pin7); + + UINT8 status_read(); + void data_write(UINT8 data); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_post_load(); + virtual void device_clock_changed(); + + // internal callbacks + static STREAM_UPDATE( static_stream_generate ); + virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples); + + // a single voice + class okim_voice + { + public: + okim_voice(); + void generate_adpcm(const address_space *space, stream_sample_t *buffer, int samples); + + adpcm_state m_adpcm; // current ADPCM state + bool m_playing; + offs_t m_base_offset; // pointer to the base memory location + UINT32 m_sample; // current sample number + UINT32 m_count; // total samples to play + INT8 m_volume; // output volume + }; + + // internal state + static const int OKIM6295_VOICES = 4; + + const okim6295_device_config &m_config; + + okim_voice m_voice[OKIM6295_VOICES]; + INT32 m_command; + bool m_bank_installed; + offs_t m_bank_offs; + sound_stream * m_stream; + UINT8 m_pin7_state; + + static const UINT8 s_volume_table[16]; +}; + + +// device type definition +const device_type SOUND_OKIM6295 = okim6295_device_config::static_alloc_device_config; + + + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + +READ8_DEVICE_HANDLER( okim6295_r ); +WRITE8_DEVICE_HANDLER( okim6295_w ); + #endif /* __OKIM6295_H__ */ diff --git a/src/emu/sound/okim6376.c b/src/emu/sound/okim6376.c index 67495e6729d..719f1ed29e1 100644 --- a/src/emu/sound/okim6376.c +++ b/src/emu/sound/okim6376.c @@ -66,10 +66,8 @@ static int tables_computed = 0; INLINE okim6376_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_OKIM6376); - return (okim6376_state *)device->token; + assert(device->type() == SOUND_OKIM6376); + return (okim6376_state *)downcast(device)->token(); } @@ -305,11 +303,11 @@ static DEVICE_START( okim6376 ) compute_tables(); info->command = -1; - info->region_base = *device->region; - info->master_clock = device->clock; + info->region_base = *device->region(); + info->master_clock = device->clock(); /* generate the name and create the stream */ - info->stream = stream_create(device, 0, 1, device->clock/divisor, info, okim6376_update); + info->stream = stream_create(device, 0, 1, device->clock()/divisor, info, okim6376_update); /* initialize the voices */ for (voice = 0; voice < OKIM6376_VOICES; voice++) diff --git a/src/emu/sound/okim6376.h b/src/emu/sound/okim6376.h index bf38fccc6ec..12346342396 100644 --- a/src/emu/sound/okim6376.h +++ b/src/emu/sound/okim6376.h @@ -3,12 +3,13 @@ #ifndef __OKIM6376_H__ #define __OKIM6376_H__ +#include "devlegcy.h" + /* an interface for the OKIM6376 and similar chips */ READ8_DEVICE_HANDLER( okim6376_r ); WRITE8_DEVICE_HANDLER( okim6376_w ); -DEVICE_GET_INFO( okim6376 ); -#define SOUND_OKIM6376 DEVICE_GET_INFO_NAME( okim6376 ) +DECLARE_LEGACY_SOUND_DEVICE(OKIM6376, okim6376); #endif /* __OKIM6376_H__ */ diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 33192350e38..522f972c3f1 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -525,10 +525,8 @@ static TIMER_CALLBACK( pokey_pot_trigger ); INLINE pokey_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_POKEY); - return (pokey_state *)device->token; + assert(device->type() == SOUND_POKEY); + return (pokey_state *)downcast(device)->token(); } @@ -618,13 +616,13 @@ static void register_for_save(pokey_state *chip, running_device *device) static DEVICE_START( pokey ) { pokey_state *chip = get_safe_token(device); - int sample_rate = device->clock; + int sample_rate = device->clock(); int i; - if (device->baseconfig().static_config) - memcpy(&chip->intf, device->baseconfig().static_config, sizeof(pokey_interface)); + if (device->baseconfig().static_config()) + memcpy(&chip->intf, device->baseconfig().static_config(), sizeof(pokey_interface)); chip->device = device; - chip->clock_period = ATTOTIME_IN_HZ(device->clock); + chip->clock_period = ATTOTIME_IN_HZ(device->clock()); /* calculate the A/D times * In normal, slow mode (SKCTL bit SK_PADDLE is clear) the conversion @@ -633,8 +631,8 @@ static DEVICE_START( pokey ) * In quick mode (SK_PADDLE set) the conversion is done very fast * (takes two scanlines) but the result is not as accurate. */ - chip->ad_time_fast = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000*2/228), FREQ_17_EXACT), device->clock); - chip->ad_time_slow = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000 ), FREQ_17_EXACT), device->clock); + chip->ad_time_fast = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000*2/228), FREQ_17_EXACT), device->clock()); + chip->ad_time_slow = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000 ), FREQ_17_EXACT), device->clock()); /* initialize the poly counters */ poly_init(chip->poly4, 4, 3, 1, 0x00004); @@ -646,7 +644,7 @@ static DEVICE_START( pokey ) rand_init(chip->rand9, 9, 8, 1, 0x00180); rand_init(chip->rand17, 17,16, 1, 0x1c000); - chip->samplerate_24_8 = (device->clock << 8) / sample_rate; + chip->samplerate_24_8 = (device->clock() << 8) / sample_rate; chip->divisor[CHAN1] = 4; chip->divisor[CHAN2] = 4; chip->divisor[CHAN3] = 4; diff --git a/src/emu/sound/pokey.h b/src/emu/sound/pokey.h index 07ef062bbe9..d4f114aa452 100644 --- a/src/emu/sound/pokey.h +++ b/src/emu/sound/pokey.h @@ -19,6 +19,8 @@ #ifndef __POKEY_H__ #define __POKEY_H__ +#include "devlegcy.h" + /* CONSTANT DEFINITIONS */ /* POKEY WRITE LOGICALS */ @@ -88,7 +90,6 @@ void pokey_serin_ready (running_device *device, int after); void pokey_break_w (running_device *device, int shift); void pokey_kbcode_w (running_device *device, int kbcode, int make); -DEVICE_GET_INFO( pokey ); -#define SOUND_POKEY DEVICE_GET_INFO_NAME( pokey ) +DECLARE_LEGACY_SOUND_DEVICE(POKEY, pokey); #endif /* __POKEY_H__ */ diff --git a/src/emu/sound/psx.c b/src/emu/sound/psx.c index 58a2dc3e8e2..63cfb6e4925 100644 --- a/src/emu/sound/psx.c +++ b/src/emu/sound/psx.c @@ -87,10 +87,8 @@ struct psxinfo INLINE struct psxinfo *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_PSXSPU); - return (struct psxinfo *)device->token; + assert(device->type() == SOUND_PSXSPU); + return (struct psxinfo *)downcast(device)->token(); } @@ -279,7 +277,7 @@ static DEVICE_START( psxspu ) int n_effect; int n_channel; - chip->intf = (const psx_spu_interface *)device->baseconfig().static_config; + chip->intf = (const psx_spu_interface *)device->baseconfig().static_config(); chip->device = device; chip->g_p_n_psxram = *(chip->intf->p_psxram); diff --git a/src/emu/sound/psx.h b/src/emu/sound/psx.h index 7444048b670..ff69fd43fd7 100644 --- a/src/emu/sound/psx.h +++ b/src/emu/sound/psx.h @@ -11,6 +11,8 @@ #ifndef __SOUND_PSX_H__ #define __SOUND_PSX_H__ +#include "devlegcy.h" + WRITE32_DEVICE_HANDLER( psx_spu_w ); READ32_DEVICE_HANDLER( psx_spu_r ); WRITE32_DEVICE_HANDLER( psx_spu_delay_w ); @@ -27,7 +29,6 @@ struct _psx_spu_interface void (*spu_install_write_handler)(int,spu_handler); }; -DEVICE_GET_INFO( psxspu ); -#define SOUND_PSXSPU DEVICE_GET_INFO_NAME( psxspu ) +DECLARE_LEGACY_SOUND_DEVICE(PSXSPU, psxspu); #endif /* __SOUND_PSX_H__ */ diff --git a/src/emu/sound/qsound.c b/src/emu/sound/qsound.c index aaae25e64c9..9f8fe9912b2 100644 --- a/src/emu/sound/qsound.c +++ b/src/emu/sound/qsound.c @@ -91,10 +91,8 @@ struct _qsound_state INLINE qsound_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_QSOUND); - return (qsound_state *)device->token; + assert(device->type() == SOUND_QSOUND); + return (qsound_state *)downcast(device)->token(); } @@ -107,8 +105,8 @@ static DEVICE_START( qsound ) qsound_state *chip = get_safe_token(device); int i; - chip->sample_rom = (QSOUND_SRC_SAMPLE *)*device->region; - chip->sample_rom_length = device->region->bytes(); + chip->sample_rom = (QSOUND_SRC_SAMPLE *)*device->region(); + chip->sample_rom_length = device->region()->bytes(); memset(chip->channel, 0, sizeof(chip->channel)); @@ -128,7 +126,7 @@ static DEVICE_START( qsound ) /* Allocate stream */ chip->stream = stream_create( device, 0, 2, - device->clock / QSOUND_CLOCKDIV, + device->clock() / QSOUND_CLOCKDIV, chip, qsound_update ); } diff --git a/src/emu/sound/qsound.h b/src/emu/sound/qsound.h index e729ee7f7d4..d1a04650f55 100644 --- a/src/emu/sound/qsound.h +++ b/src/emu/sound/qsound.h @@ -9,12 +9,13 @@ #ifndef __QSOUND_H__ #define __QSOUND_H__ +#include "devlegcy.h" + #define QSOUND_CLOCK 4000000 /* default 4MHz clock */ WRITE8_DEVICE_HANDLER( qsound_w ); READ8_DEVICE_HANDLER( qsound_r ); -DEVICE_GET_INFO( qsound ); -#define SOUND_QSOUND DEVICE_GET_INFO_NAME( qsound ) +DECLARE_LEGACY_SOUND_DEVICE(QSOUND, qsound); #endif /* __QSOUND_H__ */ diff --git a/src/emu/sound/rf5c400.c b/src/emu/sound/rf5c400.c index 669a131ded9..d38afca6ebe 100644 --- a/src/emu/sound/rf5c400.c +++ b/src/emu/sound/rf5c400.c @@ -97,10 +97,8 @@ enum { INLINE rf5c400_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_RF5C400); - return (rf5c400_state *)device->token; + assert(device->type() == SOUND_RF5C400); + return (rf5c400_state *)downcast(device)->token(); } @@ -244,8 +242,8 @@ static void rf5c400_init_chip(running_device *device, rf5c400_state *info) { int i; - info->rom = *device->region; - info->rom_length = device->region->bytes() / 2; + info->rom = *device->region(); + info->rom_length = device->region()->bytes() / 2; // init volume table { @@ -348,7 +346,7 @@ static void rf5c400_init_chip(running_device *device, rf5c400_state *info) state_save_register_device_item(device, i, info->channels[i].env_scale); } - info->stream = stream_create(device, 0, 2, device->clock/384, info, rf5c400_update); + info->stream = stream_create(device, 0, 2, device->clock()/384, info, rf5c400_update); } diff --git a/src/emu/sound/rf5c400.h b/src/emu/sound/rf5c400.h index 0bfdf6a3812..e5db5809b76 100644 --- a/src/emu/sound/rf5c400.h +++ b/src/emu/sound/rf5c400.h @@ -5,10 +5,11 @@ #ifndef __RF5C400_H__ #define __RF5C400_H__ +#include "devlegcy.h" + READ16_DEVICE_HANDLER( rf5c400_r ); WRITE16_DEVICE_HANDLER( rf5c400_w ); -DEVICE_GET_INFO( rf5c400 ); -#define SOUND_RF5C400 DEVICE_GET_INFO_NAME( rf5c400 ) +DECLARE_LEGACY_SOUND_DEVICE(RF5C400, rf5c400); #endif /* __RF5C400_H__ */ diff --git a/src/emu/sound/rf5c68.c b/src/emu/sound/rf5c68.c index bab1e2cfce6..ea286477321 100644 --- a/src/emu/sound/rf5c68.c +++ b/src/emu/sound/rf5c68.c @@ -40,10 +40,8 @@ struct _rf5c68_state INLINE rf5c68_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_RF5C68); - return (rf5c68_state *)device->token; + assert(device->type() == SOUND_RF5C68); + return (rf5c68_state *)downcast(device)->token(); } @@ -142,13 +140,13 @@ static STREAM_UPDATE( rf5c68_update ) static DEVICE_START( rf5c68 ) { - const rf5c68_interface* intf = (const rf5c68_interface*)device->baseconfig().static_config; + const rf5c68_interface* intf = (const rf5c68_interface*)device->baseconfig().static_config(); /* allocate memory for the chip */ rf5c68_state *chip = get_safe_token(device); /* allocate the stream */ - chip->stream = stream_create(device, 0, 2, device->clock / 384, chip, rf5c68_update); + chip->stream = stream_create(device, 0, 2, device->clock() / 384, chip, rf5c68_update); chip->device = device; diff --git a/src/emu/sound/rf5c68.h b/src/emu/sound/rf5c68.h index 7ef02a4aac3..02ef3d52ca8 100644 --- a/src/emu/sound/rf5c68.h +++ b/src/emu/sound/rf5c68.h @@ -7,6 +7,8 @@ #ifndef __RF5C68_H__ #define __RF5C68_H__ +#include "devlegcy.h" + /******************************************/ WRITE8_DEVICE_HANDLER( rf5c68_w ); @@ -19,7 +21,6 @@ struct _rf5c68_interface void (*sample_end_callback)(running_device* device, int channel); }; -DEVICE_GET_INFO( rf5c68 ); -#define SOUND_RF5C68 DEVICE_GET_INFO_NAME( rf5c68 ) +DECLARE_LEGACY_SOUND_DEVICE(RF5C68, rf5c68); #endif /* __RF5C68_H__ */ diff --git a/src/emu/sound/s14001a.c b/src/emu/sound/s14001a.c index eb3166e6f32..3d7bd1012f9 100644 --- a/src/emu/sound/s14001a.c +++ b/src/emu/sound/s14001a.c @@ -268,10 +268,8 @@ typedef struct INLINE S14001AChip *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_S14001A); - return (S14001AChip *)device->token; + assert(device->type() == SOUND_S14001A); + return (S14001AChip *)downcast(device)->token(); } @@ -593,9 +591,9 @@ static DEVICE_START( s14001a ) chip->filtervals[i] = SILENCE; } - chip->SpeechRom = *device->region; + chip->SpeechRom = *device->region(); - chip->stream = stream_create(device, 0, 1, device->clock ? device->clock : device->machine->sample_rate, chip, s14001a_pcm_update); + chip->stream = stream_create(device, 0, 1, device->clock() ? device->clock() : device->machine->sample_rate, chip, s14001a_pcm_update); } int s14001a_bsy_r(running_device *device) diff --git a/src/emu/sound/s14001a.h b/src/emu/sound/s14001a.h index 857d1ea7a18..6e003c66b79 100644 --- a/src/emu/sound/s14001a.h +++ b/src/emu/sound/s14001a.h @@ -3,14 +3,15 @@ #ifndef __S14001A_H__ #define __S14001A_H__ -int s14001a_bsy_r(running_device *device); /* read BUSY pin */ +#include "devlegcy.h" + +int s14001a_bsy_r(running_device *device); /* read BUSY pin */ void s14001a_reg_w(running_device *device, int data); /* write to input latch */ void s14001a_rst_w(running_device *device, int data); /* write to RESET pin */ void s14001a_set_clock(running_device *device, int clock); /* set VSU-1000 clock */ void s14001a_set_volume(running_device *device, int volume); /* set VSU-1000 volume control */ -DEVICE_GET_INFO( s14001a ); -#define SOUND_S14001A DEVICE_GET_INFO_NAME( s14001a ) +DECLARE_LEGACY_SOUND_DEVICE(S14001A, s14001a); #endif /* __S14001A_H__ */ diff --git a/src/emu/sound/saa1099.c b/src/emu/sound/saa1099.c index a3635af8234..3320cee1d0a 100644 --- a/src/emu/sound/saa1099.c +++ b/src/emu/sound/saa1099.c @@ -171,10 +171,8 @@ static const UINT8 envelope[8][64] = { INLINE saa1099_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SAA1099); - return (saa1099_state *)device->token; + assert(device->type() == SOUND_SAA1099); + return (saa1099_state *)downcast(device)->token(); } @@ -327,7 +325,7 @@ static DEVICE_START( saa1099 ) /* copy global parameters */ saa->device = device; - saa->sample_rate = device->clock / 256; + saa->sample_rate = device->clock() / 256; /* for each chip allocate one stream */ saa->stream = stream_create(device, 0, 2, saa->sample_rate, saa, saa1099_update); diff --git a/src/emu/sound/saa1099.h b/src/emu/sound/saa1099.h index f91eba85723..a07db979a76 100644 --- a/src/emu/sound/saa1099.h +++ b/src/emu/sound/saa1099.h @@ -3,6 +3,8 @@ #ifndef __SAA1099_H__ #define __SAA1099_H__ +#include "devlegcy.h" + /********************************************** Philips SAA1099 Sound driver **********************************************/ @@ -10,7 +12,6 @@ WRITE8_DEVICE_HANDLER( saa1099_control_w ); WRITE8_DEVICE_HANDLER( saa1099_data_w ); -DEVICE_GET_INFO( saa1099 ); -#define SOUND_SAA1099 DEVICE_GET_INFO_NAME( saa1099 ) +DECLARE_LEGACY_SOUND_DEVICE(SAA1099, saa1099); #endif /* __SAA1099_H__ */ diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c index b2620b0b8bc..de1e85c8fbe 100644 --- a/src/emu/sound/samples.c +++ b/src/emu/sound/samples.c @@ -33,10 +33,8 @@ struct _samples_info INLINE samples_info *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SAMPLES); - return (samples_info *)device->token; + assert(device->type() == SOUND_SAMPLES); + return (samples_info *)downcast(device)->token(); } @@ -472,7 +470,7 @@ static STATE_POSTLOAD( samples_postload ) static DEVICE_START( samples ) { int i; - const samples_interface *intf = (const samples_interface *)device->baseconfig().static_config; + const samples_interface *intf = (const samples_interface *)device->baseconfig().static_config(); samples_info *info = get_safe_token(device); info->device = device; diff --git a/src/emu/sound/samples.h b/src/emu/sound/samples.h index f50085b158a..3834d75f241 100644 --- a/src/emu/sound/samples.h +++ b/src/emu/sound/samples.h @@ -3,6 +3,8 @@ #ifndef __SAMPLES_H__ #define __SAMPLES_H__ +#include "devlegcy.h" + typedef struct _loaded_sample loaded_sample; struct _loaded_sample { @@ -42,7 +44,6 @@ int sample_playing(running_device *device,int channel); /* drivers as well (e.g. a sound chip emulator needing drum samples) */ loaded_samples *readsamples(running_machine *machine, const char *const *samplenames, const char *name); -DEVICE_GET_INFO( samples ); -#define SOUND_SAMPLES DEVICE_GET_INFO_NAME( samples ) +DECLARE_LEGACY_SOUND_DEVICE(SAMPLES, samples); #endif /* __SAMPLES_H__ */ diff --git a/src/emu/sound/scsp.c b/src/emu/sound/scsp.c index 630ff43e8dc..90882dd95e7 100644 --- a/src/emu/sound/scsp.c +++ b/src/emu/sound/scsp.c @@ -247,10 +247,8 @@ static signed short *RBUFDST; //this points to where the sample will be stored i INLINE SCSP *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SCSP); - return (SCSP *)device->token; + assert(device->type() == SOUND_SCSP); + return (SCSP *)downcast(device)->token(); } static unsigned char DecodeSCI(struct _SCSP *SCSP,unsigned char irq) @@ -541,10 +539,10 @@ static void SCSP_Init(running_device *device, struct _SCSP *SCSP, const scsp_int SCSP->Master=0; } - SCSP->SCSPRAM = *device->region; + SCSP->SCSPRAM = *device->region(); if (SCSP->SCSPRAM) { - SCSP->SCSPRAM_LENGTH = device->region->bytes(); + SCSP->SCSPRAM_LENGTH = device->region()->bytes(); SCSP->DSP.SCSPRAM = (UINT16 *)SCSP->SCSPRAM; SCSP->DSP.SCSPRAM_LENGTH = SCSP->SCSPRAM_LENGTH/2; SCSP->SCSPRAM += intf->roffset; @@ -700,7 +698,7 @@ static void SCSP_UpdateSlotReg(struct _SCSP *SCSP,int s,int r) static void SCSP_UpdateReg(struct _SCSP *SCSP, int reg) { /* temporary hack until this is converted to a device */ - const address_space *space = SCSP->device->machine->firstcpu->space(AS_PROGRAM); + const address_space *space = device_get_space(SCSP->device->machine->firstcpu, AS_PROGRAM); switch(reg&0x3f) { case 0x2: @@ -1244,7 +1242,7 @@ static DEVICE_START( scsp ) struct _SCSP *SCSP = get_safe_token(device); - intf = (const scsp_interface *)device->baseconfig().static_config; + intf = (const scsp_interface *)device->baseconfig().static_config(); // init the emulation SCSP_Init(device, SCSP, intf); diff --git a/src/emu/sound/scsp.h b/src/emu/sound/scsp.h index 998f7ce1a0c..a9cc806dbed 100644 --- a/src/emu/sound/scsp.h +++ b/src/emu/sound/scsp.h @@ -7,6 +7,8 @@ #ifndef __SCSP_H__ #define __SCSP_H__ +#include "devlegcy.h" + typedef struct _scsp_interface scsp_interface; struct _scsp_interface { @@ -26,7 +28,6 @@ READ16_DEVICE_HANDLER( scsp_midi_out_r ); extern UINT32* stv_scu; -DEVICE_GET_INFO( scsp ); -#define SOUND_SCSP DEVICE_GET_INFO_NAME( scsp ) +DECLARE_LEGACY_SOUND_DEVICE(SCSP, scsp); #endif /* __SCSP_H__ */ diff --git a/src/emu/sound/segapcm.c b/src/emu/sound/segapcm.c index 7ef550ad41e..3e2836b2d2c 100644 --- a/src/emu/sound/segapcm.c +++ b/src/emu/sound/segapcm.c @@ -21,10 +21,8 @@ struct _segapcm_state INLINE segapcm_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SEGAPCM); - return (segapcm_state *)device->token; + assert(device->type() == SOUND_SEGAPCM); + return (segapcm_state *)downcast(device)->token(); } static STREAM_UPDATE( SEGAPCM_update ) @@ -90,11 +88,11 @@ static STREAM_UPDATE( SEGAPCM_update ) static DEVICE_START( segapcm ) { - const sega_pcm_interface *intf = (const sega_pcm_interface *)device->baseconfig().static_config; + const sega_pcm_interface *intf = (const sega_pcm_interface *)device->baseconfig().static_config(); int mask, rom_mask, len; segapcm_state *spcm = get_safe_token(device); - spcm->rom = *device->region; + spcm->rom = *device->region(); spcm->ram = auto_alloc_array(device->machine, UINT8, 0x800); memset(spcm->ram, 0xff, 0x800); @@ -104,7 +102,7 @@ static DEVICE_START( segapcm ) if(!mask) mask = BANK_MASK7>>16; - len = device->region->bytes(); + len = device->region()->bytes(); spcm->rgnmask = len - 1; for(rom_mask = 1; rom_mask < len; rom_mask *= 2); @@ -113,7 +111,7 @@ static DEVICE_START( segapcm ) spcm->bankmask = mask & (rom_mask >> spcm->bankshift); - spcm->stream = stream_create(device, 0, 2, device->clock / 128, spcm, SEGAPCM_update); + spcm->stream = stream_create(device, 0, 2, device->clock() / 128, spcm, SEGAPCM_update); state_save_register_device_item_array(device, 0, spcm->low); state_save_register_device_item_pointer(device, 0, spcm->ram, 0x800); diff --git a/src/emu/sound/segapcm.h b/src/emu/sound/segapcm.h index d23a13e88dc..c3b0998ee7f 100644 --- a/src/emu/sound/segapcm.h +++ b/src/emu/sound/segapcm.h @@ -7,6 +7,8 @@ #ifndef __SEGAPCM_H__ #define __SEGAPCM_H__ +#include "devlegcy.h" + #define BANK_256 (11) #define BANK_512 (12) #define BANK_12M (13) @@ -23,7 +25,6 @@ struct _sega_pcm_interface WRITE8_DEVICE_HANDLER( sega_pcm_w ); READ8_DEVICE_HANDLER( sega_pcm_r ); -DEVICE_GET_INFO( segapcm ); -#define SOUND_SEGAPCM DEVICE_GET_INFO_NAME( segapcm ) +DECLARE_LEGACY_SOUND_DEVICE(SEGAPCM, segapcm); #endif /* __SEGAPCM_H__ */ diff --git a/src/emu/sound/sid6581.c b/src/emu/sound/sid6581.c index 2eb966e5b91..b7861311474 100644 --- a/src/emu/sound/sid6581.c +++ b/src/emu/sound/sid6581.c @@ -15,8 +15,8 @@ static SID6581 *get_sid(running_device *device) { assert(device != NULL); - assert((sound_get_type(device) == SOUND_SID6581) || (sound_get_type(device) == SOUND_SID8580)); - return (SID6581 *) device->token; + assert((device->type() == SOUND_SID6581) || (device->type() == SOUND_SID8580)); + return (SID6581 *) downcast(device)->token(); } @@ -32,12 +32,12 @@ static STREAM_UPDATE( sid_update ) static void sid_start(running_device *device, SIDTYPE sidtype) { SID6581 *sid = get_sid(device); - const sid6581_interface *iface = (const sid6581_interface*) device->baseconfig().static_config; + const sid6581_interface *iface = (const sid6581_interface*) device->baseconfig().static_config(); sid->device = device; sid->mixer_channel = stream_create (device, 0, 1, device->machine->sample_rate, (void *) sid, sid_update); sid->PCMfreq = device->machine->sample_rate; - sid->clock = device->clock; + sid->clock = device->clock(); sid->ad_read = iface ? iface->ad_read : NULL; sid->type = sidtype; diff --git a/src/emu/sound/sid6581.h b/src/emu/sound/sid6581.h index 8da7ef2cd3e..32543f07183 100644 --- a/src/emu/sound/sid6581.h +++ b/src/emu/sound/sid6581.h @@ -11,6 +11,8 @@ #ifndef __SID6581_H__ #define __SID6581_H__ +#include "devlegcy.h" + typedef enum { @@ -29,9 +31,7 @@ struct _sid6581_interface READ8_DEVICE_HANDLER ( sid6581_r ); WRITE8_DEVICE_HANDLER ( sid6581_w ); -DEVICE_GET_INFO( sid6581 ); -DEVICE_GET_INFO( sid8580 ); -#define SOUND_SID6581 DEVICE_GET_INFO_NAME( sid6581 ) -#define SOUND_SID8580 DEVICE_GET_INFO_NAME( sid8580 ) +DECLARE_LEGACY_SOUND_DEVICE(SID6581, sid6581); +DECLARE_LEGACY_SOUND_DEVICE(SID8580, sid8580); #endif /* __SID6581_H__ */ diff --git a/src/emu/sound/sn76477.c b/src/emu/sound/sn76477.c index a114183d304..82170c8a499 100644 --- a/src/emu/sound/sn76477.c +++ b/src/emu/sound/sn76477.c @@ -264,10 +264,8 @@ struct _sn76477_state INLINE sn76477_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SN76477); - return (sn76477_state *)device->token; + assert(device->type() == SOUND_SN76477); + return (sn76477_state *)downcast(device)->token(); } @@ -2401,7 +2399,7 @@ static DEVICE_START( sn76477 ) #if TEST_MODE == 0 - intf = (sn76477_interface *)device->baseconfig().static_config; + intf = (sn76477_interface *)device->baseconfig().static_config(); #else intf = &test_interface; #endif @@ -2411,9 +2409,9 @@ static DEVICE_START( sn76477 ) sn->channel = stream_create(device, 0, 1, device->machine->sample_rate, sn, SN76477_update); - if (device->clock > 0) + if (device->clock() > 0) { - sn->sample_rate = device->clock; + sn->sample_rate = device->clock(); } else { diff --git a/src/emu/sound/sn76477.h b/src/emu/sound/sn76477.h index 45c9120b751..5ff843bed5c 100644 --- a/src/emu/sound/sn76477.h +++ b/src/emu/sound/sn76477.h @@ -38,6 +38,7 @@ #ifndef __SN76477_H__ #define __SN76477_H__ +#include "devlegcy.h" #include "machine/rescap.h" @@ -124,7 +125,6 @@ void sn76477_attack_decay_cap_voltage_w(running_device *device, double data); void sn76477_vco_voltage_w(running_device *device, double data); void sn76477_pitch_voltage_w(running_device *device, double data); -DEVICE_GET_INFO( sn76477 ); -#define SOUND_SN76477 DEVICE_GET_INFO_NAME( sn76477 ) +DECLARE_LEGACY_SOUND_DEVICE(SN76477, sn76477); #endif/* __SN76477_H__ */ diff --git a/src/emu/sound/sn76496.c b/src/emu/sound/sn76496.c index 729c79b7a89..408c2b2b3e8 100644 --- a/src/emu/sound/sn76496.c +++ b/src/emu/sound/sn76496.c @@ -138,17 +138,15 @@ struct _sn76496_state INLINE sn76496_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SN76496 || - sound_get_type(device) == SOUND_SN76489 || - sound_get_type(device) == SOUND_SN76489A || - sound_get_type(device) == SOUND_SN76494 || - sound_get_type(device) == SOUND_SN94624 || - sound_get_type(device) == SOUND_NCR7496 || - sound_get_type(device) == SOUND_GAMEGEAR || - sound_get_type(device) == SOUND_SMSIII); - return (sn76496_state *)device->token; + assert(device->type() == SOUND_SN76496 || + device->type() == SOUND_SN76489 || + device->type() == SOUND_SN76489A || + device->type() == SOUND_SN76494 || + device->type() == SOUND_SN94624 || + device->type() == SOUND_NCR7496 || + device->type() == SOUND_GAMEGEAR || + device->type() == SOUND_SMSIII); + return (sn76496_state *)downcast(device)->token(); } READ8_DEVICE_HANDLER( sn76496_ready_r ) @@ -346,7 +344,7 @@ static void SN76496_set_gain(sn76496_state *R,int gain) static int SN76496_init(running_device *device, sn76496_state *R, int stereo) { - int sample_rate = device->clock/2; + int sample_rate = device->clock()/2; int i; R->Channel = stream_create(device,0,(stereo?2:1),sample_rate,R,SN76496Update); diff --git a/src/emu/sound/sn76496.h b/src/emu/sound/sn76496.h index 67c68fb8418..2ae347be60f 100644 --- a/src/emu/sound/sn76496.h +++ b/src/emu/sound/sn76496.h @@ -3,26 +3,19 @@ #ifndef __SN76496_H__ #define __SN76496_H__ +#include "devlegcy.h" + READ8_DEVICE_HANDLER( sn76496_ready_r ); WRITE8_DEVICE_HANDLER( sn76496_w ); WRITE8_DEVICE_HANDLER( sn76496_stereo_w ); -DEVICE_GET_INFO( sn76496 ); -DEVICE_GET_INFO( sn76489 ); -DEVICE_GET_INFO( sn76489a ); -DEVICE_GET_INFO( sn76494 ); -DEVICE_GET_INFO( sn94624 ); -DEVICE_GET_INFO( ncr7496 ); -DEVICE_GET_INFO( gamegear ); -DEVICE_GET_INFO( smsiii ); - -#define SOUND_SN76496 DEVICE_GET_INFO_NAME( sn76496 ) -#define SOUND_SN76489 DEVICE_GET_INFO_NAME( sn76489 ) -#define SOUND_SN76489A DEVICE_GET_INFO_NAME( sn76489a ) -#define SOUND_SN76494 DEVICE_GET_INFO_NAME( sn76494 ) -#define SOUND_SN94624 DEVICE_GET_INFO_NAME( sn94624 ) -#define SOUND_NCR7496 DEVICE_GET_INFO_NAME( ncr7496 ) -#define SOUND_GAMEGEAR DEVICE_GET_INFO_NAME( gamegear ) -#define SOUND_SMSIII DEVICE_GET_INFO_NAME( smsiii ) +DECLARE_LEGACY_SOUND_DEVICE(SN76496, sn76496); +DECLARE_LEGACY_SOUND_DEVICE(SN76489, sn76489); +DECLARE_LEGACY_SOUND_DEVICE(SN76489A, sn76489a); +DECLARE_LEGACY_SOUND_DEVICE(SN76494, sn76494); +DECLARE_LEGACY_SOUND_DEVICE(SN94624, sn94624); +DECLARE_LEGACY_SOUND_DEVICE(NCR7496, ncr7496); +DECLARE_LEGACY_SOUND_DEVICE(GAMEGEAR, gamegear); +DECLARE_LEGACY_SOUND_DEVICE(SMSIII, smsiii); #endif /* __SN76496_H__ */ diff --git a/src/emu/sound/snkwave.c b/src/emu/sound/snkwave.c index 77f88c37d72..14a3d31e661 100644 --- a/src/emu/sound/snkwave.c +++ b/src/emu/sound/snkwave.c @@ -36,10 +36,8 @@ struct _snkwave_state INLINE snkwave_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SNKWAVE); - return (snkwave_state *)device->token; + assert(device->type() == SOUND_SNKWAVE); + return (snkwave_state *)downcast(device)->token(); } @@ -113,10 +111,10 @@ static DEVICE_START( snkwave ) { snkwave_state *chip = get_safe_token(device); - assert(device->baseconfig().static_config == 0); + assert(device->baseconfig().static_config() == 0); /* adjust internal clock */ - chip->external_clock = device->clock; + chip->external_clock = device->clock(); /* adjust output clock */ chip->sample_rate = chip->external_clock >> CLOCK_SHIFT; diff --git a/src/emu/sound/snkwave.h b/src/emu/sound/snkwave.h index 043bb6580a1..44e1d163a75 100644 --- a/src/emu/sound/snkwave.h +++ b/src/emu/sound/snkwave.h @@ -3,9 +3,10 @@ #ifndef __SNKWAVE_H__ #define __SNKWAVE_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( snkwave_w ); -DEVICE_GET_INFO( snkwave ); -#define SOUND_SNKWAVE DEVICE_GET_INFO_NAME( snkwave ) +DECLARE_LEGACY_SOUND_DEVICE(SNKWAVE, snkwave); #endif /* __SNKWAVE_H__ */ diff --git a/src/emu/sound/sp0250.c b/src/emu/sound/sp0250.c index 8b56f62c463..17b6bfc6a5f 100644 --- a/src/emu/sound/sp0250.c +++ b/src/emu/sound/sp0250.c @@ -60,10 +60,8 @@ struct _sp0250_state INLINE sp0250_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SP0250); - return (sp0250_state *)device->token; + assert(device->type() == SOUND_SP0250); + return (sp0250_state *)downcast(device)->token(); } @@ -202,7 +200,7 @@ static STREAM_UPDATE( sp0250_update ) static DEVICE_START( sp0250 ) { - const struct sp0250_interface *intf = (const struct sp0250_interface *)device->baseconfig().static_config; + const struct sp0250_interface *intf = (const struct sp0250_interface *)device->baseconfig().static_config(); sp0250_state *sp = get_safe_token(device); sp->device = device; @@ -211,10 +209,10 @@ static DEVICE_START( sp0250 ) if (sp->drq != NULL) { sp->drq(sp->device, ASSERT_LINE); - timer_pulse(device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock), CLOCK_DIVIDER), sp, 0, sp0250_timer_tick); + timer_pulse(device->machine, attotime_mul(ATTOTIME_IN_HZ(device->clock()), CLOCK_DIVIDER), sp, 0, sp0250_timer_tick); } - sp->stream = stream_create(device, 0, 1, device->clock / CLOCK_DIVIDER, sp, sp0250_update); + sp->stream = stream_create(device, 0, 1, device->clock() / CLOCK_DIVIDER, sp, sp0250_update); } diff --git a/src/emu/sound/sp0250.h b/src/emu/sound/sp0250.h index 6acf20f7f97..e3e9b9d1d47 100644 --- a/src/emu/sound/sp0250.h +++ b/src/emu/sound/sp0250.h @@ -3,6 +3,8 @@ #ifndef __SP0250_H__ #define __SP0250_H__ +#include "devlegcy.h" + struct sp0250_interface { void (*drq_callback)(running_device *device, int state); }; @@ -10,7 +12,6 @@ struct sp0250_interface { WRITE8_DEVICE_HANDLER( sp0250_w ); UINT8 sp0250_drq_r(running_device *device); -DEVICE_GET_INFO( sp0250 ); -#define SOUND_SP0250 DEVICE_GET_INFO_NAME( sp0250 ) +DECLARE_LEGACY_SOUND_DEVICE(SP0250, sp0250); #endif /* __SP0250_H__ */ diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index d132239303b..c3b45eb5bd6 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -135,10 +135,8 @@ static const INT16 qtbl[128] = INLINE sp0256_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SP0256); - return (sp0256_state *)device->token; + assert(device->type() == SOUND_SP0256); + return (sp0256_state *)downcast(device)->token(); } @@ -1180,7 +1178,7 @@ static STREAM_UPDATE( sp0256_update ) static DEVICE_START( sp0256 ) { - const sp0256_interface *intf = (const sp0256_interface *)device->baseconfig().static_config; + const sp0256_interface *intf = (const sp0256_interface *)device->baseconfig().static_config(); sp0256_state *sp = get_safe_token(device); sp->device = device; @@ -1189,7 +1187,7 @@ static DEVICE_START( sp0256 ) devcb_call_write_line(&sp->drq, 1); devcb_call_write_line(&sp->sby, 1); - sp->stream = stream_create(device, 0, 1, device->clock / CLOCK_DIVIDER, sp, sp0256_update); + sp->stream = stream_create(device, 0, 1, device->clock() / CLOCK_DIVIDER, sp, sp0256_update); /* -------------------------------------------------------------------- */ /* Configure our internal variables. */ @@ -1214,7 +1212,7 @@ static DEVICE_START( sp0256 ) /* -------------------------------------------------------------------- */ /* Setup the ROM. */ /* -------------------------------------------------------------------- */ - sp->rom = *device->region; + sp->rom = *device->region(); sp0256_bitrevbuff(sp->rom, 0, 0xffff); } diff --git a/src/emu/sound/sp0256.h b/src/emu/sound/sp0256.h index b5c8ca74ed6..324decbf099 100644 --- a/src/emu/sound/sp0256.h +++ b/src/emu/sound/sp0256.h @@ -49,6 +49,8 @@ #ifndef __SP0256_H__ #define __SP0256_H__ +#include "devlegcy.h" + typedef struct _sp0256_interface sp0256_interface; struct _sp0256_interface @@ -64,7 +66,6 @@ WRITE8_DEVICE_HANDLER( sp0256_ALD_w ); READ16_DEVICE_HANDLER( spb640_r ); WRITE16_DEVICE_HANDLER( spb640_w ); -DEVICE_GET_INFO( sp0256 ); -#define SOUND_SP0256 DEVICE_GET_INFO_NAME( sp0256 ) +DECLARE_LEGACY_SOUND_DEVICE(SP0256, sp0256); #endif /* __SP0256_H__ */ diff --git a/src/emu/sound/speaker.c b/src/emu/sound/speaker.c index ced1b85741c..e48306e7d45 100644 --- a/src/emu/sound/speaker.c +++ b/src/emu/sound/speaker.c @@ -129,17 +129,15 @@ static double get_filtered_volume(speaker_state *sp); INLINE speaker_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_SPEAKER); - return (speaker_state *)device->token; + assert(device->type() == SOUND_SPEAKER); + return (speaker_state *)downcast(device)->token(); } static DEVICE_START( speaker ) { speaker_state *sp = get_safe_token(device); - const speaker_interface *intf = (const speaker_interface *) device->baseconfig().static_config; + const speaker_interface *intf = (const speaker_interface *) device->baseconfig().static_config(); int i; double x; diff --git a/src/emu/sound/speaker.h b/src/emu/sound/speaker.h index 1881709ea02..f7136506577 100644 --- a/src/emu/sound/speaker.h +++ b/src/emu/sound/speaker.h @@ -11,9 +11,7 @@ #ifndef __SPEAKER_H__ #define __SPEAKER_H__ -#ifdef __cplusplus -extern "C" { -#endif +#include "devlegcy.h" typedef struct _speaker_interface speaker_interface; @@ -25,12 +23,6 @@ struct _speaker_interface void speaker_level_w (running_device *device, int new_level); -DEVICE_GET_INFO( speaker ); -#define SOUND_SPEAKER DEVICE_GET_INFO_NAME( speaker ) - -#ifdef __cplusplus -} -#endif - +DECLARE_LEGACY_SOUND_DEVICE(SPEAKER, speaker); #endif /* __SPEAKER_H__ */ diff --git a/src/emu/sound/st0016.c b/src/emu/sound/st0016.c index 633fb80b18d..e91562dce9d 100644 --- a/src/emu/sound/st0016.c +++ b/src/emu/sound/st0016.c @@ -22,10 +22,8 @@ struct _st0016_state INLINE st0016_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ST0016); - return (st0016_state *)device->token; + assert(device->type() == SOUND_ST0016); + return (st0016_state *)downcast(device)->token(); } @@ -140,7 +138,7 @@ static STREAM_UPDATE( st0016_update ) static DEVICE_START( st0016 ) { - const st0016_interface *intf = (const st0016_interface *)device->baseconfig().static_config; + const st0016_interface *intf = (const st0016_interface *)device->baseconfig().static_config(); st0016_state *info = get_safe_token(device); info->sound_ram = intf->p_soundram; diff --git a/src/emu/sound/st0016.h b/src/emu/sound/st0016.h index 39d6f734be7..95203ffd2ba 100644 --- a/src/emu/sound/st0016.h +++ b/src/emu/sound/st0016.h @@ -3,6 +3,8 @@ #ifndef __ST0016_H__ #define __ST0016_H__ +#include "devlegcy.h" + typedef struct _st0016_interface st0016_interface; struct _st0016_interface { @@ -12,7 +14,6 @@ struct _st0016_interface READ8_DEVICE_HANDLER( st0016_snd_r ); WRITE8_DEVICE_HANDLER( st0016_snd_w ); -DEVICE_GET_INFO( st0016 ); -#define SOUND_ST0016 DEVICE_GET_INFO_NAME( st0016 ) +DECLARE_LEGACY_SOUND_DEVICE(ST0016, st0016); #endif /* __ST0016_H__ */ diff --git a/src/emu/sound/t6w28.c b/src/emu/sound/t6w28.c index 2e38fc03c59..4242febb1d9 100644 --- a/src/emu/sound/t6w28.c +++ b/src/emu/sound/t6w28.c @@ -61,10 +61,8 @@ struct _t6w28_state INLINE t6w28_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_T6W28); - return (t6w28_state *)device->token; + assert(device->type() == SOUND_T6W28); + return (t6w28_state *)downcast(device)->token(); } @@ -309,7 +307,7 @@ static void t6w28_set_gain(t6w28_state *R,int gain) static int t6w28_init(running_device *device, t6w28_state *R) { - int sample_rate = device->clock/16; + int sample_rate = device->clock()/16; int i; R->Channel = stream_create(device,0,2,sample_rate,R,t6w28_update); diff --git a/src/emu/sound/t6w28.h b/src/emu/sound/t6w28.h index 5abb244f18c..ab73573d38c 100644 --- a/src/emu/sound/t6w28.h +++ b/src/emu/sound/t6w28.h @@ -3,10 +3,10 @@ #ifndef __T6W28_H__ #define __T6W28_H__ -WRITE8_DEVICE_HANDLER( t6w28_w ); +#include "devlegcy.h" -DEVICE_GET_INFO( t6w28 ); +WRITE8_DEVICE_HANDLER( t6w28_w ); -#define SOUND_T6W28 DEVICE_GET_INFO_NAME( t6w28 ) +DECLARE_LEGACY_SOUND_DEVICE(T6W28, t6w28); #endif /* __T6W28_H__ */ diff --git a/src/emu/sound/tiaintf.c b/src/emu/sound/tiaintf.c index 8135ff7fe39..a26d9581809 100644 --- a/src/emu/sound/tiaintf.c +++ b/src/emu/sound/tiaintf.c @@ -13,10 +13,8 @@ struct _tia_state INLINE tia_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_TIA); - return (tia_state *)device->token; + assert(device->type() == SOUND_TIA); + return (tia_state *)downcast(device)->token(); } @@ -31,9 +29,9 @@ static DEVICE_START( tia ) { tia_state *info = get_safe_token(device); - info->channel = stream_create(device, 0, 1, device->clock, info, tia_update); + info->channel = stream_create(device, 0, 1, device->clock(), info, tia_update); - info->chip = tia_sound_init(device->clock, device->clock, 16); + info->chip = tia_sound_init(device->clock(), device->clock(), 16); assert_always(info->chip != NULL, "Error creating TIA chip"); } diff --git a/src/emu/sound/tiaintf.h b/src/emu/sound/tiaintf.h index 571c7420cab..bb8b05cb1c1 100644 --- a/src/emu/sound/tiaintf.h +++ b/src/emu/sound/tiaintf.h @@ -3,9 +3,10 @@ #ifndef __TIAINTF_H__ #define __TIAINTF_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( tia_sound_w ); -DEVICE_GET_INFO( tia ); -#define SOUND_TIA DEVICE_GET_INFO_NAME( tia ) +DECLARE_LEGACY_SOUND_DEVICE(TIA, tia); #endif /* __TIAINTF_H__ */ diff --git a/src/emu/sound/tms3615.c b/src/emu/sound/tms3615.c index d21e998f5f9..6c9f12a468c 100644 --- a/src/emu/sound/tms3615.c +++ b/src/emu/sound/tms3615.c @@ -24,10 +24,8 @@ struct _tms_state { INLINE tms_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_TMS3615); - return (tms_state *)device->token; + assert(device->type() == SOUND_TMS3615); + return (tms_state *)downcast(device)->token(); } @@ -92,9 +90,9 @@ static DEVICE_START( tms3615 ) { tms_state *tms = get_safe_token(device); - tms->channel = stream_create(device, 0, 2, device->clock/8, tms, tms3615_sound_update); - tms->samplerate = device->clock/8; - tms->basefreq = device->clock; + tms->channel = stream_create(device, 0, 2, device->clock()/8, tms, tms3615_sound_update); + tms->samplerate = device->clock()/8; + tms->basefreq = device->clock(); } /************************************************************************** diff --git a/src/emu/sound/tms3615.h b/src/emu/sound/tms3615.h index 46b20287313..ffd5dc8db93 100644 --- a/src/emu/sound/tms3615.h +++ b/src/emu/sound/tms3615.h @@ -3,12 +3,13 @@ #ifndef __TMS3615_H__ #define __TMS3615_H__ +#include "devlegcy.h" + extern void tms3615_enable_w(running_device *device, int enable); #define TMS3615_FOOTAGE_8 0 #define TMS3615_FOOTAGE_16 1 -DEVICE_GET_INFO( tms3615 ); -#define SOUND_TMS3615 DEVICE_GET_INFO_NAME( tms3615 ) +DECLARE_LEGACY_SOUND_DEVICE(TMS3615, tms3615); #endif /* __TMS3615_H__ */ diff --git a/src/emu/sound/tms36xx.c b/src/emu/sound/tms36xx.c index b2ff1b2fa2e..f245a7db53a 100644 --- a/src/emu/sound/tms36xx.c +++ b/src/emu/sound/tms36xx.c @@ -344,10 +344,8 @@ static const int *const tunes[] = {NULL,tune1,tune2,tune3,tune4}; INLINE tms_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_TMS36XX); - return (tms_state *)device->token; + assert(device->type() == SOUND_TMS36XX); + return (tms_state *)downcast(device)->token(); } @@ -501,11 +499,11 @@ static DEVICE_START( tms36xx ) tms_state *tms = get_safe_token(device); int enable; - tms->intf = (const tms36xx_interface *)device->baseconfig().static_config; + tms->intf = (const tms36xx_interface *)device->baseconfig().static_config(); - tms->channel = stream_create(device, 0, 1, device->clock * 64, tms, tms36xx_sound_update); - tms->samplerate = device->clock * 64; - tms->basefreq = device->clock; + tms->channel = stream_create(device, 0, 1, device->clock() * 64, tms, tms36xx_sound_update); + tms->samplerate = device->clock() * 64; + tms->basefreq = device->clock(); enable = 0; for (j = 0; j < 6; j++) { diff --git a/src/emu/sound/tms36xx.h b/src/emu/sound/tms36xx.h index 2870b1b0d0f..2e9006d6cb1 100644 --- a/src/emu/sound/tms36xx.h +++ b/src/emu/sound/tms36xx.h @@ -3,6 +3,8 @@ #ifndef __TMS36XX_H__ #define __TMS36XX_H__ +#include "devlegcy.h" + /* subtypes */ #define MM6221AA 21 /* Phoenix (fixed melodies) */ #define TMS3615 15 /* Naughty Boy, Pleiads (13 notes, one output) */ @@ -26,7 +28,6 @@ extern void tms36xx_note_w(running_device *device, int octave, int note); /* TMS3617 interface functions */ extern void tms3617_enable_w(running_device *device, int enable); -DEVICE_GET_INFO( tms36xx ); -#define SOUND_TMS36XX DEVICE_GET_INFO_NAME( tms36xx ) +DECLARE_LEGACY_SOUND_DEVICE(TMS36XX, tms36xx); #endif /* __TMS36XX_H__ */ diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index cfcc2250913..a8e5dcd7046 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -198,24 +198,21 @@ struct _tmsprom_state INLINE tms5110_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_TMS5110 || - sound_get_type(device) == SOUND_TMS5100 || - sound_get_type(device) == SOUND_TMS5110A || - sound_get_type(device) == SOUND_CD2801 || - sound_get_type(device) == SOUND_TMC0281 || - sound_get_type(device) == SOUND_CD2802 || - sound_get_type(device) == SOUND_M58817); - return (tms5110_state *)device->token; + assert(device->type() == SOUND_TMS5110 || + device->type() == SOUND_TMS5100 || + device->type() == SOUND_TMS5110A || + device->type() == SOUND_CD2801 || + device->type() == SOUND_TMC0281 || + device->type() == SOUND_CD2802 || + device->type() == SOUND_M58817); + return (tms5110_state *)downcast(device)->token(); } INLINE tmsprom_state *get_safe_token_prom(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TMSPROM); - return (tmsprom_state *)device->token; + assert(device->type() == TMSPROM); + return (tmsprom_state *)downcast(device)->token(); } /* Static function prototypes */ @@ -1019,10 +1016,10 @@ static DEVICE_START( tms5110 ) assert_always(tms != NULL, "Error creating TMS5110 chip"); - assert_always(device->baseconfig().static_config != NULL, "No config"); + assert_always(device->baseconfig().static_config() != NULL, "No config"); - tms->intf = device->baseconfig().static_config ? (const tms5110_interface *)device->baseconfig().static_config : &dummy; - tms->table = *device->region; + tms->intf = device->baseconfig().static_config() ? (const tms5110_interface *)device->baseconfig().static_config() : &dummy; + tms->table = *device->region(); tms->device = device; tms5110_set_variant(tms, TMS5110_IS_5110A); @@ -1035,7 +1032,7 @@ static DEVICE_START( tms5110 ) devcb_resolve_read_line(&tms->data_func, &tms->intf->data_func, device); /* initialize a stream */ - tms->stream = stream_create(device, 0, 1, device->clock / 80, tms, tms5110_update); + tms->stream = stream_create(device, 0, 1, device->clock() / 80, tms, tms5110_update); if (tms->table == NULL) { @@ -1243,7 +1240,7 @@ READ8_DEVICE_HANDLER( tms5110_romclk_hack_r ) if (!tms->romclk_hack_timer_started) { tms->romclk_hack_timer_started = TRUE; - timer_adjust_periodic(tms->romclk_hack_timer, ATTOTIME_IN_HZ(device->clock / 40), 0, ATTOTIME_IN_HZ(device->clock / 40)); + timer_adjust_periodic(tms->romclk_hack_timer, ATTOTIME_IN_HZ(device->clock() / 40), 0, ATTOTIME_IN_HZ(device->clock() / 40)); } return tms->romclk_hack_state; } @@ -1410,20 +1407,20 @@ static DEVICE_START( tmsprom ) assert_always(tms != NULL, "Error creating TMSPROM chip"); - tms->intf = (const tmsprom_interface *) device->baseconfig().static_config; + tms->intf = (const tmsprom_interface *) device->baseconfig().static_config(); assert_always(tms->intf != NULL, "Error creating TMSPROM chip: No configuration"); /* resolve lines */ devcb_resolve_write_line(&tms->pdc_func, &tms->intf->pdc_func, device); devcb_resolve_write8(&tms->ctl_func, &tms->intf->ctl_func, device); - tms->rom = *device->region; + tms->rom = *device->region(); assert_always(tms->rom != NULL, "Error creating TMSPROM chip: No rom region found"); tms->prom = memory_region(device->machine, tms->intf->prom_region); assert_always(tms->rom != NULL, "Error creating TMSPROM chip: No prom region found"); tms->device = device; - tms->clock = device->clock; + tms->clock = device->clock(); tms->romclk_timer = timer_alloc(device->machine, tmsprom_step, device); timer_adjust_periodic(tms->romclk_timer, attotime_zero, 0, ATTOTIME_IN_HZ(tms->clock)); diff --git a/src/emu/sound/tms5110.h b/src/emu/sound/tms5110.h index b253da1e193..0f94feb499d 100644 --- a/src/emu/sound/tms5110.h +++ b/src/emu/sound/tms5110.h @@ -3,6 +3,8 @@ #ifndef __TMS5110_H__ #define __TMS5110_H__ +#include "devlegcy.h" + /* TMS5110 commands */ /* CTL8 CTL4 CTL2 CTL1 | PDC's */ /* (MSB) (LSB) | required */ @@ -54,21 +56,14 @@ int tms5110_ready_r(running_device *device); void tms5110_set_frequency(running_device *device, int frequency); -DEVICE_GET_INFO( tms5110 ); -DEVICE_GET_INFO( tms5100 ); -DEVICE_GET_INFO( tms5110a ); -DEVICE_GET_INFO( cd2801 ); -DEVICE_GET_INFO( tmc0281 ); -DEVICE_GET_INFO( cd2802 ); -DEVICE_GET_INFO( m58817 ); - -#define SOUND_TMS5110 DEVICE_GET_INFO_NAME( tms5110 ) -#define SOUND_TMS5100 DEVICE_GET_INFO_NAME( tms5100 ) -#define SOUND_TMS5110A DEVICE_GET_INFO_NAME( tms5110a ) -#define SOUND_CD2801 DEVICE_GET_INFO_NAME( cd2801 ) -#define SOUND_TMC0281 DEVICE_GET_INFO_NAME( tmc0281 ) -#define SOUND_CD2802 DEVICE_GET_INFO_NAME( cd2802 ) -#define SOUND_M58817 DEVICE_GET_INFO_NAME( m58817 ) +DECLARE_LEGACY_SOUND_DEVICE(TMS5110, tms5110); +DECLARE_LEGACY_SOUND_DEVICE(TMS5100, tms5100); +DECLARE_LEGACY_SOUND_DEVICE(TMS5110A, tms5110a); +DECLARE_LEGACY_SOUND_DEVICE(CD2801, cd2801); +DECLARE_LEGACY_SOUND_DEVICE(TMC0281, tmc0281); +DECLARE_LEGACY_SOUND_DEVICE(CD2802, cd2802); +DECLARE_LEGACY_SOUND_DEVICE(M58817, m58817); + /* PROM controlled TMS5110 interface */ @@ -97,8 +92,6 @@ WRITE8_DEVICE_HANDLER( tmsprom_rom_csq_w ); WRITE8_DEVICE_HANDLER( tmsprom_bit_w ); WRITE_LINE_DEVICE_HANDLER( tmsprom_enable_w ); -DEVICE_GET_INFO( tmsprom ); - -#define TMSPROM DEVICE_GET_INFO_NAME( tmsprom ) +DECLARE_LEGACY_DEVICE(TMSPROM, tmsprom); #endif /* __TMS5110_H__ */ diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c index a5cc4c2b67c..9bccd11e569 100644 --- a/src/emu/sound/tms5220.c +++ b/src/emu/sound/tms5220.c @@ -348,13 +348,11 @@ struct _tms5220_state INLINE tms5220_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_TMS5220 || - sound_get_type(device) == SOUND_TMS5220C || - sound_get_type(device) == SOUND_TMC0285 || - sound_get_type(device) == SOUND_TMS5200); - return (tms5220_state *)device->token; + assert(device->type() == SOUND_TMS5220 || + device->type() == SOUND_TMS5220C || + device->type() == SOUND_TMC0285 || + device->type() == SOUND_TMS5200); + return (tms5220_state *)downcast(device)->token(); } /* Static function prototypes */ @@ -1414,12 +1412,12 @@ static DEVICE_START( tms5220 ) static const tms5220_interface dummy = { DEVCB_NULL }; tms5220_state *tms = get_safe_token(device); - tms->intf = device->baseconfig().static_config ? (const tms5220_interface *)device->baseconfig().static_config : &dummy; - //tms->table = *device->region; + tms->intf = device->baseconfig().static_config() ? (const tms5220_interface *)device->baseconfig().static_config() : &dummy; + //tms->table = *device->region(); tms->device = device; tms5220_set_variant(tms, TMS5220_IS_5220); - tms->clock = device->clock; + tms->clock = device->clock(); assert_always(tms != NULL, "Error creating TMS5220 chip"); @@ -1428,7 +1426,7 @@ static DEVICE_START( tms5220 ) devcb_resolve_write_line(&tms->readyq_func, &tms->intf->readyq_func, device); /* initialize a stream */ - tms->stream = stream_create(device, 0, 1, device->clock / 80, tms, tms5220_update); + tms->stream = stream_create(device, 0, 1, device->clock() / 80, tms, tms5220_update); /*if (tms->table == NULL) { @@ -1601,7 +1599,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_rsq_w ) tms->io_ready = 0; update_ready_state(tms); /* How long does /READY stay inactive, when /RS is pulled low? I believe its almost always ~16 clocks (25 usec at 800khz as shown on the datasheet) */ - timer_set(tms->device->machine, ATTOTIME_IN_HZ(device->clock/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~11?) cycles to complete + timer_set(tms->device->machine, ATTOTIME_IN_HZ(device->clock()/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~11?) cycles to complete } } } @@ -1664,7 +1662,7 @@ WRITE_LINE_DEVICE_HANDLER( tms5220_wsq_w ) SET RATE (5220C only): ? cycles (probably ~16) */ // TODO: actually HANDLE the timing differences! currently just assuming always 16 cycles - timer_set(tms->device->machine, ATTOTIME_IN_HZ(device->clock/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~15) cycles to complete for fifo writes, TODO: but actually depends on what command is written if in command mode + timer_set(tms->device->machine, ATTOTIME_IN_HZ(device->clock()/16), tms, 1, io_ready_cb); // this should take around 10-16 (closer to ~15) cycles to complete for fifo writes, TODO: but actually depends on what command is written if in command mode } } } diff --git a/src/emu/sound/tms5220.h b/src/emu/sound/tms5220.h index 1acb1d28a41..3d140d1d4d7 100644 --- a/src/emu/sound/tms5220.h +++ b/src/emu/sound/tms5220.h @@ -3,6 +3,8 @@ #ifndef __TMS5220_H__ #define __TMS5220_H__ +#include "devlegcy.h" + /* clock rate = 80 * output sample rate, */ /* usually 640000 for 8000 Hz sample rate or */ @@ -39,15 +41,10 @@ double tms5220_time_to_ready(running_device *device); void tms5220_set_frequency(running_device *device, int frequency); -DEVICE_GET_INFO( tms5220c ); -DEVICE_GET_INFO( tms5220 ); -DEVICE_GET_INFO( tmc0285 ); -DEVICE_GET_INFO( tms5200 ); - -#define SOUND_TMS5220C DEVICE_GET_INFO_NAME( tms5220c ) -#define SOUND_TMS5220 DEVICE_GET_INFO_NAME( tms5220 ) -#define SOUND_TMC0285 DEVICE_GET_INFO_NAME( tmc0285 ) -#define SOUND_TMS5200 DEVICE_GET_INFO_NAME( tms5200 ) +DECLARE_LEGACY_SOUND_DEVICE(TMS5220C, tms5220c); +DECLARE_LEGACY_SOUND_DEVICE(TMS5220, tms5220); +DECLARE_LEGACY_SOUND_DEVICE(TMC0285, tmc0285); +DECLARE_LEGACY_SOUND_DEVICE(TMS5200, tms5200); #endif /* __TMS5220_H__ */ diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index 4e575b8884b..06e885e3d38 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -224,10 +224,8 @@ static const int upd7759_state_table[16] = { -1, -1, 0, 0, 1, 2, 2, 3, -1, -1, 0 INLINE upd7759_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_UPD7759); - return (upd7759_state *)device->token; + assert(device->type() == SOUND_UPD7759); + return (upd7759_state *)downcast(device)->token(); } @@ -638,25 +636,25 @@ static void register_for_save(upd7759_state *chip, running_device *device) static DEVICE_START( upd7759 ) { static const upd7759_interface defintrf = { 0 }; - const upd7759_interface *intf = (device->baseconfig().static_config != NULL) ? (const upd7759_interface *)device->baseconfig().static_config : &defintrf; + const upd7759_interface *intf = (device->baseconfig().static_config() != NULL) ? (const upd7759_interface *)device->baseconfig().static_config() : &defintrf; upd7759_state *chip = get_safe_token(device); chip->device = device; /* allocate a stream channel */ - chip->channel = stream_create(device, 0, 1, device->clock/4, chip, upd7759_update); + chip->channel = stream_create(device, 0, 1, device->clock()/4, chip, upd7759_update); /* compute the stepping rate based on the chip's clock speed */ chip->step = 4 * FRAC_ONE; /* compute the clock period */ - chip->clock_period = ATTOTIME_IN_HZ(device->clock); + chip->clock_period = ATTOTIME_IN_HZ(device->clock()); /* set the intial state */ chip->state = STATE_IDLE; /* compute the ROM base or allocate a timer */ - chip->rom = chip->rombase = *device->region; + chip->rom = chip->rombase = *device->region(); if (chip->rom == NULL) chip->timer = timer_alloc(device->machine, upd7759_slave_update, chip); diff --git a/src/emu/sound/upd7759.h b/src/emu/sound/upd7759.h index ddc4490e9f2..435a4bbee25 100644 --- a/src/emu/sound/upd7759.h +++ b/src/emu/sound/upd7759.h @@ -3,6 +3,8 @@ #ifndef __UPD7759_H__ #define __UPD7759_H__ +#include "devlegcy.h" + /* There are two modes for the uPD7759, selected through the !MD pin. This is the mode select input. High is stand alone, low is slave. We're making the assumption that nobody switches modes through @@ -23,7 +25,6 @@ void upd7759_start_w(running_device *device, UINT8 data); int upd7759_busy_r(running_device *device); WRITE8_DEVICE_HANDLER( upd7759_port_w ); -DEVICE_GET_INFO( upd7759 ); -#define SOUND_UPD7759 DEVICE_GET_INFO_NAME( upd7759 ) +DECLARE_LEGACY_SOUND_DEVICE(UPD7759, upd7759); #endif /* __UPD7759_H__ */ diff --git a/src/emu/sound/vlm5030.c b/src/emu/sound/vlm5030.c index 0fea930600b..2ba587cf8d3 100644 --- a/src/emu/sound/vlm5030.c +++ b/src/emu/sound/vlm5030.c @@ -222,10 +222,8 @@ static const INT16 K5_table[] = { INLINE vlm5030_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_VLM5030); - return (vlm5030_state *)device->token; + assert(device->type() == SOUND_VLM5030); + return (vlm5030_state *)downcast(device)->token(); } static int get_bits(vlm5030_state *chip, int sbit,int bits) @@ -654,9 +652,9 @@ static DEVICE_START( vlm5030 ) vlm5030_state *chip = get_safe_token(device); chip->device = device; - chip->intf = (device->baseconfig().static_config != NULL) ? (const vlm5030_interface *)device->baseconfig().static_config : &defintrf; + chip->intf = (device->baseconfig().static_config() != NULL) ? (const vlm5030_interface *)device->baseconfig().static_config() : &defintrf; - emulation_rate = device->clock / 440; + emulation_rate = device->clock() / 440; /* reset input pins */ chip->pin_RST = chip->pin_ST = chip->pin_VCU= 0; @@ -665,10 +663,10 @@ static DEVICE_START( vlm5030 ) vlm5030_reset(chip); chip->phase = PH_IDLE; - chip->rom = *device->region; + chip->rom = *device->region(); /* memory size */ if( chip->intf->memory_size == 0) - chip->address_mask = device->region->bytes()-1; + chip->address_mask = device->region()->bytes()-1; else chip->address_mask = chip->intf->memory_size-1; diff --git a/src/emu/sound/vlm5030.h b/src/emu/sound/vlm5030.h index fa4651c7ed0..5c0961c1ec0 100644 --- a/src/emu/sound/vlm5030.h +++ b/src/emu/sound/vlm5030.h @@ -3,6 +3,8 @@ #ifndef __VLM5030_H__ #define __VLM5030_H__ +#include "devlegcy.h" + typedef struct _vlm5030_interface vlm5030_interface; struct _vlm5030_interface { @@ -23,7 +25,6 @@ void vlm5030_vcu(running_device *device, int pin ); /* set ST pin level : set table address A0-A7 / start speech */ void vlm5030_st(running_device *device, int pin ); -DEVICE_GET_INFO( vlm5030 ); -#define SOUND_VLM5030 DEVICE_GET_INFO_NAME( vlm5030 ) +DECLARE_LEGACY_SOUND_DEVICE(VLM5030, vlm5030); #endif /* __VLM5030_H__ */ diff --git a/src/emu/sound/votrax.c b/src/emu/sound/votrax.c index 9c1cda7ea9c..6166d518f5d 100644 --- a/src/emu/sound/votrax.c +++ b/src/emu/sound/votrax.c @@ -41,10 +41,8 @@ struct _votrax_state INLINE votrax_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_VOTRAX); - return (votrax_state *)device->token; + assert(device->type() == SOUND_VOTRAX); + return (votrax_state *)downcast(device)->token(); } #define FRAC_BITS 24 diff --git a/src/emu/sound/votrax.h b/src/emu/sound/votrax.h index 8cc1aeb305c..e241bc26dc7 100644 --- a/src/emu/sound/votrax.h +++ b/src/emu/sound/votrax.h @@ -3,10 +3,11 @@ #ifndef __VOTRAX_H__ #define __VOTRAX_H__ +#include "devlegcy.h" + WRITE8_DEVICE_HANDLER( votrax_w ); int votrax_status_r(running_device *device); -DEVICE_GET_INFO( votrax ); -#define SOUND_VOTRAX DEVICE_GET_INFO_NAME( votrax ) +DECLARE_LEGACY_SOUND_DEVICE(VOTRAX, votrax); #endif /* __VOTRAX_H__ */ diff --git a/src/emu/sound/vrender0.c b/src/emu/sound/vrender0.c index 9f2a408dab6..4c1445b7dc4 100644 --- a/src/emu/sound/vrender0.c +++ b/src/emu/sound/vrender0.c @@ -26,10 +26,8 @@ struct _vr0_state INLINE vr0_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_VRENDER0); - return (vr0_state *)device->token; + assert(device->type() == SOUND_VRENDER0); + return (vr0_state *)downcast(device)->token(); } static void VR0_RenderAudio(vr0_state *VR0, int nsamples,stream_sample_t *l,stream_sample_t *r); @@ -108,7 +106,7 @@ static DEVICE_START( vrender0 ) const vr0_interface *intf; vr0_state *VR0 = get_safe_token(device); - intf = (const vr0_interface *)device->baseconfig().static_config; + intf = (const vr0_interface *)device->baseconfig().static_config(); memcpy(&(VR0->Intf),intf,sizeof(vr0_interface)); memset(VR0->SOUNDREGS,0,sizeof(VR0->SOUNDREGS)); diff --git a/src/emu/sound/vrender0.h b/src/emu/sound/vrender0.h index 1361d6fb67a..eb96852d296 100644 --- a/src/emu/sound/vrender0.h +++ b/src/emu/sound/vrender0.h @@ -3,6 +3,8 @@ #ifndef __VRENDER0_H__ #define __VRENDER0_H__ +#include "devlegcy.h" + typedef struct _vr0_interface vr0_interface; struct _vr0_interface @@ -15,7 +17,6 @@ void vr0_snd_set_areas(running_device *device,UINT32 *texture,UINT32 *frame); READ32_DEVICE_HANDLER( vr0_snd_read ); WRITE32_DEVICE_HANDLER( vr0_snd_write ); -DEVICE_GET_INFO( vrender0 ); -#define SOUND_VRENDER0 DEVICE_GET_INFO_NAME( vrender0 ) +DECLARE_LEGACY_SOUND_DEVICE(VRENDER0, vrender0); #endif /* __VRENDER0_H__ */ diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c index 10f7bfc2c98..25a0dbf1e98 100644 --- a/src/emu/sound/wave.c +++ b/src/emu/sound/wave.c @@ -65,10 +65,10 @@ static DEVICE_START( wave ) running_device *image = NULL; assert( device != NULL ); - assert( device->baseconfig().static_config != NULL ); + assert( device->baseconfig().static_config() != NULL ); #ifdef MESS - image = device->machine->device( (const char *)device->baseconfig().static_config ); + image = device->machine->device( (const char *)device->baseconfig().static_config() ); #endif stream_create(device, 0, 2, device->machine->sample_rate, (void *)image, wave_sound_update); } diff --git a/src/emu/sound/wave.h b/src/emu/sound/wave.h index 32005ceafe0..bf3a6cc1da7 100644 --- a/src/emu/sound/wave.h +++ b/src/emu/sound/wave.h @@ -3,6 +3,8 @@ #ifndef __WAVE_H__ #define __WAVE_H__ +#include "devlegcy.h" + /***************************************************************************** * CassetteWave interface *****************************************************************************/ @@ -11,8 +13,7 @@ #include "messdrv.h" #endif -DEVICE_GET_INFO( wave ); -#define SOUND_WAVE DEVICE_GET_INFO_NAME( wave ) +DECLARE_LEGACY_SOUND_DEVICE(WAVE, wave); #define MDRV_SOUND_WAVE_ADD(_tag, _cass_tag) \ diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c index d3b7e161d93..38c72704d99 100644 --- a/src/emu/sound/x1_010.c +++ b/src/emu/sound/x1_010.c @@ -101,10 +101,8 @@ struct _x1_010_state INLINE x1_010_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_X1_010); - return (x1_010_state *)device->token; + assert(device->type() == SOUND_X1_010); + return (x1_010_state *)downcast(device)->token(); } @@ -203,12 +201,12 @@ static STREAM_UPDATE( seta_update ) static DEVICE_START( x1_010 ) { int i; - const x1_010_interface *intf = (const x1_010_interface *)device->baseconfig().static_config; + const x1_010_interface *intf = (const x1_010_interface *)device->baseconfig().static_config(); x1_010_state *info = get_safe_token(device); - info->region = *device->region; - info->base_clock = device->clock; - info->rate = device->clock / 1024; + info->region = *device->region(); + info->base_clock = device->clock(); + info->rate = device->clock() / 1024; info->address = intf->adr; for( i = 0; i < SETA_NUM_CHANNELS; i++ ) { @@ -216,7 +214,7 @@ static DEVICE_START( x1_010 ) info->env_offset[i] = 0; } /* Print some more debug info */ - LOG_SOUND(("masterclock = %d rate = %d\n", device->clock, info->rate )); + LOG_SOUND(("masterclock = %d rate = %d\n", device->clock(), info->rate )); /* get stream channels */ info->stream = stream_create(device,0,2,info->rate,info,seta_update); diff --git a/src/emu/sound/x1_010.h b/src/emu/sound/x1_010.h index 5d975fb1cf9..d071548fe61 100644 --- a/src/emu/sound/x1_010.h +++ b/src/emu/sound/x1_010.h @@ -3,6 +3,8 @@ #ifndef __X1_010_H__ #define __X1_010_H__ +#include "devlegcy.h" + typedef struct _x1_010_interface x1_010_interface; struct _x1_010_interface @@ -19,7 +21,6 @@ WRITE16_DEVICE_HANDLER( seta_sound_word_w ); void seta_sound_enable_w(running_device *device, int data); -DEVICE_GET_INFO( x1_010 ); -#define SOUND_X1_010 DEVICE_GET_INFO_NAME( x1_010 ) +DECLARE_LEGACY_SOUND_DEVICE(X1_010, x1_010); #endif /* __X1_010_H__ */ diff --git a/src/emu/sound/ymf271.c b/src/emu/sound/ymf271.c index 37f2bbfbda6..fd521708b14 100644 --- a/src/emu/sound/ymf271.c +++ b/src/emu/sound/ymf271.c @@ -276,10 +276,8 @@ static int env_volume_table[256]; INLINE YMF271Chip *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YMF271); - return (YMF271Chip *)device->token; + assert(device->type() == SOUND_YMF271); + return (YMF271Chip *)downcast(device)->token(); } @@ -1775,12 +1773,12 @@ static DEVICE_START( ymf271 ) YMF271Chip *chip = get_safe_token(device); chip->device = device; - chip->clock = device->clock; + chip->clock = device->clock(); - intf = (device->baseconfig().static_config != NULL) ? (const ymf271_interface *)device->baseconfig().static_config : &defintrf; + intf = (device->baseconfig().static_config() != NULL) ? (const ymf271_interface *)device->baseconfig().static_config() : &defintrf; - ymf271_init(device, chip, *device->region, intf->irq_callback, &intf->ext_read, &intf->ext_write); - chip->stream = stream_create(device, 0, 2, device->clock/384, chip, ymf271_update); + ymf271_init(device, chip, *device->region(), intf->irq_callback, &intf->ext_read, &intf->ext_write); + chip->stream = stream_create(device, 0, 2, device->clock()/384, chip, ymf271_update); for (i = 0; i < 256; i++) { diff --git a/src/emu/sound/ymf271.h b/src/emu/sound/ymf271.h index 093cca4c1b8..284cfc9d16a 100644 --- a/src/emu/sound/ymf271.h +++ b/src/emu/sound/ymf271.h @@ -3,6 +3,8 @@ #ifndef __YMF271_H__ #define __YMF271_H__ +#include "devlegcy.h" + typedef struct _ymf271_interface ymf271_interface; struct _ymf271_interface @@ -15,7 +17,6 @@ struct _ymf271_interface READ8_DEVICE_HANDLER( ymf271_r ); WRITE8_DEVICE_HANDLER( ymf271_w ); -DEVICE_GET_INFO( ymf271 ); -#define SOUND_YMF271 DEVICE_GET_INFO_NAME( ymf271 ) +DECLARE_LEGACY_SOUND_DEVICE(YMF271, ymf271); #endif /* __YMF271_H__ */ diff --git a/src/emu/sound/ymf278b.c b/src/emu/sound/ymf278b.c index 975df4adff2..2f573b1d23e 100644 --- a/src/emu/sound/ymf278b.c +++ b/src/emu/sound/ymf278b.c @@ -132,10 +132,8 @@ typedef struct INLINE YMF278BChip *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YMF278B); - return (YMF278BChip *)device->token; + assert(device->type() == SOUND_YMF278B); + return (YMF278BChip *)downcast(device)->token(); } static INT32 *mix; @@ -668,12 +666,12 @@ WRITE8_DEVICE_HANDLER( ymf278b_w ) static void ymf278b_init(running_device *device, YMF278BChip *chip, void (*cb)(running_device *, int)) { - chip->rom = *device->region; + chip->rom = *device->region(); chip->irq_callback = cb; chip->timer_a = timer_alloc(device->machine, ymf278b_timer_a_tick, chip); chip->timer_b = timer_alloc(device->machine, ymf278b_timer_b_tick, chip); chip->irq_line = CLEAR_LINE; - chip->clock = device->clock; + chip->clock = device->clock(); mix = auto_alloc_array(device->machine, INT32, 44100*2); } @@ -686,10 +684,10 @@ static DEVICE_START( ymf278b ) YMF278BChip *chip = get_safe_token(device); chip->device = device; - intf = (device->baseconfig().static_config != NULL) ? (const ymf278b_interface *)device->baseconfig().static_config : &defintrf; + intf = (device->baseconfig().static_config() != NULL) ? (const ymf278b_interface *)device->baseconfig().static_config() : &defintrf; ymf278b_init(device, chip, intf->irq_callback); - chip->stream = stream_create(device, 0, 2, device->clock/768, chip, ymf278b_pcm_update); + chip->stream = stream_create(device, 0, 2, device->clock()/768, chip, ymf278b_pcm_update); // Volume table, 1 = -0.375dB, 8 = -3dB, 256 = -96dB for(i = 0; i < 256; i++) diff --git a/src/emu/sound/ymf278b.h b/src/emu/sound/ymf278b.h index 362290d701a..9efb554c070 100644 --- a/src/emu/sound/ymf278b.h +++ b/src/emu/sound/ymf278b.h @@ -3,6 +3,8 @@ #ifndef __YMF278B_H__ #define __YMF278B_H__ +#include "devlegcy.h" + #define YMF278B_STD_CLOCK (33868800) /* standard clock for OPL4 */ @@ -15,7 +17,6 @@ struct _ymf278b_interface READ8_DEVICE_HANDLER( ymf278b_r ); WRITE8_DEVICE_HANDLER( ymf278b_w ); -DEVICE_GET_INFO( ymf278b ); -#define SOUND_YMF278B DEVICE_GET_INFO_NAME( ymf278b ) +DECLARE_LEGACY_SOUND_DEVICE(YMF278B, ymf278b); #endif /* __YMF278B_H__ */ diff --git a/src/emu/sound/ymz280b.c b/src/emu/sound/ymz280b.c index 1ac57053601..dcb3a05d27b 100644 --- a/src/emu/sound/ymz280b.c +++ b/src/emu/sound/ymz280b.c @@ -133,10 +133,8 @@ static const timer_fired_func update_irq_state_cb[] = INLINE ymz280b_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_YMZ280B); - return (ymz280b_state *)device->token; + assert(device->type() == SOUND_YMZ280B); + return (ymz280b_state *)downcast(device)->token(); } @@ -638,7 +636,7 @@ static STREAM_UPDATE( ymz280b_update ) static DEVICE_START( ymz280b ) { static const ymz280b_interface defintrf = { 0 }; - const ymz280b_interface *intf = (device->baseconfig().static_config != NULL) ? (const ymz280b_interface *)device->baseconfig().static_config : &defintrf; + const ymz280b_interface *intf = (device->baseconfig().static_config() != NULL) ? (const ymz280b_interface *)device->baseconfig().static_config() : &defintrf; ymz280b_state *chip = get_safe_token(device); chip->device = device; @@ -649,8 +647,8 @@ static DEVICE_START( ymz280b ) compute_tables(); /* initialize the rest of the structure */ - chip->master_clock = (double)device->clock / 384.0; - chip->region_base = *device->region; + chip->master_clock = (double)device->clock() / 384.0; + chip->region_base = *device->region(); chip->irq_callback = intf->irq_callback; /* create the stream */ diff --git a/src/emu/sound/ymz280b.h b/src/emu/sound/ymz280b.h index 5c7c2b7211f..9f3b06c4174 100644 --- a/src/emu/sound/ymz280b.h +++ b/src/emu/sound/ymz280b.h @@ -10,6 +10,8 @@ #ifndef __YMZ280B_H__ #define __YMZ280B_H__ +#include "devlegcy.h" + typedef struct _ymz280b_interface ymz280b_interface; struct _ymz280b_interface @@ -22,7 +24,6 @@ struct _ymz280b_interface READ8_DEVICE_HANDLER ( ymz280b_r ); WRITE8_DEVICE_HANDLER( ymz280b_w ); -DEVICE_GET_INFO( ymz280b ); -#define SOUND_YMZ280B DEVICE_GET_INFO_NAME( ymz280b ) +DECLARE_LEGACY_SOUND_DEVICE(YMZ280B, ymz280b); #endif /* __YMZ280B_H__ */ diff --git a/src/emu/sound/zsg2.c b/src/emu/sound/zsg2.c index 9b01a03096b..7c5f01e973d 100644 --- a/src/emu/sound/zsg2.c +++ b/src/emu/sound/zsg2.c @@ -69,10 +69,8 @@ struct _zsg2_state INLINE zsg2_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_ZSG2); - return (zsg2_state *)device->token; + assert(device->type() == SOUND_ZSG2); + return (zsg2_state *)downcast(device)->token(); } static STREAM_UPDATE( update_stereo ) @@ -221,10 +219,10 @@ READ16_DEVICE_HANDLER( zsg2_r ) static DEVICE_START( zsg2 ) { - const zsg2_interface *intf = (const zsg2_interface *)device->baseconfig().static_config; + const zsg2_interface *intf = (const zsg2_interface *)device->baseconfig().static_config(); zsg2_state *info = get_safe_token(device); - info->sample_rate = device->clock; + info->sample_rate = device->clock(); memset(&info->zc, 0, sizeof(info->zc)); memset(&info->act, 0, sizeof(info->act)); diff --git a/src/emu/sound/zsg2.h b/src/emu/sound/zsg2.h index 27c72cd367c..209b20141c1 100644 --- a/src/emu/sound/zsg2.h +++ b/src/emu/sound/zsg2.h @@ -16,7 +16,6 @@ struct _zsg2_interface const char *samplergn; }; -DEVICE_GET_INFO( zsg2 ); -#define SOUND_ZSG2 DEVICE_GET_INFO_NAME( zsg2 ) +DECLARE_LEGACY_SOUND_DEVICE(ZSG2, zsg2); #endif /* __ZSG2_H__ */ diff --git a/src/emu/streams.c b/src/emu/streams.c index 67cfb4a0529..2665d3a35aa 100644 --- a/src/emu/streams.c +++ b/src/emu/streams.c @@ -109,10 +109,11 @@ struct _stream_output }; -struct _sound_stream +class sound_stream { +public: /* linking information */ - running_device * device; /* owning device */ + device_t * device; /* owning device */ sound_stream * next; /* next stream in the chain */ int index; /* index for save states */ @@ -333,7 +334,7 @@ void streams_update(running_machine *machine) stream_create - create a new stream -------------------------------------------------*/ -sound_stream *stream_create(running_device *device, int inputs, int outputs, int sample_rate, void *param, stream_update_func callback) +sound_stream *stream_create(device_t *device, int inputs, int outputs, int sample_rate, void *param, stream_update_func callback) { running_machine *machine = device->machine; streams_private *strdata = machine->streams_data; @@ -411,7 +412,7 @@ sound_stream *stream_create(running_device *device, int inputs, int outputs, int output pair -------------------------------------------------*/ -int stream_device_output_to_stream_output(running_device *device, int outputnum, sound_stream **streamptr, int *streamoutputptr) +int stream_device_output_to_stream_output(device_t *device, int outputnum, sound_stream **streamptr, int *streamoutputptr) { streams_private *strdata = device->machine->streams_data; sound_stream *stream; @@ -438,7 +439,7 @@ int stream_device_output_to_stream_output(running_device *device, int outputnum, input pair -------------------------------------------------*/ -int stream_device_input_to_stream_input(running_device *device, int inputnum, sound_stream **streamptr, int *streaminputptr) +int stream_device_input_to_stream_input(device_t *device, int inputnum, sound_stream **streamptr, int *streaminputptr) { streams_private *strdata = device->machine->streams_data; sound_stream *stream; @@ -602,7 +603,7 @@ attotime stream_get_sample_period(sound_stream *stream) number of outputs for the given device -------------------------------------------------*/ -int stream_get_device_outputs(running_device *device) +int stream_get_device_outputs(device_t *device) { streams_private *strdata = device->machine->streams_data; sound_stream *stream; @@ -621,7 +622,7 @@ int stream_get_device_outputs(running_device *device) device and index -------------------------------------------------*/ -sound_stream *stream_find_by_device(running_device *device, int streamindex) +sound_stream *stream_find_by_device(device_t *device, int streamindex) { streams_private *strdata = device->machine->streams_data; sound_stream *stream; diff --git a/src/emu/streams.h b/src/emu/streams.h index 64513b5b220..263c22ae6e4 100644 --- a/src/emu/streams.h +++ b/src/emu/streams.h @@ -27,11 +27,11 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _sound_stream sound_stream; +class sound_stream; -typedef void (*stream_update_func)(running_device *device, void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples); +typedef void (*stream_update_func)(device_t *device, void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples); -#define STREAM_UPDATE(name) void name(running_device *device, void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +#define STREAM_UPDATE(name) void name(device_t *device, void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples) @@ -53,13 +53,13 @@ void streams_update(running_machine *machine); /* ----- stream configuration and setup ----- */ /* create a new stream */ -sound_stream *stream_create(running_device *device, int inputs, int outputs, int sample_rate, void *param, stream_update_func callback); +sound_stream *stream_create(device_t *device, int inputs, int outputs, int sample_rate, void *param, stream_update_func callback); /* convert a device/output pair to a stream/output pair */ -int stream_device_output_to_stream_output(running_device *device, int outputnum, sound_stream **streamptr, int *streamoutputptr); +int stream_device_output_to_stream_output(device_t *device, int outputnum, sound_stream **streamptr, int *streamoutputptr); /* convert a device/input pair to a stream/input pair */ -int stream_device_input_to_stream_input(running_device *device, int inputnum, sound_stream **streamptr, int *streaminputptr); +int stream_device_input_to_stream_input(device_t *device, int inputnum, sound_stream **streamptr, int *streaminputptr); /* configure a stream's input */ void stream_set_input(sound_stream *stream, int index, sound_stream *input_stream, int output_index, float gain); @@ -91,10 +91,10 @@ attotime stream_get_sample_period(sound_stream *stream); /* ----- stream information and control ----- */ /* return the total number of outputs for the given device */ -int stream_get_device_outputs(running_device *device); +int stream_get_device_outputs(device_t *device); /* find a stream using a device and index */ -sound_stream *stream_find_by_device(running_device *device, int streamindex); +sound_stream *stream_find_by_device(device_t *device, int streamindex); /* return the number of inputs for a given stream */ int stream_get_inputs(sound_stream *stream); diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c index 44a40867722..a30f84ad096 100644 --- a/src/emu/tilemap.c +++ b/src/emu/tilemap.c @@ -291,8 +291,8 @@ void tilemap_init(running_machine *machine) if (machine->primary_screen == NULL) return; - screen_width = video_screen_get_width(machine->primary_screen); - screen_height = video_screen_get_height(machine->primary_screen); + screen_width = machine->primary_screen->width(); + screen_height = machine->primary_screen->height(); if (screen_width != 0 && screen_height != 0) { @@ -322,7 +322,7 @@ tilemap_t *tilemap_create(running_machine *machine, tile_get_info_func tile_get_ is owned by a device -------------------------------------------------*/ -tilemap_t *tilemap_create_device(running_device *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) +tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows) { return tilemap_create_common(device->machine, (void *)device, (tile_get_info_func)tile_get_info, mapper, tilewidth, tileheight, cols, rows); } @@ -836,8 +836,8 @@ profiler_mark_start(PROFILER_TILEMAP_DRAW); tmap->gfx_used = 0; } - width = video_screen_get_width(tmap->machine->primary_screen); - height = video_screen_get_height(tmap->machine->primary_screen); + width = tmap->machine->primary_screen->width(); + height = tmap->machine->primary_screen->height(); /* XY scrolling playfield */ if (tmap->scrollrows == 1 && tmap->scrollcols == 1) diff --git a/src/emu/tilemap.h b/src/emu/tilemap.h index 2fb60d3bcae..b73435ad6c3 100644 --- a/src/emu/tilemap.h +++ b/src/emu/tilemap.h @@ -355,7 +355,7 @@ /* function definition for a get info callback */ #define TILE_GET_INFO(_name) void _name(running_machine *machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) -#define TILE_GET_INFO_DEVICE(_name) void _name(running_device *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) +#define TILE_GET_INFO_DEVICE(_name) void _name(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param) /* function definition for a logical-to-memory mapper */ #define TILEMAP_MAPPER(_name) tilemap_memory_index _name(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows) @@ -400,7 +400,7 @@ struct _tile_data /* callback function to get info about a tile */ typedef void (*tile_get_info_func)(running_machine *machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); -typedef void (*tile_get_info_device_func)(running_device *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); +typedef void (*tile_get_info_device_func)(device_t *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param); /* callback function to map a column,row pair to a memory index */ typedef tilemap_memory_index (*tilemap_mapper_func)(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows); @@ -425,7 +425,7 @@ void tilemap_init(running_machine *machine); tilemap_t *tilemap_create(running_machine *machine, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); /* create a new tilemap that is owned by a device */ -tilemap_t *tilemap_create_device(running_device *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); +tilemap_t *tilemap_create_device(device_t *device, tile_get_info_device_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows); /* specify a parameter to be passed into the tile_get_info callback */ void tilemap_set_user_data(tilemap_t *tmap, void *user_data); diff --git a/src/emu/timer.c b/src/emu/timer.c index 4fed545b6ce..5596dcfcf8f 100644 --- a/src/emu/timer.c +++ b/src/emu/timer.c @@ -38,9 +38,9 @@ TYPE DEFINITIONS ***************************************************************************/ -/* in timer.h: typedef struct _emu_timer emu_timer; */ -struct _emu_timer +class emu_timer { +public: running_machine * machine; /* pointer to the owning machine */ emu_timer * next; /* next timer in order in the list */ emu_timer * prev; /* previous timer in order in the list */ @@ -58,23 +58,6 @@ struct _emu_timer }; -/* configuration of a single timer device */ -typedef struct _timer_state timer_state; -struct _timer_state -{ - emu_timer *timer; /* the backing timer */ - void *ptr; /* the pointer parameter passed to the timer callback */ - - /* periodic timers only */ - attotime start_delay; /* delay before the timer fires for the first time */ - attotime period; /* period of repeated timer firings */ - INT32 param; /* the integer parameter passed to the timer callback */ - - /* scanline timers only */ - UINT32 first_time; /* indicates that the system is starting */ -}; - - /* a single minimum quantum */ typedef struct _quantum_slot quantum_slot; struct _quantum_slot @@ -131,7 +114,6 @@ static void timer_remove(emu_timer *which); INLINE attotime get_current_time(running_machine *machine) { - extern attotime cpuexec_override_local_time(running_machine *machine, attotime default_time); timer_private *global = machine->timer_data; /* if we're currently in a callback, use the timer's expiration time as a base */ @@ -140,7 +122,8 @@ INLINE attotime get_current_time(running_machine *machine) /* if we're executing as a particular CPU, use its local time as a base */ /* otherwise, return the global base time */ - return cpuexec_override_local_time(machine, global->exec.basetime); + device_execute_interface *execdevice = machine->scheduler.currently_executing(); + return (execdevice != NULL) ? execdevice->local_time() : global->exec.basetime; } @@ -234,21 +217,6 @@ INLINE void timer_list_insert(emu_timer *timer) } -/*------------------------------------------------- - get_safe_token - makes sure that the passed - in device is, in fact, a timer --------------------------------------------------*/ - -INLINE timer_state *get_safe_token(running_device *device) -{ - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TIMER); - - return (timer_state *)device->token; -} - - /*------------------------------------------------- timer_list_remove - remove a timer from the linked list @@ -700,19 +668,6 @@ void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param) } -void timer_device_adjust_oneshot(running_device *timer, attotime duration, INT32 param) -{ -#ifdef MAME_DEBUG - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* doesn't make sense for scanline timers */ - assert(config->type != TIMER_TYPE_SCANLINE); -#endif - - timer_device_adjust_periodic(timer, duration, param, attotime_never); -} - - /*------------------------------------------------- timer_adjust_periodic - adjust the time when this timer will fire and specify a period for @@ -748,26 +703,7 @@ void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, /* if this was inserted as the head, abort the current timeslice and resync */ LOG(("timer_adjust_oneshot %s.%s:%d to expire @ %s\n", which->file, which->func, which->line, attotime_string(which->expire, 9))); if (which == global->activelist) - cpuexec_abort_timeslice(which->machine); -} - - -void timer_device_adjust_periodic(running_device *timer, attotime start_delay, INT32 param, attotime period) -{ - timer_state *state = get_safe_token(timer); -#ifdef MAME_DEBUG - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* doesn't make sense for scanline timers */ - assert(config->type != TIMER_TYPE_SCANLINE); -#endif - - state->start_delay = start_delay; - state->period = period; - state->param = param; - - /* adjust the timer */ - timer_adjust_periodic(state->timer, state->start_delay, 0, state->period); + which->machine->scheduler.abort_timeslice(); } @@ -816,20 +752,6 @@ void timer_reset(emu_timer *which, attotime duration) } -void timer_device_reset(running_device *timer) -{ - timer_state *state = get_safe_token(timer); -#ifdef MAME_DEBUG - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* doesn't make sense for scanline timers */ - assert(config->type != TIMER_TYPE_SCANLINE); -#endif - - timer_adjust_periodic(state->timer, state->start_delay, 0, state->period); -} - - /*------------------------------------------------- timer_enable - enable/disable a timer -------------------------------------------------*/ @@ -850,13 +772,6 @@ int timer_enable(emu_timer *which, int enable) } -int timer_device_enable(running_device *timer, int enable) -{ - timer_state *state = get_safe_token(timer); - return timer_enable(state->timer, enable); -} - - /*------------------------------------------------- timer_enabled - determine if a timer is enabled @@ -868,13 +783,6 @@ int timer_enabled(emu_timer *which) } -int timer_device_enabled(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return timer_enabled(state->timer); -} - - /*------------------------------------------------- timer_get_param - returns the callback parameter of a timer @@ -886,20 +794,6 @@ int timer_get_param(emu_timer *which) } -int timer_device_get_param(running_device *timer) -{ - timer_state *state = get_safe_token(timer); -#ifdef MAME_DEBUG - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* doesn't make sense for scanline timers */ - assert(config->type != TIMER_TYPE_SCANLINE); -#endif - - return state->param; -} - - /*------------------------------------------------- timer_set_param - changes the callback parameter of a timer @@ -911,20 +805,6 @@ void timer_set_param(emu_timer *which, int param) } -void timer_device_set_param(running_device *timer, int param) -{ - timer_state *state = get_safe_token(timer); -#ifdef MAME_DEBUG - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* doesn't make sense for scanline timers */ - assert(config->type != TIMER_TYPE_SCANLINE); -#endif - - state->param = param; -} - - /*------------------------------------------------- timer_get_ptr - returns the callback pointer of a timer @@ -936,13 +816,6 @@ void *timer_get_ptr(emu_timer *which) } -void *timer_device_get_ptr(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return state->ptr; -} - - /*------------------------------------------------- timer_set_ptr - changes the callback pointer of a timer @@ -954,13 +827,6 @@ void timer_set_ptr(emu_timer *which, void *ptr) } -void timer_device_set_ptr(running_device *timer, void *ptr) -{ - timer_state *state = get_safe_token(timer); - state->ptr = ptr; -} - - /*************************************************************************** TIMING FUNCTIONS @@ -977,13 +843,6 @@ attotime timer_timeelapsed(emu_timer *which) } -attotime timer_device_timeelapsed(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return timer_timeelapsed(state->timer); -} - - /*------------------------------------------------- timer_timeleft - return the time until the next trigger @@ -995,13 +854,6 @@ attotime timer_timeleft(emu_timer *which) } -attotime timer_device_timeleft(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return timer_timeleft(state->timer); -} - - /*------------------------------------------------- timer_get_time - return the current time -------------------------------------------------*/ @@ -1023,13 +875,6 @@ attotime timer_starttime(emu_timer *which) } -attotime timer_device_starttime(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return timer_starttime(state->timer); -} - - /*------------------------------------------------- timer_firetime - return the time when this timer will fire next @@ -1041,79 +886,6 @@ attotime timer_firetime(emu_timer *which) } -attotime timer_device_firetime(running_device *timer) -{ - timer_state *state = get_safe_token(timer); - return timer_firetime(state->timer); -} - - -/*------------------------------------------------- - periodic_timer_device_timer_callback - calls - the timer device specific callback --------------------------------------------------*/ - -static TIMER_CALLBACK( periodic_timer_device_timer_callback ) -{ - running_device *timer = (running_device *)ptr; - timer_state *state = get_safe_token(timer); - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* call the real callback */ - config->callback(timer, state->ptr, state->param); -} - - - -/*------------------------------------------------- - scanline_timer_device_timer_callback - - manages the scanline based timer's state --------------------------------------------------*/ - -static TIMER_CALLBACK( scanline_timer_device_timer_callback ) -{ - int next_vpos; - running_device *timer = (running_device *)ptr; - timer_state *state = get_safe_token(timer); - timer_config *config = (timer_config *)timer->baseconfig().inline_config; - - /* get the screen device and verify it */ - running_device *screen = timer->machine->device(config->screen); - assert(screen != NULL); - - /* first time, start with the first scanline, but do not call the callback */ - if (state->first_time) - { - next_vpos = config->first_vpos; - - /* indicate that we are done with the first call */ - state->first_time = FALSE; - } - - /* not the first time */ - else - { - int vpos = video_screen_get_vpos(screen); - - /* call the real callback */ - config->callback(timer, state->ptr, vpos); - - /* if the increment is 0 or the next scanline is larger than the screen size, - go back to the first one */ - if ((config->increment == 0) || - ((vpos + config->increment) >= video_screen_get_height(screen))) - next_vpos = config->first_vpos; - - /* otherwise, increment */ - else - next_vpos = vpos + config->increment; - } - - /* adjust the timer */ - timer_adjust_oneshot(state->timer, video_screen_get_time_until_pos(screen, next_vpos, 0), 0); -} - - /*************************************************************************** DEBUGGING @@ -1149,150 +921,239 @@ static void timer_logtimers(running_machine *machine) -/*************************************************************************** - TIMER DEVICE INTERFACE -***************************************************************************/ +//************************************************************************** +// TIMER DEVICE CONFIGURATION +//************************************************************************** -/*------------------------------------------------- - timer_start - device start callback - for a timer device --------------------------------------------------*/ +//------------------------------------------------- +// timer_device_config - constructor +//------------------------------------------------- + +timer_device_config::timer_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + m_type(TIMER_TYPE_GENERIC), + m_callback(NULL), + m_ptr(NULL), + m_start_delay(0), + m_period(0), + m_param(0), + m_screen(NULL), + m_first_vpos(0), + m_increment(0) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *timer_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(timer_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *timer_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, timer_device(machine, *this)); +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void timer_device_config::device_config_complete() +{ + // move inline data into its final home + m_type = static_cast(m_inline_data[INLINE_TYPE]); + m_callback = reinterpret_cast(m_inline_data[INLINE_CALLBACK]); + m_ptr = reinterpret_cast(m_inline_data[INLINE_PTR]); + m_start_delay = static_cast(m_inline_data[INLINE_DELAY]); + m_period = static_cast(m_inline_data[INLINE_PERIOD]); + m_param = static_cast(m_inline_data[INLINE_PARAM]); + m_screen = reinterpret_cast(m_inline_data[INLINE_SCREEN]); + m_first_vpos = static_cast(m_inline_data[INLINE_FIRST_VPOS]); + m_increment = static_cast(m_inline_data[INLINE_INCREMENT]); +} + + +//------------------------------------------------- +// device_validity_check - validate the device +// configuration +//------------------------------------------------- -static DEVICE_START( timer ) +bool timer_device_config::device_validity_check(const game_driver &driver) const { - timer_state *state = get_safe_token(device); - timer_config *config; - void *param; - - /* validate some basic stuff */ - assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); - assert(device->machine != NULL); - assert(device->machine->config != NULL); - - /* get and validate the configuration */ - config = (timer_config *)device->baseconfig().inline_config; - assert(config->type == TIMER_TYPE_PERIODIC || config->type == TIMER_TYPE_SCANLINE || config->type == TIMER_TYPE_GENERIC); - - /* copy the pointer parameter */ - state->ptr = config->ptr; - - /* type based configuration */ - switch (config->type) + bool error = false; + + // type based configuration + switch (m_type) { case TIMER_TYPE_GENERIC: - /* make sure that only the applicable parameters are filled in */ - assert(config->screen == NULL); - assert(config->first_vpos == 0); - assert(config->increment == 0); - assert(config->start_delay == 0); - assert(config->period == 0); - - /* copy the optional integer parameter */ - state->param = config->param; - - /* convert the start_delay and period into attotime */ - state->period = attotime_never; - state->start_delay = attotime_zero; - - /* register for state saves */ - state_save_register_device_item(device, 0, state->param); - - /* allocate the backing timer */ - param = (void *)device; - state->timer = timer_alloc(device->machine, periodic_timer_device_timer_callback, param); + if (m_screen != NULL || m_first_vpos != 0 || m_start_delay != 0) + mame_printf_warning("%s: %s generic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); + if (m_period != 0 || m_start_delay != 0) + mame_printf_warning("%s: %s generic timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); break; case TIMER_TYPE_PERIODIC: - /* make sure that only the applicable parameters are filled in */ - assert(config->screen == NULL); - assert(config->first_vpos == 0); - assert(config->increment == 0); + if (m_screen != NULL || m_first_vpos != 0) + mame_printf_warning("%s: %s periodic timer '%s' specified parameters for a scanline timer\n", driver.source_file, driver.name, tag()); + if (m_period <= 0) + { + mame_printf_error("%s: %s periodic timer '%s' specified invalid period\n", driver.source_file, driver.name, tag()); + error = true; + } + break; - /* validate that we have at least a start_delay or period */ - assert(config->period > 0); + case TIMER_TYPE_SCANLINE: + if (m_period != 0 || m_start_delay != 0) + mame_printf_warning("%s: %s scanline timer '%s' specified parameters for a periodic timer\n", driver.source_file, driver.name, tag()); + if (m_param != 0) + mame_printf_warning("%s: %s scanline timer '%s' specified parameter which is ignored\n", driver.source_file, driver.name, tag()); + if (m_first_vpos < 0) + { + mame_printf_error("%s: %s scanline timer '%s' specified invalid initial position\n", driver.source_file, driver.name, tag()); + error = true; + } + if (m_increment < 0) + { + mame_printf_error("%s: %s scanline timer '%s' specified invalid increment\n", driver.source_file, driver.name, tag()); + error = true; + } + break; - /* copy the optional integer parameter */ - state->param = config->param; + default: + mame_printf_error("%s: %s timer '%s' has an invalid type\n", driver.source_file, driver.name, tag()); + error = true; + break; + } + + return error; +} - /* convert the start_delay and period into attotime */ - state->period = UINT64_ATTOTIME_TO_ATTOTIME(config->period); - if (config->start_delay > 0) - state->start_delay = UINT64_ATTOTIME_TO_ATTOTIME(config->start_delay); - else - state->start_delay = attotime_zero; - /* register for state saves */ - state_save_register_device_item(device, 0, state->start_delay.seconds); - state_save_register_device_item(device, 0, state->start_delay.attoseconds); - state_save_register_device_item(device, 0, state->period.seconds); - state_save_register_device_item(device, 0, state->period.attoseconds); - state_save_register_device_item(device, 0, state->param); +//************************************************************************** +// LIVE TIMER DEVICE +//************************************************************************** - /* allocate the backing timer */ - param = (void *)device; - state->timer = timer_alloc(device->machine, periodic_timer_device_timer_callback, param); +//------------------------------------------------- +// timer_device - constructor +//------------------------------------------------- - /* finally, start the timer */ - timer_adjust_periodic(state->timer, state->start_delay, 0, state->period); - break; +timer_device::timer_device(running_machine &_machine, const timer_device_config &config) + : device_t(_machine, config), + m_config(config), + m_timer(NULL), + m_ptr(m_config.m_ptr), + m_screen(NULL), + m_first_time(true) +{ +} - case TIMER_TYPE_SCANLINE: - /* make sure that only the applicable parameters are filled in */ - assert(config->start_delay == 0); - assert(config->period == 0); - assert(config->param == 0); - assert(config->first_vpos >= 0); - assert(config->increment >= 0); +//------------------------------------------------- +// device_start - perform device-specific +// startup +//------------------------------------------------- - /* allocate the backing timer */ - param = (void *)device; - state->timer = timer_alloc(device->machine, scanline_timer_device_timer_callback, param); +void timer_device::device_start() +{ + // fetch the screen + if (m_config.m_screen != NULL) + m_screen = downcast(machine->device(m_config.m_screen)); + + // allocate the timer + m_timer = timer_alloc(machine, (m_config.m_type == timer_device_config::TIMER_TYPE_SCANLINE) ? static_scanline_timer_callback : static_periodic_timer_callback, (void *)this); + + // register for save states + state_save_register_device_item(this, 0, m_first_time); +} - /* indicate that this will be the first call */ - state->first_time = TRUE; - /* register for state saves */ - state_save_register_device_item(device, 0, state->first_time); +//------------------------------------------------- +// device_reset - reset the device +//------------------------------------------------- - /* fire it as soon as the emulation starts */ - timer_adjust_oneshot(state->timer, attotime_zero, 0); +void timer_device::device_reset() +{ + // type based configuration + switch (m_config.m_type) + { + case timer_device_config::TIMER_TYPE_GENERIC: + case timer_device_config::TIMER_TYPE_PERIODIC: + { + // convert the period into attotime + attotime period = attotime_never; + if (m_config.m_period > 0) + period = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_period); + + // convert the start_delay into attotime + attotime start_delay = attotime_zero; + if (m_config.m_start_delay > 0) + start_delay = UINT64_ATTOTIME_TO_ATTOTIME(m_config.m_start_delay); + + // allocate and start the backing timer + timer_adjust_periodic(m_timer, start_delay, m_config.m_param, period); break; + } - default: - /* we will never get here */ - fatalerror("Unknown timer device type"); + case timer_device_config::TIMER_TYPE_SCANLINE: + if (m_screen == NULL) + fatalerror("timer '%s': unable to find screen '%s'\n", tag(), m_config.m_screen); + + // set the timer to to fire immediately + m_first_time = true; + timer_adjust_oneshot(m_timer, attotime_zero, m_config.m_param); break; } } /*------------------------------------------------- - timer_get_info - device get info callback + periodic_timer_callback - calls the timer + device specific callback -------------------------------------------------*/ -DEVICE_GET_INFO( timer ) +void timer_device::periodic_timer_callback(int param) { - switch (state) + (*m_config.m_callback)(*this, m_ptr, param); +} + + +/*------------------------------------------------- + scanline_timer_device_timer_callback - + manages the scanline based timer's state +-------------------------------------------------*/ + +void timer_device::scanline_timer_callback(int scanline) +{ + // by default, we fire at the first position + int next_vpos = m_config.m_first_vpos; + + // the first time through we just go with the default position + if (!m_first_time) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(timer_state); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(timer_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_TIMER; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(timer); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: /* Nothing */ break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Generic"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Timer"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + // call the real callback + int vpos = m_screen->vpos(); + (*m_config.m_callback)(*this, m_ptr, vpos); + + // advance by the increment only if we will still be within the screen bounds + if (m_config.m_increment != 0 && (vpos + m_config.m_increment) < m_screen->height()) + next_vpos = vpos + m_config.m_increment; } + m_first_time = false; + + // adjust the timer + timer_adjust_oneshot(m_timer, m_screen->time_until_pos(next_vpos), 0); } diff --git a/src/emu/timer.h b/src/emu/timer.h index d48540d71bc..af56bf054b4 100644 --- a/src/emu/timer.h +++ b/src/emu/timer.h @@ -19,19 +19,7 @@ #ifndef __TIMER_H__ #define __TIMER_H__ - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* timer types */ -enum -{ - TIMER_TYPE_PERIODIC = 0, - TIMER_TYPE_SCANLINE, - TIMER_TYPE_GENERIC -}; - +#include "devlegcy.h" /*************************************************************************** @@ -57,7 +45,7 @@ enum /* macros for a timer callback functions */ #define TIMER_CALLBACK(name) void name(running_machine *machine, void *ptr, int param) -#define TIMER_DEVICE_CALLBACK(name) void name(running_device *timer, void *ptr, INT32 param) +#define TIMER_DEVICE_CALLBACK(name) void name(timer_device &timer, void *ptr, INT32 param) @@ -65,41 +53,19 @@ enum TYPE DEFINITIONS ***************************************************************************/ -/* a timer callback looks like this */ -typedef void (*timer_fired_func)(running_machine *machine, void *ptr, INT32 param); -typedef void (*timer_device_fired_func)(running_device *timer, void *ptr, INT32 param); - +// forward declarations +class emu_timer; +class timer_device; -/*------------------------------------------------- - timer_config - configuration of a single - timer --------------------------------------------------*/ -typedef struct _timer_config timer_config; -struct _timer_config -{ - int type; /* type of timer */ - timer_device_fired_func callback; /* the timer's callback function */ - void *ptr; /* the pointer parameter passed to the timer callback */ - - /* periodic timers only */ - UINT64 start_delay; /* delay before the timer fires for the first time */ - UINT64 period; /* period of repeated timer firings */ - INT32 param; /* the integer parameter passed to the timer callback */ - - /* scanline timers only */ - const char *screen; /* the name of the screen this timer tracks */ - UINT32 first_vpos; /* the first vertical scanline position the timer fires on */ - UINT32 increment; /* the number of scanlines between firings */ -}; +// a timer callback looks like this +typedef void (*timer_fired_func)(running_machine *machine, void *ptr, INT32 param); +typedef void (*timer_device_fired_func)(timer_device &timer, void *ptr, INT32 param); -/* opaque type for representing a timer */ -typedef struct _emu_timer emu_timer; -typedef struct _timer_execution_state timer_execution_state; -struct _timer_execution_state +struct timer_execution_state { attotime nextfire; /* time that the head of the timer list will fire */ attotime basetime; /* global basetime; everything moves forward from here */ @@ -108,43 +74,43 @@ struct _timer_execution_state -/*************************************************************************** - TIMER DEVICE CONFIGURATION MACROS -***************************************************************************/ +//************************************************************************** +// TIMER DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_TIMER_ADD(_tag, _callback) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, type, TIMER_TYPE_GENERIC) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, callback, _callback) \ + MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_GENERIC) \ + MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) #define MDRV_TIMER_ADD_PERIODIC(_tag, _callback, _period) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, type, TIMER_TYPE_PERIODIC) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, callback, _callback) \ - MDRV_DEVICE_CONFIG_DATA64(timer_config, period, UINT64_ATTOTIME_IN_##_period) + MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_PERIODIC) \ + MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) \ + MDRV_DEVICE_INLINE_DATA64(timer_device_config::INLINE_PERIOD, UINT64_ATTOTIME_IN_##_period) #define MDRV_TIMER_ADD_SCANLINE(_tag, _callback, _screen, _first_vpos, _increment) \ MDRV_DEVICE_ADD(_tag, TIMER, 0) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, type, TIMER_TYPE_SCANLINE) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, callback, _callback) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, screen, _screen) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, first_vpos, _first_vpos) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, increment, _increment) + MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_TYPE, timer_device_config::TIMER_TYPE_SCANLINE) \ + MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_CALLBACK, _callback) \ + MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_SCREEN, _screen) \ + MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_FIRST_VPOS, _first_vpos) \ + MDRV_DEVICE_INLINE_DATA16(timer_device_config::INLINE_INCREMENT, _increment) #define MDRV_TIMER_MODIFY(_tag) \ MDRV_DEVICE_MODIFY(_tag) #define MDRV_TIMER_CALLBACK(_callback) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, callback, _callback) + MDRV_DEVICE_INLINE_DATA32(timer_device_config::INLINE_CALLBACK, _callback) #define MDRV_TIMER_START_DELAY(_start_delay) \ - MDRV_DEVICE_CONFIG_DATA64(timer_config, start_delay, UINT64_ATTOTIME_IN_##_start_delay) + MDRV_DEVICE_INLINE_DATA64(timer_device_config::INLINE_DELAY, UINT64_ATTOTIME_IN_##_start_delay) #define MDRV_TIMER_PARAM(_param) \ - MDRV_DEVICE_CONFIG_DATA32(timer_config, param, _param) + MDRV_DEVICE_INLINE_DATA32(timer_device_config::INLINE_PARAM, _param) #define MDRV_TIMER_PTR(_ptr) \ - MDRV_DEVICE_CONFIG_DATAPTR(timer_config, ptr, _ptr) + MDRV_DEVICE_INLINE_DATAPTR(timer_device_config::INLINE_PTR, _ptr) @@ -193,11 +159,9 @@ emu_timer *_timer_alloc_internal(running_machine *machine, timer_fired_func call /* adjust the time when this timer will fire and disable any periodic firings */ void timer_adjust_oneshot(emu_timer *which, attotime duration, INT32 param); -void timer_device_adjust_oneshot(running_device *timer, attotime duration, INT32 param); /* adjust the time when this timer will fire and specify a period for subsequent firings */ void timer_adjust_periodic(emu_timer *which, attotime start_delay, INT32 param, attotime period); -void timer_device_adjust_periodic(running_device *timer, attotime start_delay, INT32 param, attotime period); @@ -215,31 +179,24 @@ void _timer_pulse_internal(running_machine *machine, attotime period, void *ptr, /* reset the timing on a timer */ void timer_reset(emu_timer *which, attotime duration); -void timer_device_reset(running_device *timer); /* enable/disable a timer */ int timer_enable(emu_timer *which, int enable); -int timer_device_enable(running_device *timer, int enable); /* determine if a timer is enabled */ int timer_enabled(emu_timer *which); -int timer_device_enabled(running_device *timer); /* returns the callback parameter of a timer */ int timer_get_param(emu_timer *which); -int timer_device_get_param(running_device *timer); /* changes the callback parameter of a timer */ void timer_set_param(emu_timer *which, int param); -void timer_device_set_param(running_device *timer, int param); /* returns the callback pointer of a timer */ void *timer_get_ptr(emu_timer *which); -void *timer_device_get_ptr(running_device *timer); /* changes the callback pointer of a timer */ void timer_set_ptr(emu_timer *which, void *ptr); -void timer_device_set_ptr(running_device *timer, void *ptr); @@ -247,29 +204,138 @@ void timer_device_set_ptr(running_device *timer, void *ptr); /* return the time since the last trigger */ attotime timer_timeelapsed(emu_timer *which); -attotime timer_device_timeelapsed(running_device *timer); /* return the time until the next trigger */ attotime timer_timeleft(emu_timer *which); -attotime timer_device_timeleft(running_device *timer); /* return the current time */ attotime timer_get_time(running_machine *machine); /* return the time when this timer started counting */ attotime timer_starttime(emu_timer *which); -attotime timer_device_starttime(running_device *timer); /* return the time when this timer will fire next */ attotime timer_firetime(emu_timer *which); -attotime timer_device_firetime(running_device *timer); -/* ----- timer device interface ----- */ -/* device get info callback */ -#define TIMER DEVICE_GET_INFO_NAME(timer) -DEVICE_GET_INFO( timer ); +// ======================> timer_device_config + +class timer_device_config : public device_config +{ + friend class timer_device; + + // construction/destruction + timer_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Timer"; } + + // indexes to inline data + enum + { + INLINE_TYPE, + INLINE_CALLBACK, + INLINE_PERIOD, + INLINE_SCREEN, + INLINE_FIRST_VPOS, + INLINE_INCREMENT, + INLINE_DELAY, + INLINE_PARAM, + INLINE_PTR + }; + + // timer types + enum timer_type + { + TIMER_TYPE_PERIODIC, + TIMER_TYPE_SCANLINE, + TIMER_TYPE_GENERIC + }; + +private: + // device_config overrides + virtual void device_config_complete(); + virtual bool device_validity_check(const game_driver &driver) const; + + // configuration data + timer_type m_type; // type of timer + timer_device_fired_func m_callback; // the timer's callback function + void * m_ptr; // the pointer parameter passed to the timer callback + + // periodic timers only + UINT64 m_start_delay; // delay before the timer fires for the first time + UINT64 m_period; // period of repeated timer firings + INT32 m_param; // the integer parameter passed to the timer callback + + // scanline timers only + const char * m_screen; // the name of the screen this timer tracks + UINT32 m_first_vpos; // the first vertical scanline position the timer fires on + UINT32 m_increment; // the number of scanlines between firings +}; + + + +// ======================> timer_device + +class timer_device : public device_t +{ + friend class timer_device_config; + + // construction/destruction + timer_device(running_machine &_machine, const timer_device_config &config); + +public: + // property getters + int param() const { return timer_get_param(m_timer); } + void *ptr() const { return m_ptr; } + bool enabled() const { return (timer_enabled(m_timer) != 0); } + + // property setters + void set_param(int param) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); timer_set_param(m_timer, param); } + void set_ptr(void *ptr) { m_ptr = ptr; } + void enable(bool enable = true) { timer_enable(m_timer, enable); } + + // adjustments + void reset() { adjust(attotime_never, 0, attotime_never); } + void adjust(attotime duration, INT32 param = 0, attotime period = attotime_never) { assert(m_config.m_type == timer_device_config::TIMER_TYPE_GENERIC); timer_adjust_periodic(m_timer, duration, param, period); } + + // timing information + attotime time_elapsed() const { return timer_timeelapsed(m_timer); } + attotime time_left() const { return timer_timeleft(m_timer); } + attotime start_time() const { return timer_starttime(m_timer); } + attotime fire_time() const { return timer_firetime(m_timer); } + +private: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // internal helpers + static TIMER_CALLBACK( static_periodic_timer_callback ) { reinterpret_cast(ptr)->periodic_timer_callback(param); } + void periodic_timer_callback(int param); + + static TIMER_CALLBACK( static_scanline_timer_callback ) { reinterpret_cast(ptr)->scanline_timer_callback(param); } + void scanline_timer_callback(int scanline); + + // internal state + const timer_device_config &m_config; + emu_timer * m_timer; // the backing timer + void * m_ptr; // the pointer parameter passed to the timer callback + + // scanline timers only + screen_device *m_screen; // pointer to the screen + bool m_first_time; // indicates that the system is starting +}; + + +// device type definition +const device_type TIMER = timer_device_config::static_alloc_device_config; #endif /* __TIMER_H__ */ diff --git a/src/emu/ui.c b/src/emu/ui.c index 439607f33c8..1703e1f1080 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -165,8 +165,8 @@ static INT32 slider_overxoffset(running_machine *machine, void *arg, astring *st static INT32 slider_overyoffset(running_machine *machine, void *arg, astring *string, INT32 newval); static INT32 slider_flicker(running_machine *machine, void *arg, astring *string, INT32 newval); static INT32 slider_beam(running_machine *machine, void *arg, astring *string, INT32 newval); -static char *slider_get_screen_desc(running_device *screen); -static char *slider_get_laserdisc_desc(running_device *screen); +static char *slider_get_screen_desc(screen_device &screen); +static char *slider_get_laserdisc_desc(device_t *screen); #ifdef MAME_DEBUG static INT32 slider_crossscale(running_machine *machine, void *arg, astring *string, INT32 newval); static INT32 slider_crossoffset(running_machine *machine, void *arg, astring *string, INT32 newval); @@ -1002,9 +1002,9 @@ static astring &warnings_string(running_machine *machine, astring &string) astring &game_info_astring(running_machine *machine, astring &string) { - int scrcount = video_screen_count(machine->config); - running_device *scandevice; - running_device *device; + int scrcount = screen_count(*machine->config); + device_t *scandevice; + device_t *device; int found_sound = FALSE; int count; @@ -1015,13 +1015,13 @@ astring &game_info_astring(running_machine *machine, astring &string) for (device = machine->firstcpu; device != NULL; device = scandevice) { /* get cpu specific clock that takes internal multiplier/dividers into account */ - int clock = cpu_get_clock(device); + int clock = device->clock(); /* count how many identical CPUs we have */ count = 1; for (scandevice = device->typenext(); scandevice != NULL; scandevice = scandevice->typenext()) { - if (cpu_get_type(device) != cpu_get_type(scandevice) || device->clock != scandevice->clock) + if (cpu_get_type(device) != cpu_get_type(scandevice) || device->clock() != scandevice->clock()) break; count++; } @@ -1039,7 +1039,8 @@ astring &game_info_astring(running_machine *machine, astring &string) } /* loop over all sound chips */ - for (device = sound_first(machine); device != NULL; device = scandevice) + device_sound_interface *sound; + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) { /* append the Sound: string */ if (!found_sound) @@ -1048,23 +1049,26 @@ astring &game_info_astring(running_machine *machine, astring &string) /* count how many identical sound chips we have */ count = 1; - for (scandevice = device->typenext(); scandevice != NULL; scandevice = scandevice->typenext()) + device_sound_interface *scan = sound; + for (bool gotanother = scan->next(scan); gotanother; gotanother = scan->next(scan)) { - if (sound_get_type(device) != sound_get_type(scandevice) || device->clock != scandevice->clock) + if (sound->device().type() != scan->device().type() || sound->device().clock() != scan->device().clock()) break; count++; + sound = scan; } /* if more than one, prepend a #x in front of the CPU name */ if (count > 1) string.catprintf("%d" UTF8_MULTIPLY, count); - string.cat(device->name()); + string.cat(sound->device().name()); /* display clock in kHz or MHz */ - if (device->clock >= 1000000) - string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", device->clock / 1000000, device->clock % 1000000); - else if (device->clock != 0) - string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", device->clock / 1000, device->clock % 1000); + int clock = sound->device().clock(); + if (clock >= 1000000) + string.catprintf(" %d.%06d" UTF8_NBSP "MHz\n", clock / 1000000, clock % 1000000); + else if (clock != 0) + string.catprintf(" %d.%03d" UTF8_NBSP "kHz\n", clock / 1000, clock % 1000); else string.cat("\n"); } @@ -1075,27 +1079,25 @@ astring &game_info_astring(running_machine *machine, astring &string) string.cat("None\n"); else { - for (running_device *screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { - const screen_config *scrconfig = (const screen_config *)screen->baseconfig().inline_config; - if (scrcount > 1) { - string.cat(slider_get_screen_desc(screen)); + string.cat(slider_get_screen_desc(*screen)); string.cat(": "); } - if (scrconfig->type == SCREEN_TYPE_VECTOR) + if (screen->screen_type() == SCREEN_TYPE_VECTOR) string.cat("Vector\n"); else { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); string.catprintf("%d " UTF8_MULTIPLY " %d (%s) %f" UTF8_NBSP "Hz\n", - visarea->max_x - visarea->min_x + 1, - visarea->max_y - visarea->min_y + 1, + visarea.max_x - visarea.min_x + 1, + visarea.max_y - visarea.min_y + 1, (machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H", - ATTOSECONDS_TO_HZ(video_screen_get_frame_period(screen).attoseconds)); + ATTOSECONDS_TO_HZ(screen->frame_period().attoseconds)); } } } @@ -1590,7 +1592,7 @@ static slider_state *slider_init(running_machine *machine) { const input_field_config *field; const input_port_config *port; - running_device *device; + device_t *device; slider_state *listhead = NULL; slider_state **tailptr = &listhead; astring string; @@ -1616,7 +1618,7 @@ static slider_state *slider_init(running_machine *machine) } /* add analog adjusters */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == IPT_ADJUSTER) { @@ -1638,52 +1640,51 @@ static slider_state *slider_init(running_machine *machine) } /* add screen parameters */ - for (device = video_screen_first(machine); device != NULL; device = video_screen_next(device)) + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) { - const screen_config *scrconfig = (const screen_config *)device->baseconfig().inline_config; - int defxscale = floor(scrconfig->xscale * 1000.0f + 0.5f); - int defyscale = floor(scrconfig->yscale * 1000.0f + 0.5f); - int defxoffset = floor(scrconfig->xoffset * 1000.0f + 0.5f); - int defyoffset = floor(scrconfig->yoffset * 1000.0f + 0.5f); - void *param = (void *)device; + int defxscale = floor(screen->config().xscale() * 1000.0f + 0.5f); + int defyscale = floor(screen->config().yscale() * 1000.0f + 0.5f); + int defxoffset = floor(screen->config().xoffset() * 1000.0f + 0.5f); + int defyoffset = floor(screen->config().yoffset() * 1000.0f + 0.5f); + void *param = (void *)screen; /* add refresh rate tweaker */ if (options_get_bool(mame_options(), OPTION_CHEAT)) { - string.printf("%s Refresh Rate", slider_get_screen_desc(device)); + string.printf("%s Refresh Rate", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, -10000, 0, 10000, 1000, slider_refresh, param); tailptr = &(*tailptr)->next; } /* add standard brightness/contrast/gamma controls per-screen */ - string.printf("%s Brightness", slider_get_screen_desc(device)); + string.printf("%s Brightness", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, 100, 1000, 2000, 10, slider_brightness, param); tailptr = &(*tailptr)->next; - string.printf("%s Contrast", slider_get_screen_desc(device)); + string.printf("%s Contrast", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, 100, 1000, 2000, 50, slider_contrast, param); tailptr = &(*tailptr)->next; - string.printf("%s Gamma", slider_get_screen_desc(device)); + string.printf("%s Gamma", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, 100, 1000, 3000, 50, slider_gamma, param); tailptr = &(*tailptr)->next; /* add scale and offset controls per-screen */ - string.printf("%s Horiz Stretch", slider_get_screen_desc(device)); - *tailptr = slider_alloc(machine, string, 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, param); + string.printf("%s Horiz Stretch", slider_get_screen_desc(*screen)); + *tailptr = slider_alloc(machine, string, 500, defxscale, 1500, 2, slider_xscale, param); tailptr = &(*tailptr)->next; - string.printf("%s Horiz Position", slider_get_screen_desc(device)); + string.printf("%s Horiz Position", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, -500, defxoffset, 500, 2, slider_xoffset, param); tailptr = &(*tailptr)->next; - string.printf("%s Vert Stretch", slider_get_screen_desc(device)); - *tailptr = slider_alloc(machine, string, 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, param); + string.printf("%s Vert Stretch", slider_get_screen_desc(*screen)); + *tailptr = slider_alloc(machine, string, 500, defyscale, 1500, 2, slider_yscale, param); tailptr = &(*tailptr)->next; - string.printf("%s Vert Position", slider_get_screen_desc(device)); + string.printf("%s Vert Position", slider_get_screen_desc(*screen)); *tailptr = slider_alloc(machine, string, -500, defyoffset, 500, 2, slider_yoffset, param); tailptr = &(*tailptr)->next; } for (device = machine->devicelist.first(LASERDISC); device != NULL; device = device->typenext()) { - const laserdisc_config *config = (const laserdisc_config *)device->baseconfig().inline_config; + const laserdisc_config *config = (const laserdisc_config *)downcast(device->baseconfig()).inline_config(); if (config->overupdate != NULL) { int defxscale = floor(config->overscalex * 1000.0f + 0.5f); @@ -1708,10 +1709,8 @@ static slider_state *slider_init(running_machine *machine) } } - for (device = video_screen_first(machine); device != NULL; device = video_screen_next(device)) - { - const screen_config *scrconfig = (const screen_config *)device->baseconfig().inline_config; - if (scrconfig->type == SCREEN_TYPE_VECTOR) + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + if (screen->screen_type() == SCREEN_TYPE_VECTOR) { /* add flicker control */ *tailptr = slider_alloc(machine, "Vector Flicker", 0, 0, 1000, 10, slider_flicker, NULL); @@ -1720,11 +1719,10 @@ static slider_state *slider_init(running_machine *machine) tailptr = &(*tailptr)->next; break; } - } #ifdef MAME_DEBUG /* add crosshair adjusters */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0) { @@ -1801,7 +1799,7 @@ static INT32 slider_adjuster(running_machine *machine, void *arg, astring *strin static INT32 slider_overclock(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *cpu = (running_device *)arg; + device_t *cpu = (device_t *)arg; if (newval != SLIDER_NOCHANGE) cpu_set_clockscale(cpu, (float)newval * 0.001f); if (string != NULL) @@ -1816,22 +1814,20 @@ static INT32 slider_overclock(running_machine *machine, void *arg, astring *stri static INT32 slider_refresh(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; - const screen_config *scrconfig = (const screen_config *)screen->baseconfig().inline_config; - double defrefresh = ATTOSECONDS_TO_HZ(scrconfig->refresh); + screen_device *screen = reinterpret_cast(arg); + double defrefresh = ATTOSECONDS_TO_HZ(screen->config().refresh()); double refresh; if (newval != SLIDER_NOCHANGE) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); - const rectangle *visarea = video_screen_get_visible_area(screen); - - video_screen_configure(screen, width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001)); + int width = screen->width(); + int height = screen->height(); + const rectangle &visarea = screen->visible_area(); + screen->configure(width, height, visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001)); } if (string != NULL) - string->printf("%.3ffps", ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds)); - refresh = ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds); + string->printf("%.3ffps", ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds)); + refresh = ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds); return floor((refresh - defrefresh) * 1000.0f + 0.5f); } @@ -1843,7 +1839,7 @@ static INT32 slider_refresh(running_machine *machine, void *arg, astring *string static INT32 slider_brightness(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1866,7 +1862,7 @@ static INT32 slider_brightness(running_machine *machine, void *arg, astring *str static INT32 slider_contrast(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1888,7 +1884,7 @@ static INT32 slider_contrast(running_machine *machine, void *arg, astring *strin static INT32 slider_gamma(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1911,7 +1907,7 @@ static INT32 slider_gamma(running_machine *machine, void *arg, astring *string, static INT32 slider_xscale(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1934,7 +1930,7 @@ static INT32 slider_xscale(running_machine *machine, void *arg, astring *string, static INT32 slider_yscale(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1957,7 +1953,7 @@ static INT32 slider_yscale(running_machine *machine, void *arg, astring *string, static INT32 slider_xoffset(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -1980,7 +1976,7 @@ static INT32 slider_xoffset(running_machine *machine, void *arg, astring *string static INT32 slider_yoffset(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *screen = (running_device *)arg; + screen_device *screen = reinterpret_cast(arg); render_container *container = render_container_get_screen(screen); render_container_user_settings settings; @@ -2003,7 +1999,7 @@ static INT32 slider_yoffset(running_machine *machine, void *arg, astring *string static INT32 slider_overxscale(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *laserdisc = (running_device *)arg; + device_t *laserdisc = (device_t *)arg; laserdisc_config settings; laserdisc_get_config(laserdisc, &settings); @@ -2025,7 +2021,7 @@ static INT32 slider_overxscale(running_machine *machine, void *arg, astring *str static INT32 slider_overyscale(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *laserdisc = (running_device *)arg; + device_t *laserdisc = (device_t *)arg; laserdisc_config settings; laserdisc_get_config(laserdisc, &settings); @@ -2047,7 +2043,7 @@ static INT32 slider_overyscale(running_machine *machine, void *arg, astring *str static INT32 slider_overxoffset(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *laserdisc = (running_device *)arg; + device_t *laserdisc = (device_t *)arg; laserdisc_config settings; laserdisc_get_config(laserdisc, &settings); @@ -2069,7 +2065,7 @@ static INT32 slider_overxoffset(running_machine *machine, void *arg, astring *st static INT32 slider_overyoffset(running_machine *machine, void *arg, astring *string, INT32 newval) { - running_device *laserdisc = (running_device *)arg; + device_t *laserdisc = (device_t *)arg; laserdisc_config settings; laserdisc_get_config(laserdisc, &settings); @@ -2119,13 +2115,13 @@ static INT32 slider_beam(running_machine *machine, void *arg, astring *string, I description for a given screen -------------------------------------------------*/ -static char *slider_get_screen_desc(running_device *screen) +static char *slider_get_screen_desc(screen_device &screen) { - int screen_count = video_screen_count(screen->machine->config); + int scrcount = screen_count(*screen.machine->config); static char descbuf[256]; - if (screen_count > 1) - sprintf(descbuf, "Screen '%s'", screen->tag()); + if (scrcount > 1) + sprintf(descbuf, "Screen '%s'", screen.tag()); else strcpy(descbuf, "Screen"); @@ -2138,7 +2134,7 @@ static char *slider_get_screen_desc(running_device *screen) description for a given laseridsc -------------------------------------------------*/ -static char *slider_get_laserdisc_desc(running_device *laserdisc) +static char *slider_get_laserdisc_desc(device_t *laserdisc) { int ldcount = laserdisc->machine->devicelist.count(LASERDISC); static char descbuf[256]; diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c index 0b37046707a..bbaeb48f3f6 100644 --- a/src/emu/uigfx.c +++ b/src/emu/uigfx.c @@ -141,8 +141,7 @@ static void ui_gfx_exit(running_machine *machine) ui_gfx.texture = NULL; /* free the bitmap */ - if (ui_gfx.bitmap != NULL) - bitmap_free(ui_gfx.bitmap); + global_free(ui_gfx.bitmap); ui_gfx.bitmap = NULL; } @@ -697,11 +696,10 @@ static void gfxset_update_bitmap(running_machine *machine, ui_gfx_state *state, /* free the old stuff */ if (state->texture != NULL) render_texture_free(state->texture); - if (state->bitmap != NULL) - bitmap_free(state->bitmap); + global_free(state->bitmap); /* allocate new stuff */ - state->bitmap = bitmap_alloc(cellxpix * xcells, cellypix * ycells, BITMAP_FORMAT_ARGB32); + state->bitmap = global_alloc(bitmap_t(cellxpix * xcells, cellypix * ycells, BITMAP_FORMAT_ARGB32)); state->texture = render_texture_alloc(NULL, NULL); render_texture_set_bitmap(state->texture, state->bitmap, NULL, TEXFORMAT_ARGB32, NULL); @@ -1034,7 +1032,7 @@ static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, i static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, int width, int height) { - bitmap_format screen_format = video_screen_get_format(machine->primary_screen); + bitmap_format screen_format = machine->primary_screen->format(); palette_t *palette = NULL; int screen_texformat; @@ -1057,11 +1055,10 @@ static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, /* free the old stuff */ if (state->texture != NULL) render_texture_free(state->texture); - if (state->bitmap != NULL) - bitmap_free(state->bitmap); + global_free(state->bitmap); /* allocate new stuff */ - state->bitmap = bitmap_alloc(width, height, screen_format); + state->bitmap = global_alloc(bitmap_t(width, height, screen_format)); state->texture = render_texture_alloc(NULL, NULL); render_texture_set_bitmap(state->texture, state->bitmap, NULL, screen_texformat, palette); diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index f0160a20bce..c100f89b367 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -1497,7 +1497,7 @@ static void menu_main_populate(running_machine *machine, ui_menu *menu, void *st int has_dips = FALSE; /* scan the input port array to see what options we need to enable */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) { if (field->type == IPT_DIPSWITCH) @@ -1699,7 +1699,7 @@ static void menu_input_specific_populate(running_machine *machine, ui_menu *menu suborder[SEQ_TYPE_INCREMENT] = 2; /* iterate over the input ports and add menu items */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) { const char *name = input_field_name(field); @@ -2053,7 +2053,7 @@ static void menu_settings_populate(running_machine *machine, ui_menu *menu, sett diplist_tailptr = &menustate->diplist; /* loop over input ports and set up the current values */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (field->type == type && input_condition_true(machine, &field->condition)) { @@ -2307,7 +2307,7 @@ static void menu_analog_populate(running_machine *machine, ui_menu *menu) astring text; /* loop over input ports and add the items */ - for (port = machine->portlist.first(); port != NULL; port = port->next) + for (port = machine->portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) if (input_type_is_analog(field->type)) { diff --git a/src/emu/validity.c b/src/emu/validity.c index b450b8fb00a..598fcc506f2 100644 --- a/src/emu/validity.c +++ b/src/emu/validity.c @@ -21,7 +21,6 @@ ***************************************************************************/ #define REPORT_TIMES (0) -#define DETECT_OVERLAPPING_MEMORY (0) @@ -87,12 +86,12 @@ INLINE const char *input_port_string_from_index(UINT32 index) meets the general requirements -------------------------------------------------*/ -INLINE int validate_tag(const game_driver *driver, const char *object, const char *tag) +bool validate_tag(const game_driver *driver, const char *object, const char *tag) { const char *validchars = "abcdefghijklmnopqrstuvwxyz0123456789_.:"; const char *begin = strrchr(tag, ':'); const char *p; - int error = FALSE; + bool error = false; /* some common names that are now deprecated */ if (strcmp(tag, "main") == 0 || @@ -102,7 +101,7 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha strcmp(tag, "right") == 0) { mame_printf_error("%s: %s has invalid generic tag '%s'\n", driver->source_file, driver->name, tag); - error = TRUE; + error = true; } for (p = tag; *p != 0; p++) @@ -110,19 +109,19 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha if (*p != tolower((UINT8)*p)) { mame_printf_error("%s: %s has %s with tag '%s' containing upper-case characters\n", driver->source_file, driver->name, object, tag); - error = TRUE; + error = true; break; } if (*p == ' ') { mame_printf_error("%s: %s has %s with tag '%s' containing spaces\n", driver->source_file, driver->name, object, tag); - error = TRUE; + error = true; break; } if (strchr(validchars, *p) == NULL) { mame_printf_error("%s: %s has %s with tag '%s' containing invalid character '%c'\n", driver->source_file, driver->name, object, tag, *p); - error = TRUE; + error = true; break; } } @@ -135,20 +134,20 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha if (strlen(begin) == 0) { mame_printf_error("%s: %s has %s with 0-length tag\n", driver->source_file, driver->name, object); - error = TRUE; + error = true; } if (strlen(begin) < MIN_TAG_LENGTH) { mame_printf_error("%s: %s has %s with tag '%s' < %d characters\n", driver->source_file, driver->name, object, tag, MIN_TAG_LENGTH); - error = TRUE; + error = true; } if (strlen(begin) > MAX_TAG_LENGTH) { mame_printf_error("%s: %s has %s with tag '%s' > %d characters\n", driver->source_file, driver->name, object, tag, MAX_TAG_LENGTH); - error = TRUE; + error = true; } - return error; + return !error; } @@ -162,7 +161,7 @@ INLINE int validate_tag(const game_driver *driver, const char *object, const cha behaviors -------------------------------------------------*/ -static int validate_inlines(void) +static bool validate_inlines(void) { #undef rand volatile UINT64 testu64a = rand() ^ (rand() << 15) ^ ((UINT64)rand() << 30) ^ ((UINT64)rand() << 45); @@ -180,7 +179,7 @@ static int validate_inlines(void) UINT64 resultu64, expectedu64; INT32 remainder, expremainder; UINT32 uremainder, expuremainder, bigu32 = 0xffffffff; - int error = FALSE; + bool error = false; /* use only non-zero, positive numbers */ if (testu64a == 0) testu64a++; @@ -200,32 +199,32 @@ static int validate_inlines(void) resulti64 = mul_32x32(testi32a, testi32b); expectedi64 = (INT64)testi32a * (INT64)testi32b; if (resulti64 != expectedi64) - { mame_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (UINT32)(resulti64 >> 32), (UINT32)resulti64, (UINT32)(expectedi64 >> 32), (UINT32)expectedi64); error = TRUE; } + { mame_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (UINT32)(resulti64 >> 32), (UINT32)resulti64, (UINT32)(expectedi64 >> 32), (UINT32)expectedi64); error = true; } resultu64 = mulu_32x32(testu32a, testu32b); expectedu64 = (UINT64)testu32a * (UINT64)testu32b; if (resultu64 != expectedu64) - { mame_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (UINT32)(resultu64 >> 32), (UINT32)resultu64, (UINT32)(expectedu64 >> 32), (UINT32)expectedu64); error = TRUE; } + { mame_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (UINT32)(resultu64 >> 32), (UINT32)resultu64, (UINT32)(expectedu64 >> 32), (UINT32)expectedu64); error = true; } resulti32 = mul_32x32_hi(testi32a, testi32b); expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 32; if (resulti32 != expectedi32) - { mame_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; } + { mame_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = true; } resultu32 = mulu_32x32_hi(testu32a, testu32b); expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 32; if (resultu32 != expectedu32) - { mame_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; } + { mame_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = true; } resulti32 = mul_32x32_shift(testi32a, testi32b, 7); expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 7; if (resulti32 != expectedi32) - { mame_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; } + { mame_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = true; } resultu32 = mulu_32x32_shift(testu32a, testu32b, 7); expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 7; if (resultu32 != expectedu32) - { mame_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; } + { mame_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = true; } while ((INT64)testi32a * (INT64)0x7fffffff < testi64a) testi64a /= 2; @@ -235,34 +234,34 @@ static int validate_inlines(void) resulti32 = div_64x32(testi64a, testi32a); expectedi32 = testi64a / (INT64)testi32a; if (resulti32 != expectedi32) - { mame_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; } + { mame_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = true; } resultu32 = divu_64x32(testu64a, testu32a); expectedu32 = testu64a / (UINT64)testu32a; if (resultu32 != expectedu32) - { mame_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; } + { mame_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; } resulti32 = div_64x32_rem(testi64a, testi32a, &remainder); expectedi32 = testi64a / (INT64)testi32a; expremainder = testi64a % (INT64)testi32a; if (resulti32 != expectedi32 || remainder != expremainder) - { mame_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); error = TRUE; } + { mame_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); error = true; } resultu32 = divu_64x32_rem(testu64a, testu32a, &uremainder); expectedu32 = testu64a / (UINT64)testu32a; expuremainder = testu64a % (UINT64)testu32a; if (resultu32 != expectedu32 || uremainder != expuremainder) - { mame_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); error = TRUE; } + { mame_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); error = true; } resulti32 = mod_64x32(testi64a, testi32a); expectedi32 = testi64a % (INT64)testi32a; if (resulti32 != expectedi32) - { mame_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; } + { mame_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = true; } resultu32 = modu_64x32(testu64a, testu32a); expectedu32 = testu64a % (UINT64)testu32a; if (resultu32 != expectedu32) - { mame_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; } + { mame_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; } while ((INT64)testi32a * (INT64)0x7fffffff < ((INT32)testi64a << 3)) testi64a /= 2; @@ -272,39 +271,39 @@ static int validate_inlines(void) resulti32 = div_32x32_shift((INT32)testi64a, testi32a, 3); expectedi32 = ((INT64)(INT32)testi64a << 3) / (INT64)testi32a; if (resulti32 != expectedi32) - { mame_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (INT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; } + { mame_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (INT32)testi64a, testi32a, resulti32, expectedi32); error = true; } resultu32 = divu_32x32_shift((UINT32)testu64a, testu32a, 3); expectedu32 = ((UINT64)(UINT32)testu64a << 3) / (UINT64)testu32a; if (resultu32 != expectedu32) - { mame_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; } + { mame_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (UINT32)testu64a, testu32a, resultu32, expectedu32); error = true; } if (fabs(recip_approx(100.0) - 0.01) > 0.0001) - { mame_printf_error("Error testing recip_approx\n"); error = TRUE; } + { mame_printf_error("Error testing recip_approx\n"); error = true; } testi32a = (testi32a & 0x0000ffff) | 0x400000; if (count_leading_zeros(testi32a) != 9) - { mame_printf_error("Error testing count_leading_zeros\n"); error = TRUE; } + { mame_printf_error("Error testing count_leading_zeros\n"); error = true; } testi32a = (testi32a | 0xffff0000) & ~0x400000; if (count_leading_ones(testi32a) != 9) - { mame_printf_error("Error testing count_leading_ones\n"); error = TRUE; } + { mame_printf_error("Error testing count_leading_ones\n"); error = true; } testi32b = testi32a; if (compare_exchange32(&testi32a, testi32b, 1000) != testi32b || testi32a != 1000) - { mame_printf_error("Error testing compare_exchange32\n"); error = TRUE; } + { mame_printf_error("Error testing compare_exchange32\n"); error = true; } #ifdef PTR64 testi64b = testi64a; if (compare_exchange64(&testi64a, testi64b, 1000) != testi64b || testi64a != 1000) - { mame_printf_error("Error testing compare_exchange64\n"); error = TRUE; } + { mame_printf_error("Error testing compare_exchange64\n"); error = true; } #endif if (atomic_exchange32(&testi32a, testi32b) != 1000) - { mame_printf_error("Error testing atomic_exchange32\n"); error = TRUE; } + { mame_printf_error("Error testing atomic_exchange32\n"); error = true; } if (atomic_add32(&testi32a, 45) != testi32b + 45) - { mame_printf_error("Error testing atomic_add32\n"); error = TRUE; } + { mame_printf_error("Error testing atomic_add32\n"); error = true; } if (atomic_increment32(&testi32a) != testi32b + 46) - { mame_printf_error("Error testing atomic_increment32\n"); error = TRUE; } + { mame_printf_error("Error testing atomic_increment32\n"); error = true; } if (atomic_decrement32(&testi32a) != testi32b + 45) - { mame_printf_error("Error testing atomic_decrement32\n"); error = TRUE; } + { mame_printf_error("Error testing atomic_decrement32\n"); error = true; } return error; } @@ -315,13 +314,13 @@ static int validate_inlines(void) information -------------------------------------------------*/ -static int validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions) +static bool validate_driver(int drivnum, const machine_config *config, game_driver_map &names, game_driver_map &descriptions) { const game_driver *driver = drivers[drivnum]; const game_driver *clone_of; const char *compatible_with; const game_driver *other_drv; - int error = FALSE, is_clone; + bool error = FALSE, is_clone; const char *s; enum { NAME_LEN_PARENT = 8, NAME_LEN_CLONE = 16 }; @@ -331,7 +330,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive { const game_driver *match = names.find(driver->name); mame_printf_error("%s: %s is a duplicate name (%s, %s)\n", driver->source_file, driver->name, match->source_file, match->name); - error = TRUE; + error = true; } /* check for duplicate descriptions */ @@ -339,35 +338,35 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive { const game_driver *match = descriptions.find(driver->description); mame_printf_error("%s: %s is a duplicate description (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->description); - error = TRUE; + error = true; } /* determine the clone */ - is_clone = strcmp(driver->parent, "0"); + is_clone = (strcmp(driver->parent, "0") != 0); clone_of = driver_get_clone(driver); if (clone_of && (clone_of->flags & GAME_IS_BIOS_ROOT)) - is_clone = 0; + is_clone = false; /* if we have at least 100 drivers, validate the clone */ /* (100 is arbitrary, but tries to avoid tiny.mak dependencies) */ if (driver_list_get_count(drivers) > 100 && !clone_of && is_clone) { mame_printf_error("%s: %s is a non-existant clone\n", driver->source_file, driver->parent); - error = TRUE; + error = true; } /* look for recursive cloning */ if (clone_of == driver) { mame_printf_error("%s: %s is set as a clone of itself\n", driver->source_file, driver->name); - error = TRUE; + error = true; } /* look for clones that are too deep */ if (clone_of != NULL && (clone_of = driver_get_clone(clone_of)) != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0) { mame_printf_error("%s: %s is a clone of a clone\n", driver->source_file, driver->name); - error = TRUE; + error = true; } /* make sure the driver name is 8 chars or less */ @@ -375,7 +374,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive { mame_printf_error("%s: %s %s driver name must be %d characters or less\n", driver->source_file, driver->name, is_clone ? "clone" : "parent", is_clone ? NAME_LEN_CLONE : NAME_LEN_PARENT); - error = TRUE; + error = true; } /* make sure the year is only digits, '?' or '+' */ @@ -383,7 +382,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive if (!isdigit((UINT8)*s) && *s != '?' && *s != '+') { mame_printf_error("%s: %s has an invalid year '%s'\n", driver->source_file, driver->name, driver->year); - error = TRUE; + error = true; break; } @@ -396,14 +395,14 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive if ((compatible_with != NULL) && (driver_get_name(driver->compatible_with) == NULL)) { mame_printf_error("%s: is compatible with %s, which is not in drivers[]\n", driver->name, driver->compatible_with); - error = TRUE; + error = true; } /* check for clone_of and compatible_with being specified at the same time */ if ((driver_get_clone(driver) != NULL) && (compatible_with != NULL)) { mame_printf_error("%s: both compatible_with and clone_of are specified\n", driver->name); - error = TRUE; + error = true; } /* find any recursive dependencies on the current driver */ @@ -412,16 +411,17 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive if (driver == other_drv) { mame_printf_error("%s: recursive compatibility\n", driver->name); - error = TRUE; + error = true; break; } } /* make sure sound-less drivers are flagged */ - if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && sound_first(config) == NULL && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0) + const device_config_sound_interface *sound; + if ((driver->flags & GAME_IS_BIOS_ROOT) == 0 && !config->devicelist.first(sound) && (driver->flags & GAME_NO_SOUND) == 0 && (driver->flags & GAME_NO_SOUND_HW) == 0) { mame_printf_error("%s: %s missing GAME_NO_SOUND flag\n", driver->source_file, driver->name); - error = TRUE; + error = true; } return error; @@ -432,7 +432,7 @@ static int validate_driver(int drivnum, const machine_config *config, game_drive validate_roms - validate ROM definitions -------------------------------------------------*/ -static int validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms) +static bool validate_roms(int drivnum, const machine_config *config, region_array *rgninfo, game_driver_map &roms) { const game_driver *driver = drivers[drivnum]; int bios_flags = 0, last_bios = 0; @@ -440,7 +440,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array const char *last_name = "???"; region_entry *currgn = NULL; int items_since_region = 1; - int error = FALSE; + bool error = false; /* check for duplicate ROM entries */ /* @@ -452,7 +452,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array { const game_driver *match = roms.find(romaddr); mame_printf_error("%s: %s uses the same ROM set as (%s, %s)\n", driver->source_file, driver->description, match->source_file, match->name); - error = TRUE; + error = true; } } */ @@ -478,14 +478,14 @@ static int validate_roms(int drivnum, const machine_config *config, region_array if (regiontag == NULL) { mame_printf_error("%s: %s has NULL ROM_REGION tag\n", driver->source_file, driver->name); - error = TRUE; + error = true; } /* load by name entries must be 8 characters or less */ else if (ROMREGION_ISLOADBYNAME(romp) && strlen(regiontag) > 8) { mame_printf_error("%s: %s has load-by-name region '%s' with name >8 characters\n", driver->source_file, driver->name, regiontag); - error = TRUE; + error = true; } /* find any empty entry, checking for duplicates */ @@ -511,14 +511,15 @@ static int validate_roms(int drivnum, const machine_config *config, region_array if (fulltag.cmp(rgninfo->entries[rgnnum].tag) == 0) { mame_printf_error("%s: %s has duplicate ROM_REGION tag '%s'\n", driver->source_file, driver->name, fulltag.cstr()); - error = TRUE; + error = true; break; } } } /* validate the region tag */ - error |= validate_tag(driver, "region", regiontag); + if (!validate_tag(driver, "region", regiontag)) + error = true; } /* If this is a system bios, make sure it is using the next available bios number */ @@ -529,7 +530,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array { const char *name = ROM_GETNAME(romp); mame_printf_error("%s: %s has non-sequential bios %s\n", driver->source_file, driver->name, name); - error = TRUE; + error = true; } last_bios = bios_flags; } @@ -550,7 +551,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array if (tolower((UINT8)*s) != *s) { mame_printf_error("%s: %s has upper case ROM name %s\n", driver->source_file, driver->name, last_name); - error = TRUE; + error = true; break; } @@ -559,7 +560,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array if (!hash_verify_string(hash)) { mame_printf_error("%s: rom '%s' has an invalid hash string '%s'\n", driver->name, last_name, hash); - error = TRUE; + error = true; } } @@ -571,7 +572,7 @@ static int validate_roms(int drivnum, const machine_config *config, region_array if (ROM_GETOFFSET(romp) + ROM_GETLENGTH(romp) > currgn->length) { mame_printf_error("%s: %s has ROM %s extending past the defined memory region\n", driver->source_file, driver->name, last_name); - error = TRUE; + error = true; } } } @@ -585,143 +586,26 @@ static int validate_roms(int drivnum, const machine_config *config, region_array } -/*------------------------------------------------- - validate_cpu - validate CPUs and memory maps --------------------------------------------------*/ - -static int validate_cpu(int drivnum, const machine_config *config) -{ - const game_driver *driver = drivers[drivnum]; - cpu_validity_check_func cpu_validity_check; - const device_config *devconfig; - int error = FALSE; - - /* loop over all the CPUs */ - for (devconfig = cpu_first(config); devconfig != NULL; devconfig = cpu_next(devconfig)) - { - const cpu_config *cpuconfig = (const cpu_config *)devconfig->inline_config; - - /* check the CPU for incompleteness */ - if (devconfig->get_config_fct(CPUINFO_FCT_RESET) == NULL || - devconfig->get_config_fct(CPUINFO_FCT_EXECUTE) == NULL) - { - mame_printf_error("%s: %s uses an incomplete CPU\n", driver->source_file, driver->name); - error = TRUE; - continue; - } - - /* check for CPU-specific validity check */ - cpu_validity_check = (cpu_validity_check_func) devconfig->get_config_fct(CPUINFO_FCT_VALIDITY_CHECK); - if (cpu_validity_check != NULL && (*cpu_validity_check)(driver, devconfig->static_config)) - error = TRUE; - - /* validate the interrupts */ - if (cpuconfig->vblank_interrupt != NULL) - { - if (video_screen_count(config) == 0) - { - mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt, but the driver is screenless !\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - else if (cpuconfig->vblank_interrupt_screen != NULL && cpuconfig->vblank_interrupts_per_frame != 0) - { - mame_printf_error("%s: %s cpu '%s' has a new VBLANK interrupt handler with >1 interrupts!\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - else if (cpuconfig->vblank_interrupt_screen != NULL && config->devicelist.find(cpuconfig->vblank_interrupt_screen) == NULL) - { - mame_printf_error("%s: %s cpu '%s' VBLANK interrupt with a non-existant screen tag (%s)!\n", driver->source_file, driver->name, devconfig->tag(), cpuconfig->vblank_interrupt_screen); - error = TRUE; - } - else if (cpuconfig->vblank_interrupt_screen == NULL && cpuconfig->vblank_interrupts_per_frame == 0) - { - mame_printf_error("%s: %s cpu '%s' has a VBLANK interrupt handler with 0 interrupts!\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - } - else if (cpuconfig->vblank_interrupts_per_frame != 0) - { - mame_printf_error("%s: %s cpu '%s' has no VBLANK interrupt handler but a non-0 interrupt count is given!\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - - if (cpuconfig->timed_interrupt != NULL && cpuconfig->timed_interrupt_period == 0) - { - mame_printf_error("%s: %s cpu '%s' has a timer interrupt handler with 0 period!\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - else if (cpuconfig->timed_interrupt == NULL && cpuconfig->timed_interrupt_period != 0) - { - mame_printf_error("%s: %s cpu '%s' has a no timer interrupt handler but has a non-0 period given!\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - } - - return error; -} - - /*------------------------------------------------- validate_display - validate display configurations -------------------------------------------------*/ -static int validate_display(int drivnum, const machine_config *config) +static bool validate_display(int drivnum, const machine_config *config) { const game_driver *driver = drivers[drivnum]; - const device_config *devconfig; - int palette_modes = FALSE; - int error = FALSE; - - /* loop over screens */ - for (devconfig = video_screen_first(config); devconfig != NULL; devconfig = video_screen_next(devconfig)) - { - const screen_config *scrconfig = (const screen_config *)devconfig->inline_config; - - /* sanity check dimensions */ - if ((scrconfig->width <= 0) || (scrconfig->height <= 0)) - { - mame_printf_error("%s: %s screen '%s' has invalid display dimensions\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - - /* sanity check display area */ - if (scrconfig->type != SCREEN_TYPE_VECTOR) - { - if ((scrconfig->visarea.max_x < scrconfig->visarea.min_x) || - (scrconfig->visarea.max_y < scrconfig->visarea.min_y) || - (scrconfig->visarea.max_x >= scrconfig->width) || - (scrconfig->visarea.max_y >= scrconfig->height)) - { - mame_printf_error("%s: %s screen '%s' has an invalid display area\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - - /* sanity check screen formats */ - if (scrconfig->format != BITMAP_FORMAT_INDEXED16 && - scrconfig->format != BITMAP_FORMAT_RGB15 && - scrconfig->format != BITMAP_FORMAT_RGB32) - { - mame_printf_error("%s: %s screen '%s' has unsupported format\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - if (scrconfig->format == BITMAP_FORMAT_INDEXED16) - palette_modes = TRUE; - } - - /* check for zero frame rate */ - if (scrconfig->refresh == 0) - { - mame_printf_error("%s: %s screen '%s' has a zero refresh rate\n", driver->source_file, driver->name, devconfig->tag()); - error = TRUE; - } - } + bool palette_modes = false; + bool error = false; + + for (const screen_device_config *scrconfig = screen_first(*config); scrconfig != NULL; scrconfig = screen_next(scrconfig)) + if (scrconfig->format() == BITMAP_FORMAT_INDEXED16) + palette_modes = true; /* check for empty palette */ if (palette_modes && config->total_colors == 0) { mame_printf_error("%s: %s has zero palette entries\n", driver->source_file, driver->name); - error = TRUE; + error = true; } return error; @@ -733,15 +617,15 @@ static int validate_display(int drivnum, const machine_config *config) configuration -------------------------------------------------*/ -static int validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo) +static bool validate_gfx(int drivnum, const machine_config *config, region_array *rgninfo) { const game_driver *driver = drivers[drivnum]; - int error = FALSE; + bool error = false; int gfxnum; /* bail if no gfx */ if (!config->gfxdecodeinfo) - return FALSE; + return false; /* iterate over graphics decoding entries */ for (gfxnum = 0; gfxnum < MAX_GFX_ELEMENTS && config->gfxdecodeinfo[gfxnum].gfxlayout != NULL; gfxnum++) @@ -769,7 +653,7 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array if (rgninfo->entries[rgnnum].tag == NULL) { mame_printf_error("%s: %s has gfx[%d] referencing non-existent region '%s'\n", driver->source_file, driver->name, gfxnum, region); - error = TRUE; + error = true; break; } @@ -800,7 +684,7 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array if ((start + len) / 8 > avail) { mame_printf_error("%s: %s has gfx[%d] extending past allocated memory of region '%s'\n", driver->source_file, driver->name, gfxnum, region); - error = TRUE; + error = true; } } break; @@ -813,13 +697,13 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array if (total != RGN_FRAC(1,1)) { mame_printf_error("%s: %s has gfx[%d] with unsupported layout total\n", driver->source_file, driver->name, gfxnum); - error = TRUE; + error = true; } if (xscale != 1 || yscale != 1) { mame_printf_error("%s: %s has gfx[%d] with unsupported xscale/yscale\n", driver->source_file, driver->name, gfxnum); - error = TRUE; + error = true; } } else @@ -827,13 +711,13 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array if (planes > MAX_GFX_PLANES) { mame_printf_error("%s: %s has gfx[%d] with invalid planes\n", driver->source_file, driver->name, gfxnum); - error = TRUE; + error = true; } if (xscale * width > MAX_ABS_GFX_SIZE || yscale * height > MAX_ABS_GFX_SIZE) { mame_printf_error("%s: %s has gfx[%d] with invalid xscale/yscale\n", driver->source_file, driver->name, gfxnum); - error = TRUE; + error = true; } } } @@ -848,14 +732,14 @@ static int validate_gfx(int drivnum, const machine_config *config, region_array strings -------------------------------------------------*/ -static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, int *error) +static int get_defstr_index(int_map &defstr_map, const char *name, const game_driver *driver, bool *error) { /* check for strings that should be DEF_STR */ int strindex = defstr_map.find(name); if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL) { mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name); - *error = TRUE; + *error = true; } return strindex; @@ -867,7 +751,7 @@ static int get_defstr_index(int_map &defstr_map, const char *name, const game_dr analog input field -------------------------------------------------*/ -static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, int *error) +static void validate_analog_input_field(const input_field_config *field, const game_driver *driver, bool *error) { INT32 analog_max = field->max; INT32 analog_min = field->min; @@ -883,7 +767,7 @@ static void validate_analog_input_field(const input_field_config *field, const g if (((field->mask >> shift) + 1) < field->max) { mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } } else @@ -892,7 +776,7 @@ static void validate_analog_input_field(const input_field_config *field, const g if (field->flags & ANALOG_FLAG_WRAPS) { mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } } @@ -900,14 +784,14 @@ static void validate_analog_input_field(const input_field_config *field, const g if (field->sensitivity == 0) { mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check that the default falls in the bitmask range */ if (field->defvalue & ~field->mask) { mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* tests for absolute devices */ @@ -927,7 +811,7 @@ static void validate_analog_input_field(const input_field_config *field, const g if (default_value < analog_min || default_value > analog_max) { mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check that the MINMAX falls in the bitmask range */ @@ -935,14 +819,14 @@ static void validate_analog_input_field(const input_field_config *field, const g if (field->min & ~field->mask || analog_max & ~field->mask) { mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* absolute analog ports do not use PORT_RESET */ if (field->flags & ANALOG_FLAG_RESET) { mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } } @@ -956,7 +840,7 @@ static void validate_analog_input_field(const input_field_config *field, const g if (field->min != 0 || field->max != field->mask) { mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* relative devices do not use a default value */ @@ -964,7 +848,7 @@ static void validate_analog_input_field(const input_field_config *field, const g if (field->defvalue != 0) { mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } } } @@ -976,7 +860,7 @@ static void validate_analog_input_field(const input_field_config *field, const g setting -------------------------------------------------*/ -static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, int *error) +static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int_map &defstr_map, bool *error) { const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds); const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); @@ -997,21 +881,21 @@ static void validate_dip_settings(const input_field_config *field, const game_dr if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value) { mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check for bad demo sounds options */ if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) { mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); - *error = TRUE; + *error = true; } /* check for bad flip screen options */ if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) { mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); - *error = TRUE; + *error = true; } /* if we have a neighbor, compare ourselves to him */ @@ -1023,21 +907,21 @@ static void validate_dip_settings(const input_field_config *field, const game_dr if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off) { mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check for inverted yes/no dispswitch order */ else if (strindex == INPUT_STRING_Yes && next_strindex == INPUT_STRING_No) { mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check for inverted upright/cocktail dispswitch order */ else if (strindex == INPUT_STRING_Cocktail && next_strindex == INPUT_STRING_Upright) { mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name); - *error = TRUE; + *error = true; } /* check for proper coin ordering */ @@ -1045,7 +929,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0) { mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, setting->name, setting->next->name); - coin_error = *error = TRUE; + coin_error = *error = true; } } } @@ -1067,7 +951,7 @@ static void validate_dip_settings(const input_field_config *field, const game_dr validate_inputs - validate input configuration -------------------------------------------------*/ -static int validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist) +static bool validate_inputs(int drivnum, const machine_config *config, int_map &defstr_map, ioport_list &portlist) { const input_port_config *scanport; const input_port_config *port; @@ -1075,7 +959,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d const game_driver *driver = drivers[drivnum]; int empty_string_found = FALSE; char errorbuf[1024]; - int error = FALSE; + bool error = false; /* skip if no ports */ if (driver->ipt == NULL) @@ -1086,21 +970,21 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (errorbuf[0] != 0) { mame_printf_error("%s: %s has input port errors:\n%s\n", driver->source_file, driver->name, errorbuf); - error = TRUE; + error = true; } /* check for duplicate tags */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) if (port->tag != NULL) - for (scanport = port->next; scanport != NULL; scanport = scanport->next) + for (scanport = port->next(); scanport != NULL; scanport = scanport->next()) if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0) { mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver->source_file, driver->name, port->tag); - error = TRUE; + error = true; } /* iterate over the results */ - for (port = portlist.first(); port != NULL; port = port->next) + for (port = portlist.first(); port != NULL; port = port->next()) for (field = port->fieldlist; field != NULL; field = field->next) { const input_setting_config *setting; @@ -1117,7 +1001,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (field->name == NULL) { mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); - error = TRUE; + error = true; } /* verify the settings list */ @@ -1128,7 +1012,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (field->type == IPT_INVALID) { mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name); - error = TRUE; + error = true; } /* verify names */ @@ -1138,21 +1022,21 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (field->name[0] == 0 && !empty_string_found) { mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); - empty_string_found = error = TRUE; + empty_string_found = error = true; } /* check for trailing spaces */ if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ') { mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name); - error = TRUE; + error = true; } /* check for invalid UTF-8 */ if (!utf8_is_valid_string(field->name)) { mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name); - error = TRUE; + error = true; } /* look up the string and print an error if default strings are not used */ @@ -1163,7 +1047,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (field->condition.tag != NULL) { /* find a matching port */ - for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next) + for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0) break; @@ -1171,7 +1055,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (scanport == NULL) { mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, field->condition.tag); - error = TRUE; + error = true; } } @@ -1180,7 +1064,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (setting->condition.tag != NULL) { /* find a matching port */ - for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next) + for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next()) if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0) break; @@ -1188,7 +1072,7 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d if (scanport == NULL) { mame_printf_error("%s: %s has a condition referencing non-existent input port tag '%s'\n", driver->source_file, driver->name, setting->condition.tag); - error = TRUE; + error = true; } } } @@ -1200,237 +1084,34 @@ static int validate_inputs(int drivnum, const machine_config *config, int_map &d } -/*------------------------------------------------- - validate_sound - validate sound and - speaker configuration --------------------------------------------------*/ - -static int validate_sound(int drivnum, const machine_config *config) -{ - const device_config *curspeak, *checkspeak, *cursound, *checksound; - const game_driver *driver = drivers[drivnum]; - int error = FALSE; - - /* make sure the speaker layout makes sense */ - for (curspeak = speaker_output_first(config); curspeak != NULL; curspeak = speaker_output_next(curspeak)) - { - /* check for duplicate tags */ - for (checkspeak = speaker_output_first(config); checkspeak != NULL; checkspeak = speaker_output_next(checkspeak)) - if (checkspeak != curspeak && strcmp(checkspeak->tag(), curspeak->tag()) == 0) - { - mame_printf_error("%s: %s has multiple speakers tagged as '%s'\n", driver->source_file, driver->name, checkspeak->tag()); - error = TRUE; - } - - /* make sure there are no sound chips with the same tag */ - for (checksound = sound_first(config); checksound != NULL; checksound = sound_next(checksound)) - if (strcmp(curspeak->tag(), checksound->tag()) == 0) - { - mame_printf_error("%s: %s has both a speaker and a sound chip tagged as '%s'\n", driver->source_file, driver->name, curspeak->tag()); - error = TRUE; - } - } - - /* make sure the sounds are wired to the speakers correctly */ - for (cursound = sound_first(config); cursound != NULL; cursound = sound_next(cursound)) - { - const sound_config *curconfig = (const sound_config *)cursound->inline_config; - const sound_route *route; - - /* loop over all the routes */ - for (route = curconfig->routelist; route != NULL; route = route->next) - { - /* find a speaker with the requested tag */ - for (checkspeak = speaker_output_first(config); checkspeak != NULL; checkspeak = speaker_output_next(checkspeak)) - if (strcmp(route->target, checkspeak->tag()) == 0) - break; - - /* if we didn't find one, look for another sound chip with the tag */ - if (checkspeak == NULL) - { - for (checksound = sound_first(config); checksound != NULL; checksound = sound_next(checksound)) - if (checksound != cursound && strcmp(route->target, checksound->tag()) == 0) - break; - - /* if we didn't find one, it's an error */ - if (checksound == NULL) - { - mame_printf_error("%s: %s attempting to route sound to non-existant speaker '%s'\n", driver->source_file, driver->name, route->target); - error = TRUE; - } - } - } - } - - return error; -} - - /*------------------------------------------------- validate_devices - run per-device validity checks -------------------------------------------------*/ -static int validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo) +static bool validate_devices(int drivnum, const machine_config *config, const ioport_list &portlist, region_array *rgninfo) { - int error = FALSE; + bool error = false; const game_driver *driver = drivers[drivnum]; - for (const device_config *devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next) + for (const device_config *devconfig = config->devicelist.first(); devconfig != NULL; devconfig = devconfig->next()) { - device_validity_check_func validity_check = (device_validity_check_func) devconfig->get_config_fct(DEVINFO_FCT_VALIDITY_CHECK); - int detected_overlap = DETECT_OVERLAPPING_MEMORY ? FALSE : TRUE; - const device_config *scanconfig; - int spacenum; - /* validate the device tag */ - error |= validate_tag(driver, devconfig->get_config_string(DEVINFO_STR_NAME), devconfig->tag()); + if (!validate_tag(driver, devconfig->name(), devconfig->tag())) + error = true; /* look for duplicates */ - for (scanconfig = config->devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next) + for (const device_config *scanconfig = config->devicelist.first(); scanconfig != devconfig; scanconfig = scanconfig->next()) if (strcmp(scanconfig->tag(), devconfig->tag()) == 0) { mame_printf_warning("%s: %s has multiple devices with the tag '%s'\n", driver->source_file, driver->name, devconfig->tag()); break; } - /* call the device-specific validity check */ - if (validity_check != NULL && (*validity_check)(driver, devconfig)) - error = TRUE; - - /* loop over all address spaces */ - for (spacenum = 0; spacenum < ADDRESS_SPACES; spacenum++) - { -#define SPACE_SHIFT(a) ((addr_shift < 0) ? ((a) << -addr_shift) : ((a) >> addr_shift)) -#define SPACE_SHIFT_END(a) ((addr_shift < 0) ? (((a) << -addr_shift) | ((1 << -addr_shift) - 1)) : ((a) >> addr_shift)) - int databus_width = devconfig->databus_width(spacenum); - int addr_shift = devconfig->addrbus_shift(spacenum); - int alignunit = databus_width/8; - address_map_entry *entry; - address_map *map; - - /* construct the maps */ - map = address_map_alloc(devconfig, driver, spacenum, NULL); - - /* if this is an empty map, just skip it */ - if (map->entrylist == NULL) - { - address_map_free(map); - continue; - } - - /* validate the global map parameters */ - if (map->spacenum != spacenum) - { - mame_printf_error("%s: %s device '%s' space %d has address space %d handlers!\n", driver->source_file, driver->name, devconfig->tag(), spacenum, map->spacenum); - error = TRUE; - } - if (map->databits != databus_width) - { - mame_printf_error("%s: %s device '%s' uses wrong memory handlers for %s space! (width = %d, memory = %08x)\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], databus_width, map->databits); - error = TRUE; - } - - /* loop over entries and look for errors */ - for (entry = map->entrylist; entry != NULL; entry = entry->next) - { - UINT32 bytestart = SPACE_SHIFT(entry->addrstart); - UINT32 byteend = SPACE_SHIFT_END(entry->addrend); - - /* look for overlapping entries */ - if (!detected_overlap) - { - address_map_entry *scan; - for (scan = map->entrylist; scan != entry; scan = scan->next) - if (entry->addrstart <= scan->addrend && entry->addrend >= scan->addrstart && - ((entry->read.type != AMH_NONE && scan->read.type != AMH_NONE) || - (entry->write.type != AMH_NONE && scan->write.type != AMH_NONE))) - { - mame_printf_warning("%s: %s '%s' %s space has overlapping memory (%X-%X,%d,%d) vs (%X-%X,%d,%d)\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->read.type, entry->write.type, scan->addrstart, scan->addrend, scan->read.type, scan->write.type); - detected_overlap = TRUE; - break; - } - } - - /* look for inverted start/end pairs */ - if (byteend < bytestart) - { - mame_printf_error("%s: %s wrong %s memory read handler start = %08x > end = %08x\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend); - error = TRUE; - } - - /* look for misaligned entries */ - if ((bytestart & (alignunit - 1)) != 0 || (byteend & (alignunit - 1)) != (alignunit - 1)) - { - mame_printf_error("%s: %s wrong %s memory read handler start = %08x, end = %08x ALIGN = %d\n", driver->source_file, driver->name, address_space_names[spacenum], entry->addrstart, entry->addrend, alignunit); - error = TRUE; - } - - /* if this is a program space, auto-assign implicit ROM entries */ - if (entry->read.type == AMH_ROM && entry->region == NULL) - { - entry->region = devconfig->tag(); - entry->rgnoffs = entry->addrstart; - } - - /* if this entry references a memory region, validate it */ - if (entry->region != NULL && entry->share == 0) - { - int rgnnum; - - /* loop over entries in the class */ - for (rgnnum = 0; rgnnum < ARRAY_LENGTH(rgninfo->entries); rgnnum++) - { - /* stop if we hit an empty */ - if (rgninfo->entries[rgnnum].tag == NULL) - { - mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X references non-existant region '%s'\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region); - error = TRUE; - break; - } + /* check for device-specific validity check */ + if (devconfig->validity_check(*driver)) + error = true; - /* if we hit a match, check against the length */ - if (rgninfo->entries[rgnnum].tag.cmp(entry->region) == 0) - { - offs_t length = rgninfo->entries[rgnnum].length; - if (entry->rgnoffs + (byteend - bytestart + 1) > length) - { - mame_printf_error("%s: %s device '%s' %s space memory map entry %X-%X extends beyond region '%s' size (%X)\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->addrstart, entry->addrend, entry->region, length); - error = TRUE; - } - break; - } - } - } - - /* make sure all devices exist */ - if ((entry->read.type == AMH_DEVICE_HANDLER && entry->read.tag != NULL && config->devicelist.find(entry->read.tag) == NULL) || - (entry->write.type == AMH_DEVICE_HANDLER && entry->write.tag != NULL && config->devicelist.find(entry->write.tag) == NULL)) - { - mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant device '%s'\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->write.tag); - error = TRUE; - } - - /* make sure ports exist */ - if ((entry->read.type == AMH_PORT && entry->read.tag != NULL && portlist.find(entry->read.tag) == NULL) || - (entry->write.type == AMH_PORT && entry->write.tag != NULL && portlist.find(entry->write.tag) == NULL)) - { - mame_printf_error("%s: %s device '%s' %s space memory map entry references nonexistant port tag '%s'\n", driver->source_file, driver->name, devconfig->tag(), address_space_names[spacenum], entry->read.tag); - error = TRUE; - } - - /* validate bank and share tags */ - if (entry->read.type == AMH_BANK) - error |= validate_tag(driver, "bank", entry->read.tag); - if (entry->write.type == AMH_BANK) - error |= validate_tag(driver, "bank", entry->write.tag); - if (entry->share != NULL) - error |= validate_tag(driver, "share", entry->share); - } - - /* release the address map */ - address_map_free(map); - } } return error; } @@ -1440,21 +1121,19 @@ static int validate_devices(int drivnum, const machine_config *config, const iop mame_validitychecks - master validity checker -------------------------------------------------*/ -int mame_validitychecks(const game_driver *curdriver) +bool mame_validitychecks(const game_driver *curdriver) { osd_ticks_t prep = 0; osd_ticks_t expansion = 0; osd_ticks_t driver_checks = 0; osd_ticks_t rom_checks = 0; - osd_ticks_t cpu_checks = 0; osd_ticks_t gfx_checks = 0; osd_ticks_t display_checks = 0; osd_ticks_t input_checks = 0; - osd_ticks_t sound_checks = 0; osd_ticks_t device_checks = 0; int drivnum, strnum; - int error = FALSE; + bool error = false; UINT16 lsbtest; UINT8 a, b; @@ -1466,27 +1145,27 @@ int mame_validitychecks(const game_driver *curdriver) /* basic system checks */ a = 0xff; b = a + 1; - if (b > a) { mame_printf_error("UINT8 must be 8 bits\n"); error = TRUE; } - - if (sizeof(INT8) != 1) { mame_printf_error("INT8 must be 8 bits\n"); error = TRUE; } - if (sizeof(UINT8) != 1) { mame_printf_error("UINT8 must be 8 bits\n"); error = TRUE; } - if (sizeof(INT16) != 2) { mame_printf_error("INT16 must be 16 bits\n"); error = TRUE; } - if (sizeof(UINT16) != 2) { mame_printf_error("UINT16 must be 16 bits\n"); error = TRUE; } - if (sizeof(INT32) != 4) { mame_printf_error("INT32 must be 32 bits\n"); error = TRUE; } - if (sizeof(UINT32) != 4) { mame_printf_error("UINT32 must be 32 bits\n"); error = TRUE; } - if (sizeof(INT64) != 8) { mame_printf_error("INT64 must be 64 bits\n"); error = TRUE; } - if (sizeof(UINT64) != 8) { mame_printf_error("UINT64 must be 64 bits\n"); error = TRUE; } + if (b > a) { mame_printf_error("UINT8 must be 8 bits\n"); error = true; } + + if (sizeof(INT8) != 1) { mame_printf_error("INT8 must be 8 bits\n"); error = true; } + if (sizeof(UINT8) != 1) { mame_printf_error("UINT8 must be 8 bits\n"); error = true; } + if (sizeof(INT16) != 2) { mame_printf_error("INT16 must be 16 bits\n"); error = true; } + if (sizeof(UINT16) != 2) { mame_printf_error("UINT16 must be 16 bits\n"); error = true; } + if (sizeof(INT32) != 4) { mame_printf_error("INT32 must be 32 bits\n"); error = true; } + if (sizeof(UINT32) != 4) { mame_printf_error("UINT32 must be 32 bits\n"); error = true; } + if (sizeof(INT64) != 8) { mame_printf_error("INT64 must be 64 bits\n"); error = true; } + if (sizeof(UINT64) != 8) { mame_printf_error("UINT64 must be 64 bits\n"); error = true; } #ifdef PTR64 - if (sizeof(void *) != 8) { mame_printf_error("PTR64 flag enabled, but was compiled for 32-bit target\n"); error = TRUE; } + if (sizeof(void *) != 8) { mame_printf_error("PTR64 flag enabled, but was compiled for 32-bit target\n"); error = true; } #else - if (sizeof(void *) != 4) { mame_printf_error("PTR64 flag not enabled, but was compiled for 64-bit target\n"); error = TRUE; } + if (sizeof(void *) != 4) { mame_printf_error("PTR64 flag not enabled, but was compiled for 64-bit target\n"); error = true; } #endif lsbtest = 0; *(UINT8 *)&lsbtest = 0xff; #ifdef LSB_FIRST - if (lsbtest == 0xff00) { mame_printf_error("LSB_FIRST specified, but running on a big-endian machine\n"); error = TRUE; } + if (lsbtest == 0xff00) { mame_printf_error("LSB_FIRST specified, but running on a big-endian machine\n"); error = true; } #else - if (lsbtest == 0x00ff) { mame_printf_error("LSB_FIRST not specified, but running on a little-endian machine\n"); error = TRUE; } + if (lsbtest == 0x00ff) { mame_printf_error("LSB_FIRST not specified, but running on a little-endian machine\n"); error = true; } #endif /* validate inline function behavior */ @@ -1536,11 +1215,6 @@ int mame_validitychecks(const game_driver *curdriver) error = validate_inputs(drivnum, config, defstr, portlist) || error; input_checks += get_profile_ticks(); - /* validate the CPU information */ - cpu_checks -= get_profile_ticks(); - error = validate_cpu(drivnum, config) || error; - cpu_checks += get_profile_ticks(); - /* validate the display */ display_checks -= get_profile_ticks(); error = validate_display(drivnum, config) || error; @@ -1551,11 +1225,6 @@ int mame_validitychecks(const game_driver *curdriver) error = validate_gfx(drivnum, config, &rgninfo) || error; gfx_checks += get_profile_ticks(); - /* validate sounds and speakers */ - sound_checks -= get_profile_ticks(); - error = validate_sound(drivnum, config) || error; - sound_checks += get_profile_ticks(); - /* validate devices */ device_checks -= get_profile_ticks(); error = validate_devices(drivnum, config, portlist, &rgninfo) || error; @@ -1573,7 +1242,6 @@ int mame_validitychecks(const game_driver *curdriver) mame_printf_info("Display: %8dm\n", (int)(display_checks / 1000000)); mame_printf_info("Graphics: %8dm\n", (int)(gfx_checks / 1000000)); mame_printf_info("Input: %8dm\n", (int)(input_checks / 1000000)); - mame_printf_info("Sound: %8dm\n", (int)(sound_checks / 1000000)); #endif return error; diff --git a/src/emu/validity.h b/src/emu/validity.h index 0fe324c9425..b70739658a8 100644 --- a/src/emu/validity.h +++ b/src/emu/validity.h @@ -14,7 +14,7 @@ #ifndef __VALIDITY_H__ #define __VALIDITY_H__ -extern int mame_validitychecks(const game_driver *driver); +bool mame_validitychecks(const game_driver *driver); +bool validate_tag(const game_driver *driver, const char *object, const char *tag); #endif - diff --git a/src/emu/video.c b/src/emu/video.c index 8033f4c9115..dae15fcf13c 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -4,8 +4,36 @@ Core MAME video routines. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ @@ -40,9 +68,6 @@ #define SUBSECONDS_PER_SPEED_UPDATE (ATTOSECONDS_PER_SECOND / 4) #define PAUSED_REFRESH_RATE (30) -#define MAX_VBLANK_CALLBACKS (10) -#define DEFAULT_FRAME_RATE 60 -#define DEFAULT_FRAME_PERIOD ATTOTIME_IN_HZ(DEFAULT_FRAME_RATE) @@ -50,43 +75,6 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef struct _screen_state screen_state; -struct _screen_state -{ - /* dimensions */ - int width; /* current width (HTOTAL) */ - int height; /* current height (VTOTAL) */ - rectangle visarea; /* current visible area (HBLANK end/start, VBLANK end/start) */ - - /* textures and bitmaps */ - render_texture * texture[2]; /* 2x textures for the screen bitmap */ - bitmap_t * bitmap[2]; /* 2x bitmaps for rendering */ - bitmap_t * burnin; /* burn-in bitmap */ - UINT8 curbitmap; /* current bitmap index */ - UINT8 curtexture; /* current texture index */ - INT32 texture_format; /* texture format of bitmap for this screen */ - UINT8 changed; /* has this bitmap changed? */ - INT32 last_partial_scan; /* scanline of last partial update */ - - /* screen timing */ - attoseconds_t frame_period; /* attoseconds per frame */ - attoseconds_t scantime; /* attoseconds per scanline */ - attoseconds_t pixeltime; /* attoseconds per pixel */ - attoseconds_t vblank_period; /* attoseconds per VBLANK period */ - attotime vblank_start_time; /* time of last VBLANK start */ - attotime vblank_end_time; /* time of last VBLANK end */ - emu_timer * vblank_begin_timer; /* timer to signal VBLANK start */ - emu_timer * vblank_end_timer; /* timer to signal VBLANK end */ - emu_timer * scanline0_timer; /* scanline 0 timer */ - emu_timer * scanline_timer; /* scanline timer */ - UINT64 frame_number; /* the current frame number */ - - /* screen specific VBLANK callbacks */ - vblank_state_changed_func vblank_callback[MAX_VBLANK_CALLBACKS]; /* the array of callbacks */ - void * vblank_callback_param[MAX_VBLANK_CALLBACKS]; /* array of parameters */ -}; - - typedef struct _video_global video_global; struct _video_global { @@ -177,16 +165,9 @@ static const UINT8 skiptable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] = static void video_exit(running_machine *machine); static void init_buffered_spriteram(running_machine *machine); -static void realloc_screen_bitmaps(running_device *screen); -static STATE_POSTLOAD( video_screen_postload ); - /* global rendering */ -static TIMER_CALLBACK( vblank_begin_callback ); -static TIMER_CALLBACK( vblank_end_callback ); -static TIMER_CALLBACK( screenless_update_callback ); -static TIMER_CALLBACK( scanline0_callback ); -static TIMER_CALLBACK( scanline_update_callback ); static int finish_screen_updates(running_machine *machine); +static TIMER_CALLBACK( screenless_update_callback ); /* throttling/frameskipping/performance */ static void update_throttle(running_machine *machine, attotime emutime); @@ -196,17 +177,13 @@ static void recompute_speed(running_machine *machine, attotime emutime); static void update_refresh_speed(running_machine *machine); /* screen snapshots */ -static void create_snapshot_bitmap(running_device *screen); +static void create_snapshot_bitmap(device_t *screen); static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file); /* movie recording */ static void video_mng_record_frame(running_machine *machine); static void video_avi_record_frame(running_machine *machine); -/* burn-in generation */ -static void video_update_burnin(running_machine *machine); -static void video_finalize_burnin(running_device *screen); - /* software rendering */ static void rgb888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch); @@ -216,21 +193,6 @@ static void rgb888_draw_primitives(const render_primitive *primlist, void *dstda INLINE FUNCTIONS ***************************************************************************/ -/*------------------------------------------------- - get_safe_token - makes sure that the passed - in device is, in fact, a screen --------------------------------------------------*/ - -INLINE screen_state *get_safe_token(running_device *device) -{ - assert(device != NULL); - assert(device->token != NULL); - assert(device->type == VIDEO_SCREEN); - - return (screen_state *)device->token; -} - - /*------------------------------------------------- effective_autoframeskip - return the effective autoframeskip value, accounting for fast @@ -376,7 +338,7 @@ void video_init(running_machine *machine) if (machine->primary_screen == NULL) { global.screenless_frame_timer = timer_alloc(machine, screenless_update_callback, NULL); - timer_adjust_periodic(global.screenless_frame_timer, DEFAULT_FRAME_PERIOD, 0, DEFAULT_FRAME_PERIOD); + timer_adjust_periodic(global.screenless_frame_timer, screen_device::k_default_frame_period, 0, screen_device::k_default_frame_period); } } @@ -405,7 +367,7 @@ static void video_exit(running_machine *machine) if (global.snap_target != NULL) render_target_free(global.snap_target); if (global.snap_bitmap != NULL) - bitmap_free(global.snap_bitmap); + global_free(global.snap_bitmap); /* print a final result if we have at least 5 seconds' worth of data */ if (global.overall_emutime.seconds >= 5) @@ -451,2281 +413,2145 @@ static void init_buffered_spriteram(running_machine *machine) ***************************************************************************/ /*------------------------------------------------- - video_screen_configure - configure the parameters - of a screen + screenless_update_callback - update generator + when there are no screens to drive it -------------------------------------------------*/ -void video_screen_configure(running_device *screen, int width, int height, const rectangle *visarea, attoseconds_t frame_period) +static TIMER_CALLBACK( screenless_update_callback ) { - screen_state *state = get_safe_token(screen); - screen_config *config = (screen_config *)screen->baseconfig().inline_config; - - /* validate arguments */ - assert(width > 0); - assert(height > 0); - assert(visarea != NULL); - assert(visarea->min_x >= 0); - assert(visarea->min_y >= 0); - assert(config->type == SCREEN_TYPE_VECTOR || visarea->min_x < width); - assert(config->type == SCREEN_TYPE_VECTOR || visarea->min_y < height); - assert(frame_period > 0); - - /* fill in the new parameters */ - state->width = width; - state->height = height; - state->visarea = *visarea; - - /* reallocate bitmap if necessary */ - realloc_screen_bitmaps(screen); - - /* compute timing parameters */ - state->frame_period = frame_period; - state->scantime = frame_period / height; - state->pixeltime = frame_period / (height * width); - - /* if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now - from the visible area, otherwise just used the supplied value */ - if (config->vblank == 0 && !config->oldstyle_vblank_supplied) - state->vblank_period = state->scantime * (height - (visarea->max_y + 1 - visarea->min_y)); - else - state->vblank_period = config->vblank; - - /* if we are on scanline 0 already, reset the update timer immediately */ - /* otherwise, defer until the next scanline 0 */ - if (video_screen_get_vpos(screen) == 0) - timer_adjust_oneshot(state->scanline0_timer, attotime_zero, 0); - else - timer_adjust_oneshot(state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); - - /* start the VBLANK timer */ - timer_adjust_oneshot(state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); - - /* adjust speed if necessary */ - update_refresh_speed(screen->machine); + /* force an update */ + video_frame_update(machine, false); } /*------------------------------------------------- - realloc_screen_bitmaps - reallocate screen - bitmaps as necessary + video_frame_update - handle frameskipping and + UI, plus updating the screen during normal + operations -------------------------------------------------*/ -static void realloc_screen_bitmaps(running_device *screen) +void video_frame_update(running_machine *machine, int debug) { - screen_state *state = get_safe_token(screen); - screen_config *config = (screen_config *)screen->baseconfig().inline_config; - if (config->type != SCREEN_TYPE_VECTOR) - { - int curwidth = 0, curheight = 0; + attotime current_time = timer_get_time(machine); + int skipped_it = global.skipping_this_frame; + int phase = mame_get_phase(machine); - /* extract the current width/height from the bitmap */ - if (state->bitmap[0] != NULL) - { - curwidth = state->bitmap[0]->width; - curheight = state->bitmap[0]->height; - } + /* validate */ + assert(machine != NULL); + assert(machine->config != NULL); - /* if we're too small to contain this width/height, reallocate our bitmaps and textures */ - if (state->width > curwidth || state->height > curheight) - { - bitmap_format screen_format = config->format; - palette_t *palette; - - /* free what we have currently */ - if (state->texture[0] != NULL) - render_texture_free(state->texture[0]); - if (state->texture[1] != NULL) - render_texture_free(state->texture[1]); - if (state->bitmap[0] != NULL) - bitmap_free(state->bitmap[0]); - if (state->bitmap[1] != NULL) - bitmap_free(state->bitmap[1]); - - /* compute new width/height */ - curwidth = MAX(state->width, curwidth); - curheight = MAX(state->height, curheight); - - /* choose the texture format - convert the screen format to a texture format */ - switch (screen_format) - { - case BITMAP_FORMAT_INDEXED16: state->texture_format = TEXFORMAT_PALETTE16; palette = screen->machine->palette; break; - case BITMAP_FORMAT_RGB15: state->texture_format = TEXFORMAT_RGB15; palette = NULL; break; - case BITMAP_FORMAT_RGB32: state->texture_format = TEXFORMAT_RGB32; palette = NULL; break; - default: fatalerror("Invalid bitmap format!"); break; - } + /* only render sound and video if we're in the running phase */ + if (phase == MAME_PHASE_RUNNING && (!mame_is_paused(machine) || options_get_bool(mame_options(), OPTION_UPDATEINPAUSE))) + { + int anything_changed = finish_screen_updates(machine); - /* allocate bitmaps */ - state->bitmap[0] = bitmap_alloc(curwidth, curheight, screen_format); - bitmap_set_palette(state->bitmap[0], screen->machine->palette); - state->bitmap[1] = bitmap_alloc(curwidth, curheight, screen_format); - bitmap_set_palette(state->bitmap[1], screen->machine->palette); - - /* allocate textures */ - state->texture[0] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture[0], state->bitmap[0], &state->visarea, state->texture_format, palette); - state->texture[1] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture[1], state->bitmap[1], &state->visarea, state->texture_format, palette); - } + /* if none of the screens changed and we haven't skipped too many frames in a row, + mark this frame as skipped to prevent throttling; this helps for games that + don't update their screen at the monitor refresh rate */ + if (!anything_changed && !global.auto_frameskip && global.frameskip_level == 0 && global.empty_skip_count++ < 3) + skipped_it = TRUE; + else + global.empty_skip_count = 0; } -} + /* draw the user interface */ + ui_update_and_render(machine, render_container_get_ui()); -/*------------------------------------------------- - video_screen_set_visarea - just set the visible area - of a screen --------------------------------------------------*/ + /* update the internal render debugger */ + debugint_update_during_game(machine); -void video_screen_set_visarea(running_device *screen, int min_x, int max_x, int min_y, int max_y) -{ - screen_state *state = get_safe_token(screen); - rectangle visarea; + /* if we're throttling, synchronize before rendering */ + if (!debug && !skipped_it && effective_throttle(machine)) + update_throttle(machine, current_time); - /* validate arguments */ - assert(min_x >= 0); - assert(min_y >= 0); - assert(min_x < max_x); - assert(min_y < max_y); + /* ask the OSD to update */ + profiler_mark_start(PROFILER_BLIT); + osd_update(machine, !debug && skipped_it); + profiler_mark_end(); - visarea.min_x = min_x; - visarea.max_x = max_x; - visarea.min_y = min_y; - visarea.max_y = max_y; + /* perform tasks for this frame */ + if (!debug) + mame_frame_update(machine); + + /* update frameskipping */ + if (!debug) + update_frameskip(machine); + + /* update speed computations */ + if (!debug && !skipped_it) + recompute_speed(machine, current_time); + + /* call the end-of-frame callback */ + if (phase == MAME_PHASE_RUNNING) + { + /* reset partial updates if we're paused or if the debugger is active */ + if (machine->primary_screen != NULL && (mame_is_paused(machine) || debug || debugger_within_instruction_hook(machine))) + machine->primary_screen->scanline0_callback(); - video_screen_configure(screen, state->width, state->height, &visarea, state->frame_period); + /* otherwise, call the video EOF callback */ + else if (machine->config->video_eof != NULL) + { + profiler_mark_start(PROFILER_VIDEO); + (*machine->config->video_eof)(machine); + profiler_mark_end(); + } + } } /*------------------------------------------------- - video_screen_update_partial - perform a partial - update from the last scanline up to and - including the specified scanline + finish_screen_updates - finish updating all + the screens -------------------------------------------------*/ -int video_screen_update_partial(running_device *screen, int scanline) +static int finish_screen_updates(running_machine *machine) { - screen_state *state = get_safe_token(screen); - rectangle clip = state->visarea; - int result = FALSE; + bool anything_changed = false; - /* validate arguments */ - assert(scanline >= 0); + /* finish updating the screens */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + screen->update_partial(screen->visible_area().max_y); - LOG_PARTIAL_UPDATES(("Partial: video_screen_update_partial(%s, %d): ", screen->tag(), scanline)); + /* now add the quads for all the screens */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + if (screen->update_quads()) + anything_changed = true; - /* these two checks only apply if we're allowed to skip frames */ - if (!(screen->machine->config->video_attributes & VIDEO_ALWAYS_UPDATE)) + /* update our movie recording and burn-in state */ + if (!mame_is_paused(machine)) { - /* if skipping this frame, bail */ - if (global.skipping_this_frame) - { - LOG_PARTIAL_UPDATES(("skipped due to frameskipping\n")); - return FALSE; - } + video_mng_record_frame(machine); + video_avi_record_frame(machine); - /* skip if this screen is not visible anywhere */ - if (!render_is_live_screen(screen)) - { - LOG_PARTIAL_UPDATES(("skipped because screen not live\n")); - return FALSE; - } + /* iterate over screens and update the burnin for the ones that care */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + screen->update_burnin(); } - /* skip if less than the lowest so far */ - if (scanline < state->last_partial_scan) - { - LOG_PARTIAL_UPDATES(("skipped because less than previous\n")); - return FALSE; - } + /* draw any crosshairs */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + crosshair_render(*screen); - /* set the start/end scanlines */ - if (state->last_partial_scan > clip.min_y) - clip.min_y = state->last_partial_scan; - if (scanline < clip.max_y) - clip.max_y = scanline; + return anything_changed; +} - /* render if necessary */ - if (clip.min_y <= clip.max_y) - { - UINT32 flags = UPDATE_HAS_NOT_CHANGED; - profiler_mark_start(PROFILER_VIDEO); - LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y)); - if (screen->machine->config->video_update != NULL) - flags = (*screen->machine->config->video_update)(screen, state->bitmap[state->curbitmap], &clip); - global.partial_updates_this_frame++; - profiler_mark_end(); +/*************************************************************************** + THROTTLING/FRAMESKIPPING/PERFORMANCE +***************************************************************************/ - /* if we modified the bitmap, we have to commit */ - state->changed |= ~flags & UPDATE_HAS_NOT_CHANGED; - result = TRUE; - } +/*------------------------------------------------- + video_skip_this_frame - accessor to determine + if this frame is being skipped +-------------------------------------------------*/ - /* remember where we left off */ - state->last_partial_scan = scanline + 1; - return result; +int video_skip_this_frame(void) +{ + return global.skipping_this_frame; } /*------------------------------------------------- - video_screen_update_now - perform an update - from the last beam position up to the current - beam position + video_get_speed_factor - return the speed + factor as an integer * 100 -------------------------------------------------*/ -void video_screen_update_now(running_device *screen) -{ - screen_state *state = get_safe_token(screen); - int current_vpos = video_screen_get_vpos(screen); - int current_hpos = video_screen_get_hpos(screen); - - /* since we can currently update only at the scanline - level, we are trying to do the right thing by - updating including the current scanline, only if the - beam is past the halfway point horizontally. - If the beam is in the first half of the scanline, - we only update up to the previous scanline. - This minimizes the number of pixels that might be drawn - incorrectly until we support a pixel level granularity */ - if (current_hpos < (state->width / 2) && current_vpos > 0) - current_vpos = current_vpos - 1; - - video_screen_update_partial(screen, current_vpos); +int video_get_speed_factor(void) +{ + return global.speed; } /*------------------------------------------------- - video_screen_get_vpos - returns the current - vertical position of the beam for a given - screen + video_set_speed_factor - sets the speed + factor as an integer * 100 -------------------------------------------------*/ -int video_screen_get_vpos(running_device *screen) +void video_set_speed_factor(int speed) { - screen_state *state = get_safe_token(screen); - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(screen->machine), state->vblank_start_time)); - int vpos; - - /* round to the nearest pixel */ - delta += state->pixeltime / 2; - - /* compute the v position relative to the start of VBLANK */ - vpos = delta / state->scantime; - - /* adjust for the fact that VBLANK starts at the bottom of the visible area */ - return (state->visarea.max_y + 1 + vpos) % state->height; + global.speed = speed; } /*------------------------------------------------- - video_screen_get_hpos - returns the current - horizontal position of the beam for a given - screen + video_get_speed_text - print the text to + be displayed in the upper-right corner -------------------------------------------------*/ -int video_screen_get_hpos(running_device *screen) +const char *video_get_speed_text(running_machine *machine) { - screen_state *state = get_safe_token(screen); - attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(screen->machine), state->vblank_start_time)); - int vpos; + int paused = mame_is_paused(machine); + static char buffer[1024]; + char *dest = buffer; + + /* validate */ + assert(machine != NULL); - /* round to the nearest pixel */ - delta += state->pixeltime / 2; + /* if we're paused, just display Paused */ + if (paused) + dest += sprintf(dest, "paused"); - /* compute the v position relative to the start of VBLANK */ - vpos = delta / state->scantime; + /* if we're fast forwarding, just display Fast-forward */ + else if (global.fastforward) + dest += sprintf(dest, "fast "); - /* subtract that from the total time */ - delta -= vpos * state->scantime; + /* if we're auto frameskipping, display that plus the level */ + else if (effective_autoframeskip(machine)) + dest += sprintf(dest, "auto%2d/%d", effective_frameskip(), MAX_FRAMESKIP); - /* return the pixel offset from the start of this scanline */ - return delta / state->pixeltime; -} + /* otherwise, just display the frameskip plus the level */ + else + dest += sprintf(dest, "skip %d/%d", effective_frameskip(), MAX_FRAMESKIP); + + /* append the speed for all cases except paused */ + if (!paused) + dest += sprintf(dest, "%4d%%", (int)(100 * global.speed_percent + 0.5)); + + /* display the number of partial updates as well */ + if (global.partial_updates_this_frame > 1) + dest += sprintf(dest, "\n%d partial updates", global.partial_updates_this_frame); + /* return a pointer to the static buffer */ + return buffer; +} /*------------------------------------------------- - video_screen_get_vblank - returns the VBLANK - state of a given screen + video_get_speed_percent - return the current + effective speed percentage -------------------------------------------------*/ -int video_screen_get_vblank(running_device *screen) +double video_get_speed_percent(running_machine *machine) { - screen_state *state = get_safe_token(screen); - - /* we should never be called with no VBLANK period - indication of a buggy driver */ - assert(state->vblank_period != 0); - - return (attotime_compare(timer_get_time(screen->machine), state->vblank_end_time) < 0); + return global.speed_percent; } /*------------------------------------------------- - video_screen_get_hblank - returns the HBLANK - state of a given screen + video_get_frameskip - return the current + actual frameskip (-1 means autoframeskip) -------------------------------------------------*/ -int video_screen_get_hblank(running_device *screen) +int video_get_frameskip(void) { - screen_state *state = get_safe_token(screen); - int hpos = video_screen_get_hpos(screen); - return (hpos < state->visarea.min_x || hpos > state->visarea.max_x); + /* if autoframeskip is on, return -1 */ + if (global.auto_frameskip) + return -1; + + /* otherwise, return the direct level */ + else + return global.frameskip_level; } /*------------------------------------------------- - video_screen_get_width - returns the width - of a given screen + video_set_frameskip - set the current + actual frameskip (-1 means autoframeskip) -------------------------------------------------*/ -int video_screen_get_width(running_device *screen) + +void video_set_frameskip(int frameskip) { - screen_state *state = get_safe_token(screen); - return state->width; + /* -1 means autoframeskip */ + if (frameskip == -1) + { + global.auto_frameskip = TRUE; + global.frameskip_level = 0; + } + + /* any other level is a direct control */ + else if (frameskip >= 0 && frameskip <= MAX_FRAMESKIP) + { + global.auto_frameskip = FALSE; + global.frameskip_level = frameskip; + } } /*------------------------------------------------- - video_screen_get_height - returns the height - of a given screen + video_get_throttle - return the current + actual throttle -------------------------------------------------*/ -int video_screen_get_height(running_device *screen) + +int video_get_throttle(void) { - screen_state *state = get_safe_token(screen); - return state->height; + return global.throttle; } /*------------------------------------------------- - video_screen_get_visible_area - returns the - visible area of a given screen + video_set_throttle - set the current + actual throttle -------------------------------------------------*/ -const rectangle *video_screen_get_visible_area(running_device *screen) + +void video_set_throttle(int throttle) { - screen_state *state = get_safe_token(screen); - return &state->visarea; + global.throttle = throttle; } /*------------------------------------------------- - video_screen_get_time_until_pos - returns the - amount of time remaining until the beam is - at the given hpos,vpos + video_get_fastforward - return the current + fastforward value -------------------------------------------------*/ -attotime video_screen_get_time_until_pos(running_device *screen, int vpos, int hpos) +int video_get_fastforward(void) { - screen_state *state = get_safe_token(screen); - attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(screen->machine), state->vblank_start_time)); - attoseconds_t targetdelta; - - /* validate arguments */ - assert(vpos >= 0); - assert(hpos >= 0); - - /* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */ - vpos += state->height - (state->visarea.max_y + 1); - vpos %= state->height; - - /* compute the delta for the given X,Y position */ - targetdelta = (attoseconds_t)vpos * state->scantime + (attoseconds_t)hpos * state->pixeltime; - - /* if we're past that time (within 1/2 of a pixel), head to the next frame */ - if (targetdelta <= curdelta + state->pixeltime / 2) - targetdelta += state->frame_period; - while (targetdelta <= curdelta) - targetdelta += state->frame_period; - - /* return the difference */ - return attotime_make(0, targetdelta - curdelta); -} + return global.fastforward; +} /*------------------------------------------------- - video_screen_get_time_until_vblank_start - - returns the amount of time remaining until - the next VBLANK period start + video_set_fastforward - set the current + fastforward value -------------------------------------------------*/ -attotime video_screen_get_time_until_vblank_start(running_device *screen) +void video_set_fastforward(int _fastforward) { - return video_screen_get_time_until_pos(screen, video_screen_get_visible_area(screen)->max_y + 1, 0); + global.fastforward = _fastforward; } /*------------------------------------------------- - video_screen_get_time_until_vblank_end - - returns the amount of time remaining until - the end of the current VBLANK (if in progress) - or the end of the next VBLANK + update_throttle - throttle to the game's + natural speed -------------------------------------------------*/ -attotime video_screen_get_time_until_vblank_end(running_device *screen) +static void update_throttle(running_machine *machine, attotime emutime) { - attotime ret; - screen_state *state = get_safe_token(screen); - attotime current_time = timer_get_time(screen->machine); - - /* we are in the VBLANK region, compute the time until the end of the current VBLANK period */ - if (video_screen_get_vblank(screen)) - ret = attotime_sub(state->vblank_end_time, current_time); - - /* otherwise compute the time until the end of the next frame VBLANK period */ - else - ret = attotime_sub(attotime_add_attoseconds(state->vblank_end_time, state->frame_period), current_time); - - return ret; -} +/* + Throttling theory: -/*------------------------------------------------- - video_screen_get_time_until_update - - returns the amount of time remaining until - the next VBLANK period start --------------------------------------------------*/ + This routine is called periodically with an up-to-date emulated time. + The idea is to synchronize real time with emulated time. We do this + by "throttling", or waiting for real time to catch up with emulated + time. -attotime video_screen_get_time_until_update(running_device *screen) -{ - if (screen->machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK) - return video_screen_get_time_until_vblank_end(screen); - else - return video_screen_get_time_until_vblank_start(screen); -} + In an ideal world, it will take less real time to emulate and render + each frame than the emulated time, so we need to slow things down to + get both times in sync. + There are many complications to this model: -/*------------------------------------------------- - video_screen_get_scan_period - return the - amount of time the beam takes to draw one - scanline --------------------------------------------------*/ + * some games run too slow, so each frame we get further and + further behind real time; our only choice here is to not + throttle -attotime video_screen_get_scan_period(running_device *screen) -{ - screen_state *state = get_safe_token(screen); - return attotime_make(0, state->scantime); -} + * some games have very uneven frame rates; one frame will take + a long time to emulate, and the next frame may be very fast + * we run on top of multitasking OSes; sometimes execution time + is taken away from us, and this means we may not get enough + time to emulate one frame -/*------------------------------------------------- - video_screen_get_frame_period - return the - amount of time the beam takes to draw one - complete frame --------------------------------------------------*/ + * we may be paused, and emulated time may not be marching + forward -attotime video_screen_get_frame_period(running_device *screen) -{ - attotime ret; + * emulated time could jump due to resetting the machine or + restoring from a saved state - /* a lot of modules want to the period of the primary screen, so - if we are screenless, return something reasonable so that we don't fall over */ - if (screen == NULL || !screen->started || video_screen_count(screen->machine->config) == 0) +*/ + static const UINT8 popcount[256] = { - ret = DEFAULT_FRAME_PERIOD; - } - else + 0,1,1,2,1,2,2,3, 1,2,2,3,2,3,3,4, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, + 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, + 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, + 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, + 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, + 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, + 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, + 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 4,5,5,6,5,6,6,7, 5,6,6,7,6,7,7,8 + }; + attoseconds_t real_delta_attoseconds; + attoseconds_t emu_delta_attoseconds; + attoseconds_t real_is_ahead_attoseconds; + attoseconds_t attoseconds_per_tick; + osd_ticks_t ticks_per_second; + osd_ticks_t target_ticks; + osd_ticks_t diff_ticks; + + /* apply speed factor to emu time */ + if (global.speed != 0 && global.speed != 100) { - screen_state *state = get_safe_token(screen); - ret = attotime_make(0, state->frame_period); + /* multiply emutime by 100, then divide by the global speed factor */ + emutime = attotime_div(attotime_mul(emutime, 100), global.speed); } - return ret; -} - - -/*------------------------------------------------- - video_screen_get_frame_number - return the - current frame number since the start of the - emulated machine --------------------------------------------------*/ - -UINT64 video_screen_get_frame_number(running_device *screen) -{ - screen_state *state = get_safe_token(screen); - return state->frame_number; -} - - -/*------------------------------------------------- - video_screen_register_vblank_callback - registers a - VBLANK callback for a specific screen --------------------------------------------------*/ - -void video_screen_register_vblank_callback(running_device *screen, vblank_state_changed_func vblank_callback, void *param) -{ - screen_state *state = get_safe_token(screen); - int i, found; - - /* validate arguments */ - assert(vblank_callback != NULL); + /* compute conversion factors up front */ + ticks_per_second = osd_ticks_per_second(); + attoseconds_per_tick = ATTOSECONDS_PER_SECOND / ticks_per_second; - /* check if we already have this callback registered */ - found = FALSE; - for (i = 0; i < MAX_VBLANK_CALLBACKS; i++) + /* if we're paused, emutime will not advance; instead, we subtract a fixed + amount of time (1/60th of a second) from the emulated time that was passed in, + and explicitly reset our tracked real and emulated timers to that value ... + this means we pretend that the last update was exactly 1/60th of a second + ago, and was in sync in both real and emulated time */ + if (mame_is_paused(machine)) { - if (state->vblank_callback[i] == NULL) - break; - - if (state->vblank_callback[i] == vblank_callback) - found = TRUE; + global.throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); + global.throttle_realtime = global.throttle_emutime; } - /* check that there is room */ - assert(i != MAX_VBLANK_CALLBACKS); - - /* if not found, register and increment count */ - if (!found) + /* attempt to detect anomalies in the emulated time by subtracting the previously + reported value from our current value; this should be a small value somewhere + between 0 and 1/10th of a second ... anything outside of this range is obviously + wrong and requires a resync */ + emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, global.throttle_emutime)); + if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10) { - state->vblank_callback[i] = vblank_callback; - state->vblank_callback_param[i] = param; + if (LOG_THROTTLE) + logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18)); + goto resync; } -} - - -/*************************************************************************** - VIDEO SCREEN DEVICE INTERFACE -***************************************************************************/ - -/*------------------------------------------------- - device_start_video_screen - device start - callback for a video screen --------------------------------------------------*/ -static DEVICE_START( video_screen ) -{ - running_device *screen = device; - screen_state *state = get_safe_token(screen); - render_container_user_settings settings; - render_container *container; - screen_config *config; - - /* validate some basic stuff */ - assert(screen != NULL); - assert(screen->baseconfig().static_config == NULL); - assert(screen->baseconfig().inline_config != NULL); - assert(screen->machine != NULL); - assert(screen->machine->config != NULL); - - /* get and validate that the container for this screen exists */ - container = render_container_get_screen(screen); - assert(container != NULL); + /* now determine the current real time in OSD-specified ticks; we have to be careful + here because counters can wrap, so we only use the difference between the last + read value and the current value in our computations */ + diff_ticks = osd_ticks() - global.throttle_last_ticks; + global.throttle_last_ticks += diff_ticks; - /* get and validate the configuration */ - config = (screen_config *)screen->baseconfig().inline_config; - assert(config->width > 0); - assert(config->height > 0); - assert(config->refresh > 0); - assert(config->visarea.min_x >= 0); - assert(config->visarea.max_x < config->width || config->type == SCREEN_TYPE_VECTOR); - assert(config->visarea.max_x > config->visarea.min_x); - assert(config->visarea.min_y >= 0); - assert(config->visarea.max_y < config->height || config->type == SCREEN_TYPE_VECTOR); - assert(config->visarea.max_y > config->visarea.min_y); - - /* allocate the VBLANK timers */ - state->vblank_begin_timer = timer_alloc(screen->machine, vblank_begin_callback, (void *)screen); - state->vblank_end_timer = timer_alloc(screen->machine, vblank_end_callback, (void *)screen); - - /* allocate a timer to reset partial updates */ - state->scanline0_timer = timer_alloc(screen->machine, scanline0_callback, (void *)screen); - - /* configure the default cliparea */ - render_container_get_user_settings(container, &settings); - if (config->xoffset != 0) - settings.xoffset = config->xoffset; - if (config->yoffset != 0) - settings.yoffset = config->yoffset; - if (config->xscale != 0) - settings.xscale = config->xscale; - if (config->yscale != 0) - settings.yscale = config->yscale; - render_container_set_user_settings(container, &settings); + /* if it has been more than a full second of real time since the last call to this + function, we just need to resynchronize */ + if (diff_ticks >= ticks_per_second) + { + if (LOG_THROTTLE) + logerror("Resync due to real time advancing by more than 1 second\n"); + goto resync; + } - /* allocate a timer to generate per-scanline updates */ - if (screen->machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) - state->scanline_timer = timer_alloc(screen->machine, scanline_update_callback, (void *)screen); + /* convert this value into attoseconds for easier comparison */ + real_delta_attoseconds = diff_ticks * attoseconds_per_tick; - /* configure the screen with the default parameters */ - video_screen_configure(screen, config->width, config->height, &config->visarea, config->refresh); + /* now update our real and emulated timers with the current values */ + global.throttle_emutime = emutime; + global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, real_delta_attoseconds); - /* reset VBLANK timing */ - state->vblank_start_time = attotime_zero; - state->vblank_end_time = attotime_make(0, state->vblank_period); + /* keep a history of whether or not emulated time beat real time over the last few + updates; this can be used for future heuristics */ + global.throttle_history = (global.throttle_history << 1) | (emu_delta_attoseconds > real_delta_attoseconds); - /* start the timer to generate per-scanline updates */ - if (screen->machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + /* determine how far ahead real time is versus emulated time; note that we use the + accumulated times for this instead of the deltas for the current update because + we want to track time over a longer duration than a single update */ + real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(global.throttle_emutime, global.throttle_realtime)); - /* create burn-in bitmap */ - if (options_get_int(mame_options(), OPTION_BURNIN) > 0) + /* if we're more than 1/10th of a second out, or if we are behind at all and emulation + is taking longer than the real frame, we just need to resync */ + if (real_is_ahead_attoseconds < -ATTOSECONDS_PER_SECOND / 10 || + (real_is_ahead_attoseconds < 0 && popcount[global.throttle_history & 0xff] < 6)) { - int width, height; - if (sscanf(options_get_string(mame_options(), OPTION_SNAPSIZE), "%dx%d", &width, &height) != 2 || width == 0 || height == 0) - width = height = 300; - state->burnin = bitmap_alloc(width, height, BITMAP_FORMAT_INDEXED64); - if (state->burnin == NULL) - fatalerror("Error allocating burn-in bitmap for screen at (%dx%d)\n", width, height); - bitmap_fill(state->burnin, NULL, 0); + if (LOG_THROTTLE) + logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), global.throttle_history); + goto resync; } - state_save_register_device_item(screen, 0, state->width); - state_save_register_device_item(screen, 0, state->height); - state_save_register_device_item(screen, 0, state->visarea.min_x); - state_save_register_device_item(screen, 0, state->visarea.min_y); - state_save_register_device_item(screen, 0, state->visarea.max_x); - state_save_register_device_item(screen, 0, state->visarea.max_y); - state_save_register_device_item(screen, 0, state->last_partial_scan); - state_save_register_device_item(screen, 0, state->frame_period); - state_save_register_device_item(screen, 0, state->scantime); - state_save_register_device_item(screen, 0, state->pixeltime); - state_save_register_device_item(screen, 0, state->vblank_period); - state_save_register_device_item(screen, 0, state->vblank_start_time.seconds); - state_save_register_device_item(screen, 0, state->vblank_start_time.attoseconds); - state_save_register_device_item(screen, 0, state->vblank_end_time.seconds); - state_save_register_device_item(screen, 0, state->vblank_end_time.attoseconds); - state_save_register_device_item(screen, 0, state->frame_number); - state_save_register_postload(device->machine, video_screen_postload, (void *)device); -} + /* if we're behind, it's time to just get out */ + if (real_is_ahead_attoseconds < 0) + return; + /* compute the target real time, in ticks, where we want to be */ + target_ticks = global.throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick; -/*------------------------------------------------- - video_screen_postload - after a state load, - reconfigure each screen --------------------------------------------------*/ + /* throttle until we read the target, and update real time to match the final time */ + diff_ticks = throttle_until_ticks(machine, target_ticks) - global.throttle_last_ticks; + global.throttle_last_ticks += diff_ticks; + global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, diff_ticks * attoseconds_per_tick); + return; -static STATE_POSTLOAD( video_screen_postload ) -{ - running_device *screen = (running_device *)param; - realloc_screen_bitmaps(screen); - global.movie_next_frame_time = timer_get_time(machine); +resync: + /* reset realtime and emutime to the same value */ + global.throttle_realtime = global.throttle_emutime = emutime; } /*------------------------------------------------- - device_stop_video_screen - device stop - callback for a video screen + throttle_until_ticks - spin until the + specified target time, calling the OSD code + to sleep if possible -------------------------------------------------*/ -static DEVICE_STOP( video_screen ) +static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t target_ticks) { - running_device *screen = device; - screen_state *state = get_safe_token(screen); - - if (state->texture[0] != NULL) - render_texture_free(state->texture[0]); - if (state->texture[1] != NULL) - render_texture_free(state->texture[1]); - if (state->bitmap[0] != NULL) - bitmap_free(state->bitmap[0]); - if (state->bitmap[1] != NULL) - bitmap_free(state->bitmap[1]); - if (state->burnin != NULL) - { - video_finalize_burnin(screen); - bitmap_free(state->burnin); - } -} - + osd_ticks_t minimum_sleep = osd_ticks_per_second() / 1000; + osd_ticks_t current_ticks = osd_ticks(); + osd_ticks_t new_ticks; + int allowed_to_sleep = FALSE; -/*------------------------------------------------- - video_screen_get_info - device get info - callback --------------------------------------------------*/ + /* we're allowed to sleep via the OSD code only if we're configured to do so + and we're not frameskipping due to autoframeskip, or if we're paused */ + if (options_get_bool(mame_options(), OPTION_SLEEP) && (!effective_autoframeskip(machine) || effective_frameskip() == 0)) + allowed_to_sleep = TRUE; + if (mame_is_paused(machine)) + allowed_to_sleep = TRUE; -DEVICE_GET_INFO( video_screen ) -{ - switch (state) + /* loop until we reach our target */ + profiler_mark_start(PROFILER_IDLE); + while (current_ticks < target_ticks) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(screen_state); break; - case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(screen_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(video_screen); break; - case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(video_screen); break; - case DEVINFO_FCT_RESET: /* Nothing */ break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Raster"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Video Screen"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; - } -} - - + osd_ticks_t delta; + int slept = FALSE; -/*************************************************************************** - GLOBAL RENDERING -***************************************************************************/ + /* compute how much time to sleep for, taking into account the average oversleep */ + delta = (target_ticks - current_ticks) * 1000 / (1000 + global.average_oversleep); -/*------------------------------------------------- - vblank_begin_callback - call any external - callbacks to signal the VBLANK period has begun --------------------------------------------------*/ + /* see if we can sleep */ + if (allowed_to_sleep && delta >= minimum_sleep) + { + osd_sleep(delta); + slept = TRUE; + } -static TIMER_CALLBACK( vblank_begin_callback ) -{ - int i; - running_device *screen = (running_device *)ptr; - screen_state *state = get_safe_token(screen); + /* read the new value */ + new_ticks = osd_ticks(); - /* reset the starting VBLANK time */ - state->vblank_start_time = timer_get_time(machine); - state->vblank_end_time = attotime_add_attoseconds(state->vblank_start_time, state->vblank_period); + /* keep some metrics on the sleeping patterns of the OSD layer */ + if (slept) + { + osd_ticks_t actual_ticks = new_ticks - current_ticks; - /* call the screen specific callbacks */ - for (i = 0; state->vblank_callback[i] != NULL; i++) - (*state->vblank_callback[i])(screen, state->vblank_callback_param[i], TRUE); + /* if we overslept, keep an average of the amount */ + if (actual_ticks > delta) + { + osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta; - /* if this is the primary screen and we need to update now */ - if (screen == machine->primary_screen && !(machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) - video_frame_update(machine, FALSE); + /* take 90% of the previous average plus 10% of the new value */ + global.average_oversleep = (global.average_oversleep * 99 + oversleep_milliticks) / 100; - /* reset the VBLANK start timer for the next frame */ - timer_adjust_oneshot(state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0); + if (LOG_THROTTLE) + logerror("Slept for %d ticks, got %d ticks, avgover = %d\n", (int)delta, (int)actual_ticks, (int)global.average_oversleep); + } + } + current_ticks = new_ticks; + } + profiler_mark_end(); - /* if no VBLANK period, call the VBLANK end callback immedietely, otherwise reset the timer */ - if (state->vblank_period == 0) - vblank_end_callback(machine, ptr, 0); - else - timer_adjust_oneshot(state->vblank_end_timer, video_screen_get_time_until_vblank_end(screen), 0); + return current_ticks; } /*------------------------------------------------- - vblank_end_callback - call any external - callbacks to signal the VBLANK period has ended + update_frameskip - update frameskipping + counters and periodically update autoframeskip -------------------------------------------------*/ -static TIMER_CALLBACK( vblank_end_callback ) +static void update_frameskip(running_machine *machine) { - int i; - running_device *screen = (running_device *)ptr; - screen_state *state = get_safe_token(screen); - - /* call the screen specific callbacks */ - for (i = 0; state->vblank_callback[i] != NULL; i++) - (*state->vblank_callback[i])(screen, state->vblank_callback_param[i], FALSE); + /* if we're throttling and autoframeskip is on, adjust */ + if (effective_throttle(machine) && effective_autoframeskip(machine) && global.frameskip_counter == 0) + { + double speed = global.speed * 0.01; - /* if this is the primary screen and we need to update now */ - if (screen == machine->primary_screen && (machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) - video_frame_update(machine, FALSE); + /* if we're too fast, attempt to increase the frameskip */ + if (global.speed_percent >= 0.995 * speed) + { + /* but only after 3 consecutive frames where we are too fast */ + if (++global.frameskip_adjust >= 3) + { + global.frameskip_adjust = 0; + if (global.frameskip_level > 0) + global.frameskip_level--; + } + } - /* increment the frame number counter */ - state->frame_number++; -} + /* if we're too slow, attempt to increase the frameskip */ + else + { + /* if below 80% speed, be more aggressive */ + if (global.speed_percent < 0.80 * speed) + global.frameskip_adjust -= (0.90 * speed - global.speed_percent) / 0.05; + /* if we're close, only force it up to frameskip 8 */ + else if (global.frameskip_level < 8) + global.frameskip_adjust--; -/*------------------------------------------------- - screenless_update_callback - update generator - when there are no screens to drive it --------------------------------------------------*/ + /* perform the adjustment */ + while (global.frameskip_adjust <= -2) + { + global.frameskip_adjust += 2; + if (global.frameskip_level < MAX_FRAMESKIP) + global.frameskip_level++; + } + } + } -static TIMER_CALLBACK( screenless_update_callback ) -{ - /* force an update */ - video_frame_update(machine, FALSE); + /* increment the frameskip counter and determine if we will skip the next frame */ + global.frameskip_counter = (global.frameskip_counter + 1) % FRAMESKIP_LEVELS; + global.skipping_this_frame = skiptable[effective_frameskip()][global.frameskip_counter]; } /*------------------------------------------------- - scanline0_callback - reset partial updates - for a screen + update_refresh_speed - update the global.speed + based on the maximum refresh rate supported -------------------------------------------------*/ -static TIMER_CALLBACK( scanline0_callback ) +static void update_refresh_speed(running_machine *machine) { - running_device *screen = (running_device *)ptr; - screen_state *state = get_safe_token(screen); - - /* reset partial updates */ - state->last_partial_scan = 0; - global.partial_updates_this_frame = 0; - - timer_adjust_oneshot(state->scanline0_timer, video_screen_get_time_until_pos(screen, 0, 0), 0); -} - - -/*------------------------------------------------- - scanline_update_callback - perform partial - updates on each scanline --------------------------------------------------*/ + /* only do this if the refreshspeed option is used */ + if (options_get_bool(mame_options(), OPTION_REFRESHSPEED)) + { + float minrefresh = render_get_max_update_rate(); + if (minrefresh != 0) + { + attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; + UINT32 original_speed = original_speed_setting(); + UINT32 target_speed; -static TIMER_CALLBACK( scanline_update_callback ) -{ - running_device *screen = (running_device *)ptr; - screen_state *state = get_safe_token(screen); - int scanline = param; + /* find the screen with the shortest frame period (max refresh rate) */ + /* note that we first check the token since this can get called before all screens are created */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + { + attoseconds_t period = screen->frame_period().attoseconds; + if (period != 0) + min_frame_period = MIN(min_frame_period, period); + } - /* force a partial update to the current scanline */ - video_screen_update_partial(screen, scanline); + /* compute a target speed as an integral percentage */ + /* note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for + the fact that most refresh rates are not accurate to 10 digits... */ + target_speed = floor((minrefresh - 0.25f) * 100.0 / ATTOSECONDS_TO_HZ(min_frame_period)); + target_speed = MIN(target_speed, original_speed); - /* compute the next visible scanline */ - scanline++; - if (scanline > state->visarea.max_y) - scanline = state->visarea.min_y; - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline); + /* if we changed, log that verbosely */ + if (target_speed != global.speed) + { + mame_printf_verbose("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); + global.speed = target_speed; + } + } + } } /*------------------------------------------------- - video_frame_update - handle frameskipping and - UI, plus updating the screen during normal - operations + recompute_speed - recompute the current + overall speed; we assume this is called only + if we did not skip a frame -------------------------------------------------*/ -void video_frame_update(running_machine *machine, int debug) +static void recompute_speed(running_machine *machine, attotime emutime) { - attotime current_time = timer_get_time(machine); - int skipped_it = global.skipping_this_frame; - int phase = mame_get_phase(machine); - - /* validate */ - assert(machine != NULL); - assert(machine->config != NULL); + attoseconds_t delta_emutime; - /* only render sound and video if we're in the running phase */ - if (phase == MAME_PHASE_RUNNING && (!mame_is_paused(machine) || options_get_bool(mame_options(), OPTION_UPDATEINPAUSE))) + /* if we don't have a starting time yet, or if we're paused, reset our starting point */ + if (global.speed_last_realtime == 0 || mame_is_paused(machine)) { - int anything_changed = finish_screen_updates(machine); - - /* if none of the screens changed and we haven't skipped too many frames in a row, - mark this frame as skipped to prevent throttling; this helps for games that - don't update their screen at the monitor refresh rate */ - if (!anything_changed && !global.auto_frameskip && global.frameskip_level == 0 && global.empty_skip_count++ < 3) - skipped_it = TRUE; - else - global.empty_skip_count = 0; + global.speed_last_realtime = osd_ticks(); + global.speed_last_emutime = emutime; } - /* draw the user interface */ - ui_update_and_render(machine, render_container_get_ui()); - - /* update the internal render debugger */ - debugint_update_during_game(machine); - - /* if we're throttling, synchronize before rendering */ - if (!debug && !skipped_it && effective_throttle(machine)) - update_throttle(machine, current_time); - - /* ask the OSD to update */ - profiler_mark_start(PROFILER_BLIT); - osd_update(machine, !debug && skipped_it); - profiler_mark_end(); - - /* perform tasks for this frame */ - if (!debug) - mame_frame_update(machine); + /* if it has been more than the update interval, update the time */ + delta_emutime = attotime_to_attoseconds(attotime_sub(emutime, global.speed_last_emutime)); + if (delta_emutime > SUBSECONDS_PER_SPEED_UPDATE) + { + osd_ticks_t realtime = osd_ticks(); + osd_ticks_t delta_realtime = realtime - global.speed_last_realtime; + osd_ticks_t tps = osd_ticks_per_second(); - /* update frameskipping */ - if (!debug) - update_frameskip(machine); + /* convert from ticks to attoseconds */ + global.speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)ATTOSECONDS_PER_SECOND); - /* update speed computations */ - if (!debug && !skipped_it) - recompute_speed(machine, current_time); + /* remember the last times */ + global.speed_last_realtime = realtime; + global.speed_last_emutime = emutime; - /* call the end-of-frame callback */ - if (phase == MAME_PHASE_RUNNING) - { - /* reset partial updates if we're paused or if the debugger is active */ - if (machine->primary_screen != NULL && (mame_is_paused(machine) || debug || debugger_within_instruction_hook(machine))) - { - void *param = (void *)machine->primary_screen; - scanline0_callback(machine, param, 0); - } + /* if we're throttled, this time period counts for overall speed; otherwise, we reset the counter */ + if (!global.fastforward) + global.overall_valid_counter++; + else + global.overall_valid_counter = 0; - /* otherwise, call the video EOF callback */ - else if (machine->config->video_eof != NULL) + /* if we've had at least 4 consecutive valid periods, accumulate stats */ + if (global.overall_valid_counter >= 4) { - profiler_mark_start(PROFILER_VIDEO); - (*machine->config->video_eof)(machine); - profiler_mark_end(); + global.overall_real_ticks += delta_realtime; + while (global.overall_real_ticks >= tps) + { + global.overall_real_ticks -= tps; + global.overall_real_seconds++; + } + global.overall_emutime = attotime_add_attoseconds(global.overall_emutime, delta_emutime); } } -} - - -/*------------------------------------------------- - finish_screen_updates - finish updating all - the screens --------------------------------------------------*/ - -static int finish_screen_updates(running_machine *machine) -{ - running_device *screen; - int anything_changed = FALSE; - /* finish updating the screens */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) - video_screen_update_partial(screen, video_screen_get_visible_area(screen)->max_y); - - /* now add the quads for all the screens */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) + /* if we're past the "time-to-execute" requested, signal an exit */ + if (global.seconds_to_run != 0 && emutime.seconds >= global.seconds_to_run) { - screen_state *state = get_safe_token(screen); - - /* only update if live */ - if (render_is_live_screen(screen)) + if (machine->primary_screen != NULL) { - const screen_config *config = (const screen_config *)screen->baseconfig().inline_config; + astring fname(machine->basename, PATH_SEPARATOR "final.png"); + file_error filerr; + mame_file *file; - /* only update if empty and not a vector game; otherwise assume the driver did it directly */ - if (config->type != SCREEN_TYPE_VECTOR && (machine->config->video_attributes & VIDEO_SELF_RENDER) == 0) + /* create a final screenshot */ + filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); + if (filerr == FILERR_NONE) { - /* if we're not skipping the frame and if the screen actually changed, then update the texture */ - if (!global.skipping_this_frame && state->changed) - { - bitmap_t *bitmap = state->bitmap[state->curbitmap]; - rectangle fixedvis = *video_screen_get_visible_area(screen); - palette_t *palette = (state->texture_format == TEXFORMAT_PALETTE16) ? machine->palette : NULL; - - fixedvis.max_x++; - fixedvis.max_y++; - render_texture_set_bitmap(state->texture[state->curbitmap], bitmap, &fixedvis, state->texture_format, palette); - state->curtexture = state->curbitmap; - state->curbitmap = 1 - state->curbitmap; - } - - /* create an empty container with a single quad */ - render_container_empty(render_container_get_screen(screen)); - render_screen_add_quad(screen, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), state->texture[state->curtexture], PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); + screen_save_snapshot(machine, machine->primary_screen, file); + mame_fclose(file); } } - /* reset the screen changed flags */ - if (state->changed) - anything_changed = TRUE; - state->changed = FALSE; - } - - /* update our movie recording and burn-in state */ - if (!mame_is_paused(machine)) - { - video_mng_record_frame(machine); - video_avi_record_frame(machine); - video_update_burnin(machine); + /* schedule our demise */ + mame_schedule_exit(machine); } - - /* draw any crosshairs */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) - crosshair_render(screen); - - return anything_changed; } /*************************************************************************** - THROTTLING/FRAMESKIPPING/PERFORMANCE + SCREEN SNAPSHOTS ***************************************************************************/ /*------------------------------------------------- - video_skip_this_frame - accessor to determine - if this frame is being skipped + screen_save_snapshot - save a snapshot + to the given file handle -------------------------------------------------*/ -int video_skip_this_frame(void) +void screen_save_snapshot(running_machine *machine, device_t *screen, mame_file *fp) { - return global.skipping_this_frame; -} + png_info pnginfo = { 0 }; + const rgb_t *palette; + png_error error; + char text[256]; + /* validate */ + assert(!global.snap_native || screen != NULL); + assert(fp != NULL); -/*------------------------------------------------- - video_get_speed_factor - return the speed - factor as an integer * 100 --------------------------------------------------*/ + /* create the bitmap to pass in */ + create_snapshot_bitmap(screen); -int video_get_speed_factor(void) -{ - return global.speed; + /* add two text entries describing the image */ + sprintf(text, APPNAME " %s", build_version); + png_add_text(&pnginfo, "Software", text); + sprintf(text, "%s %s", machine->gamedrv->manufacturer, machine->gamedrv->description); + png_add_text(&pnginfo, "System", text); + + /* now do the actual work */ + palette = (machine->palette != NULL) ? palette_entry_list_adjusted(machine->palette) : NULL; + error = png_write_bitmap(mame_core_file(fp), &pnginfo, global.snap_bitmap, machine->config->total_colors, palette); + + /* free any data allocated */ + png_free(&pnginfo); } /*------------------------------------------------- - video_set_speed_factor - sets the speed - factor as an integer * 100 + video_save_active_screen_snapshots - save a + snapshot of all active screens -------------------------------------------------*/ -void video_set_speed_factor(int speed) +void video_save_active_screen_snapshots(running_machine *machine) { - global.speed = speed; + mame_file *fp; + + /* validate */ + assert(machine != NULL); + assert(machine->config != NULL); + + /* if we're native, then write one snapshot per visible screen */ + if (global.snap_native) + { + /* write one snapshot per visible screen */ + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) + if (render_is_live_screen(screen)) + { + file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); + if (filerr == FILERR_NONE) + { + screen_save_snapshot(machine, screen, fp); + mame_fclose(fp); + } + } + } + + /* otherwise, just write a single snapshot */ + else + { + file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); + if (filerr == FILERR_NONE) + { + screen_save_snapshot(machine, NULL, fp); + mame_fclose(fp); + } + } } /*------------------------------------------------- - video_get_speed_text - print the text to - be displayed in the upper-right corner + creare_snapshot_bitmap - creates a + bitmap containing the screenshot for the + given screen -------------------------------------------------*/ -const char *video_get_speed_text(running_machine *machine) +static void create_snapshot_bitmap(device_t *screen) { - int paused = mame_is_paused(machine); - static char buffer[1024]; - char *dest = buffer; - - /* validate */ - assert(machine != NULL); - - /* if we're paused, just display Paused */ - if (paused) - dest += sprintf(dest, "paused"); - - /* if we're fast forwarding, just display Fast-forward */ - else if (global.fastforward) - dest += sprintf(dest, "fast "); - - /* if we're auto frameskipping, display that plus the level */ - else if (effective_autoframeskip(machine)) - dest += sprintf(dest, "auto%2d/%d", effective_frameskip(), MAX_FRAMESKIP); + const render_primitive_list *primlist; + INT32 width, height; + int view_index; - /* otherwise, just display the frameskip plus the level */ - else - dest += sprintf(dest, "skip %d/%d", effective_frameskip(), MAX_FRAMESKIP); + /* select the appropriate view in our dummy target */ + if (global.snap_native && screen != NULL) + { + view_index = screen->machine->devicelist.index(SCREEN, screen->tag()); + assert(view_index != -1); + render_target_set_view(global.snap_target, view_index); + } - /* append the speed for all cases except paused */ - if (!paused) - dest += sprintf(dest, "%4d%%", (int)(100 * global.speed_percent + 0.5)); + /* get the minimum width/height and set it on the target */ + width = global.snap_width; + height = global.snap_height; + if (width == 0 || height == 0) + render_target_get_minimum_size(global.snap_target, &width, &height); + render_target_set_bounds(global.snap_target, width, height, 0); - /* display the number of partial updates as well */ - if (global.partial_updates_this_frame > 1) - dest += sprintf(dest, "\n%d partial updates", global.partial_updates_this_frame); + /* if we don't have a bitmap, or if it's not the right size, allocate a new one */ + if (global.snap_bitmap == NULL || width != global.snap_bitmap->width || height != global.snap_bitmap->height) + { + if (global.snap_bitmap != NULL) + global_free(global.snap_bitmap); + global.snap_bitmap = global_alloc(bitmap_t(width, height, BITMAP_FORMAT_RGB32)); + assert(global.snap_bitmap != NULL); + } - /* return a pointer to the static buffer */ - return buffer; + /* render the screen there */ + primlist = render_target_get_primitives(global.snap_target); + osd_lock_acquire(primlist->lock); + rgb888_draw_primitives(primlist->head, global.snap_bitmap->base, width, height, global.snap_bitmap->rowpixels); + osd_lock_release(primlist->lock); } /*------------------------------------------------- - video_get_speed_percent - return the current - effective speed percentage + mame_fopen_next - open the next non-existing + file of type filetype according to our + numbering scheme -------------------------------------------------*/ -double video_get_speed_percent(running_machine *machine) +static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file) { - return global.speed_percent; -} + const char *snapname = options_get_string(mame_options(), OPTION_SNAPNAME); + file_error filerr; + astring snapstr; + astring fname; + int index; + /* handle defaults */ + if (snapname == NULL || snapname[0] == 0) + snapname = "%g/%i"; + snapstr.cpy(snapname); -/*------------------------------------------------- - video_get_frameskip - return the current - actual frameskip (-1 means autoframeskip) --------------------------------------------------*/ + /* strip any extension in the provided name and add our own */ + index = snapstr.rchr(0, '.'); + if (index != -1) + snapstr.substr(0, index); + snapstr.cat(".").cat(extension); -int video_get_frameskip(void) -{ - /* if autoframeskip is on, return -1 */ - if (global.auto_frameskip) - return -1; + /* substitute path and gamename up front */ + snapstr.replace(0, "/", PATH_SEPARATOR); + snapstr.replace(0, "%g", machine->basename); - /* otherwise, return the direct level */ + /* determine if the template has an index; if not, we always use the same name */ + if (snapstr.find(0, "%i") == -1) + snapstr.cpy(snapstr); + + /* otherwise, we scan for the next available filename */ else - return global.frameskip_level; -} + { + int seq; + /* try until we succeed */ + for (seq = 0; ; seq++) + { + char seqtext[10]; -/*------------------------------------------------- - video_set_frameskip - set the current - actual frameskip (-1 means autoframeskip) --------------------------------------------------*/ + /* make text for the sequence number */ + sprintf(seqtext, "%04d", seq); -void video_set_frameskip(int frameskip) -{ - /* -1 means autoframeskip */ - if (frameskip == -1) - { - global.auto_frameskip = TRUE; - global.frameskip_level = 0; - } + /* build up the filename */ + fname.cpy(snapstr).replace(0, "%i", seqtext); - /* any other level is a direct control */ - else if (frameskip >= 0 && frameskip <= MAX_FRAMESKIP) - { - global.auto_frameskip = FALSE; - global.frameskip_level = frameskip; + /* try to open the file; stop when we fail */ + filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, file); + if (filerr != FILERR_NONE) + break; + mame_fclose(*file); + } } + + /* create the final file */ + return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file); } + +/*************************************************************************** + MNG MOVIE RECORDING +***************************************************************************/ + /*------------------------------------------------- - video_get_throttle - return the current - actual throttle + video_mng_is_movie_active - return true if a + MNG movie is currently being recorded -------------------------------------------------*/ -int video_get_throttle(void) +int video_mng_is_movie_active(running_machine *machine) { - return global.throttle; + return (global.mngfile != NULL); } /*------------------------------------------------- - video_set_throttle - set the current - actual throttle + video_mng_begin_recording - begin recording + of a MNG movie -------------------------------------------------*/ -void video_set_throttle(int throttle) +void video_mng_begin_recording(running_machine *machine, const char *name) { - global.throttle = throttle; -} + file_error filerr; + png_error pngerr; + int rate; + /* close any existing movie file */ + if (global.mngfile != NULL) + video_mng_end_recording(machine); -/*------------------------------------------------- - video_get_fastforward - return the current - fastforward value --------------------------------------------------*/ + /* create a snapshot bitmap so we know what the target size is */ + create_snapshot_bitmap(NULL); -int video_get_fastforward(void) -{ - return global.fastforward; + /* create a new movie file and start recording */ + if (name != NULL) + filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &global.mngfile); + else + filerr = mame_fopen_next(machine, SEARCHPATH_MOVIE, "mng", &global.mngfile); + + /* start the capture */ + rate = (machine->primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) : screen_device::k_default_frame_rate; + pngerr = mng_capture_start(mame_core_file(global.mngfile), global.snap_bitmap, rate); + if (pngerr != PNGERR_NONE) + { + video_mng_end_recording(machine); + return; + } + + /* compute the frame time */ + global.movie_next_frame_time = timer_get_time(machine); + global.movie_frame_period = ATTOTIME_IN_HZ(rate); + global.movie_frame = 0; } /*------------------------------------------------- - video_set_fastforward - set the current - fastforward value + video_mng_end_recording - stop recording of + a MNG movie -------------------------------------------------*/ -void video_set_fastforward(int _fastforward) +void video_mng_end_recording(running_machine *machine) { - global.fastforward = _fastforward; + /* close the file if it exists */ + if (global.mngfile != NULL) + { + mng_capture_stop(mame_core_file(global.mngfile)); + mame_fclose(global.mngfile); + global.mngfile = NULL; + global.movie_frame = 0; + } } /*------------------------------------------------- - update_throttle - throttle to the game's - natural speed + video_mng_record_frame - record a frame of a + movie -------------------------------------------------*/ -static void update_throttle(running_machine *machine, attotime emutime) +static void video_mng_record_frame(running_machine *machine) { -/* + /* only record if we have a file */ + if (global.mngfile != NULL) + { + attotime curtime = timer_get_time(machine); + png_info pnginfo = { 0 }; + png_error error; - Throttling theory: - - This routine is called periodically with an up-to-date emulated time. - The idea is to synchronize real time with emulated time. We do this - by "throttling", or waiting for real time to catch up with emulated - time. - - In an ideal world, it will take less real time to emulate and render - each frame than the emulated time, so we need to slow things down to - get both times in sync. - - There are many complications to this model: + profiler_mark_start(PROFILER_MOVIE_REC); - * some games run too slow, so each frame we get further and - further behind real time; our only choice here is to not - throttle + /* create the bitmap */ + create_snapshot_bitmap(NULL); - * some games have very uneven frame rates; one frame will take - a long time to emulate, and the next frame may be very fast + /* loop until we hit the right time */ + while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) + { + const rgb_t *palette; - * we run on top of multitasking OSes; sometimes execution time - is taken away from us, and this means we may not get enough - time to emulate one frame + /* set up the text fields in the movie info */ + if (global.movie_frame == 0) + { + char text[256]; - * we may be paused, and emulated time may not be marching - forward + sprintf(text, APPNAME " %s", build_version); + png_add_text(&pnginfo, "Software", text); + sprintf(text, "%s %s", machine->gamedrv->manufacturer, machine->gamedrv->description); + png_add_text(&pnginfo, "System", text); + } - * emulated time could jump due to resetting the machine or - restoring from a saved state + /* write the next frame */ + palette = (machine->palette != NULL) ? palette_entry_list_adjusted(machine->palette) : NULL; + error = mng_capture_frame(mame_core_file(global.mngfile), &pnginfo, global.snap_bitmap, machine->config->total_colors, palette); + png_free(&pnginfo); + if (error != PNGERR_NONE) + { + video_mng_end_recording(machine); + break; + } -*/ - static const UINT8 popcount[256] = - { - 0,1,1,2,1,2,2,3, 1,2,2,3,2,3,3,4, 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, - 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, - 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, - 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, - 1,2,2,3,2,3,3,4, 2,3,3,4,3,4,4,5, 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, - 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, - 2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, - 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 4,5,5,6,5,6,6,7, 5,6,6,7,6,7,7,8 - }; - attoseconds_t real_delta_attoseconds; - attoseconds_t emu_delta_attoseconds; - attoseconds_t real_is_ahead_attoseconds; - attoseconds_t attoseconds_per_tick; - osd_ticks_t ticks_per_second; - osd_ticks_t target_ticks; - osd_ticks_t diff_ticks; + /* advance time */ + global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); + global.movie_frame++; + } - /* apply speed factor to emu time */ - if (global.speed != 0 && global.speed != 100) - { - /* multiply emutime by 100, then divide by the global speed factor */ - emutime = attotime_div(attotime_mul(emutime, 100), global.speed); + profiler_mark_end(); } +} - /* compute conversion factors up front */ - ticks_per_second = osd_ticks_per_second(); - attoseconds_per_tick = ATTOSECONDS_PER_SECOND / ticks_per_second; - - /* if we're paused, emutime will not advance; instead, we subtract a fixed - amount of time (1/60th of a second) from the emulated time that was passed in, - and explicitly reset our tracked real and emulated timers to that value ... - this means we pretend that the last update was exactly 1/60th of a second - ago, and was in sync in both real and emulated time */ - if (mame_is_paused(machine)) - { - global.throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); - global.throttle_realtime = global.throttle_emutime; - } - /* attempt to detect anomalies in the emulated time by subtracting the previously - reported value from our current value; this should be a small value somewhere - between 0 and 1/10th of a second ... anything outside of this range is obviously - wrong and requires a resync */ - emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, global.throttle_emutime)); - if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10) - { - if (LOG_THROTTLE) - logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18)); - goto resync; - } - /* now determine the current real time in OSD-specified ticks; we have to be careful - here because counters can wrap, so we only use the difference between the last - read value and the current value in our computations */ - diff_ticks = osd_ticks() - global.throttle_last_ticks; - global.throttle_last_ticks += diff_ticks; +/*************************************************************************** + AVI MOVIE RECORDING +***************************************************************************/ - /* if it has been more than a full second of real time since the last call to this - function, we just need to resynchronize */ - if (diff_ticks >= ticks_per_second) - { - if (LOG_THROTTLE) - logerror("Resync due to real time advancing by more than 1 second\n"); - goto resync; - } +/*------------------------------------------------- + video_avi_begin_recording - begin recording + of an AVI movie +-------------------------------------------------*/ - /* convert this value into attoseconds for easier comparison */ - real_delta_attoseconds = diff_ticks * attoseconds_per_tick; +void video_avi_begin_recording(running_machine *machine, const char *name) +{ + avi_movie_info info; + mame_file *tempfile; + file_error filerr; + avi_error avierr; - /* now update our real and emulated timers with the current values */ - global.throttle_emutime = emutime; - global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, real_delta_attoseconds); + /* close any existing movie file */ + if (global.avifile != NULL) + video_avi_end_recording(machine); - /* keep a history of whether or not emulated time beat real time over the last few - updates; this can be used for future heuristics */ - global.throttle_history = (global.throttle_history << 1) | (emu_delta_attoseconds > real_delta_attoseconds); + /* create a snapshot bitmap so we know what the target size is */ + create_snapshot_bitmap(NULL); - /* determine how far ahead real time is versus emulated time; note that we use the - accumulated times for this instead of the deltas for the current update because - we want to track time over a longer duration than a single update */ - real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(global.throttle_emutime, global.throttle_realtime)); + /* build up information about this new movie */ + info.video_format = 0; + info.video_timescale = 1000 * ((machine->primary_screen != NULL) ? ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) : screen_device::k_default_frame_rate); + info.video_sampletime = 1000; + info.video_numsamples = 0; + info.video_width = global.snap_bitmap->width; + info.video_height = global.snap_bitmap->height; + info.video_depth = 24; - /* if we're more than 1/10th of a second out, or if we are behind at all and emulation - is taking longer than the real frame, we just need to resync */ - if (real_is_ahead_attoseconds < -ATTOSECONDS_PER_SECOND / 10 || - (real_is_ahead_attoseconds < 0 && popcount[global.throttle_history & 0xff] < 6)) - { - if (LOG_THROTTLE) - logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), global.throttle_history); - goto resync; - } + info.audio_format = 0; + info.audio_timescale = machine->sample_rate; + info.audio_sampletime = 1; + info.audio_numsamples = 0; + info.audio_channels = 2; + info.audio_samplebits = 16; + info.audio_samplerate = machine->sample_rate; - /* if we're behind, it's time to just get out */ - if (real_is_ahead_attoseconds < 0) - return; + /* create a new temporary movie file */ + if (name != NULL) + filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &tempfile); + else + filerr = mame_fopen_next(machine, SEARCHPATH_MOVIE, "avi", &tempfile); - /* compute the target real time, in ticks, where we want to be */ - target_ticks = global.throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick; + /* reset our tracking */ + global.movie_frame = 0; + global.movie_next_frame_time = timer_get_time(machine); + global.movie_frame_period = attotime_div(ATTOTIME_IN_SEC(1000), info.video_timescale); - /* throttle until we read the target, and update real time to match the final time */ - diff_ticks = throttle_until_ticks(machine, target_ticks) - global.throttle_last_ticks; - global.throttle_last_ticks += diff_ticks; - global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, diff_ticks * attoseconds_per_tick); - return; + /* if we succeeded, make a copy of the name and create the real file over top */ + if (filerr == FILERR_NONE) + { + astring fullname(mame_file_full_name(tempfile)); + mame_fclose(tempfile); -resync: - /* reset realtime and emutime to the same value */ - global.throttle_realtime = global.throttle_emutime = emutime; + /* create the file and free the string */ + avierr = avi_create(fullname, &info, &global.avifile); + } } /*------------------------------------------------- - throttle_until_ticks - spin until the - specified target time, calling the OSD code - to sleep if possible + video_avi_end_recording - stop recording of + a avi movie -------------------------------------------------*/ -static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t target_ticks) +void video_avi_end_recording(running_machine *machine) { - osd_ticks_t minimum_sleep = osd_ticks_per_second() / 1000; - osd_ticks_t current_ticks = osd_ticks(); - osd_ticks_t new_ticks; - int allowed_to_sleep = FALSE; - - /* we're allowed to sleep via the OSD code only if we're configured to do so - and we're not frameskipping due to autoframeskip, or if we're paused */ - if (options_get_bool(mame_options(), OPTION_SLEEP) && (!effective_autoframeskip(machine) || effective_frameskip() == 0)) - allowed_to_sleep = TRUE; - if (mame_is_paused(machine)) - allowed_to_sleep = TRUE; - - /* loop until we reach our target */ - profiler_mark_start(PROFILER_IDLE); - while (current_ticks < target_ticks) + /* close the file if it exists */ + if (global.avifile != NULL) { - osd_ticks_t delta; - int slept = FALSE; - - /* compute how much time to sleep for, taking into account the average oversleep */ - delta = (target_ticks - current_ticks) * 1000 / (1000 + global.average_oversleep); - - /* see if we can sleep */ - if (allowed_to_sleep && delta >= minimum_sleep) - { - osd_sleep(delta); - slept = TRUE; - } - - /* read the new value */ - new_ticks = osd_ticks(); - - /* keep some metrics on the sleeping patterns of the OSD layer */ - if (slept) - { - osd_ticks_t actual_ticks = new_ticks - current_ticks; - - /* if we overslept, keep an average of the amount */ - if (actual_ticks > delta) - { - osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta; - - /* take 90% of the previous average plus 10% of the new value */ - global.average_oversleep = (global.average_oversleep * 99 + oversleep_milliticks) / 100; - - if (LOG_THROTTLE) - logerror("Slept for %d ticks, got %d ticks, avgover = %d\n", (int)delta, (int)actual_ticks, (int)global.average_oversleep); - } - } - current_ticks = new_ticks; + avi_close(global.avifile); + global.avifile = NULL; + global.movie_frame = 0; } - profiler_mark_end(); - - return current_ticks; } /*------------------------------------------------- - update_frameskip - update frameskipping - counters and periodically update autoframeskip + video_avi_record_frame - record a frame of a + movie -------------------------------------------------*/ -static void update_frameskip(running_machine *machine) +static void video_avi_record_frame(running_machine *machine) { - /* if we're throttling and autoframeskip is on, adjust */ - if (effective_throttle(machine) && effective_autoframeskip(machine) && global.frameskip_counter == 0) + /* only record if we have a file */ + if (global.avifile != NULL) { - double speed = global.speed * 0.01; - - /* if we're too fast, attempt to increase the frameskip */ - if (global.speed_percent >= 0.995 * speed) - { - /* but only after 3 consecutive frames where we are too fast */ - if (++global.frameskip_adjust >= 3) - { - global.frameskip_adjust = 0; - if (global.frameskip_level > 0) - global.frameskip_level--; - } - } + attotime curtime = timer_get_time(machine); + avi_error avierr; - /* if we're too slow, attempt to increase the frameskip */ - else - { - /* if below 80% speed, be more aggressive */ - if (global.speed_percent < 0.80 * speed) - global.frameskip_adjust -= (0.90 * speed - global.speed_percent) / 0.05; + profiler_mark_start(PROFILER_MOVIE_REC); - /* if we're close, only force it up to frameskip 8 */ - else if (global.frameskip_level < 8) - global.frameskip_adjust--; + /* create the bitmap */ + create_snapshot_bitmap(NULL); - /* perform the adjustment */ - while (global.frameskip_adjust <= -2) + /* loop until we hit the right time */ + while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) + { + /* write the next frame */ + avierr = avi_append_video_frame_rgb32(global.avifile, global.snap_bitmap); + if (avierr != AVIERR_NONE) { - global.frameskip_adjust += 2; - if (global.frameskip_level < MAX_FRAMESKIP) - global.frameskip_level++; + video_avi_end_recording(machine); + break; } + + /* advance time */ + global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); + global.movie_frame++; } - } - /* increment the frameskip counter and determine if we will skip the next frame */ - global.frameskip_counter = (global.frameskip_counter + 1) % FRAMESKIP_LEVELS; - global.skipping_this_frame = skiptable[effective_frameskip()][global.frameskip_counter]; + profiler_mark_end(); + } } /*------------------------------------------------- - update_refresh_speed - update the global.speed - based on the maximum refresh rate supported + video_avi_add_sound - add sound to an AVI + recording -------------------------------------------------*/ -static void update_refresh_speed(running_machine *machine) +void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsamples) { - /* only do this if the refreshspeed option is used */ - if (options_get_bool(mame_options(), OPTION_REFRESHSPEED)) + /* only record if we have a file */ + if (global.avifile != NULL) { - float minrefresh = render_get_max_update_rate(); - if (minrefresh != 0) - { - attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND; - UINT32 original_speed = original_speed_setting(); - running_device *screen; - UINT32 target_speed; + avi_error avierr; - /* find the screen with the shortest frame period (max refresh rate) */ - /* note that we first check the token since this can get called before all screens are created */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) - if (screen->token != NULL) - { - screen_state *state = get_safe_token(screen); - if (state->frame_period != 0) - min_frame_period = MIN(min_frame_period, state->frame_period); - } + profiler_mark_start(PROFILER_MOVIE_REC); - /* compute a target speed as an integral percentage */ - /* note that we lop 0.25Hz off of the minrefresh when doing the computation to allow for - the fact that most refresh rates are not accurate to 10 digits... */ - target_speed = floor((minrefresh - 0.25f) * 100.0 / ATTOSECONDS_TO_HZ(min_frame_period)); - target_speed = MIN(target_speed, original_speed); + /* write the next frame */ + avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1); + if (avierr == AVIERR_NONE) + avierr = avi_append_sound_samples(global.avifile, 1, sound + 1, numsamples, 1); + if (avierr != AVIERR_NONE) + video_avi_end_recording(machine); - /* if we changed, log that verbosely */ - if (target_speed != global.speed) - { - mame_printf_verbose("Adjusting target speed to %d%% (hw=%.2fHz, game=%.2fHz, adjusted=%.2fHz)\n", target_speed, minrefresh, ATTOSECONDS_TO_HZ(min_frame_period), ATTOSECONDS_TO_HZ(min_frame_period * 100 / target_speed)); - global.speed = target_speed; - } - } + profiler_mark_end(); } } + +/*************************************************************************** + BURN-IN GENERATION +***************************************************************************/ + + +/*************************************************************************** + CONFIGURATION HELPERS +***************************************************************************/ + /*------------------------------------------------- - recompute_speed - recompute the current - overall speed; we assume this is called only - if we did not skip a frame + video_get_view_for_target - select a view + for a given target -------------------------------------------------*/ -static void recompute_speed(running_machine *machine, attotime emutime) +int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets) { - attoseconds_t delta_emutime; + int viewindex = -1; - /* if we don't have a starting time yet, or if we're paused, reset our starting point */ - if (global.speed_last_realtime == 0 || mame_is_paused(machine)) + /* auto view just selects the nth view */ + if (strcmp(viewname, "auto") != 0) { - global.speed_last_realtime = osd_ticks(); - global.speed_last_emutime = emutime; + /* scan for a matching view name */ + for (viewindex = 0; ; viewindex++) + { + const char *name = render_target_get_view_name(target, viewindex); + + /* stop scanning when we hit NULL */ + if (name == NULL) + { + viewindex = -1; + break; + } + if (mame_strnicmp(name, viewname, strlen(viewname)) == 0) + break; + } } - /* if it has been more than the update interval, update the time */ - delta_emutime = attotime_to_attoseconds(attotime_sub(emutime, global.speed_last_emutime)); - if (delta_emutime > SUBSECONDS_PER_SPEED_UPDATE) + /* if we don't have a match, default to the nth view */ + if (viewindex == -1) { - osd_ticks_t realtime = osd_ticks(); - osd_ticks_t delta_realtime = realtime - global.speed_last_realtime; - osd_ticks_t tps = osd_ticks_per_second(); - - /* convert from ticks to attoseconds */ - global.speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)ATTOSECONDS_PER_SECOND); - - /* remember the last times */ - global.speed_last_realtime = realtime; - global.speed_last_emutime = emutime; - - /* if we're throttled, this time period counts for overall speed; otherwise, we reset the counter */ - if (!global.fastforward) - global.overall_valid_counter++; - else - global.overall_valid_counter = 0; + int scrcount = screen_count(*machine->config); - /* if we've had at least 4 consecutive valid periods, accumulate stats */ - if (global.overall_valid_counter >= 4) + /* if we have enough targets to be one per screen, assign in order */ + if (numtargets >= scrcount) { - global.overall_real_ticks += delta_realtime; - while (global.overall_real_ticks >= tps) + /* find the first view with this screen and this screen only */ + for (viewindex = 0; ; viewindex++) { - global.overall_real_ticks -= tps; - global.overall_real_seconds++; + UINT32 viewscreens = render_target_get_view_screens(target, viewindex); + if (viewscreens == (1 << targetindex)) + break; + if (viewscreens == 0) + { + viewindex = -1; + break; + } } - global.overall_emutime = attotime_add_attoseconds(global.overall_emutime, delta_emutime); } - } - /* if we're past the "time-to-execute" requested, signal an exit */ - if (global.seconds_to_run != 0 && emutime.seconds >= global.seconds_to_run) - { - if (machine->primary_screen != NULL) + /* otherwise, find the first view that has all the screens */ + if (viewindex == -1) { - astring fname(machine->basename, PATH_SEPARATOR "final.png"); - file_error filerr; - mame_file *file; - - /* create a final screenshot */ - filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); - if (filerr == FILERR_NONE) + for (viewindex = 0; ; viewindex++) { - video_screen_save_snapshot(machine, machine->primary_screen, file); - mame_fclose(file); + UINT32 viewscreens = render_target_get_view_screens(target, viewindex); + if (viewscreens == (1 << scrcount) - 1) + break; + if (viewscreens == 0) + break; } } - - /* schedule our demise */ - mame_schedule_exit(machine); } + + /* make sure it's a valid view */ + if (render_target_get_view_name(target, viewindex) == NULL) + viewindex = 0; + + return viewindex; } /*************************************************************************** - SCREEN SNAPSHOTS + DEBUGGING HELPERS ***************************************************************************/ /*------------------------------------------------- - video_screen_save_snapshot - save a snapshot - to the given file handle + video_assert_out_of_range_pixels - assert if + any pixels in the given bitmap contain an + invalid palette index -------------------------------------------------*/ -void video_screen_save_snapshot(running_machine *machine, running_device *screen, mame_file *fp) +void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap) { - png_info pnginfo = { 0 }; - const rgb_t *palette; - png_error error; - char text[256]; +#ifdef MAME_DEBUG + int maxindex = palette_get_max_index(machine->palette); + int x, y; - /* validate */ - assert(!global.snap_native || screen != NULL); - assert(fp != NULL); + /* this only applies to indexed16 bitmaps */ + if (bitmap->format != BITMAP_FORMAT_INDEXED16) + return; - /* create the bitmap to pass in */ - create_snapshot_bitmap(screen); + /* iterate over rows */ + for (y = 0; y < bitmap->height; y++) + { + UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0); + for (x = 0; x < bitmap->width; x++) + assert(rowbase[x] < maxindex); + } +#endif +} - /* add two text entries describing the image */ - sprintf(text, APPNAME " %s", build_version); - png_add_text(&pnginfo, "Software", text); - sprintf(text, "%s %s", machine->gamedrv->manufacturer, machine->gamedrv->description); - png_add_text(&pnginfo, "System", text); - /* now do the actual work */ - palette = (machine->palette != NULL) ? palette_entry_list_adjusted(machine->palette) : NULL; - error = png_write_bitmap(mame_core_file(fp), &pnginfo, global.snap_bitmap, machine->config->total_colors, palette); - /* free any data allocated */ - png_free(&pnginfo); +//************************************************************************** +// VIDEO SCREEN DEVICE CONFIGURATION +//************************************************************************** + +const attotime screen_device::k_default_frame_period = STATIC_ATTOTIME_IN_HZ(k_default_frame_rate); + + +//------------------------------------------------- +// screen_device_config - constructor +//------------------------------------------------- + +screen_device_config::screen_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, tag, owner, clock), + m_type(SCREEN_TYPE_RASTER), + m_width(0), + m_height(0), + m_oldstyle_vblank_supplied(false), + m_refresh(0), + m_vblank(0), + m_format(BITMAP_FORMAT_INVALID), + m_xoffset(0.0f), + m_yoffset(0.0f), + m_xscale(1.0f), + m_yscale(1.0f) +{ } -/*------------------------------------------------- - video_save_active_screen_snapshots - save a - snapshot of all active screens --------------------------------------------------*/ +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- -void video_save_active_screen_snapshots(running_machine *machine) +device_config *screen_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) { - mame_file *fp; - running_device *screen; + return global_alloc(screen_device_config(mconfig, tag, owner, clock)); +} - /* validate */ - assert(machine != NULL); - assert(machine->config != NULL); - /* if we're native, then write one snapshot per visible screen */ - if (global.snap_native) +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *screen_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, screen_device(machine, *this)); +} + + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void screen_device_config::device_config_complete() +{ + // move inline data into its final home + m_type = static_cast(m_inline_data[INLINE_TYPE]); + m_width = static_cast(m_inline_data[INLINE_WIDTH]); + m_height = static_cast(m_inline_data[INLINE_HEIGHT]); + m_visarea.min_x = static_cast(m_inline_data[INLINE_VIS_MINX]); + m_visarea.min_y = static_cast(m_inline_data[INLINE_VIS_MINY]); + m_visarea.max_x = static_cast(m_inline_data[INLINE_VIS_MAXX]); + m_visarea.max_y = static_cast(m_inline_data[INLINE_VIS_MAXY]); + m_oldstyle_vblank_supplied = (m_inline_data[INLINE_OLDVBLANK] != 0); + m_refresh = m_inline_data[INLINE_REFRESH]; + m_vblank = m_inline_data[INLINE_VBLANK]; + m_format = static_cast(m_inline_data[INLINE_FORMAT]); + m_xoffset = static_cast(static_cast(m_inline_data[INLINE_XOFFSET])) / (double)(1 << 24); + m_yoffset = static_cast(static_cast(m_inline_data[INLINE_YOFFSET])) / (double)(1 << 24); + m_xscale = (m_inline_data[INLINE_XSCALE] == 0) ? 1.0 : (static_cast(static_cast(m_inline_data[INLINE_XSCALE])) / (double)(1 << 24)); + m_yscale = (m_inline_data[INLINE_YSCALE] == 0) ? 1.0 : (static_cast(static_cast(m_inline_data[INLINE_YSCALE])) / (double)(1 << 24)); +} + + +//------------------------------------------------- +// device_validity_check - verify device +// configuration +//------------------------------------------------- + +bool screen_device_config::device_validity_check(const game_driver &driver) const +{ + bool error = false; + + // sanity check dimensions + if (m_width <= 0 || m_height <= 0) { - /* write one snapshot per visible screen */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) - if (render_is_live_screen(screen)) - { - file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); - if (filerr == FILERR_NONE) - { - video_screen_save_snapshot(machine, screen, fp); - mame_fclose(fp); - } - } + mame_printf_error("%s: %s screen '%s' has invalid display dimensions\n", driver.source_file, driver.name, tag()); + error = true; } - /* otherwise, just write a single snapshot */ - else + // sanity check display area + if (m_type != SCREEN_TYPE_VECTOR) { - file_error filerr = mame_fopen_next(machine, SEARCHPATH_SCREENSHOT, "png", &fp); - if (filerr == FILERR_NONE) + if ((m_visarea.max_x < m_visarea.min_x) || + (m_visarea.max_y < m_visarea.min_y) || + (m_visarea.max_x >= m_width) || + (m_visarea.max_y >= m_height)) { - video_screen_save_snapshot(machine, NULL, fp); - mame_fclose(fp); + mame_printf_error("%s: %s screen '%s' has an invalid display area\n", driver.source_file, driver.name, tag()); + error = true; + } + + // sanity check screen formats + if (m_format != BITMAP_FORMAT_INDEXED16 && + m_format != BITMAP_FORMAT_RGB15 && + m_format != BITMAP_FORMAT_RGB32) + { + mame_printf_error("%s: %s screen '%s' has unsupported format\n", driver.source_file, driver.name, tag()); + error = true; } } + + // check for zero frame rate + if (m_refresh == 0) + { + mame_printf_error("%s: %s screen '%s' has a zero refresh rate\n", driver.source_file, driver.name, tag()); + error = true; + } + return error; +} + + + +//************************************************************************** +// LIVE VIDEO SCREEN DEVICE +//************************************************************************** + +//------------------------------------------------- +// screen_device - constructor +//------------------------------------------------- + +screen_device::screen_device(running_machine &_machine, const screen_device_config &config) + : device_t(_machine, config), + m_config(config), + m_width(m_config.m_width), + m_height(m_config.m_height), + m_visarea(m_config.m_visarea), + m_burnin(NULL), + m_curbitmap(0), + m_curtexture(0), + m_texture_format(0), + m_changed(true), + m_last_partial_scan(0), + m_frame_period(m_config.m_refresh), + m_scantime(0), + m_pixeltime(0), + m_vblank_period(0), + m_vblank_start_time(attotime_zero), + m_vblank_end_time(attotime_zero), + m_vblank_begin_timer(NULL), + m_vblank_end_timer(NULL), + m_scanline0_timer(NULL), + m_scanline_timer(NULL), + m_frame_number(0), + m_callback_list(NULL) +{ + memset(m_texture, 0, sizeof(m_texture)); + memset(m_bitmap, 0, sizeof(m_bitmap)); } -/*------------------------------------------------- - creare_snapshot_bitmap - creates a - bitmap containing the screenshot for the - given screen --------------------------------------------------*/ +//------------------------------------------------- +// ~screen_device - destructor +//------------------------------------------------- -static void create_snapshot_bitmap(running_device *screen) +screen_device::~screen_device() { - const render_primitive_list *primlist; - INT32 width, height; - int view_index; + if (m_texture[0] != NULL) + render_texture_free(m_texture[0]); + if (m_texture[1] != NULL) + render_texture_free(m_texture[1]); + if (m_burnin != NULL) + finalize_burnin(); +} - /* select the appropriate view in our dummy target */ - if (global.snap_native && screen != NULL) - { - view_index = screen->machine->devicelist.index(VIDEO_SCREEN, screen->tag()); - assert(view_index != -1); - render_target_set_view(global.snap_target, view_index); - } - /* get the minimum width/height and set it on the target */ - width = global.snap_width; - height = global.snap_height; - if (width == 0 || height == 0) - render_target_get_minimum_size(global.snap_target, &width, &height); - render_target_set_bounds(global.snap_target, width, height, 0); +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- - /* if we don't have a bitmap, or if it's not the right size, allocate a new one */ - if (global.snap_bitmap == NULL || width != global.snap_bitmap->width || height != global.snap_bitmap->height) +void screen_device::device_start() +{ + // get and validate that the container for this screen exists + render_container *container = render_container_get_screen(this); + assert(container != NULL); + + // configure the default cliparea + render_container_user_settings settings; + render_container_get_user_settings(container, &settings); + settings.xoffset = m_config.m_xoffset; + settings.yoffset = m_config.m_yoffset; + settings.xscale = m_config.m_xscale; + settings.yscale = m_config.m_yscale; + render_container_set_user_settings(container, &settings); + + // allocate the VBLANK timers + m_vblank_begin_timer = timer_alloc(machine, static_vblank_begin_callback, (void *)this); + m_vblank_end_timer = timer_alloc(machine, static_vblank_end_callback, (void *)this); + + // allocate a timer to reset partial updates + m_scanline0_timer = timer_alloc(machine, static_scanline0_callback, (void *)this); + + // allocate a timer to generate per-scanline updates + if ((machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) != 0) + m_scanline_timer = timer_alloc(machine, static_scanline_update_callback, (void *)this); + + // configure the screen with the default parameters + configure(m_config.m_width, m_config.m_height, m_config.m_visarea, m_config.m_refresh); + + // reset VBLANK timing */ + m_vblank_start_time = attotime_zero; + m_vblank_end_time = attotime_make(0, m_vblank_period); + + // start the timer to generate per-scanline updates + if ((machine->config->video_attributes & VIDEO_UPDATE_SCANLINE) != 0) + timer_adjust_oneshot(m_scanline_timer, time_until_pos(0), 0); + + // create burn-in bitmap + if (options_get_int(mame_options(), OPTION_BURNIN) > 0) { - if (global.snap_bitmap != NULL) - bitmap_free(global.snap_bitmap); - global.snap_bitmap = bitmap_alloc(width, height, BITMAP_FORMAT_RGB32); - assert(global.snap_bitmap != NULL); + int width, height; + if (sscanf(options_get_string(mame_options(), OPTION_SNAPSIZE), "%dx%d", &width, &height) != 2 || width == 0 || height == 0) + width = height = 300; + m_burnin = auto_alloc(machine, bitmap_t(width, height, BITMAP_FORMAT_INDEXED64)); + if (m_burnin == NULL) + fatalerror("Error allocating burn-in bitmap for screen at (%dx%d)\n", width, height); + bitmap_fill(m_burnin, NULL, 0); } - /* render the screen there */ - primlist = render_target_get_primitives(global.snap_target); - osd_lock_acquire(primlist->lock); - rgb888_draw_primitives(primlist->head, global.snap_bitmap->base, width, height, global.snap_bitmap->rowpixels); - osd_lock_release(primlist->lock); + state_save_register_device_item(this, 0, m_width); + state_save_register_device_item(this, 0, m_height); + state_save_register_device_item(this, 0, m_visarea.min_x); + state_save_register_device_item(this, 0, m_visarea.min_y); + state_save_register_device_item(this, 0, m_visarea.max_x); + state_save_register_device_item(this, 0, m_visarea.max_y); + state_save_register_device_item(this, 0, m_last_partial_scan); + state_save_register_device_item(this, 0, m_frame_period); + state_save_register_device_item(this, 0, m_scantime); + state_save_register_device_item(this, 0, m_pixeltime); + state_save_register_device_item(this, 0, m_vblank_period); + state_save_register_device_item(this, 0, m_vblank_start_time.seconds); + state_save_register_device_item(this, 0, m_vblank_start_time.attoseconds); + state_save_register_device_item(this, 0, m_vblank_end_time.seconds); + state_save_register_device_item(this, 0, m_vblank_end_time.attoseconds); + state_save_register_device_item(this, 0, m_frame_number); +} + + +//------------------------------------------------- +// device_post_load - device-specific update +// after a save state is loaded +//------------------------------------------------- + +void screen_device::device_post_load() +{ + realloc_screen_bitmaps(); + global.movie_next_frame_time = timer_get_time(machine); } -/*------------------------------------------------- - mame_fopen_next - open the next non-existing - file of type filetype according to our - numbering scheme --------------------------------------------------*/ +//------------------------------------------------- +// configure - configure screen parameters +//------------------------------------------------- -static file_error mame_fopen_next(running_machine *machine, const char *pathoption, const char *extension, mame_file **file) +void screen_device::configure(int width, int height, const rectangle &visarea, attoseconds_t frame_period) { - const char *snapname = options_get_string(mame_options(), OPTION_SNAPNAME); - file_error filerr; - astring snapstr; - astring fname; - int index; + // validate arguments + assert(width > 0); + assert(height > 0); + assert(visarea.min_x >= 0); + assert(visarea.min_y >= 0); + assert(m_config.m_type == SCREEN_TYPE_VECTOR || visarea.min_x < width); + assert(m_config.m_type == SCREEN_TYPE_VECTOR || visarea.min_y < height); + assert(frame_period > 0); - /* handle defaults */ - if (snapname == NULL || snapname[0] == 0) - snapname = "%g/%i"; - snapstr.cpy(snapname); + // fill in the new parameters + m_width = width; + m_height = height; + m_visarea = visarea; - /* strip any extension in the provided name and add our own */ - index = snapstr.rchr(0, '.'); - if (index != -1) - snapstr.substr(0, index); - snapstr.cat(".").cat(extension); + // reallocate bitmap if necessary + realloc_screen_bitmaps(); - /* substitute path and gamename up front */ - snapstr.replace(0, "/", PATH_SEPARATOR); - snapstr.replace(0, "%g", machine->basename); + // compute timing parameters + m_frame_period = frame_period; + m_scantime = frame_period / height; + m_pixeltime = frame_period / (height * width); - /* determine if the template has an index; if not, we always use the same name */ - if (snapstr.find(0, "%i") == -1) - snapstr.cpy(snapstr); + // if there has been no VBLANK time specified in the MACHINE_DRIVER, compute it now + // from the visible area, otherwise just used the supplied value + if (m_config.m_vblank == 0 && !m_config.m_oldstyle_vblank_supplied) + m_vblank_period = m_scantime * (height - (visarea.max_y + 1 - visarea.min_y)); + else + m_vblank_period = m_config.m_vblank; - /* otherwise, we scan for the next available filename */ + // if we are on scanline 0 already, reset the update timer immediately + // otherwise, defer until the next scanline 0 + if (vpos() == 0) + timer_adjust_oneshot(m_scanline0_timer, attotime_zero, 0); else - { - int seq; + timer_adjust_oneshot(m_scanline0_timer, time_until_pos(0), 0); - /* try until we succeed */ - for (seq = 0; ; seq++) - { - char seqtext[10]; + // start the VBLANK timer + timer_adjust_oneshot(m_vblank_begin_timer, time_until_vblank_start(), 0); - /* make text for the sequence number */ - sprintf(seqtext, "%04d", seq); + // adjust speed if necessary + update_refresh_speed(machine); +} - /* build up the filename */ - fname.cpy(snapstr).replace(0, "%i", seqtext); - /* try to open the file; stop when we fail */ - filerr = mame_fopen(pathoption, fname, OPEN_FLAG_READ, file); - if (filerr != FILERR_NONE) - break; - mame_fclose(*file); - } +//------------------------------------------------- +// realloc_screen_bitmaps - reallocate bitmaps +// and textures as necessary +//------------------------------------------------- + +void screen_device::realloc_screen_bitmaps() +{ + if (m_config.m_type == SCREEN_TYPE_VECTOR) + return; + + int curwidth = 0, curheight = 0; + + // extract the current width/height from the bitmap + if (m_bitmap[0] != NULL) + { + curwidth = m_bitmap[0]->width; + curheight = m_bitmap[0]->height; } - /* create the final file */ - return mame_fopen(pathoption, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, file); + // if we're too small to contain this width/height, reallocate our bitmaps and textures + if (m_width > curwidth || m_height > curheight) + { + // free what we have currently + if (m_texture[0] != NULL) + render_texture_free(m_texture[0]); + if (m_texture[1] != NULL) + render_texture_free(m_texture[1]); + if (m_bitmap[0] != NULL) + auto_free(machine, m_bitmap[0]); + if (m_bitmap[1] != NULL) + auto_free(machine, m_bitmap[1]); + + // compute new width/height + curwidth = MAX(m_width, curwidth); + curheight = MAX(m_height, curheight); + + // choose the texture format - convert the screen format to a texture format + palette_t *palette = NULL; + switch (m_config.m_format) + { + case BITMAP_FORMAT_INDEXED16: m_texture_format = TEXFORMAT_PALETTE16; palette = machine->palette; break; + case BITMAP_FORMAT_RGB15: m_texture_format = TEXFORMAT_RGB15; palette = NULL; break; + case BITMAP_FORMAT_RGB32: m_texture_format = TEXFORMAT_RGB32; palette = NULL; break; + default: fatalerror("Invalid bitmap format!"); break; + } + + // allocate bitmaps + m_bitmap[0] = auto_alloc(machine, bitmap_t(curwidth, curheight, m_config.m_format)); + bitmap_set_palette(m_bitmap[0], machine->palette); + m_bitmap[1] = auto_alloc(machine, bitmap_t(curwidth, curheight, m_config.m_format)); + bitmap_set_palette(m_bitmap[1], machine->palette); + + // allocate textures + m_texture[0] = render_texture_alloc(NULL, NULL); + render_texture_set_bitmap(m_texture[0], m_bitmap[0], &m_visarea, m_texture_format, palette); + m_texture[1] = render_texture_alloc(NULL, NULL); + render_texture_set_bitmap(m_texture[1], m_bitmap[1], &m_visarea, m_texture_format, palette); + } } +//------------------------------------------------- +// set_visible_area - just set the visible area +//------------------------------------------------- -/*************************************************************************** - MNG MOVIE RECORDING -***************************************************************************/ +void screen_device::set_visible_area(int min_x, int max_x, int min_y, int max_y) +{ + // validate arguments + assert(min_x >= 0); + assert(min_y >= 0); + assert(min_x < max_x); + assert(min_y < max_y); -/*------------------------------------------------- - video_mng_is_movie_active - return true if a - MNG movie is currently being recorded --------------------------------------------------*/ + rectangle visarea; + visarea.min_x = min_x; + visarea.max_x = max_x; + visarea.min_y = min_y; + visarea.max_y = max_y; -int video_mng_is_movie_active(running_machine *machine) -{ - return (global.mngfile != NULL); + configure(m_width, m_height, visarea, m_frame_period); } -/*------------------------------------------------- - video_mng_begin_recording - begin recording - of a MNG movie --------------------------------------------------*/ +//------------------------------------------------- +// update_partial - perform a partial update from +// the last scanline up to and including the +// specified scanline +//-----------------------------------------------*/ -void video_mng_begin_recording(running_machine *machine, const char *name) +bool screen_device::update_partial(int scanline) { - screen_state *state = NULL; - file_error filerr; - png_error pngerr; - int rate; - - /* close any existing movie file */ - if (global.mngfile != NULL) - video_mng_end_recording(machine); + // validate arguments + assert(scanline >= 0); - /* look up the primary screen */ - if (machine->primary_screen != NULL) - state = get_safe_token(machine->primary_screen); + LOG_PARTIAL_UPDATES(("Partial: update_partial(%s, %d): ", tag(), scanline)); - /* create a snapshot bitmap so we know what the target size is */ - create_snapshot_bitmap(NULL); + // these two checks only apply if we're allowed to skip frames + if (!(machine->config->video_attributes & VIDEO_ALWAYS_UPDATE)) + { + // if skipping this frame, bail + if (global.skipping_this_frame) + { + LOG_PARTIAL_UPDATES(("skipped due to frameskipping\n")); + return FALSE; + } - /* create a new movie file and start recording */ - if (name != NULL) - filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &global.mngfile); - else - filerr = mame_fopen_next(machine, SEARCHPATH_MOVIE, "mng", &global.mngfile); + // skip if this screen is not visible anywhere + if (!render_is_live_screen(this)) + { + LOG_PARTIAL_UPDATES(("skipped because screen not live\n")); + return FALSE; + } + } - /* start the capture */ - rate = (state != NULL) ? ATTOSECONDS_TO_HZ(state->frame_period) : DEFAULT_FRAME_RATE; - pngerr = mng_capture_start(mame_core_file(global.mngfile), global.snap_bitmap, rate); - if (pngerr != PNGERR_NONE) + // skip if less than the lowest so far + if (scanline < m_last_partial_scan) { - video_mng_end_recording(machine); - return; + LOG_PARTIAL_UPDATES(("skipped because less than previous\n")); + return FALSE; } - /* compute the frame time */ - global.movie_next_frame_time = timer_get_time(machine); - global.movie_frame_period = ATTOTIME_IN_HZ(rate); - global.movie_frame = 0; -} + // set the start/end scanlines + rectangle clip = m_visarea; + if (m_last_partial_scan > clip.min_y) + clip.min_y = m_last_partial_scan; + if (scanline < clip.max_y) + clip.max_y = scanline; + // render if necessary + bool result = false; + if (clip.min_y <= clip.max_y) + { + UINT32 flags = UPDATE_HAS_NOT_CHANGED; -/*------------------------------------------------- - video_mng_end_recording - stop recording of - a MNG movie --------------------------------------------------*/ + profiler_mark_start(PROFILER_VIDEO); + LOG_PARTIAL_UPDATES(("updating %d-%d\n", clip.min_y, clip.max_y)); -void video_mng_end_recording(running_machine *machine) -{ - /* close the file if it exists */ - if (global.mngfile != NULL) - { - mng_capture_stop(mame_core_file(global.mngfile)); - mame_fclose(global.mngfile); - global.mngfile = NULL; - global.movie_frame = 0; + if (machine->config->video_update != NULL) + flags = (*machine->config->video_update)(this, m_bitmap[m_curbitmap], &clip); + global.partial_updates_this_frame++; + profiler_mark_end(); + + // if we modified the bitmap, we have to commit + m_changed |= ~flags & UPDATE_HAS_NOT_CHANGED; + result = true; } + + // remember where we left off + m_last_partial_scan = scanline + 1; + return result; } -/*------------------------------------------------- - video_mng_record_frame - record a frame of a - movie --------------------------------------------------*/ +//------------------------------------------------- +// update_now - perform an update from the last +// beam position up to the current beam position +//------------------------------------------------- -static void video_mng_record_frame(running_machine *machine) +void screen_device::update_now() { - /* only record if we have a file */ - if (global.mngfile != NULL) - { - attotime curtime = timer_get_time(machine); - png_info pnginfo = { 0 }; - png_error error; + int current_vpos = vpos(); + int current_hpos = hpos(); - profiler_mark_start(PROFILER_MOVIE_REC); + // since we can currently update only at the scanline + // level, we are trying to do the right thing by + // updating including the current scanline, only if the + // beam is past the halfway point horizontally. + // If the beam is in the first half of the scanline, + // we only update up to the previous scanline. + // This minimizes the number of pixels that might be drawn + // incorrectly until we support a pixel level granularity + if (current_hpos < (m_width / 2) && current_vpos > 0) + current_vpos = current_vpos - 1; - /* create the bitmap */ - create_snapshot_bitmap(NULL); + update_partial(current_vpos); +} - /* loop until we hit the right time */ - while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) - { - const rgb_t *palette; - /* set up the text fields in the movie info */ - if (global.movie_frame == 0) - { - char text[256]; +//------------------------------------------------- +// vpos - returns the current vertical position +// of the beam +//------------------------------------------------- - sprintf(text, APPNAME " %s", build_version); - png_add_text(&pnginfo, "Software", text); - sprintf(text, "%s %s", machine->gamedrv->manufacturer, machine->gamedrv->description); - png_add_text(&pnginfo, "System", text); - } +int screen_device::vpos() const +{ + attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + int vpos; - /* write the next frame */ - palette = (machine->palette != NULL) ? palette_entry_list_adjusted(machine->palette) : NULL; - error = mng_capture_frame(mame_core_file(global.mngfile), &pnginfo, global.snap_bitmap, machine->config->total_colors, palette); - png_free(&pnginfo); - if (error != PNGERR_NONE) - { - video_mng_end_recording(machine); - break; - } + // round to the nearest pixel + delta += m_pixeltime / 2; - /* advance time */ - global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); - global.movie_frame++; - } + // compute the v position relative to the start of VBLANK + vpos = delta / m_scantime; - profiler_mark_end(); - } + // adjust for the fact that VBLANK starts at the bottom of the visible area + return (m_visarea.max_y + 1 + vpos) % m_height; } +//------------------------------------------------- +// hpos - returns the current horizontal position +// of the beam +//------------------------------------------------- -/*************************************************************************** - AVI MOVIE RECORDING -***************************************************************************/ +int screen_device::hpos() const +{ + attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); -/*------------------------------------------------- - video_avi_begin_recording - begin recording - of an AVI movie --------------------------------------------------*/ + // round to the nearest pixel + delta += m_pixeltime / 2; + + // compute the v position relative to the start of VBLANK + int vpos = delta / m_scantime; -void video_avi_begin_recording(running_machine *machine, const char *name) -{ - screen_state *state = NULL; - avi_movie_info info; - mame_file *tempfile; - file_error filerr; - avi_error avierr; + // subtract that from the total time + delta -= vpos * m_scantime; - /* close any existing movie file */ - if (global.avifile != NULL) - video_avi_end_recording(machine); + // return the pixel offset from the start of this scanline + return delta / m_pixeltime; +} - /* look up the primary screen */ - if (machine->primary_screen != NULL) - state = get_safe_token(machine->primary_screen); - /* create a snapshot bitmap so we know what the target size is */ - create_snapshot_bitmap(NULL); +//------------------------------------------------- +// time_until_pos - returns the amount of time +// remaining until the beam is at the given +// hpos,vpos +//------------------------------------------------- - /* build up information about this new movie */ - info.video_format = 0; - info.video_timescale = 1000 * ((state != NULL) ? ATTOSECONDS_TO_HZ(state->frame_period) : DEFAULT_FRAME_RATE); - info.video_sampletime = 1000; - info.video_numsamples = 0; - info.video_width = global.snap_bitmap->width; - info.video_height = global.snap_bitmap->height; - info.video_depth = 24; +attotime screen_device::time_until_pos(int vpos, int hpos) const +{ + // validate arguments + assert(vpos >= 0); + assert(hpos >= 0); - info.audio_format = 0; - info.audio_timescale = machine->sample_rate; - info.audio_sampletime = 1; - info.audio_numsamples = 0; - info.audio_channels = 2; - info.audio_samplebits = 16; - info.audio_samplerate = machine->sample_rate; + // since we measure time relative to VBLANK, compute the scanline offset from VBLANK + vpos += m_height - (m_visarea.max_y + 1); + vpos %= m_height; - /* create a new temporary movie file */ - if (name != NULL) - filerr = mame_fopen(SEARCHPATH_MOVIE, name, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &tempfile); - else - filerr = mame_fopen_next(machine, SEARCHPATH_MOVIE, "avi", &tempfile); + // compute the delta for the given X,Y position + attoseconds_t targetdelta = (attoseconds_t)vpos * m_scantime + (attoseconds_t)hpos * m_pixeltime; - /* reset our tracking */ - global.movie_frame = 0; - global.movie_next_frame_time = timer_get_time(machine); - global.movie_frame_period = attotime_div(ATTOTIME_IN_SEC(1000), info.video_timescale); + // if we're past that time (within 1/2 of a pixel), head to the next frame + attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(machine), m_vblank_start_time)); + if (targetdelta <= curdelta + m_pixeltime / 2) + targetdelta += m_frame_period; + while (targetdelta <= curdelta) + targetdelta += m_frame_period; - /* if we succeeded, make a copy of the name and create the real file over top */ - if (filerr == FILERR_NONE) - { - astring fullname(mame_file_full_name(tempfile)); - mame_fclose(tempfile); + // return the difference + return attotime_make(0, targetdelta - curdelta); +} - /* create the file and free the string */ - avierr = avi_create(fullname, &info, &global.avifile); - } + +//------------------------------------------------- +// time_until_vblank_end - returns the amount of +// time remaining until the end of the current +// VBLANK (if in progress) or the end of the next +// VBLANK +//------------------------------------------------- + +attotime screen_device::time_until_vblank_end() const +{ + // if we are in the VBLANK region, compute the time until the end of the current VBLANK period + attotime target_time = m_vblank_end_time; + if (!vblank()) + target_time = attotime_add_attoseconds(target_time, m_frame_period); + return attotime_sub(target_time, timer_get_time(machine)); } -/*------------------------------------------------- - video_avi_end_recording - stop recording of - a avi movie --------------------------------------------------*/ +//------------------------------------------------- +// register_vblank_callback - registers a VBLANK +// callback +//------------------------------------------------- -void video_avi_end_recording(running_machine *machine) +void screen_device::register_vblank_callback(vblank_state_changed_func vblank_callback, void *param) { - /* close the file if it exists */ - if (global.avifile != NULL) + // validate arguments + assert(vblank_callback != NULL); + + // check if we already have this callback registered + callback_item **itemptr; + for (itemptr = &m_callback_list; *itemptr != NULL; itemptr = &(*itemptr)->m_next) + if ((*itemptr)->m_callback == vblank_callback) + break; + + // if not found, register + if (*itemptr == NULL) { - avi_close(global.avifile); - global.avifile = NULL; - global.movie_frame = 0; + *itemptr = auto_alloc(machine, callback_item); + (*itemptr)->m_next = NULL; + (*itemptr)->m_callback = vblank_callback; + (*itemptr)->m_param = param; } } -/*------------------------------------------------- - video_avi_record_frame - record a frame of a - movie --------------------------------------------------*/ +//------------------------------------------------- +// vblank_begin_callback - call any external +// callbacks to signal the VBLANK period has begun +//------------------------------------------------- -static void video_avi_record_frame(running_machine *machine) +void screen_device::vblank_begin_callback() { - /* only record if we have a file */ - if (global.avifile != NULL) - { - attotime curtime = timer_get_time(machine); - avi_error avierr; - - profiler_mark_start(PROFILER_MOVIE_REC); + // reset the starting VBLANK time + m_vblank_start_time = timer_get_time(machine); + m_vblank_end_time = attotime_add_attoseconds(m_vblank_start_time, m_vblank_period); - /* create the bitmap */ - create_snapshot_bitmap(NULL); + // call the screen specific callbacks + for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) + (*item->m_callback)(*this, item->m_param, true); - /* loop until we hit the right time */ - while (attotime_compare(global.movie_next_frame_time, curtime) <= 0) - { - /* write the next frame */ - avierr = avi_append_video_frame_rgb32(global.avifile, global.snap_bitmap); - if (avierr != AVIERR_NONE) - { - video_avi_end_recording(machine); - break; - } + // if this is the primary screen and we need to update now + if (this == machine->primary_screen && !(machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) + video_frame_update(machine, FALSE); - /* advance time */ - global.movie_next_frame_time = attotime_add(global.movie_next_frame_time, global.movie_frame_period); - global.movie_frame++; - } + // reset the VBLANK start timer for the next frame + timer_adjust_oneshot(m_vblank_begin_timer, time_until_vblank_start(), 0); - profiler_mark_end(); - } + // if no VBLANK period, call the VBLANK end callback immedietely, otherwise reset the timer + if (m_vblank_period == 0) + vblank_end_callback(); + else + timer_adjust_oneshot(m_vblank_end_timer, time_until_vblank_end(), 0); } -/*------------------------------------------------- - video_avi_add_sound - add sound to an AVI - recording --------------------------------------------------*/ +//------------------------------------------------- +// vblank_end_callback - call any external +// callbacks to signal the VBLANK period has ended +//------------------------------------------------- -void video_avi_add_sound(running_machine *machine, const INT16 *sound, int numsamples) +void screen_device::vblank_end_callback() { - /* only record if we have a file */ - if (global.avifile != NULL) - { - avi_error avierr; - - profiler_mark_start(PROFILER_MOVIE_REC); + // call the screen specific callbacks + for (callback_item *item = m_callback_list; item != NULL; item = item->m_next) + (*item->m_callback)(*this, item->m_param, false); - /* write the next frame */ - avierr = avi_append_sound_samples(global.avifile, 0, sound + 0, numsamples, 1); - if (avierr == AVIERR_NONE) - avierr = avi_append_sound_samples(global.avifile, 1, sound + 1, numsamples, 1); - if (avierr != AVIERR_NONE) - video_avi_end_recording(machine); + // if this is the primary screen and we need to update now + if (this == machine->primary_screen && (machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)) + video_frame_update(machine, FALSE); - profiler_mark_end(); - } + // increment the frame number counter + m_frame_number++; } +//------------------------------------------------- +// scanline0_callback - reset partial updates +// for a screen +//------------------------------------------------- -/*************************************************************************** - BURN-IN GENERATION -***************************************************************************/ +void screen_device::scanline0_callback() +{ + // reset partial updates + m_last_partial_scan = 0; + global.partial_updates_this_frame = 0; -/*------------------------------------------------- - video_update_burnin - update the burnin bitmap - for all screens --------------------------------------------------*/ + timer_adjust_oneshot(m_scanline0_timer, time_until_pos(0), 0); +} -#undef rand -static void video_update_burnin(running_machine *machine) + +//------------------------------------------------- +// scanline_update_callback - perform partial +// updates on each scanline +//------------------------------------------------- + +void screen_device::scanline_update_callback(int scanline) { - running_device *screen; + // force a partial update to the current scanline + update_partial(scanline); - /* iterate over screens and update the burnin for the ones that care */ - for (screen = video_screen_first(machine); screen != NULL; screen = video_screen_next(screen)) - { - screen_state *state = get_safe_token(screen); - if (state->burnin != NULL) - { - bitmap_t *srcbitmap = state->bitmap[state->curtexture]; - int srcwidth = srcbitmap->width; - int srcheight = srcbitmap->height; - int dstwidth = state->burnin->width; - int dstheight = state->burnin->height; - int xstep = (srcwidth << 16) / dstwidth; - int ystep = (srcheight << 16) / dstheight; - int xstart = ((UINT32)rand() % 32767) * xstep / 32767; - int ystart = ((UINT32)rand() % 32767) * ystep / 32767; - int srcx, srcy; - int x, y; - - /* iterate over rows in the destination */ - for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep) - { - UINT64 *dst = BITMAP_ADDR64(state->burnin, y, 0); + // compute the next visible scanline + scanline++; + if (scanline > m_visarea.max_y) + scanline = m_visarea.min_y; + timer_adjust_oneshot(m_scanline_timer, time_until_pos(scanline), scanline); +} - /* handle the 16-bit palettized case */ - if (srcbitmap->format == BITMAP_FORMAT_INDEXED16) - { - const UINT16 *src = BITMAP_ADDR16(srcbitmap, srcy >> 16, 0); - const rgb_t *palette = palette_entry_list_adjusted(machine->palette); - for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) - { - rgb_t pixel = palette[src[srcx >> 16]]; - dst[x] += RGB_GREEN(pixel) + RGB_RED(pixel) + RGB_BLUE(pixel); - } - } - /* handle the 15-bit RGB case */ - else if (srcbitmap->format == BITMAP_FORMAT_RGB15) - { - const UINT16 *src = BITMAP_ADDR16(srcbitmap, srcy >> 16, 0); - for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) - { - rgb15_t pixel = src[srcx >> 16]; - dst[x] += ((pixel >> 10) & 0x1f) + ((pixel >> 5) & 0x1f) + ((pixel >> 0) & 0x1f); - } - } +//------------------------------------------------- +// update_quads - set up the quads for this +// screen +//------------------------------------------------- - /* handle the 32-bit RGB case */ - else if (srcbitmap->format == BITMAP_FORMAT_RGB32) - { - const UINT32 *src = BITMAP_ADDR32(srcbitmap, srcy >> 16, 0); - for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) - { - rgb_t pixel = src[srcx >> 16]; - dst[x] += RGB_GREEN(pixel) + RGB_RED(pixel) + RGB_BLUE(pixel); - } - } +bool screen_device::update_quads() +{ + // only update if live + if (render_is_live_screen(this)) + { + // only update if empty and not a vector game; otherwise assume the driver did it directly + if (m_config.m_type != SCREEN_TYPE_VECTOR && (machine->config->video_attributes & VIDEO_SELF_RENDER) == 0) + { + // if we're not skipping the frame and if the screen actually changed, then update the texture + if (!global.skipping_this_frame && m_changed) + { + rectangle fixedvis = m_visarea; + fixedvis.max_x++; + fixedvis.max_y++; + + palette_t *palette = (m_texture_format == TEXFORMAT_PALETTE16) ? machine->palette : NULL; + render_texture_set_bitmap(m_texture[m_curbitmap], m_bitmap[m_curbitmap], &fixedvis, m_texture_format, palette); + + m_curtexture = m_curbitmap; + m_curbitmap = 1 - m_curbitmap; } + + // create an empty container with a single quad + render_container_empty(render_container_get_screen(this)); + render_screen_add_quad(this, 0.0f, 0.0f, 1.0f, 1.0f, MAKE_ARGB(0xff,0xff,0xff,0xff), m_texture[m_curtexture], PRIMFLAG_BLENDMODE(BLENDMODE_NONE) | PRIMFLAG_SCREENTEX(1)); } } + + // reset the screen changed flags + bool result = m_changed; + m_changed = false; + return result; } -/*------------------------------------------------- - video_finalize_burnin - finalize the burnin - bitmaps for all screens --------------------------------------------------*/ +//------------------------------------------------- +// update_burnin - update the burnin bitmap +//------------------------------------------------- -static void video_finalize_burnin(running_device *screen) +void screen_device::update_burnin() { - screen_state *state = get_safe_token(screen); - if (state->burnin != NULL) +#undef rand + if (m_burnin == NULL) + return; + + bitmap_t *srcbitmap = m_bitmap[m_curtexture]; + int srcwidth = srcbitmap->width; + int srcheight = srcbitmap->height; + int dstwidth = m_burnin->width; + int dstheight = m_burnin->height; + int xstep = (srcwidth << 16) / dstwidth; + int ystep = (srcheight << 16) / dstheight; + int xstart = ((UINT32)rand() % 32767) * xstep / 32767; + int ystart = ((UINT32)rand() % 32767) * ystep / 32767; + int srcx, srcy; + int x, y; + + // iterate over rows in the destination + for (y = 0, srcy = ystart; y < dstheight; y++, srcy += ystep) { - astring fname; - rectangle scaledvis; - bitmap_t *finalmap; - UINT64 minval = ~(UINT64)0; - UINT64 maxval = 0; - file_error filerr; - mame_file *file; - int x, y; - - /* compute the scaled visible region */ - scaledvis.min_x = state->visarea.min_x * state->burnin->width / state->width; - scaledvis.max_x = state->visarea.max_x * state->burnin->width / state->width; - scaledvis.min_y = state->visarea.min_y * state->burnin->height / state->height; - scaledvis.max_y = state->visarea.max_y * state->burnin->height / state->height; - - /* wrap a bitmap around the subregion we care about */ - finalmap = bitmap_alloc(scaledvis.max_x + 1 - scaledvis.min_x, - scaledvis.max_y + 1 - scaledvis.min_y, - BITMAP_FORMAT_ARGB32); - - /* find the maximum value */ - for (y = 0; y < finalmap->height; y++) + UINT64 *dst = BITMAP_ADDR64(m_burnin, y, 0); + + // handle the 16-bit palettized case + if (srcbitmap->format == BITMAP_FORMAT_INDEXED16) { - UINT64 *src = BITMAP_ADDR64(state->burnin, y, 0); - for (x = 0; x < finalmap->width; x++) + const UINT16 *src = BITMAP_ADDR16(srcbitmap, srcy >> 16, 0); + const rgb_t *palette = palette_entry_list_adjusted(machine->palette); + for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) { - minval = MIN(minval, src[x]); - maxval = MAX(maxval, src[x]); + rgb_t pixel = palette[src[srcx >> 16]]; + dst[x] += RGB_GREEN(pixel) + RGB_RED(pixel) + RGB_BLUE(pixel); } } - /* now normalize and convert to RGB */ - for (y = 0; y < finalmap->height; y++) + // handle the 15-bit RGB case + else if (srcbitmap->format == BITMAP_FORMAT_RGB15) { - UINT64 *src = BITMAP_ADDR64(state->burnin, y, 0); - UINT32 *dst = BITMAP_ADDR32(finalmap, y, 0); - for (x = 0; x < finalmap->width; x++) + const UINT16 *src = BITMAP_ADDR16(srcbitmap, srcy >> 16, 0); + for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) { - int brightness = (UINT64)(maxval - src[x]) * 255 / (maxval - minval); - dst[x] = MAKE_ARGB(0xff, brightness, brightness, brightness); + rgb15_t pixel = src[srcx >> 16]; + dst[x] += ((pixel >> 10) & 0x1f) + ((pixel >> 5) & 0x1f) + ((pixel >> 0) & 0x1f); } } - /* write the final PNG */ - - /* compute the name and create the file */ - fname.printf("%s" PATH_SEPARATOR "burnin-%s.png", screen->machine->basename, screen->tag()); - filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); - if (filerr == FILERR_NONE) + // handle the 32-bit RGB case + else if (srcbitmap->format == BITMAP_FORMAT_RGB32) { - png_info pnginfo = { 0 }; - png_error pngerr; - char text[256]; - - /* add two text entries describing the image */ - sprintf(text, APPNAME " %s", build_version); - png_add_text(&pnginfo, "Software", text); - sprintf(text, "%s %s", screen->machine->gamedrv->manufacturer, screen->machine->gamedrv->description); - png_add_text(&pnginfo, "System", text); - - /* now do the actual work */ - pngerr = png_write_bitmap(mame_core_file(file), &pnginfo, finalmap, 0, NULL); - - /* free any data allocated */ - png_free(&pnginfo); - mame_fclose(file); + const UINT32 *src = BITMAP_ADDR32(srcbitmap, srcy >> 16, 0); + for (x = 0, srcx = xstart; x < dstwidth; x++, srcx += xstep) + { + rgb_t pixel = src[srcx >> 16]; + dst[x] += RGB_GREEN(pixel) + RGB_RED(pixel) + RGB_BLUE(pixel); + } } - bitmap_free(finalmap); } } +//------------------------------------------------- +// video_finalize_burnin - finalize the burnin +// bitmap +//------------------------------------------------- -/*************************************************************************** - CONFIGURATION HELPERS -***************************************************************************/ - -/*------------------------------------------------- - video_get_view_for_target - select a view - for a given target --------------------------------------------------*/ - -int video_get_view_for_target(running_machine *machine, render_target *target, const char *viewname, int targetindex, int numtargets) +void screen_device::finalize_burnin() { - int viewindex = -1; + if (m_burnin == NULL) + return; - /* auto view just selects the nth view */ - if (strcmp(viewname, "auto") != 0) + // compute the scaled visible region + rectangle scaledvis; + scaledvis.min_x = m_visarea.min_x * m_burnin->width / m_width; + scaledvis.max_x = m_visarea.max_x * m_burnin->width / m_width; + scaledvis.min_y = m_visarea.min_y * m_burnin->height / m_height; + scaledvis.max_y = m_visarea.max_y * m_burnin->height / m_height; + + // wrap a bitmap around the subregion we care about + bitmap_t *finalmap = auto_alloc(machine, bitmap_t(scaledvis.max_x + 1 - scaledvis.min_x, + scaledvis.max_y + 1 - scaledvis.min_y, + BITMAP_FORMAT_ARGB32)); + + // find the maximum value + UINT64 minval = ~(UINT64)0; + UINT64 maxval = 0; + for (int y = 0; y < finalmap->height; y++) { - /* scan for a matching view name */ - for (viewindex = 0; ; viewindex++) + UINT64 *src = BITMAP_ADDR64(m_burnin, y, 0); + for (int x = 0; x < finalmap->width; x++) { - const char *name = render_target_get_view_name(target, viewindex); - - /* stop scanning when we hit NULL */ - if (name == NULL) - { - viewindex = -1; - break; - } - if (mame_strnicmp(name, viewname, strlen(viewname)) == 0) - break; + minval = MIN(minval, src[x]); + maxval = MAX(maxval, src[x]); } } - /* if we don't have a match, default to the nth view */ - if (viewindex == -1) + // now normalize and convert to RGB + for (int y = 0; y < finalmap->height; y++) { - int scrcount = video_screen_count(machine->config); - - /* if we have enough targets to be one per screen, assign in order */ - if (numtargets >= scrcount) - { - /* find the first view with this screen and this screen only */ - for (viewindex = 0; ; viewindex++) - { - UINT32 viewscreens = render_target_get_view_screens(target, viewindex); - if (viewscreens == (1 << targetindex)) - break; - if (viewscreens == 0) - { - viewindex = -1; - break; - } - } - } - - /* otherwise, find the first view that has all the screens */ - if (viewindex == -1) + UINT64 *src = BITMAP_ADDR64(m_burnin, y, 0); + UINT32 *dst = BITMAP_ADDR32(finalmap, y, 0); + for (int x = 0; x < finalmap->width; x++) { - for (viewindex = 0; ; viewindex++) - { - UINT32 viewscreens = render_target_get_view_screens(target, viewindex); - if (viewscreens == (1 << scrcount) - 1) - break; - if (viewscreens == 0) - break; - } + int brightness = (UINT64)(maxval - src[x]) * 255 / (maxval - minval); + dst[x] = MAKE_ARGB(0xff, brightness, brightness, brightness); } } - /* make sure it's a valid view */ - if (render_target_get_view_name(target, viewindex) == NULL) - viewindex = 0; - - return viewindex; -} - - - -/*************************************************************************** - DEBUGGING HELPERS -***************************************************************************/ + // write the final PNG -/*------------------------------------------------- - video_assert_out_of_range_pixels - assert if - any pixels in the given bitmap contain an - invalid palette index --------------------------------------------------*/ + // compute the name and create the file + astring fname; + fname.printf("%s" PATH_SEPARATOR "burnin-%s.png", machine->basename, tag()); + mame_file *file; + file_error filerr = mame_fopen(SEARCHPATH_SCREENSHOT, fname, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); + if (filerr == FILERR_NONE) + { + png_info pnginfo = { 0 }; + png_error pngerr; + char text[256]; -void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap) -{ -#ifdef MAME_DEBUG - int maxindex = palette_get_max_index(machine->palette); - int x, y; + // add two text entries describing the image + sprintf(text, APPNAME " %s", build_version); + png_add_text(&pnginfo, "Software", text); + sprintf(text, "%s %s", machine->gamedrv->manufacturer, machine->gamedrv->description); + png_add_text(&pnginfo, "System", text); - /* this only applies to indexed16 bitmaps */ - if (bitmap->format != BITMAP_FORMAT_INDEXED16) - return; + // now do the actual work + pngerr = png_write_bitmap(mame_core_file(file), &pnginfo, finalmap, 0, NULL); - /* iterate over rows */ - for (y = 0; y < bitmap->height; y++) - { - UINT16 *rowbase = BITMAP_ADDR16(bitmap, y, 0); - for (x = 0; x < bitmap->width; x++) - assert(rowbase[x] < maxindex); + // free any data allocated + png_free(&pnginfo); + mame_fclose(file); } -#endif } -/*************************************************************************** - SOFTWARE RENDERING -***************************************************************************/ +//************************************************************************** +// SOFTWARE RENDERING +//************************************************************************** #define FUNC_PREFIX(x) rgb888_##x #define PIXEL_TYPE UINT32 diff --git a/src/emu/video.h b/src/emu/video.h index 774cb9f16c1..ef66e2a0309 100644 --- a/src/emu/video.h +++ b/src/emu/video.h @@ -4,8 +4,36 @@ Core MAME video routines. - Copyright Nicola Salmoria and the MAME Team. - Visit http://mamedev.org for licensing and usage restrictions. +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ @@ -19,16 +47,16 @@ #define __VIDEO_H__ -/*************************************************************************** - CONSTANTS -***************************************************************************/ +//************************************************************************** +// CONSTANTS +//************************************************************************** -/* number of levels of frameskipping supported */ -#define FRAMESKIP_LEVELS 12 -#define MAX_FRAMESKIP (FRAMESKIP_LEVELS - 2) +// number of levels of frameskipping supported +const int FRAMESKIP_LEVELS = 12; +const int MAX_FRAMESKIP = FRAMESKIP_LEVELS - 2; -/* screen types */ -enum +// screen types +enum screen_type_enum { SCREEN_TYPE_INVALID = 0, SCREEN_TYPE_RASTER, @@ -38,117 +66,271 @@ enum -/*************************************************************************** - MACROS -***************************************************************************/ - -/* these functions are macros primarily due to include file ordering */ -/* plus, they are very simple */ -#define video_screen_count(config) (config)->devicelist.count(VIDEO_SCREEN) -#define video_screen_first(config) (config)->devicelist.first(VIDEO_SCREEN) -#define video_screen_next(previous) (previous)->typenext() +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** -#define video_screen_get_format(screen) (((screen_config *)(screen)->baseconfig().inline_config)->format) +// forward references +class render_target; +struct render_texture; +class screen_device; -/* allocates a bitmap that has the same dimensions and format as the passed in screen */ -#define video_screen_auto_bitmap_alloc(screen) auto_bitmap_alloc(screen->machine, video_screen_get_width(screen), video_screen_get_height(screen), video_screen_get_format(screen)) +// callback that is called to notify of a change in the VBLANK state +typedef void (*vblank_state_changed_func)(screen_device &device, void *param, bool vblank_state); +// ======================> screen_device_config -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ +class screen_device_config : public device_config +{ + friend class screen_device; + + // construction/destruction + screen_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + +public: + // allocators + static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock); + virtual device_t *alloc_device(running_machine &machine) const; + + // basic information getters + virtual const char *name() const { return "Video Screen"; } + + // configuration readers + screen_type_enum screen_type() const { return m_type; } + int width() const { return m_width; } + int height() const { return m_height; } + const rectangle &visible_area() const { return m_visarea; } + bool oldstyle_vblank_supplied() const { return m_oldstyle_vblank_supplied; } + attoseconds_t refresh() const { return m_refresh; } + attoseconds_t vblank() const { return m_vblank; } + bitmap_format format() const { return m_format; } + float xoffset() const { return m_xoffset; } + float yoffset() const { return m_yoffset; } + float xscale() const { return m_xscale; } + float yscale() const { return m_yscale; } + + // indexes to inline data + enum + { + INLINE_TYPE, + INLINE_FORMAT, + INLINE_REFRESH, + INLINE_VBLANK, + INLINE_WIDTH, + INLINE_HEIGHT, + INLINE_VIS_MINX, + INLINE_VIS_MAXX, + INLINE_VIS_MINY, + INLINE_VIS_MAXY, + INLINE_XOFFSET, + INLINE_XSCALE, + INLINE_YOFFSET, + INLINE_YSCALE, + INLINE_OLDVBLANK + }; + +private: + // device_config overrides + virtual void device_config_complete(); + virtual bool device_validity_check(const game_driver &driver) const; + + // configuration data + screen_type_enum m_type; // type of screen + int m_width, m_height; // default total width/height (HTOTAL, VTOTAL) + rectangle m_visarea; // default visible area (HBLANK end/start, VBLANK end/start) + bool m_oldstyle_vblank_supplied; // MDRV_SCREEN_VBLANK_TIME macro used + attoseconds_t m_refresh; // default refresh period + attoseconds_t m_vblank; // duration of a VBLANK + bitmap_format m_format; // bitmap format + float m_xoffset, m_yoffset; // default X/Y offsets + float m_xscale, m_yscale; // default X/Y scale factor +}; -// forward references -class render_target; -/*------------------------------------------------- - screen_config - configuration of a single - screen --------------------------------------------------*/ +// ======================> screen_device -typedef struct _screen_config screen_config; -struct _screen_config +class screen_device : public device_t { - int type; /* type of screen */ - int width, height; /* default total width/height (HTOTAL, VTOTAL) */ - rectangle visarea; /* default visible area (HBLANK end/start, VBLANK end/start) */ - UINT8 oldstyle_vblank_supplied; /* MDRV_SCREEN_VBLANK_TIME macro used */ - attoseconds_t refresh; /* default refresh period */ - attoseconds_t vblank; /* duration of a VBLANK */ - bitmap_format format; /* bitmap format */ - float xoffset, yoffset; /* default X/Y offsets */ - float xscale, yscale; /* default X/Y scale factor */ + friend class screen_device_config; + friend resource_pool_object::~resource_pool_object(); + + // construction/destruction + screen_device(running_machine &_machine, const screen_device_config &config); + virtual ~screen_device(); + +public: + // information getters + const screen_device_config &config() const { return m_config; } + screen_type_enum screen_type() const { return m_config.m_type; } + int width() const { return m_width; } + int height() const { return m_height; } + const rectangle &visible_area() const { return m_visarea; } + bitmap_format format() const { return m_config.m_format; } + + // dynamic configuration + void configure(int width, int height, const rectangle &visarea, attoseconds_t frame_period); + void set_visible_area(int min_x, int max_x, int min_y, int max_y); + + // beam positioning and state + int vpos() const; + int hpos() const; + bool vblank() const { return attotime_compare(timer_get_time(machine), m_vblank_end_time) < 0; } + bool hblank() const { int curpos = hpos(); return (curpos < m_visarea.min_x || curpos > m_visarea.max_x); } + + // timing + attotime time_until_pos(int vpos, int hpos = 0) const; + attotime time_until_vblank_start() const { return time_until_pos(m_visarea.max_y + 1); } + attotime time_until_vblank_end() const; + attotime time_until_update() const { return (machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK) ? time_until_vblank_end() : time_until_vblank_start(); } + attotime scan_period() const { return attotime_make(0, m_scantime); } + attotime frame_period() const { return (this == NULL || !started()) ? k_default_frame_period : attotime_make(0, m_frame_period); }; + UINT64 frame_number() const { return m_frame_number; } + + // updating + bool update_partial(int scanline); + void update_now(); + + // additional helpers + void save_snapshot(mame_file *fp); + void register_vblank_callback(vblank_state_changed_func vblank_callback, void *param); + bitmap_t *alloc_compatible_bitmap(int width = 0, int height = 0) { return auto_bitmap_alloc(machine, (width == 0) ? m_width : width, (height == 0) ? m_height : height, m_config.m_format); } + + // internal to the video system + bool update_quads(); + void update_burnin(); + + // globally accessible constants + static const int k_default_frame_rate = 60; + static const attotime k_default_frame_period; + +private: + // device-level overrides + virtual void device_start(); + virtual void device_post_load(); + + // internal helpers + void realloc_screen_bitmaps(); + + static TIMER_CALLBACK( static_vblank_begin_callback ) { reinterpret_cast(ptr)->vblank_begin_callback(); } + void vblank_begin_callback(); + + static TIMER_CALLBACK( static_vblank_end_callback ) { reinterpret_cast(ptr)->vblank_end_callback(); } + void vblank_end_callback(); + + static TIMER_CALLBACK( static_scanline0_callback ) { reinterpret_cast(ptr)->scanline0_callback(); } +public: // temporary + void scanline0_callback(); +private: + + static TIMER_CALLBACK( static_scanline_update_callback ) { reinterpret_cast(ptr)->scanline_update_callback(param); } + void scanline_update_callback(int scanline); + + void finalize_burnin(); + + // internal state + const screen_device_config &m_config; + + // dimensions + int m_width; // current width (HTOTAL) + int m_height; // current height (VTOTAL) + rectangle m_visarea; // current visible area (HBLANK end/start, VBLANK end/start) + + // textures and bitmaps + render_texture * m_texture[2]; // 2x textures for the screen bitmap + bitmap_t * m_bitmap[2]; // 2x bitmaps for rendering + bitmap_t * m_burnin; // burn-in bitmap + UINT8 m_curbitmap; // current bitmap index + UINT8 m_curtexture; // current texture index + INT32 m_texture_format; // texture format of bitmap for this screen + bool m_changed; // has this bitmap changed? + INT32 m_last_partial_scan; // scanline of last partial update + + // screen timing + attoseconds_t m_frame_period; // attoseconds per frame + attoseconds_t m_scantime; // attoseconds per scanline + attoseconds_t m_pixeltime; // attoseconds per pixel + attoseconds_t m_vblank_period; // attoseconds per VBLANK period + attotime m_vblank_start_time; // time of last VBLANK start + attotime m_vblank_end_time; // time of last VBLANK end + emu_timer * m_vblank_begin_timer; // timer to signal VBLANK start + emu_timer * m_vblank_end_timer; // timer to signal VBLANK end + emu_timer * m_scanline0_timer; // scanline 0 timer + emu_timer * m_scanline_timer; // scanline timer + UINT64 m_frame_number; // the current frame number + + struct callback_item + { + callback_item * m_next; + vblank_state_changed_func m_callback; + void * m_param; + }; + callback_item * m_callback_list; // list of VBLANK callbacks }; -/*------------------------------------------------- - vblank_state_changed_func - - callback that is called to notify of a change - in the VBLANK state --------------------------------------------------*/ +// device type definition +const device_type SCREEN = screen_device_config::static_alloc_device_config; -typedef void (*vblank_state_changed_func)(running_device *device, void *param, int vblank_state); - -/*************************************************************************** - SCREEN DEVICE CONFIGURATION MACROS -***************************************************************************/ +//************************************************************************** +// SCREEN DEVICE CONFIGURATION MACROS +//************************************************************************** #define MDRV_SCREEN_ADD(_tag, _type) \ - MDRV_DEVICE_ADD(_tag, VIDEO_SCREEN, 0) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, type, SCREEN_TYPE_##_type) + MDRV_DEVICE_ADD(_tag, SCREEN, 0) \ + MDRV_SCREEN_TYPE(_type) #define MDRV_SCREEN_MODIFY(_tag) \ MDRV_DEVICE_MODIFY(_tag) #define MDRV_SCREEN_FORMAT(_format) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, format, _format) + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_FORMAT, _format) #define MDRV_SCREEN_TYPE(_type) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, type, SCREEN_TYPE_##_type) + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_TYPE, SCREEN_TYPE_##_type) #define MDRV_SCREEN_RAW_PARAMS(_pixclock, _htotal, _hbend, _hbstart, _vtotal, _vbend, _vbstart) \ - MDRV_DEVICE_CONFIG_DATA64(screen_config, refresh, HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) \ - MDRV_DEVICE_CONFIG_DATA64(screen_config, vblank, ((HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) / (_vtotal)) * ((_vtotal) - ((_vbstart) - (_vbend)))) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, width, _htotal) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, height, _vtotal) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.min_x, _hbend) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.max_x, (_hbstart) - 1) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.min_y, _vbend) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.max_y, (_vbstart) - 1) + MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_REFRESH, HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) \ + MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_VBLANK, ((HZ_TO_ATTOSECONDS(_pixclock) * (_htotal) * (_vtotal)) / (_vtotal)) * ((_vtotal) - ((_vbstart) - (_vbend)))) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_WIDTH, _htotal) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_HEIGHT, _vtotal) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINX, _hbend) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXX, (_hbstart) - 1) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINY, _vbend) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXY, (_vbstart) - 1) #define MDRV_SCREEN_REFRESH_RATE(_rate) \ - MDRV_DEVICE_CONFIG_DATA64(screen_config, refresh, HZ_TO_ATTOSECONDS(_rate)) + MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_REFRESH, HZ_TO_ATTOSECONDS(_rate)) #define MDRV_SCREEN_VBLANK_TIME(_time) \ - MDRV_DEVICE_CONFIG_DATA64(screen_config, vblank, _time) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, oldstyle_vblank_supplied, TRUE) + MDRV_DEVICE_INLINE_DATA64(screen_device_config::INLINE_VBLANK, _time) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_OLDVBLANK, true) #define MDRV_SCREEN_SIZE(_width, _height) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, width, _width) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, height, _height) + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_WIDTH, _width) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_HEIGHT, _height) #define MDRV_SCREEN_VISIBLE_AREA(_minx, _maxx, _miny, _maxy) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.min_x, _minx) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.max_x, _maxx) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.min_y, _miny) \ - MDRV_DEVICE_CONFIG_DATA32(screen_config, visarea.max_y, _maxy) + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINX, _minx) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXX, _maxx) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MINY, _miny) \ + MDRV_DEVICE_INLINE_DATA16(screen_device_config::INLINE_VIS_MAXY, _maxy) #define MDRV_SCREEN_DEFAULT_POSITION(_xscale, _xoffs, _yscale, _yoffs) \ - MDRV_DEVICE_CONFIG_DATAFP32(screen_config, xoffset, _xoffs, 24) \ - MDRV_DEVICE_CONFIG_DATAFP32(screen_config, xscale, _xscale, 24) \ - MDRV_DEVICE_CONFIG_DATAFP32(screen_config, yoffset, _yoffs, 24) \ - MDRV_DEVICE_CONFIG_DATAFP32(screen_config, yscale, _yscale, 24) + MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_XOFFSET, (_xoffs) * (double)(1 << 24)) \ + MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_XSCALE, (_xscale) * (double)(1 << 24)) \ + MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_YOFFSET, (_yoffs) * (double)(1 << 24)) \ + MDRV_DEVICE_INLINE_DATA32(screen_device_config::INLINE_YSCALE, (_yscale) * (double)(1 << 24)) -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ +//************************************************************************** +// FUNCTION PROTOTYPES +//************************************************************************** /* ----- core implementation ----- */ @@ -156,69 +338,6 @@ typedef void (*vblank_state_changed_func)(running_device *device, void *param, i void video_init(running_machine *machine); -/* ----- screen management ----- */ - -/* set the resolution of a screen */ -void video_screen_configure(running_device *screen, int width, int height, const rectangle *visarea, attoseconds_t refresh); - -/* set the visible area of a screen; this is a subset of video_screen_configure */ -void video_screen_set_visarea(running_device *screen, int min_x, int max_x, int min_y, int max_y); - -/* force a partial update of the screen up to and including the requested scanline */ -int video_screen_update_partial(running_device *screen, int scanline); - -/* force an update from the last beam position up to the current beam position */ -void video_screen_update_now(running_device *screen); - -/* return the current vertical or horizontal position of the beam for a screen */ -int video_screen_get_vpos(running_device *screen); -int video_screen_get_hpos(running_device *screen); - -/* return the current vertical or horizontal blanking state for a screen */ -int video_screen_get_vblank(running_device *screen); -int video_screen_get_hblank(running_device *screen); - -/* return the current width for a screen */ -int video_screen_get_width(running_device *screen); - -/* return the current height for a screen */ -int video_screen_get_height(running_device *screen); - -/* return the current visible area for a screen */ -const rectangle *video_screen_get_visible_area(running_device *screen); - -/* return the time when the beam will reach a particular H,V position */ -attotime video_screen_get_time_until_pos(running_device *screen, int vpos, int hpos); - -/* return the time when the beam will reach the start of VBLANK */ -attotime video_screen_get_time_until_vblank_start(running_device *screen); - -/* return the time when the beam will reach the end of VBLANK */ -attotime video_screen_get_time_until_vblank_end(running_device *screen); - -/* return the time when the VIDEO_UPDATE function will be called */ -attotime video_screen_get_time_until_update(running_device *screen); - -/* return the amount of time the beam takes to draw one scan line */ -attotime video_screen_get_scan_period(running_device *screen); - -/* return the amount of time the beam takes to draw one complete frame */ -attotime video_screen_get_frame_period(running_device *screen); - -/* return the current frame number -- this is always increasing */ -UINT64 video_screen_get_frame_number(running_device *screen); - -/* registers a VBLANK callback for the given screen */ -void video_screen_register_vblank_callback(running_device *screen, vblank_state_changed_func vblank_callback, void *param); - - -/* ----- video screen device interface ----- */ - -/* device get info callback */ -#define VIDEO_SCREEN DEVICE_GET_INFO_NAME(video_screen) -DEVICE_GET_INFO( video_screen ); - - /* ----- global rendering ----- */ /* update the screen, handling frame skipping and rendering */ @@ -256,7 +375,7 @@ void video_set_fastforward(int fastforward); /* ----- snapshots ----- */ /* save a snapshot of a given screen */ -void video_screen_save_snapshot(running_machine *machine, running_device *screen, mame_file *fp); +void screen_save_snapshot(running_machine *machine, device_t *screen, mame_file *fp); /* save a snapshot of all the active screens */ void video_save_active_screen_snapshots(running_machine *machine); @@ -285,4 +404,75 @@ int video_get_view_for_target(running_machine *machine, render_target *target, c void video_assert_out_of_range_pixels(running_machine *machine, bitmap_t *bitmap); + +//************************************************************************** +// INLINE HELPERS +//************************************************************************** + +//------------------------------------------------- +// screen_count - return the number of +// video screen devices in a machine_config +//------------------------------------------------- + +inline int screen_count(const machine_config &config) +{ + return config.devicelist.count(SCREEN); +} + + +//------------------------------------------------- +// screen_first - return the first +// video screen device config in a machine_config +//------------------------------------------------- + +inline const screen_device_config *screen_first(const machine_config &config) +{ + return downcast(config.devicelist.first(SCREEN)); +} + + +//------------------------------------------------- +// screen_next - return the next +// video screen device config in a machine_config +//------------------------------------------------- + +inline const screen_device_config *screen_next(const screen_device_config *previous) +{ + return downcast(previous->typenext()); +} + + +//------------------------------------------------- +// screen_count - return the number of +// video screen devices in a machine +//------------------------------------------------- + +inline int screen_count(running_machine &machine) +{ + return machine.devicelist.count(SCREEN); +} + + +//------------------------------------------------- +// screen_first - return the first +// video screen device in a machine +//------------------------------------------------- + +inline screen_device *screen_first(running_machine &machine) +{ + return downcast(machine.devicelist.first(SCREEN)); +} + + +//------------------------------------------------- +// screen_next - return the next +// video screen device in a machine +//------------------------------------------------- + +inline screen_device *screen_next(screen_device *previous) +{ + return downcast(previous->typenext()); +} + + #endif /* __VIDEO_H__ */ diff --git a/src/emu/video/generic.c b/src/emu/video/generic.c index 69854e0420f..ca84201e90e 100644 --- a/src/emu/video/generic.c +++ b/src/emu/video/generic.c @@ -251,7 +251,7 @@ void generic_video_init(running_machine *machine) VIDEO_START( generic_bitmapped ) { /* allocate the temporary bitmap */ - machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + machine->generic.tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); /* ensure the contents of the bitmap are saved */ state_save_register_global_bitmap(machine, machine->generic.tmpbitmap); @@ -389,10 +389,10 @@ void buffer_spriteram_2(running_machine *machine, UINT8 *ptr, int length) static void updateflip(running_machine *machine) { generic_video_private *state = machine->generic_video_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); - attoseconds_t period = video_screen_get_frame_period(machine->primary_screen).attoseconds; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); + attoseconds_t period = machine->primary_screen->frame_period().attoseconds; + rectangle visarea = machine->primary_screen->visible_area(); tilemap_set_flip_all(machine,(TILEMAP_FLIPX & state->flip_screen_x) | (TILEMAP_FLIPY & state->flip_screen_y)); @@ -413,7 +413,7 @@ static void updateflip(running_machine *machine) visarea.max_y = temp; } - video_screen_configure(machine->primary_screen, width, height, &visarea, period); + machine->primary_screen->configure(width, height, visarea, period); } diff --git a/src/emu/video/hd63484.c b/src/emu/video/hd63484.c index ae0cd62bb4e..f099cbfd6d3 100644 --- a/src/emu/video/hd63484.c +++ b/src/emu/video/hd63484.c @@ -55,17 +55,16 @@ struct _hd63484_state INLINE hd63484_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == HD63484); + assert(device->type() == HD63484); - return (hd63484_state *)device->token; + return (hd63484_state *)downcast(device)->token(); } INLINE const hd63484_interface *get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == HD63484); - return (const hd63484_interface *) device->baseconfig().static_config; + assert(device->type() == HD63484); + return (const hd63484_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -1509,7 +1508,7 @@ READ16_DEVICE_HANDLER( hd63484_data_r ) int res; if (hd63484->regno == 0x80) - res = video_screen_get_vpos(device->machine->primary_screen); + res = device->machine->primary_screen->vpos(); else if (hd63484->regno == 0) { #if LOG_COMMANDS @@ -1583,6 +1582,5 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "HD63484" #define DEVTEMPLATE_FAMILY "HD63484 Video Controller" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/emu/video/hd63484.h b/src/emu/video/hd63484.h index eb7e0e7e70f..206a47f3c53 100644 --- a/src/emu/video/hd63484.h +++ b/src/emu/video/hd63484.h @@ -14,6 +14,8 @@ TYPE DEFINITIONS ***************************************************************************/ +DECLARE_LEGACY_DEVICE(HD63484, hd63484); + #define HD63484_RAM_SIZE 0x100000 typedef struct _hd63484_interface hd63484_interface; @@ -22,19 +24,10 @@ struct _hd63484_interface int skattva_hack; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( hd63484 ); - - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define HD63484 DEVICE_GET_INFO_NAME( hd63484 ) - #define MDRV_HD63484_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, HD63484, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/emu/video/mc6845.c b/src/emu/video/mc6845.c index a986260035e..106b74dcab5 100644 --- a/src/emu/video/mc6845.c +++ b/src/emu/video/mc6845.c @@ -74,7 +74,7 @@ struct _mc6845_t int device_type; const mc6845_interface *intf; - running_device *screen; + screen_device *screen; /* register file */ UINT8 horiz_char_total; /* 0x00 */ @@ -145,16 +145,15 @@ mc6845_interface mc6845_null_interface = { 0 }; INLINE mc6845_t *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == DEVICE_GET_INFO_NAME(mc6845)) || - (device->type == DEVICE_GET_INFO_NAME(mc6845_1)) || - (device->type == DEVICE_GET_INFO_NAME(c6545_1)) || - (device->type == DEVICE_GET_INFO_NAME(r6545_1)) || - (device->type == DEVICE_GET_INFO_NAME(h46505)) || - (device->type == DEVICE_GET_INFO_NAME(hd6845)) || - (device->type == DEVICE_GET_INFO_NAME(sy6545_1))); - - return (mc6845_t *)device->token; + assert((device->type() == MC6845) || + (device->type() == MC6845_1) || + (device->type() == C6545_1) || + (device->type() == R6545_1) || + (device->type() == H46505) || + (device->type() == HD6845) || + (device->type() == SY6545_1)); + + return (mc6845_t *)downcast(device)->token(); } @@ -207,7 +206,7 @@ READ8_DEVICE_HANDLER( mc6845_status_r ) UINT8 ret = 0; /* VBLANK bit */ - if (supports_status_reg_d5[mc6845->device_type] && video_screen_get_vblank(mc6845->screen)) + if (supports_status_reg_d5[mc6845->device_type] && mc6845->screen->vblank()) ret = ret | 0x20; /* light pen latched */ @@ -403,7 +402,7 @@ static void recompute_parameters(mc6845_t *mc6845, int postload) if (LOG) logerror("M6845 config screen: HTOTAL: 0x%x VTOTAL: 0x%x MAX_X: 0x%x MAX_Y: 0x%x HSYNC: 0x%x-0x%x VSYNC: 0x%x-0x%x Freq: %ffps\n", horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, hsync_on_pos, hsync_off_pos - 1, vsync_on_pos, vsync_off_pos - 1, 1 / ATTOSECONDS_TO_DOUBLE(refresh)); - video_screen_configure(mc6845->screen, horiz_pix_total, vert_pix_total, &visarea, refresh); + mc6845->screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh); mc6845->has_valid_parameters = TRUE; } @@ -430,7 +429,7 @@ static void recompute_parameters(mc6845_t *mc6845, int postload) INLINE int is_display_enabled(mc6845_t *mc6845) { - return !video_screen_get_vblank(mc6845->screen) && !video_screen_get_hblank(mc6845->screen); + return !mc6845->screen->vblank() && !mc6845->screen->hblank(); } @@ -452,7 +451,7 @@ static void update_de_changed_timer(mc6845_t *mc6845) if (is_display_enabled(mc6845)) { /* normally, it's at end the current raster line */ - next_y = video_screen_get_vpos(mc6845->screen); + next_y = mc6845->screen->vpos(); next_x = mc6845->max_visible_x + 1; /* but if visible width = horiz_pix_total, then we need @@ -473,7 +472,7 @@ static void update_de_changed_timer(mc6845_t *mc6845) else { next_x = 0; - next_y = (video_screen_get_vpos(mc6845->screen) + 1) % mc6845->vert_pix_total; + next_y = (mc6845->screen->vpos() + 1) % mc6845->vert_pix_total; /* if we would now fall in the vertical blanking, we need to go to the top of the screen */ @@ -486,7 +485,7 @@ static void update_de_changed_timer(mc6845_t *mc6845) } if (next_y != -1) - duration = video_screen_get_time_until_pos(mc6845->screen, next_y, next_x); + duration = mc6845->screen->time_until_pos(next_y, next_x); else duration = attotime_never; @@ -504,15 +503,15 @@ static void update_cur_changed_timers(mc6845_t *mc6845) UINT16 cur_on_pos = ((mc6845->cursor_addr - mc6845->disp_start_addr) % mc6845->horiz_disp) * mc6845->intf->hpixels_per_column; UINT16 cur_off_pos = cur_on_pos + mc6845->intf->hpixels_per_column; UINT16 next_y; - UINT16 y = video_screen_get_vpos(mc6845->screen); + UINT16 y = mc6845->screen->vpos(); if ((y >= cur_on_y) && (y < cur_off_y)) next_y = y + 1; else next_y = cur_on_y; - timer_adjust_oneshot(mc6845->cur_on_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, cur_on_pos) , 0); - timer_adjust_oneshot(mc6845->cur_off_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, cur_off_pos), 0); + timer_adjust_oneshot(mc6845->cur_on_timer, mc6845->screen->time_until_pos(next_y, cur_on_pos) , 0); + timer_adjust_oneshot(mc6845->cur_off_timer, mc6845->screen->time_until_pos(next_y, cur_off_pos), 0); } } @@ -523,15 +522,15 @@ static void update_hsync_changed_timers(mc6845_t *mc6845) UINT16 next_y; /* we are before the HSYNC position, we trigger on the current line */ - if (video_screen_get_hpos(mc6845->screen) < mc6845->hsync_on_pos) - next_y = video_screen_get_vpos(mc6845->screen); + if (mc6845->screen->hpos() < mc6845->hsync_on_pos) + next_y = mc6845->screen->vpos(); /* trigger on the next line */ else - next_y = (video_screen_get_vpos(mc6845->screen) + 1) % mc6845->vert_pix_total; + next_y = (mc6845->screen->vpos() + 1) % mc6845->vert_pix_total; - timer_adjust_oneshot(mc6845->hsync_on_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, mc6845->hsync_on_pos) , 0); - timer_adjust_oneshot(mc6845->hsync_off_timer, video_screen_get_time_until_pos(mc6845->screen, next_y, mc6845->hsync_off_pos), 0); + timer_adjust_oneshot(mc6845->hsync_on_timer, mc6845->screen->time_until_pos(next_y, mc6845->hsync_on_pos) , 0); + timer_adjust_oneshot(mc6845->hsync_off_timer, mc6845->screen->time_until_pos(next_y, mc6845->hsync_off_pos), 0); } } @@ -540,8 +539,8 @@ static void update_vsync_changed_timers(mc6845_t *mc6845) { if (mc6845->has_valid_parameters && (mc6845->vsync_on_timer != NULL)) { - timer_adjust_oneshot(mc6845->vsync_on_timer, video_screen_get_time_until_pos(mc6845->screen, mc6845->vsync_on_pos, 0), 0); - timer_adjust_oneshot(mc6845->vsync_off_timer, video_screen_get_time_until_pos(mc6845->screen, mc6845->vsync_off_pos, 0), 0); + timer_adjust_oneshot(mc6845->vsync_on_timer, mc6845->screen->time_until_pos(mc6845->vsync_on_pos), 0); + timer_adjust_oneshot(mc6845->vsync_off_timer, mc6845->screen->time_until_pos(mc6845->vsync_off_pos), 0); } } @@ -642,8 +641,8 @@ UINT16 mc6845_get_ma(running_device *device) if (mc6845->has_valid_parameters) { /* clamp Y/X to the visible region */ - int y = video_screen_get_vpos(mc6845->screen); - int x = video_screen_get_hpos(mc6845->screen); + int y = mc6845->screen->vpos(); + int x = mc6845->screen->hpos(); /* since the MA counter stops in the blanking regions, if we are in a VBLANK, both X and Y are at their max */ @@ -672,7 +671,7 @@ UINT8 mc6845_get_ra(running_device *device) if (mc6845->has_valid_parameters) { /* get the current vertical raster position and clamp it to the visible region */ - int y = video_screen_get_vpos(mc6845->screen); + int y = mc6845->screen->vpos(); if (y > mc6845->max_visible_y) y = mc6845->max_visible_y; @@ -706,8 +705,8 @@ void mc6845_assert_light_pen_input(running_device *device) if (mc6845->has_valid_parameters) { /* get the current pixel coordinates */ - y = video_screen_get_vpos(mc6845->screen); - x = video_screen_get_hpos(mc6845->screen); + y = mc6845->screen->vpos(); + x = mc6845->screen->hpos(); /* compute the pixel coordinate of the NEXT character -- this is when the light pen latches */ char_x = x / mc6845->hpixels_per_column; @@ -724,7 +723,7 @@ void mc6845_assert_light_pen_input(running_device *device) } /* set the timer that will latch the display address into the light pen registers */ - timer_adjust_oneshot(mc6845->light_pen_latch_timer, video_screen_get_time_until_pos(mc6845->screen, y, x), 0); + timer_adjust_oneshot(mc6845->light_pen_latch_timer, mc6845->screen->time_until_pos(y, x), 0); } } @@ -859,12 +858,12 @@ static void common_start(running_device *device, int device_type) /* validate arguments */ assert(device != NULL); - mc6845->intf = (const mc6845_interface *)device->baseconfig().static_config; + mc6845->intf = (const mc6845_interface *)device->baseconfig().static_config(); mc6845->device_type = device_type; if (mc6845->intf != NULL) { - assert(device->clock > 0); + assert(device->clock() > 0); assert(mc6845->intf->hpixels_per_column > 0); /* resolve callbacks */ @@ -874,11 +873,11 @@ static void common_start(running_device *device, int device_type) devcb_resolve_write_line(&mc6845->out_vsync_func, &mc6845->intf->out_vsync_func, device); /* copy the initial parameters */ - mc6845->clock = device->clock; + mc6845->clock = device->clock(); mc6845->hpixels_per_column = mc6845->intf->hpixels_per_column; /* get the screen device */ - mc6845->screen = device->machine->device(mc6845->intf->screen_tag); + mc6845->screen = downcast(device->machine->device(mc6845->intf->screen_tag)); assert(mc6845->screen != NULL); /* create the timers */ @@ -996,14 +995,15 @@ static DEVICE_RESET( mc6845 ) mc6845->light_pen_latched = FALSE; } +#if 0 static DEVICE_VALIDITY_CHECK( mc6845 ) { int error = FALSE; - const mc6845_interface *intf = (const mc6845_interface *) device->static_config; + const mc6845_interface *intf = (const mc6845_interface *) device->static_config(); if (intf != NULL && intf->screen_tag != NULL) { - if (device->clock <= 0) + if (device->clock() <= 0) { mame_printf_error("%s: %s has an mc6845 with an invalid clock\n", driver->source_file, driver->name); error = TRUE; @@ -1018,7 +1018,7 @@ static DEVICE_VALIDITY_CHECK( mc6845 ) return error; } - +#endif DEVICE_GET_INFO( mc6845 ) { @@ -1027,13 +1027,12 @@ DEVICE_GET_INFO( mc6845 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mc6845_t); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mc6845); break; case DEVINFO_FCT_STOP: /* Nothing */ break; case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mc6845); break; - case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(mc6845); break; +// case DEVINFO_FCT_VALIDITY_CHECK: info->validity_check = DEVICE_VALIDITY_CHECK_NAME(mc6845); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Motorola 6845"); break; diff --git a/src/emu/video/mc6845.h b/src/emu/video/mc6845.h index c1fef2be436..8964876b012 100644 --- a/src/emu/video/mc6845.h +++ b/src/emu/video/mc6845.h @@ -10,13 +10,15 @@ #ifndef __MC6845__ #define __MC6845__ -#define MC6845 DEVICE_GET_INFO_NAME(mc6845) -#define MC6845_1 DEVICE_GET_INFO_NAME(mc6845_1) -#define R6545_1 DEVICE_GET_INFO_NAME(r6545_1) -#define C6545_1 DEVICE_GET_INFO_NAME(c6545_1) -#define H46505 DEVICE_GET_INFO_NAME(h46505) -#define HD6845 DEVICE_GET_INFO_NAME(hd6845) -#define SY6545_1 DEVICE_GET_INFO_NAME(sy6545_1) +#include "devlegcy.h" + +DECLARE_LEGACY_DEVICE(MC6845, mc6845); +DECLARE_LEGACY_DEVICE(MC6845_1, mc6845_1); +DECLARE_LEGACY_DEVICE(R6545_1, r6545_1); +DECLARE_LEGACY_DEVICE(C6545_1, c6545_1); +DECLARE_LEGACY_DEVICE(H46505, h46505); +DECLARE_LEGACY_DEVICE(HD6845, hd6845); +DECLARE_LEGACY_DEVICE(SY6545_1, sy6545_1); #define MDRV_MC6845_ADD(_tag, _variant, _clock, _config) \ @@ -84,15 +86,6 @@ struct _mc6845_interface extern mc6845_interface mc6845_null_interface; -/* device interface */ -DEVICE_GET_INFO( mc6845 ); -DEVICE_GET_INFO( mc6845_1 ); -DEVICE_GET_INFO( r6545_1 ); -DEVICE_GET_INFO( c6545_1 ); -DEVICE_GET_INFO( h46505 ); -DEVICE_GET_INFO( hd6845 ); -DEVICE_GET_INFO( sy6545_1 ); - /* select one of the registers for reading or writing */ WRITE8_DEVICE_HANDLER( mc6845_address_w ); diff --git a/src/emu/video/pc_vga.c b/src/emu/video/pc_vga.c index f9e92bd3d0f..7a22ad892e2 100644 --- a/src/emu/video/pc_vga.c +++ b/src/emu/video/pc_vga.c @@ -675,7 +675,7 @@ static void vga_cpu_interface(running_machine *machine) } else { - buswidth = machine->firstcpu->databus_width(AS_PROGRAM); + buswidth = downcast(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width; switch(buswidth) { case 8: @@ -1265,8 +1265,8 @@ void pc_vga_init(running_machine *machine, const struct pc_vga_interface *vga_in memset(vga.crtc.data, '\0', vga.svga_intf.crtc_regcount); memset(vga.gc.data, '\0', vga.svga_intf.gc_regcount); - buswidth = machine->firstcpu->databus_width(AS_PROGRAM); - spacevga =cpu_get_address_space(machine->firstcpu,vga.vga_intf.port_addressspace); + buswidth = downcast(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width; + spacevga = cpu_get_address_space(machine->firstcpu,vga.vga_intf.port_addressspace); switch(buswidth) { case 8: diff --git a/src/emu/video/pc_video.c b/src/emu/video/pc_video.c index a6a870c61b5..48736b58720 100644 --- a/src/emu/video/pc_video.c +++ b/src/emu/video/pc_video.c @@ -72,8 +72,8 @@ VIDEO_UPDATE( pc_video ) { if ((pc_current_width != w) || (pc_current_height != h)) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); pc_current_width = w; pc_current_height = h; @@ -85,7 +85,7 @@ VIDEO_UPDATE( pc_video ) pc_current_height = height; if ((pc_current_width > 100) && (pc_current_height > 100)) - video_screen_set_visarea(screen, 0, pc_current_width-1, 0, pc_current_height-1); + screen->set_visible_area(0, pc_current_width-1, 0, pc_current_height-1); bitmap_fill(bitmap, cliprect, 0); } diff --git a/src/emu/video/s2636.c b/src/emu/video/s2636.c index 6e1c600aae5..28d219e23f4 100644 --- a/src/emu/video/s2636.c +++ b/src/emu/video/s2636.c @@ -116,17 +116,16 @@ struct _s2636_state INLINE s2636_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == S2636); + assert(device->type() == S2636); - return (s2636_state *)device->token; + return (s2636_state *)downcast(device)->token(); } INLINE const s2636_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == S2636)); - return (const s2636_interface *) device->baseconfig().static_config; + assert((device->type() == S2636)); + return (const s2636_interface *) device->baseconfig().static_config(); } @@ -342,9 +341,9 @@ static DEVICE_START( s2636 ) { s2636_state *s2636 = get_safe_token(device); const s2636_interface *intf = get_interface(device); - running_device *screen = device->machine->device(intf->screen); - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + screen_device *screen = downcast(device->machine->device(intf->screen)); + int width = screen->width(); + int height = screen->height(); s2636->work_ram_size = intf->work_ram_size; s2636->x_offset = intf->x_offset; @@ -367,6 +366,5 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START #define DEVTEMPLATE_NAME "Signetics 2636" #define DEVTEMPLATE_FAMILY "Signetics Video Chips" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/emu/video/s2636.h b/src/emu/video/s2636.h index 22018ad8ee1..eaa57a738be 100644 --- a/src/emu/video/s2636.h +++ b/src/emu/video/s2636.h @@ -7,6 +7,8 @@ #ifndef __S2636_H__ #define __S2636_H__ +#include "devlegcy.h" + #define S2636_IS_PIXEL_DRAWN(p) (((p) & 0x08) ? TRUE : FALSE) #define S2636_PIXEL_COLOR(p) ((p) & 0x07) @@ -26,22 +28,13 @@ struct _s2636_interface int x_offset; }; -/************************************* - * - * Function prototypes - * - *************************************/ - -DEVICE_GET_INFO( s2636 ); - - /************************************* * * Device configuration macros * *************************************/ -#define S2636 DEVICE_GET_INFO_NAME( s2636 ) +DECLARE_LEGACY_DEVICE(S2636, s2636); #define MDRV_S2636_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, S2636, 0) \ diff --git a/src/emu/video/saa5050.c b/src/emu/video/saa5050.c index 3a45b48a25d..0a1e6d503e0 100644 --- a/src/emu/video/saa5050.c +++ b/src/emu/video/saa5050.c @@ -59,17 +59,16 @@ struct _saa5050_state INLINE saa5050_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SAA5050); + assert(device->type() == SAA5050); - return (saa5050_state *)device->token; + return (saa5050_state *)downcast(device)->token(); } INLINE const saa5050_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == SAA5050)); - return (const saa5050_interface *) device->baseconfig().static_config; + assert((device->type() == SAA5050)); + return (const saa5050_interface *) device->baseconfig().static_config(); } /************************************* @@ -385,6 +384,5 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "SAA5050" #define DEVTEMPLATE_FAMILY "SAA5050 Teletext Character Generator" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/emu/video/saa5050.h b/src/emu/video/saa5050.h index 28fb330b527..8426c5a1045 100644 --- a/src/emu/video/saa5050.h +++ b/src/emu/video/saa5050.h @@ -9,6 +9,7 @@ #ifndef __SAA5050_H__ #define __SAA5050_H__ +#include "devlegcy.h" #define SAA5050_VBLANK 2500 @@ -25,19 +26,12 @@ struct _saa5050_interface int rev; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( saa5050 ); - +DECLARE_LEGACY_DEVICE(SAA5050, saa5050); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define SAA5050 DEVICE_GET_INFO_NAME( saa5050 ) - #define MDRV_SAA5050_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, SAA5050, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/emu/video/tms34061.c b/src/emu/video/tms34061.c index 71f2e1b2d7a..6d53fe75cec 100644 --- a/src/emu/video/tms34061.c +++ b/src/emu/video/tms34061.c @@ -35,7 +35,7 @@ struct tms34061_data UINT8 * shiftreg; emu_timer * timer; struct tms34061_interface intf; - running_device *screen; + screen_device *screen; }; @@ -80,7 +80,7 @@ void tms34061_start(running_machine *machine, const struct tms34061_interface *i /* reset the data */ memset(&tms34061, 0, sizeof(tms34061)); tms34061.intf = *interface; - tms34061.screen = machine->device(tms34061.intf.screen_tag); + tms34061.screen = downcast(machine->device(tms34061.intf.screen_tag)); tms34061.vrammask = tms34061.intf.vramsize - 1; /* allocate memory for VRAM */ @@ -147,7 +147,7 @@ INLINE void update_interrupts(void) static TIMER_CALLBACK( tms34061_interrupt ) { /* set timer for next frame */ - timer_adjust_oneshot(tms34061.timer, video_screen_get_frame_period(tms34061.screen), 0); + timer_adjust_oneshot(tms34061.timer, tms34061.screen->frame_period(), 0); /* set the interrupt bit in the status reg */ tms34061.regs[TMS34061_STATUS] |= 1; @@ -172,7 +172,7 @@ static void register_w(const address_space *space, offs_t offset, UINT8 data) /* certain registers affect the display directly */ if ((regnum >= TMS34061_HORENDSYNC && regnum <= TMS34061_DISPSTART) || (regnum == TMS34061_CONTROL2)) - video_screen_update_partial(tms34061.screen, video_screen_get_vpos(tms34061.screen)); + tms34061.screen->update_partial(tms34061.screen->vpos()); /* store the hi/lo half */ if (regnum < ARRAY_LENGTH(tms34061.regs)) @@ -196,7 +196,7 @@ static void register_w(const address_space *space, offs_t offset, UINT8 data) if (scanline < 0) scanline += tms34061.regs[TMS34061_VERTOTAL]; - timer_adjust_oneshot(tms34061.timer, video_screen_get_time_until_pos(tms34061.screen, scanline, tms34061.regs[TMS34061_HORSTARTBLNK]), 0); + timer_adjust_oneshot(tms34061.timer, tms34061.screen->time_until_pos(scanline, tms34061.regs[TMS34061_HORSTARTBLNK]), 0); break; /* XY offset: set the X and Y masks */ @@ -257,7 +257,7 @@ static UINT8 register_r(const address_space *space, offs_t offset) /* vertical count register: return the current scanline */ case TMS34061_VERCOUNTER: - result = (video_screen_get_vpos(tms34061.screen)+ tms34061.regs[TMS34061_VERENDBLNK]) % tms34061.regs[TMS34061_VERTOTAL]; + result = (tms34061.screen->vpos()+ tms34061.regs[TMS34061_VERENDBLNK]) % tms34061.regs[TMS34061_VERTOTAL]; break; } diff --git a/src/emu/video/tms9927.c b/src/emu/video/tms9927.c index 29a77b26fe4..a756411fc8b 100644 --- a/src/emu/video/tms9927.c +++ b/src/emu/video/tms9927.c @@ -35,7 +35,7 @@ struct _tms9927_state { /* driver-controlled state */ const tms9927_interface *intf; - running_device *screen; + screen_device *screen; const UINT8 *selfload; /* live state */ @@ -63,9 +63,8 @@ tms9927_interface tms9927_null_interface = { 0 }; INLINE tms9927_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TMS9927); - return (tms9927_state *)device->token; + assert(device->type() == TMS9927); + return (tms9927_state *)downcast(device)->token(); } @@ -103,21 +102,21 @@ static void generic_access(running_device *device, offs_t offset) case 0x0a: /* Reset */ if (!tms->reset) { - video_screen_update_now(tms->screen); + tms->screen->update_now(); tms->reset = TRUE; } break; case 0x0b: /* Up scroll */ mame_printf_debug("Up scroll\n"); - video_screen_update_now(tms->screen); + tms->screen->update_now(); tms->start_datarow = (tms->start_datarow + 1) % DATA_ROWS_PER_FRAME(tms); break; case 0x0e: /* Start timing chain */ if (tms->reset) { - video_screen_update_now(tms->screen); + tms->screen->update_now(); tms->reset = FALSE; recompute_parameters(tms, FALSE); } @@ -248,7 +247,7 @@ static void recompute_parameters(tms9927_state *tms, int postload) refresh = HZ_TO_ATTOSECONDS(tms->clock) * tms->total_hpix * tms->total_vpix; - video_screen_configure(tms->screen, tms->total_hpix, tms->total_vpix, &visarea, refresh); + tms->screen->configure(tms->total_hpix, tms->total_vpix, visarea, refresh); } @@ -260,19 +259,19 @@ static DEVICE_START( tms9927 ) /* validate arguments */ assert(device != NULL); - tms->intf = (const tms9927_interface *)device->baseconfig().static_config; + tms->intf = (const tms9927_interface *)device->baseconfig().static_config(); if (tms->intf != NULL) { - assert(device->clock > 0); + assert(device->clock() > 0); assert(tms->intf->hpixels_per_column > 0); /* copy the initial parameters */ - tms->clock = device->clock; + tms->clock = device->clock(); tms->hpixels_per_column = tms->intf->hpixels_per_column; /* get the screen device */ - tms->screen = device->machine->device(tms->intf->screen_tag); + tms->screen = downcast(device->machine->device(tms->intf->screen_tag)); assert(tms->screen != NULL); /* get the self-load PROM */ @@ -319,7 +318,6 @@ DEVICE_GET_INFO( tms9927 ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tms9927_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tms9927); break; diff --git a/src/emu/video/tms9927.h b/src/emu/video/tms9927.h index 1f721b82682..77ac3fc136e 100644 --- a/src/emu/video/tms9927.h +++ b/src/emu/video/tms9927.h @@ -10,11 +10,13 @@ #ifndef __TMS9927__ #define __TMS9927__ +#include "devlegcy.h" -#define TMS9927 DEVICE_GET_INFO_NAME(tms9927) -#define CRT5027 DEVICE_GET_INFO_NAME(crt5027) -#define CRT5037 DEVICE_GET_INFO_NAME(crt5037) -#define CRT5057 DEVICE_GET_INFO_NAME(crt5057) + +DECLARE_LEGACY_DEVICE(TMS9927, tms9927); +DECLARE_LEGACY_DEVICE(CRT5027, crt5027); +DECLARE_LEGACY_DEVICE(CRT5037, crt5037); +DECLARE_LEGACY_DEVICE(CRT5057, crt5057); #define MDRV_TMS9927_ADD(_tag, _clock, _config) \ @@ -40,12 +42,6 @@ struct _tms9927_interface extern tms9927_interface tms9927_null_interface; -/* device interface */ -DEVICE_GET_INFO( tms9927 ); -DEVICE_GET_INFO( crt5027 ); -DEVICE_GET_INFO( crt5037 ); -DEVICE_GET_INFO( crt5057 ); - /* basic read/write handlers */ WRITE8_DEVICE_HANDLER( tms9927_w ); READ8_DEVICE_HANDLER( tms9927_r ); diff --git a/src/emu/video/tms9928a.c b/src/emu/video/tms9928a.c index 954335fc39f..53c4897eec8 100644 --- a/src/emu/video/tms9928a.c +++ b/src/emu/video/tms9928a.c @@ -195,9 +195,9 @@ static void TMS9928A_start (running_machine *machine, const TMS9928a_interface * tms.visarea.max_y = tms.top_border + 24*8 - 1 + MIN(intf->bordery, tms.bottom_border); /* configure the screen if we weren't overridden */ - if (video_screen_get_width(machine->primary_screen) == LEFT_BORDER+32*8+RIGHT_BORDER && - video_screen_get_height(machine->primary_screen) == TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ) - video_screen_configure(machine->primary_screen, LEFT_BORDER + 32*8 + RIGHT_BORDER, tms.top_border + 24*8 + tms.bottom_border, &tms.visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds); + if (machine->primary_screen->width() == LEFT_BORDER+32*8+RIGHT_BORDER && + machine->primary_screen->height() == TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ) + machine->primary_screen->configure(LEFT_BORDER + 32*8 + RIGHT_BORDER, tms.top_border + 24*8 + tms.bottom_border, tms.visarea, machine->primary_screen->frame_period().attoseconds); /* Video RAM */ tms.vramsize = intf->vram; @@ -207,7 +207,7 @@ static void TMS9928A_start (running_machine *machine, const TMS9928a_interface * tms.dBackMem = auto_alloc_array(machine, UINT8, IMAGE_SIZE); /* back bitmap */ - tms.tmpbmp = auto_bitmap_alloc (machine, 256, 192, video_screen_get_format(machine->primary_screen)); + tms.tmpbmp = auto_bitmap_alloc (machine, 256, 192, machine->primary_screen->format()); TMS9928A_reset (); tms.LimitSprites = 1; diff --git a/src/emu/video/v9938.c b/src/emu/video/v9938.c index 69262c850aa..ddefe3aa347 100644 --- a/src/emu/video/v9938.c +++ b/src/emu/video/v9938.c @@ -50,7 +50,7 @@ typedef struct { UINT16 pal_ind16[16]; UINT16 pal_ind256[256]; /* render screen */ - running_device *screen; + screen_device *screen; /* render bitmap */ bitmap_t *bitmap; /* Command unit */ @@ -478,7 +478,7 @@ WRITE8_HANDLER (v9938_1_command_w) ***************************************************************************/ -void v9938_init (running_machine *machine, int which, running_device *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ) +void v9938_init (running_machine *machine, int which, screen_device &screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ) { vdp = &vdps[which]; @@ -487,7 +487,7 @@ void v9938_init (running_machine *machine, int which, running_device *screen, bi vdp->VdpOpsCnt = 1; vdp->VdpEngine = NULL; - vdp->screen = screen; + vdp->screen = &screen; vdp->bitmap = bitmap; vdp->model = model; vdp->vram_size = vram_size; @@ -1447,9 +1447,9 @@ static void v9938_interrupt_start_vblank (running_machine *machine) if (vdp->size != vdp->size_old) { if (vdp->size == RENDER_HIGH) - video_screen_set_visarea (vdp->screen, 0, 512 + 32 - 1, 0, 424 + 56 - 1); + vdp->screen->set_visible_area (0, 512 + 32 - 1, 0, 424 + 56 - 1); else - video_screen_set_visarea (vdp->screen, 0, 256 + 16 - 1, 0, 212 + 28 - 1); + vdp->screen->set_visible_area (0, 256 + 16 - 1, 0, 212 + 28 - 1); vdp->size_old = vdp->size; } diff --git a/src/emu/video/v9938.h b/src/emu/video/v9938.h index 45d4bc5e380..f7496ccdce6 100644 --- a/src/emu/video/v9938.h +++ b/src/emu/video/v9938.h @@ -14,7 +14,7 @@ #define RENDER_LOW (1) #define RENDER_AUTO (2) -void v9938_init (running_machine *machine, int which, running_device *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ); +void v9938_init (running_machine *machine, int which, screen_device &screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ); void v9938_reset (int which); int v9938_interrupt (running_machine *machine, int which); void v9938_set_sprite_limit (int which, int); diff --git a/src/emu/video/vector.c b/src/emu/video/vector.c index 67eb5199892..1dfcff0c6c0 100644 --- a/src/emu/video/vector.c +++ b/src/emu/video/vector.c @@ -95,7 +95,7 @@ static render_texture *get_vector_texture(float dx, float dy, float intensity) return tex->texture; height = lbucket * VECTOR_WIDTH_DENOM / TEXTURE_LENGTH_BUCKETS; - tex->bitmap = bitmap_alloc(TEXTURE_WIDTH, height, BITMAP_FORMAT_ARGB32); + tex->bitmap = global_alloc(bitmap_t(TEXTURE_WIDTH, height, BITMAP_FORMAT_ARGB32)); bitmap_fill(tex->bitmap, NULL, MAKE_ARGB(0xff,0xff,0xff,0xff)); totalint = 1.0f; @@ -260,11 +260,11 @@ void vector_clear_list (void) VIDEO_UPDATE( vector ) { UINT32 flags = PRIMFLAG_ANTIALIAS(options_get_bool(mame_options(), OPTION_ANTIALIAS) ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD); - const rectangle *visarea = video_screen_get_visible_area(screen); - float xscale = 1.0f / (65536 * (visarea->max_x - visarea->min_x)); - float yscale = 1.0f / (65536 * (visarea->max_y - visarea->min_y)); - float xoffs = (float)visarea->min_x; - float yoffs = (float)visarea->min_y; + const rectangle &visarea = screen->visible_area(); + float xscale = 1.0f / (65536 * (visarea.max_x - visarea.min_x)); + float yscale = 1.0f / (65536 * (visarea.max_y - visarea.min_y)); + float xoffs = (float)visarea.min_x; + float yoffs = (float)visarea.min_y; point *curpoint; render_bounds clip; int lastx = 0, lasty = 0; diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index 07c9f115691..77a55aae5a6 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -1670,7 +1670,7 @@ struct _voodoo_state { UINT8 index; /* index of board */ running_device *device; /* pointer to our containing device */ - running_device *screen; /* the screen we are acting on */ + screen_device *screen; /* the screen we are acting on */ running_device *cpu; /* the CPU we interact with */ UINT8 type; /* type of system */ UINT8 chipmask; /* mask for which chips are available */ diff --git a/src/emu/video/voodoo.c b/src/emu/video/voodoo.c index 8d7be9dcdee..0b12b4328ba 100644 --- a/src/emu/video/voodoo.c +++ b/src/emu/video/voodoo.c @@ -273,10 +273,9 @@ static const raster_info predef_raster_table[] = INLINE voodoo_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == VOODOO_GRAPHICS); + assert(device->type() == VOODOO_GRAPHICS); - return (voodoo_state *)device->token; + return (voodoo_state *)downcast(device)->token(); } @@ -832,10 +831,10 @@ static void swap_buffers(voodoo_state *v) { int count; - if (LOG_VBLANK_SWAP) logerror("--- swap_buffers @ %d\n", video_screen_get_vpos(v->screen)); + if (LOG_VBLANK_SWAP) logerror("--- swap_buffers @ %d\n", v->screen->vpos()); /* force a partial update */ - video_screen_update_partial(v->screen, video_screen_get_vpos(v->screen)); + v->screen->update_partial(v->screen->vpos()); v->fbi.video_changed = TRUE; /* keep a history of swap intervals */ @@ -889,8 +888,8 @@ static void swap_buffers(voodoo_state *v) /* update the statistics (debug) */ if (v->stats.display) { - const rectangle *visible_area = video_screen_get_visible_area(v->screen); - int screen_area = (visible_area->max_x - visible_area->min_x + 1) * (visible_area->max_y - visible_area->min_y + 1); + const rectangle &visible_area = v->screen->visible_area(); + int screen_area = (visible_area.max_x - visible_area.min_x + 1) * (visible_area.max_y - visible_area.min_y + 1); char *statsptr = v->stats.buffer; int pixelcount; int i; @@ -943,11 +942,11 @@ static void swap_buffers(voodoo_state *v) static void adjust_vblank_timer(voodoo_state *v) { - attotime vblank_period = video_screen_get_time_until_pos(v->screen, v->fbi.vsyncscan, 0); + attotime vblank_period = v->screen->time_until_pos(v->fbi.vsyncscan); /* if zero, adjust to next frame, otherwise we may get stuck in an infinite loop */ if (attotime_compare(vblank_period, attotime_zero) == 0) - vblank_period = video_screen_get_frame_period(v->screen); + vblank_period = v->screen->frame_period(); timer_adjust_oneshot(v->fbi.vblank_timer, vblank_period, 0); } @@ -996,7 +995,7 @@ static TIMER_CALLBACK( vblank_callback ) swap_buffers(v); /* set a timer for the next off state */ - timer_set(machine, video_screen_get_time_until_pos(v->screen, 0, 0), v, 0, vblank_off_callback); + timer_set(machine, v->screen->time_until_pos(0), v, 0, vblank_off_callback); /* set internal state and call the client */ v->fbi.vblank = TRUE; @@ -2455,7 +2454,7 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data) int vvis = (v->reg[videoDimensions].u >> 16) & 0x3ff; int hbp = (v->reg[backPorch].u & 0xff) + 2; int vbp = (v->reg[backPorch].u >> 16) & 0xff; - attoseconds_t refresh = video_screen_get_frame_period(v->screen).attoseconds; + attoseconds_t refresh = v->screen->frame_period().attoseconds; attoseconds_t stdperiod, medperiod, vgaperiod; attoseconds_t stddiff, meddiff, vgadiff; rectangle visarea; @@ -2490,17 +2489,17 @@ static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data) /* configure the screen based on which one matches the closest */ if (stddiff < meddiff && stddiff < vgadiff) { - video_screen_configure(v->screen, htotal, vtotal, &visarea, stdperiod); + v->screen->configure(htotal, vtotal, visarea, stdperiod); mame_printf_debug("Standard resolution, %f Hz\n", ATTOSECONDS_TO_HZ(stdperiod)); } else if (meddiff < vgadiff) { - video_screen_configure(v->screen, htotal, vtotal, &visarea, medperiod); + v->screen->configure(htotal, vtotal, visarea, medperiod); mame_printf_debug("Medium resolution, %f Hz\n", ATTOSECONDS_TO_HZ(medperiod)); } else { - video_screen_configure(v->screen, htotal, vtotal, &visarea, vgaperiod); + v->screen->configure(htotal, vtotal, visarea, vgaperiod); mame_printf_debug("VGA resolution, %f Hz\n", ATTOSECONDS_TO_HZ(vgaperiod)); } @@ -3694,7 +3693,7 @@ static UINT32 register_r(voodoo_state *v, offs_t offset) /* eat some cycles since people like polling here */ cpu_eat_cycles(v->cpu, 10); - result = video_screen_get_vpos(v->screen); + result = v->screen->vpos(); break; /* reserved area in the TMU read by the Vegas startup sequence */ @@ -4394,7 +4393,7 @@ WRITE32_DEVICE_HANDLER( banshee_io_w ) v->fbi.width = data & 0xfff; if (data & 0xfff000) v->fbi.height = (data >> 12) & 0xfff; - video_screen_set_visarea(v->screen, 0, v->fbi.width - 1, 0, v->fbi.height - 1); + v->screen->set_visible_area(0, v->fbi.width - 1, 0, v->fbi.height - 1); adjust_vblank_timer(v); if (LOG_REGISTERS) logerror("%s:banshee_io_w(%s) = %08X & %08X\n", cpuexec_describe_context(device->machine), banshee_io_reg_name[offset], data, mem_mask); @@ -4440,7 +4439,7 @@ WRITE32_DEVICE_HANDLER( banshee_io_w ) static DEVICE_START( voodoo ) { - const voodoo_config *config = (const voodoo_config *)device->baseconfig().inline_config; + const voodoo_config *config = (const voodoo_config *)downcast(device->baseconfig()).inline_config(); voodoo_state *v = get_safe_token(device); const raster_info *info; void *fbmem, *tmumem[2]; @@ -4448,8 +4447,8 @@ static DEVICE_START( voodoo ) int val; /* validate some basic stuff */ - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() != NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -4464,7 +4463,7 @@ static DEVICE_START( voodoo ) v->device = device; /* copy config data */ - v->freq = device->clock; + v->freq = device->clock(); v->fbi.vblank_client = config->vblank; v->pci.stall_callback = config->stall; @@ -4538,8 +4537,8 @@ static DEVICE_START( voodoo ) } /* set the type, and initialize the chip mask */ - v->index = device->machine->devicelist.index(device->type, device->tag()); - v->screen = device->machine->device(config->screen); + v->index = device->machine->devicelist.index(device->type(), device->tag()); + v->screen = downcast(device->machine->device(config->screen)); assert_always(v->screen != NULL, "Unable to find screen attached to voodoo"); v->cpu = device->machine->device(config->cputag); assert_always(v->cpu != NULL, "Unable to find CPU attached to voodoo"); @@ -4647,7 +4646,7 @@ static DEVICE_RESET( voodoo ) INLINE const char *get_voodoo_name(const device_config *devconfig) { - const voodoo_config *config = (devconfig != NULL) ? (const voodoo_config *)devconfig->inline_config : NULL; + const voodoo_config *config = (devconfig != NULL) ? (const voodoo_config *)downcast(devconfig)->inline_config() : NULL; switch (config->type) { default: @@ -4664,7 +4663,6 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET | DT_HAS_STOP | DT_HAS_INLINE_CONFIG #define DEVTEMPLATE_NAME get_voodoo_name(device) #define DEVTEMPLATE_FAMILY "3dfx Voodoo Graphics" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/emu/video/voodoo.h b/src/emu/video/voodoo.h index 28dc5bee7ef..0907a9abdb1 100644 --- a/src/emu/video/voodoo.h +++ b/src/emu/video/voodoo.h @@ -6,6 +6,13 @@ **************************************************************************/ +#ifndef __VOODOO_H__ +#define __VOODOO_H__ + +#pragma once + +#include "devlegcy.h" + /*************************************************************************** CONSTANTS @@ -113,6 +120,6 @@ READ32_DEVICE_HANDLER( banshee_rom_r ); /* ----- device interface ----- */ -/* device get info callback */ -#define VOODOO_GRAPHICS DEVICE_GET_INFO_NAME(voodoo) -DEVICE_GET_INFO( voodoo ); +DECLARE_LEGACY_DEVICE(VOODOO_GRAPHICS, voodoo); + +#endif diff --git a/src/emu/watchdog.c b/src/emu/watchdog.c index 209dee1e5f3..7fd7aaaa90a 100644 --- a/src/emu/watchdog.c +++ b/src/emu/watchdog.c @@ -84,18 +84,18 @@ static TIMER_CALLBACK( watchdog_callback ) timers -------------------------------------------------*/ -static void on_vblank(running_device *screen, void *param, int vblank_state) +static void on_vblank(screen_device &screen, void *param, bool vblank_state) { /* VBLANK starting */ if (vblank_state && watchdog_enabled) { /* check the watchdog */ - if (screen->machine->config->watchdog_vblank_count != 0) + if (screen.machine->config->watchdog_vblank_count != 0) { watchdog_counter = watchdog_counter - 1; if (watchdog_counter == 0) - watchdog_callback(screen->machine, NULL, 0); + watchdog_callback(screen.machine, NULL, 0); } } } @@ -118,7 +118,7 @@ void watchdog_reset(running_machine *machine) /* register a VBLANK callback for the primary screen */ if (machine->primary_screen != NULL) - video_screen_register_vblank_callback(machine->primary_screen, on_vblank, NULL); + machine->primary_screen->register_vblank_callback(on_vblank, NULL); } /* timer-based watchdog? */ diff --git a/src/ldplayer/ldplayer.c b/src/ldplayer/ldplayer.c index 34ee75fb118..958d93e103a 100644 --- a/src/ldplayer/ldplayer.c +++ b/src/ldplayer/ldplayer.c @@ -236,8 +236,8 @@ static TIMER_CALLBACK( vsync_update ) process_commands(laserdisc); /* set a timer to go off on the next VBLANK */ - vblank_scanline = video_screen_get_visible_area(machine->primary_screen)->max_y + 1; - target = video_screen_get_time_until_pos(machine->primary_screen, vblank_scanline, 0); + vblank_scanline = machine->primary_screen->visible_area().max_y + 1; + target = machine->primary_screen->time_until_pos(vblank_scanline); timer_set(machine, target, NULL, 0, vsync_update); } diff --git a/src/lib/util/astring.c b/src/lib/util/astring.c index 6ccda117905..d6f20d7aae8 100644 --- a/src/lib/util/astring.c +++ b/src/lib/util/astring.c @@ -137,6 +137,8 @@ INLINE void normalize_substr(int *start, int *count, int length) #ifdef __cplusplus +#include + /*------------------------------------------------- init - constructor helper -------------------------------------------------*/ @@ -167,7 +169,12 @@ astring::~astring() astring *astring_alloc(void) { - return new astring; + // we do our own malloc and use placement new here to + // make our memory tracking happy + void *ptr = malloc(sizeof(astring)); + if (ptr == NULL) + return NULL; + return new(ptr) astring; } @@ -177,7 +184,10 @@ astring *astring_alloc(void) void astring_free(astring *str) { - delete str; + // since we malloc'ed the memory ourselves, we directly + // call the destructor and free the memory ourselves + str->~astring(); + free(str); } #else diff --git a/src/lib/util/astring.h b/src/lib/util/astring.h index 68a7881edb4..9b81b330374 100644 --- a/src/lib/util/astring.h +++ b/src/lib/util/astring.h @@ -342,6 +342,8 @@ public: int vprintf(const char *format, va_list args) { return astring_vprintf(this, format, args); } int catprintf(const char *format, ...) { va_list ap; va_start(ap, format); int result = astring_catvprintf(this, format, ap); va_end(ap); return result; } int catvprintf(const char *format, va_list args) { return astring_catvprintf(this, format, args); } + + astring &format(const char *format, ...) { va_list ap; va_start(ap, format); astring_vprintf(this, format, ap); va_end(ap); return *this; } int cmp(const astring &str2) const { return astring_cmp(this, &str2); } int cmp(const char *str2) const { return astring_cmpc(this, str2); } diff --git a/src/mame/audio/amiga.c b/src/mame/audio/amiga.c index aec48a4f90d..bfba8f19584 100644 --- a/src/mame/audio/amiga.c +++ b/src/mame/audio/amiga.c @@ -267,7 +267,7 @@ static DEVICE_START( amiga_sound ) int i; /* allocate a new audio state */ - audio_state = (amiga_audio *)device->token; + audio_state = (amiga_audio *)downcast(device)->token(); for (i = 0; i < 4; i++) { audio_state->channel[i].index = i; @@ -275,7 +275,7 @@ static DEVICE_START( amiga_sound ) } /* create the stream */ - audio_state->stream = stream_create(device, 0, 4, device->clock / CLOCK_DIVIDER, audio_state, amiga_stream_update); + audio_state->stream = stream_create(device, 0, 4, device->clock() / CLOCK_DIVIDER, audio_state, amiga_stream_update); } diff --git a/src/mame/audio/atarijsa.c b/src/mame/audio/atarijsa.c index 7049fa33cb0..59dcbce35b1 100644 --- a/src/mame/audio/atarijsa.c +++ b/src/mame/audio/atarijsa.c @@ -53,15 +53,15 @@ ALL: the LPF (low pass filter) bit which selectively places a lowpass filter in static UINT8 *bank_base; static UINT8 *bank_source_data; -static running_device *jsacpu; +static cpu_device *jsacpu; static const char *test_port; static UINT16 test_mask; -static running_device *pokey; -static running_device *ym2151; -static running_device *tms5220; -static running_device *oki6295; -static running_device *oki6295_l, *oki6295_r; +static pokey_sound_device *pokey; +static ym2151_sound_device *ym2151; +static tms5220_sound_device *tms5220; +static okim6295_device *oki6295; +static okim6295_device *oki6295_l, *oki6295_r; static UINT8 overall_volume; static UINT8 pokey_volume; @@ -127,7 +127,7 @@ void atarijsa_init(running_machine *machine, const char *testport, int testmask) UINT8 *rgn; /* copy in the parameters */ - jsacpu = devtag_get_device(machine, "jsa"); + jsacpu = machine->device("jsa"); assert_always(jsacpu != NULL, "Could not find JSA CPU!"); test_port = testport; test_mask = testmask; @@ -138,12 +138,12 @@ void atarijsa_init(running_machine *machine, const char *testport, int testmask) bank_source_data = &rgn[0x10000]; /* determine which sound hardware is installed */ - tms5220 = devtag_get_device(machine, "tms"); - ym2151 = devtag_get_device(machine, "ymsnd"); - pokey = devtag_get_device(machine, "pokey"); - oki6295 = devtag_get_device(machine, "adpcm"); - oki6295_l = devtag_get_device(machine, "adpcml"); - oki6295_r = devtag_get_device(machine, "adpcmr"); + tms5220 = machine->device("tms"); + ym2151 = machine->device("ymsnd"); + pokey = machine->device("pokey"); + oki6295 = machine->device("adpcm"); + oki6295_l = machine->device("adpcml"); + oki6295_r = machine->device("adpcmr"); /* install POKEY memory handlers */ if (pokey != NULL) @@ -430,7 +430,7 @@ static WRITE8_HANDLER( jsa2_io_w ) /* update the OKI frequency */ if (oki6295 != NULL) - okim6295_set_pin7(oki6295, data & 8); + oki6295->set_pin7(data & 8); break; case 0x206: /* /MIX */ @@ -558,7 +558,7 @@ static WRITE8_HANDLER( jsa3_io_w ) coin_counter_w(space->machine, 0, (data >> 4) & 1); /* update the OKI frequency */ - if (oki6295 != NULL) okim6295_set_pin7(oki6295, data & 8); + if (oki6295 != NULL) oki6295->set_pin7(data & 8); break; case 0x206: /* /MIX */ @@ -691,8 +691,8 @@ static WRITE8_HANDLER( jsa3s_io_w ) coin_counter_w(space->machine, 0, (data >> 4) & 1); /* update the OKI frequency */ - okim6295_set_pin7(oki6295_l, data & 8); - okim6295_set_pin7(oki6295_r, data & 8); + oki6295_l->set_pin7(data & 8); + oki6295_r->set_pin7(data & 8); break; case 0x206: /* /MIX */ @@ -884,8 +884,7 @@ MACHINE_DRIVER_START( jsa_ii_mono ) MDRV_SOUND_ROUTE(0, "mono", 0.60) MDRV_SOUND_ROUTE(1, "mono", 0.60) - MDRV_SOUND_ADD("adpcm", OKIM6295, JSA_MASTER_CLOCK/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("adpcm", JSA_MASTER_CLOCK/3, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_DRIVER_END @@ -930,13 +929,11 @@ MACHINE_DRIVER_START( jsa_iiis_stereo ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.60) MDRV_SOUND_ROUTE(1, "rspeaker", 0.60) - MDRV_SOUND_ADD("adpcml", OKIM6295, JSA_MASTER_CLOCK/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("adpcml", JSA_MASTER_CLOCK/3, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_DEVICE_ADDRESS_MAP(0, jsa3_oki_map) - MDRV_SOUND_ADD("adpcmr", OKIM6295, JSA_MASTER_CLOCK/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("adpcmr", JSA_MASTER_CLOCK/3, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) MDRV_DEVICE_ADDRESS_MAP(0, jsa3_oki2_map) MACHINE_DRIVER_END diff --git a/src/mame/audio/cage.c b/src/mame/audio/cage.c index d7d36136127..c28e2ab9d45 100644 --- a/src/mame/audio/cage.c +++ b/src/mame/audio/cage.c @@ -33,7 +33,7 @@ * *************************************/ -static running_device *cage_cpu; +static cpu_device *cage_cpu; static attotime cage_cpu_h1_clock_period; static UINT8 cpu_to_cage_ready; @@ -45,10 +45,10 @@ static attotime serial_period_per_word; static UINT8 dma_enabled; static UINT8 dma_timer_enabled; -static running_device *dma_timer; +static timer_device *dma_timer; static UINT8 cage_timer_enabled[2]; -static running_device *timer[2]; +static timer_device *timer[2]; static UINT32 *tms32031_io_regs; @@ -57,7 +57,7 @@ static UINT16 cage_control; static UINT32 *speedup_ram; -static running_device *dmadac[DAC_BUFFER_CHANNELS]; +static dmadac_sound_device *dmadac[DAC_BUFFER_CHANNELS]; @@ -163,13 +163,13 @@ void cage_init(running_machine *machine, offs_t speedup) memory_set_bankptr(machine, "bank10", memory_region(machine, "cageboot")); memory_set_bankptr(machine, "bank11", memory_region(machine, "cage")); - cage_cpu = devtag_get_device(machine, "cage"); - cage_cpu_clock_period = ATTOTIME_IN_HZ(cpu_get_clock(cage_cpu)); + cage_cpu = machine->device("cage"); + cage_cpu_clock_period = ATTOTIME_IN_HZ(cage_cpu->clock()); cage_cpu_h1_clock_period = attotime_mul(cage_cpu_clock_period, 2); - dma_timer = devtag_get_device(machine, "cage_dma_timer"); - timer[0] = devtag_get_device(machine, "cage_timer0"); - timer[1] = devtag_get_device(machine, "cage_timer1"); + dma_timer = machine->device("cage_dma_timer"); + timer[0] = machine->device("cage_timer0"); + timer[1] = machine->device("cage_timer1"); if (speedup) speedup_ram = memory_install_write32_handler(cpu_get_address_space(cage_cpu, ADDRESS_SPACE_PROGRAM), speedup, speedup, 0, 0, speedup_w); @@ -178,7 +178,7 @@ void cage_init(running_machine *machine, offs_t speedup) { char buffer[10]; sprintf(buffer, "dac%d", chan + 1); - dmadac[chan] = devtag_get_device(machine, buffer); + dmadac[chan] = machine->device(buffer); } state_save_register_global(machine, cpu_to_cage_ready); @@ -221,7 +221,7 @@ static TIMER_DEVICE_CALLBACK( dma_timer_callback ) { if (dma_timer_enabled) { - timer_device_adjust_oneshot(timer, attotime_never, 0); + timer.adjust(attotime_never); dma_timer_enabled = 0; } return; @@ -272,7 +272,7 @@ static void update_dma_state(const address_space *space) if (!dma_timer_enabled) { attotime period = attotime_mul(serial_period_per_word, tms32031_io_regs[DMA_TRANSFER_COUNT]); - timer_device_adjust_periodic(dma_timer, period, addr, period); + dma_timer->adjust(period, addr, period); dma_timer_enabled = 1; } } @@ -280,7 +280,7 @@ static void update_dma_state(const address_space *space) /* see if we turned off */ else if (!enabled && dma_enabled) { - timer_device_adjust_oneshot(dma_timer, attotime_never, 0); + dma_timer->reset(); dma_timer_enabled = 0; } @@ -322,13 +322,13 @@ static void update_timer(int which) if (tms32031_io_regs[base + TIMER0_GLOBAL_CTL] != 0x2c1) logerror("CAGE TIMER%d: unexpected timer config %08X!\n", which, tms32031_io_regs[base + TIMER0_GLOBAL_CTL]); - timer_device_adjust_oneshot(timer[which], period, which); + timer[which]->adjust(period, which); } /* see if we turned off */ else if (!enabled && cage_timer_enabled[which]) { - timer_device_adjust_oneshot(timer[which], attotime_never, which); + timer[which]->adjust(attotime_never, which); } /* set the new state */ @@ -569,12 +569,12 @@ void cage_control_w(running_machine *machine, UINT16 data) dma_enabled = 0; dma_timer_enabled = 0; - timer_device_adjust_oneshot(dma_timer, attotime_never, 0); + dma_timer->reset(); cage_timer_enabled[0] = 0; cage_timer_enabled[1] = 0; - timer_device_adjust_oneshot(timer[0], attotime_never, 0); - timer_device_adjust_oneshot(timer[1], attotime_never, 0); + timer[0]->reset(); + timer[1]->reset(); memset(tms32031_io_regs, 0, 0x60 * 4); diff --git a/src/mame/audio/cinemat.c b/src/mame/audio/cinemat.c index d75cfd351e5..4fdbc6e00da 100644 --- a/src/mame/audio/cinemat.c +++ b/src/mame/audio/cinemat.c @@ -905,14 +905,14 @@ static void starcas_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bit target_pitch = 0x5800 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (video_screen_get_frame_number(machine->primary_screen) > last_frame) + if (machine->primary_screen->frame_number() > last_frame) { if (current_pitch > target_pitch) current_pitch -= 225; if (current_pitch < target_pitch) current_pitch += 150; sample_set_freq(samples, 4, current_pitch); - last_frame = video_screen_get_frame_number(machine->primary_screen); + last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ @@ -1010,7 +1010,7 @@ static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits target_volume = 0; /* ramp the thrust volume */ - if (sample_playing(samples, 2) && video_screen_get_frame_number(machine->primary_screen) > last_frame) + if (sample_playing(samples, 2) && machine->primary_screen->frame_number() > last_frame) { if (current_volume > target_volume) current_volume -= 0.078f; @@ -1020,7 +1020,7 @@ static void solarq_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits sample_set_volume(samples, 2, current_volume); else sample_stop(samples, 2); - last_frame = video_screen_get_frame_number(machine->primary_screen); + last_frame = machine->primary_screen->frame_number(); } /* fire - falling edge */ @@ -1292,14 +1292,14 @@ static void wotw_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_c target_pitch = 0x10000 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (video_screen_get_frame_number(machine->primary_screen) > last_frame) + if (machine->primary_screen->frame_number() > last_frame) { if (current_pitch > target_pitch) current_pitch -= 300; if (current_pitch < target_pitch) current_pitch += 200; sample_set_freq(samples, 4, current_pitch); - last_frame = video_screen_get_frame_number(machine->primary_screen); + last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ @@ -1406,14 +1406,14 @@ static void wotwc_sound_w(running_machine *machine, UINT8 sound_val, UINT8 bits_ target_pitch = 0x10000 + (target_pitch << 12); /* once per frame slide the pitch toward the target */ - if (video_screen_get_frame_number(machine->primary_screen) > last_frame) + if (machine->primary_screen->frame_number() > last_frame) { if (current_pitch > target_pitch) current_pitch -= 300; if (current_pitch < target_pitch) current_pitch += 200; sample_set_freq(samples, 4, current_pitch); - last_frame = video_screen_get_frame_number(machine->primary_screen); + last_frame = machine->primary_screen->frame_number(); } /* remember the previous value */ @@ -1578,7 +1578,7 @@ static ADDRESS_MAP_START( demon_sound_ports, ADDRESS_SPACE_IO, 8 ) ADDRESS_MAP_END -static const z80_daisy_chain daisy_chain[] = +static const z80_daisy_config daisy_chain[] = { { "ctc" }, { NULL } diff --git a/src/mame/audio/cps3.c b/src/mame/audio/cps3.c index e684e2eb0de..cbe370c287c 100644 --- a/src/mame/audio/cps3.c +++ b/src/mame/audio/cps3.c @@ -104,7 +104,7 @@ static STREAM_UPDATE( cps3_stream_update ) static DEVICE_START( cps3_sound ) { /* Allocate the stream */ - cps3_stream = stream_create(device, 0, 2, device->clock / 384, NULL, cps3_stream_update); + cps3_stream = stream_create(device, 0, 2, device->clock() / 384, NULL, cps3_stream_update); memset(&chip, 0, sizeof(chip)); } diff --git a/src/mame/audio/dcs.c b/src/mame/audio/dcs.c index 91d197d3213..120b2a1ce55 100644 --- a/src/mame/audio/dcs.c +++ b/src/mame/audio/dcs.c @@ -284,7 +284,7 @@ struct _dsio_denver_state typedef struct _dcs_state dcs_state; struct _dcs_state { - running_device *cpu; + cpu_device *cpu; const address_space *program; const address_space *data; UINT8 rev; @@ -295,10 +295,10 @@ struct _dcs_state UINT8 channels; UINT16 size; UINT16 incs; - running_device *dmadac[6]; - running_device *reg_timer; - running_device *sport_timer; - running_device *internal_timer; + dmadac_sound_device *dmadac[6]; + timer_device *reg_timer; + timer_device *sport_timer; + timer_device *internal_timer; INT32 ireg; UINT16 ireg_base; UINT16 control_regs[32]; @@ -350,7 +350,7 @@ struct _hle_transfer_state INT32 writes_left; UINT16 sum; INT32 fifo_entries; - running_device *watchdog; + timer_device *watchdog; }; @@ -674,6 +674,7 @@ MACHINE_DRIVER_END MACHINE_DRIVER_START( dcs2_audio_2104 ) MDRV_IMPORT_FROM(dcs2_audio_2115) MDRV_CPU_REPLACE("dcs2", ADSP2104, XTAL_16MHz) + MDRV_CPU_CONFIG(adsp_config) MDRV_CPU_PROGRAM_MAP(dcs2_2104_program_map) MDRV_CPU_DATA_MAP(dcs2_2104_data_map) MACHINE_DRIVER_END @@ -863,11 +864,11 @@ static TIMER_CALLBACK( dcs_reset ) /* reset timers */ dcs.timer_enable = 0; dcs.timer_scale = 1; - timer_device_adjust_oneshot(dcs.internal_timer, attotime_never, 0); + dcs.internal_timer->reset(); /* start the SPORT0 timer */ if (dcs.sport_timer != NULL) - timer_device_adjust_periodic(dcs.sport_timer, ATTOTIME_IN_HZ(1000), 0, ATTOTIME_IN_HZ(1000)); + dcs.sport_timer->adjust(ATTOTIME_IN_HZ(1000), 0, ATTOTIME_IN_HZ(1000)); /* reset the HLE transfer states */ transfer.dcs_state = transfer.state = 0; @@ -940,12 +941,12 @@ void dcs_init(running_machine *machine) dcs_sram = NULL; /* find the DCS CPU and the sound ROMs */ - dcs.cpu = devtag_get_device(machine, "dcs"); + dcs.cpu = machine->device("dcs"); dcs.program = cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_PROGRAM); dcs.data = cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_DATA); dcs.rev = 1; dcs.channels = 1; - dcs.dmadac[0] = devtag_get_device(machine, "dac"); + dcs.dmadac[0] = machine->device("dac"); /* configure boot and sound ROMs */ dcs.bootrom = (UINT16 *)memory_region(machine, "dcs"); @@ -956,8 +957,8 @@ void dcs_init(running_machine *machine) memory_configure_bank(machine, "databank", 0, dcs.sounddata_banks, dcs.sounddata, 0x1000*2); /* create the timers */ - dcs.internal_timer = devtag_get_device(machine, "dcs_int_timer"); - dcs.reg_timer = devtag_get_device(machine, "dcs_reg_timer"); + dcs.internal_timer = machine->device("dcs_int_timer"); + dcs.reg_timer = machine->device("dcs_reg_timer"); /* non-RAM based automatically acks */ dcs.auto_ack = TRUE; @@ -977,26 +978,26 @@ void dcs2_init(running_machine *machine, int dram_in_mb, offs_t polling_offset) memset(&dcs, 0, sizeof(dcs)); /* find the DCS CPU and the sound ROMs */ - dcs.cpu = devtag_get_device(machine, "dcs2"); + dcs.cpu = machine->device("dcs2"); dcs.rev = 2; soundbank_words = 0x1000; if (dcs.cpu == NULL) { - dcs.cpu = devtag_get_device(machine, "dsio"); + dcs.cpu = machine->device("dsio"); dcs.rev = 3; soundbank_words = 0x400; } if (dcs.cpu == NULL) { - dcs.cpu = devtag_get_device(machine, "denver"); + dcs.cpu = machine->device("denver"); dcs.rev = 4; soundbank_words = 0x800; } dcs.program = cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_PROGRAM); dcs.data = cpu_get_address_space(dcs.cpu, ADDRESS_SPACE_DATA); dcs.channels = 2; - dcs.dmadac[0] = devtag_get_device(machine, "dac1"); - dcs.dmadac[1] = devtag_get_device(machine, "dac2"); + dcs.dmadac[0] = machine->device("dac1"); + dcs.dmadac[1] = machine->device("dac2"); /* always boot from the base of "dcs" */ dcs.bootrom = (UINT16 *)memory_region(machine, "dcs"); @@ -1021,9 +1022,9 @@ void dcs2_init(running_machine *machine, int dram_in_mb, offs_t polling_offset) dcs_sram = auto_alloc_array(machine, UINT16, 0x8000*4/2); /* create the timers */ - dcs.internal_timer = devtag_get_device(machine, "dcs_int_timer"); - dcs.reg_timer = devtag_get_device(machine, "dcs_reg_timer"); - dcs.sport_timer = devtag_get_device(machine, "dcs_sport_timer"); + dcs.internal_timer = machine->device("dcs_int_timer"); + dcs.reg_timer = machine->device("dcs_reg_timer"); + dcs.sport_timer = machine->device("dcs_sport_timer"); /* we don't do auto-ack by default */ dcs.auto_ack = FALSE; @@ -1036,7 +1037,7 @@ void dcs2_init(running_machine *machine, int dram_in_mb, offs_t polling_offset) /* allocate a watchdog timer for HLE transfers */ transfer.hle_enabled = (ENABLE_HLE_TRANSFERS && dram_in_mb != 0); if (transfer.hle_enabled) - transfer.watchdog = devtag_get_device(machine, "dcs_hle_timer"); + transfer.watchdog = machine->device("dcs_hle_timer"); /* register for save states */ dcs_register_state(machine); @@ -1408,7 +1409,7 @@ static WRITE16_HANDLER( denver_w ) { char buffer[10]; sprintf(buffer, "dac%d", chan + 1); - dcs.dmadac[chan] = devtag_get_device(space->machine, buffer); + dcs.dmadac[chan] = space->machine->device(buffer); } dmadac_enable(&dcs.dmadac[0], dcs.channels, enable); if (dcs.channels < 6) @@ -1753,7 +1754,7 @@ static TIMER_DEVICE_CALLBACK( internal_timer_callback ) /* set the next timer, but only if it's for a reasonable number */ if (!dcs.timer_ignore && (dcs.timer_period > 10 || dcs.timer_scale > 1)) - timer_device_adjust_oneshot(timer, cpu_clocks_to_attotime(dcs.cpu, target_cycles), 0); + timer.adjust(cpu_clocks_to_attotime(dcs.cpu, target_cycles)); /* the IRQ line is edge triggered */ cpu_set_input_line(dcs.cpu, ADSP2105_TIMER, ASSERT_LINE); @@ -1789,7 +1790,7 @@ static void reset_timer(running_machine *machine) /* adjust the timer if not optimized */ if (!dcs.timer_ignore) - timer_device_adjust_oneshot(dcs.internal_timer, cpu_clocks_to_attotime(dcs.cpu, dcs.timer_scale * (dcs.timer_start_count + 1)), 0); + dcs.internal_timer->adjust(cpu_clocks_to_attotime(dcs.cpu, dcs.timer_scale * (dcs.timer_start_count + 1))); } @@ -1805,7 +1806,7 @@ static void timer_enable_callback(running_device *device, int enable) else { // mame_printf_debug("Timer disabled\n"); - timer_device_adjust_oneshot(dcs.internal_timer, attotime_never, 0); + dcs.internal_timer->reset(); } } @@ -1883,7 +1884,7 @@ static WRITE16_HANDLER( adsp_control_w ) if ((data & 0x0800) == 0) { dmadac_enable(&dcs.dmadac[0], dcs.channels, 0); - timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0); + dcs.reg_timer->reset(); } break; @@ -1892,7 +1893,7 @@ static WRITE16_HANDLER( adsp_control_w ) if ((data & 0x0002) == 0) { dmadac_enable(&dcs.dmadac[0], dcs.channels, 0); - timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0); + dcs.reg_timer->reset(); } break; @@ -2004,7 +2005,7 @@ static void recompute_sample_rate(running_machine *machine) if (dcs.incs) { attotime period = attotime_div(attotime_mul(sample_period, dcs.size), (2 * dcs.channels * dcs.incs)); - timer_device_adjust_periodic(dcs.reg_timer, period, 0, period); + dcs.reg_timer->adjust(period, 0, period); } } @@ -2057,7 +2058,7 @@ static void sound_tx_callback(running_device *device, int port, INT32 data) dmadac_enable(&dcs.dmadac[0], dcs.channels, 0); /* remove timer */ - timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0); + dcs.reg_timer->reset(); } @@ -2112,9 +2113,9 @@ static TIMER_DEVICE_CALLBACK( transfer_watchdog_callback ) if (transfer.fifo_entries && starting_writes_left == transfer.writes_left) { for ( ; transfer.fifo_entries; transfer.fifo_entries--) - preprocess_write(timer->machine, (*dcs.fifo_data_r)(dcs.cpu)); + preprocess_write(timer.machine, (*dcs.fifo_data_r)(dcs.cpu)); } - timer_device_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left); + transfer.watchdog->adjust(ATTOTIME_IN_MSEC(1), transfer.writes_left); } @@ -2344,7 +2345,7 @@ static int preprocess_stage_2(running_machine *machine, UINT16 data) transfer.sum = 0; if (transfer.hle_enabled) { - timer_device_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left); + transfer.watchdog->adjust(ATTOTIME_IN_MSEC(1), transfer.writes_left); return 1; } break; @@ -2371,7 +2372,7 @@ static int preprocess_stage_2(running_machine *machine, UINT16 data) if (transfer.state == 0) { timer_set(machine, ATTOTIME_IN_USEC(1), NULL, transfer.sum, s2_ack_callback); - timer_device_adjust_oneshot(transfer.watchdog, attotime_never, 0); + transfer.watchdog->reset(); } return 1; } diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c index 124a5eed78d..35b6a78bd5c 100644 --- a/src/mame/audio/exidy.c +++ b/src/mame/audio/exidy.c @@ -801,7 +801,7 @@ static DEVICE_RESET( venture_sound ) } -static DEVICE_GET_INFO( venture_sound ) +DEVICE_GET_INFO( venture_sound ) { switch (state) { @@ -815,8 +815,7 @@ static DEVICE_GET_INFO( venture_sound ) } } - -#define SOUND_EXIDY_VENTURE DEVICE_GET_INFO_NAME( venture_sound ) +DECLARE_LEGACY_SOUND_DEVICE(EXIDY_VENTURE, venture_sound); static ADDRESS_MAP_START( venture_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -1027,7 +1026,7 @@ static DEVICE_RESET( victory_sound ) } -static DEVICE_GET_INFO( victory_sound ) +DEVICE_GET_INFO( victory_sound ) { switch (state) { @@ -1042,7 +1041,7 @@ static DEVICE_GET_INFO( victory_sound ) } -#define SOUND_EXIDY_VICTORY DEVICE_GET_INFO_NAME( victory_sound ) +DECLARE_LEGACY_SOUND_DEVICE(EXIDY_VICTORY, victory_sound); static ADDRESS_MAP_START( victory_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) diff --git a/src/mame/audio/exidy440.c b/src/mame/audio/exidy440.c index 88de303e3b3..f1ae102501f 100644 --- a/src/mame/audio/exidy440.c +++ b/src/mame/audio/exidy440.c @@ -156,13 +156,13 @@ static DEVICE_START( exidy440_sound ) state_save_register_global(machine, m6844_interrupt); state_save_register_global(machine, m6844_chain); - channel_frequency[0] = device->clock; /* channels 0 and 1 are run by FCLK */ - channel_frequency[1] = device->clock; - channel_frequency[2] = device->clock/2; /* channels 2 and 3 are run by SCLK */ - channel_frequency[3] = device->clock/2; + channel_frequency[0] = device->clock(); /* channels 0 and 1 are run by FCLK */ + channel_frequency[1] = device->clock(); + channel_frequency[2] = device->clock()/2; /* channels 2 and 3 are run by SCLK */ + channel_frequency[3] = device->clock()/2; /* get stream channels */ - stream = stream_create(device, 0, 2, device->clock, NULL, channel_update); + stream = stream_create(device, 0, 2, device->clock(), NULL, channel_update); /* allocate the sample cache */ length = memory_region_length(machine, "cvsd") * 16 + MAX_CACHE_ENTRIES * sizeof(sound_cache_entry); @@ -173,8 +173,8 @@ static DEVICE_START( exidy440_sound ) reset_sound_cache(); /* allocate the mixer buffer */ - mixer_buffer_left = auto_alloc_array(machine, INT32, 2 * device->clock); - mixer_buffer_right = mixer_buffer_left + device->clock; + mixer_buffer_left = auto_alloc_array(machine, INT32, 2 * device->clock()); + mixer_buffer_right = mixer_buffer_left + device->clock(); if (SOUND_LOG) debuglog = fopen("sound.log", "w"); @@ -913,7 +913,7 @@ ADDRESS_MAP_END * *************************************/ -static DEVICE_GET_INFO( exidy440_sound ) +DEVICE_GET_INFO( exidy440_sound ) { switch (state) { @@ -928,7 +928,7 @@ static DEVICE_GET_INFO( exidy440_sound ) } -#define SOUND_EXIDY440 DEVICE_GET_INFO_NAME( exidy440_sound ) +DECLARE_LEGACY_SOUND_DEVICE(EXIDY440, exidy440_sound); diff --git a/src/mame/audio/jaguar.c b/src/mame/audio/jaguar.c index e74aed42e0a..806c517e96d 100644 --- a/src/mame/audio/jaguar.c +++ b/src/mame/audio/jaguar.c @@ -370,8 +370,8 @@ static WRITE32_HANDLER( dsp_flags_w ) TIMER_DEVICE_CALLBACK( jaguar_serial_callback ) { /* assert the A2S IRQ on CPU #2 (DSP) */ - cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE); - jaguar_dsp_resume(timer->machine); + cputag_set_input_line(timer.machine, "audiocpu", 1, ASSERT_LINE); + jaguar_dsp_resume(timer.machine); /* fix flaky code in interrupt handler which thwarts our speedup */ if ((jaguar_dsp_ram[0x3e/4] & 0xffff) == 0xbfbc && @@ -389,8 +389,8 @@ TIMER_DEVICE_CALLBACK( jaguar_serial_callback ) TIMER_DEVICE_CALLBACK( jaguar_serial_callback ) { /* assert the A2S IRQ on CPU #2 (DSP) */ - cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE); - jaguar_dsp_resume(timer->machine); + cputag_set_input_line(timer.machine, "audiocpu", 1, ASSERT_LINE); + jaguar_dsp_resume(timer.machine); } #endif @@ -436,7 +436,8 @@ WRITE32_HANDLER( jaguar_serial_w ) if ((data & 0x3f) == 0x15) { attotime rate = attotime_mul(ATTOTIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1)); - timer_device_adjust_periodic(devtag_get_device(space->machine, "serial_timer"), rate, 0, rate); + timer_device *serial_timer = space->machine->device("serial_timer"); + serial_timer->adjust(rate, 0, rate); } break; diff --git a/src/mame/audio/leland.c b/src/mame/audio/leland.c index c75b31ba2bf..086e64cecff 100644 --- a/src/mame/audio/leland.c +++ b/src/mame/audio/leland.c @@ -514,7 +514,7 @@ static TIMER_CALLBACK( dma_timer_callback ); static DEVICE_START( common_sh_start ) { running_machine *machine = device->machine; - const address_space *dmaspace = machine->device("audiocpu")->space(AS_PROGRAM); + const address_space *dmaspace = cputag_get_address_space(machine, "audiocpu", AS_PROGRAM); int i; /* determine which sound hardware is installed */ @@ -651,7 +651,7 @@ static IRQ_CALLBACK( int_callback ) if (LOG_INTERRUPTS) logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time(device->machine)), i80186.intr.poll_status & 0x1f); /* clear the interrupt */ - cpu_set_info(device, CPUINFO_INT_INPUT_STATE + 0, CLEAR_LINE); + cpu_set_input_line(device, 0, CLEAR_LINE); i80186.intr.pending = 0; /* clear the request and set the in-service bit */ diff --git a/src/mame/audio/micro3d.c b/src/mame/audio/micro3d.c index 54b686ef5f9..3ab6f2461dd 100644 --- a/src/mame/audio/micro3d.c +++ b/src/mame/audio/micro3d.c @@ -186,7 +186,7 @@ void micro3d_noise_sh_w(running_machine *machine, UINT8 data) if (~data & 8) { running_device *device = devtag_get_device(machine, data & 4 ? "noise_2" : "noise_1"); - noise_state *nstate = (noise_state *)device->token; + noise_state *nstate = (noise_state *)downcast(device)->token(); if (state->dac_data != nstate->dac[data & 3]) { @@ -213,11 +213,9 @@ void micro3d_noise_sh_w(running_machine *machine, UINT8 data) INLINE noise_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SOUND_MICRO3D); + assert(device->type() == SOUND_MICRO3D); - return (noise_state *)device->token; + return (noise_state *)downcast(device)->token(); } static STREAM_UPDATE( micro3d_stream_update ) diff --git a/src/mame/audio/n8080.c b/src/mame/audio/n8080.c index 2d4095557f8..2987f36d370 100644 --- a/src/mame/audio/n8080.c +++ b/src/mame/audio/n8080.c @@ -437,8 +437,8 @@ static WRITE8_HANDLER( helifire_sound_ctrl_w ) static TIMER_DEVICE_CALLBACK( spacefev_vco_voltage_timer ) { - running_device *sn = devtag_get_device(timer->machine, "snsnd"); - n8080_state *state = (n8080_state *)timer->machine->driver_data; + running_device *sn = devtag_get_device(timer.machine, "snsnd"); + n8080_state *state = (n8080_state *)timer.machine->driver_data; double voltage = 0; if (state->mono_flop[2]) @@ -452,8 +452,8 @@ static TIMER_DEVICE_CALLBACK( spacefev_vco_voltage_timer ) static TIMER_DEVICE_CALLBACK( helifire_dac_volume_timer ) { - n8080_state *state = (n8080_state *)timer->machine->driver_data; - double t = state->helifire_dac_timing - attotime_to_double(timer_get_time(timer->machine)); + n8080_state *state = (n8080_state *)timer.machine->driver_data; + double t = state->helifire_dac_timing - attotime_to_double(timer_get_time(timer.machine)); if (state->helifire_dac_phase) { diff --git a/src/mame/audio/namco52.c b/src/mame/audio/namco52.c index 7d8311d290e..4e466c2e815 100644 --- a/src/mame/audio/namco52.c +++ b/src/mame/audio/namco52.c @@ -64,10 +64,9 @@ struct _namco_52xx_state INLINE namco_52xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_52XX); + assert(device->type() == NAMCO_52XX); - return (namco_52xx_state *)device->token; + return (namco_52xx_state *)downcast(device)->token(); } @@ -80,50 +79,50 @@ static TIMER_CALLBACK( namco_52xx_latch_callback ) static READ8_HANDLER( namco_52xx_K_r ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd & 0x0f; } static READ8_HANDLER( namco_52xx_SI_r ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->si, 0) ? 1 : 0; } static READ8_HANDLER( namco_52xx_R0_r ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->romread, state->address) & 0x0f; } static READ8_HANDLER( namco_52xx_R1_r ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->romread, state->address) >> 4; } static WRITE8_HANDLER( namco_52xx_P_w ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); discrete_sound_w(state->discrete, NAMCO_52XX_P_DATA(state->basenode), data & 0x0f); } static WRITE8_HANDLER( namco_52xx_R2_w ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); state->address = (state->address & 0xfff0) | ((data & 0xf) << 0); } static WRITE8_HANDLER( namco_52xx_R3_w ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); state->address = (state->address & 0xff0f) | ((data & 0xf) << 4); } static WRITE8_HANDLER( namco_52xx_O_w ) { - namco_52xx_state *state = get_safe_token(space->cpu->owner); + namco_52xx_state *state = get_safe_token(space->cpu->owner()); if (data & 0x10) state->address = (state->address & 0x0fff) | ((data & 0xf) << 12); else @@ -201,7 +200,7 @@ ROM_END static DEVICE_START( namco_52xx ) { - namco_52xx_interface *intf = (namco_52xx_interface *)device->baseconfig().static_config; + namco_52xx_interface *intf = (namco_52xx_interface *)device->baseconfig().static_config(); namco_52xx_state *state = get_safe_token(device); astring tempstring; diff --git a/src/mame/audio/namco52.h b/src/mame/audio/namco52.h index eaefde46f85..43fa2c1795b 100644 --- a/src/mame/audio/namco52.h +++ b/src/mame/audio/namco52.h @@ -1,6 +1,7 @@ #ifndef NAMCO52_H #define NAMCO52_H +#include "devlegcy.h" #include "sound/discrete.h" #include "devcb.h" @@ -24,9 +25,7 @@ struct _namco_52xx_interface WRITE8_DEVICE_HANDLER( namco_52xx_write ); -/* device get info callback */ -#define NAMCO_52XX DEVICE_GET_INFO_NAME(namco_52xx) -DEVICE_GET_INFO( namco_52xx ); +DECLARE_LEGACY_DEVICE(NAMCO_52XX, namco_52xx); /* discrete nodes */ diff --git a/src/mame/audio/namco54.c b/src/mame/audio/namco54.c index 6a795a77d68..8779566b2b5 100644 --- a/src/mame/audio/namco54.c +++ b/src/mame/audio/namco54.c @@ -63,10 +63,9 @@ struct _namco_54xx_state INLINE namco_54xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_54XX); + assert(device->type() == NAMCO_54XX); - return (namco_54xx_state *)device->token; + return (namco_54xx_state *)downcast(device)->token(); } @@ -79,20 +78,20 @@ static TIMER_CALLBACK( namco_54xx_latch_callback ) static READ8_HANDLER( namco_54xx_K_r ) { - namco_54xx_state *state = get_safe_token(space->cpu->owner); + namco_54xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd >> 4; } static READ8_HANDLER( namco_54xx_R0_r ) { - namco_54xx_state *state = get_safe_token(space->cpu->owner); + namco_54xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd & 0x0f; } static WRITE8_HANDLER( namco_54xx_O_w ) { - namco_54xx_state *state = get_safe_token(space->cpu->owner); + namco_54xx_state *state = get_safe_token(space->cpu->owner()); UINT8 out = (data & 0x0f); if (data & 0x10) discrete_sound_w(state->discrete, NAMCO_54XX_1_DATA(state->basenode), out); @@ -102,7 +101,7 @@ static WRITE8_HANDLER( namco_54xx_O_w ) static WRITE8_HANDLER( namco_54xx_R1_w ) { - namco_54xx_state *state = get_safe_token(space->cpu->owner); + namco_54xx_state *state = get_safe_token(space->cpu->owner()); UINT8 out = (data & 0x0f); discrete_sound_w(state->discrete, NAMCO_54XX_2_DATA(state->basenode), out); @@ -165,7 +164,7 @@ ROM_END static DEVICE_START( namco_54xx ) { - namco_54xx_config *config = (namco_54xx_config *)device->baseconfig().inline_config; + namco_54xx_config *config = (namco_54xx_config *)downcast(device->baseconfig()).inline_config(); namco_54xx_state *state = get_safe_token(device); astring tempstring; diff --git a/src/mame/audio/namco54.h b/src/mame/audio/namco54.h index 4524891e12c..2343d6b0799 100644 --- a/src/mame/audio/namco54.h +++ b/src/mame/audio/namco54.h @@ -1,6 +1,7 @@ #ifndef NAMCO54_H #define NAMCO54_H +#include "devlegcy.h" #include "sound/discrete.h" @@ -21,9 +22,7 @@ struct _namco_54xx_config WRITE8_DEVICE_HANDLER( namco_54xx_write ); -/* device get info callback */ -#define NAMCO_54XX DEVICE_GET_INFO_NAME(namco_54xx) -DEVICE_GET_INFO( namco_54xx ); +DECLARE_LEGACY_DEVICE(NAMCO_54XX, namco_54xx); /* discrete nodes */ diff --git a/src/mame/audio/segag80r.c b/src/mame/audio/segag80r.c index 3046109cd66..b6e0cdc7517 100644 --- a/src/mame/audio/segag80r.c +++ b/src/mame/audio/segag80r.c @@ -28,8 +28,9 @@ #define SEGA005_555_TIMER_FREQ (1.44 / ((15000 + 2 * 4700) * 1.5e-6)) #define SEGA005_COUNTER_FREQ (100000) /* unknown, just a guess */ -static DEVICE_GET_INFO( sega005_sound ); -#define SOUND_005 DEVICE_GET_INFO_NAME(sega005_sound) +DEVICE_GET_INFO( sega005_sound ); + +DECLARE_LEGACY_SOUND_DEVICE(005, sega005_sound); @@ -589,7 +590,7 @@ static DEVICE_START( sega005_sound ) } -static DEVICE_GET_INFO( sega005_sound ) +DEVICE_GET_INFO( sega005_sound ) { switch (state) { diff --git a/src/mame/audio/segasnd.c b/src/mame/audio/segasnd.c index 77d0a0eed66..62508a78307 100644 --- a/src/mame/audio/segasnd.c +++ b/src/mame/audio/segasnd.c @@ -729,7 +729,7 @@ static DEVICE_START( usb_sound ) } -static DEVICE_GET_INFO( usb_sound ) +DEVICE_GET_INFO( usb_sound ) { switch (state) { @@ -742,7 +742,7 @@ static DEVICE_GET_INFO( usb_sound ) } } -#define SOUND_USB DEVICE_GET_INFO_NAME(usb_sound) +DECLARE_LEGACY_SOUND_DEVICE(USB, usb_sound); diff --git a/src/mame/audio/seibu.c b/src/mame/audio/seibu.c index c0ce83596ec..ea25898714c 100644 --- a/src/mame/audio/seibu.c +++ b/src/mame/audio/seibu.c @@ -133,7 +133,7 @@ void seibu_sound_decrypt(running_machine *machine,const char *cpu,int length) typedef struct _seibu_adpcm_state seibu_adpcm_state; struct _seibu_adpcm_state { - struct adpcm_state adpcm; + adpcm_state adpcm; sound_stream *stream; UINT32 current, end; UINT8 nibble; @@ -159,7 +159,7 @@ static STREAM_UPDATE( seibu_adpcm_callback ) state->playing = 0; } - *dest++ = clock_adpcm(&state->adpcm, val) << 4; + *dest++ = state->adpcm.clock(val) << 4; samples--; } while (samples > 0) @@ -172,12 +172,12 @@ static STREAM_UPDATE( seibu_adpcm_callback ) static DEVICE_START( seibu_adpcm ) { running_machine *machine = device->machine; - seibu_adpcm_state *state = (seibu_adpcm_state *)device->token; + seibu_adpcm_state *state = (seibu_adpcm_state *)downcast(device)->token(); state->playing = 0; - state->stream = stream_create(device, 0, 1, device->clock, state, seibu_adpcm_callback); + state->stream = stream_create(device, 0, 1, device->clock(), state, seibu_adpcm_callback); state->base = memory_region(machine, "adpcm"); - reset_adpcm(&state->adpcm); + state->adpcm.reset(); } DEVICE_GET_INFO( seibu_adpcm ) @@ -215,7 +215,7 @@ void seibu_adpcm_decrypt(running_machine *machine, const char *region) WRITE8_DEVICE_HANDLER( seibu_adpcm_adr_w ) { - seibu_adpcm_state *state = (seibu_adpcm_state *)device->token; + seibu_adpcm_state *state = (seibu_adpcm_state *)downcast(device)->token(); if (state->stream) stream_update(state->stream); @@ -232,7 +232,7 @@ WRITE8_DEVICE_HANDLER( seibu_adpcm_adr_w ) WRITE8_DEVICE_HANDLER( seibu_adpcm_ctl_w ) { - seibu_adpcm_state *state = (seibu_adpcm_state *)device->token; + seibu_adpcm_state *state = (seibu_adpcm_state *)downcast(device)->token(); // sequence is 00 02 01 each time. if (state->stream) diff --git a/src/mame/audio/seibu.h b/src/mame/audio/seibu.h index 25ddbeef89f..2c69bcd96cb 100644 --- a/src/mame/audio/seibu.h +++ b/src/mame/audio/seibu.h @@ -23,6 +23,7 @@ ***************************************************************************/ +#include "devlegcy.h" #include "cpu/z80/z80.h" #include "sound/3812intf.h" #include "sound/2151intf.h" @@ -60,8 +61,7 @@ void seibu_adpcm_decrypt(running_machine *machine, const char *region); WRITE8_DEVICE_HANDLER( seibu_adpcm_adr_w ); WRITE8_DEVICE_HANDLER( seibu_adpcm_ctl_w ); -DEVICE_GET_INFO( seibu_adpcm ); -#define SOUND_SEIBU_ADPCM DEVICE_GET_INFO_NAME(seibu_adpcm) +DECLARE_LEGACY_SOUND_DEVICE(SEIBU_ADPCM, seibu_adpcm); extern const ym3812_interface seibu_ym3812_interface; extern const ym2151_interface seibu_ym2151_interface; @@ -102,8 +102,7 @@ extern const ym2203_interface seibu_ym2203_interface; MDRV_SOUND_CONFIG(seibu_ym3812_interface) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) \ \ - MDRV_SOUND_ADD("oki", OKIM6295, freq2) \ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) \ + MDRV_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_LOW) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) \ #define SEIBU_SOUND_SYSTEM_YM3812_RAIDEN_INTERFACE(freq1,freq2) \ @@ -113,8 +112,7 @@ extern const ym2203_interface seibu_ym2203_interface; MDRV_SOUND_CONFIG(seibu_ym3812_interface) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) \ \ - MDRV_SOUND_ADD("oki", OKIM6295, freq2) \ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) \ + MDRV_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_HIGH) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) \ #define SEIBU_SOUND_SYSTEM_YM2151_INTERFACE(freq1,freq2) \ @@ -125,8 +123,7 @@ extern const ym2203_interface seibu_ym2203_interface; MDRV_SOUND_ROUTE(0, "mono", 0.50) \ MDRV_SOUND_ROUTE(1, "mono", 0.50) \ \ - MDRV_SOUND_ADD("oki", OKIM6295, freq2) \ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) \ + MDRV_OKIM6295_ADD("oki", freq2, OKIM6295_PIN7_LOW) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) \ @@ -138,12 +135,10 @@ extern const ym2203_interface seibu_ym2203_interface; MDRV_SOUND_ROUTE(0, "mono", 0.50) \ MDRV_SOUND_ROUTE(1, "mono", 0.50) \ \ - MDRV_SOUND_ADD("oki1", OKIM6295, freq2) \ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) \ + MDRV_OKIM6295_ADD("oki1", freq2, OKIM6295_PIN7_HIGH) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) \ \ - MDRV_SOUND_ADD("oki2", OKIM6295, freq2) \ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) \ + MDRV_OKIM6295_ADD("oki2", freq2, OKIM6295_PIN7_HIGH) \ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) \ diff --git a/src/mame/audio/senjyo.c b/src/mame/audio/senjyo.c index 383b2929994..4f1934261e7 100644 --- a/src/mame/audio/senjyo.c +++ b/src/mame/audio/senjyo.c @@ -12,7 +12,7 @@ static int single_rate = 0; static int single_volume = 0; UINT8 senjyo_sound_cmd; -const z80_daisy_chain senjyo_daisy_chain[] = +const z80_daisy_config senjyo_daisy_chain[] = { { "z80ctc" }, { "z80pio" }, @@ -51,7 +51,7 @@ Z80CTC_INTERFACE( senjyo_ctc_intf ) WRITE8_HANDLER( senjyo_volume_w ) { - running_device *samples = devtag_get_device(space->machine, "samples"); + samples_sound_device *samples = space->machine->device("samples"); single_volume = data & 0x0f; sample_set_volume(samples,0,single_volume / 15.0); } @@ -62,7 +62,8 @@ static TIMER_CALLBACK( senjyo_sh_update ) running_device *samples = devtag_get_device(machine, "samples"); /* ctc2 timer single tone generator frequency */ - attotime period = z80ctc_getperiod (devtag_get_device(machine, "z80ctc"), 2); + z80ctc_device *ctc = machine->device("z80ctc"); + attotime period = ctc->period(2); if (attotime_compare(period, attotime_zero) != 0 ) single_rate = ATTOSECONDS_TO_HZ(period.attoseconds); else @@ -88,5 +89,5 @@ SAMPLES_START( senjyo_sh_start ) sample_set_volume(device,0,single_volume / 15.0); sample_start_raw(device,0,_single,SINGLE_LENGTH,single_rate,1); - timer_pulse(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, senjyo_sh_update); + timer_pulse(machine, machine->primary_screen->frame_period(), NULL, 0, senjyo_sh_update); } diff --git a/src/mame/audio/snes_snd.c b/src/mame/audio/snes_snd.c index 7d289d20471..987d4313bb8 100644 --- a/src/mame/audio/snes_snd.c +++ b/src/mame/audio/snes_snd.c @@ -235,11 +235,9 @@ struct _snes_sound_state INLINE snes_sound_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SOUND); - assert(sound_get_type(device) == SNES_SPC); + assert(device->type() == SNES_SPC); - return (snes_sound_state *)device->token; + return (snes_sound_state *)downcast(device)->token(); } /***************************************************************************** diff --git a/src/mame/audio/snes_snd.h b/src/mame/audio/snes_snd.h index 4f6e969673c..0a93b3ff2e0 100644 --- a/src/mame/audio/snes_snd.h +++ b/src/mame/audio/snes_snd.h @@ -12,18 +12,13 @@ #define SNES_SPCRAM_SIZE 0x10000 -/*************************************************************************** - INFO PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( snes_sound ); - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define SNES_SPC DEVICE_GET_INFO_NAME( snes_sound ) -#define SOUND_SNES SNES_SPC +DECLARE_LEGACY_SOUND_DEVICE(SNES, snes_sound); +#define SNES_SPC SOUND_SNES + /*************************************************************************** I/O PROTOTYPES diff --git a/src/mame/audio/taito_en.c b/src/mame/audio/taito_en.c index a88824958d0..15401e5e52e 100644 --- a/src/mame/audio/taito_en.c +++ b/src/mame/audio/taito_en.c @@ -74,8 +74,8 @@ static TIMER_DEVICE_CALLBACK( taito_en_timer_callback ) /* Only cause IRQ if the mask is set to allow it */ if (m68681_imr & 0x08) { - cpu_set_input_line_vector(devtag_get_device(timer->machine, "audiocpu"), 6, vector_reg); - cputag_set_input_line(timer->machine, "audiocpu", 6, ASSERT_LINE); + cpu_set_input_line_vector(devtag_get_device(timer.machine, "audiocpu"), 6, vector_reg); + cputag_set_input_line(timer.machine, "audiocpu", 6, ASSERT_LINE); imr_status |= 0x08; } } @@ -104,6 +104,7 @@ static READ16_HANDLER(f3_68681_r) static WRITE16_HANDLER(f3_68681_w) { + timer_device *timer; switch (offset) { case 0x04: /* ACR */ switch ((data>>4)&7) { @@ -119,7 +120,8 @@ static WRITE16_HANDLER(f3_68681_w) case 3: logerror("Counter: X1/Clk - divided by 16, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter*16); timer_mode=TIMER_SINGLESHOT; - timer_device_adjust_oneshot(devtag_get_device(space->machine, "timer_68681"), cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter*16), 0); + timer = space->machine->device("timer_68681"); + timer->adjust(cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter*16)); break; case 4: logerror("Timer: Unimplemented external IP2\n"); @@ -130,7 +132,8 @@ static WRITE16_HANDLER(f3_68681_w) case 6: logerror("Timer: X1/Clk, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter); timer_mode=TIMER_PULSE; - timer_device_adjust_periodic(devtag_get_device(space->machine, "timer_68681"), cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter), 0, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter)); + timer = space->machine->device("timer_68681"); + timer->adjust(cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter), 0, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter)); break; case 7: logerror("Timer: Unimplemented X1/Clk - divided by 16\n"); diff --git a/src/mame/audio/taitosnd.c b/src/mame/audio/taitosnd.c index 7c33f0536e9..53adea58c0d 100644 --- a/src/mame/audio/taitosnd.c +++ b/src/mame/audio/taitosnd.c @@ -45,17 +45,16 @@ struct _tc0140syt_state INLINE tc0140syt_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0140SYT); + assert(device->type() == TC0140SYT); - return (tc0140syt_state *)device->token; + return (tc0140syt_state *)downcast(device)->token(); } INLINE const tc0140syt_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0140SYT)); - return (const tc0140syt_interface *) device->baseconfig().static_config; + assert((device->type() == TC0140SYT)); + return (const tc0140syt_interface *) device->baseconfig().static_config(); } /***************************************************************************** diff --git a/src/mame/audio/taitosnd.h b/src/mame/audio/taitosnd.h index 6bc043b46a9..5e593ed37c1 100644 --- a/src/mame/audio/taitosnd.h +++ b/src/mame/audio/taitosnd.h @@ -1,6 +1,7 @@ #ifndef __TAITOSND_H__ #define __TAITOSND_H__ +#include "devlegcy.h" #include "devcb.h" /*************************************************************************** @@ -14,18 +15,12 @@ struct _tc0140syt_interface const char *slave; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( tc0140syt ); +DECLARE_LEGACY_DEVICE(TC0140SYT, tc0140syt); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define TC0140SYT DEVICE_GET_INFO_NAME( tc0140syt ) - #define MDRV_TC0140SYT_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0140SYT, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/audio/tiamc1.c b/src/mame/audio/tiamc1.c index 32dde518267..ced5453cc6c 100644 --- a/src/mame/audio/tiamc1.c +++ b/src/mame/audio/tiamc1.c @@ -288,7 +288,7 @@ static DEVICE_START( tiamc1_sound ) timer8253_reset(&timer0); timer8253_reset(&timer1); - channel = stream_create(device, 0, 1, device->clock / CLOCK_DIVIDER, 0, tiamc1_sound_update); + channel = stream_create(device, 0, 1, device->clock() / CLOCK_DIVIDER, 0, tiamc1_sound_update); timer1_divider = 0; diff --git a/src/mame/audio/williams.c b/src/mame/audio/williams.c index 13577c2a4e0..f543fd1b6ea 100644 --- a/src/mame/audio/williams.c +++ b/src/mame/audio/williams.c @@ -254,8 +254,7 @@ MACHINE_DRIVER_START( williams_adpcm_sound ) MDRV_SOUND_ADD("dac", DAC, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, ADPCM_MASTER_CLOCK/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", ADPCM_MASTER_CLOCK/8, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END @@ -634,7 +633,7 @@ static WRITE8_HANDLER( adpcm_bank_select_w ) static WRITE8_DEVICE_HANDLER( adpcm_6295_bank_select_w ) { - okim6295_set_bank_base(device, (data & 7) * 0x40000); + downcast(device)->set_bank_base((data & 7) * 0x40000); } diff --git a/src/mame/drivers/1945kiii.c b/src/mame/drivers/1945kiii.c index 577a36275e6..73a4bfeae9d 100644 --- a/src/mame/drivers/1945kiii.c +++ b/src/mame/drivers/1945kiii.c @@ -52,7 +52,9 @@ class k3_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, k3_state(machine)); } - k3_state(running_machine &machine) { } + k3_state(running_machine &machine) + : oki1(machine.device("oki1")), + oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * spriteram_1; @@ -64,8 +66,8 @@ public: tilemap_t *bg_tilemap; /* devices */ - running_device *oki1; - running_device *oki2; + okim6295_device *oki1; + okim6295_device *oki2; }; @@ -139,8 +141,8 @@ static WRITE16_HANDLER( k3_scrolly_w ) static WRITE16_HANDLER( k3_soundbanks_w ) { k3_state *state = (k3_state *)space->machine->driver_data; - okim6295_set_bank_base(state->oki1, (data & 4) ? 0x40000 : 0); - okim6295_set_bank_base(state->oki2, (data & 2) ? 0x40000 : 0); + state->oki1->set_bank_base((data & 4) ? 0x40000 : 0); + state->oki2->set_bank_base((data & 2) ? 0x40000 : 0); } static ADDRESS_MAP_START( k3_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -246,10 +248,6 @@ GFXDECODE_END static MACHINE_START( 1945kiii ) { - k3_state *state = (k3_state *)machine->driver_data; - - state->oki1 = devtag_get_device(machine, "oki1"); - state->oki2 = devtag_get_device(machine, "oki2"); } static MACHINE_DRIVER_START( k3 ) @@ -278,12 +276,10 @@ static MACHINE_DRIVER_START( k3 ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, MASTER_CLOCK/16) /* dividers? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", MASTER_CLOCK/16, OKIM6295_PIN7_HIGH) /* dividers? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, MASTER_CLOCK/16) /* dividers? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", MASTER_CLOCK/16, OKIM6295_PIN7_HIGH) /* dividers? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/39in1.c b/src/mame/drivers/39in1.c index 511855bbbc0..a5273295258 100644 --- a/src/mame/drivers/39in1.c +++ b/src/mame/drivers/39in1.c @@ -47,8 +47,8 @@ public: PXA255_GPIO_Regs gpio_regs; PXA255_LCD_Regs lcd_regs; - running_device *dmadac[2]; - running_device *eeprom; + dmadac_sound_device *dmadac[2]; + eeprom_device *eeprom; UINT32 pxa255_lcd_palette[0x100]; UINT8 pxa255_lcd_framebuffer[0x100000]; @@ -1451,9 +1451,9 @@ static DRIVER_INIT( 39in1 ) { _39in1_state *state = (_39in1_state *)machine->driver_data; - state->dmadac[0] = devtag_get_device(machine, "dac1"); - state->dmadac[1] = devtag_get_device(machine, "dac2"); - state->eeprom = devtag_get_device(machine, "eeprom"); + state->dmadac[0] = machine->device("dac1"); + state->dmadac[1] = machine->device("dac2"); + state->eeprom = machine->device("eeprom"); memory_install_read32_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa0151648, 0xa015164b, 0, 0, prot_cheater_r); } @@ -1532,7 +1532,7 @@ static void pxa255_start(running_machine* machine) //pxa255_t* pxa255 = pxa255_get_safe_token( device ); - //pxa255->iface = device->base_config().static_config; + //pxa255->iface = device->base_config().static_config(); for(index = 0; index < 16; index++) { diff --git a/src/mame/drivers/3super8.c b/src/mame/drivers/3super8.c index 6d22e2a2979..65bc2d76422 100644 --- a/src/mame/drivers/3super8.c +++ b/src/mame/drivers/3super8.c @@ -87,8 +87,7 @@ static MACHINE_DRIVER_START( 3super8 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/5clown.c b/src/mame/drivers/5clown.c index cfe5fb4fd51..b688ef9d21e 100644 --- a/src/mame/drivers/5clown.c +++ b/src/mame/drivers/5clown.c @@ -1066,8 +1066,7 @@ static MACHINE_DRIVER_START( fclown ) MDRV_SOUND_CONFIG(ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) - MDRV_SOUND_ADD("oki6295", OKIM6295, MASTER_CLOCK/12) /* guess, seems ok */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* pin7 guessed, seems ok */ + MDRV_OKIM6295_ADD("oki6295", MASTER_CLOCK/12, OKIM6295_PIN7_LOW) /* guess, seems ok; pin7 guessed, seems ok */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.20) MACHINE_DRIVER_END diff --git a/src/mame/drivers/acefruit.c b/src/mame/drivers/acefruit.c index 90d2181f667..0329646cab7 100644 --- a/src/mame/drivers/acefruit.c +++ b/src/mame/drivers/acefruit.c @@ -39,14 +39,14 @@ static emu_timer *acefruit_refresh_timer; static TIMER_CALLBACK( acefruit_refresh ) { - int vpos = video_screen_get_vpos(machine->primary_screen); + int vpos = machine->primary_screen->vpos(); - video_screen_update_partial(machine->primary_screen, vpos ); + machine->primary_screen->update_partial(vpos ); acefruit_update_irq(machine, vpos ); vpos = ( ( vpos / 8 ) + 1 ) * 8; - timer_adjust_oneshot( acefruit_refresh_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0 ), 0 ); + timer_adjust_oneshot( acefruit_refresh_timer, machine->primary_screen->time_until_pos(vpos), 0 ); } static VIDEO_START( acefruit ) diff --git a/src/mame/drivers/acommand.c b/src/mame/drivers/acommand.c index 01f9523217e..c3ba6bd2865 100644 --- a/src/mame/drivers/acommand.c +++ b/src/mame/drivers/acommand.c @@ -376,8 +376,10 @@ static WRITE16_HANDLER(ac_devices_w) case 0x00/2: if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(devtag_get_device(space->machine, "oki1"), 0x40000 * (data & 0x3)); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x40000 * (data & 0x30) >> 4); + okim6295_device *oki1 = space->machine->device("oki1"); + okim6295_device *oki2 = space->machine->device("oki2"); + oki1->set_bank_base(0x40000 * (data & 0x3)); + oki2->set_bank_base(0x40000 * (data & 0x30) >> 4); } break; case 0x14/2: @@ -579,13 +581,11 @@ static MACHINE_DRIVER_START( acommand ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/actfancr.c b/src/mame/drivers/actfancr.c index f489410325f..8caeb9ec022 100644 --- a/src/mame/drivers/actfancr.c +++ b/src/mame/drivers/actfancr.c @@ -360,8 +360,7 @@ static MACHINE_DRIVER_START( actfancr ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) - MDRV_SOUND_ADD("oki", OKIM6295, 1024188) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1024188, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.85) MACHINE_DRIVER_END @@ -409,8 +408,7 @@ static MACHINE_DRIVER_START( triothep ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1_056MHz) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.85) MACHINE_DRIVER_END diff --git a/src/mame/drivers/adp.c b/src/mame/drivers/adp.c index a64e5d1168d..27cf4312fb2 100644 --- a/src/mame/drivers/adp.c +++ b/src/mame/drivers/adp.c @@ -419,15 +419,15 @@ static READ8_DEVICE_HANDLER(t2_r) static UINT8 res; static int h,w; res = 0; - h = video_screen_get_height(device->machine->primary_screen); - w = video_screen_get_width(device->machine->primary_screen); + h = device->machine->primary_screen->height(); + w = device->machine->primary_screen->width(); // popmessage("%d %d",h,w); - if (video_screen_get_hpos(device->machine->primary_screen) > h) + if (device->machine->primary_screen->hpos() > h) res|= 0x20; //hblank - if (video_screen_get_vpos(device->machine->primary_screen) > w) + if (device->machine->primary_screen->vpos() > w) res|= 0x40; //vblank return res; diff --git a/src/mame/drivers/aerofgt.c b/src/mame/drivers/aerofgt.c index a1c64954c41..6da0b3f2eca 100644 --- a/src/mame/drivers/aerofgt.c +++ b/src/mame/drivers/aerofgt.c @@ -118,14 +118,18 @@ static WRITE8_HANDLER( aerofgt_sh_bankswitch_w ) static WRITE16_DEVICE_HANDLER( pspikesb_oki_banking_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 3)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 3)); } /*TODO: sound banking. */ static WRITE16_DEVICE_HANDLER( aerfboo2_okim6295_banking_w ) { // if(ACCESSING_BITS_8_15) -// okim6295_set_bank_base(device, 0x40000 * ((data & 0xf00)>>8)); +// { +// okim6295_device *oki = downcast(device); +// oki->set_bank_base(0x40000 * ((data & 0xf00)>>8)); +// } } static WRITE8_HANDLER( aerfboot_okim6295_banking_w ) @@ -1432,8 +1436,7 @@ static MACHINE_DRIVER_START( pspikesb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1466,8 +1469,7 @@ static MACHINE_DRIVER_START( pspikesc ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1716,8 +1718,7 @@ static MACHINE_DRIVER_START( aerfboot ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1751,8 +1752,7 @@ static MACHINE_DRIVER_START( aerfboo2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1793,8 +1793,7 @@ static MACHINE_DRIVER_START( wbbc97 ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/airbustr.c b/src/mame/drivers/airbustr.c index c0d12fd8964..22665d69e63 100644 --- a/src/mame/drivers/airbustr.c +++ b/src/mame/drivers/airbustr.c @@ -683,8 +683,7 @@ static MACHINE_DRIVER_START( airbustr ) MDRV_SOUND_ROUTE(2, "mono", 0.25) MDRV_SOUND_ROUTE(3, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 12000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/alg.c b/src/mame/drivers/alg.c index 6f2f40b2e20..46482ae3b43 100644 --- a/src/mame/drivers/alg.c +++ b/src/mame/drivers/alg.c @@ -43,18 +43,18 @@ static TIMER_CALLBACK( response_timer ); * *************************************/ -static int get_lightgun_pos(running_device *screen, int player, int *x, int *y) +static int get_lightgun_pos(screen_device &screen, int player, int *x, int *y) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); - int xpos = input_port_read_safe(screen->machine, (player == 0) ? "GUN1X" : "GUN2X", 0xffffffff); - int ypos = input_port_read_safe(screen->machine, (player == 0) ? "GUN1Y" : "GUN2Y", 0xffffffff); + int xpos = input_port_read_safe(screen.machine, (player == 0) ? "GUN1X" : "GUN2X", 0xffffffff); + int ypos = input_port_read_safe(screen.machine, (player == 0) ? "GUN1Y" : "GUN2Y", 0xffffffff); if (xpos == -1 || ypos == -1) return FALSE; - *x = visarea->min_x + xpos * (visarea->max_x - visarea->min_x + 1) / 255; - *y = visarea->min_y + ypos * (visarea->max_y - visarea->min_y + 1) / 255; + *x = visarea.min_x + xpos * (visarea.max_x - visarea.min_x + 1) / 255; + *y = visarea.min_y + ypos * (visarea.max_y - visarea.min_y + 1) / 255; return TRUE; } @@ -170,7 +170,7 @@ static CUSTOM_INPUT( lightgun_pos_r ) int x = 0, y = 0; /* get the position based on the input select */ - get_lightgun_pos(field->port->machine->primary_screen, input_select, &x, &y); + get_lightgun_pos(*field->port->machine->primary_screen, input_select, &x, &y); return (y << 8) | (x >> 2); } diff --git a/src/mame/drivers/aquarium.c b/src/mame/drivers/aquarium.c index db5f4084de6..2018d1d1bf5 100644 --- a/src/mame/drivers/aquarium.c +++ b/src/mame/drivers/aquarium.c @@ -395,8 +395,7 @@ static MACHINE_DRIVER_START( aquarium ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/arcadecl.c b/src/mame/drivers/arcadecl.c index 26ce4c23c65..185b27c60cd 100644 --- a/src/mame/drivers/arcadecl.c +++ b/src/mame/drivers/arcadecl.c @@ -88,11 +88,11 @@ static void update_interrupts(running_machine *machine) } -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { /* generate 32V signals */ if ((scanline & 32) == 0) - atarigen_scanline_int_gen(devtag_get_device(screen->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(screen.machine, "maincpu")); } @@ -115,7 +115,7 @@ static MACHINE_RESET( arcadecl ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 32); } @@ -137,7 +137,8 @@ static WRITE16_HANDLER( latch_w ) /* lower byte being modified? */ if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x80) ? 0x40000 : 0x00000); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x80) ? 0x40000 : 0x00000); atarigen_set_oki6295_vol(space->machine, (data & 0x001f) * 100 / 0x1f); } } @@ -351,8 +352,7 @@ static MACHINE_DRIVER_START( arcadecl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MASTER_CLOCK/4/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", MASTER_CLOCK/4/3, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/artmagic.c b/src/mame/drivers/artmagic.c index a793898bcc4..10336a76c99 100644 --- a/src/mame/drivers/artmagic.c +++ b/src/mame/drivers/artmagic.c @@ -129,7 +129,10 @@ static WRITE16_HANDLER( control_w ) /* OKI banking here */ if (offset == 0) - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (((data >> 4) & 1) * 0x40000) % memory_region_length(space->machine, "oki")); + { + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((((data >> 4) & 1) * 0x40000) % oki->region()->bytes()); + } logerror("%06X:control_w(%d) = %04X\n", cpu_get_pc(space->cpu), offset, data); } @@ -729,8 +732,7 @@ static MACHINE_DRIVER_START( artmagic ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MASTER_CLOCK_40MHz/3/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", MASTER_CLOCK_40MHz/3/10, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.65) MACHINE_DRIVER_END diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index 6c5bf82c304..e681ee29cdb 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -217,7 +217,7 @@ static TIMER_CALLBACK( kamizake_int_gen ) /* interrupts are asserted on every state change of the 128V line */ cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); param ^= 128; - timer_adjust_oneshot(state->int_timer, video_screen_get_time_until_pos(machine->primary_screen, param, 0), param); + timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(param), param); /* an RC circuit turns the interrupt off after a short amount of time */ timer_set(machine, double_to_attotime(300 * 0.1e-6), NULL, 0, kamikaze_int_off); @@ -234,7 +234,7 @@ static MACHINE_START( kamikaze ) state->samples = devtag_get_device(machine, "samples"); state->int_timer = timer_alloc(machine, kamizake_int_gen, NULL); - timer_adjust_oneshot(state->int_timer, video_screen_get_time_until_pos(machine->primary_screen, 128, 0), 128); + timer_adjust_oneshot(state->int_timer, machine->primary_screen->time_until_pos(128), 128); state_save_register_global(machine, state->screen_flip); state_save_register_global(machine, state->screen_red); diff --git a/src/mame/drivers/astrocde.c b/src/mame/drivers/astrocde.c index 039a0cd90e8..f400948ce03 100644 --- a/src/mame/drivers/astrocde.c +++ b/src/mame/drivers/astrocde.c @@ -1256,7 +1256,7 @@ static const samples_interface gorf_samples_interface = * *************************************/ -static const z80_daisy_chain tenpin_daisy_chain[] = +static const z80_daisy_config tenpin_daisy_chain[] = { { "ctc" }, { NULL } diff --git a/src/mame/drivers/astrocorp.c b/src/mame/drivers/astrocorp.c index 8d28b54a15c..5812a7ba154 100644 --- a/src/mame/drivers/astrocorp.c +++ b/src/mame/drivers/astrocorp.c @@ -60,7 +60,7 @@ static VIDEO_START( astrocorp ) { astrocorp_state *state = (astrocorp_state *)machine->driver_data; - state->bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->bitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->bitmap); state_save_register_global (machine, state->screen_enable); @@ -163,7 +163,7 @@ static WRITE16_HANDLER( astrocorp_draw_sprites_w ) UINT16 now = COMBINE_DATA(&state->draw_sprites); if (!old && now) - draw_sprites(space->machine, state->bitmap, video_screen_get_visible_area(space->machine->primary_screen)); + draw_sprites(space->machine, state->bitmap, &space->machine->primary_screen->visible_area()); } static WRITE16_HANDLER( astrocorp_eeprom_w ) @@ -178,7 +178,8 @@ static WRITE16_DEVICE_HANDLER( astrocorp_sound_bank_w ) { if (ACCESSING_BITS_8_15) { - okim6295_set_bank_base(device, 0x40000 * ((data >> 8) & 1)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * ((data >> 8) & 1)); // logerror("CPU #0 PC %06X: OKI bank %08X\n", cpu_get_pc(space->cpu), data); } } @@ -187,7 +188,8 @@ static WRITE16_DEVICE_HANDLER( skilldrp_sound_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 1)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 1)); // logerror("CPU #0 PC %06X: OKI bank %08X\n", cpu_get_pc(space->cpu), data); } } @@ -473,8 +475,7 @@ static MACHINE_DRIVER_START( showhand ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz/20) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz/20, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -528,8 +529,7 @@ static MACHINE_DRIVER_START( skilldrp ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_24MHz/24) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_24MHz/24, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/astrof.c b/src/mame/drivers/astrof.c index de28572ebba..1df7fe125f0 100644 --- a/src/mame/drivers/astrof.c +++ b/src/mame/drivers/astrof.c @@ -90,7 +90,7 @@ static READ8_HANDLER( irq_clear_r ) static TIMER_DEVICE_CALLBACK( irq_callback ) { - astrof_state *state = (astrof_state *)timer->machine->driver_data; + astrof_state *state = (astrof_state *)timer.machine->driver_data; cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); } @@ -310,7 +310,7 @@ static WRITE8_HANDLER( video_control_1_w ) /* D2 - not connected in the schematics, but at one point Astro Fighter sets it to 1 */ /* D3-D7 - not connected */ - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -333,7 +333,7 @@ static void astrof_set_video_control_2( running_machine *machine, UINT8 data ) static WRITE8_HANDLER( astrof_video_control_2_w ) { astrof_set_video_control_2(space->machine, data); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -353,7 +353,7 @@ static void spfghmk2_set_video_control_2( running_machine *machine, UINT8 data ) static WRITE8_HANDLER( spfghmk2_video_control_2_w ) { spfghmk2_set_video_control_2(space->machine, data); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -372,7 +372,7 @@ static void tomahawk_set_video_control_2( running_machine *machine, UINT8 data ) static WRITE8_HANDLER( tomahawk_video_control_2_w ) { tomahawk_set_video_control_2(space->machine, data); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } diff --git a/src/mame/drivers/atarig1.c b/src/mame/drivers/atarig1.c index d08f6b90d8f..d7e65b1a031 100644 --- a/src/mame/drivers/atarig1.c +++ b/src/mame/drivers/atarig1.c @@ -55,7 +55,7 @@ static MACHINE_RESET( atarig1 ) atarigen_eeprom_reset(&state->atarigen); atarigen_slapstic_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, atarig1_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, atarig1_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/atarig42.c b/src/mame/drivers/atarig42.c index 82054e56c1f..e14a79096cc 100644 --- a/src/mame/drivers/atarig42.c +++ b/src/mame/drivers/atarig42.c @@ -58,7 +58,7 @@ static MACHINE_RESET( atarig42 ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, atarig42_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, atarig42_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/atarigt.c b/src/mame/drivers/atarigt.c index 7be29954eee..9551e62317e 100644 --- a/src/mame/drivers/atarigt.c +++ b/src/mame/drivers/atarigt.c @@ -68,7 +68,7 @@ static MACHINE_RESET( atarigt ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, atarigt_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, atarigt_scanline_update, 8); } diff --git a/src/mame/drivers/atarigx2.c b/src/mame/drivers/atarigx2.c index 32f33217a29..72a5e9701e2 100644 --- a/src/mame/drivers/atarigx2.c +++ b/src/mame/drivers/atarigx2.c @@ -53,7 +53,7 @@ static MACHINE_RESET( atarigx2 ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, atarigx2_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, atarigx2_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/atarisy1.c b/src/mame/drivers/atarisy1.c index e2632c3e494..592d54de095 100644 --- a/src/mame/drivers/atarisy1.c +++ b/src/mame/drivers/atarisy1.c @@ -219,7 +219,6 @@ static MACHINE_RESET( atarisy1 ) /* reset the joystick parameters */ state->joystick_value = 0; - state->joystick_timer = devtag_get_device(machine, "joystick_timer"); state->joystick_int = 0; state->joystick_int_enable = 0; } @@ -234,10 +233,10 @@ static MACHINE_RESET( atarisy1 ) static TIMER_DEVICE_CALLBACK( delayed_joystick_int ) { - atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer.machine->driver_data; state->joystick_value = param; state->joystick_int = 1; - atarigen_update_interrupts(timer->machine); + atarigen_update_interrupts(timer.machine); } @@ -264,7 +263,7 @@ static READ16_HANDLER( joystick_r ) /* clear any existing interrupt and set a timer for a new one */ state->joystick_int = 0; - timer_device_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval); + state->joystick_timer->adjust(ATTOTIME_IN_USEC(50), newval); atarigen_update_interrupts(space->machine); return state->joystick_value; diff --git a/src/mame/drivers/atarisy2.c b/src/mame/drivers/atarisy2.c index e3822343335..2cd19b1d403 100644 --- a/src/mame/drivers/atarisy2.c +++ b/src/mame/drivers/atarisy2.c @@ -188,15 +188,15 @@ static void update_interrupts(running_machine *machine) * *************************************/ -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { - atarisy2_state *state = (atarisy2_state *)screen->machine->driver_data; - if (scanline <= video_screen_get_height(screen)) + atarisy2_state *state = (atarisy2_state *)screen.machine->driver_data; + if (scanline <= screen.height()) { /* generate the 32V interrupt (IRQ 2) */ if ((scanline % 64) == 0) if (state->interrupt_enable & 4) - atarigen_scanline_int_gen(devtag_get_device(screen->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(screen.machine, "maincpu")); } } @@ -244,7 +244,7 @@ static MACHINE_RESET( atarisy2 ) slapstic_reset(); atarigen_interrupt_reset(&state->atarigen, update_interrupts); atarigen_sound_io_reset(devtag_get_device(machine, "soundcpu")); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 64); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 64); memory_set_direct_update_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), atarisy2_direct_handler); state->p2portwr_state = 0; diff --git a/src/mame/drivers/atetris.c b/src/mame/drivers/atetris.c index 07ef5f9c599..24bda37117a 100644 --- a/src/mame/drivers/atetris.c +++ b/src/mame/drivers/atetris.c @@ -85,7 +85,7 @@ static TIMER_CALLBACK( interrupt_gen ) scanline += 32; if (scanline >= 256) scanline -= 256; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -134,7 +134,7 @@ static MACHINE_RESET( atetris ) reset_bank(); /* start interrupts going (32V clocked by 16V) */ - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 48, 0), 48); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(48), 48); } diff --git a/src/mame/drivers/backfire.c b/src/mame/drivers/backfire.c index 128605f1e47..aaf4a198f14 100644 --- a/src/mame/drivers/backfire.c +++ b/src/mame/drivers/backfire.c @@ -90,7 +90,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs] & 0xffff; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2] & 0xffff; diff --git a/src/mame/drivers/badlands.c b/src/mame/drivers/badlands.c index 5e4015c12fe..84e1146e7ed 100644 --- a/src/mame/drivers/badlands.c +++ b/src/mame/drivers/badlands.c @@ -184,15 +184,15 @@ static void update_interrupts(running_machine *machine) } -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { - const address_space *space = cputag_get_address_space(screen->machine, "audiocpu", ADDRESS_SPACE_PROGRAM); + const address_space *space = cputag_get_address_space(screen.machine, "audiocpu", ADDRESS_SPACE_PROGRAM); /* sound IRQ is on 32V */ if (scanline & 32) atarigen_6502_irq_ack_r(space, 0); - else if (!(input_port_read(screen->machine, "FE4000") & 0x40)) - atarigen_6502_irq_gen(devtag_get_device(screen->machine, "audiocpu")); + else if (!(input_port_read(screen.machine, "FE4000") & 0x40)) + atarigen_6502_irq_gen(devtag_get_device(screen.machine, "audiocpu")); } @@ -214,7 +214,7 @@ static MACHINE_RESET( badlands ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 32); atarigen_sound_io_reset(devtag_get_device(machine, "audiocpu")); memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); @@ -689,7 +689,7 @@ static void update_interrupts_bootleg(running_machine *machine) } -static void scanline_update_bootleg(running_device *screen, int scanline) +static void scanline_update_bootleg(screen_device &screen, int scanline) { /* sound IRQ is on 32V */ // if (scanline & 32) @@ -707,7 +707,7 @@ static MACHINE_RESET( badlandsb ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts_bootleg); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update_bootleg, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update_bootleg, 32); // atarigen_sound_io_reset(devtag_get_device(machine, "audiocpu")); // memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); diff --git a/src/mame/drivers/batman.c b/src/mame/drivers/batman.c index 2db6718db52..55e44261f1e 100644 --- a/src/mame/drivers/batman.c +++ b/src/mame/drivers/batman.c @@ -54,8 +54,8 @@ static MACHINE_RESET( batman ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); - atarigen_scanline_timer_reset(machine->primary_screen, batman_scanline_update, 8); + atarivc_reset(*machine->primary_screen, state->atarigen.atarivc_eof_data, 2); + atarigen_scanline_timer_reset(*machine->primary_screen, batman_scanline_update, 8); atarijsa_reset(); } @@ -69,13 +69,13 @@ static MACHINE_RESET( batman ) static READ16_HANDLER( batman_atarivc_r ) { - return atarivc_r(space->machine->primary_screen, offset); + return atarivc_r(*space->machine->primary_screen, offset); } static WRITE16_HANDLER( batman_atarivc_w ) { - atarivc_w(space->machine->primary_screen, offset, data, mem_mask); + atarivc_w(*space->machine->primary_screen, offset, data, mem_mask); } @@ -111,7 +111,7 @@ static WRITE16_HANDLER( latch_w ) /* alpha bank is selected by the upper 4 bits */ if ((oldword ^ state->latch_data) & 0x7000) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); tilemap_mark_all_tiles_dirty(state->atarigen.alpha_tilemap); state->alpha_tile_bank = (state->latch_data >> 12) & 7; } diff --git a/src/mame/drivers/beaminv.c b/src/mame/drivers/beaminv.c index 7e13b22d323..e5104b58ad7 100644 --- a/src/mame/drivers/beaminv.c +++ b/src/mame/drivers/beaminv.c @@ -104,7 +104,7 @@ static TIMER_CALLBACK( interrupt_callback ) next_interrupt_number = (interrupt_number + 1) % INTERRUPTS_PER_FRAME; next_vpos = interrupt_lines[next_interrupt_number]; - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), next_interrupt_number); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(next_vpos), next_interrupt_number); } @@ -119,7 +119,7 @@ static void start_interrupt_timer( running_machine *machine ) { beaminv_state *state = (beaminv_state *)machine->driver_data; int vpos = interrupt_lines[0]; - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(vpos), 0); } @@ -194,7 +194,7 @@ static VIDEO_UPDATE( beaminv ) static READ8_HANDLER( v128_r ) { - return (video_screen_get_vpos(space->machine->primary_screen) >> 7) & 0x01; + return (space->machine->primary_screen->vpos() >> 7) & 0x01; } diff --git a/src/mame/drivers/beathead.c b/src/mame/drivers/beathead.c index 8e45bb992a3..c72cf1d3383 100644 --- a/src/mame/drivers/beathead.c +++ b/src/mame/drivers/beathead.c @@ -140,11 +140,11 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) int scanline = param; /* update the video */ - video_screen_update_now(timer->machine->primary_screen); + timer.machine->primary_screen->update_now(); /* on scanline zero, clear any halt condition */ if (scanline == 0) - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); + cputag_set_input_line(timer.machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE); /* wrap around at 262 */ scanline++; @@ -153,10 +153,10 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) /* set the scanline IRQ */ irq_state[2] = 1; - update_interrupts(timer->machine); + update_interrupts(timer.machine); /* set the timer for the next one */ - timer_device_adjust_oneshot(timer, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0)) - hblank_offset), scanline); + timer.adjust(double_to_attotime(attotime_to_double(timer.machine->primary_screen->time_until_pos(scanline)) - hblank_offset), scanline); } @@ -180,8 +180,9 @@ static MACHINE_RESET( beathead ) memcpy(ram_base, rom_base, 0x40); /* compute the timing of the HBLANK interrupt and set the first timer */ - hblank_offset = attotime_to_double(video_screen_get_scan_period(machine->primary_screen)) * ((455. - 336. - 25.) / 455.); - timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), 0); + hblank_offset = attotime_to_double(machine->primary_screen->scan_period()) * ((455. - 336. - 25.) / 455.); + timer_device *scanline_timer = machine->device("scan_timer"); + scanline_timer->adjust(double_to_attotime(attotime_to_double(machine->primary_screen->time_until_pos(0)) - hblank_offset)); /* reset IRQs */ irq_line_state = CLEAR_LINE; diff --git a/src/mame/drivers/berzerk.c b/src/mame/drivers/berzerk.c index 2a158b6ea8c..f5271cb248d 100644 --- a/src/mame/drivers/berzerk.c +++ b/src/mame/drivers/berzerk.c @@ -167,7 +167,7 @@ static TIMER_CALLBACK( irq_callback ) next_v256 = irq_trigger_v256s[next_irq_number]; next_vpos = vsync_chain_counter_to_vpos(next_counter, next_v256); - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), next_irq_number); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(next_vpos), next_irq_number); } @@ -180,7 +180,7 @@ static void create_irq_timer(running_machine *machine) static void start_irq_timer(running_machine *machine) { int vpos = vsync_chain_counter_to_vpos(irq_trigger_counts[0], irq_trigger_v256s[0]); - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(vpos), 0); } @@ -244,7 +244,7 @@ static TIMER_CALLBACK( nmi_callback ) next_v256 = nmi_trigger_v256s[next_nmi_number]; next_vpos = vsync_chain_counter_to_vpos(next_counter, next_v256); - timer_adjust_oneshot(nmi_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), next_nmi_number); + timer_adjust_oneshot(nmi_timer, machine->primary_screen->time_until_pos(next_vpos), next_nmi_number); } @@ -257,7 +257,7 @@ static void create_nmi_timer(running_machine *machine) static void start_nmi_timer(running_machine *machine) { int vpos = vsync_chain_counter_to_vpos(nmi_trigger_counts[0], nmi_trigger_v256s[0]); - timer_adjust_oneshot(nmi_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(nmi_timer, machine->primary_screen->time_until_pos(vpos), 0); } @@ -377,7 +377,7 @@ static READ8_HANDLER( intercept_v256_r ) UINT8 counter; UINT8 v256; - vpos_to_vsync_chain_counter(video_screen_get_vpos(space->machine->primary_screen), &counter, &v256); + vpos_to_vsync_chain_counter(space->machine->primary_screen->vpos(), &counter, &v256); return (!intercept << 7) | v256; } diff --git a/src/mame/drivers/bestleag.c b/src/mame/drivers/bestleag.c index 3f1d43e56db..e23bfa56d35 100644 --- a/src/mame/drivers/bestleag.c +++ b/src/mame/drivers/bestleag.c @@ -193,7 +193,8 @@ static WRITE16_HANDLER( bestleag_fgram_w ) static WRITE16_DEVICE_HANDLER( oki_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * ((data & 3) - 1)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * ((data & 3) - 1)); } @@ -347,8 +348,7 @@ static MACHINE_DRIVER_START( bestleag ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) /* Hand-tuned */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) /* Hand-tuned */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) MACHINE_DRIVER_END diff --git a/src/mame/drivers/big10.c b/src/mame/drivers/big10.c index 26eb3213bcd..1f9a8635317 100644 --- a/src/mame/drivers/big10.c +++ b/src/mame/drivers/big10.c @@ -83,7 +83,7 @@ static INTERRUPT_GEN( big10_interrupt ) static VIDEO_START( big10 ) { VIDEO_START_CALL(generic_bitmapped); - v9938_init (machine, 0, machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, VDP_MEM, big10_vdp_interrupt); + v9938_init (machine, 0, *machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, VDP_MEM, big10_vdp_interrupt); v9938_reset(0); } diff --git a/src/mame/drivers/bigstrkb.c b/src/mame/drivers/bigstrkb.c index 8906d7547cb..f95f4283bd5 100644 --- a/src/mame/drivers/bigstrkb.c +++ b/src/mame/drivers/bigstrkb.c @@ -220,13 +220,11 @@ static MACHINE_DRIVER_START( bigstrkb ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") // MDRV_SOUND_ADD("ymsnd", YM2151, ym2151_config) - MDRV_SOUND_ADD("oki1", OKIM6295, 4000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 4000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MDRV_SOUND_ADD("oki2", OKIM6295, 4000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 4000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/bingor.c b/src/mame/drivers/bingor.c index c79a310c91f..6cbb62cf796 100644 --- a/src/mame/drivers/bingor.c +++ b/src/mame/drivers/bingor.c @@ -465,22 +465,22 @@ static VIDEO_UPDATE(bingor) color = (blit_ram[count] & 0xf000)>>12; - if((x+3)max_x && ((y)+0)max_y) + if((x+3)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x+3) = screen->machine->pens[color]; color = (blit_ram[count] & 0x0f00)>>8; - if((x+2)max_x && ((y)+0)max_y) + if((x+2)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x+2) = screen->machine->pens[color]; color = (blit_ram[count] & 0x00f0)>>4; - if((x+1)max_x && ((y)+0)max_y) + if((x+1)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x+1) = screen->machine->pens[color]; color = (blit_ram[count] & 0x000f)>>0; - if((x+0)max_x && ((y)+0)max_y) + if((x+0)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x+0) = screen->machine->pens[color]; count++; diff --git a/src/mame/drivers/bishjan.c b/src/mame/drivers/bishjan.c index 0269fa3ddf5..92377f7bf1e 100644 --- a/src/mame/drivers/bishjan.c +++ b/src/mame/drivers/bishjan.c @@ -327,7 +327,7 @@ static READ16_HANDLER( bishjan_serial_r ) (mame_rand(space->machine) & 0x9800) | // bit 7 - serial communication (((bishjan_sel==0x12) ? 0x40:0x00) << 8) | // (mame_rand() & 0xff); -// (((video_screen_get_frame_number(space->machine->primary_screen)%60)==0)?0x18:0x00); +// (((space->machine->primary_screen->frame_number()%60)==0)?0x18:0x00); 0x18; } @@ -348,7 +348,7 @@ static READ16_HANDLER( bishjan_input_r ) return (res << 8) | // high byte input_port_read(space->machine, "SYSTEM") | // low byte - ((bishjan_hopper && !(video_screen_get_frame_number(space->machine->primary_screen)%10)) ? 0x00 : 0x04) // bit 2: hopper sensor + ((bishjan_hopper && !(space->machine->primary_screen->frame_number()%10)) ? 0x00 : 0x04) // bit 2: hopper sensor ; } @@ -458,12 +458,13 @@ static WRITE8_HANDLER( saklove_outputs_w ) static WRITE8_DEVICE_HANDLER( saklove_oki_bank_w ) { // it writes 0x32 or 0x33 - okim6295_set_bank_base(device, (data & 1) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 1) * 0x40000); } static READ8_HANDLER( saklove_vblank_r ) { - return video_screen_get_vblank(space->machine->primary_screen) ? 0x04 : 0x00; + return space->machine->primary_screen->vblank() ? 0x04 : 0x00; } static UINT8 *am188em_regs; @@ -880,8 +881,7 @@ static MACHINE_DRIVER_START( saklove ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_8_4672MHz / 8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_8_4672MHz / 8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MDRV_SOUND_ADD("ymsnd", YM3812, XTAL_12MHz / 4) // ? chip and clock unknown diff --git a/src/mame/drivers/blackt96.c b/src/mame/drivers/blackt96.c index 92cbcc5f4cb..7a671baad92 100644 --- a/src/mame/drivers/blackt96.c +++ b/src/mame/drivers/blackt96.c @@ -441,7 +441,7 @@ static MACHINE_DRIVER_START( blackt96 ) MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) MDRV_CPU_ADD("audiocpu", PIC16C57, 8000000) /* ? */ - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MDRV_CPU_IO_MAP(sound_io_map) MDRV_GFXDECODE(blackt96) @@ -461,13 +461,11 @@ static MACHINE_DRIVER_START( blackt96 ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 8000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 8000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) - MDRV_SOUND_ADD("oki2", OKIM6295, 8000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 8000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/blmbycar.c b/src/mame/drivers/blmbycar.c index ab7a770e807..edc945ade21 100644 --- a/src/mame/drivers/blmbycar.c +++ b/src/mame/drivers/blmbycar.c @@ -386,8 +386,7 @@ static MACHINE_DRIVER_START( blmbycar ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -437,8 +436,7 @@ static MACHINE_DRIVER_START( watrball ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/blockout.c b/src/mame/drivers/blockout.c index 42bba31aeca..c4ba95b78e6 100644 --- a/src/mame/drivers/blockout.c +++ b/src/mame/drivers/blockout.c @@ -306,8 +306,7 @@ static MACHINE_DRIVER_START( blockout ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.60) MDRV_SOUND_ROUTE(1, "rspeaker", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/blstroid.c b/src/mame/drivers/blstroid.c index 80a59b3cd39..31bcf49d469 100644 --- a/src/mame/drivers/blstroid.c +++ b/src/mame/drivers/blstroid.c @@ -42,7 +42,7 @@ static void update_interrupts(running_machine *machine) static WRITE16_HANDLER( blstroid_halt_until_hblank_0_w ) { - atarigen_halt_until_hblank_0(space->machine->primary_screen); + atarigen_halt_until_hblank_0(*space->machine->primary_screen); } @@ -58,7 +58,7 @@ static MACHINE_RESET( blstroid ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, blstroid_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, blstroid_scanline_update, 8); atarijsa_reset(); } @@ -77,7 +77,7 @@ static READ16_HANDLER( inputs_r ) int temp = input_port_read(space->machine, iptnames[offset & 1]); if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0040; - if (atarigen_get_hblank(space->machine->primary_screen)) temp ^= 0x0010; + if (atarigen_get_hblank(*space->machine->primary_screen)) temp ^= 0x0010; return temp; } diff --git a/src/mame/drivers/bmcbowl.c b/src/mame/drivers/bmcbowl.c index 59cd7e1a2d5..68b25c77640 100644 --- a/src/mame/drivers/bmcbowl.c +++ b/src/mame/drivers/bmcbowl.c @@ -523,8 +523,7 @@ static MACHINE_DRIVER_START( bmcbowl ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) diff --git a/src/mame/drivers/boogwing.c b/src/mame/drivers/boogwing.c index b735f693cbf..6970e80d598 100644 --- a/src/mame/drivers/boogwing.c +++ b/src/mame/drivers/boogwing.c @@ -283,8 +283,8 @@ static void sound_irq(running_device *device, int state) static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) { boogwing_state *state = (boogwing_state *)device->machine->driver_data; - okim6295_set_bank_base(state->oki2, ((data & 2) >> 1) * 0x40000); - okim6295_set_bank_base(state->oki1, (data & 1) * 0x40000); + state->oki2->set_bank_base(((data & 2) >> 1) * 0x40000); + state->oki1->set_bank_base((data & 1) * 0x40000); } static const ym2151_interface ym2151_config = @@ -322,17 +322,6 @@ static const deco16ic_interface boogwing_deco16ic_intf = }; -static MACHINE_START( boogwing ) -{ - boogwing_state *state = (boogwing_state *)machine->driver_data; - - state->maincpu = devtag_get_device(machine, "maincpu"); - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->oki1 = devtag_get_device(machine, "oki1"); - state->oki2 = devtag_get_device(machine, "oki2"); -} - static MACHINE_DRIVER_START( boogwing ) /* driver data */ @@ -346,8 +335,6 @@ static MACHINE_DRIVER_START( boogwing ) MDRV_CPU_ADD("audiocpu", H6280,32220000/4) MDRV_CPU_PROGRAM_MAP(audio_map) - MDRV_MACHINE_START(boogwing) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) @@ -373,13 +360,11 @@ static MACHINE_DRIVER_START( boogwing ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.40) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/boxer.c b/src/mame/drivers/boxer.c index fbfdf4a4ee4..da5770245c8 100644 --- a/src/mame/drivers/boxer.c +++ b/src/mame/drivers/boxer.c @@ -81,7 +81,7 @@ static TIMER_CALLBACK( periodic_callback ) for (i = 1; i < 256; i++) if (mask[i] != 0) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, i, 0), NULL, mask[i], pot_interrupt); + timer_set(machine, machine->primary_screen->time_until_pos(i), NULL, mask[i], pot_interrupt); state->pot_state = 0; } @@ -91,7 +91,7 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline >= 262) scanline = 0; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, periodic_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); } @@ -196,7 +196,7 @@ static READ8_HANDLER( boxer_input_r ) { UINT8 val = input_port_read(space->machine, "IN0"); - if (input_port_read(space->machine, "IN3") < video_screen_get_vpos(space->machine->primary_screen)) + if (input_port_read(space->machine, "IN3") < space->machine->primary_screen->vpos()) val |= 0x02; return (val << ((offset & 7) ^ 7)) & 0x80; @@ -215,7 +215,7 @@ static READ8_HANDLER( boxer_misc_r ) break; case 1: - val = video_screen_get_vpos(space->machine->primary_screen); + val = space->machine->primary_screen->vpos(); break; case 2: @@ -429,7 +429,7 @@ static MACHINE_START( boxer ) static MACHINE_RESET( boxer ) { boxer_state *state = (boxer_state *)machine->driver_data; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, periodic_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, periodic_callback); state->pot_state = 0; state->pot_latch = 0; diff --git a/src/mame/drivers/btime.c b/src/mame/drivers/btime.c index 65fcdbb2f66..84619737937 100644 --- a/src/mame/drivers/btime.c +++ b/src/mame/drivers/btime.c @@ -192,7 +192,7 @@ static WRITE8_DEVICE_HANDLER( ay_audio_nmi_enable_w ) static TIMER_DEVICE_CALLBACK( audio_nmi_gen ) { - btime_state *state = (btime_state *)timer->machine->driver_data; + btime_state *state = (btime_state *)timer.machine->driver_data; int scanline = param; state->audio_nmi_state = scanline & 8; cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, (state->audio_nmi_enabled && state->audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); @@ -562,7 +562,7 @@ static READ8_HANDLER( audio_command_r ) static READ8_HANDLER( zoar_dsw1_read ) { - return (!video_screen_get_vblank(space->machine->primary_screen) << 7) | (input_port_read(space->machine, "DSW1") & 0x7f); + return (!space->machine->primary_screen->vblank() << 7) | (input_port_read(space->machine, "DSW1") & 0x7f); } static INPUT_PORTS_START( btime ) diff --git a/src/mame/drivers/calchase.c b/src/mame/drivers/calchase.c index 48cf2b4e493..a3b56a7c8ba 100644 --- a/src/mame/drivers/calchase.c +++ b/src/mame/drivers/calchase.c @@ -134,7 +134,7 @@ static VIDEO_UPDATE(calchase) color = (vga_vram[count])>>(32-i) & 0x1; - if((x+i)max_x && ((y)+0)max_y) + if((x+i)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x+(32-i)) = screen->machine->pens[color]; } diff --git a/src/mame/drivers/capbowl.c b/src/mame/drivers/capbowl.c index 47956e99bfe..d9625e05a49 100644 --- a/src/mame/drivers/capbowl.c +++ b/src/mame/drivers/capbowl.c @@ -123,10 +123,10 @@ static TIMER_CALLBACK( capbowl_update ) { int scanline = param; - video_screen_update_partial(machine->primary_screen, scanline - 1); + machine->primary_screen->update_partial(scanline - 1); scanline += 32; if (scanline > 240) scanline = 32; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, capbowl_update); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, capbowl_update); } @@ -361,7 +361,7 @@ static MACHINE_RESET( capbowl ) { capbowl_state *state = (capbowl_state *)machine->driver_data; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 32, 0), NULL, 32, capbowl_update); + timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, capbowl_update); state->blitter_addr = 0; state->last_trackball_val[0] = 0; diff --git a/src/mame/drivers/cardline.c b/src/mame/drivers/cardline.c index 919f7c22897..478e6de2635 100644 --- a/src/mame/drivers/cardline.c +++ b/src/mame/drivers/cardline.c @@ -219,8 +219,7 @@ static MACHINE_DRIVER_START( cardline ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c index 86f49886a3a..9a796a00e01 100644 --- a/src/mame/drivers/cave.c +++ b/src/mame/drivers/cave.c @@ -925,7 +925,7 @@ static WRITE16_HANDLER( tjumpman_leds_w ) static CUSTOM_INPUT( tjumpman_hopper_r ) { cave_state *state = (cave_state *)field->port->machine->driver_data; - return (state->hopper && !(video_screen_get_frame_number(field->port->machine->primary_screen) % 10)) ? 0 : 1; + return (state->hopper && !(field->port->machine->primary_screen->frame_number() % 10)) ? 0 : 1; } static ADDRESS_MAP_START( tjumpman_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -1890,13 +1890,11 @@ static MACHINE_DRIVER_START( donpachi ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_1_056MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.60) - MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) @@ -2082,8 +2080,7 @@ static MACHINE_DRIVER_START( hotdogst ) MDRV_SOUND_ROUTE(3, "lspeaker", 0.80) MDRV_SOUND_ROUTE(3, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1_056MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -2195,8 +2192,7 @@ static MACHINE_DRIVER_START( mazinger ) MDRV_SOUND_ROUTE(3, "lspeaker", 0.60) MDRV_SOUND_ROUTE(3, "rspeaker", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1_056MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 2.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 2.0) MACHINE_DRIVER_END @@ -2249,13 +2245,11 @@ static MACHINE_DRIVER_START( metmqstr ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.20) MDRV_SOUND_ROUTE(1, "rspeaker", 1.20) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_32MHz / 16 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", XTAL_32MHz / 16 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_32MHz / 16 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", XTAL_32MHz / 16 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -2319,13 +2313,11 @@ static MACHINE_DRIVER_START( pwrinst2 ) MDRV_SOUND_ROUTE(3, "lspeaker", 0.80) MDRV_SOUND_ROUTE(3, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_3MHz ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", XTAL_3MHz , OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_3MHz ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", XTAL_3MHz , OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) @@ -2379,13 +2371,11 @@ static MACHINE_DRIVER_START( sailormn ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.30) MDRV_SOUND_ROUTE(1, "rspeaker", 0.30) - MDRV_SOUND_ADD("oki1", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -2431,8 +2421,7 @@ static MACHINE_DRIVER_START( tjumpman ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_28MHz / 28) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", XTAL_28MHz / 28, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) diff --git a/src/mame/drivers/cball.c b/src/mame/drivers/cball.c index 269da881dbd..6928ecafcec 100644 --- a/src/mame/drivers/cball.c +++ b/src/mame/drivers/cball.c @@ -81,7 +81,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 262) scanline = 16; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); } @@ -93,7 +93,7 @@ static MACHINE_START( cball ) static MACHINE_RESET( cball ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(16), NULL, 16, interrupt_callback); } diff --git a/src/mame/drivers/cbasebal.c b/src/mame/drivers/cbasebal.c index 86692d0b636..ec9fcfdc6f8 100644 --- a/src/mame/drivers/cbasebal.c +++ b/src/mame/drivers/cbasebal.c @@ -311,8 +311,7 @@ static MACHINE_DRIVER_START( cbasebal ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd", YM2413, 3579545) diff --git a/src/mame/drivers/cbuster.c b/src/mame/drivers/cbuster.c index da802c68d44..fad69a73b89 100644 --- a/src/mame/drivers/cbuster.c +++ b/src/mame/drivers/cbuster.c @@ -357,12 +357,10 @@ static MACHINE_DRIVER_START( twocrude ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ccastles.c b/src/mame/drivers/ccastles.c index 37052410f00..0fb2f0104d1 100644 --- a/src/mame/drivers/ccastles.c +++ b/src/mame/drivers/ccastles.c @@ -157,7 +157,7 @@ INLINE void schedule_next_irq( running_machine *machine, int curscanline ) break; /* next one at the start of this scanline */ - timer_adjust_oneshot(state->irq_timer, video_screen_get_time_until_pos(machine->primary_screen, curscanline, 0), curscanline); + timer_adjust_oneshot(state->irq_timer, machine->primary_screen->time_until_pos(curscanline), curscanline); } @@ -173,7 +173,7 @@ static TIMER_CALLBACK( clock_irq ) } /* force an update now */ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* find the next edge */ schedule_next_irq(machine, param); @@ -183,7 +183,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { ccastles_state *state = (ccastles_state *)field->port->machine->driver_data; - int scanline = video_screen_get_vpos(field->port->machine->primary_screen); + int scanline = field->port->machine->primary_screen->vpos(); return state->syncprom[scanline & 0xff] & 1; } @@ -224,7 +224,7 @@ static MACHINE_START( ccastles ) visarea.max_x = 255; visarea.min_y = state->vblank_end; visarea.max_y = state->vblank_start - 1; - video_screen_configure(machine->primary_screen, 320, 256, &visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); + machine->primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); /* configure the ROM banking */ memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, "maincpu") + 0xa000, 0x6000); diff --git a/src/mame/drivers/cchasm.c b/src/mame/drivers/cchasm.c index 2e311c4847d..948beb23356 100644 --- a/src/mame/drivers/cchasm.c +++ b/src/mame/drivers/cchasm.c @@ -139,7 +139,7 @@ INPUT_PORTS_END * *************************************/ -static const z80_daisy_chain daisy_chain[] = +static const z80_daisy_config daisy_chain[] = { { "ctc" }, { NULL } diff --git a/src/mame/drivers/centiped.c b/src/mame/drivers/centiped.c index 2d3288e93f1..be7b5ad5a4d 100644 --- a/src/mame/drivers/centiped.c +++ b/src/mame/drivers/centiped.c @@ -446,10 +446,10 @@ static TIMER_DEVICE_CALLBACK( generate_interrupt ) /* IRQ is clocked on the rising edge of 16V, equal to the previous 32V */ if (scanline & 16) - cputag_set_input_line(timer->machine, "maincpu", 0, ((scanline - 1) & 32) ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(timer.machine, "maincpu", 0, ((scanline - 1) & 32) ? ASSERT_LINE : CLEAR_LINE); /* do a partial update now to handle sprite multiplexing (Maze Invaders) */ - video_screen_update_partial(timer->machine->primary_screen, scanline); + timer.machine->primary_screen->update_partial(scanline); } diff --git a/src/mame/drivers/changela.c b/src/mame/drivers/changela.c index c3b9e843a27..e1f67cddd87 100644 --- a/src/mame/drivers/changela.c +++ b/src/mame/drivers/changela.c @@ -175,7 +175,7 @@ static READ8_HANDLER( changela_2d_r ) int v8 = 0; int gas; - if ((video_screen_get_vpos(space->machine->primary_screen) & 0xf8) == 0xf8) + if ((space->machine->primary_screen->vpos() & 0xf8) == 0xf8) v8 = 1; /* Gas pedal is made up of 2 switches, 1 active low, 1 active high */ @@ -423,9 +423,9 @@ static const ay8910_interface ay8910_interface_2 = static INTERRUPT_GEN( chl_interrupt ) { changela_state *state = (changela_state *)device->machine->driver_data; - int vector = video_screen_get_vblank(device->machine->primary_screen) ? 0xdf : 0xcf; /* 4 irqs per frame: 3 times 0xcf, 1 time 0xdf */ + int vector = device->machine->primary_screen->vblank() ? 0xdf : 0xcf; /* 4 irqs per frame: 3 times 0xcf, 1 time 0xdf */ -// video_screen_update_partial(device->machine->primary_screen, video_screen_get_vpos(device->machine->primary_screen)); +// device->machine->primary_screen->update_partial(device->machine->primary_screen->vpos()); cpu_set_input_line_and_vector(device, 0, HOLD_LINE, vector); diff --git a/src/mame/drivers/chinagat.c b/src/mame/drivers/chinagat.c index a1405ebc806..8be06a9136a 100644 --- a/src/mame/drivers/chinagat.c +++ b/src/mame/drivers/chinagat.c @@ -110,15 +110,15 @@ INLINE int scanline_to_vcount( int scanline ) static TIMER_DEVICE_CALLBACK( chinagat_scanline ) { - ddragon_state *state = (ddragon_state *)timer->machine->driver_data; + ddragon_state *state = (ddragon_state *)timer.machine->driver_data; int scanline = param; - int screen_height = video_screen_get_height(timer->machine->primary_screen); + int screen_height = timer.machine->primary_screen->height(); int vcount_old = scanline_to_vcount((scanline == 0) ? screen_height - 1 : scanline - 1); int vcount = scanline_to_vcount(scanline); /* update to the current point */ if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); /* on the rising edge of VBLK (vcount == F8), signal an NMI */ if (vcount == 0xf8) @@ -608,8 +608,7 @@ static MACHINE_DRIVER_START( chinagat ) MDRV_SOUND_ROUTE(0, "mono", 0.80) MDRV_SOUND_ROUTE(1, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1065000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 not verified, clock frequency estimated with recording + MDRV_OKIM6295_ADD("oki", 1065000, OKIM6295_PIN7_HIGH) // pin 7 not verified, clock frequency estimated with recording MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/cinemat.c b/src/mame/drivers/cinemat.c index 706efaaeb1b..aaa82fe140a 100644 --- a/src/mame/drivers/cinemat.c +++ b/src/mame/drivers/cinemat.c @@ -269,8 +269,8 @@ static READ8_HANDLER( boxingb_dial_r ) static READ8_HANDLER( qb3_frame_r ) { - attotime next_update = video_screen_get_time_until_update(space->machine->primary_screen); - attotime frame_period = video_screen_get_frame_period(space->machine->primary_screen); + attotime next_update = space->machine->primary_screen->time_until_update(); + attotime frame_period = space->machine->primary_screen->frame_period(); int percent = next_update.attoseconds / (frame_period.attoseconds / 100); /* note this is just an approximation... */ diff --git a/src/mame/drivers/cischeat.c b/src/mame/drivers/cischeat.c index 8aaa90e6401..673bd01b309 100644 --- a/src/mame/drivers/cischeat.c +++ b/src/mame/drivers/cischeat.c @@ -498,8 +498,10 @@ static WRITE16_HANDLER( scudhamm_oki_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(devtag_get_device(space->machine, "oki1"), 0x40000 * ((data >> 0) & 0x3) ); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x40000 * ((data >> 4) & 0x3) ); + okim6295_device *oki1 = space->machine->device("oki1"); + okim6295_device *oki2 = space->machine->device("oki2"); + oki1->set_bank_base(0x40000 * ((data >> 0) & 0x3) ); + oki2->set_bank_base(0x40000 * ((data >> 4) & 0x3) ); } } @@ -693,8 +695,10 @@ static WRITE16_HANDLER( bigrun_soundbank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(devtag_get_device(space->machine, "oki1"), 0x40000 * ((data >> 0) & 1) ); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x40000 * ((data >> 4) & 1) ); + okim6295_device *oki1 = space->machine->device("oki1"); + okim6295_device *oki2 = space->machine->device("oki2"); + oki1->set_bank_base(0x40000 * ((data >> 0) & 1) ); + oki2->set_bank_base(0x40000 * ((data >> 4) & 1) ); } } @@ -715,7 +719,8 @@ ADDRESS_MAP_END static WRITE16_DEVICE_HANDLER( cischeat_soundbank_w ) { - if (ACCESSING_BITS_0_7) okim6295_set_bank_base(device, 0x40000 * (data & 1) ); + okim6295_device *oki = downcast(device); + if (ACCESSING_BITS_0_7) oki->set_bank_base(0x40000 * (data & 1) ); } static ADDRESS_MAP_START( cischeat_sound_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -1604,12 +1609,10 @@ static MACHINE_DRIVER_START( bigrun ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.75) MDRV_SOUND_ROUTE(1, "rspeaker", 0.75) - MDRV_SOUND_ADD("oki1", OKIM6295, STD_OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", STD_OKI_CLOCK, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, STD_OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", STD_OKI_CLOCK, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -1733,13 +1736,11 @@ static MACHINE_DRIVER_START( scudhamm ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/cliffhgr.c b/src/mame/drivers/cliffhgr.c index a71f72b422a..75a63955852 100644 --- a/src/mame/drivers/cliffhgr.c +++ b/src/mame/drivers/cliffhgr.c @@ -203,7 +203,7 @@ static TIMER_CALLBACK( cliff_irq_callback ) cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); } - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, param * 2, 0), param); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(param * 2), param); } static void vdp_interrupt(running_machine *machine, int state) @@ -223,7 +223,7 @@ static MACHINE_RESET( cliffhgr ) { port_bank = 0; phillips_code = 0; - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, 17, 0), 17); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(17), 17); } /********************************************************/ diff --git a/src/mame/drivers/cloud9.c b/src/mame/drivers/cloud9.c index 0658fca7e6b..3bba3ef235e 100644 --- a/src/mame/drivers/cloud9.c +++ b/src/mame/drivers/cloud9.c @@ -127,7 +127,7 @@ INLINE void schedule_next_irq(running_machine *machine, int curscanline) curscanline = (curscanline + 64) & 255; /* next one at the start of this scanline */ - timer_adjust_oneshot(state->irq_timer, video_screen_get_time_until_pos(machine->primary_screen, curscanline, 0), curscanline); + timer_adjust_oneshot(state->irq_timer, machine->primary_screen->time_until_pos(curscanline), curscanline); } @@ -142,7 +142,7 @@ static TIMER_CALLBACK( clock_irq ) } /* force an update now */ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* find the next edge */ schedule_next_irq(machine, param); @@ -152,7 +152,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { cloud9_state *state = (cloud9_state *)field->port->machine->driver_data; - int scanline = video_screen_get_vpos(field->port->machine->primary_screen); + int scanline = field->port->machine->primary_screen->vpos(); return (~state->syncprom[scanline & 0xff] >> 1) & 1; } @@ -193,7 +193,7 @@ static MACHINE_START( cloud9 ) visarea.max_x = 255; visarea.min_y = state->vblank_end + 1; visarea.max_y = state->vblank_start; - video_screen_configure(machine->primary_screen, 320, 256, &visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); + machine->primary_screen->configure(320, 256, visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL); /* create a timer for IRQs and set up the first callback */ state->irq_timer = timer_alloc(machine, clock_irq, NULL); diff --git a/src/mame/drivers/clshroad.c b/src/mame/drivers/clshroad.c index c60d7c01b13..614a3ca8370 100644 --- a/src/mame/drivers/clshroad.c +++ b/src/mame/drivers/clshroad.c @@ -19,6 +19,7 @@ XTAL : 18.432 MHz #include "emu.h" #include "cpu/z80/z80.h" +#include "includes/wiping.h" /* Variables & functions defined in video: */ @@ -38,7 +39,6 @@ VIDEO_UPDATE( clshroad ); extern UINT8 *wiping_soundregs; DEVICE_GET_INFO( wiping_sound ); -#define SOUND_WIPING DEVICE_GET_INFO_NAME(wiping_sound) WRITE8_HANDLER( wiping_sound_w ); diff --git a/src/mame/drivers/cninja.c b/src/mame/drivers/cninja.c index d6260f35077..531c2bf333d 100644 --- a/src/mame/drivers/cninja.c +++ b/src/mame/drivers/cninja.c @@ -71,10 +71,10 @@ static WRITE16_HANDLER( stoneage_sound_w ) static TIMER_DEVICE_CALLBACK( interrupt_gen ) { - cninja_state *state = (cninja_state *)timer->machine->driver_data; + cninja_state *state = (cninja_state *)timer.machine->driver_data; cpu_set_input_line(state->maincpu, (state->irq_mask & 0x10) ? 3 : 4, ASSERT_LINE); - timer_device_adjust_oneshot(state->raster_irq_timer, attotime_never, 0); + state->raster_irq_timer->reset(); } static READ16_HANDLER( cninja_irq_r ) @@ -117,9 +117,9 @@ static WRITE16_HANDLER( cninja_irq_w ) state->scanline = data & 0xff; if (!BIT(state->irq_mask, 1) && state->scanline > 0 && state->scanline < 240) - timer_device_adjust_oneshot(state->raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, state->scanline, 0), state->scanline); + state->raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(state->scanline), state->scanline); else - timer_device_adjust_oneshot(state->raster_irq_timer, attotime_never, 0); + state->raster_irq_timer->reset(); return; case 2: /* VBL irq ack */ @@ -153,7 +153,7 @@ static WRITE16_HANDLER( cninja_pf12_control_w ) { cninja_state *state = (cninja_state *)space->machine->driver_data; deco16ic_pf12_control_w(state->deco16ic, offset, data, mem_mask); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -161,7 +161,7 @@ static WRITE16_HANDLER( cninja_pf34_control_w ) { cninja_state *state = (cninja_state *)space->machine->driver_data; deco16ic_pf34_control_w(state->deco16ic, offset, data, mem_mask); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } @@ -736,7 +736,7 @@ static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) cninja_state *state = (cninja_state *)device->machine->driver_data; /* the second OKIM6295 ROM is bank switched */ - okim6295_set_bank_base(state->oki2, (data & 1) * 0x40000); + state->oki2->set_bank_base((data & 1) * 0x40000); } static const ym2151_interface ym2151_config = @@ -830,12 +830,6 @@ static MACHINE_START( cninja ) { cninja_state *state = (cninja_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->raster_irq_timer = devtag_get_device(machine, "raster_timer"); - state->oki2 = devtag_get_device(machine, "oki2"); - state_save_register_global(machine, state->scanline); state_save_register_global(machine, state->irq_mask); } @@ -893,12 +887,10 @@ static MACHINE_DRIVER_START( cninja ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END @@ -945,12 +937,10 @@ static MACHINE_DRIVER_START( stoneage ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END @@ -997,8 +987,7 @@ static MACHINE_DRIVER_START( cninjabl ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_DRIVER_END @@ -1048,12 +1037,10 @@ static MACHINE_DRIVER_START( edrandy ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END @@ -1103,13 +1090,11 @@ static MACHINE_DRIVER_START( robocop2 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) MACHINE_DRIVER_END @@ -1154,13 +1139,11 @@ static MACHINE_DRIVER_START( mutantf ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/coolpool.c b/src/mame/drivers/coolpool.c index b3584139673..fe3830df11e 100644 --- a/src/mame/drivers/coolpool.c +++ b/src/mame/drivers/coolpool.c @@ -63,7 +63,7 @@ static UINT8 nvram_write_enable; * *************************************/ -static void amerdart_scanline(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void amerdart_scanline(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *vram = &vram_base[(params->rowaddr << 8) & 0xff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); @@ -90,7 +90,7 @@ static void amerdart_scanline(running_device *screen, bitmap_t *bitmap, int scan } -static void coolpool_scanline(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void coolpool_scanline(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *vram = &vram_base[(params->rowaddr << 8) & 0x1ff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); @@ -169,7 +169,8 @@ static WRITE16_HANDLER( nvram_thrash_w ) if (!memcmp(nvram_unlock_seq, nvram_write_seq, sizeof(nvram_unlock_seq))) { nvram_write_enable = 1; - timer_device_adjust_oneshot(devtag_get_device(space->machine, "nvram_timer"), ATTOTIME_IN_MSEC(1000), 0); + timer_device *nvram_timer = space->machine->device("nvram_timer"); + nvram_timer->adjust(ATTOTIME_IN_MSEC(1000)); } } @@ -675,7 +676,7 @@ static MACHINE_DRIVER_START( amerdart ) MDRV_CPU_PROGRAM_MAP(amerdart_map) MDRV_CPU_ADD("dsp", TMS32010, 15000000/2) - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MDRV_CPU_PROGRAM_MAP(amerdart_dsp_map) MDRV_MACHINE_RESET(amerdart) diff --git a/src/mame/drivers/coolridr.c b/src/mame/drivers/coolridr.c index 460a34c0cf9..aa7228a1bcb 100644 --- a/src/mame/drivers/coolridr.c +++ b/src/mame/drivers/coolridr.c @@ -249,8 +249,8 @@ static bitmap_t* temp_bitmap_sprites; static VIDEO_START(coolridr) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); temp_bitmap_sprites = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_RGB32); } diff --git a/src/mame/drivers/cosmic.c b/src/mame/drivers/cosmic.c index 5d1e0d8b4cd..6f6e0b43bbb 100644 --- a/src/mame/drivers/cosmic.c +++ b/src/mame/drivers/cosmic.c @@ -391,7 +391,7 @@ static READ8_HANDLER( cosmica_pixel_clock_r ) static READ8_HANDLER( cosmicg_port_0_r ) { /* The top four address lines from the CRTC are bits 0-3 */ - return (input_port_read(space->machine, "IN0") & 0xf0) | ((video_screen_get_vpos(space->machine->primary_screen) & 0xf0) >> 4); + return (input_port_read(space->machine, "IN0") & 0xf0) | ((space->machine->primary_screen->vpos() & 0xf0) >> 4); } static READ8_HANDLER( magspot_coinage_dip_r ) diff --git a/src/mame/drivers/cps1.c b/src/mame/drivers/cps1.c index 70395c4b555..a268d2a2c4f 100644 --- a/src/mame/drivers/cps1.c +++ b/src/mame/drivers/cps1.c @@ -289,7 +289,7 @@ static WRITE8_HANDLER( cps1_snd_bankswitch_w ) static WRITE8_DEVICE_HANDLER( cps1_oki_pin7_w ) { - okim6295_set_pin7(device, (data & 1)); + downcast(device)->set_pin7(data & 1); } static WRITE16_HANDLER( cps1_soundlatch_w ) @@ -3000,8 +3000,7 @@ static MACHINE_DRIVER_START( cps1_10MHz ) MDRV_SOUND_ROUTE(1, "mono", 0.35) /* CPS PPU is fed by a 16mhz clock,pin 117 outputs a 4mhz clock which is divided by 4 using 2 74ls74 */ - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/4/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 can be changed by the game code, see f006 on z80 + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/4/4, OKIM6295_PIN7_HIGH) // pin 7 can be changed by the game code, see f006 on z80 MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_DRIVER_END @@ -3011,7 +3010,8 @@ static MACHINE_DRIVER_START( cps1_12MHz ) /* basic machine hardware */ MDRV_IMPORT_FROM(cps1_10MHz) - MDRV_CPU_REPLACE("maincpu", M68000, XTAL_12MHz ) /* verified on pcb */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK( XTAL_12MHz ) /* verified on pcb */ MACHINE_DRIVER_END static MACHINE_DRIVER_START( pang3 ) @@ -3064,7 +3064,7 @@ static MACHINE_DRIVER_START( cpspicb ) MDRV_CPU_VBLANK_INT("screen", cps1_qsound_interrupt) MDRV_CPU_ADD("audiocpu", PIC16C57, 12000000) - MDRV_CPU_FLAGS(CPU_DISABLE) /* no valid dumps .. */ + MDRV_DEVICE_DISABLE() /* no valid dumps .. */ MDRV_MACHINE_START(common) @@ -3086,8 +3086,7 @@ static MACHINE_DRIVER_START( cpspicb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/cps2.c b/src/mame/drivers/cps2.c index 602588a8fec..ad527656801 100644 --- a/src/mame/drivers/cps2.c +++ b/src/mame/drivers/cps2.c @@ -648,7 +648,7 @@ static INTERRUPT_GEN( cps2_interrupt ) state->cps_b_regs[0x10/2] = 0; cpu_set_input_line(device, 4, HOLD_LINE); cps2_set_sprite_priorities(device->machine); - video_screen_update_partial(device->machine->primary_screen, 16 - 10 + state->scancount); /* visarea.min_y - [first visible line?] + scancount */ + device->machine->primary_screen->update_partial(16 - 10 + state->scancount); /* visarea.min_y - [first visible line?] + scancount */ state->scancalls++; // popmessage("IRQ4 scancounter = %04i", state->scancount); } @@ -659,7 +659,7 @@ static INTERRUPT_GEN( cps2_interrupt ) state->cps_b_regs[0x12 / 2] = 0; cpu_set_input_line(device, 4, HOLD_LINE); cps2_set_sprite_priorities(device->machine); - video_screen_update_partial(device->machine->primary_screen, 16 - 10 + state->scancount); /* visarea.min_y - [first visible line?] + scancount */ + device->machine->primary_screen->update_partial(16 - 10 + state->scancount); /* visarea.min_y - [first visible line?] + scancount */ state->scancalls++; // popmessage("IRQ4 scancounter = %04i",scancount); } @@ -672,7 +672,7 @@ static INTERRUPT_GEN( cps2_interrupt ) if(state->scancalls) { cps2_set_sprite_priorities(device->machine); - video_screen_update_partial(device->machine->primary_screen, 256); + device->machine->primary_screen->update_partial(256); } cps2_objram_latch(device->machine); } @@ -1270,8 +1270,7 @@ static MACHINE_DRIVER_START( gigamn2 ) MDRV_DEVICE_REMOVE("qsound") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/32, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/cps3.c b/src/mame/drivers/cps3.c index c4d6a3667c3..86aefec79b0 100644 --- a/src/mame/drivers/cps3.c +++ b/src/mame/drivers/cps3.c @@ -822,7 +822,7 @@ static VIDEO_START(cps3) // the renderbuffer can be twice the size of the screen, this allows us to handle framebuffer zoom values // between 0x00 and 0x80 (0x40 is normal, 0x80 would be 'view twice as much', 0x20 is 'view half as much') - renderbuffer_bitmap = auto_bitmap_alloc(machine,512*2,224*2,video_screen_get_format(machine->primary_screen)); + renderbuffer_bitmap = auto_bitmap_alloc(machine,512*2,224*2,machine->primary_screen->format()); renderbuffer_clip.min_x = 0; renderbuffer_clip.max_x = cps3_screenwidth-1; @@ -920,8 +920,8 @@ static void cps3_draw_tilemapsprite_line(running_machine *machine, int tmnum, in static VIDEO_UPDATE(cps3) { int y,x, count; - attoseconds_t period = video_screen_get_frame_period(screen).attoseconds; - rectangle visarea = *video_screen_get_visible_area(screen); + attoseconds_t period = screen->frame_period().attoseconds; + rectangle visarea = screen->visible_area(); int bg_drawn[4] = { 0, 0, 0, 0 }; @@ -941,7 +941,7 @@ static VIDEO_UPDATE(cps3) cps3_screenwidth = 496; visarea.min_x = 0; visarea.max_x = 496-1; visarea.min_y = 0; visarea.max_y = 224-1; - video_screen_configure(screen, 496, 224, &visarea, period); + screen->configure(496, 224, visarea, period); } } else @@ -951,7 +951,7 @@ static VIDEO_UPDATE(cps3) cps3_screenwidth = 384; visarea.min_x = 0; visarea.max_x = 384-1; visarea.min_y = 0; visarea.max_y = 224-1; - video_screen_configure(screen, 384, 224, &visarea, period); + screen->configure(384, 224, visarea, period); } } @@ -1126,7 +1126,7 @@ static VIDEO_UPDATE(cps3) if (current_ypos&0x200) current_ypos-=0x400; - //if ( (whichbpp) && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + //if ( (whichbpp) && (machine->primary_screen->frame_number() & 1)) continue; /* use the palette value from the main list or the sublists? */ if (whichpal) diff --git a/src/mame/drivers/crospang.c b/src/mame/drivers/crospang.c index 304065d5a64..fc243b68f3b 100644 --- a/src/mame/drivers/crospang.c +++ b/src/mame/drivers/crospang.c @@ -346,8 +346,7 @@ static MACHINE_DRIVER_START( crospang ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -389,8 +388,7 @@ static MACHINE_DRIVER_START( bestri ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/crystal.c b/src/mame/drivers/crystal.c index 69c8ecd1bed..2ca628be2c1 100644 --- a/src/mame/drivers/crystal.c +++ b/src/mame/drivers/crystal.c @@ -644,7 +644,7 @@ static VIDEO_UPDATE( crystal ) UINT16 *srcline; int y; UINT16 head, tail; - UINT32 width = video_screen_get_width(screen); + UINT32 width = screen->width(); if (GetVidReg(space, 0x8e) & 1) { diff --git a/src/mame/drivers/cubeqst.c b/src/mame/drivers/cubeqst.c index 7ae66c36715..0aa3df60df5 100644 --- a/src/mame/drivers/cubeqst.c +++ b/src/mame/drivers/cubeqst.c @@ -89,7 +89,7 @@ static PALETTE_INIT( cubeqst ) static WRITE16_HANDLER( palette_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]); } @@ -172,7 +172,7 @@ static VIDEO_UPDATE( cubeqst ) static READ16_HANDLER( line_r ) { /* I think this is unusued */ - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } static INTERRUPT_GEN( vblank ) diff --git a/src/mame/drivers/cultures.c b/src/mame/drivers/cultures.c index b86eeb07126..b6b9bcf28c8 100644 --- a/src/mame/drivers/cultures.c +++ b/src/mame/drivers/cultures.c @@ -416,8 +416,7 @@ static MACHINE_DRIVER_START( cultures ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, (MCLK/1024)*132) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", (MCLK/1024)*132, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/cyberbal.c b/src/mame/drivers/cyberbal.c index 1ef688cd86c..f7df17cba10 100644 --- a/src/mame/drivers/cyberbal.c +++ b/src/mame/drivers/cyberbal.c @@ -64,7 +64,7 @@ static MACHINE_RESET( cyberbal ) atarigen_eeprom_reset(&state->atarigen); atarigen_slapstic_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, cyberbal_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, cyberbal_scanline_update, 8); atarigen_sound_io_reset(devtag_get_device(machine, "audiocpu")); cyberbal_sound_reset(machine); @@ -88,7 +88,7 @@ static MACHINE_RESET( cyberbal2p ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, cyberbal2p_update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, cyberbal_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, cyberbal_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/cybertnk.c b/src/mame/drivers/cybertnk.c index a8a0c0422a6..628914cd50e 100644 --- a/src/mame/drivers/cybertnk.c +++ b/src/mame/drivers/cybertnk.c @@ -307,12 +307,12 @@ static VIDEO_UPDATE( cybertnk ) dot|= col_bank<<4; if(fx) { - if(((x+xsize-(xz)) < video_screen_get_visible_area(screen)->max_x) && ((y+yi) < video_screen_get_visible_area(screen)->max_y)) + if(((x+xsize-(xz)) < screen->visible_area().max_x) && ((y+yi) < screen->visible_area().max_y)) *BITMAP_ADDR16(bitmap, y+yz, x+xsize-(xz)) = screen->machine->pens[dot]; } else { - if(((x+xz) < video_screen_get_visible_area(screen)->max_x) && ((y+yi) < video_screen_get_visible_area(screen)->max_y)) + if(((x+xz) < screen->visible_area().max_x) && ((y+yi) < screen->visible_area().max_y)) *BITMAP_ADDR16(bitmap, y+yz, x+xz) = screen->machine->pens[dot]; } } @@ -341,12 +341,12 @@ static VIDEO_UPDATE( cybertnk ) dot|= col_bank<<4; if(fx) { - if(((x+xsize-(xz)) < video_screen_get_visible_area(screen)->max_x) && ((y+yi) < video_screen_get_visible_area(screen)->max_y)) + if(((x+xsize-(xz)) < screen->visible_area().max_x) && ((y+yi) < screen->visible_area().max_y)) *BITMAP_ADDR16(bitmap, y+yz, x+xsize-(xz)) = screen->machine->pens[dot]; } else { - if(((x+x_dec+xi) < video_screen_get_visible_area(screen)->max_x) && ((y+yi) < video_screen_get_visible_area(screen)->max_y)) + if(((x+x_dec+xi) < screen->visible_area().max_x) && ((y+yi) < screen->visible_area().max_y)) *BITMAP_ADDR16(bitmap, y+yz, x+xz) = screen->machine->pens[dot]; } } diff --git a/src/mame/drivers/darkhors.c b/src/mame/drivers/darkhors.c index 14989d55fa6..c33e79df799 100644 --- a/src/mame/drivers/darkhors.c +++ b/src/mame/drivers/darkhors.c @@ -645,8 +645,7 @@ static MACHINE_DRIVER_START( darkhors ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 528000) // ?? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 528000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/darkseal.c b/src/mame/drivers/darkseal.c index 7982b947d4c..abdb069df2d 100644 --- a/src/mame/drivers/darkseal.c +++ b/src/mame/drivers/darkseal.c @@ -276,12 +276,10 @@ static MACHINE_DRIVER_START( darkseal ) MDRV_SOUND_ROUTE(0, "mono", 0.55) MDRV_SOUND_ROUTE(1, "mono", 0.55) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dassault.c b/src/mame/drivers/dassault.c index 68e4456989b..561c0b025d0 100644 --- a/src/mame/drivers/dassault.c +++ b/src/mame/drivers/dassault.c @@ -522,7 +522,7 @@ static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) dassault_state *state = (dassault_state *)device->machine->driver_data; /* the second OKIM6295 ROM is bank switched */ - okim6295_set_bank_base(state->oki2, (data & 1) * 0x40000); + state->oki2->set_bank_base((data & 1) * 0x40000); } static const ym2151_interface ym2151_config = @@ -551,17 +551,6 @@ static const deco16ic_interface dassault_deco16ic_intf = dassault_bank_callback }; -static MACHINE_START( dassault ) -{ - dassault_state *state = (dassault_state *)machine->driver_data; - - state->maincpu = devtag_get_device(machine, "maincpu"); - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->subcpu = devtag_get_device(machine, "sub"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->oki2 = devtag_get_device(machine, "oki2"); -} - static MACHINE_DRIVER_START( dassault ) /* driver data */ @@ -581,8 +570,6 @@ static MACHINE_DRIVER_START( dassault ) MDRV_QUANTUM_TIME(HZ(8400)) /* 140 CPU slices per frame */ - MDRV_MACHINE_START(dassault) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -612,13 +599,11 @@ static MACHINE_DRIVER_START( dassault ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, 2047848) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2047848, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dblewing.c b/src/mame/drivers/dblewing.c index 8c28a57d088..ab1f57fc51b 100644 --- a/src/mame/drivers/dblewing.c +++ b/src/mame/drivers/dblewing.c @@ -116,7 +116,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; xsize = y & 0x0800; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; @@ -772,8 +772,7 @@ static MACHINE_DRIVER_START( dblewing ) MDRV_SOUND_CONFIG(ym2151_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) - MDRV_SOUND_ADD("oki", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dbz.c b/src/mame/drivers/dbz.c index ff851eb3cb8..cbb02f1aeb3 100644 --- a/src/mame/drivers/dbz.c +++ b/src/mame/drivers/dbz.c @@ -416,8 +416,7 @@ static MACHINE_DRIVER_START( dbz ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ddealer.c b/src/mame/drivers/ddealer.c index 8d96dcd3541..725a0fc3d96 100644 --- a/src/mame/drivers/ddealer.c +++ b/src/mame/drivers/ddealer.c @@ -294,11 +294,11 @@ static VIDEO_UPDATE( ddealer ) static TIMER_DEVICE_CALLBACK( ddealer_mcu_sim ) { - ddealer_state *state = (ddealer_state *)timer->machine->driver_data; + ddealer_state *state = (ddealer_state *)timer.machine->driver_data; /*coin/credit simulation*/ /*$fe002 is used,might be for multiple coins for one credit settings.*/ - state->coin_input = (~(input_port_read(timer->machine, "IN0"))); + state->coin_input = (~(input_port_read(timer.machine, "IN0"))); if (state->coin_input & 0x01)//coin 1 { @@ -351,10 +351,10 @@ static TIMER_DEVICE_CALLBACK( ddealer_mcu_sim ) } /*random number generators,controls order of cards*/ - state->mcu_shared_ram[0x10 / 2] = mame_rand(timer->machine) & 0xffff; - state->mcu_shared_ram[0x12 / 2] = mame_rand(timer->machine) & 0xffff; - state->mcu_shared_ram[0x14 / 2] = mame_rand(timer->machine) & 0xffff; - state->mcu_shared_ram[0x16 / 2] = mame_rand(timer->machine) & 0xffff; + state->mcu_shared_ram[0x10 / 2] = mame_rand(timer.machine) & 0xffff; + state->mcu_shared_ram[0x12 / 2] = mame_rand(timer.machine) & 0xffff; + state->mcu_shared_ram[0x14 / 2] = mame_rand(timer.machine) & 0xffff; + state->mcu_shared_ram[0x16 / 2] = mame_rand(timer.machine) & 0xffff; } diff --git a/src/mame/drivers/ddenlovr.c b/src/mame/drivers/ddenlovr.c index 2d1fbb5326b..4b8f32bd24b 100644 --- a/src/mame/drivers/ddenlovr.c +++ b/src/mame/drivers/ddenlovr.c @@ -1537,13 +1537,17 @@ static WRITE16_HANDLER( ddenlovr16_transparency_mask_w ) static WRITE8_DEVICE_HANDLER( quizchq_oki_bank_w ) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 1) * 0x40000); } static WRITE16_DEVICE_HANDLER( ddenlovr_oki_bank_w ) { if (ACCESSING_BITS_0_7) - okim6295_set_bank_base(device, (data & 7) * 0x40000); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 7) * 0x40000); + } } @@ -1555,7 +1559,8 @@ static WRITE16_DEVICE_HANDLER( quiz365_oki_bank1_w ) if (ACCESSING_BITS_0_7) { state->okibank = (state->okibank & 2) | (data & 1); - okim6295_set_bank_base(device, state->okibank * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(state->okibank * 0x40000); } } @@ -1566,7 +1571,8 @@ static WRITE16_DEVICE_HANDLER( quiz365_oki_bank2_w ) if (ACCESSING_BITS_0_7) { state->okibank = (state->okibank & 1) | ((data & 1) << 1); - okim6295_set_bank_base(device, state->okibank * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(state->okibank * 0x40000); } } @@ -1835,7 +1841,7 @@ static WRITE16_HANDLER( ddenlovrk_protection2_w ) dynax_state *state = (dynax_state *)space->machine->driver_data; COMBINE_DATA(state->protection2); - okim6295_set_bank_base(state->oki, ((*state->protection2) & 0x7) * 0x40000); + state->oki->set_bank_base(((*state->protection2) & 0x7) * 0x40000); } static ADDRESS_MAP_START( ddenlovrk_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -1960,7 +1966,10 @@ static WRITE16_HANDLER( nettoqc_coincounter_w ) static WRITE16_DEVICE_HANDLER( nettoqc_oki_bank_w ) { if (ACCESSING_BITS_0_7) - okim6295_set_bank_base(device, (data & 3) * 0x40000); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 3) * 0x40000); + } } static ADDRESS_MAP_START( nettoqc_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -2521,7 +2530,8 @@ static WRITE8_HANDLER( hanakanz_palette_w ) static WRITE8_DEVICE_HANDLER( hanakanz_oki_bank_w ) { - okim6295_set_bank_base(device, (data & 0x40) ? 0x40000 : 0); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x40) ? 0x40000 : 0); } static READ8_HANDLER( hanakanz_rand_r ) @@ -2707,7 +2717,8 @@ static WRITE8_HANDLER( mjchuuka_coincounter_w ) static WRITE8_DEVICE_HANDLER( mjchuuka_oki_bank_w ) { // data & 0x08 ? - okim6295_set_bank_base(device, (data & 0x01) ? 0x40000 : 0); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x01) ? 0x40000 : 0); #ifdef MAME_DEBUG // popmessage("1e = %02x",data); @@ -3052,7 +3063,7 @@ ADDRESS_MAP_END static UINT8 hgokou_player_r( const address_space *space, int player ) { dynax_state *state = (dynax_state *)space->machine->driver_data; - UINT8 hopper_bit = ((state->hopper && !(video_screen_get_frame_number(space->machine->primary_screen) % 10)) ? 0 : (1 << 6)); + UINT8 hopper_bit = ((state->hopper && !(space->machine->primary_screen->frame_number() % 10)) ? 0 : (1 << 6)); if (!BIT(state->input_sel, 0)) return input_port_read(space->machine, player ? "KEY5" : "KEY0") | hopper_bit; if (!BIT(state->input_sel, 1)) return input_port_read(space->machine, player ? "KEY6" : "KEY1") | hopper_bit; @@ -3321,7 +3332,7 @@ static WRITE16_HANDLER( akamaru_protection1_w ) COMBINE_DATA(&state->prot_16); // BCD number? bank = (((state->prot_16 >> 4) & 0x0f) % 10) * 10 + ((state->prot_16 & 0x0f) % 10); - okim6295_set_bank_base(state->oki, bank * 0x40000); + state->oki->set_bank_base(bank * 0x40000); // popmessage("bank $%0x (%d)", state->prot_16, bank); } @@ -3409,7 +3420,8 @@ static WRITE8_HANDLER( mjflove_rombank_w ) static WRITE8_DEVICE_HANDLER( mjflove_okibank_w ) { - okim6295_set_bank_base(device, (data & 0x07) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x07) * 0x40000); //popmessage("SOUND = %02x", data); } @@ -3495,7 +3507,8 @@ ADDRESS_MAP_END static WRITE8_DEVICE_HANDLER( jongtei_okibank_w ) { - okim6295_set_bank_base(device, ((data >> 4) & 0x07) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(((data >> 4) & 0x07) * 0x40000); } static WRITE8_HANDLER( jongtei_dsw_keyb_w ) @@ -3674,7 +3687,8 @@ static READ8_HANDLER( daimyojn_protection_r ) static WRITE8_DEVICE_HANDLER( daimyojn_okibank_w ) { - okim6295_set_bank_base(device, ((data >> 4) & 0x01) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(((data >> 4) & 0x01) * 0x40000); } static WRITE8_HANDLER( daimyojn_palette_sel_w ) @@ -7564,7 +7578,7 @@ static MACHINE_START( ddenlovr ) state->maincpu = devtag_get_device(machine, "maincpu"); state->soundcpu = devtag_get_device(machine, "soundcpu"); - state->oki = devtag_get_device(machine, "oki"); + state->oki = machine->device("oki"); state_save_register_global(machine, state->input_sel); state_save_register_global(machine, state->dsw_sel); @@ -7732,8 +7746,7 @@ static MACHINE_DRIVER_START( ddenlovr ) MDRV_SOUND_ADD("aysnd", AY8910, XTAL_28_63636MHz / 16) // or /8 ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_28_63636MHz / 28) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_28_63636MHz / 28, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -7811,7 +7824,7 @@ static INTERRUPT_GEN( quizchq_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise quizchq would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; if ((++state->irq_count % 60) == 0) @@ -7861,8 +7874,7 @@ static MACHINE_DRIVER_START( quizchq ) MDRV_SOUND_ADD("ymsnd", YM2413, 3579545) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1022720) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1022720, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -7897,7 +7909,7 @@ static INTERRUPT_GEN( mmpanic_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise the game would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; if ((++state->irq_count % 60) == 0) @@ -7948,8 +7960,7 @@ static MACHINE_DRIVER_START( mmpanic ) MDRV_SOUND_ADD("aysnd", AY8910, 3579545) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, 1022720) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1022720, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -7975,7 +7986,7 @@ static INTERRUPT_GEN( hanakanz_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise quizchq would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; if ((++state->irq_count % 60) == 0) @@ -8018,8 +8029,7 @@ static MACHINE_DRIVER_START( hanakanz ) MDRV_SOUND_ADD("ymsnd", YM2413, 3579545) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1022720) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1022720, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -8057,7 +8067,7 @@ static INTERRUPT_GEN( mjchuuka_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise quizchq would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; if ((++state->irq_count % 60) == 0) @@ -8117,7 +8127,7 @@ static INTERRUPT_GEN( mjmyster_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise quizchq would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; switch (cpu_getiloops(device)) @@ -8175,7 +8185,7 @@ static INTERRUPT_GEN( hginga_irq ) /* I haven't found a irq ack register, so I need this kludge to make sure I don't lose any interrupt generated by the blitter, otherwise hginga would lock up. */ - if (device->get_runtime_int(CPUINFO_INT_INPUT_STATE + 0)) + if (downcast(device)->input_state(0)) return; if ((++state->irq_count % 60) == 0) @@ -8349,8 +8359,7 @@ static MACHINE_DRIVER_START( jongtei ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_28_63636MHz / 8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_28_63636MHz / 28) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_28_63636MHz / 28, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -8398,8 +8407,7 @@ static MACHINE_DRIVER_START( sryudens ) MDRV_SOUND_ADD("aysnd", AY8910, XTAL_28_63636MHz / 8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_28_63636MHz / 28) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_28_63636MHz / 28, OKIM6295_PIN7_HIGH) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ @@ -8444,8 +8452,7 @@ static MACHINE_DRIVER_START( daimyojn ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_28_63636MHz / 8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_28_63636MHz / 28) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_28_63636MHz / 28, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) /* devices */ diff --git a/src/mame/drivers/ddragon.c b/src/mame/drivers/ddragon.c index 3b6925d5621..b37d4ce511e 100644 --- a/src/mame/drivers/ddragon.c +++ b/src/mame/drivers/ddragon.c @@ -118,15 +118,15 @@ INLINE int scanline_to_vcount( int scanline ) static TIMER_DEVICE_CALLBACK( ddragon_scanline ) { - ddragon_state *state = (ddragon_state *)timer->machine->driver_data; + ddragon_state *state = (ddragon_state *)timer.machine->driver_data; int scanline = param; - int screen_height = video_screen_get_height(timer->machine->primary_screen); + int screen_height = timer.machine->primary_screen->height(); int vcount_old = scanline_to_vcount((scanline == 0) ? screen_height - 1 : scanline - 1); int vcount = scanline_to_vcount(scanline); /* update to the current point */ if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); /* on the rising edge of VBLK (vcount == F8), signal an NMI */ if (vcount == 0xf8) @@ -1133,8 +1133,7 @@ static MACHINE_DRIVER_START( ddragon2 ) MDRV_SOUND_ROUTE(0, "mono", 0.60) MDRV_SOUND_ROUTE(1, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ddragon3.c b/src/mame/drivers/ddragon3.c index 0423faa3b5c..fb300b0d815 100644 --- a/src/mame/drivers/ddragon3.c +++ b/src/mame/drivers/ddragon3.c @@ -156,7 +156,8 @@ ROMs (All ROMs are 27C010 EPROM. - means not populated) static WRITE8_DEVICE_HANDLER( oki_bankswitch_w ) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 1) * 0x40000); } static WRITE16_HANDLER( ddragon3_io_w ) @@ -532,21 +533,21 @@ static const ym2151_interface ym2151_config = static TIMER_DEVICE_CALLBACK( ddragon3_scanline ) { - ddragon3_state *state = (ddragon3_state *)timer->machine->driver_data; + ddragon3_state *state = (ddragon3_state *)timer.machine->driver_data; int scanline = param; /* An interrupt is generated every 16 scanlines */ if (scanline % 16 == 0) { if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); cpu_set_input_line(state->maincpu, 5, ASSERT_LINE); } /* Vblank is raised on scanline 248 */ if (scanline == 248) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); cpu_set_input_line(state->maincpu, 6, ASSERT_LINE); } } @@ -624,8 +625,7 @@ static MACHINE_DRIVER_START( ddragon3 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.50) MDRV_SOUND_ROUTE(1, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1_056MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dec0.c b/src/mame/drivers/dec0.c index 8c59759fcd4..37784a056dd 100644 --- a/src/mame/drivers/dec0.c +++ b/src/mame/drivers/dec0.c @@ -1218,8 +1218,7 @@ static MACHINE_DRIVER_START( hbarrel ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 2 / 10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1260,8 +1259,7 @@ static MACHINE_DRIVER_START( baddudes ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 2 / 10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1302,8 +1300,7 @@ static MACHINE_DRIVER_START( birdtry ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 2 / 10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1349,8 +1346,7 @@ static MACHINE_DRIVER_START( robocop ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 2 / 10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1391,8 +1387,7 @@ static MACHINE_DRIVER_START( robocopb ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1438,8 +1433,7 @@ static MACHINE_DRIVER_START( hippodrm ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 2 / 10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 2 / 10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1480,8 +1474,7 @@ static MACHINE_DRIVER_START( slyspy ) MDRV_SOUND_CONFIG(ym3812b_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/12) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1523,8 +1516,7 @@ static MACHINE_DRIVER_START( secretab ) MDRV_SOUND_CONFIG(ym3812b_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/12) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -1565,8 +1557,7 @@ static MACHINE_DRIVER_START( midres ) MDRV_SOUND_CONFIG(ym3812b_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1MHz) /* verified on pcb (1mhz crystal) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 verified on pcb + MDRV_OKIM6295_ADD("oki", XTAL_1MHz, OKIM6295_PIN7_HIGH) /* verified on pcb (1mhz crystal) */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.40) MACHINE_DRIVER_END diff --git a/src/mame/drivers/deco156.c b/src/mame/drivers/deco156.c index 394e2359675..4eaf8696ab9 100644 --- a/src/mame/drivers/deco156.c +++ b/src/mame/drivers/deco156.c @@ -27,16 +27,17 @@ class deco156_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, deco156_state(machine)); } - deco156_state(running_machine &machine) { } + deco156_state(running_machine &machine) + : oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * pf1_rowscroll; UINT16 * pf2_rowscroll; /* devices */ - running_device *maincpu; - running_device *deco16ic; - running_device *oki2; + cpu_device *maincpu; + deco16ic_device *deco16ic; + okim6295_device *oki2; }; @@ -70,7 +71,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan y = spriteram[offs] & 0xffff; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2] & 0xffff; @@ -157,14 +158,15 @@ static WRITE32_HANDLER(hvysmsh_eeprom_w) deco156_state *state = (deco156_state *)space->machine->driver_data; if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(state->oki2, 0x40000 * (data & 0x7)); + state->oki2->set_bank_base(0x40000 * (data & 0x7)); input_port_write(space->machine, "EEPROMOUT", data, 0xff); } } static WRITE32_DEVICE_HANDLER( hvysmsh_oki_0_bank_w ) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 1) * 0x40000); } static WRITE32_HANDLER(wcvol95_nonbuffered_palette_w) @@ -402,9 +404,8 @@ static MACHINE_START( deco156 ) { deco156_state *state = (deco156_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->oki2 = devtag_get_device(machine, "oki2"); + state->maincpu = machine->device("maincpu"); + state->deco16ic = machine->device("deco_custom"); } static MACHINE_DRIVER_START( hvysmsh ) @@ -442,13 +443,11 @@ static MACHINE_DRIVER_START( hvysmsh ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 28000000/28) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 28000000/28, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 28000000/14) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 28000000/14, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_DRIVER_END diff --git a/src/mame/drivers/deco32.c b/src/mame/drivers/deco32.c index 302e73c7580..af882efe631 100644 --- a/src/mame/drivers/deco32.c +++ b/src/mame/drivers/deco32.c @@ -239,7 +239,7 @@ Notes: static UINT32 *deco32_ram; static int raster_enable; -static running_device *raster_irq_timer; +static timer_device *raster_irq_timer; static UINT8 nslasher_sound_irq; /**********************************************************************************/ @@ -248,21 +248,21 @@ static UINT8 nslasher_sound_irq; static WRITE32_HANDLER( deco32_pf12_control_w ) { COMBINE_DATA(&deco32_pf12_control[offset]); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } static WRITE32_HANDLER( deco32_pf34_control_w ) { COMBINE_DATA(&deco32_pf34_control[offset]); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); } static TIMER_DEVICE_CALLBACK( interrupt_gen ) { - cputag_set_input_line(timer->machine, "maincpu", ARM_IRQ_LINE, HOLD_LINE); + cputag_set_input_line(timer.machine, "maincpu", ARM_IRQ_LINE, HOLD_LINE); } static READ32_HANDLER( deco32_irq_controller_r ) @@ -289,7 +289,7 @@ static READ32_HANDLER( deco32_irq_controller_r ) /* ZV03082007 - video_screen_get_vblank() doesn't work for Captain America, as it expects that this bit is NOT set in rows 0-7. */ - vblank = video_screen_get_vpos(space->machine->primary_screen) > video_screen_get_visible_area(space->machine->primary_screen)->max_y; + vblank = space->machine->primary_screen->vpos() > space->machine->primary_screen->visible_area().max_y; if (vblank) return 0xffffff80 | 0x1 | 0x10; /* Assume VBL takes priority over possible raster/lightgun irq */ @@ -316,10 +316,10 @@ static WRITE32_HANDLER( deco32_irq_controller_w ) if (raster_enable && scanline>0 && scanline<240) { // needs +16 for the raster to align on captaven intro? (might just be our screen size / visible area / layer offsets need adjusting instead) - timer_device_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, scanline+16, 320),0); + raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(scanline+16, 320)); } else - timer_device_adjust_oneshot(raster_irq_timer,attotime_never,0); + raster_irq_timer->reset(); break; case 2: /* VBL irq ack */ break; @@ -372,7 +372,7 @@ static READ32_HANDLER( fghthist_control_r ) static WRITE32_HANDLER( fghthist_eeprom_w ) { if (ACCESSING_BITS_0_7) { - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); eeprom_set_clock_line(device, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE); eeprom_write_bit(device, data & 0x10); eeprom_set_cs_line(device, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); @@ -642,7 +642,7 @@ static WRITE32_HANDLER( nslasher_eeprom_w ) { if (ACCESSING_BITS_0_7) { - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); eeprom_set_clock_line(device, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE); eeprom_write_bit(device, data & 0x10); eeprom_set_cs_line(device, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); @@ -1613,8 +1613,10 @@ static void sound_irq_nslasher(running_device *device, int state) static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) { - okim6295_set_bank_base(devtag_get_device(device->machine, "oki1"), ((data >> 0)& 1) * 0x40000); - okim6295_set_bank_base(devtag_get_device(device->machine, "oki2"), ((data >> 1)& 1) * 0x40000); + okim6295_device *oki1 = device->machine->device("oki1"); + okim6295_device *oki2 = device->machine->device("oki2"); + oki1->set_bank_base(((data >> 0)& 1) * 0x40000); + oki2->set_bank_base(((data >> 1)& 1) * 0x40000); } static const ym2151_interface ym2151_config = @@ -1639,7 +1641,7 @@ static const eeprom_interface eeprom_interface_tattass = static MACHINE_RESET( deco32 ) { - raster_irq_timer = devtag_get_device(machine, "int_timer"); + raster_irq_timer = machine->device("int_timer"); } static INTERRUPT_GEN( deco32_vbl_interrupt ) @@ -1690,13 +1692,11 @@ static MACHINE_DRIVER_START( captaven ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.42) MDRV_SOUND_ROUTE(1, "rspeaker", 0.42) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_32_22MHz/32) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* pin 7 is floating to 2.5V (left unconnected), so I presume High */ + MDRV_OKIM6295_ADD("oki1", XTAL_32_22MHz/32, OKIM6295_PIN7_HIGH) /* verified on pcb; pin 7 is floating to 2.5V (left unconnected), so I presume High */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_32_22MHz/16) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* pin 7 is floating to 2.5V (left unconnected), so I presume High */ + MDRV_OKIM6295_ADD("oki2", XTAL_32_22MHz/16, OKIM6295_PIN7_HIGH) /* verified on pcb; pin 7 is floating to 2.5V (left unconnected), so I presume High */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_DRIVER_END @@ -1736,13 +1736,11 @@ static MACHINE_DRIVER_START( fghthist ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.42) MDRV_SOUND_ROUTE(1, "rspeaker", 0.42) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_DRIVER_END @@ -1782,13 +1780,11 @@ static MACHINE_DRIVER_START( fghthsta ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.42) MDRV_SOUND_ROUTE(1, "rspeaker", 0.42) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) MACHINE_DRIVER_END @@ -1832,18 +1828,15 @@ static MACHINE_DRIVER_START( dragngun ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.42) MDRV_SOUND_ROUTE(1, "rspeaker", 0.42) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) - MDRV_SOUND_ADD("oki3", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki3", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -1887,18 +1880,15 @@ static MACHINE_DRIVER_START( lockload ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.42) MDRV_SOUND_ROUTE(1, "rspeaker", 0.42) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.35) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.35) - MDRV_SOUND_ADD("oki3", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki3", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -1977,13 +1967,11 @@ static MACHINE_DRIVER_START( nslasher ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.40) MDRV_SOUND_ROUTE(1, "rspeaker", 0.40) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) MACHINE_DRIVER_END diff --git a/src/mame/drivers/deco_mlc.c b/src/mame/drivers/deco_mlc.c index ef8cf9926ba..83e0197f941 100644 --- a/src/mame/drivers/deco_mlc.c +++ b/src/mame/drivers/deco_mlc.c @@ -109,7 +109,7 @@ VIDEO_EOF( mlc ); extern UINT32 *mlc_vram, *mlc_clip_ram; static UINT32 *mlc_ram, *irq_ram; -static running_device *raster_irq_timer; +static timer_device *raster_irq_timer; static int mainCpuIsArm; static int mlc_raster_table[9][256]; static UINT32 vbl_i; @@ -170,20 +170,20 @@ static READ32_HANDLER( decomlc_vbl_r ) static READ32_HANDLER( mlc_scanline_r ) { -// logerror("read scanline counter (%d)\n", video_screen_get_vpos(space->machine->primary_screen)); - return video_screen_get_vpos(space->machine->primary_screen); +// logerror("read scanline counter (%d)\n", space->machine->primary_screen->vpos()); + return space->machine->primary_screen->vpos(); } static TIMER_DEVICE_CALLBACK( interrupt_gen ) { -// logerror("hit scanline IRQ %d (%08x)\n", video_screen_get_vpos(machine->primary_screen), info.i); - cputag_set_input_line(timer->machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE); +// logerror("hit scanline IRQ %d (%08x)\n", machine->primary_screen->vpos(), info.i); + cputag_set_input_line(timer.machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE); } static WRITE32_HANDLER( mlc_irq_w ) { static int lastScanline[9]={ 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - int scanline=video_screen_get_vpos(space->machine->primary_screen); + int scanline=space->machine->primary_screen->vpos(); irq_ram[offset]=data&0xffff; switch (offset*4) @@ -192,8 +192,8 @@ static WRITE32_HANDLER( mlc_irq_w ) cputag_set_input_line(space->machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, CLEAR_LINE); return; case 0x14: /* Prepare scanline interrupt */ - timer_device_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, irq_ram[0x14/4], 0),0); - //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], video_screen_get_vpos(space->machine->primary_screen)); + raster_irq_timer->adjust(space->machine->primary_screen->time_until_pos(irq_ram[0x14/4])); + //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], space->machine->primary_screen->vpos()); return; case 0x18: case 0x1c: @@ -379,7 +379,7 @@ GFXDECODE_END static MACHINE_RESET( mlc ) { vbl_i = 0xffffffff; - raster_irq_timer = devtag_get_device(machine, "int_timer"); + raster_irq_timer = machine->device("int_timer"); } static MACHINE_DRIVER_START( avengrgs ) diff --git a/src/mame/drivers/deniam.c b/src/mame/drivers/deniam.c index 714dc7232f9..5e6b8242aed 100644 --- a/src/mame/drivers/deniam.c +++ b/src/mame/drivers/deniam.c @@ -62,13 +62,17 @@ static WRITE16_HANDLER( sound_command_w ) static WRITE8_DEVICE_HANDLER( deniam16b_oki_rom_bank_w ) { - okim6295_set_bank_base(device, (data & 0x40) ? 0x40000 : 0x00000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x40) ? 0x40000 : 0x00000); } static WRITE16_DEVICE_HANDLER( deniam16c_oki_rom_bank_w ) { if (ACCESSING_BITS_0_7) - okim6295_set_bank_base(device, (data & 0x01) ? 0x40000 : 0x00000); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x01) ? 0x40000 : 0x00000); + } } static WRITE16_HANDLER( deniam_irq_ack_w ) @@ -262,7 +266,7 @@ static MACHINE_START( deniam ) static MACHINE_RESET( deniam ) { /* logicpr2 does not reset the bank base on startup */ - okim6295_set_bank_base(devtag_get_device(machine, "oki"), 0x00000); + machine->device("oki")->set_bank_base(0x00000); } static MACHINE_DRIVER_START( deniam16b ) @@ -304,8 +308,7 @@ static MACHINE_DRIVER_START( deniam16b ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_25MHz/24) /* 1.041620 measured, = 1.0416666Mhz verified */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 verified high + MDRV_OKIM6295_ADD("oki", XTAL_25MHz/24, OKIM6295_PIN7_HIGH) /* 1.041620 measured, = 1.0416666Mhz verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -344,8 +347,7 @@ static MACHINE_DRIVER_START( deniam16c ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_25MHz/24) /* 1.041620 measured, = 1.0416666Mhz verified */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 verified high + MDRV_OKIM6295_ADD("oki", XTAL_25MHz/24, OKIM6295_PIN7_HIGH) /* 1.041620 measured, = 1.0416666Mhz verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/destroyr.c b/src/mame/drivers/destroyr.c index 1a4af3aa1df..063717c49c7 100644 --- a/src/mame/drivers/destroyr.c +++ b/src/mame/drivers/destroyr.c @@ -131,8 +131,8 @@ static TIMER_CALLBACK( destroyr_frame_callback ) state->potsense[1] = 0; /* PCB supports two dials, but cab has only got one */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, input_port_read(machine, "PADDLE"), 0), NULL, 0, destroyr_dial_callback); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, destroyr_frame_callback); + timer_set(machine, machine->primary_screen->time_until_pos(input_port_read(machine, "PADDLE"), 0), NULL, 0, destroyr_dial_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, destroyr_frame_callback); } @@ -140,7 +140,7 @@ static MACHINE_RESET( destroyr ) { destroyr_state *state = (destroyr_state *)machine->driver_data; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, destroyr_frame_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, destroyr_frame_callback); state->cursor = 0; state->wavemod = 0; @@ -256,7 +256,7 @@ static READ8_HANDLER( destroyr_input_r ) static READ8_HANDLER( destroyr_scanline_r ) { - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } diff --git a/src/mame/drivers/dietgo.c b/src/mame/drivers/dietgo.c index 2458e6960c6..93947f3a6db 100644 --- a/src/mame/drivers/dietgo.c +++ b/src/mame/drivers/dietgo.c @@ -236,8 +236,7 @@ static MACHINE_DRIVER_START( dietgo ) MDRV_SOUND_CONFIG(ym2151_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32_22MHz/32) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_32_22MHz/32, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/diverboy.c b/src/mame/drivers/diverboy.c index ec0a956b495..d1897e20bf7 100644 --- a/src/mame/drivers/diverboy.c +++ b/src/mame/drivers/diverboy.c @@ -96,7 +96,7 @@ static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rect bank = (source[1] & 0x0002) >> 1; - if (!flash || (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (!flash || (machine->primary_screen->frame_number() & 1)) { drawgfx_transpen(bitmap,cliprect,machine->gfx[bank], number, @@ -134,7 +134,8 @@ static WRITE8_DEVICE_HANDLER( okibank_w ) /* bit 2 might be reset */ // popmessage("%02x",data); - okim6295_set_bank_base(device, (data & 3) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 3) * 0x40000); } @@ -277,8 +278,7 @@ static MACHINE_DRIVER_START( diverboy ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1320000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1320000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/djboy.c b/src/mame/drivers/djboy.c index d50c57a49b3..9e2927db6e9 100644 --- a/src/mame/drivers/djboy.c +++ b/src/mame/drivers/djboy.c @@ -956,12 +956,10 @@ static MACHINE_DRIVER_START( djboy ) MDRV_SOUND_ADD("ymsnd", YM2203, 3000000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, 12000000 / 8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 12000000 / 8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, 12000000 / 8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 12000000 / 8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dlair.c b/src/mame/drivers/dlair.c index 90711d9c4e4..7df3a7e7f5a 100644 --- a/src/mame/drivers/dlair.c +++ b/src/mame/drivers/dlair.c @@ -65,7 +65,7 @@ * *************************************/ -static running_device *laserdisc; +static laserdisc_device *laserdisc; static UINT8 last_misc; static UINT8 laserdisc_type; @@ -125,7 +125,7 @@ static const z80sio_interface sio_intf = }; -static const z80_daisy_chain dleuro_daisy_chain[] = +static const z80_daisy_config dleuro_daisy_chain[] = { { "sio" }, { "ctc" }, @@ -184,7 +184,7 @@ static VIDEO_UPDATE( dleuro ) static MACHINE_START( dlair ) { - laserdisc = devtag_get_device(machine, "laserdisc"); + laserdisc = machine->device("laserdisc"); } @@ -209,12 +209,12 @@ static MACHINE_RESET( dlair ) static INTERRUPT_GEN( vblank_callback ) { /* also update the speaker on the European version */ - running_device *beep = devtag_get_device(device->machine, "beep"); + beep_sound_device *beep = device->machine->device("beep"); if (beep != NULL) { - running_device *ctc = devtag_get_device(device->machine, "ctc"); + z80ctc_device *ctc = device->machine->device("ctc"); beep_set_state(beep, 1); - beep_set_frequency(beep, ATTOSECONDS_TO_HZ(z80ctc_getperiod(ctc, 0).attoseconds)); + beep_set_frequency(beep, ATTOSECONDS_TO_HZ(ctc->period(0).attoseconds)); } } diff --git a/src/mame/drivers/dooyong.c b/src/mame/drivers/dooyong.c index df4cca6e689..397e3e4bb29 100644 --- a/src/mame/drivers/dooyong.c +++ b/src/mame/drivers/dooyong.c @@ -794,8 +794,7 @@ static MACHINE_DRIVER_START( sound_2151 ) MDRV_SOUND_ROUTE(0, "mono", 0.50) MDRV_SOUND_ROUTE(1, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END @@ -807,8 +806,7 @@ static MACHINE_DRIVER_START( sound_2151_m68k ) MDRV_SOUND_ROUTE(0, "mono", 0.50) MDRV_SOUND_ROUTE(1, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dorachan.c b/src/mame/drivers/dorachan.c index ab111576194..27662062686 100644 --- a/src/mame/drivers/dorachan.c +++ b/src/mame/drivers/dorachan.c @@ -134,7 +134,7 @@ static CUSTOM_INPUT( dorachan_v128_r ) dorachan_state *state = (dorachan_state *)field->port->machine->driver_data; /* to avoid resetting (when player 2 starts) bit 0 need to be inverted when screen is flipped */ - return ((video_screen_get_vpos(field->port->machine->primary_screen) >> 7) & 0x01) ^ state->flip_screen; + return ((field->port->machine->primary_screen->vpos() >> 7) & 0x01) ^ state->flip_screen; } diff --git a/src/mame/drivers/dotrikun.c b/src/mame/drivers/dotrikun.c index c922f90c22e..e9d2f7b020e 100644 --- a/src/mame/drivers/dotrikun.c +++ b/src/mame/drivers/dotrikun.c @@ -49,7 +49,7 @@ public: static WRITE8_HANDLER( dotrikun_color_w ) { dotrikun_state *state = (dotrikun_state *)space->machine->driver_data; - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); state->color = data; } diff --git a/src/mame/drivers/dragrace.c b/src/mame/drivers/dragrace.c index e2b844f87f6..7ad510c3fda 100644 --- a/src/mame/drivers/dragrace.c +++ b/src/mame/drivers/dragrace.c @@ -13,13 +13,13 @@ Atari Drag Race Driver static TIMER_DEVICE_CALLBACK( dragrace_frame_callback ) { - dragrace_state *state = (dragrace_state *)timer->machine->driver_data; + dragrace_state *state = (dragrace_state *)timer.machine->driver_data; int i; static const char *const portnames[] = { "P1", "P2" }; for (i = 0; i < 2; i++) { - switch (input_port_read(timer->machine, portnames[i])) + switch (input_port_read(timer.machine, portnames[i])) { case 0x01: state->gear[i] = 1; break; case 0x02: state->gear[i] = 2; break; @@ -30,7 +30,7 @@ static TIMER_DEVICE_CALLBACK( dragrace_frame_callback ) } /* watchdog is disabled during service mode */ - watchdog_enable(timer->machine, input_port_read(timer->machine, "IN0") & 0x20); + watchdog_enable(timer.machine, input_port_read(timer.machine, "IN0") & 0x20); } @@ -163,7 +163,7 @@ static READ8_HANDLER( dragrace_steering_r ) static READ8_HANDLER( dragrace_scanline_r ) { - return (video_screen_get_vpos(space->machine->primary_screen) ^ 0xf0) | 0x0f; + return (space->machine->primary_screen->vpos() ^ 0xf0) | 0x0f; } diff --git a/src/mame/drivers/dreamwld.c b/src/mame/drivers/dreamwld.c index 126ad2695d2..6079e1bc639 100644 --- a/src/mame/drivers/dreamwld.c +++ b/src/mame/drivers/dreamwld.c @@ -448,13 +448,11 @@ static MACHINE_DRIVER_START( dreamwld ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, MASTER_CLOCK/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", MASTER_CLOCK/32, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, MASTER_CLOCK/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", MASTER_CLOCK/32, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/drgnmst.c b/src/mame/drivers/drgnmst.c index 25e165746a2..d09412fb467 100644 --- a/src/mame/drivers/drgnmst.c +++ b/src/mame/drivers/drgnmst.c @@ -157,14 +157,14 @@ static WRITE8_HANDLER( drgnmst_snd_control_w ) state->oki0_bank = oki_new_bank; if (state->oki0_bank) oki_new_bank--; - okim6295_set_bank_base(state->oki_1, (oki_new_bank * 0x40000)); + state->oki_1->set_bank_base(oki_new_bank * 0x40000); } oki_new_bank = ((state->pic16c5x_port0 & 0x3) >> 0) | ((state->oki_control & 0x20) >> 3); if (oki_new_bank != state->oki1_bank) { state->oki1_bank = oki_new_bank; - okim6295_set_bank_base(state->oki_2, (oki_new_bank * 0x40000)); + state->oki_2->set_bank_base(oki_new_bank * 0x40000); } switch (state->oki_control & 0x1f) @@ -381,9 +381,6 @@ static MACHINE_START( drgnmst ) { drgnmst_state *state = (drgnmst_state *)machine->driver_data; - state->oki_1 = devtag_get_device(machine, "oki1"); - state->oki_2 = devtag_get_device(machine, "oki2"); - state_save_register_global(machine, state->snd_flag); state_save_register_global(machine, state->snd_command); state_save_register_global(machine, state->oki_control); @@ -437,13 +434,11 @@ static MACHINE_DRIVER_START( drgnmst ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 32000000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32000000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, 32000000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32000000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/drtomy.c b/src/mame/drivers/drtomy.c index ed0e03320d8..88701ac0a5e 100644 --- a/src/mame/drivers/drtomy.c +++ b/src/mame/drivers/drtomy.c @@ -153,7 +153,8 @@ static WRITE16_DEVICE_HANDLER( drtomy_okibank_w ) if (state->oki_bank != (data & 3)) { state->oki_bank = data & 3; - okim6295_set_bank_base(device, state->oki_bank * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(state->oki_bank * 0x40000); } /* unknown bit 2 -> (data & 4) */ @@ -320,8 +321,7 @@ static MACHINE_DRIVER_START( drtomy ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 26000000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 26000000/16, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.8) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dunhuang.c b/src/mame/drivers/dunhuang.c index 57b150d3312..50b9c8b28f6 100644 --- a/src/mame/drivers/dunhuang.c +++ b/src/mame/drivers/dunhuang.c @@ -431,7 +431,7 @@ static READ8_HANDLER( dunhuang_service_r ) { dunhuang_state *state = (dunhuang_state *)space->machine->driver_data; return input_port_read(space->machine, "SERVICE") - | ((state->hopper && !(video_screen_get_frame_number(space->machine->primary_screen) % 10)) ? 0x00 : 0x08) // bit 3: hopper sensor + | ((state->hopper && !(space->machine->primary_screen->frame_number() % 10)) ? 0x00 : 0x08) // bit 3: hopper sensor | 0x80 // bit 7 low -> tiles block transferrer busy ; } @@ -853,8 +853,7 @@ static MACHINE_DRIVER_START( dunhuang ) MDRV_SOUND_CONFIG(dunhuang_ay8910_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 12000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/dynax.c b/src/mame/drivers/dynax.c index 40bc599925b..7778784ea12 100644 --- a/src/mame/drivers/dynax.c +++ b/src/mame/drivers/dynax.c @@ -626,7 +626,7 @@ static WRITE8_HANDLER( hjingi_hopper_w ) static UINT8 hjingi_hopper_bit( running_machine *machine ) { dynax_state *state = (dynax_state *)machine->driver_data; - return (state->hopper && !(video_screen_get_frame_number(machine->primary_screen) % 10)) ? 0 : (1 << 6); + return (state->hopper && !(machine->primary_screen->frame_number() % 10)) ? 0 : (1 << 6); } static READ8_HANDLER( hjingi_keyboard_0_r ) @@ -1203,7 +1203,7 @@ static READ8_HANDLER( htengoku_coin_r ) { case 0x00: return input_port_read(space->machine, "COINS"); case 0x01: return 0xff; //? - case 0x02: return 0xbf | ((state->hopper && !(video_screen_get_frame_number(space->machine->primary_screen) % 10)) ? 0 : (1 << 6)); // bit 7 = blitter busy, bit 6 = hopper + case 0x02: return 0xbf | ((state->hopper && !(space->machine->primary_screen->frame_number() % 10)) ? 0 : (1 << 6)); // bit 7 = blitter busy, bit 6 = hopper case 0x03: return state->coins; } logerror("%04x: coin_r with select = %02x\n", cpu_get_pc(space->cpu), state->input_sel); diff --git a/src/mame/drivers/egghunt.c b/src/mame/drivers/egghunt.c index 4a66990cd97..a5d56b1268a 100644 --- a/src/mame/drivers/egghunt.c +++ b/src/mame/drivers/egghunt.c @@ -217,7 +217,8 @@ static WRITE8_DEVICE_HANDLER( egghunt_okibanking_w ) { egghunt_state *state = (egghunt_state *)device->machine->driver_data; state->okibanking = data; - okim6295_set_bank_base(device, (data & 0x10) ? 0x40000 : 0); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x10) ? 0x40000 : 0); } static ADDRESS_MAP_START( egghunt_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -442,8 +443,7 @@ static MACHINE_DRIVER_START( egghunt ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/enigma2.c b/src/mame/drivers/enigma2.c index 38c3d0aebdc..abe9ecf716e 100644 --- a/src/mame/drivers/enigma2.c +++ b/src/mame/drivers/enigma2.c @@ -113,7 +113,7 @@ static TIMER_CALLBACK( interrupt_assert_callback ) int next_vpos; /* compute vector and set the interrupt line */ - int vpos = video_screen_get_vpos(machine->primary_screen); + int vpos = machine->primary_screen->vpos(); UINT16 counter = vpos_to_vysnc_chain_counter(vpos); UINT8 vector = 0xc7 | ((counter & 0x80) >> 3) | ((~counter & 0x80) >> 4); cpu_set_input_line_and_vector(state->maincpu, 0, ASSERT_LINE, vector); @@ -125,8 +125,8 @@ static TIMER_CALLBACK( interrupt_assert_callback ) next_counter = INT_TRIGGER_COUNT_1; next_vpos = vysnc_chain_counter_to_vpos(next_counter); - timer_adjust_oneshot(state->interrupt_assert_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0); - timer_adjust_oneshot(state->interrupt_clear_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos + 1, 0), 0); + timer_adjust_oneshot(state->interrupt_assert_timer, machine->primary_screen->time_until_pos(next_vpos), 0); + timer_adjust_oneshot(state->interrupt_clear_timer, machine->primary_screen->time_until_pos(vpos + 1), 0); } @@ -142,7 +142,7 @@ static void start_interrupt_timers( running_machine *machine ) { enigma2_state *state = (enigma2_state *)machine->driver_data; int vpos = vysnc_chain_counter_to_vpos(INT_TRIGGER_COUNT_1); - timer_adjust_oneshot(state->interrupt_assert_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_assert_timer, machine->primary_screen->time_until_pos(vpos), 0); } @@ -201,13 +201,13 @@ static VIDEO_UPDATE( enigma2 ) enigma2_state *state = (enigma2_state *)screen->machine->driver_data; pen_t pens[NUM_PENS]; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); UINT8 *prom = memory_region(screen->machine, "proms"); UINT8 *color_map_base = state->flip_screen ? &prom[0x0400] : &prom[0x0000]; UINT8 *star_map_base = (state->blink_count & 0x08) ? &prom[0x0c00] : &prom[0x0800]; UINT8 x = 0; - UINT16 bitmap_y = visarea->min_y; + UINT16 bitmap_y = visarea.min_y; UINT8 y = (UINT8)vpos_to_vysnc_chain_counter(bitmap_y); UINT8 video_data = 0; UINT8 fore_color = 0; @@ -269,7 +269,7 @@ static VIDEO_UPDATE( enigma2 ) if (x == 0) { /* end of screen? */ - if (bitmap_y == visarea->max_y) + if (bitmap_y == visarea.max_y) break; /* next row */ @@ -288,8 +288,8 @@ static VIDEO_UPDATE( enigma2a ) { enigma2_state *state = (enigma2_state *)screen->machine->driver_data; UINT8 x = 0; - const rectangle *visarea = video_screen_get_visible_area(screen); - UINT16 bitmap_y = visarea->min_y; + const rectangle &visarea = screen->visible_area(); + UINT16 bitmap_y = visarea.min_y; UINT8 y = (UINT8)vpos_to_vysnc_chain_counter(bitmap_y); UINT8 video_data = 0; @@ -332,7 +332,7 @@ static VIDEO_UPDATE( enigma2a ) if (x == 0) { /* end of screen? */ - if (bitmap_y == visarea->max_y) + if (bitmap_y == visarea.max_y) break; /* next row */ diff --git a/src/mame/drivers/eolith.c b/src/mame/drivers/eolith.c index f0a57416486..3c3eebb307c 100644 --- a/src/mame/drivers/eolith.c +++ b/src/mame/drivers/eolith.c @@ -365,12 +365,14 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( eolith50 ) MDRV_IMPORT_FROM(eolith45) - MDRV_CPU_REPLACE("maincpu", E132N, 50000000) /* 50 MHz */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(50000000) /* 50 MHz */ MACHINE_DRIVER_END static MACHINE_DRIVER_START( ironfort ) MDRV_IMPORT_FROM(eolith45) - MDRV_CPU_REPLACE("maincpu", E132N, 44900000) /* Normaly 45MHz??? but PCB actually had a 44.9MHz OSC, so it's value is used */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(44900000) /* Normaly 45MHz??? but PCB actually had a 44.9MHz OSC, so it's value is used */ MACHINE_DRIVER_END diff --git a/src/mame/drivers/eolith16.c b/src/mame/drivers/eolith16.c index 46204f7c0a2..afe53c6c9a2 100644 --- a/src/mame/drivers/eolith16.c +++ b/src/mame/drivers/eolith16.c @@ -180,8 +180,7 @@ static MACHINE_DRIVER_START( eolith16 ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/eprom.c b/src/mame/drivers/eprom.c index c93082369e5..b72b0d0d1c3 100644 --- a/src/mame/drivers/eprom.c +++ b/src/mame/drivers/eprom.c @@ -61,7 +61,7 @@ static MACHINE_RESET( eprom ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, eprom_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, eprom_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/esd16.c b/src/mame/drivers/esd16.c index 06bb99c74d6..46f4af255b8 100644 --- a/src/mame/drivers/esd16.c +++ b/src/mame/drivers/esd16.c @@ -574,8 +574,7 @@ static MACHINE_DRIVER_START( multchmp ) MDRV_SOUND_ADD("ymsnd", YM3812, 4000000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/esripsys.c b/src/mame/drivers/esripsys.c index 611e8a85558..363bfe22598 100644 --- a/src/mame/drivers/esripsys.c +++ b/src/mame/drivers/esripsys.c @@ -131,7 +131,7 @@ static READ8_HANDLER( uart_r ) static READ8_HANDLER( g_status_r ) { int bank4 = BIT(get_rip_status(devtag_get_device(space->machine, "video_cpu")), 2); - int vblank = video_screen_get_vblank(space->machine->primary_screen); + int vblank = space->machine->primary_screen->vblank(); return (!vblank << 7) | (bank4 << 6) | (f_status & 0x2f); } @@ -178,7 +178,7 @@ static WRITE8_HANDLER( g_status_w ) static READ8_HANDLER( f_status_r ) { - int vblank = video_screen_get_vblank(space->machine->primary_screen); + int vblank = space->machine->primary_screen->vblank(); UINT8 rip_status = get_rip_status(devtag_get_device(space->machine, "video_cpu")); rip_status = (rip_status & 0x18) | (BIT(rip_status, 6) << 1) | BIT(rip_status, 7); @@ -272,9 +272,9 @@ static WRITE16_DEVICE_HANDLER( fdt_rip_w ) static UINT8 rip_status_in(running_machine *machine) { - int vpos = video_screen_get_vpos(machine->primary_screen); + int vpos = machine->primary_screen->vpos(); UINT8 _vblank = !(vpos >= ESRIPSYS_VBLANK_START); -// UINT8 _hblank = !video_screen_get_hblank(machine->primary_screen); +// UINT8 _hblank = !machine->primary_screen->hblank(); return _vblank | (esripsys_hblank << 1) diff --git a/src/mame/drivers/expro02.c b/src/mame/drivers/expro02.c index da4f63d71c5..7ed2f52f62e 100644 --- a/src/mame/drivers/expro02.c +++ b/src/mame/drivers/expro02.c @@ -506,8 +506,7 @@ static MACHINE_DRIVER_START( galsnew ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/6) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 12000000/6, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/exprraid.c b/src/mame/drivers/exprraid.c index 84eb4be1bad..2ed79a29a3d 100644 --- a/src/mame/drivers/exprraid.c +++ b/src/mame/drivers/exprraid.c @@ -540,7 +540,6 @@ static MACHINE_DRIVER_START( exprboot ) MDRV_CPU_REPLACE("maincpu", M6502, 4000000) /* 4 MHz ??? */ MDRV_CPU_PROGRAM_MAP(master_map) - MDRV_CPU_IO_MAP(0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/exterm.c b/src/mame/drivers/exterm.c index bc743b3df49..5cfcb49cadb 100644 --- a/src/mame/drivers/exterm.c +++ b/src/mame/drivers/exterm.c @@ -212,7 +212,7 @@ static TIMER_DEVICE_CALLBACK( master_sound_nmi_callback ) { /* bit 0 of the sound control determines if the NMI is actually delivered */ if (sound_control & 0x01) - cputag_set_input_line(timer->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); } @@ -229,7 +229,8 @@ static WRITE8_HANDLER( sound_nmi_rate_w ) /* this value is latched into up-counters, which are clocked at the */ /* input clock / 256 */ attotime nmi_rate = attotime_mul(ATTOTIME_IN_HZ(4000000), 4096 * (256 - data)); - timer_device_adjust_periodic(devtag_get_device(space->machine, "snd_nmi_timer"), nmi_rate, 0, nmi_rate); + timer_device *nmi_timer = space->machine->device("snd_nmi_timer"); + nmi_timer->adjust(nmi_rate, 0, nmi_rate); } diff --git a/src/mame/drivers/f-32.c b/src/mame/drivers/f-32.c index 3b22ec01d66..421c38e5054 100644 --- a/src/mame/drivers/f-32.c +++ b/src/mame/drivers/f-32.c @@ -159,8 +159,7 @@ static MACHINE_DRIVER_START( mosaicf2 ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1789772.5) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1789772.5, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/f1gp.c b/src/mame/drivers/f1gp.c index c881901cfcb..69356c378ff 100644 --- a/src/mame/drivers/f1gp.c +++ b/src/mame/drivers/f1gp.c @@ -553,8 +553,7 @@ static MACHINE_DRIVER_START( f1gpb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/fantland.c b/src/mame/drivers/fantland.c index 9556130a243..3402efde6a7 100644 --- a/src/mame/drivers/fantland.c +++ b/src/mame/drivers/fantland.c @@ -194,7 +194,7 @@ static READ8_HANDLER( borntofi_inputs_r ) x = input_port_read(space->machine, offset ? "P2 Trackball X" : "P1 Trackball X"); y = input_port_read(space->machine, offset ? "P2 Trackball Y" : "P1 Trackball Y"); - f = video_screen_get_frame_number(space->machine->primary_screen); + f = space->machine->primary_screen->frame_number(); state->input_ret[offset] = (state->input_ret[offset] & 0x14) | (input_port_read(space->machine, offset ? "P2_TRACK" : "P1_TRACK") & 0xc3); diff --git a/src/mame/drivers/fcrash.c b/src/mame/drivers/fcrash.c index 94e194be02a..3da63165022 100644 --- a/src/mame/drivers/fcrash.c +++ b/src/mame/drivers/fcrash.c @@ -818,8 +818,7 @@ static MACHINE_DRIVER_START( kodb ) // MDRV_SOUND_ROUTE(0, "mono", 0.35) // MDRV_SOUND_ROUTE(1, "mono", 0.35) -// MDRV_SOUND_ADD("oki", OKIM6295, 1000000) -// MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 can be changed by the game code, see f006 on z80 +// MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // pin 7 can be changed by the game code, see f006 on z80 // MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/feversoc.c b/src/mame/drivers/feversoc.c index d04422d1db0..90dbc244da7 100644 --- a/src/mame/drivers/feversoc.c +++ b/src/mame/drivers/feversoc.c @@ -136,7 +136,8 @@ static WRITE32_HANDLER( output_w ) //data>>16 & 2 coin out coin_counter_w(space->machine, 1,data>>16 & 4); //data>>16 & 8 coin hopper - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), 0x40000 * (((data>>16) & 0x20)>>5)); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base(0x40000 * (((data>>16) & 0x20)>>5)); } if(ACCESSING_BITS_0_15) { @@ -255,8 +256,7 @@ static MACHINE_DRIVER_START( feversoc ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MASTER_CLOCK/16) //pin 7 & frequency not verified (clock should be 28,6363 / n) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", MASTER_CLOCK/16, OKIM6295_PIN7_LOW) //pin 7 & frequency not verified (clock should be 28,6363 / n) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.6) MACHINE_DRIVER_END diff --git a/src/mame/drivers/fgoal.c b/src/mame/drivers/fgoal.c index 3f980fc35aa..39220a1fb28 100644 --- a/src/mame/drivers/fgoal.c +++ b/src/mame/drivers/fgoal.c @@ -81,12 +81,12 @@ static TIMER_CALLBACK( interrupt_callback ) state->prev_coin = coin; - scanline = video_screen_get_vpos(machine->primary_screen) + 128; + scanline = machine->primary_screen->vpos() + 128; if (scanline > 256) scanline = 0; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, 0, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, 0, interrupt_callback); } @@ -106,7 +106,7 @@ static READ8_HANDLER( fgoal_analog_r ) static CUSTOM_INPUT( fgoal_80_r ) { - UINT8 ret = (video_screen_get_vpos(field->port->machine->primary_screen) & 0x80) ? 1 : 0; + UINT8 ret = (field->port->machine->primary_screen->vpos() & 0x80) ? 1 : 0; return ret; } @@ -356,7 +356,7 @@ static MACHINE_RESET( fgoal ) { fgoal_state *state = (fgoal_state *)machine->driver_data; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, interrupt_callback); state->xpos = 0; state->ypos = 0; diff --git a/src/mame/drivers/firebeat.c b/src/mame/drivers/firebeat.c index 946196335b0..9e1b94eb568 100644 --- a/src/mame/drivers/firebeat.c +++ b/src/mame/drivers/firebeat.c @@ -470,7 +470,7 @@ static VIDEO_UPDATE(firebeat) { int chip; - if (screen == screen->machine->devicelist.find(VIDEO_SCREEN, 0)) + if (screen == screen->machine->devicelist.find(SCREEN, 0)) chip = 0; else chip = 1; @@ -599,11 +599,11 @@ static void GCU_w(running_machine *machine, int chip, UINT32 offset, UINT32 data COMBINE_DATA( &gcu[chip].visible_area ); if (ACCESSING_BITS_0_15) { - running_device *screen = machine->devicelist.find(VIDEO_SCREEN, chip); + screen_device *screen = downcast(machine->devicelist.find(SCREEN, chip)); if (screen != NULL) { - rectangle visarea = *video_screen_get_visible_area(screen); + rectangle visarea = screen->visible_area(); int width, height; width = (gcu[chip].visible_area & 0xffff); @@ -612,7 +612,7 @@ static void GCU_w(running_machine *machine, int chip, UINT32 offset, UINT32 data visarea.max_x = width-1; visarea.max_y = height-1; - video_screen_configure(screen, visarea.max_x + 1, visarea.max_y + 1, &visarea, video_screen_get_frame_period(screen).attoseconds); + screen->configure(visarea.max_x + 1, visarea.max_y + 1, visarea, screen->frame_period().attoseconds); } } break; diff --git a/src/mame/drivers/firefox.c b/src/mame/drivers/firefox.c index 53e31cd864d..9128378b7d2 100644 --- a/src/mame/drivers/firefox.c +++ b/src/mame/drivers/firefox.c @@ -157,14 +157,14 @@ static VIDEO_START( firefox ) { bgtiles = tilemap_create(machine, bgtile_get_info, tilemap_scan_rows, 8,8, 64,64); tilemap_set_transparent_pen(bgtiles, 0); - tilemap_set_scrolldy(bgtiles, video_screen_get_visible_area(machine->primary_screen)->min_y, 0); + tilemap_set_scrolldy(bgtiles, machine->primary_screen->visible_area().min_y, 0); } static VIDEO_UPDATE( firefox ) { int sprite; - int gfxtop = video_screen_get_visible_area(screen)->min_y; + int gfxtop = screen->visible_area().min_y; bitmap_fill( bitmap, cliprect, palette_get_color(screen->machine, 256) ); @@ -198,9 +198,9 @@ static VIDEO_UPDATE( firefox ) static TIMER_DEVICE_CALLBACK( video_timer_callback ) { - video_screen_update_now(timer->machine->primary_screen); + timer.machine->primary_screen->update_now(); - cputag_set_input_line( timer->machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE ); + cputag_set_input_line( timer.machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE ); } static void set_rgba( running_machine *machine, int start, int index, unsigned char *palette_ram ) diff --git a/src/mame/drivers/firetrk.c b/src/mame/drivers/firetrk.c index 09af79d1fa6..3635a8d75e1 100644 --- a/src/mame/drivers/firetrk.c +++ b/src/mame/drivers/firetrk.c @@ -74,7 +74,7 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline > 262) scanline = 0; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, periodic_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); } @@ -914,7 +914,7 @@ static MACHINE_DRIVER_START( superbug ) /* basic machine hardware */ MDRV_IMPORT_FROM(firetrk) - MDRV_CPU_REPLACE("maincpu", M6800, MASTER_CLOCK/12) + MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(superbug_map) /* video hardware */ @@ -934,7 +934,7 @@ static MACHINE_DRIVER_START( montecar ) /* basic machine hardware */ MDRV_IMPORT_FROM(firetrk) - MDRV_CPU_REPLACE("maincpu", M6800, MASTER_CLOCK/12) /* 750Khz during service mode */ + MDRV_CPU_MODIFY("maincpu") /* 750Khz during service mode */ MDRV_CPU_PROGRAM_MAP(montecar_map) /* video hardware */ diff --git a/src/mame/drivers/fitfight.c b/src/mame/drivers/fitfight.c index d19ee91a694..16c01e67151 100644 --- a/src/mame/drivers/fitfight.c +++ b/src/mame/drivers/fitfight.c @@ -763,8 +763,7 @@ static MACHINE_DRIVER_START( fitfight ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1333333) // ~8080Hz ??? TODO: find out the real frequency - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 1333333, OKIM6295_PIN7_LOW) // ~8080Hz ??? TODO: find out the real frequency MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -794,8 +793,7 @@ static MACHINE_DRIVER_START( bbprot ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1333333) // ~8080Hz ??? TODO: find out the real frequency - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 1333333, OKIM6295_PIN7_LOW) // ~8080Hz ??? TODO: find out the real frequency MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/flyball.c b/src/mame/drivers/flyball.c index 8b9e0253512..959da53d024 100644 --- a/src/mame/drivers/flyball.c +++ b/src/mame/drivers/flyball.c @@ -137,12 +137,12 @@ static TIMER_CALLBACK( flyball_quarter_callback ) for (i = 0; i < 64; i++) if (potsense[i] != 0) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline + i, 0), NULL, potsense[i], flyball_joystick_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline + i), NULL, potsense[i], flyball_joystick_callback); scanline += 0x40; scanline &= 0xff; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, flyball_quarter_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, flyball_quarter_callback); state->potsense = 0; state->potmask = 0; @@ -163,7 +163,7 @@ static READ8_HANDLER( flyball_input_r ) static READ8_HANDLER( flyball_scanline_r ) { - return video_screen_get_vpos(space->machine->primary_screen) & 0x3f; + return space->machine->primary_screen->vpos() & 0x3f; } static READ8_HANDLER( flyball_potsense_r ) @@ -388,7 +388,7 @@ static MACHINE_RESET( flyball ) machine->device("maincpu")->reset(); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, flyball_quarter_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, flyball_quarter_callback); state->pitcher_vert = 0; state->pitcher_horz = 0; diff --git a/src/mame/drivers/foodf.c b/src/mame/drivers/foodf.c index f4d2617407d..5f5a687670d 100644 --- a/src/mame/drivers/foodf.c +++ b/src/mame/drivers/foodf.c @@ -121,7 +121,7 @@ static TIMER_DEVICE_CALLBACK( scanline_update ) mystery yet */ /* INT 1 is on 32V */ - atarigen_scanline_int_gen(devtag_get_device(timer->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(timer.machine, "maincpu")); /* advance to the next interrupt */ scanline += 64; @@ -129,7 +129,7 @@ static TIMER_DEVICE_CALLBACK( scanline_update ) scanline = 0; /* set a timer for it */ - timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); + timer.adjust(timer.machine->primary_screen->time_until_pos(scanline), scanline); } @@ -145,7 +145,8 @@ static MACHINE_RESET( foodf ) { foodf_state *state = (foodf_state *)machine->driver_data; atarigen_interrupt_reset(&state->atarigen, update_interrupts); - timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device *scan_timer = machine->device("scan_timer"); + scan_timer->adjust(machine->primary_screen->time_until_pos(0)); } diff --git a/src/mame/drivers/funkyjet.c b/src/mame/drivers/funkyjet.c index 3c987964622..a02b0ed1df4 100644 --- a/src/mame/drivers/funkyjet.c +++ b/src/mame/drivers/funkyjet.c @@ -343,8 +343,7 @@ static MACHINE_DRIVER_START( funkyjet ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/funworld.c b/src/mame/drivers/funworld.c index c6065ded2e5..186151285dc 100644 --- a/src/mame/drivers/funworld.c +++ b/src/mame/drivers/funworld.c @@ -2181,6 +2181,7 @@ static MACHINE_DRIVER_START( magicrd2 ) MDRV_CPU_REPLACE("maincpu", M65C02, MASTER_CLOCK/8) /* 2MHz */ MDRV_CPU_PROGRAM_MAP(magicrd2_map) + MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) MDRV_VIDEO_START(magicrd2) @@ -2194,6 +2195,7 @@ static MACHINE_DRIVER_START( royalcd1 ) MDRV_CPU_REPLACE("maincpu", M65C02, MASTER_CLOCK/8) /* (G65SC02P in pro version) 2MHz */ MDRV_CPU_PROGRAM_MAP(magicrd2_map) + MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) MACHINE_DRIVER_END static MACHINE_DRIVER_START( royalcd2 ) @@ -2208,6 +2210,7 @@ static MACHINE_DRIVER_START( cuoreuno ) MDRV_CPU_REPLACE("maincpu", M65C02, MASTER_CLOCK/8) /* 2MHz */ MDRV_CPU_PROGRAM_MAP(cuoreuno_map) + MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) MACHINE_DRIVER_END static MACHINE_DRIVER_START( saloon ) @@ -2215,6 +2218,7 @@ static MACHINE_DRIVER_START( saloon ) MDRV_CPU_REPLACE("maincpu", M65C02, MASTER_CLOCK/8) /* 2MHz */ MDRV_CPU_PROGRAM_MAP(saloon_map) + MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) MACHINE_DRIVER_END diff --git a/src/mame/drivers/funybubl.c b/src/mame/drivers/funybubl.c index 58a207fecce..7b2d81a8a29 100644 --- a/src/mame/drivers/funybubl.c +++ b/src/mame/drivers/funybubl.c @@ -74,7 +74,8 @@ static WRITE8_HANDLER( funybubl_soundcommand_w ) static WRITE8_DEVICE_HANDLER( funybubl_oki_bank_sw ) { - okim6295_set_bank_base(device, ((data & 1) * 0x40000)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(((data & 1) * 0x40000)); } @@ -250,8 +251,7 @@ static MACHINE_DRIVER_START( funybubl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/fuukifg2.c b/src/mame/drivers/fuukifg2.c index db7bffff0b8..f54563ce97f 100644 --- a/src/mame/drivers/fuukifg2.c +++ b/src/mame/drivers/fuukifg2.c @@ -58,9 +58,9 @@ static WRITE16_HANDLER( fuuki16_vregs_w ) UINT16 new_data = COMBINE_DATA(&state->vregs[offset]); if ((offset == 0x1c/2) && old_data != new_data) { - const rectangle *visarea = video_screen_get_visible_area(space->machine->primary_screen); - attotime period = video_screen_get_frame_period(space->machine->primary_screen); - timer_adjust_periodic(state->raster_interrupt_timer, video_screen_get_time_until_pos(space->machine->primary_screen, new_data, visarea->max_x + 1), 0, period); + const rectangle &visarea = space->machine->primary_screen->visible_area(); + attotime period = space->machine->primary_screen->frame_period(); + timer_adjust_periodic(state->raster_interrupt_timer, space->machine->primary_screen->time_until_pos(new_data, visarea.max_x + 1), 0, period); } } @@ -118,7 +118,8 @@ static WRITE8_DEVICE_HANDLER( fuuki16_oki_banking_w ) data & 0x10 is always set */ - okim6295_set_bank_base(device, ((data & 6) >> 1) * 0x40000); + okim6295_device *oki = downcast(device); + oki->set_bank_base(((data & 6) >> 1) * 0x40000); } static ADDRESS_MAP_START( fuuki16_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -400,7 +401,7 @@ static TIMER_CALLBACK( level_1_interrupt_callback ) { fuuki16_state *state = (fuuki16_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 1, HOLD_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); } @@ -408,7 +409,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) { fuuki16_state *state = (fuuki16_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 3, HOLD_LINE); // VBlank IRQ - timer_set(machine, video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); } @@ -416,8 +417,8 @@ static TIMER_CALLBACK( raster_interrupt_callback ) { fuuki16_state *state = (fuuki16_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 5, HOLD_LINE); // Raster Line IRQ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); - timer_adjust_oneshot(state->raster_interrupt_timer, video_screen_get_frame_period(machine->primary_screen), 0); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); + timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->frame_period(), 0); } @@ -438,11 +439,11 @@ static MACHINE_START( fuuki16 ) static MACHINE_RESET( fuuki16 ) { fuuki16_state *state = (fuuki16_state *)machine->driver_data; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback); - timer_set(machine, video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback); - timer_adjust_oneshot(state->raster_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, visarea->max_x + 1), 0); + timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->time_until_pos(0, visarea.max_x + 1), 0); } @@ -487,8 +488,7 @@ static MACHINE_DRIVER_START( fuuki16 ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.85) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.85) MACHINE_DRIVER_END diff --git a/src/mame/drivers/fuukifg3.c b/src/mame/drivers/fuukifg3.c index 6b2a2057c8a..b8b9f19fb75 100644 --- a/src/mame/drivers/fuukifg3.c +++ b/src/mame/drivers/fuukifg3.c @@ -219,9 +219,9 @@ static WRITE32_HANDLER( fuuki32_vregs_w ) COMBINE_DATA(&state->vregs[offset]); if (offset == 0x1c / 4) { - const rectangle *visarea = video_screen_get_visible_area(space->machine->primary_screen); - attotime period = video_screen_get_frame_period(space->machine->primary_screen); - timer_adjust_periodic(state->raster_interrupt_timer, video_screen_get_time_until_pos(space->machine->primary_screen, state->vregs[0x1c / 4] >> 16, visarea->max_x + 1), 0, period); + const rectangle &visarea = space->machine->primary_screen->visible_area(); + attotime period = space->machine->primary_screen->frame_period(); + timer_adjust_periodic(state->raster_interrupt_timer, space->machine->primary_screen->time_until_pos(state->vregs[0x1c / 4] >> 16, visarea.max_x + 1), 0, period); } } } @@ -487,7 +487,7 @@ static TIMER_CALLBACK( level_1_interrupt_callback ) { fuuki32_state *state = (fuuki32_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 1, HOLD_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); } @@ -495,7 +495,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) { fuuki32_state *state = (fuuki32_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 3, HOLD_LINE); // VBlank IRQ - timer_set(machine, video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); } @@ -503,8 +503,8 @@ static TIMER_CALLBACK( raster_interrupt_callback ) { fuuki32_state *state = (fuuki32_state *)machine->driver_data; cpu_set_input_line(state->maincpu, 5, HOLD_LINE); // Raster Line IRQ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); - timer_adjust_oneshot(state->raster_interrupt_timer, video_screen_get_frame_period(machine->primary_screen), 0); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); + timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->frame_period(), 0); } @@ -528,11 +528,11 @@ static MACHINE_START( fuuki32 ) static MACHINE_RESET( fuuki32 ) { fuuki32_state *state = (fuuki32_state *)machine->driver_data; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 248, 0), NULL, 0, level_1_interrupt_callback); - timer_set(machine, video_screen_get_time_until_vblank_start(machine->primary_screen), NULL, 0, vblank_interrupt_callback); - timer_adjust_oneshot(state->raster_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, visarea->max_x + 1), 0); + timer_set(machine, machine->primary_screen->time_until_pos(248), NULL, 0, level_1_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_vblank_start(), NULL, 0, vblank_interrupt_callback); + timer_adjust_oneshot(state->raster_interrupt_timer, machine->primary_screen->time_until_pos(0, visarea.max_x + 1), 0); } diff --git a/src/mame/drivers/gaelco.c b/src/mame/drivers/gaelco.c index 6202b9d7b9f..ef160e8847b 100644 --- a/src/mame/drivers/gaelco.c +++ b/src/mame/drivers/gaelco.c @@ -534,8 +534,7 @@ static MACHINE_DRIVER_START( bigkarnk ) MDRV_SOUND_ADD("ymsnd", YM3812, 3580000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -568,8 +567,7 @@ static MACHINE_DRIVER_START( maniacsq ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -604,8 +602,7 @@ static MACHINE_DRIVER_START( squash ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -640,8 +637,7 @@ static MACHINE_DRIVER_START( thoop ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gaelco3d.c b/src/mame/drivers/gaelco3d.c index 29cc9c950e6..ef9e700baf4 100644 --- a/src/mame/drivers/gaelco3d.c +++ b/src/mame/drivers/gaelco3d.c @@ -164,12 +164,12 @@ static offs_t tms_offset_xor; static UINT8 analog_ports[4]; static UINT8 framenum; -static running_device *adsp_autobuffer_timer; +static timer_device *adsp_autobuffer_timer; static UINT16 *adsp_control_regs; static UINT16 *adsp_fastram_base; static UINT8 adsp_ireg; static offs_t adsp_ireg_base, adsp_incs, adsp_size; -static running_device *dmadac[SOUND_CHANNELS]; +static dmadac_sound_device *dmadac[SOUND_CHANNELS]; static void adsp_tx_callback(running_device *device, int port, INT32 data); @@ -210,7 +210,7 @@ static MACHINE_RESET( common ) } /* allocate a timer for feeding the autobuffer */ - adsp_autobuffer_timer = devtag_get_device(machine, "adsp_timer"); + adsp_autobuffer_timer = machine->device("adsp_timer"); memory_configure_bank(machine, "bank1", 0, 256, memory_region(machine, "user1"), 0x4000); memory_set_bank(machine, "bank1", 0); @@ -222,7 +222,7 @@ static MACHINE_RESET( common ) { char buffer[10]; sprintf(buffer, "dac%d", i + 1); - dmadac[i] = devtag_get_device(machine, buffer); + dmadac[i] = machine->device(buffer); } } @@ -250,7 +250,7 @@ static MACHINE_RESET( gaelco3d2 ) static INTERRUPT_GEN( vblank_gen ) { - gaelco3d_render(device->machine->primary_screen); + gaelco3d_render(*device->machine->primary_screen); cpu_set_input_line(device, 2, ASSERT_LINE); } @@ -531,7 +531,7 @@ static WRITE16_HANDLER( adsp_control_w ) if ((data & 0x0800) == 0) { dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0); - timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0); + adsp_autobuffer_timer->reset(); } break; @@ -540,7 +540,7 @@ static WRITE16_HANDLER( adsp_control_w ) if ((data & 0x0002) == 0) { dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0); - timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0); + adsp_autobuffer_timer->reset(); } break; @@ -572,7 +572,7 @@ static WRITE16_HANDLER( adsp_rombank_w ) static TIMER_DEVICE_CALLBACK( adsp_autobuffer_irq ) { /* get the index register */ - int reg = cpu_get_reg(devtag_get_device(timer->machine, "adsp"), ADSP2100_I0 + adsp_ireg); + int reg = cpu_get_reg(devtag_get_device(timer.machine, "adsp"), ADSP2100_I0 + adsp_ireg); /* copy the current data into the buffer */ // logerror("ADSP buffer: I%d=%04X incs=%04X size=%04X\n", adsp_ireg, reg, adsp_incs, adsp_size); @@ -589,11 +589,11 @@ static TIMER_DEVICE_CALLBACK( adsp_autobuffer_irq ) reg = adsp_ireg_base; /* generate the (internal, thats why the pulse) irq */ - generic_pulse_irq_line(devtag_get_device(timer->machine, "adsp"), ADSP2105_IRQ1); + generic_pulse_irq_line(devtag_get_device(timer.machine, "adsp"), ADSP2105_IRQ1); } /* store it */ - cpu_set_reg(devtag_get_device(timer->machine, "adsp"), ADSP2100_I0 + adsp_ireg, reg); + cpu_set_reg(devtag_get_device(timer.machine, "adsp"), ADSP2100_I0 + adsp_ireg, reg); } @@ -648,7 +648,7 @@ static void adsp_tx_callback(running_device *device, int port, INT32 data) /* fire off a timer wich will hit every half-buffer */ sample_period = attotime_div(attotime_mul(sample_period, adsp_size), SOUND_CHANNELS * adsp_incs); - timer_device_adjust_periodic(adsp_autobuffer_timer, sample_period, 0, sample_period); + adsp_autobuffer_timer->adjust(sample_period, 0, sample_period); return; } @@ -660,7 +660,7 @@ static void adsp_tx_callback(running_device *device, int port, INT32 data) dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0); /* remove timer */ - timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0); + adsp_autobuffer_timer->reset(); } @@ -1013,8 +1013,10 @@ static MACHINE_DRIVER_START( gaelco3d2 ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", M68EC020, 25000000) MDRV_CPU_PROGRAM_MAP(main020_map) + MDRV_CPU_VBLANK_INT("screen", vblank_gen) - MDRV_CPU_REPLACE("tms", TMS32031, 50000000) + MDRV_CPU_MODIFY("tms") + MDRV_CPU_CLOCK(50000000) MDRV_MACHINE_RESET(gaelco3d2) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gaiden.c b/src/mame/drivers/gaiden.c index 3625a95ef61..0a6aafc763f 100644 --- a/src/mame/drivers/gaiden.c +++ b/src/mame/drivers/gaiden.c @@ -897,8 +897,7 @@ static MACHINE_DRIVER_START( shadoww ) MDRV_SOUND_ROUTE(2, "mono", 0.15) MDRV_SOUND_ROUTE(3, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -950,8 +949,7 @@ static MACHINE_DRIVER_START( drgnbowl ) MDRV_SOUND_ADD("ymsnd", YM2151, 4000000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END @@ -1082,8 +1080,7 @@ static MACHINE_DRIVER_START( mastninj ) MDRV_SOUND_ROUTE(3, "mono", 0.60) /* no OKI on the bootleg */ -// MDRV_SOUND_ADD("oki", OKIM6295, 1000000) -// MDRV_SOUND_CONFIG(okim6295_interface_pin7high) +// MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index 2553db68f61..0de04c19bdf 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -873,7 +873,7 @@ static TIMER_CALLBACK( cpu3_interrupt_callback ) scanline = 64; /* the vertical synch chain is clocked by H256 -- this is probably not important, but oh well */ - timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(cpu3_interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -900,7 +900,7 @@ static MACHINE_RESET( galaga ) /* Reset all latches */ bosco_latch_reset(machine); - timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64); + timer_adjust_oneshot(cpu3_interrupt_timer, machine->primary_screen->time_until_pos(64), 64); } static MACHINE_RESET( battles ) diff --git a/src/mame/drivers/galaxi.c b/src/mame/drivers/galaxi.c index 0fcd3238cd3..e6942cce086 100644 --- a/src/mame/drivers/galaxi.c +++ b/src/mame/drivers/galaxi.c @@ -257,13 +257,13 @@ static WRITE16_HANDLER( galaxi_500004_w ) static CUSTOM_INPUT( ticket_r ) { galaxi_state *state = (galaxi_state *)field->port->machine->driver_data; - return state->ticket && !(video_screen_get_frame_number(field->port->machine->primary_screen) % 10); + return state->ticket && !(field->port->machine->primary_screen->frame_number() % 10); } static CUSTOM_INPUT( hopper_r ) { galaxi_state *state = (galaxi_state *)field->port->machine->driver_data; - return state->hopper && !(video_screen_get_frame_number(field->port->machine->primary_screen) % 10); + return state->hopper && !(field->port->machine->primary_screen->frame_number() % 10); } @@ -422,8 +422,7 @@ static MACHINE_DRIVER_START( galaxi ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // ? + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_LOW) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index 90473411e9c..cd7c5070aab 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -1220,7 +1220,7 @@ static WRITE8_HANDLER( checkman_sound_command_w ) static TIMER_DEVICE_CALLBACK( checkmaj_irq0_gen ) { - cputag_set_input_line(timer->machine, "audiocpu", 0, HOLD_LINE); + cputag_set_input_line(timer.machine, "audiocpu", 0, HOLD_LINE); } diff --git a/src/mame/drivers/galpani2.c b/src/mame/drivers/galpani2.c index 49c4e6de298..9ccc103bd42 100644 --- a/src/mame/drivers/galpani2.c +++ b/src/mame/drivers/galpani2.c @@ -282,7 +282,8 @@ static WRITE8_DEVICE_HANDLER( galpani2_oki1_bank_w ) static WRITE8_DEVICE_HANDLER( galpani2_oki2_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 0xf) ); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 0xf) ); logerror("%s : %s bank %08X\n",cpuexec_describe_context(device->machine),device->tag(),data); } @@ -606,12 +607,10 @@ static MACHINE_DRIVER_START( galpani2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_16MHz/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", XTAL_16MHz/8, OKIM6295_PIN7_LOW) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_16MHz/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", XTAL_16MHz/8, OKIM6295_PIN7_LOW) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/galpanic.c b/src/mame/drivers/galpanic.c index d7d6e096785..f812829cd85 100644 --- a/src/mame/drivers/galpanic.c +++ b/src/mame/drivers/galpanic.c @@ -909,8 +909,7 @@ static MACHINE_DRIVER_START( galpanic ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/6) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/6, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -928,7 +927,8 @@ static MACHINE_DRIVER_START( comad ) /* basic machine hardware */ MDRV_IMPORT_FROM(galpanic) - MDRV_CPU_REPLACE("maincpu", M68000, 10000000) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(10000000) MDRV_CPU_PROGRAM_MAP(comad_map) MDRV_DEVICE_REMOVE("pandora") @@ -942,7 +942,8 @@ static MACHINE_DRIVER_START( supmodel ) /* basic machine hardware */ MDRV_IMPORT_FROM(comad) - MDRV_CPU_REPLACE("maincpu", M68000, 12000000) /* ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(12000000) /* ? */ MDRV_CPU_PROGRAM_MAP(supmodel_map) MDRV_CPU_VBLANK_INT_HACK(galpanic_interrupt,2) @@ -951,8 +952,7 @@ static MACHINE_DRIVER_START( supmodel ) MDRV_VIDEO_EOF(0) /* sound hardware */ - MDRV_SOUND_REPLACE("oki", OKIM6295, 1584000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_REPLACE("oki", 1584000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -961,7 +961,8 @@ static MACHINE_DRIVER_START( fantsia2 ) /* basic machine hardware */ MDRV_IMPORT_FROM(comad) - MDRV_CPU_REPLACE("maincpu", M68000, 12000000) /* ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(12000000) /* ? */ MDRV_CPU_PROGRAM_MAP(fantsia2_map) /* video hardware */ @@ -973,7 +974,8 @@ static MACHINE_DRIVER_START( galhustl ) /* basic machine hardware */ MDRV_IMPORT_FROM(comad) - MDRV_CPU_REPLACE("maincpu", M68000, 12000000) /* ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(12000000) /* ? */ MDRV_CPU_PROGRAM_MAP(galhustl_map) MDRV_CPU_VBLANK_INT_HACK(galhustl_interrupt,3) @@ -982,8 +984,7 @@ static MACHINE_DRIVER_START( galhustl ) MDRV_VIDEO_EOF(0) /* sound hardware */ - MDRV_SOUND_REPLACE("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_REPLACE("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -991,7 +992,8 @@ static MACHINE_DRIVER_START( zipzap ) /* basic machine hardware */ MDRV_IMPORT_FROM(comad) - MDRV_CPU_REPLACE("maincpu", M68000, 12000000) /* ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(12000000) /* ? */ MDRV_CPU_PROGRAM_MAP(zipzap_map) MDRV_CPU_VBLANK_INT_HACK(galhustl_interrupt,3) @@ -999,8 +1001,7 @@ static MACHINE_DRIVER_START( zipzap ) MDRV_VIDEO_UPDATE(comad) /* sound hardware */ - MDRV_SOUND_REPLACE("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_REPLACE("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/galspnbl.c b/src/mame/drivers/galspnbl.c index 2ac479aacdd..7a7fedb1e5f 100644 --- a/src/mame/drivers/galspnbl.c +++ b/src/mame/drivers/galspnbl.c @@ -244,8 +244,7 @@ static MACHINE_DRIVER_START( galspnbl ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gameplan.c b/src/mame/drivers/gameplan.c index b37ad1cd4f1..32b5685b51f 100644 --- a/src/mame/drivers/gameplan.c +++ b/src/mame/drivers/gameplan.c @@ -1046,7 +1046,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( leprechn ) MDRV_IMPORT_FROM(gameplan) - MDRV_CPU_REPLACE("maincpu", M6502, LEPRECHAUN_MAIN_CPU_CLOCK) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(LEPRECHAUN_MAIN_CPU_CLOCK) /* basic machine hardware */ MDRV_CPU_MODIFY("audiocpu") diff --git a/src/mame/drivers/gauntlet.c b/src/mame/drivers/gauntlet.c index a0d98f8653f..d2e75fbef21 100644 --- a/src/mame/drivers/gauntlet.c +++ b/src/mame/drivers/gauntlet.c @@ -142,13 +142,13 @@ static void update_interrupts(running_machine *machine) } -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { - const address_space *space = cputag_get_address_space(screen->machine, "audiocpu", ADDRESS_SPACE_PROGRAM); + const address_space *space = cputag_get_address_space(screen.machine, "audiocpu", ADDRESS_SPACE_PROGRAM); /* sound IRQ is on 32V */ if (scanline & 32) - atarigen_6502_irq_gen(devtag_get_device(screen->machine, "audiocpu")); + atarigen_6502_irq_gen(devtag_get_device(screen.machine, "audiocpu")); else atarigen_6502_irq_ack_r(space, 0); } @@ -172,7 +172,7 @@ static MACHINE_RESET( gauntlet ) atarigen_eeprom_reset(&state->atarigen); atarigen_slapstic_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 32); atarigen_sound_io_reset(devtag_get_device(machine, "audiocpu")); } diff --git a/src/mame/drivers/gcpinbal.c b/src/mame/drivers/gcpinbal.c index 18860749aca..2b2b4def51c 100644 --- a/src/mame/drivers/gcpinbal.c +++ b/src/mame/drivers/gcpinbal.c @@ -136,7 +136,7 @@ static WRITE16_HANDLER( ioc_w ) // MSM6585 bank, coin LEDs, maybe others? case 0x44: state->msm_bank = data & 0x1000 ? 0x100000 : 0; - okim6295_set_bank_base(state->oki, 0x40000 * ((data & 0x800 )>> 11)); + state->oki->set_bank_base(0x40000 * ((data & 0x800 )>> 11)); break; case 0x45: @@ -396,10 +396,6 @@ static MACHINE_START( gcpinbal ) { gcpinbal_state *state = (gcpinbal_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->oki = devtag_get_device(machine, "oki"); - state->msm = devtag_get_device(machine, "msm"); - state_save_register_global_array(machine, state->scrollx); state_save_register_global_array(machine, state->scrolly); state_save_register_global(machine, state->bg0_gfxset); @@ -467,8 +463,7 @@ static MACHINE_DRIVER_START( gcpinbal ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MDRV_SOUND_ADD("msm", MSM5205, 384000) diff --git a/src/mame/drivers/ghosteo.c b/src/mame/drivers/ghosteo.c index 41ce080d7e1..87aefa51329 100644 --- a/src/mame/drivers/ghosteo.c +++ b/src/mame/drivers/ghosteo.c @@ -212,7 +212,7 @@ static READ32_HANDLER( lcd_control_r ) { case 0x00/4: { - int line_val = video_screen_get_vpos(space->machine->primary_screen) & 0x3ff; + int line_val = space->machine->primary_screen->vpos() & 0x3ff; return (lcd_control[offset] & ~(0x3ff << 18)) | ((lcd.line_val - line_val) << 18); } @@ -241,7 +241,7 @@ static WRITE32_HANDLER( lcd_control_w ) { case 0x00/4: { - int line_val = video_screen_get_vpos(space->machine->primary_screen) & 0x3ff; + int line_val = space->machine->primary_screen->vpos() & 0x3ff; int bpp_mode = (lcd_control[offset] & 0x1e) >> 1; int screen_type = (lcd_control[offset] & 0x60) >> 5; diff --git a/src/mame/drivers/glass.c b/src/mame/drivers/glass.c index cacbe88ef1c..851ae62430f 100644 --- a/src/mame/drivers/glass.c +++ b/src/mame/drivers/glass.c @@ -224,8 +224,7 @@ static MACHINE_DRIVER_START( glass ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/go2000.c b/src/mame/drivers/go2000.c index ee6b08ec575..7355582cfbf 100644 --- a/src/mame/drivers/go2000.c +++ b/src/mame/drivers/go2000.c @@ -204,8 +204,8 @@ static VIDEO_UPDATE(go2000) { int offs; - int max_x = video_screen_get_width(screen->machine->primary_screen) - 8; - int max_y = video_screen_get_height(screen->machine->primary_screen) - 8; + int max_x = screen->machine->primary_screen->width() - 8; + int max_y = screen->machine->primary_screen->height() - 8; for (offs = 0xf800 / 2; offs < 0x10000 / 2 ; offs += 4/2) { diff --git a/src/mame/drivers/goldstar.c b/src/mame/drivers/goldstar.c index 014053af713..23668957902 100644 --- a/src/mame/drivers/goldstar.c +++ b/src/mame/drivers/goldstar.c @@ -5536,8 +5536,7 @@ static MACHINE_DRIVER_START( goldstar ) MDRV_SOUND_CONFIG(ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -5574,8 +5573,7 @@ static MACHINE_DRIVER_START( goldstbl ) MDRV_SOUND_CONFIG(ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -5611,8 +5609,7 @@ static MACHINE_DRIVER_START( moonlght ) MDRV_SOUND_CONFIG(ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -6184,8 +6181,7 @@ static MACHINE_DRIVER_START( amcoe1 ) MDRV_SOUND_CONFIG(cm_ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -6227,8 +6223,7 @@ static MACHINE_DRIVER_START( amcoe1a ) MDRV_SOUND_CONFIG(cm_ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/good.c b/src/mame/drivers/good.c index 5f5cea127bc..1a42687e190 100644 --- a/src/mame/drivers/good.c +++ b/src/mame/drivers/good.c @@ -296,8 +296,7 @@ static MACHINE_DRIVER_START( good ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gotcha.c b/src/mame/drivers/gotcha.c index 83acb7d6c79..a6f492da041 100644 --- a/src/mame/drivers/gotcha.c +++ b/src/mame/drivers/gotcha.c @@ -89,7 +89,8 @@ static WRITE16_DEVICE_HANDLER( gotcha_oki_bank_w ) { if (ACCESSING_BITS_8_15) { - okim6295_set_bank_base(device,(((~data & 0x0100) >> 8) * 0x40000)); + okim6295_device *oki = downcast(device); + oki->set_bank_base((((~data & 0x0100) >> 8) * 0x40000)); } } @@ -311,8 +312,7 @@ static MACHINE_DRIVER_START( gotcha ) MDRV_SOUND_ROUTE(0, "mono", 0.80) MDRV_SOUND_ROUTE(1, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index bcee76f7575..19a648cc064 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -309,7 +309,7 @@ static MACHINE_RESET( gottlieb ) { /* if we have a laserdisc, reset our philips code callback for the next line 17 */ if (laserdisc != NULL) - timer_adjust_oneshot(laserdisc_philips_timer, video_screen_get_time_until_pos(machine->primary_screen, 17, 0), 17); + timer_adjust_oneshot(laserdisc_philips_timer, machine->primary_screen->time_until_pos(17), 17); } @@ -468,7 +468,7 @@ static TIMER_CALLBACK( laserdisc_philips_callback ) /* toggle to the next one */ param = (param == 17) ? 18 : 17; - timer_adjust_oneshot(laserdisc_philips_timer, video_screen_get_time_until_pos(machine->primary_screen, param * 2, 0), param); + timer_adjust_oneshot(laserdisc_philips_timer, machine->primary_screen->time_until_pos(param * 2), param); } @@ -689,7 +689,7 @@ static INTERRUPT_GEN( gottlieb_interrupt ) { /* assert the NMI and set a timer to clear it at the first visible line */ cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE); - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), NULL, 0, nmi_clear); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, nmi_clear); /* if we have a laserdisc, update it */ if (laserdisc != NULL) diff --git a/src/mame/drivers/grchamp.c b/src/mame/drivers/grchamp.c index 09e4f06ac01..a6db5520515 100644 --- a/src/mame/drivers/grchamp.c +++ b/src/mame/drivers/grchamp.c @@ -342,7 +342,7 @@ INLINE UINT8 get_pc3259_bits(running_machine *machine, grchamp_state *state, int int bits; /* force a partial update to the current position */ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* get the relevant 4 bits */ bits = (state->collide >> (offs*4)) & 0x0f; diff --git a/src/mame/drivers/gridlee.c b/src/mame/drivers/gridlee.c index ea539fb26b0..964bfbe65a1 100644 --- a/src/mame/drivers/gridlee.c +++ b/src/mame/drivers/gridlee.c @@ -121,15 +121,15 @@ static TIMER_CALLBACK( irq_timer_tick ) { /* next interrupt after scanline 256 is scanline 64 */ if (param == 256) - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(64), 64); else - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, param + 64, 0), param + 64); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(param + 64), param + 64); /* IRQ starts on scanline 0, 64, 128, etc. */ cputag_set_input_line(machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE); /* it will turn off on the next HBLANK */ - timer_adjust_oneshot(irq_off, video_screen_get_time_until_pos(machine->primary_screen, param, BALSENTE_HBSTART), 0); + timer_adjust_oneshot(irq_off, machine->primary_screen->time_until_pos(param, BALSENTE_HBSTART), 0); } @@ -142,13 +142,13 @@ static TIMER_CALLBACK( firq_off_tick ) static TIMER_CALLBACK( firq_timer_tick ) { /* same time next frame */ - timer_adjust_oneshot(firq_timer, video_screen_get_time_until_pos(machine->primary_screen, FIRQ_SCANLINE, 0), 0); + timer_adjust_oneshot(firq_timer, machine->primary_screen->time_until_pos(FIRQ_SCANLINE), 0); /* IRQ starts on scanline FIRQ_SCANLINE? */ cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); /* it will turn off on the next HBLANK */ - timer_adjust_oneshot(firq_off, video_screen_get_time_until_pos(machine->primary_screen, FIRQ_SCANLINE, BALSENTE_HBSTART), 0); + timer_adjust_oneshot(firq_off, machine->primary_screen->time_until_pos(FIRQ_SCANLINE, BALSENTE_HBSTART), 0); } static MACHINE_START( gridlee ) @@ -169,8 +169,8 @@ static MACHINE_START( gridlee ) static MACHINE_RESET( gridlee ) { /* start timers to generate interrupts */ - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); - timer_adjust_oneshot(firq_timer, video_screen_get_time_until_pos(machine->primary_screen, FIRQ_SCANLINE, 0), 0); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(0), 0); + timer_adjust_oneshot(firq_timer, machine->primary_screen->time_until_pos(FIRQ_SCANLINE), 0); } diff --git a/src/mame/drivers/gstream.c b/src/mame/drivers/gstream.c index e78d7aafebe..d988d3351b2 100644 --- a/src/mame/drivers/gstream.c +++ b/src/mame/drivers/gstream.c @@ -131,7 +131,9 @@ class gstream_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gstream_state(machine)); } - gstream_state(running_machine &machine) { } + gstream_state(running_machine &machine) + : oki_1(machine.device("oki1")), + oki_2(machine.device("oki2")) { } /* memory pointers */ UINT32 * vram; @@ -148,8 +150,8 @@ public: int oki_bank_0, oki_bank_1; /* devices */ - running_device *oki_1; - running_device *oki_2; + okim6295_device *oki_1; + okim6295_device *oki_2; }; @@ -333,8 +335,8 @@ static WRITE32_HANDLER( gstream_oki_banking_w ) state->oki_bank_1 = 3; // end sequence music } - okim6295_set_bank_base(state->oki_1, state->oki_bank_0 * 0x40000); - okim6295_set_bank_base(state->oki_2, state->oki_bank_1 * 0x40000); + state->oki_1->set_bank_base(state->oki_bank_0 * 0x40000); + state->oki_2->set_bank_base(state->oki_bank_1 * 0x40000); } static WRITE32_HANDLER( gstream_oki_4040_w ) @@ -521,9 +523,6 @@ static MACHINE_START( gstream ) { gstream_state *state = (gstream_state *)machine->driver_data; - state->oki_1 = devtag_get_device(machine, "oki1"); - state->oki_2 = devtag_get_device(machine, "oki2"); - state_save_register_global(machine, state->tmap1_scrollx); state_save_register_global(machine, state->tmap2_scrollx); state_save_register_global(machine, state->tmap3_scrollx); @@ -580,12 +579,10 @@ static MACHINE_DRIVER_START( gstream ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 1000000) /* 1 Mhz? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 1000000, OKIM6295_PIN7_HIGH) /* 1 Mhz? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) - MDRV_SOUND_ADD("oki2", OKIM6295, 1000000) /* 1 Mhz? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 1000000, OKIM6295_PIN7_HIGH) /* 1 Mhz? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gumbo.c b/src/mame/drivers/gumbo.c index 7f4bf44cd3c..28da3732001 100644 --- a/src/mame/drivers/gumbo.c +++ b/src/mame/drivers/gumbo.c @@ -250,8 +250,7 @@ static MACHINE_DRIVER_START( gumbo ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/gunpey.c b/src/mame/drivers/gunpey.c index 770a135e037..777362165d3 100644 --- a/src/mame/drivers/gunpey.c +++ b/src/mame/drivers/gunpey.c @@ -76,7 +76,7 @@ static VIDEO_UPDATE( gunpey ) g = (color & 0x03e0) >> 2; r = (color & 0x7c00) >> 7; - if(xmax_x && ymax_y) + if(xvisible_area().max_x && yvisible_area().max_y) *BITMAP_ADDR32(bitmap, y, x) = b | (g<<8) | (r<<16); @@ -337,8 +337,7 @@ static MACHINE_DRIVER_START( gunpey ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker","rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16_9344MHz / 8 / 165) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_16_9344MHz / 8 / 165, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(0, "lspeaker", 0.25) MDRV_SOUND_ROUTE(1, "rspeaker", 0.25) diff --git a/src/mame/drivers/halleys.c b/src/mame/drivers/halleys.c index 6e168f55fea..1068d701bc5 100644 --- a/src/mame/drivers/halleys.c +++ b/src/mame/drivers/halleys.c @@ -1979,7 +1979,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( benberob ) MDRV_IMPORT_FROM(halleys) - MDRV_CPU_REPLACE("maincpu", M6809, XTAL_19_968MHz/12) /* not verified but pcb identical to halley's comet */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(XTAL_19_968MHz/12) /* not verified but pcb identical to halley's comet */ MDRV_CPU_VBLANK_INT_HACK(benberob_interrupt, 4) MDRV_VIDEO_UPDATE(benberob) MACHINE_DRIVER_END diff --git a/src/mame/drivers/harddriv.c b/src/mame/drivers/harddriv.c index 8d44db61b2a..49a8dc6d8a6 100644 --- a/src/mame/drivers/harddriv.c +++ b/src/mame/drivers/harddriv.c @@ -3632,21 +3632,6 @@ ROM_END * *************************************/ -/* COMMON INIT: find all the CPUs */ -static void find_cpus(running_machine *machine) -{ - harddriv_state *state = (harddriv_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->gsp = devtag_get_device(machine, "gsp"); - state->msp = devtag_get_device(machine, "msp"); - state->adsp = devtag_get_device(machine, "adsp"); - state->soundcpu = devtag_get_device(machine, "soundcpu"); - state->sounddsp = devtag_get_device(machine, "sounddsp"); - state->jsacpu = devtag_get_device(machine, "jsa"); - state->dsp32 = devtag_get_device(machine, "dsp32"); -} - - static const UINT16 default_eeprom[] = { 1, @@ -3660,9 +3645,6 @@ static void init_driver(running_machine *machine) { harddriv_state *state = (harddriv_state *)machine->driver_data; - /* assume we're first to be called */ - find_cpus(machine); - /* note that we're not multisync and set the default EEPROM data */ state->gsp_multisync = FALSE; state->atarigen.eeprom_default = default_eeprom; @@ -3674,9 +3656,6 @@ static void init_multisync(running_machine *machine, int compact_inputs) { harddriv_state *state = (harddriv_state *)machine->driver_data; - /* assume we're first to be called */ - find_cpus(machine); - /* note that we're multisync and set the default EEPROM data */ state->gsp_multisync = TRUE; state->atarigen.eeprom_default = default_eeprom; @@ -3736,10 +3715,10 @@ static void init_ds3(running_machine *machine) /* if we have a sound DSP, boot it */ if (state->soundcpu != NULL && cpu_get_type(state->soundcpu) == CPU_ADSP2105) - adsp2105_load_boot_data(state->soundcpu->region->base.u8 + 0x10000, state->soundcpu->region->base.u32); + adsp2105_load_boot_data(state->soundcpu->region()->base.u8 + 0x10000, state->soundcpu->region()->base.u32); if (state->sounddsp != NULL && cpu_get_type(state->sounddsp) == CPU_ADSP2105) - adsp2105_load_boot_data(state->sounddsp->region->base.u8 + 0x10000, state->sounddsp->region->base.u32); + adsp2105_load_boot_data(state->sounddsp->region()->base.u8 + 0x10000, state->sounddsp->region()->base.u32); /* @@ -3994,10 +3973,7 @@ static READ32_HANDLER( rddsp32_speedup_r ) int cycles_to_burn = 17 * 4 * (0x2bc - r1 - 2); if (cycles_to_burn > 20 * 4) { - int icount_remaining = *cpu_get_icount_ptr(space->cpu); - if (cycles_to_burn > icount_remaining) - cycles_to_burn = icount_remaining; - cpu_adjust_icount(space->cpu, -cycles_to_burn); + cpu_eat_cycles(space->cpu, cycles_to_burn); memory_write_word(space, r14 - 0x14, r1 + cycles_to_burn / 17); } state->msp_speedup_count[0]++; diff --git a/src/mame/drivers/hexion.c b/src/mame/drivers/hexion.c index da82093c9d2..996003170ea 100644 --- a/src/mame/drivers/hexion.c +++ b/src/mame/drivers/hexion.c @@ -252,8 +252,7 @@ static MACHINE_DRIVER_START( hexion ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_SOUND_ADD("konami", K051649, 24000000/16) diff --git a/src/mame/drivers/highvdeo.c b/src/mame/drivers/highvdeo.c index b91e84c4c81..0f1c5040201 100644 --- a/src/mame/drivers/highvdeo.c +++ b/src/mame/drivers/highvdeo.c @@ -102,20 +102,20 @@ static VIDEO_UPDATE(tourvisn) count = (0/2); - for(y=0;y<(video_screen_get_visible_area(screen)->max_y+1);y++) + for(y=0;y<(screen->visible_area().max_y+1);y++) { - for(x=0;x<(video_screen_get_visible_area(screen)->max_x+1)/2;x++) + for(x=0;x<(screen->visible_area().max_x+1)/2;x++) { UINT32 color; color = ((blit_ram[count]) & 0x00ff)>>0; - if((x*2)max_x && ((y)+0)max_y) + if((x*2)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color]; color = ((blit_ram[count]) & 0xff00)>>8; - if(((x*2)+1)max_x && ((y)+0)max_y) + if(((x*2)+1)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color]; count++; @@ -146,7 +146,7 @@ static VIDEO_UPDATE(brasil) b = (color & 0x001f) << 3; g = (color & 0x07e0) >> 3; r = (color & 0xf800) >> 8; - if(xmax_x && ymax_y) + if(xvisible_area().max_x && yvisible_area().max_y) *BITMAP_ADDR32(bitmap, y, x) = b | (g<<8) | (r<<16); count++; diff --git a/src/mame/drivers/hitme.c b/src/mame/drivers/hitme.c index df3c9707969..d0189968b92 100644 --- a/src/mame/drivers/hitme.c +++ b/src/mame/drivers/hitme.c @@ -147,7 +147,7 @@ static UINT8 read_port_and_t0( running_machine *machine, int port ) static UINT8 read_port_and_t0_and_hblank( running_machine *machine, int port ) { UINT8 val = read_port_and_t0(machine, port); - if (video_screen_get_hpos(machine->primary_screen) < (video_screen_get_width(machine->primary_screen) * 9 / 10)) + if (machine->primary_screen->hpos() < (machine->primary_screen->width() * 9 / 10)) val ^= 0x04; return val; } diff --git a/src/mame/drivers/hng64.c b/src/mame/drivers/hng64.c index 7d014835f05..a5dc07e8d0f 100644 --- a/src/mame/drivers/hng64.c +++ b/src/mame/drivers/hng64.c @@ -918,7 +918,7 @@ static WRITE32_HANDLER( tcram_w ) if(offset == 0x02) { static UINT16 min_x,min_y,max_x,max_y; - rectangle visarea = *video_screen_get_visible_area(space->machine->primary_screen); + rectangle visarea = space->machine->primary_screen->visible_area(); min_x = (hng64_tcram[1] & 0xffff0000) >> 16; min_y = (hng64_tcram[1] & 0x0000ffff) >> 0; @@ -937,7 +937,7 @@ static WRITE32_HANDLER( tcram_w ) visarea.max_x = min_x + max_x - 1; visarea.min_y = min_y; visarea.max_y = min_y + max_y - 1; - video_screen_configure(space->machine->primary_screen, 0x200, 0x1c0, &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds ); + space->machine->primary_screen->configure(0x200, 0x1c0, visarea, space->machine->primary_screen->frame_period().attoseconds ); } } diff --git a/src/mame/drivers/homedata.c b/src/mame/drivers/homedata.c index 93002927fed..380eee3cbb1 100644 --- a/src/mame/drivers/homedata.c +++ b/src/mame/drivers/homedata.c @@ -1427,7 +1427,8 @@ static MACHINE_DRIVER_START( mjkinjas ) MDRV_IMPORT_FROM(pteacher) - MDRV_CPU_REPLACE("audiocpu", UPD7807, 11000000) /* 11MHz ? */ + MDRV_CPU_MODIFY("audiocpu") + MDRV_CPU_CLOCK(11000000) /* 11MHz ? */ MACHINE_DRIVER_END static MACHINE_DRIVER_START( lemnangl ) @@ -1557,12 +1558,12 @@ static MACHINE_DRIVER_START( mirderby ) /* basic machine hardware */ MDRV_CPU_ADD("cpu0", Z80, 16000000/4) /* 4 Mhz */ - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MDRV_CPU_PROGRAM_MAP(cpu0_map) MDRV_CPU_ADD("cpu1", M6809, 16000000/8) /* 2 Mhz */ MDRV_CPU_PROGRAM_MAP(cpu1_map) - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() //MDRV_CPU_VBLANK_INT("screen", mirderby_irq) diff --git a/src/mame/drivers/homerun.c b/src/mame/drivers/homerun.c index 83e8a6f93da..82263de3503 100644 --- a/src/mame/drivers/homerun.c +++ b/src/mame/drivers/homerun.c @@ -64,7 +64,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( homerun_40_r ) { - UINT8 ret = (video_screen_get_vpos(field->port->machine->primary_screen) > 116) ? 1 : 0; + UINT8 ret = (field->port->machine->primary_screen->vpos() > 116) ? 1 : 0; return ret; } diff --git a/src/mame/drivers/hyprduel.c b/src/mame/drivers/hyprduel.c index af8d08093a9..ec5dc93dbca 100644 --- a/src/mame/drivers/hyprduel.c +++ b/src/mame/drivers/hyprduel.c @@ -711,8 +711,7 @@ static MACHINE_DRIVER_START( hyprduel ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 4000000/16/16*132) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 4000000/16/16*132, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.57) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.57) MACHINE_DRIVER_END @@ -757,8 +756,7 @@ static MACHINE_DRIVER_START( magerror ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.00) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.00) - MDRV_SOUND_ADD("oki", OKIM6295, 4000000/16/16*132) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 4000000/16/16*132, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.57) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.57) MACHINE_DRIVER_END diff --git a/src/mame/drivers/igs009.c b/src/mame/drivers/igs009.c index 4fa49c93c4e..a13c38d8184 100644 --- a/src/mame/drivers/igs009.c +++ b/src/mame/drivers/igs009.c @@ -242,7 +242,7 @@ static VIDEO_UPDATE(jingbell) { int zz,i; int startclipmin = 0; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); for (i= 0;i < 0x80;i++) @@ -262,8 +262,8 @@ static VIDEO_UPDATE(jingbell) int rowenable = bg_scroll2[zz]; /* draw top of screen */ - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; clip.min_y = startclipmin; clip.max_y = startclipmin+2; @@ -307,7 +307,7 @@ static int nmi_enable, hopper; static CUSTOM_INPUT( hopper_r ) { - return hopper && !(video_screen_get_frame_number(field->port->machine->primary_screen)%10); + return hopper && !(field->port->machine->primary_screen->frame_number()%10); } static UINT8 out[3]; @@ -660,8 +660,7 @@ static MACHINE_DRIVER_START( jingbell ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz / 12) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_12MHz / 12, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/igs011.c b/src/mame/drivers/igs011.c index a2588123436..efc36f51f31 100644 --- a/src/mame/drivers/igs011.c +++ b/src/mame/drivers/igs011.c @@ -266,7 +266,7 @@ static WRITE16_HANDLER( igs011_blit_flags_w ) int gfx_size = memory_region_length(space->machine, "blitter"); int gfx2_size = memory_region_length(space->machine, "blitter_hi"); - const rectangle *clip = video_screen_get_visible_area(space->machine->primary_screen); + const rectangle &clip = space->machine->primary_screen->visible_area(); COMBINE_DATA(&blitter.flags); @@ -335,7 +335,7 @@ static WRITE16_HANDLER( igs011_blit_flags_w ) } // plot it - if (x >= clip->min_x && x <= clip->max_x && y >= clip->min_y && y <= clip->max_y) + if (x >= clip.min_x && x <= clip.max_x && y >= clip.min_y && y <= clip.max_y) { if (clear) dest[x + y * 512] = clear_pen; else if (pen != trans_pen) dest[x + y * 512] = pen | pen_hi; @@ -369,7 +369,7 @@ static UINT16 igs_dips_sel, igs_input_sel, igs_hopper; static CUSTOM_INPUT( igs_hopper_r ) { - return (igs_hopper && ((video_screen_get_frame_number(field->port->machine->primary_screen)/5)&1)) ? 0x0000 : 0x0001; + return (igs_hopper && ((field->port->machine->primary_screen->frame_number()/5)&1)) ? 0x0000 : 0x0001; } static WRITE16_HANDLER( igs_dips_w ) @@ -799,7 +799,8 @@ static WRITE16_HANDLER( lhb2_magic_w ) { lhb2_pen_hi = data & 0x07; - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x08) ? 0x40000 : 0); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x08) ? 0x40000 : 0); } if ( lhb2_pen_hi & ~0xf ) @@ -941,7 +942,8 @@ static WRITE16_HANDLER( wlcc_magic_w ) coin_counter_w(space->machine, 0, data & 0x01); // coin out data & 0x02 - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x10) ? 0x40000 : 0); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x10) ? 0x40000 : 0); igs_hopper = data & 0x20; } @@ -997,7 +999,8 @@ static WRITE16_DEVICE_HANDLER( lhb_okibank_w ) { if (ACCESSING_BITS_8_15) { - okim6295_set_bank_base(device, (data & 0x200) ? 0x40000 : 0); + okim6295_device *oki = downcast(device); + oki->set_bank_base((data & 0x200) ? 0x40000 : 0); } if ( data & (~0x200) ) @@ -2525,8 +2528,7 @@ static MACHINE_DRIVER_START( igs011_base ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_22MHz/21) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_22MHz/21, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/igs017.c b/src/mame/drivers/igs017.c index 2b4a5962e6d..72c08b2ade2 100644 --- a/src/mame/drivers/igs017.c +++ b/src/mame/drivers/igs017.c @@ -1288,7 +1288,8 @@ static WRITE16_HANDLER( sdmg2_magic_w ) case 0x02: if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x80) ? 0x40000 : 0); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x80) ? 0x40000 : 0); } break; @@ -1303,7 +1304,7 @@ static READ16_HANDLER( sdmg2_magic_r ) { case 0x00: { - UINT16 hopper_bit = (hopper && ((video_screen_get_frame_number(space->machine->primary_screen)/10)&1)) ? 0x0000 : 0x0001; + UINT16 hopper_bit = (hopper && ((space->machine->primary_screen->frame_number()/10)&1)) ? 0x0000 : 0x0001; return input_port_read(space->machine, "COINS") | hopper_bit; } @@ -1388,7 +1389,8 @@ static WRITE16_HANDLER( mgdh_magic_w ) if (ACCESSING_BITS_0_7) { // bit 7? - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x40) ? 0x40000 : 0); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x40) ? 0x40000 : 0); } break; @@ -1412,7 +1414,7 @@ static READ16_HANDLER( mgdh_magic_r ) case 0x03: { - UINT16 hopper_bit = (hopper && ((video_screen_get_frame_number(space->machine->primary_screen)/10)&1)) ? 0x0000 : 0x0001; + UINT16 hopper_bit = (hopper && ((space->machine->primary_screen->frame_number()/10)&1)) ? 0x0000 : 0x0001; return input_port_read(space->machine, "COINS") | hopper_bit; } @@ -2055,8 +2057,7 @@ static MACHINE_DRIVER_START( iqblocka ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz / 16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_16MHz / 16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END @@ -2124,8 +2125,7 @@ static MACHINE_DRIVER_START( mgcs ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_8MHz / 8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_8MHz / 8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END @@ -2170,8 +2170,7 @@ static MACHINE_DRIVER_START( sdmg2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_22MHz / 22) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_22MHz / 22, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END @@ -2229,8 +2228,7 @@ static MACHINE_DRIVER_START( mgdh ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_22MHz / 22) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_22MHz / 22, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END diff --git a/src/mame/drivers/igspoker.c b/src/mame/drivers/igspoker.c index 860616b5bfd..2310e0b075d 100644 --- a/src/mame/drivers/igspoker.c +++ b/src/mame/drivers/igspoker.c @@ -283,7 +283,7 @@ static WRITE8_HANDLER( custom_io_w ) static CUSTOM_INPUT( hopper_r ) { - if (hopper) return !(video_screen_get_frame_number(field->port->machine->primary_screen)%10); + if (hopper) return !(field->port->machine->primary_screen->frame_number()%10); return input_code_pressed(field->port->machine, KEYCODE_H); } @@ -1615,8 +1615,7 @@ static MACHINE_DRIVER_START( number10 ) MDRV_VIDEO_START(cpokerpk) MDRV_VIDEO_UPDATE(cpokerpk) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz / 12) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_12MHz / 12, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ilpag.c b/src/mame/drivers/ilpag.c index 2c435e8ede7..af6a5892e0b 100644 --- a/src/mame/drivers/ilpag.c +++ b/src/mame/drivers/ilpag.c @@ -100,7 +100,7 @@ static VIDEO_UPDATE(ilpag) UINT32 color; color = (blit_buffer[count] & 0xff); - if(xmax_x && ymax_y) + if(xvisible_area().max_x && yvisible_area().max_y) *BITMAP_ADDR32(bitmap, y, x) = screen->machine->pens[color]; count++; @@ -464,19 +464,19 @@ static TIMER_DEVICE_CALLBACK( steaser_mcu_sim ) { // static int i; /*first off, signal the "MCU is running" flag*/ - timer->machine->generic.nvram.u16[0x932/2] = 0xffff; + timer.machine->generic.nvram.u16[0x932/2] = 0xffff; /*clear the inputs (they are impulsed)*/ // for(i=0;i<8;i+=2) // timer->machine->generic.nvram.u16[((0x8a0)+i)/2] = 0; /*finally, read the inputs*/ - timer->machine->generic.nvram.u16[0x89e/2] = input_port_read(timer->machine, "MENU") & 0xffff; - timer->machine->generic.nvram.u16[0x8a0/2] = input_port_read(timer->machine, "STAT") & 0xffff; - timer->machine->generic.nvram.u16[0x8a2/2] = input_port_read(timer->machine, "BET_DEAL") & 0xffff; - timer->machine->generic.nvram.u16[0x8a4/2] = input_port_read(timer->machine, "TAKE_DOUBLE") & 0xffff; - timer->machine->generic.nvram.u16[0x8a6/2] = input_port_read(timer->machine, "SMALL_BIG") & 0xffff; - timer->machine->generic.nvram.u16[0x8a8/2] = input_port_read(timer->machine, "CANCEL_HOLD1") & 0xffff; - timer->machine->generic.nvram.u16[0x8aa/2] = input_port_read(timer->machine, "HOLD2_HOLD3") & 0xffff; - timer->machine->generic.nvram.u16[0x8ac/2] = input_port_read(timer->machine, "HOLD4_HOLD5") & 0xffff; + timer.machine->generic.nvram.u16[0x89e/2] = input_port_read(timer.machine, "MENU") & 0xffff; + timer.machine->generic.nvram.u16[0x8a0/2] = input_port_read(timer.machine, "STAT") & 0xffff; + timer.machine->generic.nvram.u16[0x8a2/2] = input_port_read(timer.machine, "BET_DEAL") & 0xffff; + timer.machine->generic.nvram.u16[0x8a4/2] = input_port_read(timer.machine, "TAKE_DOUBLE") & 0xffff; + timer.machine->generic.nvram.u16[0x8a6/2] = input_port_read(timer.machine, "SMALL_BIG") & 0xffff; + timer.machine->generic.nvram.u16[0x8a8/2] = input_port_read(timer.machine, "CANCEL_HOLD1") & 0xffff; + timer.machine->generic.nvram.u16[0x8aa/2] = input_port_read(timer.machine, "HOLD2_HOLD3") & 0xffff; + timer.machine->generic.nvram.u16[0x8ac/2] = input_port_read(timer.machine, "HOLD4_HOLD5") & 0xffff; } /* TODO: remove this hack.*/ diff --git a/src/mame/drivers/itech32.c b/src/mame/drivers/itech32.c index f886b6ea784..d3d6369f8b0 100644 --- a/src/mame/drivers/itech32.c +++ b/src/mame/drivers/itech32.c @@ -445,7 +445,7 @@ static INTERRUPT_GEN( generate_int1 ) { /* signal the NMI */ itech32_update_interrupts(device->machine, 1, -1, -1); - if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", video_screen_get_vpos(device->machine->primary_screen)); + if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", device->machine->primary_screen->vpos()); } @@ -524,7 +524,7 @@ static READ32_HANDLER( trackball32_4bit_r ) static attotime lasttime; attotime curtime = timer_get_time(space->machine); - if (attotime_compare(attotime_sub(curtime, lasttime), video_screen_get_scan_period(space->machine->primary_screen)) > 0) + if (attotime_compare(attotime_sub(curtime, lasttime), space->machine->primary_screen->scan_period()) > 0) { int upper, lower; int dx, dy; @@ -563,7 +563,7 @@ static READ32_HANDLER( trackball32_4bit_p2_r ) static attotime lasttime; attotime curtime = timer_get_time(space->machine); - if (attotime_compare(attotime_sub(curtime, lasttime), video_screen_get_scan_period(space->machine->primary_screen)) > 0) + if (attotime_compare(attotime_sub(curtime, lasttime), space->machine->primary_screen->scan_period()) > 0) { int upper, lower; int dx, dy; @@ -1786,7 +1786,6 @@ static MACHINE_DRIVER_START( drivedge ) MDRV_CPU_REPLACE("maincpu", M68EC020, CPU020_CLOCK) MDRV_CPU_PROGRAM_MAP(drivedge_map) - MDRV_CPU_VBLANK_INT_HACK(NULL,0) MDRV_CPU_ADD("dsp1", TMS32031, TMS_CLOCK) MDRV_CPU_PROGRAM_MAP(drivedge_tms1_map) @@ -1808,6 +1807,7 @@ static MACHINE_DRIVER_START( sftm ) MDRV_CPU_REPLACE("maincpu", M68EC020, CPU020_CLOCK) MDRV_CPU_PROGRAM_MAP(itech020_map) + MDRV_CPU_VBLANK_INT("screen", generate_int1) MDRV_CPU_MODIFY("soundcpu") MDRV_CPU_PROGRAM_MAP(sound_020_map) diff --git a/src/mame/drivers/itech8.c b/src/mame/drivers/itech8.c index 637eb6d0f9e..792bef504d4 100644 --- a/src/mame/drivers/itech8.c +++ b/src/mame/drivers/itech8.c @@ -636,7 +636,7 @@ static INTERRUPT_GEN( generate_nmi ) itech8_update_interrupts(device->machine, 1, -1, -1); timer_set(device->machine, ATTOTIME_IN_USEC(1), NULL, 0, irq_off); - if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", video_screen_get_vpos(device->machine->primary_screen)); + if (FULL_LOGGING) logerror("------------ VBLANK (%d) --------------\n", device->machine->primary_screen->vpos()); } @@ -666,7 +666,7 @@ static TIMER_CALLBACK( behind_the_beam_update ); static MACHINE_START( sstrike ) { /* we need to update behind the beam as well */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 32, behind_the_beam_update); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 32, behind_the_beam_update); } static MACHINE_RESET( itech8 ) @@ -686,7 +686,7 @@ static MACHINE_RESET( itech8 ) /* set the visible area */ if (visarea) { - video_screen_set_visarea(machine->primary_screen, visarea->min_x, visarea->max_x, visarea->min_y, visarea->max_y); + machine->primary_screen->set_visible_area(visarea->min_x, visarea->max_x, visarea->min_y, visarea->max_y); visarea = NULL; } } @@ -705,14 +705,14 @@ static TIMER_CALLBACK( behind_the_beam_update ) int interval = param & 0xff; /* force a partial update to the current scanline */ - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); /* advance by the interval, and wrap to 0 */ scanline += interval; if (scanline >= 256) scanline = 0; /* set a new timer */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, (scanline << 8) + interval, behind_the_beam_update); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, (scanline << 8) + interval, behind_the_beam_update); } @@ -1769,8 +1769,7 @@ static MACHINE_DRIVER_START( itech8_sound_ym2203 ) MDRV_SOUND_ROUTE(2, "mono", 0.07) MDRV_SOUND_ROUTE(3, "mono", 0.75) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128?? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified + MDRV_OKIM6295_ADD("oki", CLOCK_8MHz/8, OKIM6295_PIN7_HIGH) // was /128, not /132, so unsure so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_DRIVER_END @@ -1801,8 +1800,7 @@ static MACHINE_DRIVER_START( itech8_sound_ym3812 ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128?? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified + MDRV_OKIM6295_ADD("oki", CLOCK_8MHz/8, OKIM6295_PIN7_HIGH) // was /128, not /132, so unsure so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_DRIVER_END @@ -1818,8 +1816,7 @@ static MACHINE_DRIVER_START( itech8_sound_ym3812_external ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_8MHz/8) // was /128?? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128, not /132, so unsure so pin 7 not verified + MDRV_OKIM6295_ADD("oki", CLOCK_8MHz/8, OKIM6295_PIN7_HIGH) // was /128, not /132, so unsure so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) MACHINE_DRIVER_END @@ -1972,6 +1969,8 @@ static MACHINE_DRIVER_START( rimrockn ) MDRV_IMPORT_FROM(itech8_sound_ym3812_external) MDRV_CPU_REPLACE("maincpu", HD6309, CLOCK_12MHz) + MDRV_CPU_PROGRAM_MAP(tmshi_map) + MDRV_CPU_VBLANK_INT("screen", generate_nmi) /* video hardware */ MDRV_SCREEN_MODIFY("screen") @@ -1988,6 +1987,7 @@ static MACHINE_DRIVER_START( ninclown ) MDRV_CPU_REPLACE("maincpu", M68000, CLOCK_12MHz) MDRV_CPU_PROGRAM_MAP(ninclown_map) + MDRV_CPU_VBLANK_INT("screen", generate_nmi) /* video hardware */ MDRV_SCREEN_MODIFY("screen") diff --git a/src/mame/drivers/itgambl2.c b/src/mame/drivers/itgambl2.c index 389f49680c7..0cbf5d55226 100644 --- a/src/mame/drivers/itgambl2.c +++ b/src/mame/drivers/itgambl2.c @@ -114,7 +114,7 @@ static VIDEO_UPDATE( itgambl2 ) color = (blit_ram[count] & 0xff)>>0; - if((x)max_x && ((y)+0)max_y) + if((x)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x) = screen->machine->pens[color]; count++; diff --git a/src/mame/drivers/itgambl3.c b/src/mame/drivers/itgambl3.c index d7f9df655d7..ec98498a087 100644 --- a/src/mame/drivers/itgambl3.c +++ b/src/mame/drivers/itgambl3.c @@ -102,7 +102,7 @@ static VIDEO_UPDATE( itgambl3 ) color = (blit_ram[count] & 0xff)>>0; - if((x)max_x && ((y)+0)max_y) + if((x)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x) = screen->machine->pens[color]; count++; @@ -259,8 +259,7 @@ static MACHINE_DRIVER_START( itgambl3 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MAIN_CLOCK/16) /* 1MHz */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", MAIN_CLOCK/16, OKIM6295_PIN7_HIGH) /* 1MHz */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/itgamble.c b/src/mame/drivers/itgamble.c index 7970c99d63c..4ad8685f77b 100644 --- a/src/mame/drivers/itgamble.c +++ b/src/mame/drivers/itgamble.c @@ -201,8 +201,7 @@ static MACHINE_DRIVER_START( itgamble ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, SND_CLOCK) /* 1MHz resonator */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", SND_CLOCK, OKIM6295_PIN7_HIGH) /* 1MHz resonator */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -210,10 +209,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( mnumber ) MDRV_IMPORT_FROM(itgamble) - MDRV_CPU_REPLACE("maincpu", H83044, MNUMBER_MAIN_CLOCK/2) /* probably the wrong CPU */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(MNUMBER_MAIN_CLOCK/2) /* probably the wrong CPU */ - MDRV_SOUND_REPLACE("oki", OKIM6295, MNUMBER_SND_CLOCK/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_REPLACE("oki", MNUMBER_SND_CLOCK/16, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -222,10 +221,10 @@ static MACHINE_DRIVER_START( ejollyx5 ) MDRV_IMPORT_FROM(itgamble) /* wrong CPU. we need a Renesas M16/62A 16bit microcomputer core */ - MDRV_CPU_REPLACE("maincpu", H83044, EJOLLYX5_MAIN_CLOCK/2) /* up to 10MHz.*/ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(EJOLLYX5_MAIN_CLOCK/2) /* up to 10MHz.*/ - MDRV_SOUND_REPLACE("oki", OKIM6295, MNUMBER_SND_CLOCK/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_REPLACE("oki", MNUMBER_SND_CLOCK/16, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/jackie.c b/src/mame/drivers/jackie.c index c6d73af86d3..dc0fdca6d6e 100644 --- a/src/mame/drivers/jackie.c +++ b/src/mame/drivers/jackie.c @@ -146,7 +146,7 @@ static VIDEO_UPDATE(jackie) { int i,j; int startclipmin = 0; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); @@ -163,8 +163,8 @@ static VIDEO_UPDATE(jackie) int rowenable = bg_scroll2[j]; /* draw top of screen */ - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; clip.min_y = startclipmin; clip.max_y = startclipmin+1; @@ -355,7 +355,7 @@ ADDRESS_MAP_END static CUSTOM_INPUT( hopper_r ) { - if (hopper) return !(video_screen_get_frame_number(field->port->machine->primary_screen)%10); + if (hopper) return !(field->port->machine->primary_screen->frame_number()%10); return input_code_pressed(field->port->machine, KEYCODE_H); } diff --git a/src/mame/drivers/jackpool.c b/src/mame/drivers/jackpool.c index a0463e0c23e..0fa87651169 100644 --- a/src/mame/drivers/jackpool.c +++ b/src/mame/drivers/jackpool.c @@ -262,8 +262,7 @@ static MACHINE_DRIVER_START( jackpool ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/jalmah.c b/src/mame/drivers/jalmah.c index 0e77da81389..8eb88f17772 100644 --- a/src/mame/drivers/jalmah.c +++ b/src/mame/drivers/jalmah.c @@ -841,12 +841,12 @@ static TIMER_DEVICE_CALLBACK( jalmah_mcu_sim ) #define KAKUMEI2_MCU (0x22) #define SUCHIPI_MCU (0x23) */ - case MJZOOMIN_MCU: mjzoomin_mcu_run(timer->machine); break; - case DAIREIKA_MCU: daireika_mcu_run(timer->machine); break; - case URASHIMA_MCU: urashima_mcu_run(timer->machine); break; + case MJZOOMIN_MCU: mjzoomin_mcu_run(timer.machine); break; + case DAIREIKA_MCU: daireika_mcu_run(timer.machine); break; + case URASHIMA_MCU: urashima_mcu_run(timer.machine); break; case KAKUMEI_MCU: case KAKUMEI2_MCU: - case SUCHIPI_MCU: second_mcu_run(timer->machine); break; + case SUCHIPI_MCU: second_mcu_run(timer.machine); break; } } @@ -1327,8 +1327,7 @@ static MACHINE_DRIVER_START( jalmah ) MDRV_TIMER_ADD_PERIODIC("mcusim", jalmah_mcu_sim, HZ(10000)) // not real, but for simulating the MCU MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 4000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 4000000, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END diff --git a/src/mame/drivers/janshi.c b/src/mame/drivers/janshi.c index 392a91c6285..279d63a5ead 100644 --- a/src/mame/drivers/janshi.c +++ b/src/mame/drivers/janshi.c @@ -92,8 +92,7 @@ static MACHINE_DRIVER_START( janshi ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/jantotsu.c b/src/mame/drivers/jantotsu.c index 336feddac93..f0a3c33c5eb 100644 --- a/src/mame/drivers/jantotsu.c +++ b/src/mame/drivers/jantotsu.c @@ -160,7 +160,7 @@ static VIDEO_UPDATE(jantotsu) color |= ((pen[3] & 1) << 3); color |= state->col_bank; - if ((x + i) <= video_screen_get_visible_area(screen)->max_x && (y + 0) < video_screen_get_visible_area(screen)->max_y) + if ((x + i) <= screen->visible_area().max_x && (y + 0) < screen->visible_area().max_y) *BITMAP_ADDR32(bitmap, y, x + i) = screen->machine->pens[color]; } diff --git a/src/mame/drivers/jedi.c b/src/mame/drivers/jedi.c index df38bf48e1e..442f5dfc30f 100644 --- a/src/mame/drivers/jedi.c +++ b/src/mame/drivers/jedi.c @@ -135,7 +135,7 @@ static TIMER_CALLBACK( generate_interrupt ) scanline += 32; if (scanline > 256) scanline = 32; - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -158,7 +158,7 @@ static MACHINE_START( jedi ) /* set a timer to run the interrupts */ state->interrupt_timer = timer_alloc(machine, generate_interrupt, NULL); - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 32, 0), 32); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(32), 32); /* configure the banks */ memory_configure_bank(machine, "bank1", 0, 3, memory_region(machine, "maincpu") + 0x10000, 0x4000); diff --git a/src/mame/drivers/jpmimpct.c b/src/mame/drivers/jpmimpct.c index ffb48a0b3bd..bb6c1179a58 100644 --- a/src/mame/drivers/jpmimpct.c +++ b/src/mame/drivers/jpmimpct.c @@ -241,7 +241,7 @@ static TIMER_DEVICE_CALLBACK( duart_1_timer_event ) duart_1.ISR |= 0x08; duart_1_irq = 1; - update_irqs(timer->machine); + update_irqs(timer.machine); } static READ16_HANDLER( duart_1_r ) @@ -292,7 +292,8 @@ static READ16_HANDLER( duart_1_r ) case 0xe: { attotime rate = attotime_mul(ATTOTIME_IN_HZ(MC68681_1_CLOCK), 16 * duart_1.CT); - timer_device_adjust_periodic(devtag_get_device(space->machine, "duart_1_timer"), rate, 0, rate); + timer_device *duart_timer = space->machine->device("duart_1_timer"); + duart_timer->adjust(rate, 0, rate); break; } case 0xf: diff --git a/src/mame/drivers/kaneko16.c b/src/mame/drivers/kaneko16.c index 814f4d2f297..1157f8892ab 100644 --- a/src/mame/drivers/kaneko16.c +++ b/src/mame/drivers/kaneko16.c @@ -398,7 +398,8 @@ ADDRESS_MAP_END static WRITE16_DEVICE_HANDLER( bakubrkr_oki_bank_sw ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 0x7) ); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 0x7) ); logerror("%s:Selecting OKI bank %02X\n",cpuexec_describe_context(device->machine),data&0xff); } } @@ -469,7 +470,8 @@ static WRITE16_DEVICE_HANDLER( bloodwar_oki_0_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 0xf) ); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 0xf) ); // logerror("CPU #0 PC %06X : OKI0 bank %08X\n",cpu_get_pc(space->cpu),data); } } @@ -478,7 +480,8 @@ static WRITE16_DEVICE_HANDLER( bloodwar_oki_1_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * data ); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * data ); // logerror("CPU #0 PC %06X : OKI1 bank %08X\n",cpu_get_pc(space->cpu),data); } } @@ -539,7 +542,8 @@ static WRITE16_DEVICE_HANDLER( bonkadv_oki_0_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 0xF)); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * (data & 0xF)); logerror("%s: OKI0 bank %08X\n",cpuexec_describe_context(device->machine),data); } } @@ -548,7 +552,8 @@ static WRITE16_DEVICE_HANDLER( bonkadv_oki_1_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * data ); + okim6295_device *oki = downcast(device); + oki->set_bank_base(0x40000 * data ); logerror("%s: OKI1 bank %08X\n",cpuexec_describe_context(device->machine),data); } } @@ -614,7 +619,8 @@ static WRITE16_DEVICE_HANDLER( gtmr_oki_0_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 0xF) ); + okim6295_device *oki = downcast(device); + oki->set_bank_base( 0x40000 * (data & 0xF) ); // logerror("CPU #0 PC %06X : OKI0 bank %08X\n",cpu_get_pc(space->cpu),data); } } @@ -623,7 +629,8 @@ static WRITE16_DEVICE_HANDLER( gtmr_oki_1_bank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * (data & 0x1) ); + okim6295_device *oki = downcast(device); + oki->set_bank_base( 0x40000 * (data & 0x1) ); // logerror("CPU #0 PC %06X : OKI1 bank %08X\n",cpu_get_pc(space->cpu),data); } } @@ -1828,8 +1835,7 @@ static MACHINE_DRIVER_START( berlwall ) MDRV_SOUND_ADD("ay2", YM2149, 1000000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/6) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 12000000/6, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -1875,8 +1881,7 @@ static MACHINE_DRIVER_START( bakubrkr ) MDRV_SOUND_CONFIG(ay8910_intf_eeprom) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/6) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/6, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1976,12 +1981,10 @@ static MACHINE_DRIVER_START( gtmr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_16MHz/8) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_16MHz/8, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_16MHz/8) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", XTAL_16MHz/8, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_DRIVER_END @@ -2076,8 +2079,7 @@ static MACHINE_DRIVER_START( mgcrystl ) MDRV_SOUND_CONFIG(ay8910_intf_eeprom) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/6) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/6, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -2187,13 +2189,11 @@ static MACHINE_DRIVER_START( shogwarr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_16MHz/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", XTAL_16MHz/8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_DEVICE_ADDRESS_MAP(0, shogwarr_oki1_map) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_16MHz/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", XTAL_16MHz/8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_DEVICE_ADDRESS_MAP(0, shogwarr_oki2_map) MACHINE_DRIVER_END diff --git a/src/mame/drivers/kangaroo.c b/src/mame/drivers/kangaroo.c index d855bc1e4d0..4359d03952a 100644 --- a/src/mame/drivers/kangaroo.c +++ b/src/mame/drivers/kangaroo.c @@ -468,7 +468,7 @@ static MACHINE_DRIVER_START( mcu ) MDRV_MACHINE_START(kangaroo_mcu) MDRV_CPU_ADD("mcu", MB8841, MASTER_CLOCK/4/2) - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MACHINE_DRIVER_END diff --git a/src/mame/drivers/kickgoal.c b/src/mame/drivers/kickgoal.c index 88e0c9b0db3..ca30b56fb55 100644 --- a/src/mame/drivers/kickgoal.c +++ b/src/mame/drivers/kickgoal.c @@ -172,25 +172,37 @@ WRITE16_DEVICE_HANDLER( kickgoal_snd_w ) if (kickgoal_sound >= 0x70) { if (kickgoal_snd_bank != 1) - okim6295_set_bank_base(device, (1 * 0x40000)); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((1 * 0x40000)); + } kickgoal_snd_bank = 1; kickgoal_play(device, 0, data); } else if (kickgoal_sound >= 0x69) { if (kickgoal_snd_bank != 2) - okim6295_set_bank_base(device, (2 * 0x40000)); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((2 * 0x40000)); + } kickgoal_snd_bank = 2; kickgoal_play(device, 4, data); } else if (kickgoal_sound >= 0x65) { if (kickgoal_snd_bank != 1) - okim6295_set_bank_base(device, (1 * 0x40000)); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base((1 * 0x40000)); + } kickgoal_snd_bank = 1; kickgoal_play(device, 4, data); } else if (kickgoal_sound >= 0x60) { kickgoal_snd_bank = 0; - okim6295_set_bank_base(device, (0 * 0x40000)); + { + okim6295_device *oki = downcast(device); + oki->set_bank_base(device, (0 * 0x40000)); + } kickgoal_snd_bank = 0; kickgoal_play(device, 4, data); } @@ -210,12 +222,13 @@ static WRITE16_DEVICE_HANDLER( actionhw_snd_w ) if (!ACCESSING_BITS_0_7) data >>= 8; + okim6295_device *oki = downcast(device); switch (data) { - case 0xfc: okim6295_set_bank_base(device, (0 * 0x40000)); break; - case 0xfd: okim6295_set_bank_base(device, (2 * 0x40000)); break; - case 0xfe: okim6295_set_bank_base(device, (1 * 0x40000)); break; - case 0xff: okim6295_set_bank_base(device, (3 * 0x40000)); break; + case 0xfc: oki->set_bank_base((0 * 0x40000)); break; + case 0xfd: oki->set_bank_base((2 * 0x40000)); break; + case 0xfe: oki->set_bank_base((1 * 0x40000)); break; + case 0xff: oki->set_bank_base((3 * 0x40000)); break; case 0x78: okim6295_w(device, 0, data); state->snd_sam[0] = 00; state->snd_sam[1]= 00; state->snd_sam[2] = 00; state->snd_sam[3] = 00; @@ -336,7 +349,7 @@ static INTERRUPT_GEN( kickgoal_interrupt ) if (state->m6295_bank == 0x03) state->m6295_bank = 0x00; popmessage("Changing Bank to %02x", state->m6295_bank); - okim6295_set_bank_base(state->adpcm, ((state->m6295_bank) * 0x40000)); + state->adpcm->set_bank_base(((state->m6295_bank) * 0x40000)); if (state->m6295_key_delay == 0xffff) state->m6295_key_delay = 0x00; @@ -355,7 +368,7 @@ static INTERRUPT_GEN( kickgoal_interrupt ) if (state->m6295_bank == 0x03) state->m6295_bank = 0x02; popmessage("Changing Bank to %02x", state->m6295_bank); - okim6295_set_bank_base(state->adpcm, ((state->m6295_bank) * 0x40000)); + state->adpcm->set_bank_base(((state->m6295_bank) * 0x40000)); if (state->m6295_key_delay == 0xffff) state->m6295_key_delay = 0x00; @@ -371,11 +384,11 @@ static INTERRUPT_GEN( kickgoal_interrupt ) { state->m6295_comm += 1; state->m6295_comm &= 0x7f; - if (state->m6295_comm == 0x00) { okim6295_set_bank_base(state->adpcm, (0 * 0x40000)); state->m6295_bank = 0; } - if (state->m6295_comm == 0x60) { okim6295_set_bank_base(state->adpcm, (0 * 0x40000)); state->m6295_bank = 0; } - if (state->m6295_comm == 0x65) { okim6295_set_bank_base(state->adpcm, (1 * 0x40000)); state->m6295_bank = 1; } - if (state->m6295_comm == 0x69) { okim6295_set_bank_base(state->adpcm, (2 * 0x40000)); state->m6295_bank = 2; } - if (state->m6295_comm == 0x70) { okim6295_set_bank_base(state->adpcm, (1 * 0x40000)); state->m6295_bank = 1; } + if (state->m6295_comm == 0x00) { state->adpcm->set_bank_base((0 * 0x40000)); state->m6295_bank = 0; } + if (state->m6295_comm == 0x60) { state->adpcm->set_bank_base((0 * 0x40000)); state->m6295_bank = 0; } + if (state->m6295_comm == 0x65) { state->adpcm->set_bank_base((1 * 0x40000)); state->m6295_bank = 1; } + if (state->m6295_comm == 0x69) { state->adpcm->set_bank_base((2 * 0x40000)); state->m6295_bank = 2; } + if (state->m6295_comm == 0x70) { state->adpcm->set_bank_base((1 * 0x40000)); state->m6295_bank = 1; } popmessage("Sound test command %02x on Bank %02x", state->m6295_comm, state->m6295_bank); if (state->m6295_key_delay == 0xffff) @@ -392,11 +405,11 @@ static INTERRUPT_GEN( kickgoal_interrupt ) { state->m6295_comm -= 1; state->m6295_comm &= 0x7f; - if (state->m6295_comm == 0x2b) { okim6295_set_bank_base(state->adpcm, (0 * 0x40000)); state->m6295_bank = 0; } - if (state->m6295_comm == 0x64) { okim6295_set_bank_base(state->adpcm, (0 * 0x40000)); state->m6295_bank = 0; } - if (state->m6295_comm == 0x68) { okim6295_set_bank_base(state->adpcm, (1 * 0x40000)); state->m6295_bank = 1; } - if (state->m6295_comm == 0x6c) { okim6295_set_bank_base(state->adpcm, (2 * 0x40000)); state->m6295_bank = 2; } - if (state->m6295_comm == 0x76) { okim6295_set_bank_base(state->adpcm, (1 * 0x40000)); state->m6295_bank = 1; } + if (state->m6295_comm == 0x2b) { state->adpcm->set_bank_base((0 * 0x40000)); state->m6295_bank = 0; } + if (state->m6295_comm == 0x64) { state->adpcm->set_bank_base((0 * 0x40000)); state->m6295_bank = 0; } + if (state->m6295_comm == 0x68) { state->adpcm->set_bank_base((1 * 0x40000)); state->m6295_bank = 1; } + if (state->m6295_comm == 0x6c) { state->adpcm->set_bank_base((2 * 0x40000)); state->m6295_bank = 2; } + if (state->m6295_comm == 0x76) { state->adpcm->set_bank_base((1 * 0x40000)); state->m6295_bank = 1; } popmessage("Sound test command %02x on Bank %02x", state->m6295_comm, state->m6295_bank); if (state->m6295_key_delay == 0xffff) @@ -647,9 +660,6 @@ static MACHINE_START( kickgoal ) { kickgoal_state *state = (kickgoal_state *)machine->driver_data; - state->adpcm = devtag_get_device(machine, "oki"); - state->eeprom = devtag_get_device(machine, "eeprom"); - state_save_register_global_array(machine, state->snd_sam); state_save_register_global(machine, state->melody_loop); state_save_register_global(machine, state->snd_new); @@ -685,7 +695,7 @@ static MACHINE_DRIVER_START( kickgoal ) MDRV_CPU_PERIODIC_INT(kickgoal_interrupt, 240) MDRV_CPU_ADD("audiocpu", PIC16C57, 12000000/4) /* 3MHz ? */ - MDRV_CPU_FLAGS(CPU_DISABLE) /* Disables since the internal rom isn't dumped */ + MDRV_DEVICE_DISABLE() /* Disables since the internal rom isn't dumped */ /* Program and Data Maps are internal to the MCU */ MDRV_CPU_IO_MAP(kickgoal_sound_io_map) @@ -711,8 +721,7 @@ static MACHINE_DRIVER_START( kickgoal ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 12000000/8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -727,7 +736,7 @@ static MACHINE_DRIVER_START( actionhw ) MDRV_CPU_VBLANK_INT("screen", irq6_line_hold) MDRV_CPU_ADD("audiocpu", PIC16C57, XTAL_12MHz/3) /* verified on pcb */ - MDRV_CPU_FLAGS(CPU_DISABLE) /* Disables since the internal rom isn't dumped */ + MDRV_DEVICE_DISABLE() /* Disables since the internal rom isn't dumped */ /* Program and Data Maps are internal to the MCU */ MDRV_CPU_IO_MAP(actionhw_io_map) @@ -753,8 +762,7 @@ static MACHINE_DRIVER_START( actionhw ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz/12) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/kingdrby.c b/src/mame/drivers/kingdrby.c index b9cf8c1fd7b..eea2dca4d82 100644 --- a/src/mame/drivers/kingdrby.c +++ b/src/mame/drivers/kingdrby.c @@ -183,7 +183,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta static VIDEO_UPDATE(kingdrby) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); rectangle clip; tilemap_set_scrollx( sc0_tilemap,0, kingdrby_vram[0x342]); tilemap_set_scrolly( sc0_tilemap,0, kingdrby_vram[0x341]); @@ -192,10 +192,10 @@ static VIDEO_UPDATE(kingdrby) tilemap_set_scrolly( sc0w_tilemap,0, 32); /* maybe it needs two window tilemaps? (one at the top, the other at the bottom)*/ - clip.min_x = visarea->min_x; + clip.min_x = visarea.min_x; clip.max_x = 256; clip.min_y = 192; - clip.max_y = visarea->max_y; + clip.max_y = visarea.max_y; /*TILEMAP_DRAW_CATEGORY + TILEMAP_DRAW_OPAQUE doesn't suit well?*/ tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0); @@ -1033,8 +1033,7 @@ static MACHINE_DRIVER_START( cowrace ) MDRV_GFXDECODE(cowrace) MDRV_PALETTE_INIT(kingdrby) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MDRV_SOUND_REPLACE("aysnd", YM2203, 3000000) diff --git a/src/mame/drivers/klax.c b/src/mame/drivers/klax.c index baf9a012dbd..6e9ce11d2c9 100644 --- a/src/mame/drivers/klax.c +++ b/src/mame/drivers/klax.c @@ -37,11 +37,11 @@ static void update_interrupts(running_machine *machine) } -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { /* generate 32V signals */ - if ((scanline & 32) == 0 && !(input_port_read(screen->machine, "P1") & 0x800)) - atarigen_scanline_int_gen(devtag_get_device(screen->machine, "maincpu")); + if ((scanline & 32) == 0 && !(input_port_read(screen.machine, "P1") & 0x800)) + atarigen_scanline_int_gen(devtag_get_device(screen.machine, "maincpu")); } @@ -71,7 +71,7 @@ static MACHINE_RESET( klax ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 32); } @@ -193,8 +193,7 @@ static MACHINE_DRIVER_START( klax ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, ATARI_CLOCK_14MHz/4/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", ATARI_CLOCK_14MHz/4/4, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/koftball.c b/src/mame/drivers/koftball.c index 5ba631677f9..d2b813e8def 100644 --- a/src/mame/drivers/koftball.c +++ b/src/mame/drivers/koftball.c @@ -223,8 +223,7 @@ static MACHINE_DRIVER_START( koftball ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_LOW) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/konamigx.c b/src/mame/drivers/konamigx.c index 5eae6c1b9c0..e1a1323254e 100644 --- a/src/mame/drivers/konamigx.c +++ b/src/mame/drivers/konamigx.c @@ -670,7 +670,7 @@ static INTERRUPT_GEN(konamigx_vbinterrupt_type4) // maybe this interupt should only be every 30fps, or maybe there are flags to prevent the game running too fast // the real hardware should output the display for each screen on alternate frames -// if(video_screen_get_frame_number(device->machine->primary_screen) & 1) +// if(device->machine->primary_screen->frame_number() & 1) if (1) // gx_syncen & 0x20) { gx_syncen &= ~0x20; @@ -1840,7 +1840,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( dragoonj ) MDRV_IMPORT_FROM(konamigx) - MDRV_CPU_REPLACE("maincpu", M68EC020, 26400000) // needs higher clock to stop sprite flickerings + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(26400000) // needs higher clock to stop sprite flickerings MDRV_SCREEN_MODIFY("screen") MDRV_SCREEN_VISIBLE_AREA(40, 40+384-1, 16, 16+224-1) MDRV_VIDEO_START(dragoonj) diff --git a/src/mame/drivers/laserbas.c b/src/mame/drivers/laserbas.c index 61b421a22d5..6983615c10d 100644 --- a/src/mame/drivers/laserbas.c +++ b/src/mame/drivers/laserbas.c @@ -150,7 +150,7 @@ INPUT_PORTS_END static INTERRUPT_GEN( laserbas_interrupt ) { - if(video_screen_get_vblank(device->machine->primary_screen)) + if(device->machine->primary_screen->vblank()) cpu_set_input_line(device, 0, HOLD_LINE); else cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); diff --git a/src/mame/drivers/lastduel.c b/src/mame/drivers/lastduel.c index f499c8d752d..1c90207ecf8 100644 --- a/src/mame/drivers/lastduel.c +++ b/src/mame/drivers/lastduel.c @@ -590,8 +590,7 @@ static MACHINE_DRIVER_START( madgear ) MDRV_SOUND_ADD("ym2", YM2203, XTAL_3_579545MHz) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_10MHz/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_10MHz/10, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.98) MACHINE_DRIVER_END diff --git a/src/mame/drivers/lastfght.c b/src/mame/drivers/lastfght.c index 326bfb354fd..25325527d02 100644 --- a/src/mame/drivers/lastfght.c +++ b/src/mame/drivers/lastfght.c @@ -101,7 +101,7 @@ static VIDEO_START( lastfght ) lastfght_state *state = (lastfght_state *)machine->driver_data; int i; for (i = 0; i < 2; i++) - state->bitmap[i] = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->bitmap[i] = machine->primary_screen->alloc_compatible_bitmap(); state->colorram = auto_alloc_array(machine, UINT8, 256 * 3); diff --git a/src/mame/drivers/legionna.c b/src/mame/drivers/legionna.c index 2d6dec73616..d511c758646 100644 --- a/src/mame/drivers/legionna.c +++ b/src/mame/drivers/legionna.c @@ -207,16 +207,16 @@ static ADDRESS_MAP_START( cupsocbl_mem, ADDRESS_SPACE_PROGRAM, 16 ) ADDRESS_MAP_END -static WRITE8_HANDLER( okim_rombank_w ) +static WRITE8_DEVICE_HANDLER( okim_rombank_w ) { // popmessage("%08x",0x40000 * (data & 0x07)); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), 0x40000 * (data & 0x7)); + downcast(device)->set_bank_base(0x40000 * (data & 0x7)); } static ADDRESS_MAP_START( cupsocbl_sound_mem, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x8000, 0x87ff) AM_RAM - AM_RANGE(0x9000, 0x9000) AM_WRITE(okim_rombank_w) + AM_RANGE(0x9000, 0x9000) AM_DEVWRITE("oki", okim_rombank_w) AM_RANGE(0x9800, 0x9800) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w) AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r) ADDRESS_MAP_END @@ -1262,8 +1262,7 @@ static MACHINE_DRIVER_START( cupsocbl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/lemmings.c b/src/mame/drivers/lemmings.c index e9b8849ba94..0271a8ebf3e 100644 --- a/src/mame/drivers/lemmings.c +++ b/src/mame/drivers/lemmings.c @@ -302,8 +302,7 @@ static MACHINE_DRIVER_START( lemmings ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/lethalj.c b/src/mame/drivers/lethalj.c index 7db241e7f9a..158d376fd3e 100644 --- a/src/mame/drivers/lethalj.c +++ b/src/mame/drivers/lethalj.c @@ -614,16 +614,13 @@ static MACHINE_DRIVER_START( gameroom ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, SOUND_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", SOUND_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.26) - MDRV_SOUND_ADD("oki2", OKIM6295, SOUND_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", SOUND_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.26) - MDRV_SOUND_ADD("oki3", OKIM6295, SOUND_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki3", SOUND_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.26) MACHINE_DRIVER_END diff --git a/src/mame/drivers/limenko.c b/src/mame/drivers/limenko.c index 0e043bac1fa..4cfe1c45272 100644 --- a/src/mame/drivers/limenko.c +++ b/src/mame/drivers/limenko.c @@ -693,8 +693,7 @@ static MACHINE_DRIVER_START( spotty ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 4000000 / 4 ) //? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // not verified + MDRV_OKIM6295_ADD("oki", 4000000 / 4 , OKIM6295_PIN7_HIGH) //? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/lordgun.c b/src/mame/drivers/lordgun.c index fe03458e22f..40f9cd8cf44 100644 --- a/src/mame/drivers/lordgun.c +++ b/src/mame/drivers/lordgun.c @@ -318,7 +318,7 @@ ADDRESS_MAP_END static WRITE8_DEVICE_HANDLER( lordgun_okibank_w ) { - okim6295_set_bank_base(device, (data & 2) ? 0x40000 : 0); + downcast(device)->set_bank_base((data & 2) ? 0x40000 : 0); if (data & ~3) logerror("%s: unknown okibank bits %02x\n", cpuexec_describe_context(device->machine), data); // popmessage("OKI %x", data); } @@ -684,8 +684,7 @@ static MACHINE_DRIVER_START( lordgun ) MDRV_SOUND_CONFIG(lordgun_ym3812_interface) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 20) // ? 5MHz can't be right - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 20, OKIM6295_PIN7_HIGH) // ? 5MHz can't be right! MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -729,12 +728,10 @@ static MACHINE_DRIVER_START( aliencha ) MDRV_SOUND_CONFIG(ymf278b_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz / 20) // ? 5MHz can't be right - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz / 20, OKIM6295_PIN7_HIGH) // ? 5MHz can't be right MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_20MHz / 20) // ? 5MHz can't be right - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", XTAL_20MHz / 20, OKIM6295_PIN7_HIGH) // ? 5MHz can't be right MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/luckgrln.c b/src/mame/drivers/luckgrln.c index c3e262da48a..5da7036f67a 100644 --- a/src/mame/drivers/luckgrln.c +++ b/src/mame/drivers/luckgrln.c @@ -235,17 +235,17 @@ static VIDEO_UPDATE(luckgrln) { int y,x; int count = 0; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); int i; rectangle clip; bitmap_fill(bitmap, cliprect, 0x3f); /* is there a register controling the colour?, we currently use the last colour of the tx palette */ - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; bitmap_fill(bitmap, cliprect, 0); @@ -263,8 +263,8 @@ static VIDEO_UPDATE(luckgrln) clip.min_y = y*8; clip.max_y = y*8+8; - if (clip.min_ymin_y) clip.min_y = visarea->min_y; - if (clip.max_y>visarea->max_y) clip.max_y = visarea->max_y; + if (clip.min_yvisarea.max_y) clip.max_y = visarea.max_y; for (x=0;x<64;x++) { @@ -278,8 +278,8 @@ static VIDEO_UPDATE(luckgrln) clip.min_x = x*8; clip.max_x = x*8+8; - if (clip.min_xmin_x) clip.min_x = visarea->min_x; - if (clip.max_x>visarea->max_x) clip.max_x = visarea->max_x; + if (clip.min_xvisarea.max_x) clip.max_x = visarea.max_x; /* luck_vram1 tttt tttt (t = low tile bits) diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index ff2503b123b..bac5351cc17 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -131,7 +131,7 @@ Notes (couriersud) static WRITE8_DEVICE_HANDLER( ic8j1_output_changed ) { m10_state *state = (m10_state *)device->machine->driver_data; - LOG(("ic8j1: %d %d\n", data, video_screen_get_vpos(device->machine->primary_screen))); + LOG(("ic8j1: %d %d\n", data, device->machine->primary_screen->vpos())); cpu_set_input_line(state->maincpu, 0, !data ? CLEAR_LINE : ASSERT_LINE); } @@ -482,7 +482,7 @@ static WRITE8_HANDLER( m15_a100_w ) static READ8_HANDLER( m10_a700_r ) { m10_state *state = (m10_state *)space->machine->driver_data; - //LOG(("rd:%d\n",video_screen_get_vpos(space->machine->primary_screen))); + //LOG(("rd:%d\n",space->machine->primary_screen->vpos())); LOG(("clear\n")); ttl74123_clear_w(state->ic8j1, 0, 0); ttl74123_clear_w(state->ic8j1, 0, 1); @@ -492,7 +492,7 @@ static READ8_HANDLER( m10_a700_r ) static READ8_HANDLER( m11_a700_r ) { m10_state *state = (m10_state *)space->machine->driver_data; - //LOG(("rd:%d\n",video_screen_get_vpos(space->machine->primary_screen))); + //LOG(("rd:%d\n",space->machine->primary_screen->vpos())); //cpu_set_input_line(state->maincpu, 0, CLEAR_LINE); LOG(("clear\n")); ttl74123_clear_w(state->ic8j1, 0, 0); @@ -520,12 +520,12 @@ static TIMER_CALLBACK( interrupt_callback ) if (param == 0) { cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, IREMM10_VBSTART + 16, 0), NULL, 1, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(IREMM10_VBSTART + 16), NULL, 1, interrupt_callback); } if (param == 1) { cpu_set_input_line(state->maincpu, 0, ASSERT_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, IREMM10_VBSTART + 24, 0), NULL, 2, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(IREMM10_VBSTART + 24), NULL, 2, interrupt_callback); } if (param == -1) cpu_set_input_line(state->maincpu, 0, CLEAR_LINE); @@ -536,7 +536,7 @@ static TIMER_CALLBACK( interrupt_callback ) static INTERRUPT_GEN( m11_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - //timer_set(device->machine, video_screen_get_time_until_pos(machine->primary_screen, IREMM10_VBEND, 0), NULL, -1, interrupt_callback); + //timer_set(device->machine, machine->primary_screen->time_until_pos(IREMM10_VBEND), NULL, -1, interrupt_callback); } static INTERRUPT_GEN( m10_interrupt ) @@ -548,7 +548,7 @@ static INTERRUPT_GEN( m10_interrupt ) static INTERRUPT_GEN( m15_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, IREMM10_VBSTART + 1, 80), NULL, -1, interrupt_callback); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(IREMM10_VBSTART + 1, 80), NULL, -1, interrupt_callback); } /************************************* @@ -878,8 +878,7 @@ static MACHINE_DRIVER_START( m11 ) /* basic machine hardware */ MDRV_IMPORT_FROM(m10) - MDRV_CPU_REPLACE("maincpu", M6502,IREMM10_CPU_CLOCK) - //MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(m11_main) //MDRV_CPU_VBLANK_INT("screen", m11_interrupt) @@ -922,7 +921,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( headoni ) MDRV_IMPORT_FROM(m15) - MDRV_CPU_REPLACE("maincpu", M6502,11730000/16) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(11730000/16) MACHINE_DRIVER_END /************************************* diff --git a/src/mame/drivers/m107.c b/src/mame/drivers/m107.c index 127bfb533e3..88b2effd6ee 100644 --- a/src/mame/drivers/m107.c +++ b/src/mame/drivers/m107.c @@ -62,7 +62,7 @@ static MACHINE_START( m107 ) static MACHINE_RESET( m107 ) { - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } /*****************************************************************************/ @@ -74,21 +74,21 @@ static TIMER_CALLBACK( m107_scanline_interrupt ) /* raster interrupt */ if (scanline == m107_raster_irq_position) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M107_IRQ_2); } /* VBLANK interrupt */ - else if (scanline == video_screen_get_visible_area(machine->primary_screen)->max_y + 1) + else if (scanline == machine->primary_screen->visible_area().max_y + 1) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M107_IRQ_0); } /* adjust for next scanline */ - if (++scanline >= video_screen_get_height(machine->primary_screen)) + if (++scanline >= machine->primary_screen->height()) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -481,7 +481,8 @@ static MACHINE_DRIVER_START( dsoccr94 ) MDRV_IMPORT_FROM(firebarr) /* basic machine hardware */ - MDRV_CPU_REPLACE("maincpu", V33, 20000000/2) /* NEC V33, Could be 28MHz clock? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(20000000/2) /* NEC V33, Could be 28MHz clock? */ MDRV_CPU_MODIFY("soundcpu") MDRV_CPU_CONFIG(dsoccr94_config) diff --git a/src/mame/drivers/m62.c b/src/mame/drivers/m62.c index 450fe8d579a..5ae480610e1 100644 --- a/src/mame/drivers/m62.c +++ b/src/mame/drivers/m62.c @@ -992,7 +992,8 @@ static MACHINE_DRIVER_START( kungfum ) /* basic machine hardware */ MDRV_IMPORT_FROM(ldrun) - MDRV_CPU_REPLACE("maincpu", Z80, 18432000/6) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(18432000/6) MDRV_CPU_PROGRAM_MAP(kungfum_map) MDRV_CPU_IO_MAP(kungfum_io_map) @@ -1009,7 +1010,8 @@ static MACHINE_DRIVER_START( battroad ) /* basic machine hardware */ MDRV_IMPORT_FROM(ldrun) - MDRV_CPU_REPLACE("maincpu", Z80, 18432000/6) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(18432000/6) MDRV_CPU_PROGRAM_MAP(battroad_map) MDRV_CPU_IO_MAP(battroad_io_map) @@ -1137,7 +1139,8 @@ static MACHINE_DRIVER_START( youjyudn ) /* basic machine hardware */ MDRV_IMPORT_FROM(ldrun) - MDRV_CPU_REPLACE("maincpu", Z80, 18432000/6) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(18432000/6) MDRV_CPU_PROGRAM_MAP(youjyudn_map) MDRV_CPU_IO_MAP(youjyudn_io_map) diff --git a/src/mame/drivers/m72.c b/src/mame/drivers/m72.c index dac615f400a..857a0a49676 100644 --- a/src/mame/drivers/m72.c +++ b/src/mame/drivers/m72.c @@ -128,20 +128,20 @@ static MACHINE_RESET( m72 ) mcu_sample_addr = 0; mcu_snd_cmd_latch = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); timer_call_after_resynch(machine, NULL, 0, synch_callback); } static MACHINE_RESET( xmultipl ) { m72_irq_base = 0x08; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } static MACHINE_RESET( kengo ) { m72_irq_base = 0x18; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } static TIMER_CALLBACK( m72_scanline_interrupt ) @@ -151,21 +151,21 @@ static TIMER_CALLBACK( m72_scanline_interrupt ) /* raster interrupt - visible area only? */ if (scanline < 256 && scanline == m72_raster_irq_position - 128) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, m72_irq_base + 2); } /* VBLANK interrupt */ else if (scanline == 256) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, m72_irq_base + 0); } /* adjust for next scanline */ - if (++scanline >= video_screen_get_height(machine->primary_screen)) + if (++scanline >= machine->primary_screen->height()) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } /*************************************************************************** diff --git a/src/mame/drivers/m92.c b/src/mame/drivers/m92.c index 34ce0ab644e..2d8684a268d 100644 --- a/src/mame/drivers/m92.c +++ b/src/mame/drivers/m92.c @@ -242,7 +242,7 @@ static MACHINE_START( m92 ) static MACHINE_RESET( m92 ) { - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } /*****************************************************************************/ @@ -254,21 +254,21 @@ static TIMER_CALLBACK( m92_scanline_interrupt ) /* raster interrupt */ if (scanline == m92_raster_irq_position) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M92_IRQ_2); } /* VBLANK interrupt */ - else if (scanline == video_screen_get_visible_area(machine->primary_screen)->max_y + 1) + else if (scanline == machine->primary_screen->visible_area().max_y + 1) { - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, M92_IRQ_0); } /* adjust for next scanline */ - if (++scanline >= video_screen_get_height(machine->primary_screen)) + if (++scanline >= machine->primary_screen->height()) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } /*****************************************************************************/ @@ -1041,8 +1041,7 @@ static MACHINE_DRIVER_START( ppan ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/madmotor.c b/src/mame/drivers/madmotor.c index b551bddb9ec..0298f89aad8 100644 --- a/src/mame/drivers/madmotor.c +++ b/src/mame/drivers/madmotor.c @@ -283,12 +283,10 @@ static MACHINE_DRIVER_START( madmotor ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki1", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, 2047848) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2047848, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_DRIVER_END diff --git a/src/mame/drivers/magic10.c b/src/mame/drivers/magic10.c index 1c8ea27284a..e326507cd78 100644 --- a/src/mame/drivers/magic10.c +++ b/src/mame/drivers/magic10.c @@ -668,8 +668,7 @@ static MACHINE_DRIVER_START( magic10 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/magicard.c b/src/mame/drivers/magicard.c index 2f6fcdddf4d..4aa69449e07 100644 --- a/src/mame/drivers/magicard.c +++ b/src/mame/drivers/magicard.c @@ -383,22 +383,22 @@ static VIDEO_UPDATE(magicard) color = ((magicram[count]) & 0x000f)>>0; - if(((x*4)+3)max_x && ((y)+0)max_y) + if(((x*4)+3)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*4)+3) = screen->machine->pens[color]; color = ((magicram[count]) & 0x00f0)>>4; - if(((x*4)+2)max_x && ((y)+0)max_y) + if(((x*4)+2)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*4)+2) = screen->machine->pens[color]; color = ((magicram[count]) & 0x0f00)>>8; - if(((x*4)+1)max_x && ((y)+0)max_y) + if(((x*4)+1)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*4)+1) = screen->machine->pens[color]; color = ((magicram[count]) & 0xf000)>>12; - if(((x*4)+0)max_x && ((y)+0)max_y) + if(((x*4)+0)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*4)+0) = screen->machine->pens[color]; count++; @@ -415,12 +415,12 @@ static VIDEO_UPDATE(magicard) color = ((magicram[count]) & 0x00ff)>>0; - if(((x*2)+1)max_x && ((y)+0)max_y) + if(((x*2)+1)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color]; color = ((magicram[count]) & 0xff00)>>8; - if(((x*2)+0)max_x && ((y)+0)max_y) + if(((x*2)+0)visible_area().max_x && ((y)+0)visible_area().max_y) *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color]; count++; diff --git a/src/mame/drivers/magmax.c b/src/mame/drivers/magmax.c index 10928c4e966..b4be2c58ab3 100644 --- a/src/mame/drivers/magmax.c +++ b/src/mame/drivers/magmax.c @@ -84,7 +84,7 @@ static TIMER_CALLBACK( scanline_callback ) scanline += 128; scanline &= 255; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } static MACHINE_START( magmax ) @@ -101,7 +101,7 @@ static MACHINE_START( magmax ) static MACHINE_RESET( magmax ) { - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(64), 64); #if 0 { diff --git a/src/mame/drivers/malzak.c b/src/mame/drivers/malzak.c index d24531b2526..0e25b847b37 100644 --- a/src/mame/drivers/malzak.c +++ b/src/mame/drivers/malzak.c @@ -73,7 +73,7 @@ static READ8_HANDLER( fake_VRLE_r ) { malzak_state *state = (malzak_state *)space->machine->driver_data; - return (s2636_work_ram_r(state->s2636_0, 0xcb) & 0x3f) + (video_screen_get_vblank(space->machine->primary_screen) * 0x40); + return (s2636_work_ram_r(state->s2636_0, 0xcb) & 0x3f) + (space->machine->primary_screen->vblank() * 0x40); } static READ8_HANDLER( s2636_portA_r ) diff --git a/src/mame/drivers/marinedt.c b/src/mame/drivers/marinedt.c index b3c28d948e1..60b7a5fe89c 100644 --- a/src/mame/drivers/marinedt.c +++ b/src/mame/drivers/marinedt.c @@ -283,7 +283,7 @@ static WRITE8_HANDLER( marinedt_pf_w ) //if (data & 0xf0) // logerror("pf:%02x %d\n", state->pf); - //logerror("pd:%02x %d\n", state->pd, video_screen_get_frame_number(space->machine->primary_screen)); + //logerror("pd:%02x %d\n", state->pd, space->machine->primary_screen->frame_number()); } @@ -474,9 +474,9 @@ static VIDEO_START( marinedt ) tilemap_set_scrolldx(state->tx_tilemap, 0, 4*8); tilemap_set_scrolldy(state->tx_tilemap, 0, -4*8); - state->tile = auto_bitmap_alloc(machine, 32 * 8, 32 * 8, video_screen_get_format(machine->primary_screen)); - state->obj1 = auto_bitmap_alloc(machine, 32, 32, video_screen_get_format(machine->primary_screen)); - state->obj2 = auto_bitmap_alloc(machine, 32, 32, video_screen_get_format(machine->primary_screen)); + state->tile = auto_bitmap_alloc(machine, 32 * 8, 32 * 8, machine->primary_screen->format()); + state->obj1 = auto_bitmap_alloc(machine, 32, 32, machine->primary_screen->format()); + state->obj2 = auto_bitmap_alloc(machine, 32, 32, machine->primary_screen->format()); } diff --git a/src/mame/drivers/mario.c b/src/mame/drivers/mario.c index 0f89ac36a33..38fc2fbbcf5 100644 --- a/src/mame/drivers/mario.c +++ b/src/mame/drivers/mario.c @@ -356,10 +356,9 @@ static MACHINE_DRIVER_START( masao ) /* basic machine hardware */ MDRV_IMPORT_FROM(mario_base ) - MDRV_CPU_REPLACE("maincpu", Z80, 4000000) /* 4.000 MHz (?) */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(4000000) /* 4.000 MHz (?) */ MDRV_CPU_PROGRAM_MAP(masao_map) - MDRV_CPU_IO_MAP(mario_io_map) - MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse) /* sound hardware */ MDRV_IMPORT_FROM(masao_audio) diff --git a/src/mame/drivers/maxaflex.c b/src/mame/drivers/maxaflex.c index e3f5ec77d72..16cf0727e9a 100644 --- a/src/mame/drivers/maxaflex.c +++ b/src/mame/drivers/maxaflex.c @@ -31,7 +31,7 @@ static UINT8 portA_in,portA_out,ddrA; static UINT8 portB_in,portB_out,ddrB; static UINT8 portC_in,portC_out,ddrC; static UINT8 tdr,tcr; -static running_device *mcu_timer; +static timer_device *mcu_timer; /* Port A: 0 (in) DSW @@ -154,7 +154,7 @@ static TIMER_DEVICE_CALLBACK( mcu_timer_proc ) if ( (tcr & 0x40) == 0 ) { //timer interrupt! - generic_pulse_irq_line(devtag_get_device(timer->machine, "mcu"), M68705_INT_TIMER); + generic_pulse_irq_line(devtag_get_device(timer.machine, "mcu"), M68705_INT_TIMER); } } } @@ -202,7 +202,7 @@ static WRITE8_HANDLER( mcu_tcr_w ) } period = attotime_mul(ATTOTIME_IN_HZ(3579545), divider); - timer_device_adjust_periodic( mcu_timer, period, 0, period); + mcu_timer->adjust(period, 0, period); } } @@ -212,7 +212,7 @@ static MACHINE_RESET(supervisor_board) portB_in = portB_out = ddrB = 0; portC_in = portC_out = ddrC = 0; tdr = tcr = 0; - mcu_timer = devtag_get_device(machine, "mcu_timer"); + mcu_timer = machine->device("mcu_timer"); output_set_lamp_value(0, 0); output_set_lamp_value(1, 0); diff --git a/src/mame/drivers/mazerbla.c b/src/mame/drivers/mazerbla.c index 59a3aa24f3c..94d8cb6922a 100644 --- a/src/mame/drivers/mazerbla.c +++ b/src/mame/drivers/mazerbla.c @@ -131,10 +131,10 @@ static PALETTE_INIT( mazerbla ) static VIDEO_START( mazerbla ) { mazerbla_state *state = (mazerbla_state *)machine->driver_data; - state->tmpbitmaps[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmpbitmaps[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmpbitmaps[2] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmpbitmaps[3] = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmpbitmaps[0] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmpbitmaps[1] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmpbitmaps[2] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmpbitmaps[3] = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->tmpbitmaps[0]); state_save_register_global_bitmap(machine, state->tmpbitmaps[1]); diff --git a/src/mame/drivers/mcr3.c b/src/mame/drivers/mcr3.c index 8d82002a6ee..042a32cdad9 100644 --- a/src/mame/drivers/mcr3.c +++ b/src/mame/drivers/mcr3.c @@ -448,7 +448,7 @@ static READ8_HANDLER( turbotag_ip2_r ) if (input_mux) return input_port_read(space->machine, "SSIO.IP2.ALT"); - return input_port_read(space->machine, "SSIO.IP2") + 5 * (video_screen_get_frame_number(space->machine->primary_screen) & 1); + return input_port_read(space->machine, "SSIO.IP2") + 5 * (space->machine->primary_screen->frame_number() & 1); } diff --git a/src/mame/drivers/meadows.c b/src/mame/drivers/meadows.c index 2bfc73ea9bd..5b2dadf107f 100644 --- a/src/mame/drivers/meadows.c +++ b/src/mame/drivers/meadows.c @@ -148,21 +148,21 @@ static UINT8 audio_sense_state; static READ8_HANDLER( hsync_chain_r ) { - UINT8 val = video_screen_get_hpos(space->machine->primary_screen); + UINT8 val = space->machine->primary_screen->hpos(); return BITSWAP8(val,0,1,2,3,4,5,6,7); } static READ8_HANDLER( vsync_chain_hi_r ) { - UINT8 val = video_screen_get_vpos(space->machine->primary_screen); + UINT8 val = space->machine->primary_screen->vpos(); return ((val >> 1) & 0x08) | ((val >> 3) & 0x04) | ((val >> 5) & 0x02) | (val >> 7); } static READ8_HANDLER( vsync_chain_lo_r ) { - UINT8 val = video_screen_get_vpos(space->machine->primary_screen); + UINT8 val = space->machine->primary_screen->vpos(); return val & 0x0f; } diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c index b1e53de3cc7..b00921fa695 100644 --- a/src/mame/drivers/mediagx.c +++ b/src/mame/drivers/mediagx.c @@ -117,14 +117,14 @@ static UINT8 ad1847_regs[16]; static UINT32 ad1847_sample_counter = 0; static UINT32 ad1847_sample_rate; -static running_device *dmadac[2]; +static dmadac_sound_device *dmadac[2]; static struct { - running_device *pit8254; - running_device *pic8259_1; - running_device *pic8259_2; - running_device *dma8237_1; - running_device *dma8237_2; + pit8254_device *pit8254; + pic8259_device *pic8259_1; + pic8259_device *pic8259_2; + i8237_device *dma8237_1; + i8237_device *dma8237_2; } mediagx_devices; @@ -231,7 +231,7 @@ static void draw_framebuffer(running_machine *machine, bitmap_t *bitmap, const r visarea.min_x = visarea.min_y = 0; visarea.max_x = width - 1; visarea.max_y = height - 1; - video_screen_configure(machine->primary_screen, width, height * 262 / 240, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds); + machine->primary_screen->configure(width, height * 262 / 240, visarea, machine->primary_screen->frame_period().attoseconds); } if (disp_ctrl_reg[DC_OUTPUT_CFG] & 0x1) // 8-bit mode @@ -341,7 +341,7 @@ static READ32_HANDLER( disp_ctrl_r ) case DC_TIMING_CFG: r |= 0x40000000; - if (video_screen_get_vpos(space->machine->primary_screen) >= frame_height) + if (space->machine->primary_screen->vpos() >= frame_height) r &= ~0x40000000; #if SPEEDUP_HACKS @@ -637,7 +637,7 @@ static void cx5510_pci_w(running_device *busdevice, running_device *device, int static TIMER_DEVICE_CALLBACK( sound_timer_callback ) { ad1847_sample_counter = 0; - timer_device_adjust_oneshot(timer, ATTOTIME_IN_MSEC(10), 0); + timer.adjust(ATTOTIME_IN_MSEC(10)); dmadac_transfer(&dmadac[0], 1, 0, 1, dacl_ptr, dacl); dmadac_transfer(&dmadac[1], 1, 0, 1, dacr_ptr, dacr); @@ -959,11 +959,11 @@ static IRQ_CALLBACK(irq_callback) static MACHINE_START(mediagx) { - mediagx_devices.pit8254 = devtag_get_device( machine, "pit8254" ); - mediagx_devices.pic8259_1 = devtag_get_device( machine, "pic8259_master" ); - mediagx_devices.pic8259_2 = devtag_get_device( machine, "pic8259_slave" ); - mediagx_devices.dma8237_1 = devtag_get_device( machine, "dma8237_1" ); - mediagx_devices.dma8237_2 = devtag_get_device( machine, "dma8237_2" ); + mediagx_devices.pit8254 = machine->device( "pit8254" ); + mediagx_devices.pic8259_1 = machine->device( "pic8259_master" ); + mediagx_devices.pic8259_2 = machine->device( "pic8259_slave" ); + mediagx_devices.dma8237_1 = machine->device( "dma8237_1" ); + mediagx_devices.dma8237_2 = machine->device( "dma8237_2" ); dacl = auto_alloc_array(machine, INT16, 65536); dacr = auto_alloc_array(machine, INT16, 65536); @@ -978,10 +978,11 @@ static MACHINE_RESET(mediagx) memcpy(bios_ram, rom, 0x40000); machine->device("maincpu")->reset(); - timer_device_adjust_oneshot(devtag_get_device(machine, "sound_timer"), ATTOTIME_IN_MSEC(10), 0); + timer_device *sound_timer = machine->device("sound_timer"); + sound_timer->adjust(ATTOTIME_IN_MSEC(10)); - dmadac[0] = devtag_get_device(machine, "dac1"); - dmadac[1] = devtag_get_device(machine, "dac2"); + dmadac[0] = machine->device("dac1"); + dmadac[1] = machine->device("dac2"); dmadac_enable(&dmadac[0], 2, 1); devtag_reset(machine, "ide"); } diff --git a/src/mame/drivers/megadriv.c b/src/mame/drivers/megadriv.c index 63886e83ef1..27ada961b0f 100644 --- a/src/mame/drivers/megadriv.c +++ b/src/mame/drivers/megadriv.c @@ -95,8 +95,8 @@ static int megadrive_irq6_pending = 0; static int megadrive_irq4_pending = 0; /* 32x! */ -static running_device *_32x_master_cpu; -static running_device *_32x_slave_cpu; +static cpu_device *_32x_master_cpu; +static cpu_device *_32x_slave_cpu; static int _32x_is_connected; static int sh2_are_running; @@ -129,12 +129,12 @@ static UINT16 *_32x_display_dram, *_32x_access_dram; static UINT16* _32x_palette; static UINT16* _32x_palette_lookup; /* SegaCD! */ -static running_device *_segacd_68k_cpu; +static cpu_device *_segacd_68k_cpu; /* SVP (virtua racing) */ -static running_device *_svp_cpu; +static cpu_device *_svp_cpu; -static running_device *_genesis_snd_z80_cpu; +static cpu_device *_genesis_snd_z80_cpu; int segac2_bg_pal_lookup[4]; int segac2_sp_pal_lookup[4]; @@ -163,10 +163,10 @@ static int megadrive_region_pal; static int megadrive_max_hposition; -static running_device* frame_timer; -static running_device* scanline_timer; -static running_device* irq6_on_timer; -static running_device* irq4_on_timer; +static timer_device* frame_timer; +static timer_device* scanline_timer; +static timer_device* irq6_on_timer; +static timer_device* irq4_on_timer; static bitmap_t* render_bitmap; //emu_timer* vblankirq_off_timer; @@ -3907,7 +3907,7 @@ VIDEO_START(megadriv) { int x; - render_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + render_bitmap = machine->primary_screen->alloc_compatible_bitmap(); megadrive_vdp_vram = auto_alloc_array(machine, UINT16, 0x10000/2); megadrive_vdp_cram = auto_alloc_array(machine, UINT16, 0x80/2); @@ -3963,7 +3963,7 @@ VIDEO_UPDATE(megadriv) // int xxx; /* reference */ -// time_elapsed_since_crap = timer_device_timeelapsed(frame_timer); +// time_elapsed_since_crap = frame_timer->time_elapsed(); // xxx = cputag_attotime_to_clocks(screen->machine, "maincpu", time_elapsed_since_crap); // mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff)); @@ -5508,7 +5508,7 @@ INLINE UINT16 get_hposition(void) attotime time_elapsed_since_scanline_timer; UINT16 value4; - time_elapsed_since_scanline_timer = timer_device_timeelapsed(scanline_timer); + time_elapsed_since_scanline_timer = scanline_timer->time_elapsed(); if (time_elapsed_since_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)) { @@ -5796,13 +5796,13 @@ INLINE UINT16 get_hposition(void) static int irq4counter; -static running_device* render_timer; +static timer_device* render_timer; static TIMER_DEVICE_CALLBACK( render_timer_callback ) { if (genesis_scanline_counter>=0 && genesis_scanline_countermachine, genesis_scanline_counter); + genesis_render_scanline(timer.machine, genesis_scanline_counter); } } @@ -5813,7 +5813,7 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) top-left of the screen. The first scanline is scanline 0 (we set scanline to -1 in VIDEO_EOF) */ - timer_call_after_resynch(timer->machine, NULL, 0, 0); + timer_call_after_resynch(timer.machine, NULL, 0, 0); /* Compensate for some rounding errors When the counter reaches 261 we should have reached the end of the frame, however due @@ -5825,13 +5825,13 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { genesis_scanline_counter++; // mame_printf_debug("scanline %d\n",genesis_scanline_counter); - timer_device_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0); - timer_device_adjust_oneshot(render_timer, ATTOTIME_IN_USEC(1), 0); + scanline_timer->adjust(attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines)); + render_timer->adjust(ATTOTIME_IN_USEC(1)); if (genesis_scanline_counter==megadrive_irq6_scanline ) { // mame_printf_debug("x %d",genesis_scanline_counter); - timer_device_adjust_oneshot(irq6_on_timer, ATTOTIME_IN_USEC(6), 0); + irq6_on_timer->adjust(ATTOTIME_IN_USEC(6)); megadrive_irq6_pending = 1; megadrive_vblank_flag = 1; @@ -5868,7 +5868,7 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) if (MEGADRIVE_REG0_IRQ4_ENABLE) { - timer_device_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(1), 0); + irq4_on_timer->adjust(ATTOTIME_IN_USEC(1)); //mame_printf_debug("irq4 on scanline %d reload %d\n",genesis_scanline_counter,MEGADRIVE_REG0A_HINT_VALUE); } } @@ -5879,21 +5879,21 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) else irq4counter=MEGADRIVE_REG0A_HINT_VALUE; } - //if (genesis_scanline_counter==0) timer_device_adjust_oneshot(irq4_on_timer, ATTOTIME_IN_USEC(2), 0); + //if (genesis_scanline_counter==0) irq4_on_timer->adjust(ATTOTIME_IN_USEC(2)); - if (devtag_get_device(timer->machine, "genesis_snd_z80") != NULL) + if (devtag_get_device(timer.machine, "genesis_snd_z80") != NULL) { if (genesis_scanline_counter == megadrive_z80irq_scanline) { if ((genz80.z80_has_bus == 1) && (genz80.z80_is_reset == 0)) - cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, HOLD_LINE); + cputag_set_input_line(timer.machine, "genesis_snd_z80", 0, HOLD_LINE); } if (genesis_scanline_counter == megadrive_z80irq_scanline + 1) { - cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, CLEAR_LINE); + cputag_set_input_line(timer.machine, "genesis_snd_z80", 0, CLEAR_LINE); } } @@ -5912,14 +5912,14 @@ static TIMER_DEVICE_CALLBACK( irq6_on_callback ) { // megadrive_irq6_pending = 1; if (MEGADRIVE_REG01_IRQ6_ENABLE || genesis_always_irq6) - cputag_set_input_line(timer->machine, "maincpu", 6, HOLD_LINE); + cputag_set_input_line(timer.machine, "maincpu", 6, HOLD_LINE); } } static TIMER_DEVICE_CALLBACK( irq4_on_callback ) { //mame_printf_debug("irq4 active on %d\n",genesis_scanline_counter); - cputag_set_input_line(timer->machine, "maincpu", 4, HOLD_LINE); + cputag_set_input_line(timer.machine, "maincpu", 4, HOLD_LINE); } /*****************************************************************************************/ @@ -5985,15 +5985,15 @@ MACHINE_RESET( megadriv ) megadrive_reset_io(machine); - frame_timer = devtag_get_device(machine, "frame_timer"); - scanline_timer = devtag_get_device(machine, "scanline_timer"); - render_timer = devtag_get_device(machine, "render_timer"); + frame_timer = machine->device("frame_timer"); + scanline_timer = machine->device("scanline_timer"); + render_timer = machine->device("render_timer"); - irq6_on_timer = devtag_get_device(machine, "irq6_timer"); - irq4_on_timer = devtag_get_device(machine, "irq4_timer"); + irq6_on_timer = machine->device("irq6_timer"); + irq4_on_timer = machine->device("irq4_timer"); - timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); - timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); + frame_timer->reset(); + scanline_timer->reset(); if (genesis_other_hacks) { @@ -6032,7 +6032,7 @@ MACHINE_RESET( megadriv ) void megadriv_stop_scanline_timer(void) { - timer_device_adjust_oneshot(scanline_timer, attotime_never, 0); + scanline_timer->reset(); } /* @@ -6134,7 +6134,7 @@ int megadrive_z80irq_hpos = 320; visarea.min_y = 0; visarea.max_y = megadrive_visible_scanlines-1; - video_screen_configure(machine->primary_screen, scr_width, megadrive_visible_scanlines, &visarea, HZ_TO_ATTOSECONDS(megadriv_framerate)); + machine->primary_screen->configure(scr_width, megadrive_visible_scanlines, visarea, HZ_TO_ATTOSECONDS(megadriv_framerate)); if (0) { @@ -6144,14 +6144,14 @@ int megadrive_z80irq_hpos = 320; // /* reference */ frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate; - //time_elapsed_since_crap = timer_device_timeelapsed(frame_timer); + //time_elapsed_since_crap = frame_timer->time_elapsed(); //xxx = cputag_attotime_to_clocks(machine, "maincpu",time_elapsed_since_crap); //mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff)); //mame_printf_debug("---------- framet %d, %08x %08x\n",xxx, (UINT32)(frametime>>32),(UINT32)(frametime&0xffffffff)); - timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); + frame_timer->reset(); } - timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); + scanline_timer->reset(); } @@ -6365,7 +6365,7 @@ static void megadriv_init_common(running_machine *machine) const input_port_token *ipt = machine->gamedrv->ipt; /* Look to see if this system has the standard Sound Z80 */ - _genesis_snd_z80_cpu = devtag_get_device(machine, "genesis_snd_z80"); + _genesis_snd_z80_cpu = machine->device("genesis_snd_z80"); if (_genesis_snd_z80_cpu != NULL) { //printf("GENESIS Sound Z80 cpu found %d\n", cpu_get_index(_genesis_snd_z80_cpu) ); @@ -6375,14 +6375,14 @@ static void megadriv_init_common(running_machine *machine) } /* Look to see if this system has the 32x Master SH2 */ - _32x_master_cpu = devtag_get_device(machine, "32x_master_sh2"); + _32x_master_cpu = machine->device("32x_master_sh2"); if (_32x_master_cpu != NULL) { printf("32x MASTER SH2 cpu found %d\n", cpu_get_index(_32x_master_cpu) ); } /* Look to see if this system has the 32x Slave SH2 */ - _32x_slave_cpu = devtag_get_device(machine, "32x_slave_sh2"); + _32x_slave_cpu = machine->device("32x_slave_sh2"); if (_32x_slave_cpu != NULL) { printf("32x SLAVE SH2 cpu found %d\n", cpu_get_index(_32x_slave_cpu) ); @@ -6397,13 +6397,13 @@ static void megadriv_init_common(running_machine *machine) _32x_is_connected = 0; } - _segacd_68k_cpu = devtag_get_device(machine, "segacd_68k"); + _segacd_68k_cpu = machine->device("segacd_68k"); if (_segacd_68k_cpu != NULL) { printf("Sega CD secondary 68k cpu found %d\n", cpu_get_index(_segacd_68k_cpu) ); } - _svp_cpu = devtag_get_device(machine, "svp"); + _svp_cpu = machine->device("svp"); if (_svp_cpu != NULL) { printf("SVP (cpu) found %d\n", cpu_get_index(_svp_cpu) ); diff --git a/src/mame/drivers/megasys1.c b/src/mame/drivers/megasys1.c index 953e425f8bc..7bc27c13d0a 100644 --- a/src/mame/drivers/megasys1.c +++ b/src/mame/drivers/megasys1.c @@ -1492,13 +1492,11 @@ static MACHINE_DRIVER_START( system_A ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, OKI4_SOUND_CLOCK) /* 4MHz verified */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", OKI4_SOUND_CLOCK, OKIM6295_PIN7_HIGH) /* 4MHz verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MDRV_SOUND_ADD("oki2", OKIM6295, OKI4_SOUND_CLOCK) /* 4MHz verified */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", OKI4_SOUND_CLOCK, OKIM6295_PIN7_HIGH) /* 4MHz verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) MACHINE_DRIVER_END @@ -1513,8 +1511,8 @@ static MACHINE_DRIVER_START( system_B ) /* basic machine hardware */ MDRV_IMPORT_FROM(system_A) - MDRV_CPU_REPLACE("maincpu", M68000, SYS_B_CPU_CLOCK) /* 8MHz */ MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(SYS_B_CPU_CLOCK) /* 8MHz */ MDRV_CPU_PROGRAM_MAP(megasys1B_map) MDRV_CPU_VBLANK_INT_HACK(interrupt_B,INTERRUPT_NUM_B) @@ -1552,8 +1550,7 @@ static MACHINE_DRIVER_START( system_Bbl ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") /* just the one OKI, used for sound and music */ - MDRV_SOUND_ADD("oki1", OKIM6295, OKI4_SOUND_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", OKI4_SOUND_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) MACHINE_DRIVER_END @@ -1563,13 +1560,11 @@ static MACHINE_DRIVER_START( system_B_hayaosi1 ) /* basic machine hardware */ MDRV_IMPORT_FROM(system_B) - MDRV_SOUND_REPLACE("oki1",OKIM6295, 2000000) /* correct speed, but unknown OSC + divider combo */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_REPLACE("oki1", 2000000, OKIM6295_PIN7_HIGH) /* correct speed, but unknown OSC + divider combo */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MDRV_SOUND_REPLACE("oki2",OKIM6295, 2000000) /* correct speed, but unknown OSC + divider combo */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_REPLACE("oki2", 2000000, OKIM6295_PIN7_HIGH) /* correct speed, but unknown OSC + divider combo */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) MACHINE_DRIVER_END @@ -1579,8 +1574,8 @@ static MACHINE_DRIVER_START( system_C ) /* basic machine hardware */ MDRV_IMPORT_FROM(system_A) - MDRV_CPU_REPLACE("maincpu", M68000, SYS_C_CPU_CLOCK) /* 12MHz */ MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(SYS_C_CPU_CLOCK) /* 12MHz */ MDRV_CPU_PROGRAM_MAP(megasys1C_map) MDRV_CPU_VBLANK_INT_HACK(interrupt_C,INTERRUPT_NUM_C) @@ -1628,8 +1623,7 @@ static MACHINE_DRIVER_START( system_D ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1",OKIM6295, SYS_D_CPU_CLOCK/4) /* 2MHz (8MHz / 4) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", SYS_D_CPU_CLOCK/4, OKIM6295_PIN7_HIGH) /* 2MHz (8MHz / 4) */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/merit.c b/src/mame/drivers/merit.c index 75c75539271..9f56eb5f0b1 100644 --- a/src/mame/drivers/merit.c +++ b/src/mame/drivers/merit.c @@ -164,7 +164,7 @@ static WRITE8_HANDLER( palette_w ) { int co; - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); data &= 0x0f; co = ((ram_attr[offset] & 0x7F) << 3) | (offset & 0x07); @@ -243,7 +243,7 @@ static MC6845_UPDATE_ROW( update_row ) static WRITE_LINE_DEVICE_HANDLER(hsync_changed) { /* update any video up to the current scanline */ - video_screen_update_now(device->machine->primary_screen); + device->machine->primary_screen->update_now(); } static WRITE_LINE_DEVICE_HANDLER(vsync_changed) diff --git a/src/mame/drivers/meritm.c b/src/mame/drivers/meritm.c index 85ef1f0d667..da467b353b2 100644 --- a/src/mame/drivers/meritm.c +++ b/src/mame/drivers/meritm.c @@ -333,12 +333,12 @@ static VIDEO_START( meritm ) { layer0_enabled = layer1_enabled = 1; - vdp0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - v9938_init (machine, 0, machine->primary_screen, vdp0_bitmap, MODEL_V9938, 0x20000, meritm_vdp0_interrupt); + vdp0_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + v9938_init (machine, 0, *machine->primary_screen, vdp0_bitmap, MODEL_V9938, 0x20000, meritm_vdp0_interrupt); v9938_reset(0); - vdp1_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - v9938_init (machine, 1, machine->primary_screen, vdp1_bitmap, MODEL_V9938, 0x20000, meritm_vdp1_interrupt); + vdp1_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + v9938_init (machine, 1, *machine->primary_screen, vdp1_bitmap, MODEL_V9938, 0x20000, meritm_vdp1_interrupt); v9938_reset(1); state_save_register_global(machine, meritm_vint); @@ -954,7 +954,7 @@ static Z80PIO_INTERFACE( meritm_io_pio_intf ) DEVCB_NULL }; -static const z80_daisy_chain meritm_daisy_chain[] = +static const z80_daisy_config meritm_daisy_chain[] = { { "z80pio_0" }, { "z80pio_1" }, diff --git a/src/mame/drivers/metro.c b/src/mame/drivers/metro.c index f64ff33bac5..a288646b904 100644 --- a/src/mame/drivers/metro.c +++ b/src/mame/drivers/metro.c @@ -1274,7 +1274,7 @@ static void gakusai_oki_bank_set(running_device *device) { metro_state *state = (metro_state *)device->machine->driver_data; int bank = (state->gakusai_oki_bank_lo & 7) + (state->gakusai_oki_bank_hi & 1) * 8; - okim6295_set_bank_base(device, bank * 0x40000); + downcast(device)->set_bank_base(bank * 0x40000); } static WRITE16_DEVICE_HANDLER( gakusai_oki_bank_hi_w ) @@ -1772,7 +1772,7 @@ static WRITE16_DEVICE_HANDLER( mouja_sound_rombank_w ) metro_state *state = (metro_state *)device->machine->driver_data; if (ACCESSING_BITS_0_7) - okim6295_set_bank_base(state->oki, ((data >> 3) & 0x07) * 0x40000); + state->oki->set_bank_base(((data >> 3) & 0x07) * 0x40000); } static ADDRESS_MAP_START( mouja_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -3579,12 +3579,6 @@ static MACHINE_START( metro ) { metro_state *state = (metro_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->oki = devtag_get_device(machine, "oki"); - state->ymsnd = devtag_get_device(machine, "ymsnd"); - state->k053936 = devtag_get_device(machine, "k053936"); - state_save_register_global(machine, state->blitter_bit); state_save_register_global(machine, state->irq_line); state_save_register_global_array(machine, state->requested_int); @@ -3839,8 +3833,7 @@ static MACHINE_DRIVER_START( daitorid ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END @@ -3881,8 +3874,7 @@ static MACHINE_DRIVER_START( dharma ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -3927,8 +3919,7 @@ static MACHINE_DRIVER_START( karatour ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -3973,8 +3964,7 @@ static MACHINE_DRIVER_START( 3kokushi ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4019,8 +4009,7 @@ static MACHINE_DRIVER_START( lastfort ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4064,8 +4053,7 @@ static MACHINE_DRIVER_START( lastforg ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4104,8 +4092,7 @@ static MACHINE_DRIVER_START( dokyusei ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) @@ -4145,8 +4132,7 @@ static MACHINE_DRIVER_START( dokyusp ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) @@ -4187,8 +4173,7 @@ static MACHINE_DRIVER_START( gakusai ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) @@ -4229,8 +4214,7 @@ static MACHINE_DRIVER_START( gakusai2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) @@ -4275,8 +4259,7 @@ static MACHINE_DRIVER_START( pangpoms ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4321,8 +4304,7 @@ static MACHINE_DRIVER_START( poitto ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4373,8 +4355,7 @@ static MACHINE_DRIVER_START( pururun ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END @@ -4415,8 +4396,7 @@ static MACHINE_DRIVER_START( skyalert ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4461,8 +4441,7 @@ static MACHINE_DRIVER_START( toride2g ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1200000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // was /128.. so pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1200000, OKIM6295_PIN7_HIGH) // was /128.. so pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.10) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.10) @@ -4501,8 +4480,7 @@ static MACHINE_DRIVER_START( mouja ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 16000000/1024*132) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 16000000/1024*132, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) @@ -4677,8 +4655,7 @@ static MACHINE_DRIVER_START( puzzlet ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_20MHz/5) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", XTAL_20MHz/5, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) diff --git a/src/mame/drivers/mgolf.c b/src/mame/drivers/mgolf.c index 1f782a5e603..53a424fec21 100644 --- a/src/mame/drivers/mgolf.c +++ b/src/mame/drivers/mgolf.c @@ -120,7 +120,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 262) scanline = 16; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); } @@ -313,7 +313,7 @@ static MACHINE_START( mgolf ) static MACHINE_RESET( mgolf ) { mgolf_state *state = (mgolf_state *)machine->driver_data; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(16), NULL, 16, interrupt_callback); state->mask = 0; state->prev = 0; diff --git a/src/mame/drivers/midvunit.c b/src/mame/drivers/midvunit.c index 16f5c2caa3c..6c67f9c1d10 100644 --- a/src/mame/drivers/midvunit.c +++ b/src/mame/drivers/midvunit.c @@ -41,7 +41,7 @@ static UINT8 adc_shift; static UINT16 last_port0; static UINT8 shifter_state; -static running_device *timer[2]; +static timer_device *timer[2]; static double timer_rate; static UINT32 *tms32031_control; @@ -76,8 +76,8 @@ static MACHINE_RESET( midvunit ) memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4); machine->device("maincpu")->reset(); - timer[0] = devtag_get_device(machine, "timer0"); - timer[1] = devtag_get_device(machine, "timer1"); + timer[0] = machine->device("timer0"); + timer[1] = machine->device("timer1"); } @@ -89,8 +89,8 @@ static MACHINE_RESET( midvplus ) memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4); machine->device("maincpu")->reset(); - timer[0] = devtag_get_device(machine, "timer0"); - timer[1] = devtag_get_device(machine, "timer1"); + timer[0] = machine->device("timer0"); + timer[1] = machine->device("timer1"); devtag_reset(machine, "ide"); } @@ -261,7 +261,7 @@ static READ32_HANDLER( tms32031_control_r ) { /* timer is clocked at 100ns */ int which = (offset >> 4) & 1; - INT32 result = attotime_to_double(attotime_mul(timer_device_timeelapsed(timer[which]), timer_rate)); + INT32 result = attotime_to_double(attotime_mul(timer[which]->time_elapsed(), timer_rate)); // logerror("%06X:tms32031_control_r(%02X) = %08X\n", cpu_get_pc(space->cpu), offset, result); return result; } @@ -288,7 +288,7 @@ static WRITE32_HANDLER( tms32031_control_w ) int which = (offset >> 4) & 1; // logerror("%06X:tms32031_control_w(%02X) = %08X\n", cpu_get_pc(space->cpu), offset, data); if (data & 0x40) - timer_device_adjust_oneshot(timer[which], attotime_never, 0); + timer[which]->reset(); /* bit 0x200 selects internal clocking, which is 1/2 the main CPU clock rate */ if (data & 0x200) diff --git a/src/mame/drivers/midyunit.c b/src/mame/drivers/midyunit.c index 8e33a10d5f6..085f22d93be 100644 --- a/src/mame/drivers/midyunit.c +++ b/src/mame/drivers/midyunit.c @@ -140,7 +140,7 @@ Notes: static WRITE8_DEVICE_HANDLER( yawdim_oki_bank_w ) { if (data & 4) - okim6295_set_bank_base(device, 0x40000 * (data & 3)); + downcast(device)->set_bank_base(0x40000 * (data & 3)); } @@ -1086,7 +1086,8 @@ static MACHINE_DRIVER_START( yunit_cvsd_4bit_fast ) /* basic machine hardware */ MDRV_IMPORT_FROM(yunit_core) - MDRV_CPU_REPLACE("maincpu", TMS34010, FAST_MASTER_CLOCK) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(FAST_MASTER_CLOCK) MDRV_IMPORT_FROM(williams_cvsd_sound) /* video hardware */ @@ -1111,7 +1112,8 @@ static MACHINE_DRIVER_START( yunit_adpcm_6bit_fast ) /* basic machine hardware */ MDRV_IMPORT_FROM(yunit_core) - MDRV_CPU_REPLACE("maincpu", TMS34010, FAST_MASTER_CLOCK) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(FAST_MASTER_CLOCK) MDRV_IMPORT_FROM(williams_adpcm_sound) /* video hardware */ @@ -1124,7 +1126,8 @@ static MACHINE_DRIVER_START( yunit_adpcm_6bit_faster ) /* basic machine hardware */ MDRV_IMPORT_FROM(yunit_core) - MDRV_CPU_REPLACE("maincpu", TMS34010, FASTER_MASTER_CLOCK) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(FASTER_MASTER_CLOCK) MDRV_IMPORT_FROM(williams_adpcm_sound) /* video hardware */ @@ -1148,8 +1151,7 @@ static MACHINE_DRIVER_START( mkyawdim ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/midzeus.c b/src/mame/drivers/midzeus.c index 06c9c8aaf3b..b4550048747 100644 --- a/src/mame/drivers/midzeus.c +++ b/src/mame/drivers/midzeus.c @@ -509,7 +509,7 @@ static void update_gun_irq(running_machine *machine) static TIMER_CALLBACK( invasn_gun_callback ) { int player = param; - int beamy = video_screen_get_vpos(machine->primary_screen); + int beamy = machine->primary_screen->vpos(); /* set the appropriate IRQ in the internal gun control and update */ gun_irq_state |= 0x01 << player; @@ -517,8 +517,8 @@ static TIMER_CALLBACK( invasn_gun_callback ) /* generate another interrupt on the next scanline while we are within the BEAM_DY */ beamy++; - if (beamy <= video_screen_get_visible_area(machine->primary_screen)->max_y && beamy <= gun_y[player] + BEAM_DY) - timer_adjust_oneshot(gun_timer[player], video_screen_get_time_until_pos(machine->primary_screen, beamy, MAX(0, gun_x[player] - BEAM_DX)), player); + if (beamy <= machine->primary_screen->visible_area().max_y && beamy <= gun_y[player] + BEAM_DY) + timer_adjust_oneshot(gun_timer[player], machine->primary_screen->time_until_pos(beamy, MAX(0, gun_x[player] - BEAM_DX)), player); } @@ -539,15 +539,15 @@ static WRITE32_HANDLER( invasn_gun_w ) UINT8 pmask = 0x04 << player; if (((old_control ^ gun_control) & pmask) != 0 && (gun_control & pmask) == 0) { - const rectangle *visarea = video_screen_get_visible_area(space->machine->primary_screen); + const rectangle &visarea = space->machine->primary_screen->visible_area(); static const char *const names[2][2] = { { "GUNX1", "GUNY1" }, { "GUNX2", "GUNY2" } }; - gun_x[player] = input_port_read(space->machine, names[player][0]) * (visarea->max_x + 1 - visarea->min_x) / 255 + visarea->min_x + BEAM_XOFFS; - gun_y[player] = input_port_read(space->machine, names[player][1]) * (visarea->max_y + 1 - visarea->min_y) / 255 + visarea->min_y; - timer_adjust_oneshot(gun_timer[player], video_screen_get_time_until_pos(space->machine->primary_screen, MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player); + gun_x[player] = input_port_read(space->machine, names[player][0]) * (visarea.max_x + 1 - visarea.min_x) / 255 + visarea.min_x + BEAM_XOFFS; + gun_y[player] = input_port_read(space->machine, names[player][1]) * (visarea.max_y + 1 - visarea.min_y) / 255 + visarea.min_y; + timer_adjust_oneshot(gun_timer[player], space->machine->primary_screen->time_until_pos(MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player); } } } @@ -555,8 +555,8 @@ static WRITE32_HANDLER( invasn_gun_w ) static READ32_HANDLER( invasn_gun_r ) { - int beamx = video_screen_get_hpos(space->machine->primary_screen); - int beamy = video_screen_get_vpos(space->machine->primary_screen); + int beamx = space->machine->primary_screen->hpos(); + int beamy = space->machine->primary_screen->vpos(); UINT32 result = 0xffff; int player; diff --git a/src/mame/drivers/mil4000.c b/src/mame/drivers/mil4000.c index d410eea81a2..025bfc38c16 100644 --- a/src/mame/drivers/mil4000.c +++ b/src/mame/drivers/mil4000.c @@ -364,8 +364,7 @@ static MACHINE_DRIVER_START( mil4000 ) MDRV_VIDEO_UPDATE(mil4000) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) // frequency from 1000 kHz resonator. pin 7 high not verified. - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // frequency from 1000 kHz resonator. pin 7 high not verified. MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/mirage.c b/src/mame/drivers/mirage.c index b69d055e448..0df967d67e1 100644 --- a/src/mame/drivers/mirage.c +++ b/src/mame/drivers/mirage.c @@ -44,7 +44,11 @@ class mirage_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mirage_state(machine)); } - mirage_state(running_machine &machine) { } + mirage_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + deco16ic(machine.device("deco_custom")), + oki_sfx(machine.device("oki_sfx")), + oki_bgm(machine.device("oki_bgm")) { } /* memory pointers */ UINT16 * pf1_rowscroll; @@ -57,11 +61,10 @@ public: UINT32 mux_data; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *deco16ic; - running_device *oki_sfx; - running_device *oki_bgm; + cpu_device *maincpu; + deco16ic_device *deco16ic; + okim6295_device *oki_sfx; + okim6295_device *oki_bgm; }; @@ -82,7 +85,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; if (pri != ((y & 0x8000) >> 15)) @@ -181,7 +184,7 @@ static READ16_HANDLER( mirage_input_r ) static WRITE16_HANDLER( okim1_rombank_w ) { mirage_state *state = (mirage_state *)space->machine->driver_data; - okim6295_set_bank_base(state->oki_sfx, 0x40000 * (data & 0x3)); + state->oki_sfx->set_bank_base(0x40000 * (data & 0x3)); } static WRITE16_HANDLER( okim0_rombank_w ) @@ -189,7 +192,7 @@ static WRITE16_HANDLER( okim0_rombank_w ) mirage_state *state = (mirage_state *)space->machine->driver_data; /*bits 4-6 used on POST? */ - okim6295_set_bank_base(state->oki_bgm, 0x40000 * (data & 0x7)); + state->oki_bgm->set_bank_base(0x40000 * (data & 0x7)); } static ADDRESS_MAP_START( mirage_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -362,11 +365,6 @@ static MACHINE_START( mirage ) { mirage_state *state = (mirage_state *)machine->driver_data; - state->maincpu = devtag_get_device(machine, "maincpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->oki_sfx = devtag_get_device(machine, "oki_sfx"); - state->oki_bgm = devtag_get_device(machine, "oki_bgm"); - state_save_register_global(machine, state->mux_data); } @@ -408,12 +406,10 @@ static MACHINE_DRIVER_START( mirage ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki_bgm", OKIM6295, 2000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki_bgm", 2000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki_sfx", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki_sfx", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MACHINE_DRIVER_END diff --git a/src/mame/drivers/missb2.c b/src/mame/drivers/missb2.c index 6b06041794d..b753cf2c24c 100644 --- a/src/mame/drivers/missb2.c +++ b/src/mame/drivers/missb2.c @@ -423,8 +423,7 @@ static MACHINE_DRIVER_START( missb2 ) MDRV_SOUND_CONFIG(ym3526_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.4) MACHINE_DRIVER_END diff --git a/src/mame/drivers/missile.c b/src/mame/drivers/missile.c index 58887e48e1c..a35f61eddc2 100644 --- a/src/mame/drivers/missile.c +++ b/src/mame/drivers/missile.c @@ -372,7 +372,7 @@ INLINE int scanline_to_v(int scanline) { /* since the vertical sync counter counts backwards when flipped, this function returns the current effective V value, given - that video_screen_get_vpos() only counts forward */ + that vpos() only counts forward */ return flipscreen ? (256 - scanline) : scanline; } @@ -395,7 +395,7 @@ INLINE void schedule_next_irq(running_machine *machine, int curv) curv = ((curv + 32) & 0xff) & ~0x10; /* next one at the start of this scanline */ - timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, v_to_scanline(curv), 0), curv); + timer_adjust_oneshot(irq_timer, machine->primary_screen->time_until_pos(v_to_scanline(curv), 0), curv); } @@ -408,7 +408,7 @@ static TIMER_CALLBACK( clock_irq ) cputag_set_input_line(machine, "maincpu", 0, irq_state ? ASSERT_LINE : CLEAR_LINE); /* force an update while we're here */ - video_screen_update_partial(machine->primary_screen, v_to_scanline(curv)); + machine->primary_screen->update_partial(v_to_scanline(curv)); /* find the next edge */ schedule_next_irq(machine, curv); @@ -417,7 +417,7 @@ static TIMER_CALLBACK( clock_irq ) static CUSTOM_INPUT( get_vblank ) { - int v = scanline_to_v(video_screen_get_vpos(field->port->machine->primary_screen)); + int v = scanline_to_v(field->port->machine->primary_screen->vpos()); return v < 24; } @@ -441,7 +441,7 @@ static TIMER_CALLBACK( adjust_cpu_speed ) /* scanline for the next run */ curv ^= 224; - timer_adjust_oneshot(cpu_timer, video_screen_get_time_until_pos(machine->primary_screen, v_to_scanline(curv), 0), curv); + timer_adjust_oneshot(cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(curv), 0), curv); } @@ -481,7 +481,7 @@ static MACHINE_START( missile ) /* create a timer to speed/slow the CPU */ cpu_timer = timer_alloc(machine, adjust_cpu_speed, NULL); - timer_adjust_oneshot(cpu_timer, video_screen_get_time_until_pos(machine->primary_screen, v_to_scanline(0), 0), 0); + timer_adjust_oneshot(cpu_timer, machine->primary_screen->time_until_pos(v_to_scanline(0), 0), 0); /* create a timer for IRQs and set up the first callback */ irq_timer = timer_alloc(machine, clock_irq, NULL); diff --git a/src/mame/drivers/mitchell.c b/src/mame/drivers/mitchell.c index f5f96d0cae5..ca9131cfacc 100644 --- a/src/mame/drivers/mitchell.c +++ b/src/mame/drivers/mitchell.c @@ -390,7 +390,7 @@ ADDRESS_MAP_END /**** Monsters World ****/ static WRITE8_DEVICE_HANDLER( oki_banking_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 3)); + downcast(device)->set_bank_base(0x40000 * (data & 3)); } static ADDRESS_MAP_START( mstworld_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -1084,9 +1084,6 @@ static MACHINE_START( mitchell ) { mitchell_state *state = (mitchell_state *)machine->driver_data; - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->oki = devtag_get_device(machine, "oki"); - state_save_register_global(machine, state->sample_buffer); state_save_register_global(machine, state->sample_select); state_save_register_global(machine, state->dial_selected); @@ -1143,8 +1140,7 @@ static MACHINE_DRIVER_START( mgakuen ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) /* probably same clock as the other mitchell hardware games */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) /* probably same clock as the other mitchell hardware games */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_16MHz/4) /* probably same clock as the other mitchell hardware games */ @@ -1186,8 +1182,7 @@ static MACHINE_DRIVER_START( pang ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 verified + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd",YM2413, XTAL_16MHz/4) /* verified on pcb */ @@ -1289,8 +1284,7 @@ static MACHINE_DRIVER_START( mstworld ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 990000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 990000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END @@ -1326,8 +1320,7 @@ static MACHINE_DRIVER_START( marukin ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_16MHz/4) /* verified on pcb */ @@ -1383,8 +1376,7 @@ static MACHINE_DRIVER_START( pkladiesbl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) /* It should be a OKIM5205 with a 384khz resonator */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) /* It should be a OKIM5205 with a 384khz resonator */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd", YM2413, 3750000) /* verified on pcb, read the comments */ diff --git a/src/mame/drivers/mjkjidai.c b/src/mame/drivers/mjkjidai.c index a886f21aa5b..e0074373619 100644 --- a/src/mame/drivers/mjkjidai.c +++ b/src/mame/drivers/mjkjidai.c @@ -32,7 +32,7 @@ TODO: typedef struct _mjkjidai_adpcm_state mjkjidai_adpcm_state; struct _mjkjidai_adpcm_state { - struct adpcm_state adpcm; + adpcm_state adpcm; sound_stream *stream; UINT32 current, end; UINT8 nibble; @@ -57,7 +57,7 @@ static STREAM_UPDATE( mjkjidai_adpcm_callback ) state->playing = 0; } - *dest++ = clock_adpcm(&state->adpcm, val) << 4; + *dest++ = state->adpcm.clock(val) << 4; samples--; } while (samples > 0) @@ -70,15 +70,15 @@ static STREAM_UPDATE( mjkjidai_adpcm_callback ) static DEVICE_START( mjkjidai_adpcm ) { running_machine *machine = device->machine; - mjkjidai_adpcm_state *state = (mjkjidai_adpcm_state *)device->token; + mjkjidai_adpcm_state *state = (mjkjidai_adpcm_state *)downcast(device)->token(); state->playing = 0; - state->stream = stream_create(device, 0, 1, device->clock, state, mjkjidai_adpcm_callback); + state->stream = stream_create(device, 0, 1, device->clock(), state, mjkjidai_adpcm_callback); state->base = memory_region(machine, "adpcm"); - reset_adpcm(&state->adpcm); + state->adpcm.reset(); } -static DEVICE_GET_INFO( mjkjidai_adpcm ) +DEVICE_GET_INFO( mjkjidai_adpcm ) { switch (state) { @@ -93,7 +93,7 @@ static DEVICE_GET_INFO( mjkjidai_adpcm ) } } -#define SOUND_MJKJIDAI DEVICE_GET_INFO_NAME(mjkjidai_adpcm) +DECLARE_LEGACY_SOUND_DEVICE(MJKJIDAI, mjkjidai_adpcm); static void mjkjidai_adpcm_play (mjkjidai_adpcm_state *state, int offset, int length) @@ -106,7 +106,7 @@ static void mjkjidai_adpcm_play (mjkjidai_adpcm_state *state, int offset, int le static WRITE8_DEVICE_HANDLER( adpcm_w ) { - mjkjidai_adpcm_state *state = (mjkjidai_adpcm_state *)device->token; + mjkjidai_adpcm_state *state = (mjkjidai_adpcm_state *)downcast(device)->token(); mjkjidai_adpcm_play (state, (data & 0x07) * 0x1000, 0x1000 * 2); } /* End of ADPCM custom chip code */ diff --git a/src/mame/drivers/mjsister.c b/src/mame/drivers/mjsister.c index d70ee13575e..241ca5e406d 100644 --- a/src/mame/drivers/mjsister.c +++ b/src/mame/drivers/mjsister.c @@ -56,8 +56,8 @@ public: static VIDEO_START( mjsister ) { mjsister_state *state = (mjsister_state *)machine->driver_data; - state->tmpbitmap0 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); - state->tmpbitmap1 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); + state->tmpbitmap0 = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); + state->tmpbitmap1 = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); state->videoram0 = auto_alloc_array(machine, UINT8, 0x8000); state->videoram1 = auto_alloc_array(machine, UINT8, 0x8000); diff --git a/src/mame/drivers/model2.c b/src/mame/drivers/model2.c index 36c54c9d25f..8ec54c2a264 100644 --- a/src/mame/drivers/model2.c +++ b/src/mame/drivers/model2.c @@ -111,7 +111,7 @@ static UINT16 *model2_soundram = NULL; static UINT32 model2_timervals[4], model2_timerorig[4]; static int model2_timerrun[4]; -static running_device *model2_timers[4]; +static timer_device *model2_timers[4]; static int model2_ctrlmode; static int analog_channel; @@ -315,7 +315,7 @@ static READ32_HANDLER( timers_r ) if (model2_timerrun[offset]) { // get elapsed time, convert to units of 25 MHz - UINT32 cur = attotime_to_double(attotime_mul(timer_device_timeelapsed(model2_timers[offset]), 25000000)); + UINT32 cur = attotime_to_double(attotime_mul(model2_timers[offset]->time_elapsed(), 25000000)); // subtract units from starting value model2_timervals[offset] = model2_timerorig[offset] - cur; @@ -333,7 +333,7 @@ static WRITE32_HANDLER( timers_w ) model2_timerorig[offset] = model2_timervals[offset]; period = attotime_mul(ATTOTIME_IN_HZ(25000000), model2_timerorig[offset]); - timer_device_adjust_oneshot(model2_timers[offset], period, 0); + model2_timers[offset]->adjust(period); model2_timerrun[offset] = 1; } @@ -342,12 +342,12 @@ static TIMER_DEVICE_CALLBACK( model2_timer_cb ) int tnum = (int)(FPTR)ptr; int bit = tnum + 2; - timer_device_adjust_oneshot(model2_timers[tnum], attotime_never, 0); + model2_timers[tnum]->reset(); model2_intreq |= (1<machine, "maincpu", I960_IRQ2, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", I960_IRQ2, ASSERT_LINE); } model2_timervals[tnum] = 0; @@ -374,12 +374,12 @@ static MACHINE_RESET(model2_common) model2_timerrun[0] = model2_timerrun[1] = model2_timerrun[2] = model2_timerrun[3] = 0; - model2_timers[0] = devtag_get_device(machine, "timer0"); - model2_timers[1] = devtag_get_device(machine, "timer1"); - model2_timers[2] = devtag_get_device(machine, "timer2"); - model2_timers[3] = devtag_get_device(machine, "timer3"); + model2_timers[0] = machine->device("timer0"); + model2_timers[1] = machine->device("timer1"); + model2_timers[2] = machine->device("timer2"); + model2_timers[3] = machine->device("timer3"); for (i=0; i<4; i++) - timer_device_adjust_oneshot(model2_timers[i], attotime_never, 0); + model2_timers[i]->reset(); } static MACHINE_RESET(model2o) @@ -454,7 +454,7 @@ static WRITE32_HANDLER( ctrl0_w ) { if(ACCESSING_BITS_0_7) { - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); model2_ctrlmode = data & 0x01; eeprom_write_bit(device, data & 0x20); eeprom_set_clock_line(device, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE); @@ -483,7 +483,7 @@ static READ32_HANDLER( fifoctl_r ) static READ32_HANDLER( videoctl_r ) { - return (video_screen_get_frame_number(space->machine->primary_screen) & 1) << 2; + return (space->machine->primary_screen->frame_number() & 1) << 2; } static CUSTOM_INPUT( _1c00000_r ) diff --git a/src/mame/drivers/model3.c b/src/mame/drivers/model3.c index 8df65712c6a..3dcf1887ef5 100644 --- a/src/mame/drivers/model3.c +++ b/src/mame/drivers/model3.c @@ -1597,7 +1597,7 @@ static READ64_HANDLER(real3d_status_r) { /* pretty sure this is VBLANK */ real3d_status &= ~U64(0x0000000200000000); - if (video_screen_get_vblank(space->machine->primary_screen)) + if (space->machine->primary_screen->vblank()) real3d_status |= U64(0x0000000200000000); return real3d_status; } diff --git a/src/mame/drivers/mogura.c b/src/mame/drivers/mogura.c index ecd8d13475d..97ba27285f2 100644 --- a/src/mame/drivers/mogura.c +++ b/src/mame/drivers/mogura.c @@ -82,21 +82,21 @@ static VIDEO_START( mogura ) static VIDEO_UPDATE( mogura ) { mogura_state *state = (mogura_state *)screen->machine->driver_data; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); /* tilemap layout is a bit strange ... */ rectangle clip; - clip.min_x = visarea->min_x; + clip.min_x = visarea.min_x; clip.max_x = 256 - 1; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; tilemap_set_scrollx(state->tilemap, 0, 256); tilemap_draw(bitmap, &clip, state->tilemap, 0, 0); clip.min_x = 256; clip.max_x = 512 - 1; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; tilemap_set_scrollx(state->tilemap, 0, -128); tilemap_draw(bitmap, &clip, state->tilemap, 0, 0); diff --git a/src/mame/drivers/moo.c b/src/mame/drivers/moo.c index 307abe0f246..8c8a9631a30 100644 --- a/src/mame/drivers/moo.c +++ b/src/mame/drivers/moo.c @@ -255,7 +255,7 @@ static WRITE16_DEVICE_HANDLER( moobl_oki_bank_w ) { logerror("%x to OKI bank\n", data); - okim6295_set_bank_base(device, (data & 0x0f) * 0x40000); + downcast(device)->set_bank_base((data & 0x0f) * 0x40000); } static ADDRESS_MAP_START( moo_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -593,8 +593,7 @@ static MACHINE_DRIVER_START( moobl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/mpu4.c b/src/mame/drivers/mpu4.c index 02a11afc041..64f3285d2ef 100644 --- a/src/mame/drivers/mpu4.c +++ b/src/mame/drivers/mpu4.c @@ -1745,7 +1745,7 @@ static TIMER_DEVICE_CALLBACK( gen_50hz ) oscillating signal.*/ signal_50hz = signal_50hz?0:1; update_lamps(); - pia6821_ca1_w(devtag_get_device(timer->machine, "pia_ic4"), 0, signal_50hz); /* signal is connected to IC4 CA1 */ + pia6821_ca1_w(devtag_get_device(timer.machine, "pia_ic4"), 0, signal_50hz); /* signal is connected to IC4 CA1 */ } diff --git a/src/mame/drivers/mugsmash.c b/src/mame/drivers/mugsmash.c index dc09cd28497..56b6653efc0 100644 --- a/src/mame/drivers/mugsmash.c +++ b/src/mame/drivers/mugsmash.c @@ -441,8 +441,7 @@ static MACHINE_DRIVER_START( mugsmash ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.00) /* music */ MDRV_SOUND_ROUTE(1, "rspeaker", 1.00) - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) /* sound fx */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/multfish.c b/src/mame/drivers/multfish.c index 1728fcaf601..68ca9056f22 100644 --- a/src/mame/drivers/multfish.c +++ b/src/mame/drivers/multfish.c @@ -289,7 +289,7 @@ static READ8_HANDLER( ray_r ) { // the games read the raster beam position as part of the hardware checks.. // with a 6mhz clock and 640x480 resolution this seems to give the right results. - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } static UINT8 multfish_hopper_motor = 0; diff --git a/src/mame/drivers/mw8080bw.c b/src/mame/drivers/mw8080bw.c index 27fac7e6380..6f75c249e88 100644 --- a/src/mame/drivers/mw8080bw.c +++ b/src/mame/drivers/mw8080bw.c @@ -2156,7 +2156,7 @@ MACHINE_DRIVER_END static TIMER_DEVICE_CALLBACK( spcenctr_strobe_timer_callback ) { - mw8080bw_state *state = (mw8080bw_state *)timer->machine->driver_data; + mw8080bw_state *state = (mw8080bw_state *)timer.machine->driver_data; output_set_value("STROBE", param && state->spcenctr_strobe_state); } diff --git a/src/mame/drivers/mwarr.c b/src/mame/drivers/mwarr.c index f2bc912282f..080ce7fa517 100644 --- a/src/mame/drivers/mwarr.c +++ b/src/mame/drivers/mwarr.c @@ -108,7 +108,7 @@ static WRITE16_HANDLER( tx_videoram_w ) static WRITE16_DEVICE_HANDLER( oki1_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 3)); + downcast(device)->set_bank_base(0x40000 * (data & 3)); } static WRITE16_HANDLER( sprites_commands_w ) @@ -563,12 +563,10 @@ static MACHINE_DRIVER_START( mwarr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, SOUND_CLOCK/48 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", SOUND_CLOCK/48 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, SOUND_CLOCK/48 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", SOUND_CLOCK/48 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/n8080.c b/src/mame/drivers/n8080.c index 2a8c7bd58f5..b5043ebccbb 100644 --- a/src/mame/drivers/n8080.c +++ b/src/mame/drivers/n8080.c @@ -393,7 +393,7 @@ INPUT_PORTS_END static TIMER_DEVICE_CALLBACK( rst1_tick ) { - n8080_state *n8080 = (n8080_state *)timer->machine->driver_data; + n8080_state *n8080 = (n8080_state *)timer.machine->driver_data; int state = n8080->inte ? ASSERT_LINE : CLEAR_LINE; /* V7 = 1, V6 = 0 */ @@ -402,7 +402,7 @@ static TIMER_DEVICE_CALLBACK( rst1_tick ) static TIMER_DEVICE_CALLBACK( rst2_tick ) { - n8080_state *n8080 = (n8080_state *)timer->machine->driver_data; + n8080_state *n8080 = (n8080_state *)timer.machine->driver_data; int state = n8080->inte ? ASSERT_LINE : CLEAR_LINE; /* vblank */ diff --git a/src/mame/drivers/namcofl.c b/src/mame/drivers/namcofl.c index 31078667914..f57ec24813b 100644 --- a/src/mame/drivers/namcofl.c +++ b/src/mame/drivers/namcofl.c @@ -219,7 +219,7 @@ static WRITE32_HANDLER( namcofl_paletteram_w ) UINT16 v = space->machine->generic.paletteram.u32[offset] >> 16; UINT16 triggerscanline=(((v>>8)&0xff)|((v&0xff)<<8))-(32+1); - timer_adjust_oneshot(raster_interrupt_timer, video_screen_get_time_until_pos(space->machine->primary_screen, triggerscanline, 0), 0); + timer_adjust_oneshot(raster_interrupt_timer, space->machine->primary_screen->time_until_pos(triggerscanline), 0); } } @@ -538,22 +538,22 @@ GFXDECODE_END static TIMER_CALLBACK( network_interrupt_callback ) { cputag_set_input_line(machine, "maincpu", I960_IRQ0, ASSERT_LINE); - timer_set(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, network_interrupt_callback); + timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, network_interrupt_callback); } static TIMER_CALLBACK( vblank_interrupt_callback ) { cputag_set_input_line(machine, "maincpu", I960_IRQ2, ASSERT_LINE); - timer_set(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, vblank_interrupt_callback); + timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, vblank_interrupt_callback); } static TIMER_CALLBACK( raster_interrupt_callback ) { - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); cputag_set_input_line(machine, "maincpu", I960_IRQ1, ASSERT_LINE); - timer_adjust_oneshot(raster_interrupt_timer, video_screen_get_frame_period(machine->primary_screen), 0); + timer_adjust_oneshot(raster_interrupt_timer, machine->primary_screen->frame_period(), 0); } static INTERRUPT_GEN( mcu_interrupt ) @@ -580,8 +580,8 @@ static MACHINE_START( namcofl ) static MACHINE_RESET( namcofl ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, video_screen_get_visible_area(machine->primary_screen)->max_y + 3, 0), NULL, 0, network_interrupt_callback); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, video_screen_get_visible_area(machine->primary_screen)->max_y + 1, 0), NULL, 0, vblank_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 3, 0), NULL, 0, network_interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(machine->primary_screen->visible_area().max_y + 1, 0), NULL, 0, vblank_interrupt_callback); memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") ); memory_set_bankptr(machine, "bank2", namcofl_workram ); diff --git a/src/mame/drivers/namcona1.c b/src/mame/drivers/namcona1.c index 461987b92d7..a19250c80a3 100644 --- a/src/mame/drivers/namcona1.c +++ b/src/mame/drivers/namcona1.c @@ -974,7 +974,7 @@ static INTERRUPT_GEN( namcona1_interrupt ) int scanline = namcona1_vreg[0x8a/2]&0xff; if( scanline ) { - video_screen_update_partial(device->machine->primary_screen, scanline ); + device->machine->primary_screen->update_partial(scanline ); } } cpu_set_input_line(device, level+1, HOLD_LINE); @@ -1062,7 +1062,7 @@ static MACHINE_DRIVER_START( namcona2 ) /* basic machine hardware */ MDRV_IMPORT_FROM(namcona1) - MDRV_CPU_REPLACE("maincpu", M68000, 50113000/4) + MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(namcona2_main_map) MACHINE_DRIVER_END diff --git a/src/mame/drivers/namconb1.c b/src/mame/drivers/namconb1.c index d1c4c44749a..6c6d17bad1e 100644 --- a/src/mame/drivers/namconb1.c +++ b/src/mame/drivers/namconb1.c @@ -294,7 +294,7 @@ static TIMER_CALLBACK( namconb1_TriggerPOSIRQ ) if(pos_irq_active || !(namconb_cpureg[0x02] & 0xf0)) return; - video_screen_update_partial(machine->primary_screen, param); + machine->primary_screen->update_partial(param); pos_irq_active = 1; cputag_set_input_line(machine, "maincpu", namconb_cpureg[0x02] & 0xf, ASSERT_LINE); } @@ -348,7 +348,7 @@ static INTERRUPT_GEN( namconb1_interrupt ) } if( scanline < NAMCONB1_VBSTART ) { - timer_set( device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, scanline, 0), NULL, scanline, namconb1_TriggerPOSIRQ ); + timer_set( device->machine, device->machine->primary_screen->time_until_pos(scanline), NULL, scanline, namconb1_TriggerPOSIRQ ); } } /* namconb1_interrupt */ @@ -370,7 +370,7 @@ static INTERRUPT_GEN( mcu_interrupt ) static TIMER_CALLBACK( namconb2_TriggerPOSIRQ ) { - video_screen_update_partial(machine->primary_screen, param); + machine->primary_screen->update_partial(param); pos_irq_active = 1; cputag_set_input_line(machine, "maincpu", namconb_cpureg[0x02], ASSERT_LINE); } @@ -417,7 +417,7 @@ static INTERRUPT_GEN( namconb2_interrupt ) scanline = 0; if( scanline < NAMCONB1_VBSTART ) - timer_set( device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, scanline, 0), NULL, scanline, namconb2_TriggerPOSIRQ ); + timer_set( device->machine, device->machine->primary_screen->time_until_pos(scanline), NULL, scanline, namconb2_TriggerPOSIRQ ); } /* namconb2_interrupt */ static void namconb1_cpureg8_w(running_machine *machine, int reg, UINT8 data) diff --git a/src/mame/drivers/namcos23.c b/src/mame/drivers/namcos23.c index 7086034e27f..c0ba77fc299 100644 --- a/src/mame/drivers/namcos23.c +++ b/src/mame/drivers/namcos23.c @@ -1293,7 +1293,7 @@ static READ16_HANDLER(s23_c417_r) 1: 1st c435 busy (inverted) 0: xcpreq */ - case 0: return 0x8e | (video_screen_get_vblank(space->machine->primary_screen) ? 0x0000 : 0x8000); + case 0: return 0x8e | (space->machine->primary_screen->vblank() ? 0x0000 : 0x8000); case 1: return c417_adr; case 4: // logerror("c417_r %04x = %04x (%08x, %08x)\n", c417_adr, c417_ram[c417_adr], cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31)); @@ -1531,7 +1531,7 @@ static WRITE16_HANDLER(s23_c361_w) } else { - timer_adjust_oneshot(c361_timer, video_screen_get_time_until_pos(space->machine->primary_screen, c361_scanline, 0), 0); + timer_adjust_oneshot(c361_timer, space->machine->primary_screen->time_until_pos(c361_scanline), 0); } break; @@ -1543,8 +1543,8 @@ static WRITE16_HANDLER(s23_c361_w) static READ16_HANDLER(s23_c361_r) { switch(offset) { - case 5: return video_screen_get_vpos(space->machine->primary_screen)*2 | (video_screen_get_vblank(space->machine->primary_screen) ? 1 : 0); - case 6: return video_screen_get_vblank(space->machine->primary_screen); + case 5: return space->machine->primary_screen->vpos()*2 | (space->machine->primary_screen->vblank() ? 1 : 0); + case 6: return space->machine->primary_screen->vblank(); } logerror("c361_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31)); return 0xffff; diff --git a/src/mame/drivers/nbmj9195.c b/src/mame/drivers/nbmj9195.c index 5a0e13a42b3..818cdf41f65 100644 --- a/src/mame/drivers/nbmj9195.c +++ b/src/mame/drivers/nbmj9195.c @@ -2898,13 +2898,13 @@ static INPUT_PORTS_START( mjegolf ) INPUT_PORTS_END -static const z80_daisy_chain daisy_chain_main[] = +static const z80_daisy_config daisy_chain_main[] = { { "main_ctc" }, { NULL } }; -static const z80_daisy_chain daisy_chain_sound[] = +static const z80_daisy_config daisy_chain_sound[] = { { "audio_ctc" }, { NULL } diff --git a/src/mame/drivers/neogeo.c b/src/mame/drivers/neogeo.c index 0335431060e..0981cf30a54 100644 --- a/src/mame/drivers/neogeo.c +++ b/src/mame/drivers/neogeo.c @@ -246,7 +246,7 @@ static void adjust_display_position_interrupt_timer( running_machine *machine ) if ((state->display_counter + 1) != 0) { attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), state->display_counter + 1); - if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer current y: %02x current x: %02x target y: %x target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL); + if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer current y: %02x current x: %02x target y: %x target x: %x\n", machine->primary_screen->vpos(), machine->primary_screen->hpos(), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL); timer_adjust_oneshot(state->display_position_interrupt_timer, period, 0); } @@ -315,11 +315,11 @@ static TIMER_CALLBACK( display_position_interrupt_callback ) { neogeo_state *state = (neogeo_state *)machine->driver_data; - if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); + if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", machine->primary_screen->vpos(), machine->primary_screen->hpos()); if (state->display_position_interrupt_control & IRQ2CTRL_ENABLE) { - if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) *** y: %02x x: %02x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); + if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) *** y: %02x x: %02x\n", machine->primary_screen->vpos(), machine->primary_screen->hpos()); state->display_position_interrupt_pending = 1; update_interrupts(machine); @@ -344,7 +344,7 @@ static TIMER_CALLBACK( display_position_vblank_callback ) } /* set timer for next screen */ - timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0); + timer_adjust_oneshot(state->display_position_vblank_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0); } @@ -352,7 +352,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) { neogeo_state *state = (neogeo_state *)machine->driver_data; - if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); + if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", machine->primary_screen->vpos(), machine->primary_screen->hpos()); /* add a timer tick to the pd4990a */ upd4990a_addretrace(state->upd4990a); @@ -362,7 +362,7 @@ static TIMER_CALLBACK( vblank_interrupt_callback ) update_interrupts(machine); /* set timer for next screen */ - timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0); + timer_adjust_oneshot(state->vblank_interrupt_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART), 0); } @@ -378,8 +378,8 @@ static void create_interrupt_timers( running_machine *machine ) static void start_interrupt_timers( running_machine *machine ) { neogeo_state *state = (neogeo_state *)machine->driver_data; - timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0); - timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0); + timer_adjust_oneshot(state->vblank_interrupt_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART), 0); + timer_adjust_oneshot(state->display_position_vblank_timer, machine->primary_screen->time_until_pos(NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0); } diff --git a/src/mame/drivers/news.c b/src/mame/drivers/news.c index ed2b621c1bf..6e44f558495 100644 --- a/src/mame/drivers/news.c +++ b/src/mame/drivers/news.c @@ -157,8 +157,7 @@ static MACHINE_DRIVER_START( news ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ninjaw.c b/src/mame/drivers/ninjaw.c index 798d419329c..758c6889e3e 100644 --- a/src/mame/drivers/ninjaw.c +++ b/src/mame/drivers/ninjaw.c @@ -690,7 +690,7 @@ static DEVICE_GET_INFO( subwoofer ) } } -#define SOUND_SUBWOOFER DEVICE_GET_INFO_NAME(subwoofer) +DECLARE_LEGACY_SOUND_DEVICE(SUBWOOFER, subwoofer); #endif diff --git a/src/mame/drivers/niyanpai.c b/src/mame/drivers/niyanpai.c index 421a356a0b6..d9b6b34722f 100644 --- a/src/mame/drivers/niyanpai.c +++ b/src/mame/drivers/niyanpai.c @@ -764,7 +764,7 @@ static INTERRUPT_GEN( niyanpai_interrupt ) cpu_set_input_line(device, 1, HOLD_LINE); } -static const z80_daisy_chain daisy_chain_sound[] = +static const z80_daisy_config daisy_chain_sound[] = { { "ctc" }, { NULL } diff --git a/src/mame/drivers/nmg5.c b/src/mame/drivers/nmg5.c index c4df333d28f..44e0e407b02 100644 --- a/src/mame/drivers/nmg5.c +++ b/src/mame/drivers/nmg5.c @@ -315,7 +315,7 @@ static WRITE16_HANDLER( priority_reg_w ) static WRITE8_DEVICE_HANDLER( oki_banking_w ) { - okim6295_set_bank_base(device, (data & 1) ? 0x40000 : 0); + downcast(device)->set_bank_base((data & 1) ? 0x40000 : 0); } /******************************************************************* @@ -1069,8 +1069,7 @@ static MACHINE_DRIVER_START( nmg5 ) MDRV_SOUND_CONFIG(ym3812_intf) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/nmk16.c b/src/mame/drivers/nmk16.c index eb70e0d8a05..5a759ab2a0c 100644 --- a/src/mame/drivers/nmk16.c +++ b/src/mame/drivers/nmk16.c @@ -873,12 +873,12 @@ static void mcu_run(running_machine *machine, UINT8 dsw_setting) static TIMER_DEVICE_CALLBACK( tdragon_mcu_sim ) { - mcu_run(timer->machine,1); + mcu_run(timer.machine,1); } static TIMER_DEVICE_CALLBACK( hachamf_mcu_sim ) { - mcu_run(timer->machine,0); + mcu_run(timer.machine,0); } static ADDRESS_MAP_START( tdragon_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -3567,12 +3567,10 @@ static MACHINE_DRIVER_START( tharrier ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3613,12 +3611,10 @@ static MACHINE_DRIVER_START( manybloc ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3658,12 +3654,10 @@ static MACHINE_DRIVER_START( mustang ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3737,12 +3731,10 @@ static MACHINE_DRIVER_START( bioship ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, BIOSHIP_CRYSTAL2 / 3 ) /* 4.0 Mhz, Pin 7 High (verified) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", BIOSHIP_CRYSTAL2 / 3 , OKIM6295_PIN7_HIGH) /* 4.0 Mhz, Pin 7 High (verified) */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, BIOSHIP_CRYSTAL2 / 3 ) /* 4.0 Mhz, Pin 7 High (verified) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", BIOSHIP_CRYSTAL2 / 3 , OKIM6295_PIN7_HIGH) /* 4.0 Mhz, Pin 7 High (verified) */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3781,12 +3773,10 @@ static MACHINE_DRIVER_START( vandyke ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_12MHz/3) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_12MHz/3, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_12MHz/3) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", XTAL_12MHz/3, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3799,7 +3789,7 @@ static MACHINE_DRIVER_START( vandykeb ) MDRV_CPU_PERIODIC_INT(irq1_line_hold,112)/* ???????? */ MDRV_CPU_ADD("mcu", PIC16C57, 12000000) /* 3MHz */ - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() //MDRV_MACHINE_RESET(NMK004) // no NMK004 @@ -3821,8 +3811,7 @@ static MACHINE_DRIVER_START( vandykeb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3861,12 +3850,10 @@ static MACHINE_DRIVER_START( acrobatm ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) /* (verified on pcb) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* on the pcb pin7 is not connected to gnd or +5v! */ + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) /* (verified on pcb) on the pcb pin7 is not connected to gnd or +5v! */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) /* (verified on pcb) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* on the pcb pin7 is not connected to gnd or +5v! */ + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) /* (verified on pcb) on the pcb pin7 is not connected to gnd or +5v! */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3940,12 +3927,10 @@ static MACHINE_DRIVER_START( tdragon ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_8MHz/2) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_8MHz/2, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_8MHz/2) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", XTAL_8MHz/2, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -3978,8 +3963,7 @@ static MACHINE_DRIVER_START( ssmissin ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 8000000/8) /* 1 Mhz, pin 7 high */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 8000000/8, OKIM6295_PIN7_HIGH) /* 1 Mhz, pin 7 high */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_NMK112_ADD("nmk112", nmk16_nmk112_intf) @@ -4020,12 +4004,10 @@ static MACHINE_DRIVER_START( strahl ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -4065,12 +4047,10 @@ static MACHINE_DRIVER_START( hachamf ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -4109,12 +4089,10 @@ static MACHINE_DRIVER_START( macross ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -4153,12 +4131,10 @@ static MACHINE_DRIVER_START( blkheart ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_8MHz/2) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_8MHz/2, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_8MHz/2) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", XTAL_8MHz/2, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -4197,12 +4173,10 @@ static MACHINE_DRIVER_START( gunnail ) MDRV_SOUND_ROUTE(2, "mono", 0.50) MDRV_SOUND_ROUTE(3, "mono", 2.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MACHINE_DRIVER_END @@ -4240,12 +4214,10 @@ static MACHINE_DRIVER_START( macross2 ) MDRV_SOUND_CONFIG(ym2203_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MDRV_NMK112_ADD("nmk112", nmk16_nmk112_intf) @@ -4285,12 +4257,10 @@ static MACHINE_DRIVER_START( tdragon2 ) MDRV_SOUND_CONFIG(ym2203_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.08) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.08) MDRV_NMK112_ADD("nmk112", nmk16_nmk112_intf) @@ -4329,12 +4299,10 @@ static MACHINE_DRIVER_START( raphero ) MDRV_SOUND_CONFIG(ym2203_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MDRV_NMK112_ADD("nmk112", nmk16_nmk112_intf) @@ -4366,12 +4334,10 @@ static MACHINE_DRIVER_START( bjtwin ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 16000000/4) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", 16000000/4, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) - MDRV_SOUND_ADD("oki2", OKIM6295, 16000000/4) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", 16000000/4, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MDRV_NMK112_ADD("nmk112", nmk16_nmk112_intf) @@ -4713,9 +4679,9 @@ static WRITE16_HANDLER( twinactn_flipscreen_w ) static WRITE8_DEVICE_HANDLER( spec2k_oki1_banking_w ) { if(data == 0xfe) - okim6295_set_bank_base(device, 0); + downcast(device)->set_bank_base(0); else if(data == 0xff) - okim6295_set_bank_base(device, 0x40000); + downcast(device)->set_bank_base(0x40000); } static ADDRESS_MAP_START( afega_sound_cpu, ADDRESS_SPACE_PROGRAM, 8 ) @@ -4741,7 +4707,7 @@ ADDRESS_MAP_END static WRITE8_DEVICE_HANDLER( twinactn_oki_bank_w ) { - okim6295_set_bank_base(device, (data & 3) * 0x40000); + downcast(device)->set_bank_base((data & 3) * 0x40000); if (data & (~3)) logerror("%s: invalid oki bank %02x\n", cpuexec_describe_context(device->machine), data); @@ -4881,8 +4847,7 @@ static MACHINE_DRIVER_START( stagger1 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.30) MDRV_SOUND_ROUTE(1, "rspeaker", 0.30) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_4MHz/4) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_4MHz/4, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.70) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.70) MACHINE_DRIVER_END @@ -4961,12 +4926,10 @@ static MACHINE_DRIVER_START( firehawk ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -5000,8 +4963,7 @@ static MACHINE_DRIVER_START( twinactn ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/norautp.c b/src/mame/drivers/norautp.c index d0480142b3d..7184413ecb8 100644 --- a/src/mame/drivers/norautp.c +++ b/src/mame/drivers/norautp.c @@ -1339,6 +1339,7 @@ static MACHINE_DRIVER_START( dphl ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", 8080, DPHL_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(dphl_map) + MDRV_CPU_IO_MAP(norautp_portmap) /* sound hardware */ MDRV_SOUND_MODIFY("discrete") @@ -1352,6 +1353,7 @@ static MACHINE_DRIVER_START( dphla ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", 8080, DPHL_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(dphla_map) + MDRV_CPU_IO_MAP(norautp_portmap) /* sound hardware */ MDRV_SOUND_MODIFY("discrete") @@ -1365,6 +1367,7 @@ static MACHINE_DRIVER_START( kimbldhl ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", 8080, DPHL_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(kimbldhl_map) + MDRV_CPU_IO_MAP(norautp_portmap) /* sound hardware */ MDRV_SOUND_MODIFY("discrete") @@ -1378,6 +1381,7 @@ static MACHINE_DRIVER_START( dphltest ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", 8080, DPHL_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(dphltest_map) + MDRV_CPU_IO_MAP(norautp_portmap) /* sound hardware */ MDRV_SOUND_MODIFY("discrete") @@ -1391,6 +1395,7 @@ static MACHINE_DRIVER_START( drhl ) /* basic machine hardware */ MDRV_CPU_REPLACE("maincpu", 8080, DPHL_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(drhl_map) + MDRV_CPU_IO_MAP(norautp_portmap) /* sound hardware */ MDRV_SOUND_MODIFY("discrete") diff --git a/src/mame/drivers/nyny.c b/src/mame/drivers/nyny.c index c9b7fd0342d..a400a246996 100644 --- a/src/mame/drivers/nyny.c +++ b/src/mame/drivers/nyny.c @@ -465,7 +465,7 @@ static WRITE8_DEVICE_HANDLER( nyny_ay8910_37_port_a_w ) { /* not sure what this does */ - /*logerror("%x PORT A write %x at Y=%x X=%x\n", cpu_get_pc(space->cpu), data, video_screen_get_vpos(space->machine->primary_screen), video_screen_get_hpos(space->machine->primary_screen));*/ + /*logerror("%x PORT A write %x at Y=%x X=%x\n", cpu_get_pc(space->cpu), data, space->machine->primary_screen->vpos(), space->machine->primary_screen->hpos());*/ } diff --git a/src/mame/drivers/offtwall.c b/src/mame/drivers/offtwall.c index b7db515fb08..26828b55f00 100644 --- a/src/mame/drivers/offtwall.c +++ b/src/mame/drivers/offtwall.c @@ -57,7 +57,7 @@ static MACHINE_RESET( offtwall ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 1); + atarivc_reset(*machine->primary_screen, state->atarigen.atarivc_eof_data, 1); atarijsa_reset(); } @@ -71,13 +71,13 @@ static MACHINE_RESET( offtwall ) static READ16_HANDLER( offtwall_atarivc_r ) { - return atarivc_r(space->machine->primary_screen, offset); + return atarivc_r(*space->machine->primary_screen, offset); } static WRITE16_HANDLER( offtwall_atarivc_w ) { - atarivc_w(space->machine->primary_screen, offset, data, mem_mask); + atarivc_w(*space->machine->primary_screen, offset, data, mem_mask); } diff --git a/src/mame/drivers/ohmygod.c b/src/mame/drivers/ohmygod.c index 324d433113c..4494fed9198 100644 --- a/src/mame/drivers/ohmygod.c +++ b/src/mame/drivers/ohmygod.c @@ -349,8 +349,7 @@ static MACHINE_DRIVER_START( ohmygod ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 14000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 14000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/oneshot.c b/src/mame/drivers/oneshot.c index 80da17e313e..7b60ccff9a3 100644 --- a/src/mame/drivers/oneshot.c +++ b/src/mame/drivers/oneshot.c @@ -96,7 +96,7 @@ static WRITE16_DEVICE_HANDLER( soundbank_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, 0x40000 * ((data & 0x03) ^ 0x03)); + downcast(device)->set_bank_base(0x40000 * ((data & 0x03) ^ 0x03)); } } @@ -406,8 +406,7 @@ static MACHINE_DRIVER_START( oneshot ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/onetwo.c b/src/mame/drivers/onetwo.c index aaf741833e5..fa7ec53fdab 100644 --- a/src/mame/drivers/onetwo.c +++ b/src/mame/drivers/onetwo.c @@ -390,8 +390,7 @@ static MACHINE_DRIVER_START( onetwo ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000*2) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000*2, OKIM6295_PIN7_LOW) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/orbit.c b/src/mame/drivers/orbit.c index 3ae149cda64..1ca05391b30 100644 --- a/src/mame/drivers/orbit.c +++ b/src/mame/drivers/orbit.c @@ -33,7 +33,7 @@ Atari Orbit Driver static TIMER_DEVICE_CALLBACK( nmi_32v ) { - orbit_state *state = (orbit_state *)timer->machine->driver_data; + orbit_state *state = (orbit_state *)timer.machine->driver_data; int scanline = param; int nmistate = (scanline & 32) && (state->misc_flags & 4); cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE); @@ -50,7 +50,7 @@ static TIMER_CALLBACK( irq_off ) static INTERRUPT_GEN( orbit_interrupt ) { cpu_set_input_line(device, 0, ASSERT_LINE); - timer_set(device->machine, video_screen_get_time_until_vblank_end(device->machine->primary_screen), NULL, 0, irq_off); + timer_set(device->machine, device->machine->primary_screen->time_until_vblank_end(), NULL, 0, irq_off); } diff --git a/src/mame/drivers/othldrby.c b/src/mame/drivers/othldrby.c index e60c6b87776..c1d7dd5fa24 100644 --- a/src/mame/drivers/othldrby.c +++ b/src/mame/drivers/othldrby.c @@ -35,7 +35,7 @@ static READ16_HANDLER( pap ) static WRITE16_DEVICE_HANDLER( oki_bankswitch_w ) { if (ACCESSING_BITS_0_7) - okim6295_set_bank_base(device, (data & 1) * 0x40000); + downcast(device)->set_bank_base((data & 1) * 0x40000); } static WRITE16_HANDLER( coinctrl_w ) @@ -268,8 +268,7 @@ static MACHINE_DRIVER_START( othldrby ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1584000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1584000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/paradise.c b/src/mame/drivers/paradise.c index ba6e5469d3a..2d6a4930c6e 100644 --- a/src/mame/drivers/paradise.c +++ b/src/mame/drivers/paradise.c @@ -60,7 +60,7 @@ static WRITE8_DEVICE_HANDLER( paradise_okibank_w ) if (data & ~0x02) logerror("%s: unknown oki bank bits %02X\n", cpuexec_describe_context(device->machine), data); - okim6295_set_bank_base(device, (data & 0x02) ? 0x40000 : 0); + downcast(device)->set_bank_base((data & 0x02) ? 0x40000 : 0); } static WRITE8_HANDLER( torus_coin_counter_w ) @@ -593,12 +593,10 @@ static MACHINE_DRIVER_START( paradise ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_12MHz/12) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki1", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_12MHz/12) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki2", XTAL_12MHz/12, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/pasha2.c b/src/mame/drivers/pasha2.c index 1e8660e060b..64423b9d2ef 100644 --- a/src/mame/drivers/pasha2.c +++ b/src/mame/drivers/pasha2.c @@ -201,7 +201,7 @@ static WRITE16_DEVICE_HANDLER( oki_w ) static WRITE16_DEVICE_HANDLER( oki_bank_w ) { if (offset) - okim6295_set_bank_base(device, (data & 1) * 0x40000); + downcast(device)->set_bank_base((data & 1) * 0x40000); } static WRITE16_HANDLER( pasha2_lamps_w ) @@ -443,12 +443,10 @@ static MACHINE_DRIVER_START( pasha2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) //and ATMEL DREAM SAM9773 diff --git a/src/mame/drivers/pass.c b/src/mame/drivers/pass.c index 8d1ae70b808..404845c9382 100644 --- a/src/mame/drivers/pass.c +++ b/src/mame/drivers/pass.c @@ -265,8 +265,7 @@ static MACHINE_DRIVER_START( pass ) MDRV_SOUND_ADD("ymsnd", YM2203, 14318180/4) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 792000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 792000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/pcat_dyn.c b/src/mame/drivers/pcat_dyn.c index 7015ec7fcfa..72cf5b5d414 100644 --- a/src/mame/drivers/pcat_dyn.c +++ b/src/mame/drivers/pcat_dyn.c @@ -34,12 +34,12 @@ static UINT8 vga_regs[0x19]; #define SET_VISIBLE_AREA(_x_,_y_) \ { \ - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \ + rectangle visarea; \ visarea.min_x = 0; \ visarea.max_x = _x_-1; \ visarea.min_y = 0; \ visarea.max_y = _y_-1; \ - video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \ + machine->primary_screen->configure(_x_, _y_, visarea, machine->primary_screen->frame_period().attoseconds ); \ } \ #define RES_320x200 0 diff --git a/src/mame/drivers/pcat_nit.c b/src/mame/drivers/pcat_nit.c index b5296289164..95ddff8bcbd 100644 --- a/src/mame/drivers/pcat_nit.c +++ b/src/mame/drivers/pcat_nit.c @@ -91,12 +91,6 @@ Smitdogg #include "video/pc_vga.h" #include "video/pc_video.h" -/************************************* - * - * Microtouch <-> ins8250 interface - * - *************************************/ - static void pcat_nit_microtouch_tx_callback(running_machine *machine, UINT8 data) { ins8250_receive(machine->device("ns16450_0"), data); diff --git a/src/mame/drivers/pcxt.c b/src/mame/drivers/pcxt.c index 11ec234661d..471a441b346 100644 --- a/src/mame/drivers/pcxt.c +++ b/src/mame/drivers/pcxt.c @@ -72,12 +72,12 @@ the main program is 9th October 1990. #define SET_VISIBLE_AREA(_x_,_y_) \ { \ - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \ + rectangle visarea; \ visarea.min_x = 0; \ visarea.max_x = _x_-1; \ visarea.min_y = 0; \ visarea.max_y = _y_-1; \ - video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \ + machine->primary_screen->configure(_x_, _y_, visarea, machine->primary_screen->frame_period().attoseconds ); \ } \ @@ -116,15 +116,15 @@ static READ8_HANDLER( vga_hvretrace_r ) static UINT8 res; static int h,w; res = 0; - h = video_screen_get_height(space->machine->primary_screen); - w = video_screen_get_width(space->machine->primary_screen); + h = space->machine->primary_screen->height(); + w = space->machine->primary_screen->width(); // popmessage("%d %d",h,w); - if (video_screen_get_hpos(space->machine->primary_screen) > h) + if (space->machine->primary_screen->hpos() > h) res|= 1; - if (video_screen_get_vpos(space->machine->primary_screen) > w) + if (space->machine->primary_screen->vpos() > w) res|= 8; return res; diff --git a/src/mame/drivers/peplus.c b/src/mame/drivers/peplus.c index 853c00b1eb0..ecc5cca852e 100644 --- a/src/mame/drivers/peplus.c +++ b/src/mame/drivers/peplus.c @@ -336,13 +336,13 @@ static void handle_lightpen( running_device *device ) { int x_val = input_port_read_safe(device->machine, "TOUCH_X",0x00); int y_val = input_port_read_safe(device->machine, "TOUCH_Y",0x00); - const rectangle *vis_area = video_screen_get_visible_area(device->machine->primary_screen); + const rectangle &vis_area = device->machine->primary_screen->visible_area(); int xt, yt; - xt = x_val * (vis_area->max_x - vis_area->min_x) / 1024 + vis_area->min_x; - yt = y_val * (vis_area->max_y - vis_area->min_y) / 1024 + vis_area->min_y; + xt = x_val * (vis_area.max_x - vis_area.min_x) / 1024 + vis_area.min_x; + yt = y_val * (vis_area.max_y - vis_area.min_y) / 1024 + vis_area.min_y; - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, yt, xt), (void *) device, 0, assert_lp_cb); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(yt, xt), (void *) device, 0, assert_lp_cb); } static WRITE_LINE_DEVICE_HANDLER(crtc_vsync) diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index d647b8bde44..d27292239b5 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -1471,7 +1471,7 @@ static MACHINE_DRIVER_START( kov_disabled_arm ) /* protection CPU */ MDRV_CPU_ADD("prot", ARM7, 20000000) // 55857E/F/G MDRV_CPU_PROGRAM_MAP(kovsh_arm7_map) - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MACHINE_DRIVER_END diff --git a/src/mame/drivers/phoenix.c b/src/mame/drivers/phoenix.c index 43d46520a76..2727e35a0e6 100644 --- a/src/mame/drivers/phoenix.c +++ b/src/mame/drivers/phoenix.c @@ -563,6 +563,7 @@ static MACHINE_DRIVER_START( condor ) MDRV_IMPORT_FROM(phoenix) /* FIXME: Verify clock. This is most likely 11MHz/2 */ MDRV_CPU_REPLACE("maincpu", Z80, 11000000/4) /* 2.75 MHz??? */ + MDRV_CPU_PROGRAM_MAP(phoenix_memory_map) MACHINE_DRIVER_END diff --git a/src/mame/drivers/photoply.c b/src/mame/drivers/photoply.c index bb3f0ed15fa..912ef4f0d63 100644 --- a/src/mame/drivers/photoply.c +++ b/src/mame/drivers/photoply.c @@ -31,12 +31,12 @@ static UINT8 vga_regs[0x19]; #define SET_VISIBLE_AREA(_x_,_y_) \ { \ - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \ + rectangle visarea; \ visarea.min_x = 0; \ visarea.max_x = _x_-1; \ visarea.min_y = 0; \ visarea.max_y = _y_-1; \ - video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \ + machine->primary_screen->configure(_x_, _y_, visarea, machine->primary_screen->frame_period().attoseconds ); \ } \ #define RES_320x200 0 diff --git a/src/mame/drivers/pipeline.c b/src/mame/drivers/pipeline.c index c8dac4f3402..a339c3befc7 100644 --- a/src/mame/drivers/pipeline.c +++ b/src/mame/drivers/pipeline.c @@ -295,7 +295,7 @@ static Z80CTC_INTERFACE( ctc_intf ) DEVCB_NULL // ZC/TO2 callback }; -static const z80_daisy_chain daisy_chain_sound[] = +static const z80_daisy_config daisy_chain_sound[] = { { "ctc" }, { NULL } diff --git a/src/mame/drivers/pirates.c b/src/mame/drivers/pirates.c index c2c2028457c..261d4e2f717 100644 --- a/src/mame/drivers/pirates.c +++ b/src/mame/drivers/pirates.c @@ -119,7 +119,7 @@ static WRITE16_HANDLER( pirates_out_w ) { if (ACCESSING_BITS_0_7) { - running_device *eeprom = devtag_get_device(space->machine, "eeprom"); + eeprom_device *eeprom = space->machine->device("eeprom"); /* bits 0-2 control EEPROM */ eeprom_write_bit(eeprom, data & 0x04); @@ -127,7 +127,8 @@ static WRITE16_HANDLER( pirates_out_w ) eeprom_set_clock_line(eeprom, (data & 0x02) ? ASSERT_LINE : CLEAR_LINE); /* bit 6 selects oki bank */ - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x40) ? 0x40000 : 0x00000); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base((data & 0x40) ? 0x40000 : 0x00000); /* bit 7 used (function unknown) */ } @@ -293,8 +294,7 @@ static MACHINE_DRIVER_START( pirates ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1333333) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 1333333, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/pkscram.c b/src/mame/drivers/pkscram.c index 3e5c510f671..e613dd05590 100644 --- a/src/mame/drivers/pkscram.c +++ b/src/mame/drivers/pkscram.c @@ -25,7 +25,6 @@ static UINT16* pkscramble_mdtilemap_ram; static UINT16* pkscramble_bgtilemap_ram; static tilemap_t *fg_tilemap, *md_tilemap, *bg_tilemap; -static running_device *scanline_timer; static WRITE16_HANDLER( pkscramble_fgtilemap_w ) { @@ -196,15 +195,15 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) if (param == interrupt_scanline) { if (out & 0x2000) - cputag_set_input_line(timer->machine, "maincpu", 1, ASSERT_LINE); - timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param + 1, 0), param+1); + cputag_set_input_line(timer.machine, "maincpu", 1, ASSERT_LINE); + timer.adjust(timer.machine->primary_screen->time_until_pos(param + 1), param+1); interrupt_line_active = 1; } else { if (interrupt_line_active) - cputag_set_input_line(timer->machine, "maincpu", 1, CLEAR_LINE); - timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, interrupt_scanline, 0), interrupt_scanline); + cputag_set_input_line(timer.machine, "maincpu", 1, CLEAR_LINE); + timer.adjust(timer.machine->primary_screen->time_until_pos(interrupt_scanline), interrupt_scanline); interrupt_line_active = 0; } } @@ -269,8 +268,8 @@ static MACHINE_RESET( pkscramble) { out = 0; interrupt_line_active=0; - scanline_timer = devtag_get_device(machine, "scan_timer"); - timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline); + timer_device *scanline_timer = machine->device("scan_timer"); + scanline_timer->adjust(machine->primary_screen->time_until_pos(interrupt_scanline), interrupt_scanline); } static MACHINE_DRIVER_START( pkscramble ) diff --git a/src/mame/drivers/pktgaldx.c b/src/mame/drivers/pktgaldx.c index 7cd9ee5f9f5..6ff664815de 100644 --- a/src/mame/drivers/pktgaldx.c +++ b/src/mame/drivers/pktgaldx.c @@ -65,7 +65,7 @@ bootleg todo: static WRITE16_DEVICE_HANDLER(pktgaldx_oki_bank_w) { - okim6295_set_bank_base(device, (data & 3) * 0x40000); + downcast(device)->set_bank_base((data & 3) * 0x40000); } /**********************************************************************************/ @@ -348,13 +348,11 @@ static MACHINE_DRIVER_START( pktgaldx ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) MACHINE_DRIVER_END @@ -388,13 +386,11 @@ static MACHINE_DRIVER_START( pktgaldb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/playmark.c b/src/mame/drivers/playmark.c index 6aa6cce524e..01a07fe2c0f 100644 --- a/src/mame/drivers/playmark.c +++ b/src/mame/drivers/playmark.c @@ -172,7 +172,7 @@ static WRITE8_DEVICE_HANDLER( playmark_oki_banking_w ) if (((state->old_oki_bank - 1) * 0x40000) < memory_region_length(device->machine, "oki")) { - okim6295_set_bank_base(device, 0x40000 * (state->old_oki_bank - 1)); + downcast(device)->set_bank_base(0x40000 * (state->old_oki_bank - 1)); } } } @@ -979,8 +979,7 @@ static MACHINE_DRIVER_START( bigtwin ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1022,8 +1021,7 @@ static MACHINE_DRIVER_START( wbeachvl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1061,8 +1059,7 @@ static MACHINE_DRIVER_START( excelsr ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1103,8 +1100,7 @@ static MACHINE_DRIVER_START( hotmind ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1MHz) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_1MHz, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1142,8 +1138,7 @@ static MACHINE_DRIVER_START( hrdtimes ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1MHz) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_1MHz, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/pokechmp.c b/src/mame/drivers/pokechmp.c index 8bfea8cc716..0ef029614f3 100644 --- a/src/mame/drivers/pokechmp.c +++ b/src/mame/drivers/pokechmp.c @@ -262,8 +262,7 @@ static MACHINE_DRIVER_START( pokechmp ) MDRV_SOUND_ADD("ym2", YM3812, 3000000) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 4000000/4) // ?? unknown frequency - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 4000000/4, OKIM6295_PIN7_HIGH) // ?? unknown frequency MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) /* sound fx */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/polepos.c b/src/mame/drivers/polepos.c index aad62e19058..69ae171c554 100644 --- a/src/mame/drivers/polepos.c +++ b/src/mame/drivers/polepos.c @@ -288,7 +288,7 @@ static READ8_HANDLER( polepos_ready_r ) { int ret = 0xff; - if (video_screen_get_vpos(space->machine->primary_screen) >= 128) + if (space->machine->primary_screen->vpos() >= 128) ret ^= 0x02; ret ^= 0x08; /* ADC End Flag */ diff --git a/src/mame/drivers/policetr.c b/src/mame/drivers/policetr.c index 370f95094ff..3ec7ec4303f 100644 --- a/src/mame/drivers/policetr.c +++ b/src/mame/drivers/policetr.c @@ -128,7 +128,7 @@ static TIMER_CALLBACK( irq5_gen ) static INTERRUPT_GEN( irq4_gen ) { cpu_set_input_line(device, R3000_IRQ4, ASSERT_LINE); - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), NULL, 0, irq5_gen); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, irq5_gen); } diff --git a/src/mame/drivers/polyplay.c b/src/mame/drivers/polyplay.c index 1298ca9b1b5..a0ce2240ff2 100644 --- a/src/mame/drivers/polyplay.c +++ b/src/mame/drivers/polyplay.c @@ -97,7 +97,7 @@ static int channel2_const; /* timer handling */ static TIMER_DEVICE_CALLBACK( polyplay_timer_callback ); -static running_device* polyplay_timer; +static timer_device* polyplay_timer; static WRITE8_HANDLER( polyplay_start_timer2 ); static WRITE8_HANDLER( polyplay_sound_channel ); @@ -123,7 +123,7 @@ static MACHINE_RESET( polyplay ) polyplay_set_channel2(0); polyplay_play_channel2(machine, 0); - polyplay_timer = devtag_get_device(machine, "timer"); + polyplay_timer = machine->device("timer"); } @@ -234,10 +234,10 @@ static WRITE8_HANDLER( polyplay_sound_channel ) static WRITE8_HANDLER( polyplay_start_timer2 ) { if (data == 0x03) - timer_device_adjust_oneshot(polyplay_timer, attotime_never, 0); + polyplay_timer->reset(); if (data == 0xb5) - timer_device_adjust_periodic(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40)); + polyplay_timer->adjust(ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40)); } static READ8_HANDLER( polyplay_random_read ) @@ -359,7 +359,7 @@ ROM_END static TIMER_DEVICE_CALLBACK( polyplay_timer_callback ) { - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0, HOLD_LINE, 0x4c); + cputag_set_input_line_and_vector(timer.machine, "maincpu", 0, HOLD_LINE, 0x4c); } /* game driver */ diff --git a/src/mame/drivers/powerbal.c b/src/mame/drivers/powerbal.c index b053a19a695..39f6cdbf590 100644 --- a/src/mame/drivers/powerbal.c +++ b/src/mame/drivers/powerbal.c @@ -70,7 +70,7 @@ static WRITE16_DEVICE_HANDLER( oki_banking ) int addr = 0x40000 * ((data & 3) - 1); if (addr < memory_region_length(device->machine, "oki")) - okim6295_set_bank_base(device, addr); + downcast(device)->set_bank_base(addr); } } @@ -513,8 +513,7 @@ static MACHINE_DRIVER_START( powerbal ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -551,8 +550,7 @@ static MACHINE_DRIVER_START( magicstk ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/powerins.c b/src/mame/drivers/powerins.c index 11cf30c575f..320059e37b0 100644 --- a/src/mame/drivers/powerins.c +++ b/src/mame/drivers/powerins.c @@ -387,12 +387,10 @@ static MACHINE_DRIVER_START( powerins ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 4000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki1", 4000000, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) - MDRV_SOUND_ADD("oki2", OKIM6295, 4000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", 4000000, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) MDRV_SOUND_ADD("ym2203", YM2203, 12000000 / 8) @@ -415,8 +413,7 @@ static MACHINE_DRIVER_START( powerina ) MDRV_DEVICE_REMOVE("soundcpu") - MDRV_SOUND_REPLACE("oki1", OKIM6295, 990000) // pin7 not verified - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_REPLACE("oki1", 990000, OKIM6295_PIN7_LOW) // pin7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_DEVICE_REMOVE("oki2") diff --git a/src/mame/drivers/psikyo.c b/src/mame/drivers/psikyo.c index 604ba76f1a0..76a19dd6ac3 100644 --- a/src/mame/drivers/psikyo.c +++ b/src/mame/drivers/psikyo.c @@ -1186,8 +1186,7 @@ static MACHINE_DRIVER_START( s1945bl ) /* Bootleg hardware based on the unprotec /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) // ?? clock - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // ?? pin 7 + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_LOW) // ?? clock MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_DEVICE_ADDRESS_MAP(0, s1945bl_oki_map) MACHINE_DRIVER_END diff --git a/src/mame/drivers/puckpkmn.c b/src/mame/drivers/puckpkmn.c index 4b91912ab25..c9db9c8b48e 100644 --- a/src/mame/drivers/puckpkmn.c +++ b/src/mame/drivers/puckpkmn.c @@ -157,8 +157,7 @@ static MACHINE_DRIVER_START( puckpkmn ) MDRV_DEVICE_REMOVE("genesis_snd_z80") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker",0.25) MACHINE_DRIVER_END diff --git a/src/mame/drivers/pzletime.c b/src/mame/drivers/pzletime.c index 15f66578711..ea65c6bf7b5 100644 --- a/src/mame/drivers/pzletime.c +++ b/src/mame/drivers/pzletime.c @@ -128,7 +128,7 @@ static VIDEO_UPDATE( pzletime ) } tilemap_draw(bitmap, cliprect, state->txt_tilemap, 0, 0); - if ((video_screen_get_frame_number(screen) % 16) != 0) + if ((screen->frame_number() % 16) != 0) tilemap_draw(bitmap, cliprect, state->txt_tilemap, 1, 0); return 0; @@ -197,13 +197,13 @@ static WRITE16_HANDLER( video_regs_w ) static WRITE16_DEVICE_HANDLER( oki_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 0x3)); + downcast(device)->set_bank_base(0x40000 * (data & 0x3)); } static CUSTOM_INPUT( ticket_status_r ) { pzletime_state *state = (pzletime_state *)field->port->machine->driver_data; - return (state->ticket && !(video_screen_get_frame_number(field->port->machine->primary_screen) % 128)); + return (state->ticket && !(field->port->machine->primary_screen->frame_number() % 128)); } static ADDRESS_MAP_START( pzletime_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -337,8 +337,7 @@ static MACHINE_DRIVER_START( pzletime ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 937500) //freq & pin7 taken from stlforce - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 937500, OKIM6295_PIN7_HIGH) //freq & pin7 taken from stlforce MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/quizdna.c b/src/mame/drivers/quizdna.c index c3d39c25ac9..8dfad94e826 100644 --- a/src/mame/drivers/quizdna.c +++ b/src/mame/drivers/quizdna.c @@ -484,8 +484,7 @@ static MACHINE_DRIVER_START( quizdna ) MDRV_SOUND_ROUTE(2, "mono", 0.10) MDRV_SOUND_ROUTE(3, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, (MCLK/1024)*132) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", (MCLK/1024)*132, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_DRIVER_END diff --git a/src/mame/drivers/quizpani.c b/src/mame/drivers/quizpani.c index dff9963196b..d984c2d3df3 100644 --- a/src/mame/drivers/quizpani.c +++ b/src/mame/drivers/quizpani.c @@ -261,8 +261,7 @@ static MACHINE_DRIVER_START( quizpani ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 16000000/4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", 16000000/4, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_NMK112_ADD("nmk112", quizpani_nmk112_intf) diff --git a/src/mame/drivers/rabbit.c b/src/mame/drivers/rabbit.c index e16ccc6b2d3..bf84cd1ae25 100644 --- a/src/mame/drivers/rabbit.c +++ b/src/mame/drivers/rabbit.c @@ -362,7 +362,7 @@ static VIDEO_START(rabbit) tilemap_map_pen_to_layer(rabbit_tilemap[3], 0, 15, TILEMAP_PIXEL_TRANSPARENT); tilemap_map_pen_to_layer(rabbit_tilemap[3], 1, 255, TILEMAP_PIXEL_TRANSPARENT); - rabbit_sprite_bitmap = auto_bitmap_alloc(machine,0x1000,0x1000,video_screen_get_format(machine->primary_screen)); + rabbit_sprite_bitmap = auto_bitmap_alloc(machine,0x1000,0x1000,machine->primary_screen->format()); rabbit_sprite_clip.min_x = 0; rabbit_sprite_clip.max_x = 0x1000-1; rabbit_sprite_clip.min_y = 0; diff --git a/src/mame/drivers/raiden2.c b/src/mame/drivers/raiden2.c index e6dcc07593c..da4c7ae02fb 100644 --- a/src/mame/drivers/raiden2.c +++ b/src/mame/drivers/raiden2.c @@ -2300,8 +2300,7 @@ static MACHINE_DRIVER_START( rdx_v33 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/rampart.c b/src/mame/drivers/rampart.c index 112bf50fc47..0ab022b7946 100644 --- a/src/mame/drivers/rampart.c +++ b/src/mame/drivers/rampart.c @@ -45,11 +45,11 @@ static void update_interrupts(running_machine *machine) } -static void scanline_update(running_device *screen, int scanline) +static void scanline_update(screen_device &screen, int scanline) { /* generate 32V signals */ if ((scanline & 32) == 0) - atarigen_scanline_int_gen(devtag_get_device(screen->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(screen.machine, "maincpu")); } @@ -73,7 +73,7 @@ static MACHINE_RESET( rampart ) atarigen_eeprom_reset(&state->atarigen); atarigen_slapstic_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32); + atarigen_scanline_timer_reset(*machine->primary_screen, scanline_update, 32); } @@ -371,8 +371,7 @@ static MACHINE_DRIVER_START( rampart ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MASTER_CLOCK/4/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", MASTER_CLOCK/4/3, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MDRV_SOUND_ADD("ymsnd", YM2413, MASTER_CLOCK/4) diff --git a/src/mame/drivers/rbmk.c b/src/mame/drivers/rbmk.c index 65630fb7cdd..7dd6cf155e8 100644 --- a/src/mame/drivers/rbmk.c +++ b/src/mame/drivers/rbmk.c @@ -486,8 +486,7 @@ static MACHINE_DRIVER_START( rbmk ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/redalert.c b/src/mame/drivers/redalert.c index 7a492a84e9f..f0c3744574a 100644 --- a/src/mame/drivers/redalert.c +++ b/src/mame/drivers/redalert.c @@ -122,7 +122,7 @@ static READ8_HANDLER( redalert_interrupt_clear_r ) cputag_set_input_line(space->machine, "maincpu", M6502_IRQ_LINE, CLEAR_LINE); /* the result never seems to be actually used */ - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } diff --git a/src/mame/drivers/relief.c b/src/mame/drivers/relief.c index 7df68d723ca..aa1791bae46 100644 --- a/src/mame/drivers/relief.c +++ b/src/mame/drivers/relief.c @@ -47,13 +47,13 @@ static void update_interrupts(running_machine *machine) static READ16_HANDLER( relief_atarivc_r ) { - return atarivc_r(space->machine->primary_screen, offset); + return atarivc_r(*space->machine->primary_screen, offset); } static WRITE16_HANDLER( relief_atarivc_w ) { - atarivc_w(space->machine->primary_screen, offset, data, mem_mask); + atarivc_w(*space->machine->primary_screen, offset, data, mem_mask); } @@ -76,9 +76,9 @@ static MACHINE_RESET( relief ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); + atarivc_reset(*machine->primary_screen, state->atarigen.atarivc_eof_data, 2); - okim6295_set_bank_base(devtag_get_device(machine, "oki"), 0); + machine->device("oki")->set_bank_base(0); state->ym2413_volume = 15; state->overall_volume = 127; state->adpcm_bank_base = 0; @@ -97,7 +97,7 @@ static READ16_HANDLER( special_port2_r ) relief_state *state = (relief_state *)space->machine->driver_data; int result = input_port_read(space->machine, "260010"); if (state->atarigen.cpu_to_sound_ready) result ^= 0x0020; - if (!(result & 0x0080) || atarigen_get_hblank(space->machine->primary_screen)) result ^= 0x0001; + if (!(result & 0x0080) || atarigen_get_hblank(*space->machine->primary_screen)) result ^= 0x0001; return result; } @@ -121,7 +121,8 @@ static WRITE16_HANDLER( audio_control_w ) if (ACCESSING_BITS_8_15) state->adpcm_bank_base = (0x100000 * ((data >> 8) & 1)) | (state->adpcm_bank_base & 0x0c0000); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), state->adpcm_bank_base); + okim6295_device *oki = space->machine->device("oki"); + oki->set_bank_base(state->adpcm_bank_base); } @@ -320,8 +321,7 @@ static MACHINE_DRIVER_START( relief ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, ATARI_CLOCK_14MHz/4/3) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", ATARI_CLOCK_14MHz/4/3, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("ymsnd", YM2413, ATARI_CLOCK_14MHz/4) diff --git a/src/mame/drivers/renegade.c b/src/mame/drivers/renegade.c index 786d3823431..3465c57e02b 100644 --- a/src/mame/drivers/renegade.c +++ b/src/mame/drivers/renegade.c @@ -129,7 +129,7 @@ static UINT8 bank; static struct renegade_adpcm_state { - struct adpcm_state adpcm; + adpcm_state adpcm; sound_stream *stream; UINT32 current, end; UINT8 nibble; @@ -154,7 +154,7 @@ static STREAM_UPDATE( renegade_adpcm_callback ) state->playing = 0; } - *dest++ = clock_adpcm(&state->adpcm, val) << 4; + *dest++ = state->adpcm.clock(val) << 4; samples--; } while (samples > 0) @@ -169,12 +169,12 @@ static DEVICE_START( renegade_adpcm ) running_machine *machine = device->machine; struct renegade_adpcm_state *state = &renegade_adpcm; state->playing = 0; - state->stream = stream_create(device, 0, 1, device->clock, state, renegade_adpcm_callback); + state->stream = stream_create(device, 0, 1, device->clock(), state, renegade_adpcm_callback); state->base = memory_region(machine, "adpcm"); - reset_adpcm(&state->adpcm); + state->adpcm.reset(); } -static DEVICE_GET_INFO( renegade_adpcm ) +DEVICE_GET_INFO( renegade_adpcm ) { switch (state) { @@ -187,7 +187,7 @@ static DEVICE_GET_INFO( renegade_adpcm ) } } -#define SOUND_RENEGADE_ADPCM DEVICE_GET_INFO_NAME(renegade_adpcm) +DECLARE_LEGACY_SOUND_DEVICE(RENEGADE_ADPCM, renegade_adpcm); static WRITE8_HANDLER( adpcm_play_w ) diff --git a/src/mame/drivers/rohga.c b/src/mame/drivers/rohga.c index 22de2c00726..c5660140226 100644 --- a/src/mame/drivers/rohga.c +++ b/src/mame/drivers/rohga.c @@ -112,7 +112,6 @@ #include "includes/rohga.h" #include "sound/2151intf.h" #include "sound/okim6295.h" -#include "video/deco16ic.h" static READ16_HANDLER( rohga_irq_ack_r ) @@ -730,8 +729,8 @@ static void sound_irq(running_device *device, int state) static WRITE8_DEVICE_HANDLER( sound_bankswitch_w ) { rohga_state *state = (rohga_state *)device->machine->driver_data; - okim6295_set_bank_base(state->oki1, BIT(data, 0) * 0x40000); - okim6295_set_bank_base(state->oki2, BIT(data, 1) * 0x40000); + state->oki1->set_bank_base(BIT(data, 0) * 0x40000); + state->oki2->set_bank_base(BIT(data, 1) * 0x40000); } static const ym2151_interface ym2151_config = @@ -773,17 +772,6 @@ static const deco16ic_interface nitrobal_deco16ic_intf = rohga_bank_callback }; -static MACHINE_START( rohga ) -{ - rohga_state *state = (rohga_state *)machine->driver_data; - - state->maincpu = devtag_get_device(machine, "maincpu"); - state->audiocpu = devtag_get_device(machine, "audiocpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->oki1 = devtag_get_device(machine, "oki1"); - state->oki2 = devtag_get_device(machine, "oki2"); -} - static MACHINE_DRIVER_START( rohga ) /* driver data */ @@ -797,8 +785,6 @@ static MACHINE_DRIVER_START( rohga ) MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */ MDRV_CPU_PROGRAM_MAP(rohga_sound_map) - MDRV_MACHINE_START(rohga) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -825,13 +811,11 @@ static MACHINE_DRIVER_START( rohga ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.78) MDRV_SOUND_ROUTE(1, "rspeaker", 0.78) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END @@ -849,8 +833,6 @@ static MACHINE_DRIVER_START( wizdfire ) MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */ MDRV_CPU_PROGRAM_MAP(rohga_sound_map) - MDRV_MACHINE_START(rohga) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) @@ -876,13 +858,11 @@ static MACHINE_DRIVER_START( wizdfire ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END @@ -900,8 +880,6 @@ static MACHINE_DRIVER_START( nitrobal ) MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */ MDRV_CPU_PROGRAM_MAP(rohga_sound_map) - MDRV_MACHINE_START(rohga) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) @@ -927,13 +905,11 @@ static MACHINE_DRIVER_START( nitrobal ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END @@ -951,8 +927,6 @@ static MACHINE_DRIVER_START( schmeisr ) MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */ MDRV_CPU_PROGRAM_MAP(rohga_sound_map) - MDRV_MACHINE_START(rohga) - /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -979,13 +953,11 @@ static MACHINE_DRIVER_START( schmeisr ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.80) MDRV_SOUND_ROUTE(1, "rspeaker", 0.80) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END diff --git a/src/mame/drivers/rotaryf.c b/src/mame/drivers/rotaryf.c index cff304d9650..733f7cfb6d7 100644 --- a/src/mame/drivers/rotaryf.c +++ b/src/mame/drivers/rotaryf.c @@ -28,7 +28,7 @@ static size_t rotaryf_videoram_size; static INTERRUPT_GEN( rotaryf_interrupt ) { - if (video_screen_get_vblank(device->machine->primary_screen)) + if (device->machine->primary_screen->vblank()) cpu_set_input_line(device, I8085_RST55_LINE, HOLD_LINE); else { diff --git a/src/mame/drivers/royalmah.c b/src/mame/drivers/royalmah.c index e7c9c25b439..55add6ce9d1 100644 --- a/src/mame/drivers/royalmah.c +++ b/src/mame/drivers/royalmah.c @@ -3127,7 +3127,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( janoh ) MDRV_IMPORT_FROM(royalmah) - MDRV_CPU_REPLACE("maincpu", Z80, 8000000/2) /* 4 MHz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(8000000/2) /* 4 MHz ? */ MDRV_CPU_PROGRAM_MAP(janho_map) MDRV_CPU_ADD("sub", Z80, 4000000) /* 4 MHz ? */ @@ -3153,25 +3154,29 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( dondenmj ) MDRV_IMPORT_FROM(royalmah) - MDRV_CPU_REPLACE("maincpu", Z80, 8000000/2) /* 4 MHz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(8000000/2) /* 4 MHz ? */ MDRV_CPU_IO_MAP(dondenmj_iomap) MACHINE_DRIVER_END static MACHINE_DRIVER_START( makaijan ) MDRV_IMPORT_FROM(royalmah) - MDRV_CPU_REPLACE("maincpu", Z80, 8000000/2) /* 4 MHz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(8000000/2) /* 4 MHz ? */ MDRV_CPU_IO_MAP(makaijan_iomap) MACHINE_DRIVER_END static MACHINE_DRIVER_START( daisyari ) MDRV_IMPORT_FROM(royalmah) - MDRV_CPU_REPLACE("maincpu", Z80, 8000000/2) /* 4 MHz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(8000000/2) /* 4 MHz ? */ MDRV_CPU_IO_MAP(daisyari_iomap) MACHINE_DRIVER_END static MACHINE_DRIVER_START( mjclub ) MDRV_IMPORT_FROM(royalmah) - MDRV_CPU_REPLACE("maincpu", Z80, 8000000/2) /* 4 MHz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(8000000/2) /* 4 MHz ? */ MDRV_CPU_IO_MAP(mjclub_iomap) MACHINE_DRIVER_END diff --git a/src/mame/drivers/runaway.c b/src/mame/drivers/runaway.c index 3d3306bf9ca..f7d175cb26c 100644 --- a/src/mame/drivers/runaway.c +++ b/src/mame/drivers/runaway.c @@ -41,7 +41,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 263) scanline = 16; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } static MACHINE_START( runaway ) @@ -51,7 +51,7 @@ static MACHINE_START( runaway ) static MACHINE_RESET( runaway ) { - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), 16); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(16), 16); } diff --git a/src/mame/drivers/sandscrp.c b/src/mame/drivers/sandscrp.c index 85830db275a..1014896e115 100644 --- a/src/mame/drivers/sandscrp.c +++ b/src/mame/drivers/sandscrp.c @@ -473,8 +473,7 @@ static MACHINE_DRIVER_START( sandscrp ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/6) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 12000000/6, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) diff --git a/src/mame/drivers/sangho.c b/src/mame/drivers/sangho.c index d41d5a7377d..4b4a3210ea3 100644 --- a/src/mame/drivers/sangho.c +++ b/src/mame/drivers/sangho.c @@ -266,7 +266,7 @@ static INTERRUPT_GEN( sangho_interrupt ) static VIDEO_START( sangho ) { VIDEO_START_CALL(generic_bitmapped); - v9938_init (machine, 0, machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, 0x20000, msx_vdp_interrupt); + v9938_init (machine, 0, *machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, 0x20000, msx_vdp_interrupt); } static MACHINE_DRIVER_START(pzlestar) diff --git a/src/mame/drivers/sbowling.c b/src/mame/drivers/sbowling.c index 50e9cd7917e..2b4c3b79079 100644 --- a/src/mame/drivers/sbowling.c +++ b/src/mame/drivers/sbowling.c @@ -120,7 +120,7 @@ static VIDEO_START(sbowling) { sbowling_state *state = (sbowling_state *)machine->driver_data; - state->tmpbitmap = auto_bitmap_alloc(machine,32*8,32*8,video_screen_get_format(machine->primary_screen)); + state->tmpbitmap = auto_bitmap_alloc(machine,32*8,32*8,machine->primary_screen->format()); state->sb_tilemap = tilemap_create(machine, get_sb_tile_info, tilemap_scan_rows, 8, 8, 32, 32); } @@ -156,7 +156,7 @@ static READ8_HANDLER( pix_data_r ) static INTERRUPT_GEN( sbw_interrupt ) { - int vector = video_screen_get_vblank(device->machine->primary_screen) ? 0xcf : 0xd7; /* RST 08h/10h */ + int vector = device->machine->primary_screen->vblank() ? 0xcf : 0xd7; /* RST 08h/10h */ cpu_set_input_line_and_vector(device, 0, HOLD_LINE, vector); } diff --git a/src/mame/drivers/sbrkout.c b/src/mame/drivers/sbrkout.c index e6be2da16de..589b44f465d 100644 --- a/src/mame/drivers/sbrkout.c +++ b/src/mame/drivers/sbrkout.c @@ -97,7 +97,7 @@ static MACHINE_START( sbrkout ) static MACHINE_RESET( sbrkout ) { - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -113,7 +113,7 @@ static TIMER_CALLBACK( scanline_callback ) int scanline = param; /* force a partial update before anything happens */ - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); /* if this is a rising edge of 16V, assert the CPU interrupt */ if (scanline % 32 == 16) @@ -123,17 +123,17 @@ static TIMER_CALLBACK( scanline_callback ) dac_data_w(devtag_get_device(machine, "dac"), (machine->generic.videoram.u8[0x380 + 0x11] & (scanline >> 2)) ? 255 : 0); /* on the VBLANK, read the pot and schedule an interrupt time for it */ - if (scanline == video_screen_get_visible_area(machine->primary_screen)->max_y + 1) + if (scanline == machine->primary_screen->visible_area().max_y + 1) { UINT8 potvalue = input_port_read(machine, "PADDLE"); - timer_adjust_oneshot(pot_timer, video_screen_get_time_until_pos(machine->primary_screen, 56 + (potvalue / 2), (potvalue % 2) * 128), 0); + timer_adjust_oneshot(pot_timer, machine->primary_screen->time_until_pos(56 + (potvalue / 2), (potvalue % 2) * 128), 0); } /* call us back in 4 scanlines */ scanline += 4; - if (scanline >= video_screen_get_height(machine->primary_screen)) + if (scanline >= machine->primary_screen->height()) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -258,9 +258,9 @@ static WRITE8_HANDLER( coincount_w ) static READ8_HANDLER( sync_r ) { - int hpos = video_screen_get_hpos(space->machine->primary_screen); - sync2_value = (hpos >= 128 && hpos <= video_screen_get_visible_area(space->machine->primary_screen)->max_x); - return video_screen_get_vpos(space->machine->primary_screen); + int hpos = space->machine->primary_screen->hpos(); + sync2_value = (hpos >= 128 && hpos <= space->machine->primary_screen->visible_area().max_x); + return space->machine->primary_screen->vpos(); } diff --git a/src/mame/drivers/scramble.c b/src/mame/drivers/scramble.c index 834f5c0ba49..0a3ee243dab 100644 --- a/src/mame/drivers/scramble.c +++ b/src/mame/drivers/scramble.c @@ -1469,7 +1469,8 @@ static MACHINE_DRIVER_START( hncholms ) /* basic machine hardware */ MDRV_IMPORT_FROM(hunchbks) - MDRV_CPU_REPLACE("maincpu", S2650, 18432000/6/2/2) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(18432000/6/2/2) MDRV_VIDEO_START(scorpion) MACHINE_DRIVER_END diff --git a/src/mame/drivers/sderby.c b/src/mame/drivers/sderby.c index 4ff2dc5c338..05f1fd7fa5d 100644 --- a/src/mame/drivers/sderby.c +++ b/src/mame/drivers/sderby.c @@ -476,8 +476,7 @@ static MACHINE_DRIVER_START( sderby ) MDRV_VIDEO_UPDATE(sderby) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -504,8 +503,7 @@ static MACHINE_DRIVER_START( spacewin ) MDRV_VIDEO_UPDATE(pmroulet) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -532,8 +530,7 @@ static MACHINE_DRIVER_START( pmroulet ) MDRV_VIDEO_UPDATE(pmroulet) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) /* clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/seattle.c b/src/mame/drivers/seattle.c index 0e66e392148..f2770253ad0 100644 --- a/src/mame/drivers/seattle.c +++ b/src/mame/drivers/seattle.c @@ -433,7 +433,7 @@ static UINT32 *rombase; static galileo_data galileo; static widget_data widget; -static running_device *voodoo_device; +static running_device *voodoo; static UINT8 voodoo_stalled; static UINT8 cpu_stalled_on_voodoo; static UINT32 cpu_stalled_offset; @@ -485,7 +485,7 @@ static void update_widget_irq(running_machine *machine); static VIDEO_UPDATE( seattle ) { - return voodoo_update(voodoo_device, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; + return voodoo_update(voodoo, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; } @@ -500,7 +500,7 @@ static MACHINE_START( seattle ) { int index; - voodoo_device = devtag_get_device(machine, "voodoo"); + voodoo = devtag_get_device(machine, "voodoo"); /* allocate timers for the galileo */ galileo.timer[0].timer = timer_alloc(machine, galileo_timer_callback, NULL); @@ -828,7 +828,7 @@ static void pci_3dfx_w(const address_space *space, UINT8 reg, UINT8 type, UINT32 break; case 0x10: /* initEnable register */ - voodoo_set_init_enable(voodoo_device, data); + voodoo_set_init_enable(voodoo, data); break; } if (LOG_PCI) @@ -1016,7 +1016,7 @@ static void galileo_perform_dma(const address_space *space, int which) } /* write the data and advance */ - voodoo_w(voodoo_device, (dstaddr & 0xffffff) / 4, memory_read_dword(space, srcaddr), 0xffffffff); + voodoo_w(voodoo, (dstaddr & 0xffffff) / 4, memory_read_dword(space, srcaddr), 0xffffffff); srcaddr += srcinc; dstaddr += dstinc; bytesleft -= 4; @@ -1298,7 +1298,7 @@ static WRITE32_HANDLER( seattle_voodoo_w ) /* if we're not stalled, just write and get out */ if (!voodoo_stalled) { - voodoo_w(voodoo_device, offset, data, mem_mask); + voodoo_w(voodoo, offset, data, mem_mask); return; } @@ -2493,14 +2493,20 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( phoenixsa ) MDRV_IMPORT_FROM(seattle_common) MDRV_IMPORT_FROM(dcs2_audio_2115) + MDRV_CPU_REPLACE("maincpu", R4700LE, SYSTEM_CLOCK*2) + MDRV_CPU_CONFIG(config) + MDRV_CPU_PROGRAM_MAP(seattle_map) MACHINE_DRIVER_END static MACHINE_DRIVER_START( seattle150 ) MDRV_IMPORT_FROM(seattle_common) MDRV_IMPORT_FROM(dcs2_audio_2115) + MDRV_CPU_REPLACE("maincpu", R5000LE, SYSTEM_CLOCK*3) + MDRV_CPU_CONFIG(config) + MDRV_CPU_PROGRAM_MAP(seattle_map) MACHINE_DRIVER_END @@ -2513,7 +2519,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( seattle200 ) MDRV_IMPORT_FROM(seattle_common) MDRV_IMPORT_FROM(dcs2_audio_2115) + MDRV_CPU_REPLACE("maincpu", R5000LE, SYSTEM_CLOCK*4) + MDRV_CPU_CONFIG(config) + MDRV_CPU_PROGRAM_MAP(seattle_map) MACHINE_DRIVER_END @@ -2526,7 +2535,10 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( flagstaff ) MDRV_IMPORT_FROM(seattle_common) MDRV_IMPORT_FROM(cage_seattle) + MDRV_CPU_REPLACE("maincpu", R5000LE, SYSTEM_CLOCK*4) + MDRV_CPU_CONFIG(config) + MDRV_CPU_PROGRAM_MAP(seattle_map) MDRV_SMC91C94_ADD("ethernet", ethernet_interrupt) diff --git a/src/mame/drivers/segac2.c b/src/mame/drivers/segac2.c index 6ccecb35aa0..dcde26cd8b3 100644 --- a/src/mame/drivers/segac2.c +++ b/src/mame/drivers/segac2.c @@ -422,7 +422,7 @@ static WRITE16_HANDLER( io_chip_w ) newbank = data & 3; if (newbank != palbank) { - //video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) + 1); + //space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() + 1); palbank = newbank; recompute_palette_tables(); } @@ -525,11 +525,11 @@ static WRITE16_HANDLER( prot_w ) /* if the palette changed, force an update */ if (new_sp_palbase != sp_palbase || new_bg_palbase != bg_palbase) { - //video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) + 1); + //space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() + 1); sp_palbase = new_sp_palbase; bg_palbase = new_bg_palbase; recompute_palette_tables(); - if (LOG_PALETTE) logerror("Set palbank: %d/%d (scan=%d)\n", bg_palbase, sp_palbase, video_screen_get_vpos(space->machine->primary_screen)); + if (LOG_PALETTE) logerror("Set palbank: %d/%d (scan=%d)\n", bg_palbase, sp_palbase, space->machine->primary_screen->vpos()); } } diff --git a/src/mame/drivers/segahang.c b/src/mame/drivers/segahang.c index a6c59f8e570..d86fc1bae15 100644 --- a/src/mame/drivers/segahang.c +++ b/src/mame/drivers/segahang.c @@ -949,11 +949,13 @@ static MACHINE_DRIVER_START( sharrier_base ) MDRV_IMPORT_FROM(hangon_base) /* basic machine hardware */ - MDRV_CPU_REPLACE("maincpu", M68000, MASTER_CLOCK_10MHz) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(MASTER_CLOCK_10MHz) MDRV_CPU_PROGRAM_MAP(sharrier_map) MDRV_CPU_VBLANK_INT("screen", i8751_main_cpu_vblank) - MDRV_CPU_REPLACE("sub", M68000, MASTER_CLOCK_10MHz) + MDRV_CPU_MODIFY("sub") + MDRV_CPU_CLOCK(MASTER_CLOCK_10MHz) /* video hardware */ MDRV_VIDEO_START(sharrier) @@ -1068,8 +1070,10 @@ static MACHINE_DRIVER_START( shangupb ) MDRV_IMPORT_FROM(sound_board_2151) /* not sure about these speeds, but at 6MHz, the road is not updated fast enough */ - MDRV_CPU_REPLACE("maincpu", M68000, 10000000) - MDRV_CPU_REPLACE("sub", M68000, 10000000) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(10000000) + MDRV_CPU_MODIFY("sub") + MDRV_CPU_CLOCK(10000000) MDRV_SEGA16SP_ADD_HANGON("segaspr1") MACHINE_DRIVER_END diff --git a/src/mame/drivers/segamsys.c b/src/mame/drivers/segamsys.c index 66f997737e3..e2a05d11b8e 100644 --- a/src/mame/drivers/segamsys.c +++ b/src/mame/drivers/segamsys.c @@ -1155,7 +1155,7 @@ static void end_of_frame(running_machine *machine, struct sms_vdp *chip) visarea.min_y = 0; visarea.max_y = sms_mode_table[chip->screen_mode].sms2_height-1; - if (chip->chip_id==3) video_screen_configure(machine->primary_screen, 256, 256, &visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); + if (chip->chip_id==3) machine->primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); } else /* 160x144 */ @@ -1166,7 +1166,7 @@ static void end_of_frame(running_machine *machine, struct sms_vdp *chip) visarea.min_y = (192-144)/2; visarea.max_y = (192-144)/2+144-1; - video_screen_configure(machine->primary_screen, 256, 256, &visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); + machine->primary_screen->configure(256, 256, visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate)); } diff --git a/src/mame/drivers/segaorun.c b/src/mame/drivers/segaorun.c index d75bd120aa4..13ddc688559 100644 --- a/src/mame/drivers/segaorun.c +++ b/src/mame/drivers/segaorun.c @@ -469,7 +469,7 @@ static TIMER_CALLBACK( scanline_callback ) case 65: case 129: case 193: - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, video_screen_get_visible_area(machine->primary_screen)->max_x + 1), NULL, 0, irq2_gen); + timer_set(machine, machine->primary_screen->time_until_pos(scanline, machine->primary_screen->visible_area().max_x + 1), NULL, 0, irq2_gen); next_scanline = scanline + 1; break; @@ -500,7 +500,7 @@ static TIMER_CALLBACK( scanline_callback ) update_main_irqs(machine); /* come back at the next targeted scanline */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, next_scanline, 0), NULL, next_scanline, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(next_scanline), NULL, next_scanline, scanline_callback); } @@ -533,7 +533,7 @@ static MACHINE_RESET( outrun ) m68k_set_reset_callback(devtag_get_device(machine, "maincpu"), outrun_reset); /* start timers to track interrupts */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), NULL, 223, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(223), NULL, 223, scanline_callback); } diff --git a/src/mame/drivers/segas16b.c b/src/mame/drivers/segas16b.c index dfbae662009..8fd89500e3f 100644 --- a/src/mame/drivers/segas16b.c +++ b/src/mame/drivers/segas16b.c @@ -1120,7 +1120,7 @@ static MACHINE_RESET( system16b ) static TIMER_DEVICE_CALLBACK( atomicp_sound_irq ) { - segas1x_state *state = (segas1x_state *)timer->machine->driver_data; + segas1x_state *state = (segas1x_state *)timer.machine->driver_data; if (++state->atomicp_sound_count >= state->atomicp_sound_divisor) { diff --git a/src/mame/drivers/segas24.c b/src/mame/drivers/segas24.c index 6676b973766..ebd1cc26e75 100644 --- a/src/mame/drivers/segas24.c +++ b/src/mame/drivers/segas24.c @@ -789,24 +789,24 @@ static UINT16 irq_timera; static UINT8 irq_timerb; static UINT8 irq_allow0, irq_allow1; static int irq_timer_pend0, irq_timer_pend1, irq_yms, irq_vblank, irq_sprite; -static running_device *irq_timer, *irq_timer_clear; +static timer_device *irq_timer, *irq_timer_clear; static TIMER_DEVICE_CALLBACK( irq_timer_cb ) { irq_timer_pend0 = irq_timer_pend1 = 1; if(irq_allow0 & (1 << IRQ_TIMER)) - cputag_set_input_line(timer->machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE); if(irq_allow1 & (1 << IRQ_TIMER)) - cputag_set_input_line(timer->machine, "sub", IRQ_TIMER+1, ASSERT_LINE); + cputag_set_input_line(timer.machine, "sub", IRQ_TIMER+1, ASSERT_LINE); } static TIMER_DEVICE_CALLBACK( irq_timer_clear_cb ) { irq_sprite = irq_vblank = 0; - cputag_set_input_line(timer->machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE); - cputag_set_input_line(timer->machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE); - cputag_set_input_line(timer->machine, "sub", IRQ_VBLANK+1, CLEAR_LINE); - cputag_set_input_line(timer->machine, "sub", IRQ_SPRITE+1, CLEAR_LINE); + cputag_set_input_line(timer.machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE); + cputag_set_input_line(timer.machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE); + cputag_set_input_line(timer.machine, "sub", IRQ_VBLANK+1, CLEAR_LINE); + cputag_set_input_line(timer.machine, "sub", IRQ_SPRITE+1, CLEAR_LINE); } static void irq_init(running_machine *machine) @@ -819,8 +819,8 @@ static void irq_init(running_machine *machine) irq_timer_pend1 = 0; irq_vblank = 0; irq_sprite = 0; - irq_timer = devtag_get_device(machine, "irq_timer"); - irq_timer_clear = devtag_get_device(machine, "irq_timer_clear"); + irq_timer = machine->device("irq_timer"); + irq_timer_clear = machine->device("irq_timer_clear"); } static void irq_timer_reset(void) @@ -828,7 +828,7 @@ static void irq_timer_reset(void) int freq = (irq_timerb << 12) | irq_timera; freq &= 0x1fff; - timer_device_adjust_periodic(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq)); + irq_timer->adjust(ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq)); logerror("New timer frequency: %0d [%02x %04x]\n", freq, irq_timerb, irq_timera); } @@ -915,7 +915,7 @@ static INTERRUPT_GEN(irq_vbl) irq_vblank = 1; } - timer_device_adjust_oneshot(irq_timer_clear, ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0), 0); + irq_timer_clear->adjust(ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0)); mask = 1 << irq; diff --git a/src/mame/drivers/segas32.c b/src/mame/drivers/segas32.c index 69f9ea0f320..a50477fb5be 100644 --- a/src/mame/drivers/segas32.c +++ b/src/mame/drivers/segas32.c @@ -389,7 +389,7 @@ static UINT8 *z80_shared_ram; /* V60 interrupt controller */ static UINT8 v60_irq_control[0x10]; -static running_device *v60_irq_timer[2]; +static timer_device *v60_irq_timer[2]; /* sound interrupt controller */ static UINT8 sound_irq_control[4]; @@ -436,8 +436,8 @@ static MACHINE_RESET( system32 ) memset(v60_irq_control, 0xff, sizeof(v60_irq_control)); /* allocate timers */ - v60_irq_timer[0] = devtag_get_device(machine, "v60_irq0"); - v60_irq_timer[1] = devtag_get_device(machine, "v60_irq1"); + v60_irq_timer[0] = machine->device("v60_irq0"); + v60_irq_timer[1] = machine->device("v60_irq1"); /* clear IRQ lines */ cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); @@ -485,7 +485,7 @@ static void signal_v60_irq(running_machine *machine, int which) static TIMER_DEVICE_CALLBACK( signal_v60_irq_callback ) { - signal_v60_irq(timer->machine, param); + signal_v60_irq(timer.machine, param); } @@ -525,7 +525,7 @@ static void int_control_w(const address_space *space, int offset, UINT8 data) if (duration) { attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration); - timer_device_adjust_oneshot(v60_irq_timer[0], period, MAIN_IRQ_TIMER0); + v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0); } break; @@ -536,7 +536,7 @@ static void int_control_w(const address_space *space, int offset, UINT8 data) if (duration) { attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration); - timer_device_adjust_oneshot(v60_irq_timer[1], period, MAIN_IRQ_TIMER1); + v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1); } break; @@ -615,7 +615,7 @@ static INTERRUPT_GEN( start_of_vblank_int ) { signal_v60_irq(device->machine, MAIN_IRQ_VBSTART); system32_set_vblank(device->machine, 1); - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), NULL, 0, end_of_vblank_int); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, end_of_vblank_int); if (system32_prot_vblank) (*system32_prot_vblank)(device); } @@ -712,7 +712,7 @@ static void common_io_chip_w(const address_space *space, int which, offs_t offse if (which == 0) { - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); eeprom_write_bit(device, data & 0x80); eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE); eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE); @@ -730,7 +730,7 @@ static void common_io_chip_w(const address_space *space, int which, offs_t offse else { /* multi-32 EEPROM access */ - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); eeprom_write_bit(device, data & 0x80); eeprom_set_cs_line(device, (data & 0x20) ? CLEAR_LINE : ASSERT_LINE); eeprom_set_clock_line(device, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE); @@ -4151,7 +4151,7 @@ static DRIVER_INIT( radr ) static DRIVER_INIT( scross ) { - running_device *multipcm = devtag_get_device(machine, "sega"); + multipcm_sound_device *multipcm = machine->device("sega"); segas32_common_init(analog_custom_io_r, analog_custom_io_w); memory_install_write8_device_handler(cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_PROGRAM), multipcm, 0xb0, 0xbf, 0, 0, scross_bank_w); diff --git a/src/mame/drivers/segaxbd.c b/src/mame/drivers/segaxbd.c index 4e3b02510d4..dd466c7b08e 100644 --- a/src/mame/drivers/segaxbd.c +++ b/src/mame/drivers/segaxbd.c @@ -362,7 +362,7 @@ static TIMER_CALLBACK( scanline_callback ) update_main_irqs(machine); /* come back in 2 scanlines */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, next_scanline, 0), NULL, next_scanline, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(next_scanline), NULL, next_scanline, scanline_callback); } @@ -441,7 +441,7 @@ static MACHINE_RESET( xboard ) m68k_set_reset_callback(devtag_get_device(machine, "maincpu"), xboard_reset); /* start timers to track interrupts */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 1, 0), NULL, 1, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(1), NULL, 1, scanline_callback); } diff --git a/src/mame/drivers/segaybd.c b/src/mame/drivers/segaybd.c index 2689300e832..1ff0255001c 100644 --- a/src/mame/drivers/segaybd.c +++ b/src/mame/drivers/segaybd.c @@ -137,7 +137,7 @@ static void update_main_irqs(running_machine *machine) static TIMER_DEVICE_CALLBACK( scanline_callback ) { - segas1x_state *state = (segas1x_state *)timer->machine->driver_data; + segas1x_state *state = (segas1x_state *)timer.machine->driver_data; int scanline = param; /* on scanline 'irq2_scanline' generate an IRQ2 */ @@ -169,10 +169,10 @@ static TIMER_DEVICE_CALLBACK( scanline_callback ) } /* update IRQs on the main CPU */ - update_main_irqs(timer->machine); + update_main_irqs(timer.machine); /* come back at the next appropriate scanline */ - timer_device_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); + timer.adjust(timer.machine->primary_screen->time_until_pos(scanline), scanline); #if TWEAK_IRQ2_SCANLINE if (scanline == 223) @@ -214,8 +214,7 @@ static MACHINE_RESET( yboard ) state->irq2_scanline = 170; - state->interrupt_timer = devtag_get_device(machine, "int_timer"); - timer_device_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), 223); + state->interrupt_timer->adjust(machine->primary_screen->time_until_pos(223), 223); } diff --git a/src/mame/drivers/seibuspi.c b/src/mame/drivers/seibuspi.c index 41e46d86ebd..dea33ced6a4 100644 --- a/src/mame/drivers/seibuspi.c +++ b/src/mame/drivers/seibuspi.c @@ -890,7 +890,7 @@ static READ32_HANDLER( spi_unknown_r ) static WRITE32_DEVICE_HANDLER( eeprom_w ) { - running_device *oki2 = devtag_get_device(device->machine, "oki2"); + okim6295_device *oki2 = device->machine->device("oki2"); // tile banks if( ACCESSING_BITS_16_23 ) { @@ -902,7 +902,7 @@ static WRITE32_DEVICE_HANDLER( eeprom_w ) // oki banking if (oki2 != NULL) - okim6295_set_bank_base(oki2, (data & 0x4000000) ? 0x40000 : 0); + oki2->set_bank_base((data & 0x4000000) ? 0x40000 : 0); } static WRITE32_HANDLER( z80_prg_fifo_w ) @@ -1943,9 +1943,11 @@ static MACHINE_DRIVER_START( sxx2g ) /* single board version using measured cloc MDRV_IMPORT_FROM(spi) - MDRV_CPU_REPLACE("maincpu", I386, 28636360) /* AMD AM386DX/DX-40, 28.63636MHz */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(28636360) /* AMD AM386DX/DX-40, 28.63636MHz */ - MDRV_CPU_REPLACE("soundcpu", Z80, 4915200) /* 4.9152MHz */ + MDRV_CPU_MODIFY("soundcpu") + MDRV_CPU_CLOCK(4915200) /* 4.9152MHz */ MDRV_SOUND_REPLACE("ymf", YMF271, 16384000) /* 16.3840MHz */ MDRV_SOUND_CONFIG(ymf271_config) @@ -2223,12 +2225,10 @@ static MACHINE_DRIVER_START( seibu386 ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, 1431815) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 1431815, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki2", OKIM6295, 1431815) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 1431815, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/seta.c b/src/mame/drivers/seta.c index 749746c49e1..0e24e75b1e3 100644 --- a/src/mame/drivers/seta.c +++ b/src/mame/drivers/seta.c @@ -7904,8 +7904,7 @@ static MACHINE_DRIVER_START( triplfun ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 792000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 792000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -8049,8 +8048,7 @@ static MACHINE_DRIVER_START( wiggie ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -8331,8 +8329,7 @@ static MACHINE_DRIVER_START( crazyfgt ) MDRV_SOUND_ADD("ymsnd", YM3812, 16000000/4) /* 4 MHz */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) // clock? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/seta2.c b/src/mame/drivers/seta2.c index 84a46afba9d..899075b503e 100644 --- a/src/mame/drivers/seta2.c +++ b/src/mame/drivers/seta2.c @@ -950,7 +950,7 @@ static READ32_HANDLER( funcube_debug_r ) UINT32 ret = input_port_read(space->machine,"DEBUG"); // This bits let you move the crosshair in the inputs / touch panel test with a joystick - if (!(video_screen_get_frame_number(space->machine->primary_screen) % 3)) + if (!(space->machine->primary_screen->frame_number() % 3)) ret |= 0x3f; return ret; @@ -996,7 +996,7 @@ static READ8_HANDLER( funcube_coins_r ) UINT8 coin_bit0 = 1; // active low UINT8 coin_bit1 = 1; - UINT8 hopper_bit = (funcube_hopper_motor && !(video_screen_get_frame_number(space->machine->primary_screen)%20)) ? 1 : 0; + UINT8 hopper_bit = (funcube_hopper_motor && !(space->machine->primary_screen->frame_number()%20)) ? 1 : 0; const UINT64 coin_total_cycles = FUNCUBE_SUB_CPU_CLOCK / (1000/20); diff --git a/src/mame/drivers/sfbonus.c b/src/mame/drivers/sfbonus.c index 8b50e5a0de0..e1a1f1a8ad5 100644 --- a/src/mame/drivers/sfbonus.c +++ b/src/mame/drivers/sfbonus.c @@ -722,12 +722,12 @@ static VIDEO_START(sfbonus) } -static void sfbonus_draw_reel_layer(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int catagory) +static void sfbonus_draw_reel_layer(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int catagory) { int zz; int i; int startclipmin; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); UINT8* selectbase = &sfbonus_videoram[0x600]; UINT8* bg_scroll = &sfbonus_videoram[0x000]; UINT8* reels_rowscroll = &sfbonus_videoram[0x400]; @@ -770,7 +770,7 @@ static void sfbonus_draw_reel_layer(running_device *screen, bitmap_t *bitmap, co //printf("%04x %04x %d\n",zz, xxxscroll, line/8); /* draw top of screen */ - clip.min_x = visarea->min_x; + clip.min_x = visarea.min_x; clip.max_x = 511; clip.min_y = startclipmin; clip.max_y = startclipmin; @@ -1230,8 +1230,7 @@ static MACHINE_DRIVER_START( sfbonus ) /* Parrot 3 seems fine at 1 Mhz, but Double Challenge isn't? */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_DRIVER_END diff --git a/src/mame/drivers/sfkick.c b/src/mame/drivers/sfkick.c index c84726a877f..23551990d45 100644 --- a/src/mame/drivers/sfkick.c +++ b/src/mame/drivers/sfkick.c @@ -419,7 +419,7 @@ static void sfkick_vdp_interrupt(running_machine *machine, int i) static VIDEO_START( sfkick ) { VIDEO_START_CALL(generic_bitmapped); - v9938_init (machine, 0, machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, 0x80000, sfkick_vdp_interrupt); + v9938_init (machine, 0, *machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, 0x80000, sfkick_vdp_interrupt); v9938_reset(0); } diff --git a/src/mame/drivers/shadfrce.c b/src/mame/drivers/shadfrce.c index 4f4c5916e0f..c165a2df415 100644 --- a/src/mame/drivers/shadfrce.c +++ b/src/mame/drivers/shadfrce.c @@ -312,7 +312,7 @@ static WRITE16_HANDLER( shadfrce_scanline_w ) static TIMER_DEVICE_CALLBACK( shadfrce_scanline ) { - shadfrce_state *state = (shadfrce_state *)timer->machine->driver_data; + shadfrce_state *state = (shadfrce_state *)timer.machine->driver_data; int scanline = param; /* Vblank is lowered on scanline 0 */ @@ -333,8 +333,8 @@ static TIMER_DEVICE_CALLBACK( shadfrce_scanline ) { state->raster_scanline = (state->raster_scanline + 1) % 240; if (state->raster_scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, state->raster_scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 1, ASSERT_LINE); + timer.machine->primary_screen->update_partial(state->raster_scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 1, ASSERT_LINE); } } @@ -344,8 +344,8 @@ static TIMER_DEVICE_CALLBACK( shadfrce_scanline ) if (scanline % 16 == 0) { if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 2, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 2, ASSERT_LINE); } } @@ -354,8 +354,8 @@ static TIMER_DEVICE_CALLBACK( shadfrce_scanline ) { if (scanline == 248) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 3, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 3, ASSERT_LINE); } } } @@ -396,7 +396,7 @@ ADDRESS_MAP_END static WRITE8_DEVICE_HANDLER( oki_bankswitch_w ) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + downcast(device)->set_bank_base((data & 1) * 0x40000); } static ADDRESS_MAP_START( shadfrce_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -586,8 +586,7 @@ static MACHINE_DRIVER_START( shadfrce ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.50) MDRV_SOUND_ROUTE(1, "rspeaker", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_13_4952MHz/8) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb, pin7 is at 2.4v */ + MDRV_OKIM6295_ADD("oki", XTAL_13_4952MHz/8, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/shangha3.c b/src/mame/drivers/shangha3.c index 0152e1cd33d..d2406ed644e 100644 --- a/src/mame/drivers/shangha3.c +++ b/src/mame/drivers/shangha3.c @@ -91,7 +91,7 @@ static WRITE16_HANDLER( heberpop_coinctrl_w ) if (ACCESSING_BITS_0_7) { /* the sound ROM bank is selected by the main CPU! */ - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"),(data & 0x08) ? 0x40000 : 0x00000); + space->machine->device("oki")->set_bank_base((data & 0x08) ? 0x40000 : 0x00000); coin_lockout_w(space->machine, 0,~data & 0x04); coin_lockout_w(space->machine, 1,~data & 0x04); @@ -105,7 +105,7 @@ static WRITE16_HANDLER( blocken_coinctrl_w ) if (ACCESSING_BITS_0_7) { /* the sound ROM bank is selected by the main CPU! */ - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), ((data >> 4) & 3) * 0x40000); + space->machine->device("oki")->set_bank_base(((data >> 4) & 3) * 0x40000); coin_lockout_w(space->machine, 0,~data & 0x04); coin_lockout_w(space->machine, 1,~data & 0x04); @@ -506,8 +506,7 @@ static MACHINE_DRIVER_START( shangha3 ) MDRV_SOUND_CONFIG(ay8910_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -547,8 +546,7 @@ static MACHINE_DRIVER_START( heberpop ) MDRV_SOUND_ROUTE(0, "mono", 0.40) MDRV_SOUND_ROUTE(1, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -588,8 +586,7 @@ static MACHINE_DRIVER_START( blocken ) MDRV_SOUND_ROUTE(0, "mono", 0.40) MDRV_SOUND_ROUTE(1, "mono", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/shuuz.c b/src/mame/drivers/shuuz.c index 6178fb989dc..5fb1ed1d865 100644 --- a/src/mame/drivers/shuuz.c +++ b/src/mame/drivers/shuuz.c @@ -46,13 +46,13 @@ static void update_interrupts(running_machine *machine) static READ16_HANDLER( shuuz_atarivc_r ) { - return atarivc_r(space->machine->primary_screen, offset); + return atarivc_r(*space->machine->primary_screen, offset); } static WRITE16_HANDLER( shuuz_atarivc_w ) { - atarivc_w(space->machine->primary_screen, offset, data, mem_mask); + atarivc_w(*space->machine->primary_screen, offset, data, mem_mask); } @@ -75,7 +75,7 @@ static MACHINE_RESET( shuuz ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 1); + atarivc_reset(*machine->primary_screen, state->atarigen.atarivc_eof_data, 1); } @@ -123,7 +123,7 @@ static READ16_HANDLER( special_port0_r ) { int result = input_port_read(space->machine, "SYSTEM"); - if ((result & 0x0800) && atarigen_get_hblank(space->machine->primary_screen)) + if ((result & 0x0800) && atarigen_get_hblank(*space->machine->primary_screen)) result &= ~0x0800; return result; @@ -286,8 +286,7 @@ static MACHINE_DRIVER_START( shuuz ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, ATARI_CLOCK_14MHz/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", ATARI_CLOCK_14MHz/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/silkroad.c b/src/mame/drivers/silkroad.c index b079291ae4c..6e8dc0c4fde 100644 --- a/src/mame/drivers/silkroad.c +++ b/src/mame/drivers/silkroad.c @@ -139,7 +139,7 @@ static WRITE32_DEVICE_HANDLER(silk_6295_bank_w) { int bank = (data & 0x3000000) >> 24; if(bank < 3) - okim6295_set_bank_base(devtag_get_device(device->machine, "oki1"), 0x40000 * (bank)); + device->machine->device("oki1")->set_bank_base(0x40000 * (bank)); } } @@ -308,13 +308,11 @@ static MACHINE_DRIVER_START( silkroad ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki1", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.45) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 2112000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.45) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.45) MACHINE_DRIVER_END diff --git a/src/mame/drivers/simpl156.c b/src/mame/drivers/simpl156.c index 34ff1708445..217e5a15a63 100644 --- a/src/mame/drivers/simpl156.c +++ b/src/mame/drivers/simpl156.c @@ -174,7 +174,7 @@ static WRITE32_HANDLER( simpl156_eeprom_w ) //okibank = data & 0x07; - okim6295_set_bank_base(state->okimusic, 0x40000 * (data & 0x7)); + state->okimusic->set_bank_base(0x40000 * (data & 0x7)); eeprom_set_clock_line(state->eeprom, BIT(data, 5) ? ASSERT_LINE : CLEAR_LINE); eeprom_write_bit(state->eeprom, BIT(data, 4)); @@ -415,16 +415,6 @@ static const deco16ic_interface simpl156_deco16ic_intf = NULL }; -static MACHINE_START( simpl156 ) -{ - simpl156_state *state = (simpl156_state *)machine->driver_data; - - state->maincpu = devtag_get_device(machine, "maincpu"); - state->deco16ic = devtag_get_device(machine, "deco_custom"); - state->eeprom = devtag_get_device(machine, "eeprom"); - state->okimusic = devtag_get_device(machine, "okimusic"); -} - static MACHINE_DRIVER_START( chainrec ) /* driver data */ @@ -437,8 +427,6 @@ static MACHINE_DRIVER_START( chainrec ) MDRV_EEPROM_93C46_ADD("eeprom") // 93C45 - MDRV_MACHINE_START(simpl156) - /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(58) @@ -456,13 +444,11 @@ static MACHINE_DRIVER_START( chainrec ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("okisfx", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("okisfx", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.6) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.6) - MDRV_SOUND_ADD("okimusic", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("okimusic", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.2) MACHINE_DRIVER_END @@ -494,8 +480,7 @@ static MACHINE_DRIVER_START( mitchell156 ) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(mitchell156_map) - MDRV_SOUND_REPLACE("okimusic", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_REPLACE("okimusic", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.2) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.2) MACHINE_DRIVER_END diff --git a/src/mame/drivers/skeetsht.c b/src/mame/drivers/skeetsht.c index 1bba846262a..5594727bb22 100644 --- a/src/mame/drivers/skeetsht.c +++ b/src/mame/drivers/skeetsht.c @@ -62,9 +62,9 @@ static VIDEO_START ( skeetsht ) { } -static void skeetsht_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void skeetsht_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - skeetsht_state *state = (skeetsht_state *)screen->machine->driver_data; + skeetsht_state *state = (skeetsht_state *)screen.machine->driver_data; const rgb_t *const pens = tlc34076_get_pens(); UINT16 *vram = &state->tms_vram[(params->rowaddr << 8) & 0x3ff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); diff --git a/src/mame/drivers/skimaxx.c b/src/mame/drivers/skimaxx.c index 49db2ff2063..c1690b28c87 100644 --- a/src/mame/drivers/skimaxx.c +++ b/src/mame/drivers/skimaxx.c @@ -167,7 +167,7 @@ static void skimaxx_from_shiftreg(const address_space *space, UINT32 address, UI * *************************************/ -static void skimaxx_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void skimaxx_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { // TODO: This isn't correct. I just hacked it together quickly so I could see something! @@ -538,20 +538,16 @@ static MACHINE_DRIVER_START( skimaxx ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_4MHz) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // ? + MDRV_OKIM6295_ADD("oki1", XTAL_4MHz, OKIM6295_PIN7_LOW) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_4MHz/2) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // ? + MDRV_OKIM6295_ADD("oki2", XTAL_4MHz/2, OKIM6295_PIN7_HIGH) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ADD("oki3", OKIM6295, XTAL_4MHz) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // ? + MDRV_OKIM6295_ADD("oki3", XTAL_4MHz, OKIM6295_PIN7_LOW) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki4", OKIM6295, XTAL_4MHz/2) // ? - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // ? + MDRV_OKIM6295_ADD("oki4", XTAL_4MHz/2, OKIM6295_PIN7_HIGH) // ? MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/skullxbo.c b/src/mame/drivers/skullxbo.c index d16911d9916..10de0de5b11 100644 --- a/src/mame/drivers/skullxbo.c +++ b/src/mame/drivers/skullxbo.c @@ -45,28 +45,28 @@ static TIMER_CALLBACK( irq_gen ) } -static void alpha_row_update(running_device *screen, int scanline) +static void alpha_row_update(screen_device &screen, int scanline) { - skullxbo_state *state = (skullxbo_state *)screen->machine->driver_data; + skullxbo_state *state = (skullxbo_state *)screen.machine->driver_data; UINT16 *check = &state->atarigen.alpha[(scanline / 8) * 64 + 42]; /* check for interrupts in the alpha ram */ /* the interrupt occurs on the HBLANK of the 6th scanline following */ if (check < &state->atarigen.alpha[0x7c0] && (*check & 0x8000)) { - int width = video_screen_get_width(screen); - attotime period = video_screen_get_time_until_pos(screen, video_screen_get_vpos(screen) + 6, width * 0.9); - timer_set(screen->machine, period, NULL, 0, irq_gen); + int width = screen.width(); + attotime period = screen.time_until_pos(screen.vpos() + 6, width * 0.9); + timer_set(screen.machine, period, NULL, 0, irq_gen); } /* update the playfield and motion objects */ - skullxbo_scanline_update(screen->machine, scanline); + skullxbo_scanline_update(screen.machine, scanline); } static WRITE16_HANDLER( skullxbo_halt_until_hblank_0_w ) { - atarigen_halt_until_hblank_0(space->machine->primary_screen); + atarigen_halt_until_hblank_0(*space->machine->primary_screen); } @@ -82,7 +82,7 @@ static MACHINE_RESET( skullxbo ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, alpha_row_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, alpha_row_update, 8); atarijsa_reset(); } @@ -99,7 +99,7 @@ static READ16_HANDLER( special_port1_r ) skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; int temp = input_port_read(space->machine, "FF5802"); if (state->atarigen.cpu_to_sound_ready) temp ^= 0x0040; - if (atarigen_get_hblank(space->machine->primary_screen)) temp ^= 0x0010; + if (atarigen_get_hblank(*space->machine->primary_screen)) temp ^= 0x0010; return temp; } diff --git a/src/mame/drivers/sliver.c b/src/mame/drivers/sliver.c index c8c589a08ec..c5ba4ee0a26 100644 --- a/src/mame/drivers/sliver.c +++ b/src/mame/drivers/sliver.c @@ -480,8 +480,8 @@ static VIDEO_START(sliver) { sliver_state *state = (sliver_state *)machine->driver_data; - state->bitmap_bg = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->bitmap_fg = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->bitmap_bg = machine->primary_screen->alloc_compatible_bitmap(); + state->bitmap_fg = machine->primary_screen->alloc_compatible_bitmap(); } static VIDEO_UPDATE(sliver) @@ -594,8 +594,7 @@ static MACHINE_DRIVER_START( sliver ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.6) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.6) MACHINE_DRIVER_END diff --git a/src/mame/drivers/slotcarn.c b/src/mame/drivers/slotcarn.c index ff553df75c1..e4e6b3247a5 100644 --- a/src/mame/drivers/slotcarn.c +++ b/src/mame/drivers/slotcarn.c @@ -58,7 +58,7 @@ static WRITE8_HANDLER( palette_w ) { int co; - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); data &= 0x0f; co = ((ram_attr[offset] & 0x7F) << 3) | (offset & 0x07); @@ -140,7 +140,7 @@ static MC6845_UPDATE_ROW( update_row ) static WRITE_LINE_DEVICE_HANDLER(hsync_changed) { /* update any video up to the current scanline */ - video_screen_update_now(device->machine->primary_screen); + device->machine->primary_screen->update_now(); } static WRITE_LINE_DEVICE_HANDLER(vsync_changed) diff --git a/src/mame/drivers/sms.c b/src/mame/drivers/sms.c index c1e561669a3..5df9683a2b5 100644 --- a/src/mame/drivers/sms.c +++ b/src/mame/drivers/sms.c @@ -450,7 +450,7 @@ static WRITE8_HANDLER(video_w) static VIDEO_START( sms ) { - sms_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + sms_bitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_array(machine, vid_regs); state_save_register_global_bitmap(machine, sms_bitmap); diff --git a/src/mame/drivers/snk6502.c b/src/mame/drivers/snk6502.c index 7b70efd7d3f..44c5ece897a 100644 --- a/src/mame/drivers/snk6502.c +++ b/src/mame/drivers/snk6502.c @@ -848,7 +848,7 @@ static MACHINE_DRIVER_START( sasuke ) // sound hardware MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("snk6502", snk6502, 0) + MDRV_SOUND_ADD("snk6502", SNK6502, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("samples", SAMPLES, 0) @@ -922,7 +922,7 @@ static MACHINE_DRIVER_START( vanguard ) // sound hardware MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("snk6502", snk6502, 0) + MDRV_SOUND_ADD("snk6502", SNK6502, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_SOUND_ADD("samples", SAMPLES, 0) diff --git a/src/mame/drivers/snookr10.c b/src/mame/drivers/snookr10.c index f72298c5bd3..8cb62bd9d5c 100644 --- a/src/mame/drivers/snookr10.c +++ b/src/mame/drivers/snookr10.c @@ -725,8 +725,7 @@ static MACHINE_DRIVER_START( snookr10 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, MASTER_CLOCK/16) /* 1 MHz (995.5 kHz measured) */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* pin7 checked HIGH on PCB */ + MDRV_OKIM6295_ADD("oki", MASTER_CLOCK/16, OKIM6295_PIN7_HIGH) /* 1 MHz (995.5 kHz measured); pin7 checked HIGH on PCB */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.8) MACHINE_DRIVER_END diff --git a/src/mame/drivers/snowbros.c b/src/mame/drivers/snowbros.c index 24ddd57f1e7..67e627dc634 100644 --- a/src/mame/drivers/snowbros.c +++ b/src/mame/drivers/snowbros.c @@ -336,7 +336,7 @@ static WRITE8_DEVICE_HANDLER( twinadv_oki_bank_w ) if (data&0xfd) logerror ("Unused bank bits! %02x\n",data); - okim6295_set_bank_base(device, bank * 0x40000); + downcast(device)->set_bank_base(bank * 0x40000); } static ADDRESS_MAP_START( twinadv_sound_io_map, ADDRESS_SPACE_IO, 8 ) @@ -1558,7 +1558,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( wintbob ) /* basic machine hardware */ MDRV_IMPORT_FROM(snowbros) - MDRV_CPU_REPLACE("maincpu", M68000, 10000000) /* 10mhz - Confirmed */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(10000000) /* 10mhz - Confirmed */ MDRV_CPU_PROGRAM_MAP(wintbob_map) MDRV_DEVICE_REMOVE("pandora") @@ -1574,10 +1575,12 @@ static MACHINE_DRIVER_START( semicom ) /* basic machine hardware */ MDRV_IMPORT_FROM(snowbros) - MDRV_CPU_REPLACE("maincpu", M68000, 16000000) /* 16mhz or 12mhz ? */ + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(16000000) /* 16mhz or 12mhz ? */ MDRV_CPU_PROGRAM_MAP(hyperpac_map) - MDRV_CPU_REPLACE("soundcpu", Z80, 4000000) /* 4.0 MHz ??? */ + MDRV_CPU_MODIFY("soundcpu") + MDRV_CPU_CLOCK(4000000) /* 4.0 MHz ??? */ MDRV_CPU_PROGRAM_MAP(hyperpac_sound_map) MDRV_GFXDECODE(hyperpac) @@ -1588,8 +1591,7 @@ static MACHINE_DRIVER_START( semicom ) MDRV_SOUND_ROUTE(0, "mono", 0.10) MDRV_SOUND_ROUTE(1, "mono", 0.10) - MDRV_SOUND_ADD("oki", OKIM6295, 999900) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 999900, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1665,8 +1667,7 @@ static MACHINE_DRIVER_START( honeydol ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 999900) /* freq? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 999900, OKIM6295_PIN7_HIGH) /* freq? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1699,8 +1700,7 @@ static MACHINE_DRIVER_START( twinadv ) MDRV_SPEAKER_STANDARD_MONO("mono") /* sound hardware */ - MDRV_SOUND_ADD("oki", OKIM6295, 12000000/12) /* freq? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 12000000/12, OKIM6295_PIN7_HIGH) /* freq? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -1726,10 +1726,12 @@ Intel P8752 (mcu) static MACHINE_DRIVER_START( finalttr ) MDRV_IMPORT_FROM(semicom) - MDRV_CPU_REPLACE("maincpu", M68000, 12000000) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(12000000) MDRV_CPU_PROGRAM_MAP(finalttr_map) - MDRV_CPU_REPLACE("soundcpu", Z80, 3578545) + MDRV_CPU_MODIFY("soundcpu") + MDRV_CPU_CLOCK(3578545) MDRV_MACHINE_RESET ( finalttr ) @@ -1738,8 +1740,7 @@ static MACHINE_DRIVER_START( finalttr ) MDRV_SOUND_ROUTE(0, "mono", 0.08) MDRV_SOUND_ROUTE(1, "mono", 0.08) - MDRV_SOUND_REPLACE("oki", OKIM6295, 999900) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_REPLACE("oki", 999900, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) MACHINE_DRIVER_END @@ -1773,8 +1774,7 @@ static MACHINE_DRIVER_START( snowbro3 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 999900) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 999900, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/sothello.c b/src/mame/drivers/sothello.c index fbd4ba77aca..5f557faade6 100644 --- a/src/mame/drivers/sothello.c +++ b/src/mame/drivers/sothello.c @@ -322,7 +322,7 @@ static const msm5205_interface msm_interface = static VIDEO_START( sothello ) { VIDEO_START_CALL(generic_bitmapped); - v9938_init (machine, 0, machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, VDP_MEM, sothello_vdp_interrupt); + v9938_init (machine, 0, *machine->primary_screen, machine->generic.tmpbitmap, MODEL_V9938, VDP_MEM, sothello_vdp_interrupt); v9938_reset(0); } diff --git a/src/mame/drivers/spacefb.c b/src/mame/drivers/spacefb.c index 8998c2ad898..d8b19dddf9c 100644 --- a/src/mame/drivers/spacefb.c +++ b/src/mame/drivers/spacefb.c @@ -126,7 +126,7 @@ static TIMER_CALLBACK( interrupt_callback ) int next_vpos; /* compute vector and set the interrupt line */ - int vpos = video_screen_get_vpos(machine->primary_screen); + int vpos = machine->primary_screen->vpos(); UINT8 vector = 0xc7 | ((vpos & 0x40) >> 2) | ((~vpos & 0x40) >> 3); cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, vector); @@ -136,7 +136,7 @@ static TIMER_CALLBACK( interrupt_callback ) else next_vpos = SPACEFB_INT_TRIGGER_COUNT_1; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(next_vpos), 0); } @@ -148,7 +148,7 @@ static void create_interrupt_timer(running_machine *machine) static void start_interrupt_timer(running_machine *machine) { - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, SPACEFB_INT_TRIGGER_COUNT_1, 0), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(SPACEFB_INT_TRIGGER_COUNT_1), 0); } diff --git a/src/mame/drivers/spbactn.c b/src/mame/drivers/spbactn.c index 99364ce07a9..0d03c0efa3b 100644 --- a/src/mame/drivers/spbactn.c +++ b/src/mame/drivers/spbactn.c @@ -368,8 +368,7 @@ static MACHINE_DRIVER_START( spbactn ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/speedspn.c b/src/mame/drivers/speedspn.c index c60a1c9370b..5dd570bf2e5 100644 --- a/src/mame/drivers/speedspn.c +++ b/src/mame/drivers/speedspn.c @@ -109,7 +109,7 @@ static WRITE8_HANDLER(speedspn_sound_w) static WRITE8_DEVICE_HANDLER( oki_banking_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 3)); + downcast(device)->set_bank_base(0x40000 * (data & 3)); } /*** MEMORY MAPS *************************************************************/ @@ -305,8 +305,7 @@ static MACHINE_DRIVER_START( speedspn ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/spoker.c b/src/mame/drivers/spoker.c index 54361479019..a3ea3eec86a 100644 --- a/src/mame/drivers/spoker.c +++ b/src/mame/drivers/spoker.c @@ -104,7 +104,7 @@ static CUSTOM_INPUT( hopper_r ) running_machine *machine = field->port->machine; spoker_state *state = (spoker_state *)machine->driver_data; - if (state->hopper) return !(video_screen_get_frame_number(machine->primary_screen)%10); + if (state->hopper) return !(machine->primary_screen->frame_number()%10); return input_code_pressed(machine, KEYCODE_H); } @@ -418,8 +418,7 @@ static MACHINE_DRIVER_START( spoker ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_12MHz / 12) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_12MHz / 12, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/spool99.c b/src/mame/drivers/spool99.c index 06c65bf1bb5..5239229dcff 100644 --- a/src/mame/drivers/spool99.c +++ b/src/mame/drivers/spool99.c @@ -360,8 +360,7 @@ static MACHINE_DRIVER_START( spool99 ) MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/sprint2.c b/src/mame/drivers/sprint2.c index 3be74f54c37..7abfea96dda 100644 --- a/src/mame/drivers/sprint2.c +++ b/src/mame/drivers/sprint2.c @@ -170,13 +170,13 @@ static READ8_HANDLER( sprint2_sync_r ) if (attract != 0) val |= 0x10; - if (video_screen_get_vpos(space->machine->primary_screen) == 261) + if (space->machine->primary_screen->vpos() == 261) val |= 0x20; /* VRESET */ - if (video_screen_get_vpos(space->machine->primary_screen) >= 224) + if (space->machine->primary_screen->vpos() >= 224) val |= 0x40; /* VBLANK */ - if (video_screen_get_vpos(space->machine->primary_screen) >= 131) + if (space->machine->primary_screen->vpos() >= 131) val |= 0x80; /* 60 Hz? */ return val; diff --git a/src/mame/drivers/sprint4.c b/src/mame/drivers/sprint4.c index 861d164b344..fa5b996354d 100644 --- a/src/mame/drivers/sprint4.c +++ b/src/mame/drivers/sprint4.c @@ -121,13 +121,13 @@ static TIMER_CALLBACK( nmi_callback ) if (input_port_read(machine, "IN0") & 0x40) cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, nmi_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback); } static MACHINE_RESET( sprint4 ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 32, 0), NULL, 32, nmi_callback); + timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback); memset(steer_FF1, 0, sizeof steer_FF1); memset(steer_FF2, 0, sizeof steer_FF2); diff --git a/src/mame/drivers/sprint8.c b/src/mame/drivers/sprint8.c index 02ef923aad2..71c766999eb 100644 --- a/src/mame/drivers/sprint8.c +++ b/src/mame/drivers/sprint8.c @@ -35,7 +35,7 @@ static TIMER_DEVICE_CALLBACK( input_callback ) for (i = 0; i < 8; i++) { - UINT8 val = input_port_read(timer->machine, dialnames[i]) >> 4; + UINT8 val = input_port_read(timer.machine, dialnames[i]) >> 4; signed char delta = (val - dial[i]) & 15; diff --git a/src/mame/drivers/srmp5.c b/src/mame/drivers/srmp5.c index 3d4f1277924..06f8f8d497f 100644 --- a/src/mame/drivers/srmp5.c +++ b/src/mame/drivers/srmp5.c @@ -94,7 +94,7 @@ static VIDEO_UPDATE( srmp5 ) UINT16 *sprite_list=state->sprram; UINT16 *sprite_list_end=&state->sprram[0x4000]; //guess UINT8 *pixels=(UINT8 *)state->tileram; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); //Table surface seems to be tiles, but display corrupts when switching the scene if always ON. //Currently the tiles are OFF. @@ -170,7 +170,7 @@ static VIDEO_UPDATE( srmp5 ) xs2 = (sprite_sublist[SPRITE_PALETTE] & 0x8000) ? (sizex - xs) : xs; if(pen) { - if(xb+xs2<=visarea->max_x && xb+xs2>=visarea->min_x && yb+ys2<=visarea->max_y && yb+ys2>=visarea->min_y ) + if(xb+xs2<=visarea.max_x && xb+xs2>=visarea.min_x && yb+ys2<=visarea.max_y && yb+ys2>=visarea.min_y ) { UINT16 pixdata=state->palram[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)]; *BITMAP_ADDR32(bitmap, yb+ys2, xb+xs2) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19); diff --git a/src/mame/drivers/sshangha.c b/src/mame/drivers/sshangha.c index a171ab38a6d..fc21756eeca 100644 --- a/src/mame/drivers/sshangha.c +++ b/src/mame/drivers/sshangha.c @@ -391,8 +391,7 @@ static MACHINE_DRIVER_START( sshangha ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.33) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.33) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.27) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.27) MACHINE_DRIVER_END diff --git a/src/mame/drivers/sslam.c b/src/mame/drivers/sslam.c index a18e6a055e2..54cc75dabda 100644 --- a/src/mame/drivers/sslam.c +++ b/src/mame/drivers/sslam.c @@ -219,7 +219,7 @@ static TIMER_CALLBACK( music_playback ) { sslam_state *state = (sslam_state *)machine->driver_data; int pattern = 0; - running_device *device = devtag_get_device(machine, "oki"); + okim6295_device *device = machine->device("oki"); if ((okim6295_r(device,0) & 0x08) == 0) { @@ -330,13 +330,13 @@ static WRITE16_DEVICE_HANDLER( sslam_snd_w ) else if (state->sound >= 0x70) { /* These vocals are in bank 1, but a bug in the actual MCU doesn't set the bank */ // if (state->snd_bank != 1) -// okim6295_set_bank_base(device, (1 * 0x40000)); +// downcast(device)->set_bank_base((1 * 0x40000)); // sslam_snd_bank = 1; sslam_play(device, 0, state->sound); } else if (state->sound >= 0x69) { if (state->snd_bank != 2) - okim6295_set_bank_base(device, (2 * 0x40000)); + downcast(device)->set_bank_base(2 * 0x40000); state->snd_bank = 2; switch (state->sound) { @@ -349,14 +349,14 @@ static WRITE16_DEVICE_HANDLER( sslam_snd_w ) } else if (state->sound >= 0x65) { if (state->snd_bank != 1) - okim6295_set_bank_base(device, (1 * 0x40000)); + downcast(device)->set_bank_base(1 * 0x40000); state->snd_bank = 1; state->melody = 4; sslam_play(device, state->melody, state->sound); } else if (state->sound >= 0x60) { if (state->snd_bank != 0) - okim6295_set_bank_base(device, (0 * 0x40000)); + downcast(device)->set_bank_base(0 * 0x40000); state->snd_bank = 0; switch (state->sound) { @@ -465,7 +465,7 @@ static WRITE8_HANDLER( playmark_snd_control_w ) if (state->oki_bank != ((data & 3) - 1)) { state->oki_bank = (data & 3) - 1; - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), 0x40000 * state->oki_bank); + space->machine->device("oki")->set_bank_base(0x40000 * state->oki_bank); } } @@ -720,7 +720,7 @@ static MACHINE_DRIVER_START( sslam ) MDRV_CPU_VBLANK_INT("screen", irq2_line_hold) MDRV_CPU_ADD("audiocpu", I8051, 12000000) - MDRV_CPU_FLAGS(CPU_DISABLE) /* Internal code is not dumped - 2 boards were protected */ + MDRV_DEVICE_DISABLE() /* Internal code is not dumped - 2 boards were protected */ /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -739,8 +739,7 @@ static MACHINE_DRIVER_START( sslam ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END @@ -773,8 +772,7 @@ static MACHINE_DRIVER_START( powerbls ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) /* verified on original PCB */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) /* verified on original PCB */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/stadhero.c b/src/mame/drivers/stadhero.c index 67ea379c4d1..8694218b740 100644 --- a/src/mame/drivers/stadhero.c +++ b/src/mame/drivers/stadhero.c @@ -256,8 +256,7 @@ static MACHINE_DRIVER_START( stadhero ) MDRV_SOUND_CONFIG(ym3812_config) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_DRIVER_END diff --git a/src/mame/drivers/stlforce.c b/src/mame/drivers/stlforce.c index 9f9e485f52b..800a2d467fa 100644 --- a/src/mame/drivers/stlforce.c +++ b/src/mame/drivers/stlforce.c @@ -86,7 +86,7 @@ static WRITE16_DEVICE_HANDLER( eeprom_w ) static WRITE16_DEVICE_HANDLER( oki_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * ((data>>8) & 3)); + downcast(device)->set_bank_base(0x40000 * ((data>>8) & 3)); } static ADDRESS_MAP_START( stlforce_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -211,15 +211,15 @@ static MACHINE_DRIVER_START( stlforce ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 937500 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 937500 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END static MACHINE_DRIVER_START( twinbrat ) /* basic machine hardware */ MDRV_IMPORT_FROM(stlforce) - MDRV_CPU_REPLACE("maincpu", M68000, 14745600) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(14745600) MDRV_SCREEN_MODIFY("screen") MDRV_SCREEN_VISIBLE_AREA(3*8, 45*8-1, 0*8, 30*8-1) diff --git a/src/mame/drivers/stv.c b/src/mame/drivers/stv.c index 52b2916220d..72e3db7ff5d 100644 --- a/src/mame/drivers/stv.c +++ b/src/mame/drivers/stv.c @@ -498,7 +498,7 @@ static void stv_SMPC_w8 (const address_space *space, int offset, UINT8 data) if(offset == 0x75) { - running_device *device = devtag_get_device(space->machine, "eeprom"); + eeprom_device *device = space->machine->device("eeprom"); eeprom_set_clock_line(device, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE); eeprom_write_bit(device, data & 0x10); eeprom_set_cs_line(device, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE); @@ -2654,9 +2654,9 @@ SCU register[40] is for IRQ masking. It's not tested much either, but I'm aware that timer 1 doesn't work with this for whatever reason ... */ static TIMER_CALLBACK( stv_irq_callback ) { - int hpos = video_screen_get_hpos(machine->primary_screen); - int vpos = video_screen_get_vpos(machine->primary_screen); - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); + int hpos = machine->primary_screen->hpos(); + int vpos = machine->primary_screen->vpos(); + rectangle visarea = *machine->primary_screen->visible_area(); h_sync = visarea.max_x+1;//horz v_sync = visarea.max_y+1;//vert @@ -2664,12 +2664,12 @@ static TIMER_CALLBACK( stv_irq_callback ) if(vpos == v_sync && hpos == 0) VBLANK_IN_IRQ; if(hpos == 0 && vpos == 0) - VBLANK_OUT_IRQ; + VBLANK_OUT_IRQ(timer->machine); if(hpos == h_sync) - TIMER_0_IRQ; + TIMER_0_IRQ(timer->machine); if(hpos == h_sync && (vpos != 0 && vpos != v_sync)) { - HBLANK_IN_IRQ; + HBLANK_IN_IRQ(timer->machine); timer_0++; } @@ -2679,28 +2679,28 @@ static TIMER_CALLBACK( stv_irq_callback ) VDP1_IRQ; if(hpos == timer_1) - TIMER_1_IRQ; + TIMER_1_IRQ(timer->machine); if(hpos <= h_sync) - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, hpos+1), 0); + scan_timer->adjust(machine->primary_screen->time_until_pos(vpos, hpos+1)); else if(vpos <= v_sync) - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos+1, 0), 0); + scan_timer->adjust(machine->primary_screen->time_until_pos(vpos+1)); else - timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + scan_timer->adjust(machine->primary_screen->time_until_pos(0)); } #endif -static running_device *vblank_out_timer,*scan_timer,*t1_timer; +static timer_device *vblank_out_timer,*scan_timer,*t1_timer; static int h_sync,v_sync; static int cur_scan; -#define VBLANK_OUT_IRQ \ +#define VBLANK_OUT_IRQ(m) \ timer_0 = 0; \ { \ /*if(LOG_IRQ) logerror ("Interrupt: VBlank-OUT Vector 0x41 Level 0x0e\n");*/ \ - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ + cputag_set_input_line_and_vector(m, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ } \ #define VBLANK_IN_IRQ \ @@ -2709,34 +2709,34 @@ timer_0 = 0; \ cputag_set_input_line_and_vector(device->machine, "maincpu", 0xf, (stv_irq.vblank_in) ? HOLD_LINE : CLEAR_LINE , 0x40); \ } \ -#define HBLANK_IN_IRQ \ +#define HBLANK_IN_IRQ(m) \ timer_1 = stv_scu[37] & 0x1ff; \ { \ /*if(LOG_IRQ) logerror ("Interrupt: HBlank-In at scanline %04x, Vector 0x42 Level 0x0d\n",scanline);*/ \ - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ + cputag_set_input_line_and_vector(m, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ } \ -#define TIMER_0_IRQ \ +#define TIMER_0_IRQ(m) \ if(timer_0 == (stv_scu[36] & 0x3ff)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 0 at scanline %04x, Vector 0x43 Level 0x0c\n",scanline);*/ \ - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ + cputag_set_input_line_and_vector(m, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ } \ -#define TIMER_1_IRQ \ +#define TIMER_1_IRQ(m) \ if((stv_scu[38] & 1)) \ { \ if(!(stv_scu[38] & 0x80)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ + cputag_set_input_line_and_vector(m, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ } \ else \ { \ if((timer_0) == (stv_scu[36] & 0x3ff)) \ { \ /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ - cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ + cputag_set_input_line_and_vector(m, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ } \ } \ } \ @@ -2750,20 +2750,20 @@ static TIMER_DEVICE_CALLBACK( hblank_in_irq ) { int scanline = param; -// h = video_screen_get_height(timer->machine->primary_screen); -// w = video_screen_get_width(timer->machine->primary_screen); +// h = timer.machine->primary_screen->height(); +// w = timer.machine->primary_screen->width(); - HBLANK_IN_IRQ; - TIMER_0_IRQ; + HBLANK_IN_IRQ(timer.machine); + TIMER_0_IRQ(timer.machine); if(scanline+1 < v_sync) { if(stv_irq.hblank_in || stv_irq.timer_0) - timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, h_sync), scanline+1); + scan_timer->adjust(timer.machine->primary_screen->time_until_pos(scanline+1, h_sync), scanline+1); /*set the first Timer-1 event*/ cur_scan = scanline+1; if(stv_irq.timer_1) - timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1); + t1_timer->adjust(timer.machine->primary_screen->time_until_pos(scanline+1, timer_1), scanline+1); } timer_0++; @@ -2773,10 +2773,10 @@ static TIMER_DEVICE_CALLBACK( timer1_irq ) { int scanline = param; - TIMER_1_IRQ; + TIMER_1_IRQ(timer.machine); if(stv_irq.timer_1) - timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1); + t1_timer->adjust(timer.machine->primary_screen->time_until_pos(scanline+1, timer_1), scanline+1); } static TIMER_CALLBACK( vdp1_irq ) @@ -2786,14 +2786,14 @@ static TIMER_CALLBACK( vdp1_irq ) static TIMER_DEVICE_CALLBACK( vblank_out_irq ) { - VBLANK_OUT_IRQ; + VBLANK_OUT_IRQ(timer.machine); } /*V-Blank-IN event*/ static INTERRUPT_GEN( stv_interrupt ) { // scanline = 0; - rectangle visarea = *video_screen_get_visible_area(device->machine->primary_screen); + rectangle visarea = device->machine->primary_screen->visible_area(); h_sync = visarea.max_x+1;//horz v_sync = visarea.max_y+1;//vert @@ -2802,14 +2802,14 @@ static INTERRUPT_GEN( stv_interrupt ) /*Next V-Blank-OUT event*/ if(stv_irq.vblank_out) - timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0); + vblank_out_timer->adjust(device->machine->primary_screen->time_until_pos(0)); /*Set the first Hblank-IN event*/ if(stv_irq.hblank_in || stv_irq.timer_0 || stv_irq.timer_1) - timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0); + scan_timer->adjust(device->machine->primary_screen->time_until_pos(0, h_sync)); /*TODO: timing of this one (related to the VDP1 speed)*/ /* (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/ - timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen,0,0), NULL, 0, vdp1_irq); + timer_set(device->machine, device->machine->primary_screen->time_until_pos(0), NULL, 0, vdp1_irq); } static MACHINE_RESET( stv ) @@ -2835,11 +2835,11 @@ static MACHINE_RESET( stv ) stvcd_reset(machine); /* set the first scanline 0 timer to go off */ - scan_timer = devtag_get_device(machine, "scan_timer"); - t1_timer = devtag_get_device(machine, "t1_timer"); - vblank_out_timer = devtag_get_device(machine, "vbout_timer"); - timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); - timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0); + scan_timer = machine->device("scan_timer"); + t1_timer = machine->device("t1_timer"); + vblank_out_timer = machine->device("vbout_timer"); + vblank_out_timer->adjust(machine->primary_screen->time_until_pos(0)); + scan_timer->adjust(machine->primary_screen->time_until_pos(224, 352)); timer_adjust_periodic(stv_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1)); } diff --git a/src/mame/drivers/subsino.c b/src/mame/drivers/subsino.c index d5eab8f559f..08808f1b0f9 100644 --- a/src/mame/drivers/subsino.c +++ b/src/mame/drivers/subsino.c @@ -2231,8 +2231,7 @@ static MACHINE_DRIVER_START( victor21 ) MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_4_433619MHz / 4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* Clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", XTAL_4_433619MHz / 4, OKIM6295_PIN7_HIGH) /* Clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -2304,8 +2303,7 @@ static MACHINE_DRIVER_START( srider ) MDRV_SOUND_ADD("ymsnd", YM3812, XTAL_3_579545MHz) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_4_433619MHz / 4) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* Clock frequency & pin 7 not verified */ + MDRV_OKIM6295_ADD("oki", XTAL_4_433619MHz / 4, OKIM6295_PIN7_HIGH) /* Clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/suna8.c b/src/mame/drivers/suna8.c index ca6468465ab..8e021ee23cf 100644 --- a/src/mame/drivers/suna8.c +++ b/src/mame/drivers/suna8.c @@ -923,7 +923,7 @@ static WRITE8_HANDLER( sparkman_rombank_w ) static READ8_HANDLER( sparkman_c0a3_r ) { - return (video_screen_get_frame_number(space->machine->primary_screen) & 1) ? 0x80 : 0; + return (space->machine->primary_screen->frame_number() & 1) ? 0x80 : 0; } #if 0 diff --git a/src/mame/drivers/supbtime.c b/src/mame/drivers/supbtime.c index 3ef985980e9..845dffb885c 100644 --- a/src/mame/drivers/supbtime.c +++ b/src/mame/drivers/supbtime.c @@ -379,8 +379,7 @@ static MACHINE_DRIVER_START( supbtime ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END @@ -425,8 +424,7 @@ static MACHINE_DRIVER_START( chinatwn ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/suprnova.c b/src/mame/drivers/suprnova.c index dd8422872e7..4d9fdae7437 100644 --- a/src/mame/drivers/suprnova.c +++ b/src/mame/drivers/suprnova.c @@ -451,7 +451,7 @@ static READ32_HANDLER( skns_hit_r ) static TIMER_DEVICE_CALLBACK( interrupt_callback ) { - cputag_set_input_line(timer->machine, "maincpu", param, HOLD_LINE); + cputag_set_input_line(timer.machine, "maincpu", param, HOLD_LINE); } static MACHINE_RESET(skns) diff --git a/src/mame/drivers/system1.c b/src/mame/drivers/system1.c index 48dc3474b17..a0bfbff9fbc 100644 --- a/src/mame/drivers/system1.c +++ b/src/mame/drivers/system1.c @@ -520,7 +520,7 @@ static WRITE8_HANDLER( soundport_w ) static TIMER_DEVICE_CALLBACK( soundirq_gen ) { /* sound IRQ is generated on 32V, 96V, ... and auto-acknowledged */ - cputag_set_input_line(timer->machine, "soundcpu", 0, HOLD_LINE); + cputag_set_input_line(timer.machine, "soundcpu", 0, HOLD_LINE); } @@ -607,7 +607,7 @@ static TIMER_DEVICE_CALLBACK( mcu_t0_callback ) enough, the MCU will fail; on shtngmst this happens after 3 VBLANKs without a tick */ - running_device *mcu = devtag_get_device(timer->machine, "mcu"); + running_device *mcu = devtag_get_device(timer.machine, "mcu"); cpu_set_input_line(mcu, MCS51_T0_LINE, ASSERT_LINE); cpu_set_input_line(mcu, MCS51_T0_LINE, CLEAR_LINE); } diff --git a/src/mame/drivers/taito_b.c b/src/mame/drivers/taito_b.c index 9f7e1c630d6..e1c96c6b6d2 100644 --- a/src/mame/drivers/taito_b.c +++ b/src/mame/drivers/taito_b.c @@ -2511,8 +2511,7 @@ static MACHINE_DRIVER_START( hitice ) MDRV_SOUND_ROUTE(2, "mono", 0.25) MDRV_SOUND_ROUTE(3, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_TC0140SYT_ADD("tc0140syt", taitob_tc0140syt_intf) @@ -2877,8 +2876,7 @@ static MACHINE_DRIVER_START( viofight ) MDRV_SOUND_ROUTE(2, "mono", 0.25) MDRV_SOUND_ROUTE(3, "mono", 0.80) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MDRV_TC0140SYT_ADD("tc0140syt", taitob_tc0140syt_intf) diff --git a/src/mame/drivers/taito_f2.c b/src/mame/drivers/taito_f2.c index 1652f520a99..0be681b5826 100644 --- a/src/mame/drivers/taito_f2.c +++ b/src/mame/drivers/taito_f2.c @@ -647,7 +647,7 @@ static READ8_HANDLER( driveout_sound_command_r) static void reset_driveout_sound_region( running_machine *machine ) { taitof2_state *state = (taitof2_state *)machine->driver_data; - okim6295_set_bank_base(state->oki, state->oki_bank * 0x40000); + state->oki->set_bank_base(state->oki_bank * 0x40000); } static WRITE8_HANDLER( oki_bank_w ) @@ -3381,7 +3381,6 @@ static MACHINE_START( common ) state->maincpu = devtag_get_device(machine, "maincpu"); state->audiocpu = devtag_get_device(machine, "audiocpu");; - state->oki = devtag_get_device(machine, "oki");; state->tc0100scn = devtag_get_device(machine, "tc0100scn");; state->tc0100scn_1 = devtag_get_device(machine, "tc0100scn_1");; state->tc0100scn_2 = devtag_get_device(machine, "tc0100scn_2");; @@ -4000,8 +3999,7 @@ static MACHINE_DRIVER_START( cameltrya ) MDRV_SOUND_ROUTE(2, "mono", 0.20) MDRV_SOUND_ROUTE(3, "mono", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 4224000/4) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", 4224000/4, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) MDRV_TC0140SYT_ADD("tc0140syt", taitof2_tc0140syt_intf) @@ -4047,8 +4045,7 @@ static MACHINE_DRIVER_START( driveout ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") /* does it ? */ - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) diff --git a/src/mame/drivers/taito_f3.c b/src/mame/drivers/taito_f3.c index c8e72e37914..bed858889ae 100644 --- a/src/mame/drivers/taito_f3.c +++ b/src/mame/drivers/taito_f3.c @@ -518,8 +518,7 @@ static MACHINE_DRIVER_START( bubsympb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000 ) // not verified - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // not verified + MDRV_OKIM6295_ADD("oki", 1000000 , OKIM6295_PIN7_HIGH) // not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/taito_l.c b/src/mame/drivers/taito_l.c index c061008471c..546c3869348 100644 --- a/src/mame/drivers/taito_l.c +++ b/src/mame/drivers/taito_l.c @@ -2328,8 +2328,8 @@ static MACHINE_DRIVER_START( lagirl ) /* basic machine hardware */ MDRV_IMPORT_FROM(plotting) MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(XTAL_27_2109MHz/4) MDRV_CPU_PROGRAM_MAP(cachat_map) - MDRV_CPU_REPLACE("maincpu", Z80, XTAL_27_2109MHz/4) /* sound hardware */ MDRV_SOUND_REPLACE("ymsnd", YM2203, XTAL_27_2109MHz/8) diff --git a/src/mame/drivers/targeth.c b/src/mame/drivers/targeth.c index dde9ecf87da..05651d253e4 100644 --- a/src/mame/drivers/targeth.c +++ b/src/mame/drivers/targeth.c @@ -200,8 +200,7 @@ static MACHINE_DRIVER_START( targeth ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tatsumi.c b/src/mame/drivers/tatsumi.c index 50fd97df0df..bb7279c39d5 100644 --- a/src/mame/drivers/tatsumi.c +++ b/src/mame/drivers/tatsumi.c @@ -896,8 +896,7 @@ static MACHINE_DRIVER_START( apache3 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_1 / 4 / 2) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", CLOCK_1 / 4 / 2, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) MACHINE_DRIVER_END @@ -939,8 +938,7 @@ static MACHINE_DRIVER_START( roundup5 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_1 / 4 / 2) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", CLOCK_1 / 4 / 2, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) MACHINE_DRIVER_END @@ -983,8 +981,7 @@ static MACHINE_DRIVER_START( cyclwarr ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_1 / 8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", CLOCK_1 / 8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) MACHINE_DRIVER_END @@ -1027,8 +1024,7 @@ static MACHINE_DRIVER_START( bigfight ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, CLOCK_1 / 8 / 2) /* 2MHz was too fast. Can the clock be software controlled? */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", CLOCK_1 / 8 / 2, OKIM6295_PIN7_HIGH) /* 2MHz was too fast. Can the clock be software controlled? */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tecmo.c b/src/mame/drivers/tecmo.c index 518461163f1..b0e09aa0ee1 100644 --- a/src/mame/drivers/tecmo.c +++ b/src/mame/drivers/tecmo.c @@ -718,7 +718,8 @@ static MACHINE_DRIVER_START( gemini ) /* basic machine hardware */ MDRV_IMPORT_FROM(rygar) - MDRV_CPU_REPLACE("maincpu", Z80, 6000000) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(6000000) MDRV_CPU_PROGRAM_MAP(gemini_map) MDRV_CPU_MODIFY("soundcpu") @@ -730,7 +731,8 @@ static MACHINE_DRIVER_START( silkworm ) /* basic machine hardware */ MDRV_IMPORT_FROM(gemini) - MDRV_CPU_REPLACE("maincpu", Z80, 6000000) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(6000000) MDRV_CPU_PROGRAM_MAP(silkworm_map) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tecmo16.c b/src/mame/drivers/tecmo16.c index c67370395f7..7b2984b94e6 100644 --- a/src/mame/drivers/tecmo16.c +++ b/src/mame/drivers/tecmo16.c @@ -432,8 +432,7 @@ static MACHINE_DRIVER_START( fstarfrc ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.60) MDRV_SOUND_ROUTE(1, "rspeaker", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 999900) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 999900, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tecmosys.c b/src/mame/drivers/tecmosys.c index cfb7a6b6803..006076076b0 100644 --- a/src/mame/drivers/tecmosys.c +++ b/src/mame/drivers/tecmosys.c @@ -350,7 +350,7 @@ static READ16_HANDLER( unk880000_r ) switch( offset ) { case 0: - if ( video_screen_get_vpos(space->machine->primary_screen) >= 240) return 0; + if ( space->machine->primary_screen->vpos() >= 240) return 0; else return 1; default: @@ -914,8 +914,7 @@ static MACHINE_DRIVER_START( deroon ) MDRV_SOUND_ROUTE(2, "lspeaker", 1.00) MDRV_SOUND_ROUTE(3, "rspeaker", 1.00) - MDRV_SOUND_ADD("oki", OKIM6295, 16000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 16000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) diff --git a/src/mame/drivers/tetrisp2.c b/src/mame/drivers/tetrisp2.c index 77da5fe6ada..ef3a11cc539 100644 --- a/src/mame/drivers/tetrisp2.c +++ b/src/mame/drivers/tetrisp2.c @@ -1165,8 +1165,7 @@ static MACHINE_DRIVER_START( nndmseal ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_2MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_2MHz, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tgtpanic.c b/src/mame/drivers/tgtpanic.c index 05ff03a09a6..5d485e9d074 100644 --- a/src/mame/drivers/tgtpanic.c +++ b/src/mame/drivers/tgtpanic.c @@ -59,7 +59,7 @@ static VIDEO_UPDATE( tgtpanic ) static WRITE8_HANDLER( color_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); color = data; } diff --git a/src/mame/drivers/thoop2.c b/src/mame/drivers/thoop2.c index 8b5eb1f705f..a84308c2bed 100644 --- a/src/mame/drivers/thoop2.c +++ b/src/mame/drivers/thoop2.c @@ -219,8 +219,7 @@ static MACHINE_DRIVER_START( thoop2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/thunderj.c b/src/mame/drivers/thunderj.c index c37c3c82ab2..2fdbfd40fbb 100644 --- a/src/mame/drivers/thunderj.c +++ b/src/mame/drivers/thunderj.c @@ -55,7 +55,7 @@ static MACHINE_RESET( thunderj ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2); + atarivc_reset(*machine->primary_screen, state->atarigen.atarivc_eof_data, 2); atarijsa_reset(); } @@ -96,7 +96,7 @@ static WRITE16_HANDLER( latch_w ) /* bits 2-5 are the alpha bank */ if (state->alpha_tile_bank != ((data >> 2) & 7)) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); tilemap_mark_all_tiles_dirty(state->atarigen.alpha_tilemap); state->alpha_tile_bank = (data >> 2) & 7; } @@ -133,13 +133,13 @@ static READ16_HANDLER( thunderj_atarivc_r ) mame_printf_debug("You're screwed!"); #endif - return atarivc_r(space->machine->primary_screen, offset); + return atarivc_r(*space->machine->primary_screen, offset); } static WRITE16_HANDLER( thunderj_atarivc_w ) { - atarivc_w(space->machine->primary_screen, offset, data, mem_mask); + atarivc_w(*space->machine->primary_screen, offset, data, mem_mask); } diff --git a/src/mame/drivers/tickee.c b/src/mame/drivers/tickee.c index 6c189f78252..6d3b0f1fe84 100644 --- a/src/mame/drivers/tickee.c +++ b/src/mame/drivers/tickee.c @@ -50,10 +50,10 @@ static UINT8 gunx[2]; INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int *y) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * (visarea->max_x - visarea->min_x)) >> 8) + visarea->min_x; - *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * (visarea->max_y - visarea->min_y)) >> 8) + visarea->min_y; + *x = (((input_port_read(machine, player ? "GUNX2" : "GUNX1") & 0xff) * (visarea.max_x - visarea.min_x)) >> 8) + visarea.min_x; + *y = (((input_port_read(machine, player ? "GUNY2" : "GUNY1") & 0xff) * (visarea.max_y - visarea.min_y)) >> 8) + visarea.min_y; } @@ -67,7 +67,7 @@ INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int * static TIMER_CALLBACK( trigger_gun_interrupt ) { int which = param & 1; - int beamx = (video_screen_get_hpos(machine->primary_screen)/2)-58; + int beamx = (machine->primary_screen->hpos()/2)-58; /* once we're ready to fire, set the X coordinate and assert the line */ gunx[which] = beamx; @@ -89,7 +89,7 @@ static TIMER_CALLBACK( setup_gun_interrupts ) int beamx, beamy; /* set a timer to do this again next frame */ - timer_adjust_oneshot(setup_gun_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(setup_gun_timer, machine->primary_screen->time_until_pos(0), 0); /* only do work if the palette is flashed */ if (tickee_control) @@ -98,13 +98,13 @@ static TIMER_CALLBACK( setup_gun_interrupts ) /* generate interrupts for player 1's gun */ get_crosshair_xy(machine, 0, &beamx, &beamy); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, beamy + beamyadd, beamx + beamxadd), NULL, 0, trigger_gun_interrupt); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, beamy + beamyadd + 1, beamx + beamxadd), NULL, 0, clear_gun_interrupt); + timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), NULL, 0, trigger_gun_interrupt); + timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), NULL, 0, clear_gun_interrupt); /* generate interrupts for player 2's gun */ get_crosshair_xy(machine, 1, &beamx, &beamy); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, beamy + beamyadd, beamx + beamxadd), NULL, 1, trigger_gun_interrupt); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, beamy + beamyadd + 1, beamx + beamxadd), NULL, 1, clear_gun_interrupt); + timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), NULL, 1, trigger_gun_interrupt); + timer_set(machine, machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), NULL, 1, clear_gun_interrupt); } @@ -119,7 +119,7 @@ static VIDEO_START( tickee ) { /* start a timer going on the first scanline of every frame */ setup_gun_timer = timer_alloc(machine, setup_gun_interrupts, NULL); - timer_adjust_oneshot(setup_gun_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(setup_gun_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -130,7 +130,7 @@ static VIDEO_START( tickee ) * *************************************/ -static void scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *src = &tickee_vram[(params->rowaddr << 8) & 0x3ff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); @@ -155,7 +155,7 @@ static void scanline_update(running_device *screen, bitmap_t *bitmap, int scanli } -static void rapidfir_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void rapidfir_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *src = &tickee_vram[(params->rowaddr << 8) & 0x3ff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); @@ -322,19 +322,19 @@ static WRITE16_DEVICE_HANDLER( sound_bank_w ) switch (data & 0xff) { case 0x2c: - okim6295_set_bank_base(device, 0x00000); + downcast(device)->set_bank_base(0x00000); break; case 0x2d: - okim6295_set_bank_base(device, 0x40000); + downcast(device)->set_bank_base(0x40000); break; case 0x1c: - okim6295_set_bank_base(device, 0x80000); + downcast(device)->set_bank_base(0x80000); break; case 0x1d: - okim6295_set_bank_base(device, 0xc0000); + downcast(device)->set_bank_base(0xc0000); break; default: @@ -790,8 +790,7 @@ static MACHINE_DRIVER_START( rapidfir ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_DRIVER_END @@ -822,8 +821,7 @@ static MACHINE_DRIVER_START( mouseatk ) MDRV_SOUND_CONFIG(ay8910_interface_1) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, OKI_CLOCK) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", OKI_CLOCK, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tmaster.c b/src/mame/drivers/tmaster.c index fc26fd76774..f83dc68928f 100644 --- a/src/mame/drivers/tmaster.c +++ b/src/mame/drivers/tmaster.c @@ -133,7 +133,7 @@ static WRITE16_DEVICE_HANDLER( tmaster_oki_bank_w ) { // data & 0x0800? okibank = ((data >> 8) & 3); - okim6295_set_bank_base(device, okibank * 0x40000); + downcast(device)->set_bank_base(okibank * 0x40000); } if (ACCESSING_BITS_0_7) @@ -279,7 +279,7 @@ static VIDEO_START( tmaster ) { for (buffer = 0; buffer < 2; buffer++) { - tmaster_bitmap[layer][buffer] = video_screen_auto_bitmap_alloc(machine->primary_screen); + tmaster_bitmap[layer][buffer] = machine->primary_screen->alloc_compatible_bitmap(); bitmap_fill(tmaster_bitmap[layer][buffer], NULL, 0xff); } } @@ -896,8 +896,7 @@ static MACHINE_DRIVER_START( tm3k ) MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki",OKIM6295, XTAL_32MHz / 16) /* 2MHz */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_32MHz / 16, OKIM6295_PIN7_HIGH) /* 2MHz; clock frequency & pin 7 not verified */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -905,8 +904,7 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( tm ) MDRV_IMPORT_FROM(tm3k) - MDRV_SOUND_REPLACE("oki",OKIM6295, 1122000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_REPLACE("oki", 1122000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -969,8 +967,7 @@ static MACHINE_DRIVER_START( galgames ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_24MHz / 8) // ?? - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", XTAL_24MHz / 8, OKIM6295_PIN7_LOW) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tmnt.c b/src/mame/drivers/tmnt.c index 1aef572b2a9..5d9fb67b56e 100644 --- a/src/mame/drivers/tmnt.c +++ b/src/mame/drivers/tmnt.c @@ -2852,8 +2852,7 @@ static MACHINE_DRIVER_START( sunsetbl ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/toaplan1.c b/src/mame/drivers/toaplan1.c index 72fde1d7f9d..4f9cafd7458 100644 --- a/src/mame/drivers/toaplan1.c +++ b/src/mame/drivers/toaplan1.c @@ -1723,7 +1723,7 @@ static MACHINE_DRIVER_START( samesame ) MDRV_CPU_ADD("audiocpu", Z180, XTAL_28MHz/8) /* HD647180XOFS6 CPU */ MDRV_CPU_PROGRAM_MAP(hd647180_mem_map) - MDRV_CPU_FLAGS(CPU_DISABLE) /* Internal code is not dumped */ + MDRV_DEVICE_DISABLE() /* Internal code is not dumped */ MDRV_MACHINE_RESET(toaplan1) @@ -1801,7 +1801,7 @@ static MACHINE_DRIVER_START( vimana ) MDRV_CPU_ADD("audiocpu", Z180, XTAL_28MHz/8) /* HD647180XOFS6 CPU */ MDRV_CPU_PROGRAM_MAP(hd647180_mem_map) - MDRV_CPU_FLAGS(CPU_DISABLE) /* Internal code is not dumped */ + MDRV_DEVICE_DISABLE() /* Internal code is not dumped */ MDRV_MACHINE_RESET(vimana) diff --git a/src/mame/drivers/toaplan2.c b/src/mame/drivers/toaplan2.c index b597243c8e8..a3eacbcb88e 100644 --- a/src/mame/drivers/toaplan2.c +++ b/src/mame/drivers/toaplan2.c @@ -531,7 +531,7 @@ static DRIVER_INIT( bbakradu ) static READ16_HANDLER( toaplan2_inputport_0_word_r ) { - return ((video_screen_get_vpos(space->machine->primary_screen) + 15) % 262) >= 245; + return ((space->machine->primary_screen->vpos() + 15) % 262) >= 245; } @@ -543,7 +543,7 @@ static TIMER_CALLBACK( toaplan2_raise_irq ) static void toaplan2_vblank_irq(running_machine *machine, int irq_line) { /* the IRQ appears to fire at line 0xe6 */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0xe6, 0), NULL, irq_line, toaplan2_raise_irq); + timer_set(machine, machine->primary_screen->time_until_pos(0xe6), NULL, irq_line, toaplan2_raise_irq); } static INTERRUPT_GEN( toaplan2_vblank_irq1 ) { toaplan2_vblank_irq(device->machine, 1); } @@ -558,8 +558,8 @@ static READ16_HANDLER( video_count_r ) /* +---------+---------+--------+---------------------------+ */ /*************** Control Signals are active low ***************/ - int hpos = video_screen_get_hpos(space->machine->primary_screen); - int vpos = video_screen_get_vpos(space->machine->primary_screen); + int hpos = space->machine->primary_screen->hpos(); + int vpos = space->machine->primary_screen->vpos(); video_status = 0xff00; /* Set signals inactive */ vpos = (vpos + 15) % 262; @@ -575,7 +575,7 @@ static READ16_HANDLER( video_count_r ) else video_status |= 0xff; -// logerror("VC: vpos=%04x hpos=%04x VBL=%04x\n",vpos,hpos,video_screen_get_vblank(space->machine->primary_screen)); +// logerror("VC: vpos=%04x hpos=%04x VBL=%04x\n",vpos,hpos,space->machine->primary_screen->vblank()); return video_status; } @@ -658,7 +658,7 @@ static WRITE16_HANDLER( shippumd_coin_word_w ) if (ACCESSING_BITS_0_7) { toaplan2_coin_w(space, offset, data & 0xff); - okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (((data & 0x10) >> 4) * 0x40000)); + space->machine->device("oki")->set_bank_base(((data & 0x10) >> 4) * 0x40000); } if (ACCESSING_BITS_8_15 && (data & 0xff00) ) { @@ -1000,7 +1000,7 @@ static WRITE16_DEVICE_HANDLER( oki_bankswitch_w ) { if (ACCESSING_BITS_0_7) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + downcast(device)->set_bank_base((data & 1) * 0x40000); } } @@ -1084,7 +1084,7 @@ static WRITE8_HANDLER( bgaregga_bankswitch_w ) static WRITE8_HANDLER( raizing_okim6295_bankselect_0 ) { - running_device *nmk112 = devtag_get_device(space->machine, "nmk112"); + nmk112_device *nmk112 = space->machine->device("nmk112"); nmk112_okibank_w(nmk112, 0, data & 0x0f); // chip 0 bank 0 nmk112_okibank_w(nmk112, 1, (data >> 4) & 0x0f); // chip 0 bank 1 @@ -1092,7 +1092,7 @@ static WRITE8_HANDLER( raizing_okim6295_bankselect_0 ) static WRITE8_HANDLER( raizing_okim6295_bankselect_1 ) { - running_device *nmk112 = devtag_get_device(space->machine, "nmk112"); + nmk112_device *nmk112 = space->machine->device("nmk112"); nmk112_okibank_w(nmk112, 2, data & 0x0f); // chip 0 bank 2 nmk112_okibank_w(nmk112, 3, (data >> 4) & 0x0f); // chip 0 bank 3 @@ -1100,7 +1100,7 @@ static WRITE8_HANDLER( raizing_okim6295_bankselect_1 ) static WRITE8_HANDLER( raizing_okim6295_bankselect_2 ) { - running_device *nmk112 = devtag_get_device(space->machine, "nmk112"); + nmk112_device *nmk112 = space->machine->device("nmk112"); nmk112_okibank_w(nmk112, 4, data & 0x0f); // chip 1 bank 0 nmk112_okibank_w(nmk112, 5, (data >> 4) & 0x0f); // chip 1 bank 1 @@ -1108,7 +1108,7 @@ static WRITE8_HANDLER( raizing_okim6295_bankselect_2 ) static WRITE8_HANDLER( raizing_okim6295_bankselect_3 ) { - running_device *nmk112 = devtag_get_device(space->machine, "nmk112"); + nmk112_device *nmk112 = space->machine->device("nmk112"); nmk112_okibank_w(nmk112, 6, data & 0x0f); // chip 1 bank 2 nmk112_okibank_w(nmk112, 7, (data >> 4) & 0x0f); // chip 1 bank 3 @@ -1267,7 +1267,7 @@ static const eeprom_interface bbakraid_93C66_intf = static READ16_HANDLER( bbakraid_nvram_r ) { - running_device *eeprom = devtag_get_device(space->machine, "eeprom"); + eeprom_device *eeprom = space->machine->device("eeprom"); /* Bit 1 returns the status of BUSAK from the Z80. BUSRQ is activated via bit 0x10 on the NVRAM write port. @@ -3541,8 +3541,7 @@ static MACHINE_DRIVER_START( dogyuun ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_25MHz/24) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_25MHz/24, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -3631,8 +3630,7 @@ static MACHINE_DRIVER_START( kbash ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -3664,12 +3662,10 @@ static MACHINE_DRIVER_START( kbash2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_16MHz/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_16MHz/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -3705,8 +3701,7 @@ static MACHINE_DRIVER_START( truxton2 ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/4) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/4, OKIM6295_PIN7_LOW) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -3893,8 +3888,7 @@ static MACHINE_DRIVER_START( fixeight ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_16MHz/16) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_16MHz/16, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -3926,8 +3920,7 @@ static MACHINE_DRIVER_START( fixeighb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_14MHz/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", XTAL_14MHz/16, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -4089,8 +4082,7 @@ static MACHINE_DRIVER_START( batsugun ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_SOUND_CONFIG(batsugun_ym2151_interface) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/8, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -4126,8 +4118,7 @@ static MACHINE_DRIVER_START( snowbro2 ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_27MHz/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_27MHz/10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -4168,8 +4159,7 @@ static MACHINE_DRIVER_START( mahoudai ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -4210,8 +4200,7 @@ static MACHINE_DRIVER_START( shippumd ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_27MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono",1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END @@ -4252,8 +4241,7 @@ static MACHINE_DRIVER_START( bgaregga ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_32MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_32MHz/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_32MHz/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_NMK112_ADD("nmk112", bgaregga_nmk112_intf) @@ -4296,12 +4284,10 @@ static MACHINE_DRIVER_START( batrider ) MDRV_SOUND_ADD("ymsnd", YM2151, XTAL_32MHz/8) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki1", OKIM6295, XTAL_32MHz/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", XTAL_32MHz/10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MDRV_SOUND_ADD("oki2", OKIM6295, XTAL_32MHz/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7low) + MDRV_OKIM6295_ADD("oki2", XTAL_32MHz/10, OKIM6295_PIN7_LOW) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_NMK112_ADD("nmk112", batrider_nmk112_intf) diff --git a/src/mame/drivers/tomcat.c b/src/mame/drivers/tomcat.c index 9d7872e84e2..7cc227f59a7 100644 --- a/src/mame/drivers/tomcat.c +++ b/src/mame/drivers/tomcat.c @@ -385,7 +385,7 @@ static MACHINE_DRIVER_START(tomcat) MDRV_CPU_IO_MAP( dsp_io_map) MDRV_CPU_ADD("soundcpu", M6502, XTAL_14_31818MHz / 8 ) - MDRV_CPU_FLAGS( CPU_DISABLE ) + MDRV_DEVICE_DISABLE() MDRV_CPU_PROGRAM_MAP( sound_map) MDRV_RIOT6532_ADD("riot", XTAL_14_31818MHz / 8, tomcat_riot6532_intf) diff --git a/src/mame/drivers/toobin.c b/src/mame/drivers/toobin.c index b06bae8094e..4972669d558 100644 --- a/src/mame/drivers/toobin.c +++ b/src/mame/drivers/toobin.c @@ -76,7 +76,7 @@ static WRITE16_HANDLER( interrupt_scan_w ) if (oldword != newword) { state->interrupt_scan[offset] = newword; - atarigen_scanline_int_set(space->machine->primary_screen, newword & 0x1ff); + atarigen_scanline_int_set(*space->machine->primary_screen, newword & 0x1ff); } } @@ -92,7 +92,7 @@ static READ16_HANDLER( special_port1_r ) { toobin_state *state = (toobin_state *)space->machine->driver_data; int result = input_port_read(space->machine, "FF9000"); - if (atarigen_get_hblank(space->machine->primary_screen)) result ^= 0x8000; + if (atarigen_get_hblank(*space->machine->primary_screen)) result ^= 0x8000; if (state->atarigen.cpu_to_sound_ready) result ^= 0x2000; return result; } diff --git a/src/mame/drivers/tubep.c b/src/mame/drivers/tubep.c index 06e8e456209..9c057ab8c05 100644 --- a/src/mame/drivers/tubep.c +++ b/src/mame/drivers/tubep.c @@ -316,16 +316,16 @@ static TIMER_CALLBACK( tubep_scanline_callback ) } - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); //debug - logerror("scanline=%3i scrgetvpos(0)=%3i\n",scanline,video_screen_get_vpos(machine->primary_screen)); + logerror("scanline=%3i scrgetvpos(0)=%3i\n",scanline,machine->primary_screen->vpos()); scanline++; if (scanline >= 264) scanline = 0; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -357,7 +357,7 @@ static MACHINE_START( tubep ) static MACHINE_RESET( tubep ) { - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -497,15 +497,15 @@ static TIMER_CALLBACK( rjammer_scanline_callback ) } - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); - logerror("scanline=%3i scrgetvpos(0)=%3i\n", scanline, video_screen_get_vpos(machine->primary_screen)); + logerror("scanline=%3i scrgetvpos(0)=%3i\n", scanline, machine->primary_screen->vpos()); scanline++; if (scanline >= 264) scanline = 0; - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -519,7 +519,7 @@ static MACHINE_START( rjammer ) static MACHINE_RESET( rjammer ) { - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(0), 0); } diff --git a/src/mame/drivers/tugboat.c b/src/mame/drivers/tugboat.c index 5b09d5246a8..6b44e30842f 100644 --- a/src/mame/drivers/tugboat.c +++ b/src/mame/drivers/tugboat.c @@ -187,12 +187,12 @@ static const pia6821_interface pia1_intf = static TIMER_CALLBACK( interrupt_gen ) { cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); - timer_set(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, interrupt_gen); + timer_set(machine, machine->primary_screen->frame_period(), NULL, 0, interrupt_gen); } static MACHINE_RESET( tugboat ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 30*8+4, 0), NULL, 0, interrupt_gen); + timer_set(machine, machine->primary_screen->time_until_pos(30*8+4), NULL, 0, interrupt_gen); } diff --git a/src/mame/drivers/tumbleb.c b/src/mame/drivers/tumbleb.c index 2411667ff8e..4d92dbb075c 100644 --- a/src/mame/drivers/tumbleb.c +++ b/src/mame/drivers/tumbleb.c @@ -2042,8 +2042,7 @@ static MACHINE_DRIVER_START( tumblepb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 8000000/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 8000000/10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MACHINE_DRIVER_END @@ -2078,8 +2077,7 @@ static MACHINE_DRIVER_START( tumbleb2 ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 8000000/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 8000000/10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MACHINE_DRIVER_END @@ -2117,8 +2115,7 @@ static MACHINE_DRIVER_START( jumpkids ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 8000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 8000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MACHINE_DRIVER_END @@ -2156,8 +2153,7 @@ static MACHINE_DRIVER_START( fncywld ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.20) MDRV_SOUND_ROUTE(1, "rspeaker", 0.20) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -2228,8 +2224,7 @@ static MACHINE_DRIVER_START( htchctch ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.10) MDRV_SOUND_ROUTE(1, "rspeaker", 0.10) - MDRV_SOUND_ADD("oki", OKIM6295, 1024000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1024000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -2308,8 +2303,7 @@ static MACHINE_DRIVER_START( jumppop ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.70) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.70) - MDRV_SOUND_ADD("oki", OKIM6295, 875000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 875000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END @@ -2347,8 +2341,7 @@ static MACHINE_DRIVER_START( suprtrio ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 875000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 875000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END @@ -2383,8 +2376,7 @@ static MACHINE_DRIVER_START( pangpang ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 8000000/10) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 8000000/10, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MACHINE_DRIVER_END diff --git a/src/mame/drivers/tumblep.c b/src/mame/drivers/tumblep.c index 2cfffc857ed..016e756b300 100644 --- a/src/mame/drivers/tumblep.c +++ b/src/mame/drivers/tumblep.c @@ -340,8 +340,7 @@ static MACHINE_DRIVER_START( tumblep ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1023924) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1023924, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/turbo.c b/src/mame/drivers/turbo.c index 51ddc01f020..f90d04d2dea 100644 --- a/src/mame/drivers/turbo.c +++ b/src/mame/drivers/turbo.c @@ -625,7 +625,7 @@ static WRITE8_HANDLER( turbo_8279_w ) static READ8_HANDLER( turbo_collision_r ) { turbo_state *state = (turbo_state *)space->machine->driver_data; - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); return input_port_read(space->machine, "DSW3") | (state->turbo_collision & 15); } @@ -633,7 +633,7 @@ static READ8_HANDLER( turbo_collision_r ) static WRITE8_HANDLER( turbo_collision_clear_w ) { turbo_state *state = (turbo_state *)space->machine->driver_data; - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); state->turbo_collision = 0; } diff --git a/src/mame/drivers/twincobr.c b/src/mame/drivers/twincobr.c index 2fcf4ee8091..278b2fcfd59 100644 --- a/src/mame/drivers/twincobr.c +++ b/src/mame/drivers/twincobr.c @@ -610,7 +610,7 @@ static MACHINE_DRIVER_START( fsharkbt ) MDRV_CPU_ADD("mcu", I8741, XTAL_28MHz/16) /* Program Map is internal to the CPU */ MDRV_CPU_IO_MAP(fsharkbt_i8741_io_map) - MDRV_CPU_FLAGS(CPU_DISABLE) /* Internal program code is not dumped */ + MDRV_DEVICE_DISABLE() /* Internal program code is not dumped */ MDRV_MACHINE_RESET(fsharkbt) /* Reset fshark bootleg 8741 MCU data */ MACHINE_DRIVER_END diff --git a/src/mame/drivers/ultraman.c b/src/mame/drivers/ultraman.c index 35902242969..c2eb7b35680 100644 --- a/src/mame/drivers/ultraman.c +++ b/src/mame/drivers/ultraman.c @@ -262,8 +262,7 @@ static MACHINE_DRIVER_START( ultraman ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/ultratnk.c b/src/mame/drivers/ultratnk.c index c82eb976f2c..1228865de7c 100644 --- a/src/mame/drivers/ultratnk.c +++ b/src/mame/drivers/ultratnk.c @@ -58,13 +58,13 @@ static TIMER_CALLBACK( nmi_callback ) if (input_port_read(machine, "IN0") & 0x40) cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, nmi_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback); } static MACHINE_RESET( ultratnk ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 32, 0), NULL, 32, nmi_callback); + timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback); } diff --git a/src/mame/drivers/unico.c b/src/mame/drivers/unico.c index d9d476e0757..2ab32a00711 100644 --- a/src/mame/drivers/unico.c +++ b/src/mame/drivers/unico.c @@ -53,7 +53,7 @@ static WRITE16_DEVICE_HANDLER( burglarx_sound_bank_w ) if (ACCESSING_BITS_8_15) { int bank = (data >> 8 ) & 1; - okim6295_set_bank_base(device, 0x40000 * bank ); + downcast(device)->set_bank_base(0x40000 * bank ); } } @@ -117,7 +117,7 @@ static READ16_HANDLER( unico_gunx_0_msb_r ) if (x<0x160) x=0x30 + (x*0xd0/0x15f); else x=((x-0x160) * 0x20)/0x1f; - return ((x&0xff) ^ (video_screen_get_frame_number(space->machine->primary_screen)&1))<<8; + return ((x&0xff) ^ (space->machine->primary_screen->frame_number()&1))<<8; } static READ16_HANDLER( unico_guny_0_msb_r ) @@ -126,7 +126,7 @@ static READ16_HANDLER( unico_guny_0_msb_r ) y=0x18+((y*0xe0)/0xff); - return ((y&0xff) ^ (video_screen_get_frame_number(space->machine->primary_screen)&1))<<8; + return ((y&0xff) ^ (space->machine->primary_screen->frame_number()&1))<<8; } static READ16_HANDLER( unico_gunx_1_msb_r ) @@ -137,7 +137,7 @@ static READ16_HANDLER( unico_gunx_1_msb_r ) if (x<0x160) x=0x30 + (x*0xd0/0x15f); else x=((x-0x160) * 0x20)/0x1f; - return ((x&0xff) ^ (video_screen_get_frame_number(space->machine->primary_screen)&1))<<8; + return ((x&0xff) ^ (space->machine->primary_screen->frame_number()&1))<<8; } static READ16_HANDLER( unico_guny_1_msb_r ) @@ -146,7 +146,7 @@ static READ16_HANDLER( unico_guny_1_msb_r ) y=0x18+((y*0xe0)/0xff); - return ((y&0xff) ^ (video_screen_get_frame_number(space->machine->primary_screen)&1))<<8; + return ((y&0xff) ^ (space->machine->primary_screen->frame_number()&1))<<8; } static ADDRESS_MAP_START( zeropnt_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -631,8 +631,7 @@ static MACHINE_DRIVER_START( burglarx ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80) MACHINE_DRIVER_END @@ -678,8 +677,7 @@ static MACHINE_DRIVER_START( zeropnt ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.40) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80) MACHINE_DRIVER_END @@ -722,12 +720,10 @@ static MACHINE_DRIVER_START( zeropnt2 ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.70) MDRV_SOUND_ROUTE(1, "rspeaker", 0.70) - MDRV_SOUND_ADD("oki1", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki1", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.40) - MDRV_SOUND_ADD("oki2", OKIM6295, 3960000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki2", 3960000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.20) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vamphalf.c b/src/mame/drivers/vamphalf.c index 68a0d542535..116c90d4602 100644 --- a/src/mame/drivers/vamphalf.c +++ b/src/mame/drivers/vamphalf.c @@ -187,7 +187,7 @@ F94B static WRITE32_DEVICE_HANDLER( finalgdr_oki_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * ((data & 0x300) >> 8)); + downcast(device)->set_bank_base(0x40000 * ((data & 0x300) >> 8)); } static WRITE32_HANDLER( finalgdr_backupram_bank_w ) @@ -225,7 +225,7 @@ static WRITE32_HANDLER( finalgdr_prize_w ) static WRITE32_DEVICE_HANDLER( aoh_oki_bank_w ) { - okim6295_set_bank_base(device, 0x40000 * (data & 0x3)); + downcast(device)->set_bank_base(0x40000 * (data & 0x3)); } static ADDRESS_MAP_START( common_map, ADDRESS_SPACE_PROGRAM, 16 ) @@ -388,7 +388,7 @@ or Offset+3 -------x xxxxxxxx X offs */ -static void draw_sprites(running_device *screen, bitmap_t *bitmap) +static void draw_sprites(screen_device *screen, bitmap_t *bitmap) { const gfx_element *gfx = screen->machine->gfx[0]; UINT32 cnt; @@ -396,8 +396,8 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap) int code,color,x,y,fx,fy; rectangle clip; - clip.min_x = video_screen_get_visible_area(screen)->min_x; - clip.max_x = video_screen_get_visible_area(screen)->max_x; + clip.min_x = screen->visible_area().min_x; + clip.max_x = screen->visible_area().max_x; for (block=0; block<0x8000; block+=0x800) { @@ -461,7 +461,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap) } } -static void draw_sprites_aoh(running_device *screen, bitmap_t *bitmap) +static void draw_sprites_aoh(screen_device *screen, bitmap_t *bitmap) { const gfx_element *gfx = screen->machine->gfx[0]; UINT32 cnt; @@ -469,8 +469,8 @@ static void draw_sprites_aoh(running_device *screen, bitmap_t *bitmap) int code,color,x,y,fx,fy; rectangle clip; - clip.min_x = video_screen_get_visible_area(screen)->min_x; - clip.max_x = video_screen_get_visible_area(screen)->max_x; + clip.min_x = screen->visible_area().min_x; + clip.max_x = screen->visible_area().max_x; for (block=0; block<0x8000; block+=0x800) { @@ -700,8 +700,7 @@ static MACHINE_DRIVER_START( sound_ym_oki ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 28000000/16 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 28000000/16 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -713,8 +712,7 @@ static MACHINE_DRIVER_START( sound_suplup ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki", OKIM6295, 1789772.5 ) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1789772.5 , OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END @@ -737,7 +735,9 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( misncrft ) MDRV_IMPORT_FROM(common) MDRV_CPU_REPLACE("maincpu", GMS30C2116, 50000000) /* 50 MHz */ + MDRV_CPU_PROGRAM_MAP(common_map) MDRV_CPU_IO_MAP(misncrft_io) + MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) MDRV_IMPORT_FROM(sound_qs1000) MACHINE_DRIVER_END @@ -780,6 +780,7 @@ static MACHINE_DRIVER_START( wyvernwg ) MDRV_CPU_REPLACE("maincpu", E132T, 50000000) /* 50 MHz */ MDRV_CPU_PROGRAM_MAP(common_32bit_map) MDRV_CPU_IO_MAP(wyvernwg_io) + MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) MDRV_IMPORT_FROM(sound_qs1000) MACHINE_DRIVER_END @@ -789,6 +790,7 @@ static MACHINE_DRIVER_START( finalgdr ) MDRV_CPU_REPLACE("maincpu", E132T, 50000000) /* 50 MHz */ MDRV_CPU_PROGRAM_MAP(common_32bit_map) MDRV_CPU_IO_MAP(finalgdr_io) + MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) MDRV_NVRAM_HANDLER(finalgdr) @@ -834,13 +836,11 @@ static MACHINE_DRIVER_START( aoh ) MDRV_SOUND_ROUTE(0, "lspeaker", 1.0) MDRV_SOUND_ROUTE(1, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki_1", OKIM6295, 32000000/8) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki_1", 32000000/8, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) - MDRV_SOUND_ADD("oki_2", OKIM6295, 32000000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki_2", 32000000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vaportra.c b/src/mame/drivers/vaportra.c index 97c9dfabcc1..7f6a34e0e5d 100644 --- a/src/mame/drivers/vaportra.c +++ b/src/mame/drivers/vaportra.c @@ -292,12 +292,10 @@ static MACHINE_DRIVER_START( vaportra ) MDRV_SOUND_ROUTE(0, "mono", 0.60) MDRV_SOUND_ROUTE(1, "mono", 0.60) - MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki1", 32220000/32, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) - MDRV_SOUND_ADD("oki2", OKIM6295, 32220000/16) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki2", 32220000/16, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vball.c b/src/mame/drivers/vball.c index ad06fcab220..1aca94ebc8b 100644 --- a/src/mame/drivers/vball.c +++ b/src/mame/drivers/vball.c @@ -111,26 +111,26 @@ INLINE int scanline_to_vcount(int scanline) static TIMER_DEVICE_CALLBACK( vball_scanline ) { int scanline = param; - int screen_height = video_screen_get_height(timer->machine->primary_screen); + int screen_height = timer.machine->primary_screen->height(); int vcount_old = scanline_to_vcount((scanline == 0) ? screen_height - 1 : scanline - 1); int vcount = scanline_to_vcount(scanline); /* Update to the current point */ if (scanline > 0) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); } /* IRQ fires every on every 8th scanline */ if (!(vcount_old & 8) && (vcount & 8)) { - cputag_set_input_line(timer->machine, "maincpu", M6502_IRQ_LINE, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", M6502_IRQ_LINE, ASSERT_LINE); } /* NMI fires on scanline 248 (VBL) and is latched */ if (vcount == 0xf8) { - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); } /* Save the scroll x register value */ @@ -445,8 +445,7 @@ static MACHINE_DRIVER_START( vball ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.60) MDRV_SOUND_ROUTE(1, "rspeaker", 0.60) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vegas.c b/src/mame/drivers/vegas.c index 0986ca929fb..f12e4844db4 100644 --- a/src/mame/drivers/vegas.c +++ b/src/mame/drivers/vegas.c @@ -475,7 +475,7 @@ static UINT8 cmos_unlocked; static UINT32 *timekeeper_nvram; static size_t timekeeper_nvram_size; -static running_device *voodoo_device; +static running_device *voodoo; static UINT8 dcs_idma_cs; static int dynamic_count; @@ -516,7 +516,7 @@ static void remap_dynamic_addresses(running_machine *machine); static VIDEO_UPDATE( vegas ) { - return voodoo_update(voodoo_device, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; + return voodoo_update(voodoo, bitmap, cliprect) ? 0 : UPDATE_HAS_NOT_CHANGED; } @@ -528,7 +528,7 @@ static VIDEO_UPDATE( vegas ) static MACHINE_START( vegas ) { - voodoo_device = devtag_get_device(machine, "voodoo"); + voodoo = devtag_get_device(machine, "voodoo"); /* allocate timers for the NILE */ timer[0] = timer_alloc(machine, NULL, NULL); @@ -784,7 +784,7 @@ static WRITE32_HANDLER( pci_ide_w ) static READ32_HANDLER( pci_3dfx_r ) { - int voodoo_type = voodoo_get_type(voodoo_device); + int voodoo_type = voodoo_get_type(voodoo); UINT32 result = pci_3dfx_regs[offset]; switch (offset) @@ -817,7 +817,7 @@ static READ32_HANDLER( pci_3dfx_r ) static WRITE32_HANDLER( pci_3dfx_w ) { - int voodoo_type = voodoo_get_type(voodoo_device); + int voodoo_type = voodoo_get_type(voodoo); pci_3dfx_regs[offset] = data; @@ -856,7 +856,7 @@ static WRITE32_HANDLER( pci_3dfx_w ) break; case 0x10: /* initEnable register */ - voodoo_set_init_enable(voodoo_device, data); + voodoo_set_init_enable(voodoo, data); break; } @@ -1553,7 +1553,7 @@ static void remap_dynamic_addresses(running_machine *machine) { running_device *ethernet = devtag_get_device(machine, "ethernet"); running_device *ide = devtag_get_device(machine, "ide"); - int voodoo_type = voodoo_get_type(voodoo_device); + int voodoo_type = voodoo_get_type(voodoo); offs_t base; int addr; @@ -1652,24 +1652,24 @@ static void remap_dynamic_addresses(running_machine *machine) if (base >= ramsize && base < 0x20000000) { if (voodoo_type == VOODOO_2) - add_dynamic_device_address(voodoo_device, base + 0x000000, base + 0xffffff, voodoo_r, voodoo_w); + add_dynamic_device_address(voodoo, base + 0x000000, base + 0xffffff, voodoo_r, voodoo_w); else - add_dynamic_device_address(voodoo_device, base + 0x000000, base + 0x1ffffff, banshee_r, banshee_w); + add_dynamic_device_address(voodoo, base + 0x000000, base + 0x1ffffff, banshee_r, banshee_w); } if (voodoo_type >= VOODOO_BANSHEE) { base = pci_3dfx_regs[0x05] & 0xfffffff0; if (base >= ramsize && base < 0x20000000) - add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x1ffffff, banshee_fb_r, banshee_fb_w); + add_dynamic_device_address(voodoo, base + 0x0000000, base + 0x1ffffff, banshee_fb_r, banshee_fb_w); base = pci_3dfx_regs[0x06] & 0xfffffff0; if (base >= ramsize && base < 0x20000000) - add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x00000ff, banshee_io_r, banshee_io_w); + add_dynamic_device_address(voodoo, base + 0x0000000, base + 0x00000ff, banshee_io_r, banshee_io_w); base = pci_3dfx_regs[0x0c] & 0xffff0000; if (base >= ramsize && base < 0x20000000) - add_dynamic_device_address(voodoo_device, base + 0x0000000, base + 0x000ffff, banshee_rom_r, NULL); + add_dynamic_device_address(voodoo, base + 0x0000000, base + 0x000ffff, banshee_rom_r, NULL); } } @@ -2258,7 +2258,8 @@ static MACHINE_DRIVER_START( vegas250 ) MDRV_IMPORT_FROM(vegascore) MDRV_IMPORT_FROM(dcs2_audio_2104) - MDRV_CPU_REPLACE("maincpu", R5000LE, SYSTEM_CLOCK*2.5) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(SYSTEM_CLOCK*2.5) MACHINE_DRIVER_END @@ -2288,6 +2289,8 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( vegasv3 ) MDRV_IMPORT_FROM(vegas32m) MDRV_CPU_REPLACE("maincpu", RM7000LE, SYSTEM_CLOCK*2.5) + MDRV_CPU_CONFIG(config) + MDRV_CPU_PROGRAM_MAP(vegas_map_8mb) MDRV_DEVICE_REMOVE("voodoo") MDRV_3DFX_VOODOO_3_ADD("voodoo", STD_VOODOO_3_CLOCK, 16, "screen") @@ -2301,6 +2304,7 @@ static MACHINE_DRIVER_START( denver ) MDRV_IMPORT_FROM(dcs2_audio_denver) MDRV_CPU_REPLACE("maincpu", RM7000LE, SYSTEM_CLOCK*2.5) + MDRV_CPU_CONFIG(config) MDRV_CPU_PROGRAM_MAP(vegas_map_32mb) MDRV_DEVICE_REMOVE("voodoo") diff --git a/src/mame/drivers/vicdual.c b/src/mame/drivers/vicdual.c index a434a56779e..5f21fe68713 100644 --- a/src/mame/drivers/vicdual.c +++ b/src/mame/drivers/vicdual.c @@ -98,7 +98,7 @@ static INPUT_CHANGED( coin_changed ) cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE); /* simulate the coin switch being closed for a while */ - timer_set(field->port->machine, double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(field->port->machine->primary_screen))), NULL, 0, clear_coin_status); + timer_set(field->port->machine, double_to_attotime(4 * attotime_to_double(field->port->machine->primary_screen->frame_period())), NULL, 0, clear_coin_status); } } @@ -123,11 +123,11 @@ static INPUT_CHANGED( coin_changed ) static int get_vcounter(running_machine *machine) { - int vcounter = video_screen_get_vpos(machine->primary_screen); + int vcounter = machine->primary_screen->vpos(); /* the vertical synch counter gets incremented at the end of HSYNC, compensate for this */ - if (video_screen_get_hpos(machine->primary_screen) >= VICDUAL_HSEND) + if (machine->primary_screen->hpos() >= VICDUAL_HSEND) vcounter = (vcounter + 1) % VICDUAL_VTOTAL; return vcounter; @@ -148,7 +148,7 @@ static CUSTOM_INPUT( vicdual_get_vblank_comp ) static CUSTOM_INPUT( vicdual_get_composite_blank_comp ) { - return (vicdual_get_vblank_comp(field, 0) && !video_screen_get_hblank(field->port->machine->primary_screen)); + return (vicdual_get_vblank_comp(field, 0) && !field->port->machine->primary_screen->hblank()); } @@ -195,7 +195,7 @@ static UINT8 *vicdual_characterram; static WRITE8_HANDLER( vicdual_videoram_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); vicdual_videoram[offset] = data; } @@ -208,7 +208,7 @@ UINT8 vicdual_videoram_r(offs_t offset) static WRITE8_HANDLER( vicdual_characterram_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); vicdual_characterram[offset] = data; } diff --git a/src/mame/drivers/videopin.c b/src/mame/drivers/videopin.c index 0107e7f61dd..3b25a34b613 100644 --- a/src/mame/drivers/videopin.c +++ b/src/mame/drivers/videopin.c @@ -60,7 +60,7 @@ static TIMER_CALLBACK( interrupt_callback ) if (scanline >= 263) scanline = 32; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, interrupt_callback); } @@ -68,7 +68,7 @@ static MACHINE_RESET( videopin ) { running_device *discrete = devtag_get_device(machine, "discrete"); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 32, 0), NULL, 32, interrupt_callback); + timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, interrupt_callback); /* both output latches are cleared on reset */ @@ -113,7 +113,7 @@ static READ8_HANDLER( videopin_misc_r ) static WRITE8_HANDLER( videopin_led_w ) { - int i = (video_screen_get_vpos(space->machine->primary_screen) >> 5) & 7; + int i = (space->machine->primary_screen->vpos() >> 5) & 7; static const char *const matrix[8][4] = { { "LED26", "LED18", "LED11", "LED13" }, diff --git a/src/mame/drivers/videopkr.c b/src/mame/drivers/videopkr.c index e9d5429a6c2..0112afe06ac 100644 --- a/src/mame/drivers/videopkr.c +++ b/src/mame/drivers/videopkr.c @@ -919,7 +919,7 @@ static TIMER_DEVICE_CALLBACK(sound_t1_callback) if (dc_40103 == 0) { - cputag_set_input_line(timer->machine, "soundcpu", 0, ASSERT_LINE); + cputag_set_input_line(timer.machine, "soundcpu", 0, ASSERT_LINE); } } } @@ -1263,7 +1263,8 @@ static MACHINE_DRIVER_START( videodad ) /* basic machine hardware */ MDRV_IMPORT_FROM(videopkr) - MDRV_CPU_REPLACE("maincpu", I8039, CPU_CLOCK_ALT) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(CPU_CLOCK_ALT) /* video hardware */ MDRV_SCREEN_MODIFY("screen") @@ -1279,7 +1280,8 @@ static MACHINE_DRIVER_START( babypkr ) /* basic machine hardware */ MDRV_IMPORT_FROM(videopkr) - MDRV_CPU_REPLACE("maincpu", I8039, CPU_CLOCK_ALT) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(CPU_CLOCK_ALT) /* most likely romless or eprom */ MDRV_CPU_REPLACE("soundcpu", I8031, CPU_CLOCK ) MDRV_CPU_PROGRAM_MAP(i8051_sound_mem) @@ -1303,7 +1305,8 @@ static MACHINE_DRIVER_START( fortune1 ) /* basic machine hardware */ MDRV_IMPORT_FROM(videopkr) - MDRV_CPU_REPLACE("maincpu", I8039, CPU_CLOCK_ALT) + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_CLOCK(CPU_CLOCK_ALT) MDRV_PALETTE_INIT(fortune1) MACHINE_DRIVER_END diff --git a/src/mame/drivers/vindictr.c b/src/mame/drivers/vindictr.c index d708a6ea957..680dfe45f5a 100644 --- a/src/mame/drivers/vindictr.c +++ b/src/mame/drivers/vindictr.c @@ -50,7 +50,7 @@ static MACHINE_RESET( vindictr ) atarigen_eeprom_reset(&state->atarigen); atarigen_interrupt_reset(&state->atarigen, update_interrupts); - atarigen_scanline_timer_reset(machine->primary_screen, vindictr_scanline_update, 8); + atarigen_scanline_timer_reset(*machine->primary_screen, vindictr_scanline_update, 8); atarijsa_reset(); } diff --git a/src/mame/drivers/vmetal.c b/src/mame/drivers/vmetal.c index 4b3db9e81c0..92e2aa58339 100644 --- a/src/mame/drivers/vmetal.c +++ b/src/mame/drivers/vmetal.c @@ -448,8 +448,7 @@ static MACHINE_DRIVER_START( varia ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1320000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1320000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.75) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.75) diff --git a/src/mame/drivers/wheelfir.c b/src/mame/drivers/wheelfir.c index abf96f82c1e..1ec6077a330 100644 --- a/src/mame/drivers/wheelfir.c +++ b/src/mame/drivers/wheelfir.c @@ -153,8 +153,8 @@ static bitmap_t* render_bitmap; static WRITE16_HANDLER(wheelfir_blit_w) { //wheelfir_blitdata[offset]=data; - int width = video_screen_get_width(space->machine->primary_screen); - int height = video_screen_get_height(space->machine->primary_screen); + int width = space->machine->primary_screen->width(); + int height = space->machine->primary_screen->height(); int vpage=0; COMBINE_DATA(&wheelfir_blitdata[offset]); @@ -275,11 +275,11 @@ static WRITE16_HANDLER(wheelfir_blit_w) static VIDEO_START(wheelfir) { - wheelfir_tmp_bitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - wheelfir_tmp_bitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - wheelfir_tmp_bitmap[2] = video_screen_auto_bitmap_alloc(machine->primary_screen); + wheelfir_tmp_bitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + wheelfir_tmp_bitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); + wheelfir_tmp_bitmap[2] = machine->primary_screen->alloc_compatible_bitmap(); - render_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + render_bitmap = machine->primary_screen->alloc_compatible_bitmap(); } @@ -304,7 +304,7 @@ static VIDEO_UPDATE(wheelfir) copybitmap(bitmap, wheelfir_tmp_bitmap[2], 0, 0, 0, 0, cliprect); //copybitmap_trans(bitmap, wheelfir_tmp_bitmap[1], 0, 0, 0, 0, cliprect, 0); copybitmap_trans(bitmap, wheelfir_tmp_bitmap[0], 0, 0, 0, 0, cliprect, 0); - bitmap_fill(wheelfir_tmp_bitmap[0], video_screen_get_visible_area(screen),0); + bitmap_fill(wheelfir_tmp_bitmap[0], screen->visible_area(),0); if ( input_code_pressed(screen->machine, KEYCODE_R) ) { @@ -540,8 +540,8 @@ static INPUT_PORTS_START( wheelfir ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) INPUT_PORTS_END -static running_device* frame_timer; -static running_device* scanline_timer; +static timer_device* frame_timer; +static timer_device* scanline_timer; static TIMER_DEVICE_CALLBACK( frame_timer_callback ) { @@ -572,13 +572,13 @@ static void render_background_to_render_buffer(int scanline) static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) { - timer_call_after_resynch(timer->machine, NULL, 0, 0); + timer_call_after_resynch(timer.machine, NULL, 0, 0); if (scanline_counter != (total_scanlines - 1)) { scanline_counter++; - cputag_set_input_line(timer->machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road - timer_device_adjust_oneshot(timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0); + cputag_set_input_line(timer.machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road + timer.adjust(attotime_div(ATTOTIME_IN_HZ(60), total_scanlines)); if (scanline_counter < 256) { @@ -587,7 +587,7 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) if (scanline_counter == 256) { - cputag_set_input_line(timer->machine, "maincpu", 3, HOLD_LINE); // vblank IRQ? + cputag_set_input_line(timer.machine, "maincpu", 3, HOLD_LINE); // vblank IRQ? toggle_bit = 0x8000; // must toggle.. } @@ -607,18 +607,18 @@ static TIMER_DEVICE_CALLBACK( scanline_timer_callback ) static VIDEO_EOF( wheelfir ) { scanline_counter = -1; - bitmap_fill(wheelfir_tmp_bitmap[0], video_screen_get_visible_area(machine->primary_screen),0); + bitmap_fill(wheelfir_tmp_bitmap[0], &machine->primary_screen->visible_area(),0); - timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); - timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); + frame_timer->reset(); + scanline_timer->reset(); } static MACHINE_RESET(wheelfir) { - frame_timer = devtag_get_device(machine, "frame_timer"); - scanline_timer = devtag_get_device(machine, "scan_timer"); - timer_device_adjust_oneshot(frame_timer, attotime_zero, 0); - timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0); + frame_timer = machine->device("frame_timer"); + scanline_timer = machine->device("scan_timer"); + frame_timer->reset(); + scanline_timer->reset(); scanline_counter = -1; } diff --git a/src/mame/drivers/wolfpack.c b/src/mame/drivers/wolfpack.c index 9b200e28ee5..5b3cffe5d21 100644 --- a/src/mame/drivers/wolfpack.c +++ b/src/mame/drivers/wolfpack.c @@ -42,13 +42,13 @@ static TIMER_CALLBACK( periodic_callback ) if (scanline >= 262) scanline = 0; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, periodic_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, periodic_callback); } static MACHINE_RESET( wolfpack ) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, periodic_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, periodic_callback); } @@ -79,7 +79,7 @@ static READ8_HANDLER( wolfpack_misc_r ) if (!wolfpack_collision) val |= 0x10; - if (video_screen_get_vpos(space->machine->primary_screen) >= 240) + if (space->machine->primary_screen->vpos() >= 240) val |= 0x80; return val; diff --git a/src/mame/drivers/wrally.c b/src/mame/drivers/wrally.c index 79548a487c5..0b4f27fbbb1 100644 --- a/src/mame/drivers/wrally.c +++ b/src/mame/drivers/wrally.c @@ -275,8 +275,7 @@ static MACHINE_DRIVER_START( wrally ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1MHz) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb */ + MDRV_OKIM6295_ADD("oki", XTAL_1MHz, OKIM6295_PIN7_HIGH) /* verified on pcb */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/wwfsstar.c b/src/mame/drivers/wwfsstar.c index 1f634edfb0e..276ff479581 100644 --- a/src/mame/drivers/wwfsstar.c +++ b/src/mame/drivers/wwfsstar.c @@ -242,7 +242,7 @@ static WRITE16_HANDLER( wwfsstar_irqack_w ) static TIMER_DEVICE_CALLBACK( wwfsstar_scanline ) { - wwfsstar_state *state = (wwfsstar_state *)timer->machine->driver_data; + wwfsstar_state *state = (wwfsstar_state *)timer.machine->driver_data; int scanline = param; /* Vblank is lowered on scanline 0 */ @@ -260,15 +260,15 @@ static TIMER_DEVICE_CALLBACK( wwfsstar_scanline ) if (scanline % 16 == 0) { if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 5, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 5, ASSERT_LINE); } /* Vblank is raised on scanline 240 */ if (scanline == 240) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 6, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 6, ASSERT_LINE); } } @@ -458,8 +458,7 @@ static MACHINE_DRIVER_START( wwfsstar ) MDRV_SOUND_ROUTE(0, "lspeaker", 0.45) MDRV_SOUND_ROUTE(1, "rspeaker", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_1_056MHz) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", XTAL_1_056MHz, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.47) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.47) MACHINE_DRIVER_END diff --git a/src/mame/drivers/wwfwfest.c b/src/mame/drivers/wwfwfest.c index 174e98a2fb6..c689897fd9c 100644 --- a/src/mame/drivers/wwfwfest.c +++ b/src/mame/drivers/wwfwfest.c @@ -160,7 +160,7 @@ static WRITE16_HANDLER( wwfwfest_scroll_write ) static WRITE8_DEVICE_HANDLER( oki_bankswitch_w ) { - okim6295_set_bank_base(device, (data & 1) * 0x40000); + downcast(device)->set_bank_base((data & 1) * 0x40000); } static WRITE16_HANDLER ( wwfwfest_soundwrite ) @@ -351,15 +351,15 @@ static TIMER_DEVICE_CALLBACK( wwfwfest_scanline ) if (scanline % 16 == 0) { if (scanline > 0) - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 2, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 2, ASSERT_LINE); } /* Vblank is raised on scanline 248 */ if (scanline == 248) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); - cputag_set_input_line(timer->machine, "maincpu", 3, ASSERT_LINE); + timer.machine->primary_screen->update_partial(scanline - 1); + cputag_set_input_line(timer.machine, "maincpu", 3, ASSERT_LINE); } } @@ -422,8 +422,7 @@ static MACHINE_DRIVER_START( wwfwfest ) MDRV_SOUND_ROUTE(0, "mono", 0.45) MDRV_SOUND_ROUTE(1, "mono", 0.45) - MDRV_SOUND_ADD("oki", OKIM6295, 1024188) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* Verified - Pin 7 tied to +5VDC */ + MDRV_OKIM6295_ADD("oki", 1024188, OKIM6295_PIN7_HIGH) /* Verified - Pin 7 tied to +5VDC */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90) MACHINE_DRIVER_END diff --git a/src/mame/drivers/xain.c b/src/mame/drivers/xain.c index 4d24aa625ad..7fa42684caa 100644 --- a/src/mame/drivers/xain.c +++ b/src/mame/drivers/xain.c @@ -194,26 +194,26 @@ INLINE int scanline_to_vcount(int scanline) static TIMER_DEVICE_CALLBACK( xain_scanline ) { int scanline = param; - int screen_height = video_screen_get_height(timer->machine->primary_screen); + int screen_height = timer.machine->primary_screen->height(); int vcount_old = scanline_to_vcount((scanline == 0) ? screen_height - 1 : scanline - 1); int vcount = scanline_to_vcount(scanline); /* update to the current point */ if (scanline > 0) { - video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + timer.machine->primary_screen->update_partial(scanline - 1); } /* FIRQ (IMS) fires every on every 8th scanline (except 0) */ if (!(vcount_old & 8) && (vcount & 8)) { - cputag_set_input_line(timer->machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); } /* NMI fires on scanline 248 (VBL) and is latched */ if (vcount == 0xf8) { - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); } /* VBLANK input bit is held high from scanlines 248-255 */ diff --git a/src/mame/drivers/xexex.c b/src/mame/drivers/xexex.c index 17c738a1798..46cf441e8c3 100644 --- a/src/mame/drivers/xexex.c +++ b/src/mame/drivers/xexex.c @@ -125,7 +125,7 @@ static void xexex_objdma( running_machine *machine, int limiter ) UINT16 *src, *dst; counter = state->frame; - state->frame = video_screen_get_frame_number(machine->primary_screen); + state->frame = machine->primary_screen->frame_number(); if (limiter && counter == state->frame) return; // make sure we only do DMA transfer once per frame diff --git a/src/mame/drivers/xtheball.c b/src/mame/drivers/xtheball.c index 65c8f4f3bde..71a566a1b09 100644 --- a/src/mame/drivers/xtheball.c +++ b/src/mame/drivers/xtheball.c @@ -44,7 +44,7 @@ static MACHINE_RESET( xtheball ) * *************************************/ -static void xtheball_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +static void xtheball_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *srcbg = &vram_bg[(params->rowaddr << 8) & 0xff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); diff --git a/src/mame/drivers/yunsun16.c b/src/mame/drivers/yunsun16.c index cecdb0de734..b30fa4e451d 100644 --- a/src/mame/drivers/yunsun16.c +++ b/src/mame/drivers/yunsun16.c @@ -627,8 +627,7 @@ static MACHINE_DRIVER_START( magicbub ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.20) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.20) - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.80) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.80) MACHINE_DRIVER_END @@ -668,8 +667,7 @@ static MACHINE_DRIVER_START( shocking ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MDRV_SOUND_ADD("oki", OKIM6295, 1000000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) + MDRV_OKIM6295_ADD("oki", 1000000, OKIM6295_PIN7_HIGH) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/zerozone.c b/src/mame/drivers/zerozone.c index 5c49583b17b..ceea25b444e 100644 --- a/src/mame/drivers/zerozone.c +++ b/src/mame/drivers/zerozone.c @@ -219,8 +219,7 @@ static MACHINE_DRIVER_START( zerozone ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("oki", OKIM6295, 1056000) - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified + MDRV_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/zn.c b/src/mame/drivers/zn.c index 0d90b0c799d..42356488ee5 100644 --- a/src/mame/drivers/zn.c +++ b/src/mame/drivers/zn.c @@ -345,7 +345,7 @@ static READ32_HANDLER( boardconfig_r ) 111----- rev=5 */ - if( video_screen_get_height(space->machine->primary_screen) == 1024 ) + if( space->machine->primary_screen->height() == 1024 ) { return 64|32|8; } diff --git a/src/mame/includes/amiga.h b/src/mame/includes/amiga.h index b211dcad004..bba8987d966 100644 --- a/src/mame/includes/amiga.h +++ b/src/mame/includes/amiga.h @@ -10,6 +10,8 @@ Ernesto Corvi & Mariusz Wojcieszek #ifndef __AMIGA_H__ #define __AMIGA_H__ +#include "devlegcy.h" + /* A bit of a trick here: some registers are 32-bit. In order to efficiently */ /* read them on both big-endian and little-endian systems, we store the custom */ @@ -396,8 +398,7 @@ const amiga_machine_interface *amiga_get_interface(void); /*----------- defined in audio/amiga.c -----------*/ -DEVICE_GET_INFO( amiga_sound ); -#define SOUND_AMIGA DEVICE_GET_INFO_NAME(amiga_sound) +DECLARE_LEGACY_SOUND_DEVICE(AMIGA, amiga_sound); void amiga_audio_update(void); void amiga_audio_data_w(int which, UINT16 data); @@ -409,7 +410,7 @@ PALETTE_INIT( amiga ); VIDEO_START( amiga ); VIDEO_UPDATE( amiga ); -UINT32 amiga_gethvpos(running_device *screen); +UINT32 amiga_gethvpos(screen_device &screen); void copper_setpc(UINT32 pc); void amiga_set_genlock_color(UINT16 color); void amiga_render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline); @@ -421,7 +422,7 @@ void amiga_sprite_enable_comparitor(int which, int enable); VIDEO_START( amiga_aga ); VIDEO_UPDATE( amiga_aga ); -UINT32 amiga_aga_gethvpos(running_device *screen); +UINT32 amiga_aga_gethvpos(screen_device &screen); void aga_copper_setpc(UINT32 pc); void amiga_aga_set_genlock_color(UINT16 color); void amiga_aga_render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline); diff --git a/src/mame/includes/artmagic.h b/src/mame/includes/artmagic.h index f6b331cf55d..4ae44cdce9c 100644 --- a/src/mame/includes/artmagic.h +++ b/src/mame/includes/artmagic.h @@ -19,4 +19,4 @@ void artmagic_from_shiftreg(const address_space *space, offs_t address, UINT16 * READ16_HANDLER( artmagic_blitter_r ); WRITE16_HANDLER( artmagic_blitter_w ); -void artmagic_scanline(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void artmagic_scanline(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/atarig1.h b/src/mame/includes/atarig1.h index e68b7293640..da7bc1dc1f6 100644 --- a/src/mame/includes/atarig1.h +++ b/src/mame/includes/atarig1.h @@ -39,4 +39,4 @@ WRITE16_HANDLER( atarig1_mo_control_w ); VIDEO_START( atarig1 ); VIDEO_UPDATE( atarig1 ); -void atarig1_scanline_update(running_device *screen, int scanline); +void atarig1_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/atarig42.h b/src/mame/includes/atarig42.h index eb9a391cda0..81838a80526 100644 --- a/src/mame/includes/atarig42.h +++ b/src/mame/includes/atarig42.h @@ -42,5 +42,5 @@ VIDEO_UPDATE( atarig42 ); WRITE16_HANDLER( atarig42_mo_control_w ); -void atarig42_scanline_update(running_device *screen, int scanline); +void atarig42_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/atarigt.h b/src/mame/includes/atarigt.h index cd12a5e24ee..69310d12925 100644 --- a/src/mame/includes/atarigt.h +++ b/src/mame/includes/atarigt.h @@ -49,4 +49,4 @@ UINT16 atarigt_colorram_r(atarigt_state *state, offs_t address); VIDEO_START( atarigt ); VIDEO_UPDATE( atarigt ); -void atarigt_scanline_update(running_device *screen, int scanline); +void atarigt_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/atarigx2.h b/src/mame/includes/atarigx2.h index a66ccf3bb00..ee0f0b46b67 100644 --- a/src/mame/includes/atarigx2.h +++ b/src/mame/includes/atarigx2.h @@ -36,4 +36,4 @@ VIDEO_UPDATE( atarigx2 ); WRITE16_HANDLER( atarigx2_mo_control_w ); -void atarigx2_scanline_update(running_device *screen, int scanline); +void atarigx2_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/atarisy1.h b/src/mame/includes/atarisy1.h index 8d858c5a3bd..8bf2a641ae1 100644 --- a/src/mame/includes/atarisy1.h +++ b/src/mame/includes/atarisy1.h @@ -11,7 +11,11 @@ class atarisy1_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarisy1_state(machine)); } - atarisy1_state(running_machine &machine) { } + atarisy1_state(running_machine &machine) + : joystick_timer(machine.device("joystick_timer")), + yscroll_reset_timer(machine.device("yreset_timer")), + scanline_timer(machine.device("scan_timer")), + int3off_timer(machine.device("int3off_timer")) { } atarigen_state atarigen; @@ -20,7 +24,7 @@ public: UINT8 joystick_type; UINT8 trackball_type; - running_device *joystick_timer; + timer_device * joystick_timer; UINT8 joystick_int; UINT8 joystick_int_enable; UINT8 joystick_value; @@ -29,12 +33,12 @@ public: UINT16 playfield_lookup[256]; UINT8 playfield_tile_bank; UINT16 playfield_priority_pens; - running_device *yscroll_reset_timer; + timer_device * yscroll_reset_timer; /* INT3 tracking */ int next_timer_scanline; - running_device *scanline_timer; - running_device *int3off_timer; + timer_device * scanline_timer; + timer_device * int3off_timer; /* graphics bank tracking */ UINT8 bank_gfx[3][8]; diff --git a/src/mame/includes/balsente.h b/src/mame/includes/balsente.h index ed82b71f075..0fb391bb9ab 100644 --- a/src/mame/includes/balsente.h +++ b/src/mame/includes/balsente.h @@ -6,6 +6,7 @@ ***************************************************************************/ +#include "sound/cem3394.h" #define BALSENTE_MASTER_CLOCK (20000000) #define BALSENTE_CPU_CLOCK (BALSENTE_MASTER_CLOCK / 16) @@ -30,7 +31,17 @@ class balsente_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, balsente_state(machine)); } - balsente_state(running_machine &machine) { } + balsente_state(running_machine &machine) + : scanline_timer(machine.device("scan_timer")), + counter_0_timer(machine.device("8253_0_timer")) + { + astring temp; + for (int i = 0; i < ARRAY_LENGTH(cem_device); i++) + { + cem_device[i] = machine.device(temp.format("cem%d", i+1)); + assert(cem_device[i] != NULL); + } + } /* global data */ UINT8 shooter; @@ -43,7 +54,7 @@ public: /* 8253 counter state */ struct { - running_device *timer; + timer_device *timer; UINT8 timer_active; INT32 initial; INT32 count; @@ -54,12 +65,12 @@ public: UINT8 writebyte; } counter[3]; - running_device *scanline_timer; + timer_device *scanline_timer; /* manually clocked counter 0 states */ UINT8 counter_control; UINT8 counter_0_ff; - running_device *counter_0_timer; + timer_device *counter_0_timer; UINT8 counter_0_timer_active; /* random number generator states */ @@ -90,7 +101,7 @@ public: /* noise generator states */ UINT32 noise_position[6]; - running_device *cem_device[6]; + cem3394_sound_device *cem_device[6]; /* game-specific states */ UINT8 nstocker_bits; diff --git a/src/mame/includes/batman.h b/src/mame/includes/batman.h index f8911124aa1..82f66729ccb 100644 --- a/src/mame/includes/batman.h +++ b/src/mame/includes/batman.h @@ -26,4 +26,4 @@ public: VIDEO_START( batman ); VIDEO_UPDATE( batman ); -void batman_scanline_update(running_device *screen, int scanline); +void batman_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/blstroid.h b/src/mame/includes/blstroid.h index 71793617d1f..5c95fdbbdbd 100644 --- a/src/mame/includes/blstroid.h +++ b/src/mame/includes/blstroid.h @@ -24,4 +24,4 @@ public: VIDEO_START( blstroid ); VIDEO_UPDATE( blstroid ); -void blstroid_scanline_update(running_device *screen, int scanline); +void blstroid_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/boogwing.h b/src/mame/includes/boogwing.h index 81e26c6e3e6..68fde98664e 100644 --- a/src/mame/includes/boogwing.h +++ b/src/mame/includes/boogwing.h @@ -4,12 +4,20 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "video/deco16ic.h" + class boogwing_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, boogwing_state(machine)); } - boogwing_state(running_machine &machine) { } + boogwing_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + audiocpu(machine.device("audiocpu")), + deco16ic(machine.device("deco_custom")), + oki1(machine.device("oki1")), + oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * pf1_rowscroll; @@ -18,11 +26,11 @@ public: UINT16 * pf4_rowscroll; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *deco16ic; - running_device *oki1; - running_device *oki2; + cpu_device *maincpu; + cpu_device *audiocpu; + deco16ic_device *deco16ic; + okim6295_device *oki1; + okim6295_device *oki2; }; diff --git a/src/mame/includes/btoads.h b/src/mame/includes/btoads.h index e124e2da314..f49ce7f8889 100644 --- a/src/mame/includes/btoads.h +++ b/src/mame/includes/btoads.h @@ -37,4 +37,4 @@ READ16_HANDLER( btoads_vram_fg_draw_r ); void btoads_to_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); void btoads_from_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); -void btoads_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void btoads_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/bzone.h b/src/mame/includes/bzone.h index 205ce85df6e..1f3e3b2104e 100644 --- a/src/mame/includes/bzone.h +++ b/src/mame/includes/bzone.h @@ -4,6 +4,8 @@ *************************************************************************/ +#include "devlegcy.h" + #define BZONE_MASTER_CLOCK (XTAL_12_096MHz) #define BZONE_CLOCK_3KHZ (MASTER_CLOCK / 4096) @@ -23,5 +25,4 @@ MACHINE_DRIVER_EXTERN( bzone_audio ); WRITE8_HANDLER( redbaron_sounds_w ); -DEVICE_GET_INFO( redbaron_sound ); -#define SOUND_REDBARON DEVICE_GET_INFO_NAME(redbaron_sound) +DECLARE_LEGACY_SOUND_DEVICE(REDBARON, redbaron_sound); diff --git a/src/mame/includes/cninja.h b/src/mame/includes/cninja.h index 74351a18e1a..a37eb42cdff 100644 --- a/src/mame/includes/cninja.h +++ b/src/mame/includes/cninja.h @@ -4,12 +4,20 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "video/deco16ic.h" + class cninja_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cninja_state(machine)); } - cninja_state(running_machine &machine) { } + cninja_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + audiocpu(machine.device("audiocpu")), + deco16ic(machine.device("deco_custom")), + raster_irq_timer(machine.device("raster_timer")), + oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * ram; @@ -22,11 +30,11 @@ public: int scanline, irq_mask; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *deco16ic; - running_device *raster_irq_timer; - running_device *oki2; + cpu_device *maincpu; + cpu_device *audiocpu; + deco16ic_device *deco16ic; + timer_device *raster_irq_timer; + okim6295_device *oki2; }; /*----------- defined in video/cninja.c -----------*/ diff --git a/src/mame/includes/cps3.h b/src/mame/includes/cps3.h index 171f18308bc..06f1b96a5d4 100644 --- a/src/mame/includes/cps3.h +++ b/src/mame/includes/cps3.h @@ -4,10 +4,11 @@ ****************************************************************************/ +#include "devlegcy.h" + /*----------- defined in audio/cps3.c -----------*/ -DEVICE_GET_INFO( cps3_sound ); -#define SOUND_CPS3 DEVICE_GET_INFO_NAME(cps3_sound) +DECLARE_LEGACY_SOUND_DEVICE(CPS3, cps3_sound); WRITE32_HANDLER( cps3_sound_w ); READ32_HANDLER( cps3_sound_r ); diff --git a/src/mame/includes/cyberbal.h b/src/mame/includes/cyberbal.h index 199ec697102..36302ca60a2 100644 --- a/src/mame/includes/cyberbal.h +++ b/src/mame/includes/cyberbal.h @@ -62,4 +62,4 @@ VIDEO_START( cyberbal ); VIDEO_START( cyberbal2p ); VIDEO_UPDATE( cyberbal ); -void cyberbal_scanline_update(running_device *screen, int scanline); +void cyberbal_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/dassault.h b/src/mame/includes/dassault.h index abe9feef40a..38e83efbd88 100644 --- a/src/mame/includes/dassault.h +++ b/src/mame/includes/dassault.h @@ -4,12 +4,20 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "video/deco16ic.h" + class dassault_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dassault_state(machine)); } - dassault_state(running_machine &machine) { } + dassault_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + audiocpu(machine.device("audiocpu")), + subcpu(machine.device("sub")), + deco16ic(machine.device("deco_custom")), + oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * pf2_rowscroll; @@ -19,11 +27,11 @@ public: UINT16 * shared_ram; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *subcpu; - running_device *deco16ic; - running_device *oki2; + cpu_device *maincpu; + cpu_device *audiocpu; + cpu_device *subcpu; + deco16ic_device *deco16ic; + okim6295_device *oki2; }; diff --git a/src/mame/includes/drgnmst.h b/src/mame/includes/drgnmst.h index 085e2941bf9..d84da91538f 100644 --- a/src/mame/includes/drgnmst.h +++ b/src/mame/includes/drgnmst.h @@ -1,10 +1,14 @@ +#include "sound/okim6295.h" + class drgnmst_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, drgnmst_state(machine)); } - drgnmst_state(running_machine &machine) { } + drgnmst_state(running_machine &machine) + : oki_1(machine.device("oki1")), + oki_2(machine.device("oki2")) { } /* memory pointers */ UINT16 * vidregs; @@ -30,8 +34,8 @@ public: UINT8 oki1_bank; /* devices */ - running_device *oki_1; - running_device *oki_2; + okim6295_device *oki_1; + okim6295_device *oki_2; }; diff --git a/src/mame/includes/dynax.h b/src/mame/includes/dynax.h index 3b9e1bc3be9..d48a6168f7b 100644 --- a/src/mame/includes/dynax.h +++ b/src/mame/includes/dynax.h @@ -4,6 +4,8 @@ ***************************************************************************/ +#include "sound/okim6295.h" + class dynax_state { public: @@ -121,7 +123,7 @@ public: running_device *soundcpu; running_device *rtc; running_device *ymsnd; - running_device *oki; + okim6295_device *oki; running_device *top_scr; running_device *bot_scr; }; diff --git a/src/mame/includes/eprom.h b/src/mame/includes/eprom.h index ab6d7d4239a..4a2c7a59768 100644 --- a/src/mame/includes/eprom.h +++ b/src/mame/includes/eprom.h @@ -28,4 +28,4 @@ VIDEO_UPDATE( eprom ); VIDEO_START( guts ); VIDEO_UPDATE( guts ); -void eprom_scanline_update(running_device *screen, int scanline); +void eprom_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/exidy.h b/src/mame/includes/exidy.h index 6176848af37..6eef3e28004 100644 --- a/src/mame/includes/exidy.h +++ b/src/mame/includes/exidy.h @@ -4,6 +4,8 @@ *************************************************************************/ +#include "devlegcy.h" + #define EXIDY_MASTER_CLOCK (XTAL_11_289MHz) #define EXIDY_CPU_CLOCK (EXIDY_MASTER_CLOCK / 16) #define EXIDY_PIXEL_CLOCK (EXIDY_MASTER_CLOCK / 2) @@ -21,8 +23,7 @@ /*----------- defined in audio/exidy.c -----------*/ -DEVICE_GET_INFO( exidy_sound ); -#define SOUND_EXIDY DEVICE_GET_INFO_NAME( exidy_sound ) +DECLARE_LEGACY_SOUND_DEVICE(EXIDY, exidy_sound); READ8_HANDLER( exidy_sh6840_r ); WRITE8_HANDLER( exidy_sh6840_w ); diff --git a/src/mame/includes/exterm.h b/src/mame/includes/exterm.h index ae81474729e..a2ff4e31d14 100644 --- a/src/mame/includes/exterm.h +++ b/src/mame/includes/exterm.h @@ -10,7 +10,7 @@ extern UINT16 *exterm_master_videoram; extern UINT16 *exterm_slave_videoram; PALETTE_INIT( exterm ); -void exterm_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void exterm_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); void exterm_to_shiftreg_master(const address_space *space, UINT32 address, UINT16* shiftreg); void exterm_from_shiftreg_master(const address_space *space, UINT32 address, UINT16* shiftreg); diff --git a/src/mame/includes/flower.h b/src/mame/includes/flower.h index 5bafc158d2c..910b0968a7c 100644 --- a/src/mame/includes/flower.h +++ b/src/mame/includes/flower.h @@ -1,3 +1,5 @@ +#include "devlegcy.h" + /*----------- defined in audio/flower.c -----------*/ extern UINT8 *flower_soundregs1,*flower_soundregs2; @@ -5,8 +7,7 @@ extern UINT8 *flower_soundregs1,*flower_soundregs2; WRITE8_HANDLER( flower_sound1_w ); WRITE8_HANDLER( flower_sound2_w ); -DEVICE_GET_INFO( flower_sound ); -#define SOUND_FLOWER DEVICE_GET_INFO_NAME(flower_sound) +DECLARE_LEGACY_SOUND_DEVICE(FLOWER, flower_sound); /*----------- defined in video/flower.c -----------*/ diff --git a/src/mame/includes/gaelco3d.h b/src/mame/includes/gaelco3d.h index 95be5d82660..6c6cd5f4ae1 100644 --- a/src/mame/includes/gaelco3d.h +++ b/src/mame/includes/gaelco3d.h @@ -14,7 +14,7 @@ extern UINT8 *gaelco3d_texmask; extern offs_t gaelco3d_texture_size; extern offs_t gaelco3d_texmask_size; -void gaelco3d_render(running_device *screen); +void gaelco3d_render(screen_device &screen); WRITE32_HANDLER( gaelco3d_render_w ); WRITE16_HANDLER( gaelco3d_paletteram_w ); diff --git a/src/mame/includes/gcpinbal.h b/src/mame/includes/gcpinbal.h index b6e18a113ce..440edd43fe3 100644 --- a/src/mame/includes/gcpinbal.h +++ b/src/mame/includes/gcpinbal.h @@ -1,10 +1,16 @@ +#include "sound/okim6295.h" +#include "sound/msm5205.h" + class gcpinbal_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gcpinbal_state(machine)); } - gcpinbal_state(running_machine &machine) { } + gcpinbal_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + oki(machine.device("oki")), + msm(machine.device("msm")) { } /* memory pointers */ UINT16 * tilemapram; @@ -27,9 +33,9 @@ public: UINT8 adpcm_trigger, adpcm_data; /* devices */ - running_device *maincpu; - running_device *oki; - running_device *msm; + cpu_device *maincpu; + okim6295_device *oki; + msm5205_sound_device *msm; }; diff --git a/src/mame/includes/gomoku.h b/src/mame/includes/gomoku.h index cc0d8b1e244..e87f0a3225f 100644 --- a/src/mame/includes/gomoku.h +++ b/src/mame/includes/gomoku.h @@ -1,3 +1,5 @@ +#include "devlegcy.h" + /*----------- defined in audio/gomoku.c -----------*/ extern UINT8 *gomoku_soundregs1; @@ -6,8 +8,7 @@ extern UINT8 *gomoku_soundregs2; WRITE8_HANDLER( gomoku_sound1_w ); WRITE8_HANDLER( gomoku_sound2_w ); -DEVICE_GET_INFO( gomoku_sound ); -#define SOUND_GOMOKU DEVICE_GET_INFO_NAME(gomoku_sound) +DECLARE_LEGACY_SOUND_DEVICE(GOMOKU, gomoku_sound); /*----------- defined in video/gomoku.c -----------*/ diff --git a/src/mame/includes/gridlee.h b/src/mame/includes/gridlee.h index 28708c98580..f9ae8cb985b 100644 --- a/src/mame/includes/gridlee.h +++ b/src/mame/includes/gridlee.h @@ -6,13 +6,14 @@ ***************************************************************************/ +#include "devlegcy.h" + /*----------- defined in audio/gridlee.c -----------*/ WRITE8_HANDLER( gridlee_sound_w ); -DEVICE_GET_INFO( gridlee_sound ); -#define SOUND_GRIDLEE DEVICE_GET_INFO_NAME(gridlee_sound) +DECLARE_LEGACY_SOUND_DEVICE(GRIDLEE, gridlee_sound); /*----------- defined in video/gridlee.c -----------*/ diff --git a/src/mame/includes/harddriv.h b/src/mame/includes/harddriv.h index 6830b2c9f95..a590b0b5982 100644 --- a/src/mame/includes/harddriv.h +++ b/src/mame/includes/harddriv.h @@ -12,18 +12,27 @@ class harddriv_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, harddriv_state(machine)); } - harddriv_state(running_machine &machine) { } + harddriv_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + gsp(machine.device("gsp")), + msp(machine.device("msp")), + adsp(machine.device("adsp")), + soundcpu(machine.device("soundcpu")), + sounddsp(machine.device("sounddsp")), + jsacpu(machine.device("jsa")), + dsp32(machine.device("dsp32")), + duart_timer(machine.device("duart_timer")) { } atarigen_state atarigen; - running_device * maincpu; - running_device * gsp; - running_device * msp; - running_device * adsp; - running_device * soundcpu; - running_device * sounddsp; - running_device * jsacpu; - running_device * dsp32; + cpu_device * maincpu; + cpu_device * gsp; + cpu_device * msp; + cpu_device * adsp; + cpu_device * soundcpu; + cpu_device * sounddsp; + cpu_device * jsacpu; + cpu_device * dsp32; UINT8 hd34010_host_access; UINT8 dsk_pio_access; @@ -81,7 +90,7 @@ public: UINT8 duart_read_data[16]; UINT8 duart_write_data[16]; UINT8 duart_output_port; - running_device * duart_timer; + timer_device * duart_timer; UINT8 last_gsp_shiftreg; @@ -347,5 +356,5 @@ WRITE16_HANDLER( hdgsp_paletteram_lo_w ); READ16_HANDLER( hdgsp_paletteram_hi_r ); WRITE16_HANDLER( hdgsp_paletteram_hi_w ); -void harddriv_scanline_driver(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); -void harddriv_scanline_multisync(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void harddriv_scanline_driver(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void harddriv_scanline_multisync(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/jpmimpct.h b/src/mame/includes/jpmimpct.h index 400898260a0..b8704fbdddc 100644 --- a/src/mame/includes/jpmimpct.h +++ b/src/mame/includes/jpmimpct.h @@ -13,6 +13,6 @@ WRITE16_HANDLER( jpmimpct_bt477_w ); void jpmimpct_to_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); void jpmimpct_from_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg); -void jpmimpct_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void jpmimpct_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); VIDEO_START( jpmimpct ); diff --git a/src/mame/includes/kickgoal.h b/src/mame/includes/kickgoal.h index 0e6f0ec6124..3aaaf2bdd6c 100644 --- a/src/mame/includes/kickgoal.h +++ b/src/mame/includes/kickgoal.h @@ -4,12 +4,17 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "machine/eeprom.h" + class kickgoal_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kickgoal_state(machine)); } - kickgoal_state(running_machine &machine) { } + kickgoal_state(running_machine &machine) + : adpcm(machine.device("oki")), + eeprom(machine.device("eeprom")) { } /* memory pointers */ UINT16 * fgram; @@ -30,8 +35,8 @@ public: UINT16 m6295_key_delay; /* devices */ - running_device *adpcm; - running_device *eeprom; + okim6295_device *adpcm; + eeprom_device *eeprom; }; diff --git a/src/mame/includes/leland.h b/src/mame/includes/leland.h index 9afdd6dc805..f45d218efe5 100644 --- a/src/mame/includes/leland.h +++ b/src/mame/includes/leland.h @@ -4,6 +4,8 @@ *************************************************************************/ +#include "devlegcy.h" + #define LELAND_BATTERY_RAM_SIZE 0x4000 #define ATAXX_EXTRA_TRAM_SIZE 0x800 @@ -98,14 +100,9 @@ void leland_rotate_memory(running_machine *machine, const char *cpuname); /*----------- defined in audio/leland.c -----------*/ -DEVICE_GET_INFO( leland_sound ); -#define SOUND_LELAND DEVICE_GET_INFO_NAME(leland_sound) - -DEVICE_GET_INFO( leland_80186_sound ); -#define SOUND_LELAND_80186 DEVICE_GET_INFO_NAME(leland_80186_sound) - -DEVICE_GET_INFO( redline_80186_sound ); -#define SOUND_REDLINE_80186 DEVICE_GET_INFO_NAME(redline_80186_sound) +DECLARE_LEGACY_SOUND_DEVICE(LELAND, leland_sound); +DECLARE_LEGACY_SOUND_DEVICE(LELAND_80186, leland_80186_sound); +DECLARE_LEGACY_SOUND_DEVICE(REDLINE_80186, redline_80186_sound); void leland_dac_update(int dacnum, UINT8 sample); diff --git a/src/mame/includes/lethalj.h b/src/mame/includes/lethalj.h index c3c782703e4..276d8279681 100644 --- a/src/mame/includes/lethalj.h +++ b/src/mame/includes/lethalj.h @@ -12,4 +12,4 @@ VIDEO_START( lethalj ); WRITE16_HANDLER( lethalj_blitter_w ); -void lethalj_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void lethalj_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/mcr.h b/src/mame/includes/mcr.h index da5f867ff75..b314299996b 100644 --- a/src/mame/includes/mcr.h +++ b/src/mame/includes/mcr.h @@ -24,8 +24,8 @@ WRITE8_DEVICE_HANDLER( mcr_ipu_sio_transmit ); extern attotime mcr68_timing_factor; -extern const z80_daisy_chain mcr_daisy_chain[]; -extern const z80_daisy_chain mcr_ipu_daisy_chain[]; +extern const z80_daisy_config mcr_daisy_chain[]; +extern const z80_daisy_config mcr_ipu_daisy_chain[]; extern const z80ctc_interface mcr_ctc_intf; extern const z80ctc_interface nflfoot_ctc_intf; extern const z80pio_interface nflfoot_pio_intf; diff --git a/src/mame/includes/metro.h b/src/mame/includes/metro.h index a781bd535be..c7e7efa8da3 100644 --- a/src/mame/includes/metro.h +++ b/src/mame/includes/metro.h @@ -4,12 +4,21 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "sound/2151intf.h" +#include "video/konicdev.h" + class metro_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, metro_state(machine)); } - metro_state(running_machine &machine) { } + metro_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + audiocpu(machine.device("audiocpu")), + oki(machine.device("oki")), + ymsnd(machine.device("ymsnd")), + k053936(machine.device("k053936")) { } /* memory pointers */ UINT16 * vram_0; @@ -72,11 +81,11 @@ public: tilemap_t *vmetal_mid2tilemap; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *oki; - running_device *ymsnd; - running_device *k053936; + cpu_device *maincpu; + cpu_device *audiocpu; + okim6295_device *oki; + ym2151_sound_device *ymsnd; + k053936_device *k053936; }; diff --git a/src/mame/includes/micro3d.h b/src/mame/includes/micro3d.h index 2cb70873ccd..63f3b4b9b67 100644 --- a/src/mame/includes/micro3d.h +++ b/src/mame/includes/micro3d.h @@ -4,6 +4,7 @@ *************************************************************************/ +#include "devlegcy.h" #include "cpu/tms34010/tms34010.h" @@ -173,8 +174,8 @@ READ8_HANDLER( micro3d_sound_io_r ); WRITE8_HANDLER( micro3d_sound_io_w ); void micro3d_noise_sh_w(running_machine *machine, UINT8 data); -DEVICE_GET_INFO( micro3d_sound ); -#define SOUND_MICRO3D DEVICE_GET_INFO_NAME(micro3d_sound) + +DECLARE_LEGACY_SOUND_DEVICE(MICRO3D, micro3d_sound); /*----------- defined in video/micro3d.c -----------*/ VIDEO_START( micro3d ); @@ -182,7 +183,7 @@ VIDEO_UPDATE( micro3d ); VIDEO_RESET( micro3d ); void micro3d_tms_interrupt(running_device *device, int state); -void micro3d_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void micro3d_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); WRITE16_HANDLER( micro3d_clut_w ); WRITE16_HANDLER( micro3d_creg_w ); diff --git a/src/mame/includes/midtunit.h b/src/mame/includes/midtunit.h index 2076492ae8d..1cec737599f 100644 --- a/src/mame/includes/midtunit.h +++ b/src/mame/includes/midtunit.h @@ -61,5 +61,5 @@ READ16_HANDLER( midxunit_paletteram_r ); READ16_HANDLER( midtunit_dma_r ); WRITE16_HANDLER( midtunit_dma_w ); -void midtunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); -void midxunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void midtunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void midxunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/midyunit.h b/src/mame/includes/midyunit.h index 260fd17ac89..434e8c8f583 100644 --- a/src/mame/includes/midyunit.h +++ b/src/mame/includes/midyunit.h @@ -62,4 +62,4 @@ WRITE16_HANDLER( midyunit_paletteram_w ); READ16_HANDLER( midyunit_dma_r ); WRITE16_HANDLER( midyunit_dma_w ); -void midyunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); +void midyunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params); diff --git a/src/mame/includes/mitchell.h b/src/mame/includes/mitchell.h index ba28a766dc0..18bf75e1561 100644 --- a/src/mame/includes/mitchell.h +++ b/src/mame/includes/mitchell.h @@ -4,12 +4,16 @@ *************************************************************************/ +#include "sound/okim6295.h" + class mitchell_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mitchell_state(machine)); } - mitchell_state(running_machine &machine) { } + mitchell_state(running_machine &machine) + : audiocpu(machine.device("audiocpu")), + oki(machine.device("oki")) { } /* memory pointers */ UINT8 * videoram; @@ -34,8 +38,8 @@ public: int keymatrix; /* devices */ - running_device *audiocpu; - running_device *oki; + cpu_device *audiocpu; + okim6295_device *oki; }; diff --git a/src/mame/includes/naomibd.h b/src/mame/includes/naomibd.h index 79f51e26555..e21c9061ba7 100644 --- a/src/mame/includes/naomibd.h +++ b/src/mame/includes/naomibd.h @@ -6,6 +6,7 @@ **************************************************************************/ +#include "devlegcy.h" /*************************************************************************** CONSTANTS @@ -20,12 +21,6 @@ enum MAX_NAOMIBD_TYPES }; -enum -{ - DEVINFO_INT_DMAOFFSET = DEVINFO_INT_DEVICE_SPECIFIC+0, /* R/O: value of dma_offset register */ - DEVINFO_PTR_MEMORY = DEVINFO_PTR_DEVICE_SPECIFIC+0 /* R/O: pointer to memory inside the board containing game data */ -}; - /*************************************************************************** TYPE DEFINITIONS @@ -91,13 +86,12 @@ struct _naomibd_config int naomibd_interrupt_callback(running_device *device, naomibd_interrupt_func callback); int naomibd_get_type(running_device *device); +void *naomibd_get_memory(running_device *device); +offs_t naomibd_get_dmaoffset(running_device *device); READ64_DEVICE_HANDLER( naomibd_r ); WRITE64_DEVICE_HANDLER( naomibd_w ); - /* ----- device interface ----- */ -/* device get info callback */ -#define NAOMI_BOARD DEVICE_GET_INFO_NAME(naomibd) -DEVICE_GET_INFO( naomibd ); +DECLARE_LEGACY_NVRAM_DEVICE(NAOMI_BOARD, naomibd); diff --git a/src/mame/includes/phoenix.h b/src/mame/includes/phoenix.h index 9c9bc88c5a7..c9be40c698c 100644 --- a/src/mame/includes/phoenix.h +++ b/src/mame/includes/phoenix.h @@ -1,3 +1,4 @@ +#include "devlegcy.h" #include "devcb.h" #include "sound/discrete.h" @@ -24,8 +25,7 @@ DISCRETE_SOUND_EXTERN( phoenix ); WRITE8_DEVICE_HANDLER( phoenix_sound_control_a_w ); WRITE8_DEVICE_HANDLER( phoenix_sound_control_b_w ); -DEVICE_GET_INFO( phoenix_sound ); -#define SOUND_PHOENIX DEVICE_GET_INFO_NAME(phoenix_sound) +DECLARE_LEGACY_SOUND_DEVICE(PHOENIX, phoenix_sound); /*----------- defined in audio/pleiads.c -----------*/ @@ -33,14 +33,9 @@ WRITE8_HANDLER( pleiads_sound_control_a_w ); WRITE8_HANDLER( pleiads_sound_control_b_w ); WRITE8_HANDLER( pleiads_sound_control_c_w ); -DEVICE_GET_INFO( pleiads_sound ); -#define SOUND_PLEIADS DEVICE_GET_INFO_NAME(pleiads_sound) - -DEVICE_GET_INFO( naughtyb_sound ); -#define SOUND_NAUGHTYB DEVICE_GET_INFO_NAME(naughtyb_sound) - -DEVICE_GET_INFO( popflame_sound ); -#define SOUND_POPFLAME DEVICE_GET_INFO_NAME(popflame_sound) +DECLARE_LEGACY_SOUND_DEVICE(PLEIADS, pleiads_sound); +DECLARE_LEGACY_SOUND_DEVICE(NAUGHTYB, naughtyb_sound); +DECLARE_LEGACY_SOUND_DEVICE(POPFLAME, popflame_sound); /*----------- defined in video/naughtyb.c -----------*/ diff --git a/src/mame/includes/polepos.h b/src/mame/includes/polepos.h index 810777782a9..17b5ecfbd56 100644 --- a/src/mame/includes/polepos.h +++ b/src/mame/includes/polepos.h @@ -4,13 +4,13 @@ *************************************************************************/ +#include "devlegcy.h" #include "sound/discrete.h" /*----------- defined in audio/polepos.c -----------*/ -DEVICE_GET_INFO( polepos_sound ); -#define SOUND_POLEPOS DEVICE_GET_INFO_NAME(polepos_sound) +DECLARE_LEGACY_SOUND_DEVICE(POLEPOS, polepos_sound); WRITE8_HANDLER( polepos_engine_sound_lsb_w ); WRITE8_HANDLER( polepos_engine_sound_msb_w ); diff --git a/src/mame/includes/rohga.h b/src/mame/includes/rohga.h index bd07b5bd078..443c778fbad 100644 --- a/src/mame/includes/rohga.h +++ b/src/mame/includes/rohga.h @@ -4,12 +4,20 @@ *************************************************************************/ +#include "sound/okim6295.h" +#include "video/deco16ic.h" + class rohga_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rohga_state(machine)); } - rohga_state(running_machine &machine) { } + rohga_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + audiocpu(machine.device("audiocpu")), + deco16ic(machine.device("deco_custom")), + oki1(machine.device("oki1")), + oki2(machine.device("oki2")) { } /* memory pointers */ UINT16 * pf1_rowscroll; @@ -19,11 +27,11 @@ public: UINT16 * spriteram; /* devices */ - running_device *maincpu; - running_device *audiocpu; - running_device *deco16ic; - running_device *oki1; - running_device *oki2; + cpu_device *maincpu; + cpu_device *audiocpu; + deco16ic_device *deco16ic; + okim6295_device *oki1; + okim6295_device *oki2; }; diff --git a/src/mame/includes/segas16.h b/src/mame/includes/segas16.h index ead127d5c10..85f7f7556ce 100644 --- a/src/mame/includes/segas16.h +++ b/src/mame/includes/segas16.h @@ -4,7 +4,8 @@ class segas1x_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, segas1x_state(machine)); } - segas1x_state(running_machine &machine) { } + segas1x_state(running_machine &machine) + : interrupt_timer(machine.device("int_timer")) { } /* memory pointers */ // UINT16 * workram; // this is used in the nvram handler, hence it cannot be added here @@ -92,7 +93,7 @@ public: running_device *n7751; running_device *ppi8255_1; running_device *ppi8255_2; - running_device *interrupt_timer; + timer_device *interrupt_timer; running_device *_315_5248_1; running_device *_315_5250_1; running_device *_315_5250_2; diff --git a/src/mame/includes/senjyo.h b/src/mame/includes/senjyo.h index 87381ffc69f..a1b3ba78179 100644 --- a/src/mame/includes/senjyo.h +++ b/src/mame/includes/senjyo.h @@ -5,7 +5,7 @@ /*----------- defined in audio/senjyo.c -----------*/ -extern const z80_daisy_chain senjyo_daisy_chain[]; +extern const z80_daisy_config senjyo_daisy_chain[]; extern const z80pio_interface senjyo_pio_intf; extern const z80ctc_interface senjyo_ctc_intf; diff --git a/src/mame/includes/simpl156.h b/src/mame/includes/simpl156.h index 78dd4023d13..5cf3ec4a037 100644 --- a/src/mame/includes/simpl156.h +++ b/src/mame/includes/simpl156.h @@ -4,12 +4,20 @@ *************************************************************************/ +#include "machine/eeprom.h" +#include "sound/okim6295.h" +#include "video/deco16ic.h" + class simpl156_state { public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, simpl156_state(machine)); } - simpl156_state(running_machine &machine) { } + simpl156_state(running_machine &machine) + : maincpu(machine.device("maincpu")), + deco16ic(machine.device("deco_custom")), + eeprom(machine.device("eeprom")), + okimusic(machine.device("okimusic")) { } /* memory pointers */ UINT16 * pf1_rowscroll; @@ -18,10 +26,10 @@ public: UINT32 * systemram; /* devices */ - running_device *maincpu; - running_device *deco16ic; - running_device *eeprom; - running_device *okimusic; + cpu_device *maincpu; + deco16ic_device *deco16ic; + eeprom_device *eeprom; + okim6295_device *okimusic; }; diff --git a/src/mame/includes/snes.h b/src/mame/includes/snes.h index fbd696543ee..03e3a23274a 100644 --- a/src/mame/includes/snes.h +++ b/src/mame/includes/snes.h @@ -1,6 +1,7 @@ #ifndef _SNES_H_ #define _SNES_H_ +#include "devlegcy.h" #include "devcb.h" #include "streams.h" diff --git a/src/mame/includes/snk6502.h b/src/mame/includes/snk6502.h index 3f2e5d2bba7..ce10edcfe3b 100644 --- a/src/mame/includes/snk6502.h +++ b/src/mame/includes/snk6502.h @@ -4,6 +4,7 @@ *************************************************************************/ +#include "devlegcy.h" #include "sound/discrete.h" #include "sound/samples.h" #include "sound/sn76477.h" @@ -29,8 +30,7 @@ extern WRITE8_HANDLER( vanguard_speech_w ); extern WRITE8_HANDLER( fantasy_sound_w ); extern WRITE8_HANDLER( fantasy_speech_w ); -DEVICE_GET_INFO( snk6502_sound ); -#define SOUND_snk6502 DEVICE_GET_INFO_NAME(snk6502_sound) +DECLARE_LEGACY_SOUND_DEVICE(SNK6502, snk6502_sound); void snk6502_set_music_clock(double clock_time); void snk6502_set_music_freq(int freq); diff --git a/src/mame/includes/taito_f2.h b/src/mame/includes/taito_f2.h index edb9ac723fe..5e4195a33d7 100644 --- a/src/mame/includes/taito_f2.h +++ b/src/mame/includes/taito_f2.h @@ -1,4 +1,6 @@ +#include "sound/okim6295.h" + struct f2_tempsprite { int code, color; @@ -13,7 +15,8 @@ class taitof2_state public: static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitof2_state(machine)); } - taitof2_state(running_machine &machine) { } + taitof2_state(running_machine &machine) + : oki(machine.device("oki")) { } /* memory pointers */ UINT16 * sprite_extension; @@ -66,7 +69,7 @@ public: /* devices */ running_device *maincpu; running_device *audiocpu; - running_device *oki; + okim6295_device *oki; running_device *tc0100scn; running_device *tc0100scn_1; running_device *tc0100scn_2; diff --git a/src/mame/includes/tiamc1.h b/src/mame/includes/tiamc1.h index 8e3007d2b48..b7c70776fbd 100644 --- a/src/mame/includes/tiamc1.h +++ b/src/mame/includes/tiamc1.h @@ -1,7 +1,8 @@ +#include "devlegcy.h" + /*----------- defined in audio/tiamc1.c -----------*/ -DEVICE_GET_INFO( tiamc1_sound ); -#define SOUND_TIAMC1 DEVICE_GET_INFO_NAME(tiamc1_sound) +DECLARE_LEGACY_SOUND_DEVICE(TIAMC1, tiamc1_sound); WRITE8_HANDLER( tiamc1_timer0_w ); WRITE8_HANDLER( tiamc1_timer1_w ); diff --git a/src/mame/includes/tx1.h b/src/mame/includes/tx1.h index 1cfca210574..1227a48a81f 100644 --- a/src/mame/includes/tx1.h +++ b/src/mame/includes/tx1.h @@ -4,6 +4,8 @@ *************************************************************************/ +#include "devlegcy.h" + #define TX1_PIXEL_CLOCK (XTAL_18MHz / 3) #define TX1_HBSTART 256 #define TX1_HBEND 0 @@ -56,13 +58,13 @@ WRITE8_HANDLER( tx1_pit8253_w ); WRITE8_DEVICE_HANDLER( bb_ym1_a_w ); WRITE8_DEVICE_HANDLER( bb_ym2_a_w ); WRITE8_DEVICE_HANDLER( bb_ym2_b_w ); -DEVICE_GET_INFO( buggyboy_sound ); -#define SOUND_BUGGYBOY DEVICE_GET_INFO_NAME(buggyboy_sound) + +DECLARE_LEGACY_SOUND_DEVICE(BUGGYBOY, buggyboy_sound); WRITE8_DEVICE_HANDLER( tx1_ay8910_a_w ); WRITE8_DEVICE_HANDLER( tx1_ay8910_b_w ); -DEVICE_GET_INFO( tx1_sound ); -#define SOUND_TX1 DEVICE_GET_INFO_NAME(tx1_sound) + +DECLARE_LEGACY_SOUND_DEVICE(TX1, tx1_sound); /*----------- defined in video/tx1.c -----------*/ diff --git a/src/mame/includes/vindictr.h b/src/mame/includes/vindictr.h index bb50f4d4452..3727851a04f 100644 --- a/src/mame/includes/vindictr.h +++ b/src/mame/includes/vindictr.h @@ -28,4 +28,4 @@ WRITE16_HANDLER( vindictr_paletteram_w ); VIDEO_START( vindictr ); VIDEO_UPDATE( vindictr ); -void vindictr_scanline_update(running_device *screen, int scanline); +void vindictr_scanline_update(screen_device &screen, int scanline); diff --git a/src/mame/includes/warpwarp.h b/src/mame/includes/warpwarp.h index 1d8896e8f96..c368f0a50f1 100644 --- a/src/mame/includes/warpwarp.h +++ b/src/mame/includes/warpwarp.h @@ -1,3 +1,5 @@ +#include "devlegcy.h" + /*----------- defined in video/warpwarp.c -----------*/ extern UINT8 *geebee_videoram,*warpwarp_videoram; @@ -23,8 +25,8 @@ WRITE8_HANDLER( geebee_videoram_w ); /*----------- defined in audio/geebee.c -----------*/ WRITE8_HANDLER( geebee_sound_w ); -DEVICE_GET_INFO( geebee_sound ); -#define SOUND_GEEBEE DEVICE_GET_INFO_NAME(geebee_sound) + +DECLARE_LEGACY_SOUND_DEVICE(GEEBEE, geebee_sound); /*----------- defined in audio/warpwarp.c -----------*/ @@ -32,5 +34,5 @@ DEVICE_GET_INFO( geebee_sound ); WRITE8_HANDLER( warpwarp_sound_w ); WRITE8_HANDLER( warpwarp_music1_w ); WRITE8_HANDLER( warpwarp_music2_w ); -DEVICE_GET_INFO( warpwarp_sound ); -#define SOUND_WARPWARP DEVICE_GET_INFO_NAME(warpwarp_sound) + +DECLARE_LEGACY_SOUND_DEVICE(WARPWARP, warpwarp_sound); diff --git a/src/mame/includes/wiping.h b/src/mame/includes/wiping.h index c512cd6f8cf..1400bbb804b 100644 --- a/src/mame/includes/wiping.h +++ b/src/mame/includes/wiping.h @@ -1,9 +1,10 @@ +#include "devlegcy.h" + /*----------- defined in audio/wiping.c -----------*/ extern UINT8 *wiping_soundregs; -DEVICE_GET_INFO( wiping_sound ); -#define SOUND_WIPING DEVICE_GET_INFO_NAME(wiping_sound) +DECLARE_LEGACY_SOUND_DEVICE(WIPING, wiping_sound); WRITE8_HANDLER( wiping_sound_w ); diff --git a/src/mame/machine/amiga.c b/src/mame/machine/amiga.c index 1d7ce2953eb..a17d5b55a45 100644 --- a/src/mame/machine/amiga.c +++ b/src/mame/machine/amiga.c @@ -327,7 +327,7 @@ MACHINE_RESET( amiga ) (*amiga_intf->reset_callback)(machine); /* start the scanline timer */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, scanline_callback); } @@ -362,7 +362,7 @@ static TIMER_CALLBACK( scanline_callback ) mos6526_tod_w(cia_1, 1); /* render up to this scanline */ - if (!video_screen_update_partial(machine->primary_screen, scanline)) + if (!machine->primary_screen->update_partial(scanline)) { if (IS_AGA(amiga_intf)) amiga_aga_render_scanline(machine, NULL, scanline); @@ -374,8 +374,8 @@ static TIMER_CALLBACK( scanline_callback ) amiga_audio_update(); /* set timer for next line */ - scanline = (scanline + 1) % video_screen_get_height(machine->primary_screen); - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, scanline_callback); + scanline = (scanline + 1) % machine->primary_screen->height(); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, scanline_callback); } @@ -1183,16 +1183,16 @@ READ16_HANDLER( amiga_custom_r ) case REG_VPOSR: CUSTOM_REG(REG_VPOSR) &= 0xff00; if (IS_AGA(amiga_intf)) - CUSTOM_REG(REG_VPOSR) |= amiga_aga_gethvpos(space->machine->primary_screen) >> 16; + CUSTOM_REG(REG_VPOSR) |= amiga_aga_gethvpos(*space->machine->primary_screen) >> 16; else - CUSTOM_REG(REG_VPOSR) |= amiga_gethvpos(space->machine->primary_screen) >> 16; + CUSTOM_REG(REG_VPOSR) |= amiga_gethvpos(*space->machine->primary_screen) >> 16; return CUSTOM_REG(REG_VPOSR); case REG_VHPOSR: if (IS_AGA(amiga_intf)) - return amiga_aga_gethvpos(space->machine->primary_screen) & 0xffff; + return amiga_aga_gethvpos(*space->machine->primary_screen) & 0xffff; else - return amiga_gethvpos(space->machine->primary_screen) & 0xffff; + return amiga_gethvpos(*space->machine->primary_screen) & 0xffff; case REG_SERDATR: CUSTOM_REG(REG_SERDATR) &= ~0x4000; diff --git a/src/mame/machine/archimds.c b/src/mame/machine/archimds.c index 3a04a806dc7..111adcc4c3a 100644 --- a/src/mame/machine/archimds.c +++ b/src/mame/machine/archimds.c @@ -98,7 +98,7 @@ static TIMER_CALLBACK( vidc_vblank ) archimedes_request_irq_a(machine, ARCHIMEDES_IRQA_VBL); // set up for next vbl - timer_adjust_oneshot(vbl_timer, video_screen_get_time_until_pos(machine->primary_screen, vidc_regs[0xb4], 0), 0); + timer_adjust_oneshot(vbl_timer, machine->primary_screen->time_until_pos(vidc_regs[0xb4]), 0); } static TIMER_CALLBACK( a310_audio_tick ) @@ -542,7 +542,7 @@ WRITE32_HANDLER(archimedes_vidc_w) vidc_regs[0x80], vidc_regs[0xa0], visarea.max_x, visarea.max_y); - video_screen_configure(space->machine->primary_screen, vidc_regs[0x80], vidc_regs[0xa0], &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds); + space->machine->primary_screen->configure(vidc_regs[0x80], vidc_regs[0xa0], visarea, space->machine->primary_screen->frame_period().attoseconds); // slightly hacky: fire off a VBL right now. the BIOS doesn't wait long enough otherwise. timer_adjust_oneshot(vbl_timer, attotime_zero, 0); diff --git a/src/mame/machine/atari_vg.c b/src/mame/machine/atari_vg.c index 197b72df7e6..4c4a13f2e7a 100644 --- a/src/mame/machine/atari_vg.c +++ b/src/mame/machine/atari_vg.c @@ -34,9 +34,8 @@ struct _atari_vg_earom_state INLINE atari_vg_earom_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == ATARIVGEAROM); - return (atari_vg_earom_state *)device->token; + assert(device->type() == ATARIVGEAROM); + return (atari_vg_earom_state *)downcast(device)->token(); } @@ -134,7 +133,6 @@ DEVICE_GET_INFO( atari_vg_earom ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(atari_vg_earom_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(atari_vg_earom);break; diff --git a/src/mame/machine/atari_vg.h b/src/mame/machine/atari_vg.h index 5ba363ada8f..2948aad4300 100644 --- a/src/mame/machine/atari_vg.h +++ b/src/mame/machine/atari_vg.h @@ -4,6 +4,7 @@ ***************************************************************************/ +#include "devlegcy.h" /*************************************************************************** @@ -24,6 +25,4 @@ WRITE8_DEVICE_HANDLER( atari_vg_earom_ctrl_w ); /* ----- device interface ----- */ -#define ATARIVGEAROM DEVICE_GET_INFO_NAME(atari_vg_earom) - -DEVICE_GET_INFO( atari_vg_earom ); +DECLARE_LEGACY_NVRAM_DEVICE(ATARIVGEAROM, atari_vg_earom); diff --git a/src/mame/machine/atarigen.c b/src/mame/machine/atarigen.c index a76738a0db6..8f8a5cc39a6 100644 --- a/src/mame/machine/atarigen.c +++ b/src/mame/machine/atarigen.c @@ -44,11 +44,11 @@ static TIMER_CALLBACK( delayed_sound_reset ); static TIMER_CALLBACK( delayed_sound_w ); static TIMER_CALLBACK( delayed_6502_sound_w ); -static void atarigen_set_vol(running_machine *machine, int volume, sound_type type); +static void atarigen_set_vol(running_machine *machine, int volume, device_type type); static TIMER_CALLBACK( scanline_timer_callback ); -static void atarivc_common_w(running_device *screen, offs_t offset, UINT16 newword); +static void atarivc_common_w(screen_device &screen, offs_t offset, UINT16 newword); static TIMER_CALLBACK( unhalt_cpu ); @@ -60,17 +60,17 @@ static TIMER_CALLBACK( atarivc_eof_update ); INLINE FUNCTIONS ***************************************************************************/ -INLINE const atarigen_screen_timer *get_screen_timer(running_device *screen) +INLINE const atarigen_screen_timer *get_screen_timer(screen_device &screen) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; int i; /* find the index of the timer that matches the screen */ for (i = 0; i < ARRAY_LENGTH(state->screen_timer); i++) - if (state->screen_timer[i].screen == screen) + if (state->screen_timer[i].screen == &screen) return &state->screen_timer[i]; - fatalerror("Unexpected: no atarivc_eof_update_timer for screen '%s'\n", screen->tag()); + fatalerror("Unexpected: no atarivc_eof_update_timer for screen '%s'\n", screen.tag()); return NULL; } @@ -83,12 +83,12 @@ INLINE const atarigen_screen_timer *get_screen_timer(running_device *screen) void atarigen_init(running_machine *machine) { atarigen_state *state = (atarigen_state *)machine->driver_data; - running_device *screen; + screen_device *screen; int i; /* allocate timers for all screens */ - assert(video_screen_count(machine->config) <= ARRAY_LENGTH(state->screen_timer)); - for (i = 0, screen = video_screen_first(machine); screen != NULL; i++, screen = video_screen_next(screen)) + assert(screen_count(*machine) <= ARRAY_LENGTH(state->screen_timer)); + for (i = 0, screen = screen_first(*machine); screen != NULL; i++, screen = screen_next(screen)) { state->screen_timer[i].screen = screen; state->screen_timer[i].scanline_interrupt_timer = timer_alloc(machine, scanline_interrupt_callback, (void *)screen); @@ -179,10 +179,10 @@ void atarigen_update_interrupts(running_machine *machine) scanline interrupt should be generated. ---------------------------------------------------------------*/ -void atarigen_scanline_int_set(running_device *screen, int scanline) +void atarigen_scanline_int_set(screen_device &screen, int scanline) { emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer; - timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, scanline, 0), 0); + timer_adjust_oneshot(timer, screen.time_until_pos(scanline), 0); } @@ -291,14 +291,14 @@ WRITE32_HANDLER( atarigen_video_int_ack32_w ) static TIMER_CALLBACK( scanline_interrupt_callback ) { - running_device *screen = (running_device *)ptr; + screen_device &screen = *reinterpret_cast(ptr); emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer; /* generate the interrupt */ atarigen_scanline_int_gen(devtag_get_device(machine, "maincpu")); /* set a new timer to go off at the same scan line next frame */ - timer_adjust_oneshot(timer, video_screen_get_frame_period(screen), 0); + timer_adjust_oneshot(timer, screen.frame_period(), 0); } @@ -873,11 +873,12 @@ static TIMER_CALLBACK( delayed_6502_sound_w ) changes the volume on all channels associated with it. ---------------------------------------------------------------*/ -void atarigen_set_vol(running_machine *machine, int volume, sound_type type) +void atarigen_set_vol(running_machine *machine, int volume, device_type type) { - for (running_device *device = sound_first(machine); device != NULL; device = sound_next(device)) - if (sound_get_type(device) == type) - sound_set_output_gain(device, ALL_OUTPUTS, volume / 100.0); + device_sound_interface *sound; + for (bool gotone = machine->devicelist.first(sound); gotone; gotone = sound->next(sound)) + if (sound->device().type() == type) + sound_set_output_gain(*sound, ALL_OUTPUTS, volume / 100.0); } @@ -921,9 +922,9 @@ void atarigen_set_oki6295_vol(running_machine *machine, int volume) atarigen_scanline_timer_reset: Sets up the scanline timer. ---------------------------------------------------------------*/ -void atarigen_scanline_timer_reset(running_device *screen, atarigen_scanline_func update_graphics, int frequency) +void atarigen_scanline_timer_reset(screen_device &screen, atarigen_scanline_func update_graphics, int frequency) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; /* set the scanline callback */ state->scanline_callback = update_graphics; @@ -933,7 +934,7 @@ void atarigen_scanline_timer_reset(running_device *screen, atarigen_scanline_fun if (state->scanline_callback != NULL) { emu_timer *timer = get_screen_timer(screen)->scanline_timer; - timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + timer_adjust_oneshot(timer, screen.time_until_pos(0), 0); } } @@ -946,7 +947,7 @@ void atarigen_scanline_timer_reset(running_device *screen, atarigen_scanline_fun static TIMER_CALLBACK( scanline_timer_callback ) { atarigen_state *state = (atarigen_state *)machine->driver_data; - running_device *screen = (running_device *)ptr; + screen_device &screen = *reinterpret_cast(ptr); int scanline = param; /* callback */ @@ -956,9 +957,9 @@ static TIMER_CALLBACK( scanline_timer_callback ) /* generate another */ scanline += state->scanlines_per_callback; - if (scanline >= video_screen_get_height(screen)) + if (scanline >= screen.height()) scanline = 0; - timer_adjust_oneshot(get_screen_timer(screen)->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline); + timer_adjust_oneshot(get_screen_timer(screen)->scanline_timer, screen.time_until_pos(scanline), scanline); } } @@ -976,7 +977,7 @@ static TIMER_CALLBACK( scanline_timer_callback ) static TIMER_CALLBACK( atarivc_eof_update ) { atarigen_state *state = (atarigen_state *)machine->driver_data; - running_device *screen = (running_device *)ptr; + screen_device &screen = *reinterpret_cast(ptr); emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer; int i; @@ -997,7 +998,7 @@ static TIMER_CALLBACK( atarivc_eof_update ) tilemap_set_scrollx(state->playfield2_tilemap, 0, state->atarivc_state.pf1_xscroll); tilemap_set_scrolly(state->playfield2_tilemap, 0, state->atarivc_state.pf1_yscroll); } - timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + timer_adjust_oneshot(timer, screen.time_until_pos(0), 0); /* use this for debugging the video controller values */ #if 0 @@ -1020,9 +1021,9 @@ static TIMER_CALLBACK( atarivc_eof_update ) atarivc_reset: Initializes the video controller. ---------------------------------------------------------------*/ -void atarivc_reset(running_device *screen, UINT16 *eof_data, int playfields) +void atarivc_reset(screen_device &screen, UINT16 *eof_data, int playfields) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; /* this allows us to manually reset eof_data to NULL if it's not used */ state->atarivc_eof_data = eof_data; @@ -1040,7 +1041,7 @@ void atarivc_reset(running_device *screen, UINT16 *eof_data, int playfields) if (state->atarivc_eof_data) { emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer; - timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0); + timer_adjust_oneshot(timer, screen.time_until_pos(0), 0); } } @@ -1050,9 +1051,9 @@ void atarivc_reset(running_device *screen, UINT16 *eof_data, int playfields) atarivc_w: Handles an I/O write to the video controller. ---------------------------------------------------------------*/ -void atarivc_w(running_device *screen, offs_t offset, UINT16 data, UINT16 mem_mask) +void atarivc_w(screen_device &screen, offs_t offset, UINT16 data, UINT16 mem_mask) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; int oldword = state->atarivc_data[offset]; int newword = oldword; @@ -1067,9 +1068,9 @@ void atarivc_w(running_device *screen, offs_t offset, UINT16 data, UINT16 mem_ma write. ---------------------------------------------------------------*/ -static void atarivc_common_w(running_device *screen, offs_t offset, UINT16 newword) +static void atarivc_common_w(screen_device &screen, offs_t offset, UINT16 newword) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; int oldword = state->atarivc_data[offset]; state->atarivc_data[offset] = newword; @@ -1102,7 +1103,7 @@ static void atarivc_common_w(running_device *screen, offs_t offset, UINT16 newwo /* check for palette banking */ if (state->atarivc_state.palette_bank != (((newword & 0x0400) >> 10) ^ 1)) { - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen.update_partial(screen.vpos()); state->atarivc_state.palette_bank = ((newword & 0x0400) >> 10) ^ 1; } break; @@ -1160,7 +1161,7 @@ static void atarivc_common_w(running_device *screen, offs_t offset, UINT16 newwo /* scanline IRQ ack here */ case 0x1e: /* hack: this should be a device */ - atarigen_scanline_int_ack_w(cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, 0, 0xffff); + atarigen_scanline_int_ack_w(cputag_get_address_space(screen.machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, 0, 0xffff); break; /* log anything else */ @@ -1177,9 +1178,9 @@ static void atarivc_common_w(running_device *screen, offs_t offset, UINT16 newwo atarivc_r: Handles an I/O read from the video controller. ---------------------------------------------------------------*/ -UINT16 atarivc_r(running_device *screen, offs_t offset) +UINT16 atarivc_r(screen_device &screen, offs_t offset) { - atarigen_state *state = (atarigen_state *)screen->machine->driver_data; + atarigen_state *state = (atarigen_state *)screen.machine->driver_data; logerror("vc_r(%02X)\n", offset); @@ -1187,11 +1188,11 @@ UINT16 atarivc_r(running_device *screen, offs_t offset) /* also sets bit 0x4000 if we're in VBLANK */ if (offset == 0) { - int result = video_screen_get_vpos(screen); + int result = screen.vpos(); if (result > 255) result = 255; - if (result > video_screen_get_visible_area(screen)->max_y) + if (result > screen.visible_area().max_y) result |= 0x4000; return result; @@ -1394,9 +1395,9 @@ WRITE16_HANDLER( atarigen_playfield2_latched_msb_w ) 10% of the scanline period. ---------------------------------------------------------------*/ -int atarigen_get_hblank(running_device *screen) +int atarigen_get_hblank(screen_device &screen) { - return (video_screen_get_hpos(screen) > (video_screen_get_width(screen) * 9 / 10)); + return (screen.hpos() > (screen.width() * 9 / 10)); } @@ -1405,13 +1406,13 @@ int atarigen_get_hblank(running_device *screen) next HBLANK. ---------------------------------------------------------------*/ -void atarigen_halt_until_hblank_0(running_device *screen) +void atarigen_halt_until_hblank_0(screen_device &screen) { - running_device *cpu = devtag_get_device(screen->machine, "maincpu"); + running_device *cpu = devtag_get_device(screen.machine, "maincpu"); /* halt the CPU until the next HBLANK */ - int hpos = video_screen_get_hpos(screen); - int width = video_screen_get_width(screen); + int hpos = screen.hpos(); + int width = screen.width(); int hblank = width * 9 / 10; double fraction; @@ -1421,7 +1422,7 @@ void atarigen_halt_until_hblank_0(running_device *screen) /* halt and set a timer to wake up */ fraction = (double)(hblank - hpos) / (double)width; - timer_set(screen->machine, double_to_attotime(attotime_to_double(video_screen_get_scan_period(screen)) * fraction), (void *)cpu, 0, unhalt_cpu); + timer_set(screen.machine, double_to_attotime(attotime_to_double(screen.scan_period()) * fraction), (void *)cpu, 0, unhalt_cpu); cpu_set_input_line(cpu, INPUT_LINE_HALT, ASSERT_LINE); } diff --git a/src/mame/machine/atarigen.h b/src/mame/machine/atarigen.h index 49cef7fae7f..8e8d8d0f728 100644 --- a/src/mame/machine/atarigen.h +++ b/src/mame/machine/atarigen.h @@ -30,7 +30,7 @@ typedef void (*atarigen_int_func)(running_machine *machine); -typedef void (*atarigen_scanline_func)(running_device *screen, int scanline); +typedef void (*atarigen_scanline_func)(screen_device &screen, int scanline); typedef struct _atarivc_state_desc atarivc_state_desc; struct _atarivc_state_desc @@ -53,7 +53,7 @@ struct _atarivc_state_desc typedef struct _atarigen_screen_timer atarigen_screen_timer; struct _atarigen_screen_timer { - running_device *screen; + screen_device *screen; emu_timer * scanline_interrupt_timer; emu_timer * scanline_timer; emu_timer * atarivc_eof_update_timer; @@ -147,7 +147,7 @@ void atarigen_init(running_machine *machine); void atarigen_interrupt_reset(atarigen_state *state, atarigen_int_func update_int); void atarigen_update_interrupts(running_machine *machine); -void atarigen_scanline_int_set(running_device *screen, int scanline); +void atarigen_scanline_int_set(screen_device &screen, int scanline); INTERRUPT_GEN( atarigen_scanline_int_gen ); WRITE16_HANDLER( atarigen_scanline_int_ack_w ); WRITE32_HANDLER( atarigen_scanline_int_ack32_w ); @@ -231,10 +231,10 @@ void atarigen_set_oki6295_vol(running_machine *machine, int volume); VIDEO CONTROLLER ---------------------------------------------------------------*/ -void atarivc_reset(running_device *screen, UINT16 *eof_data, int playfields); +void atarivc_reset(screen_device &screen, UINT16 *eof_data, int playfields); -void atarivc_w(running_device *screen, offs_t offset, UINT16 data, UINT16 mem_mask); -UINT16 atarivc_r(running_device *screen, offs_t offset); +void atarivc_w(screen_device &screen, offs_t offset, UINT16 data, UINT16 mem_mask); +UINT16 atarivc_r(screen_device &screen, offs_t offset); INLINE void atarivc_update_pf_xscrolls(atarigen_state *state) { @@ -267,9 +267,9 @@ WRITE16_HANDLER( atarigen_playfield2_latched_msb_w ); VIDEO HELPERS ---------------------------------------------------------------*/ -void atarigen_scanline_timer_reset(running_device *screen, atarigen_scanline_func update_graphics, int frequency); -int atarigen_get_hblank(running_device *screen); -void atarigen_halt_until_hblank_0(running_device *screen); +void atarigen_scanline_timer_reset(screen_device &screen, atarigen_scanline_func update_graphics, int frequency); +int atarigen_get_hblank(screen_device &screen); +void atarigen_halt_until_hblank_0(screen_device &screen); WRITE16_HANDLER( atarigen_666_paletteram_w ); WRITE16_HANDLER( atarigen_expanded_666_paletteram_w ); WRITE32_HANDLER( atarigen_666_paletteram32_w ); diff --git a/src/mame/machine/balsente.c b/src/mame/machine/balsente.c index 3ca3c653c36..9f816903b6a 100644 --- a/src/mame/machine/balsente.c +++ b/src/mame/machine/balsente.c @@ -37,23 +37,23 @@ static TIMER_CALLBACK( irq_off ) TIMER_DEVICE_CALLBACK( balsente_interrupt_timer ) { - balsente_state *state = (balsente_state *)timer->machine->driver_data; + balsente_state *state = (balsente_state *)timer.machine->driver_data; /* next interrupt after scanline 256 is scanline 64 */ if (param == 256) - timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 64, 0), 64); + state->scanline_timer->adjust(timer.machine->primary_screen->time_until_pos(64), 64); else - timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param + 64, 0), param + 64); + state->scanline_timer->adjust(timer.machine->primary_screen->time_until_pos(param + 64), param + 64); /* IRQ starts on scanline 0, 64, 128, etc. */ - cputag_set_input_line(timer->machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE); /* it will turn off on the next HBLANK */ - timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, param, BALSENTE_HBSTART), NULL, 0, irq_off); + timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(param, BALSENTE_HBSTART), NULL, 0, irq_off); /* if this is Grudge Match, update the steering */ if (state->grudge_steering_result & 0x80) - update_grudge_steering(timer->machine); + update_grudge_steering(timer.machine); /* if we're a shooter, we do a little more work */ if (state->shooter) @@ -63,8 +63,8 @@ TIMER_DEVICE_CALLBACK( balsente_interrupt_timer ) /* we latch the beam values on the first interrupt after VBLANK */ if (param == 64) { - state->shooter_x = input_port_read(timer->machine, "FAKEX"); - state->shooter_y = input_port_read(timer->machine, "FAKEY"); + state->shooter_x = input_port_read(timer.machine, "FAKEX"); + state->shooter_y = input_port_read(timer.machine, "FAKEY"); } /* which bits get returned depends on which scanline we're at */ @@ -134,16 +134,15 @@ MACHINE_RESET( balsente ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); balsente_state *state = (balsente_state *)machine->driver_data; - int numbanks, i; + int numbanks; /* reset counters; counter 2's gate is tied high */ memset(state->counter, 0, sizeof(state->counter)); - state->counter[1].timer = devtag_get_device(machine, "8253_1_timer"); - state->counter[2].timer = devtag_get_device(machine, "8253_2_timer"); + state->counter[1].timer = machine->device("8253_1_timer"); + state->counter[2].timer = machine->device("8253_2_timer"); state->counter[2].gate = 1; /* reset the manual counter 0 clock */ - state->counter_0_timer = devtag_get_device(machine, "8253_0_timer"); state->counter_control = 0x00; state->counter_0_ff = 0; state->counter_0_timer_active = 0; @@ -166,15 +165,6 @@ MACHINE_RESET( balsente ) /* reset the noise generator */ memset(state->noise_position, 0, sizeof(state->noise_position)); - /* find the CEM devices */ - for (i = 0; i < ARRAY_LENGTH(state->cem_device); i++) - { - char name[10]; - sprintf(name, "cem%d", i+1); - state->cem_device[i] = devtag_get_device(machine, name); - assert(state->cem_device[i] != NULL); - } - /* point the banks to bank 0 */ numbanks = (memory_region_length(machine, "maincpu") > 0x40000) ? 16 : 8; memory_configure_bank(machine, "bank1", 0, numbanks, &memory_region(machine, "maincpu")[0x10000], 0x6000); @@ -184,8 +174,7 @@ MACHINE_RESET( balsente ) machine->device("maincpu")->reset(); /* start a timer to generate interrupts */ - state->scanline_timer = devtag_get_device(machine, "scan_timer"); - timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + state->scanline_timer->adjust(machine->primary_screen->time_until_pos(0)); } @@ -230,15 +219,8 @@ void balsente_noise_gen(running_device *device, int count, short *buffer) /* find the chip we are referring to */ for (chip = 0; chip < ARRAY_LENGTH(state->cem_device); chip++) - { if (device == state->cem_device[chip]) break; - else if (state->cem_device[chip] == NULL) - { - state->cem_device[chip] = device; - break; - } - } assert(chip < ARRAY_LENGTH(state->cem_device)); /* noise generator runs at 100kHz */ @@ -661,7 +643,7 @@ INLINE void counter_start(balsente_state *state, int which) if (state->counter[which].gate && !state->counter[which].timer_active) { state->counter[which].timer_active = 1; - timer_device_adjust_oneshot(state->counter[which].timer, attotime_mul(ATTOTIME_IN_HZ(2000000), state->counter[which].count), which); + state->counter[which].timer->adjust(attotime_mul(ATTOTIME_IN_HZ(2000000), state->counter[which].count), which); } } } @@ -671,7 +653,7 @@ INLINE void counter_stop(balsente_state *state, int which) { /* only stop the timer if it exists */ if (state->counter[which].timer_active) - timer_device_adjust_oneshot(state->counter[which].timer, attotime_never, 0); + state->counter[which].timer->reset(); state->counter[which].timer_active = 0; } @@ -682,7 +664,7 @@ INLINE void counter_update_count(balsente_state *state, int which) if (state->counter[which].timer_active) { /* determine how many 2MHz cycles are remaining */ - int count = attotime_to_double(attotime_mul(timer_device_timeleft(state->counter[which].timer), 2000000)); + int count = attotime_to_double(attotime_mul(state->counter[which].timer->time_left(), 2000000)); state->counter[which].count = (count < 0) ? 0 : count; } } @@ -750,7 +732,7 @@ static void counter_set_out(running_machine *machine, int which, int out) TIMER_DEVICE_CALLBACK( balsente_counter_callback ) { - balsente_state *state = (balsente_state *)timer->machine->driver_data; + balsente_state *state = (balsente_state *)timer.machine->driver_data; /* reset the counter and the count */ state->counter[param].timer_active = 0; @@ -759,7 +741,7 @@ TIMER_DEVICE_CALLBACK( balsente_counter_callback ) /* set the state of the OUT line */ /* mode 0 and 1: when firing, transition OUT to high */ if (state->counter[param].mode == 0 || state->counter[param].mode == 1) - counter_set_out(timer->machine, param, 1); + counter_set_out(timer.machine, param, 1); /* no other modes handled currently */ } @@ -884,9 +866,9 @@ WRITE8_HANDLER( balsente_counter_8253_w ) * *************************************/ -static void set_counter_0_ff(running_device *timer, int newstate) +static void set_counter_0_ff(timer_device &timer, int newstate) { - balsente_state *state = (balsente_state *)timer->machine->driver_data; + balsente_state *state = (balsente_state *)timer.machine->driver_data; /* the flip/flop output is inverted, so if we went high to low, that's a clock */ if (state->counter_0_ff && !newstate) @@ -907,7 +889,7 @@ static void set_counter_0_ff(running_device *timer, int newstate) TIMER_DEVICE_CALLBACK( balsente_clock_counter_0_ff ) { - balsente_state *state = (balsente_state *)timer->machine->driver_data; + balsente_state *state = (balsente_state *)timer.machine->driver_data; /* clock the D value through the flip-flop */ set_counter_0_ff(timer, (state->counter_control >> 3) & 1); @@ -921,7 +903,7 @@ static void update_counter_0_timer(balsente_state *state) /* if there's already a timer, remove it */ if (state->counter_0_timer_active) - timer_device_adjust_oneshot(state->counter_0_timer, attotime_never, 0); + state->counter_0_timer->reset(); state->counter_0_timer_active = 0; /* find the counter with the maximum frequency */ @@ -946,7 +928,7 @@ static void update_counter_0_timer(balsente_state *state) if (maxfreq > 0.0) { state->counter_0_timer_active = 1; - timer_device_adjust_periodic(state->counter_0_timer, ATTOTIME_IN_HZ(maxfreq), 0, ATTOTIME_IN_HZ(maxfreq)); + state->counter_0_timer->adjust(ATTOTIME_IN_HZ(maxfreq), 0, ATTOTIME_IN_HZ(maxfreq)); } } @@ -998,7 +980,7 @@ WRITE8_HANDLER( balsente_counter_control_w ) /* if we gate off, remove the timer */ else if (state->counter[0].gate && !(data & 0x02) && state->counter_0_timer_active) { - timer_device_adjust_oneshot(state->counter_0_timer, attotime_never, 0); + state->counter_0_timer->reset(); state->counter_0_timer_active = 0; } @@ -1006,8 +988,8 @@ WRITE8_HANDLER( balsente_counter_control_w ) counter_set_gate(space->machine, 0, (data >> 1) & 1); /* bits D2 and D4 control the clear/reset flags on the flip-flop that feeds counter 0 */ - if (!(data & 0x04)) set_counter_0_ff(state->counter_0_timer, 1); - if (!(data & 0x10)) set_counter_0_ff(state->counter_0_timer, 0); + if (!(data & 0x04)) set_counter_0_ff(*state->counter_0_timer, 1); + if (!(data & 0x10)) set_counter_0_ff(*state->counter_0_timer, 0); /* bit 5 clears the NMI interrupt; recompute the I/O state now */ m6850_update_io(space->machine); @@ -1209,7 +1191,7 @@ static void update_grudge_steering(running_machine *machine) READ8_HANDLER( grudge_steering_r ) { balsente_state *state = (balsente_state *)space->machine->driver_data; - logerror("%04X:grudge_steering_r(@%d)\n", cpu_get_pc(space->cpu), video_screen_get_vpos(space->machine->primary_screen)); + logerror("%04X:grudge_steering_r(@%d)\n", cpu_get_pc(space->cpu), space->machine->primary_screen->vpos()); state->grudge_steering_result |= 0x80; return state->grudge_steering_result; } diff --git a/src/mame/machine/dc.c b/src/mame/machine/dc.c index 637b6baae7d..7dae918e865 100644 --- a/src/mame/machine/dc.c +++ b/src/mame/machine/dc.c @@ -1316,8 +1316,8 @@ WRITE64_HANDLER( dc_g1_ctrl_w ) } g1bus_regs[SB_GDST] = dat & 1; // printf("ROM board DMA to %x len %x (PC %x)\n", g1bus_regs[SB_GDSTAR], g1bus_regs[SB_GDLEN], cpu_get_pc(space->cpu)); - ROM = (UINT8 *)space->machine->device("rom_board")->get_runtime_ptr(DEVINFO_PTR_MEMORY); - dmaoffset = (UINT32)space->machine->device("rom_board")->get_runtime_int(DEVINFO_INT_DMAOFFSET); + ROM = (UINT8 *)naomibd_get_memory(space->machine->device("rom_board")); + dmaoffset = naomibd_get_dmaoffset(space->machine->device("rom_board")); ddtdata.destination=g1bus_regs[SB_GDSTAR]; // destination address ddtdata.length=g1bus_regs[SB_GDLEN] >> 5; // words to transfer /* data in the lower 5 bits makes the length size to round by 32 bytes, this'll be needed by Virtua Tennis to boot (according to Deunan) */ diff --git a/src/mame/machine/decocass.c b/src/mame/machine/decocass.c index 19c16c9f5f3..c81b82156f8 100644 --- a/src/mame/machine/decocass.c +++ b/src/mame/machine/decocass.c @@ -102,7 +102,7 @@ READ8_HANDLER( decocass_sound_command_r ) TIMER_DEVICE_CALLBACK( decocass_audio_nmi_gen ) { - decocass_state *state = (decocass_state *)timer->machine->driver_data; + decocass_state *state = (decocass_state *)timer.machine->driver_data; int scanline = param; state->audio_nmi_state = scanline & 8; cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, (state->audio_nmi_enabled && state->audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); @@ -1909,10 +1909,9 @@ struct _tape_state INLINE tape_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DECOCASS_TAPE); + assert(device->type() == DECOCASS_TAPE); - return (tape_state *)device->token; + return (tape_state *)downcast(device)->token(); } @@ -2105,7 +2104,7 @@ static UINT8 tape_get_status_bits(running_device *device) /* data block bytes are data */ else if (tape->bytenum >= BYTE_DATA_0 && tape->bytenum <= BYTE_DATA_255) - byteval = static_cast(*device->region)[blocknum * 256 + (tape->bytenum - BYTE_DATA_0)]; + byteval = static_cast(*device->region())[blocknum * 256 + (tape->bytenum - BYTE_DATA_0)]; /* CRC MSB */ else if (tape->bytenum == BYTE_CRC16_MSB) @@ -2130,7 +2129,7 @@ static UINT8 tape_get_status_bits(running_device *device) static UINT8 tape_is_present(running_device *device) { - return device->region != NULL; + return device->region() != NULL; } @@ -2173,19 +2172,19 @@ static DEVICE_START( decocass_tape ) /* validate some basic stuff */ assert(device != NULL); - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config == NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() == NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); /* fetch the data pointer */ tape->timer = timer_alloc(device->machine, tape_clock_callback, (void *)device); - if (device->region == NULL) + if (device->region() == NULL) return; - UINT8 *regionbase = *device->region; + UINT8 *regionbase = *device->region(); /* scan for the first non-empty block in the image */ - for (offs = device->region->bytes() - 1; offs >= 0; offs--) + for (offs = device->region()->bytes() - 1; offs >= 0; offs--) if (regionbase[offs] != 0) break; numblocks = ((offs | 0xff) + 1) / 256; @@ -2239,7 +2238,6 @@ DEVICE_GET_INFO( decocass_tape ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tape_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(decocass_tape); break; diff --git a/src/mame/machine/decocass.h b/src/mame/machine/decocass.h index 9aaa8f6cfb3..d6d318e108a 100644 --- a/src/mame/machine/decocass.h +++ b/src/mame/machine/decocass.h @@ -1,3 +1,5 @@ +#include "devlegcy.h" + #ifdef MAME_DEBUG #define LOGLEVEL 5 #else @@ -6,8 +8,7 @@ #define LOG(n,x) do { if (LOGLEVEL >= n) logerror x; } while (0) -#define DECOCASS_TAPE DEVICE_GET_INFO_NAME(decocass_tape) -DEVICE_GET_INFO( decocass_tape ); +DECLARE_LEGACY_DEVICE(DECOCASS_TAPE, decocass_tape); #define MDRV_DECOCASS_TAPE_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, DECOCASS_TAPE, 0) diff --git a/src/mame/machine/fddebug.c b/src/mame/machine/fddebug.c index 8075142f841..0bce6c699f5 100644 --- a/src/mame/machine/fddebug.c +++ b/src/mame/machine/fddebug.c @@ -1038,7 +1038,7 @@ static void execute_fdpc(running_machine *machine, int ref, int params, const ch newpc = cpu_get_pc(cpu); /* set the new PC */ - cpu_set_reg(cpu, REG_GENPC, newpc); + cpu_set_reg(cpu, STATE_GENPC, newpc); /* recompute around that */ instruction_hook(cpu, newpc); @@ -1091,7 +1091,7 @@ static void execute_fdsearch(running_machine *machine, int ref, int params, cons } /* set this as our current PC and run the instruction hook */ - cpu_set_reg(space->cpu, REG_GENPC, pc); + cpu_set_reg(space->cpu, STATE_GENPC, pc); if (instruction_hook(space->cpu, pc)) break; } diff --git a/src/mame/machine/galaxold.c b/src/mame/machine/galaxold.c index b20b2345acd..d1f96b59d6b 100644 --- a/src/mame/machine/galaxold.c +++ b/src/mame/machine/galaxold.c @@ -12,7 +12,6 @@ #include "includes/galaxold.h" static int irq_line; -static running_device *int_timer; static UINT8 _4in1_bank; @@ -25,8 +24,8 @@ static IRQ_CALLBACK(hunchbkg_irq_callback) * * Therefore we reset the line without any detour .... */ - //cpu_set_input_line(device->machine->firstcpu, 0, CLEAR_LINE); - cpu_set_info(device->machine->firstcpu, CPUINFO_INT_INPUT_STATE + irq_line, CLEAR_LINE); + cpu_set_input_line(device->machine->firstcpu, 0, CLEAR_LINE); + //cpu_set_info(device->machine->firstcpu, CPUINFO_INT_INPUT_STATE + irq_line, CLEAR_LINE); return 0x03; } @@ -53,7 +52,7 @@ WRITE8_HANDLER( galaxold_nmi_enable_w ) TIMER_DEVICE_CALLBACK( galaxold_interrupt_timer ) { - running_device *target = devtag_get_device(timer->machine, "7474_9m_2"); + running_device *target = devtag_get_device(timer.machine, "7474_9m_2"); /* 128V, 64V and 32V go to D */ ttl7474_d_w(target, ((param & 0xe0) != 0xe0) ? 1 : 0); @@ -63,7 +62,7 @@ TIMER_DEVICE_CALLBACK( galaxold_interrupt_timer ) param = (param + 0x10) & 0xff; - timer_device_adjust_oneshot(int_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param, 0), param); + timer.adjust(timer.machine->primary_screen->time_until_pos(param), param); } @@ -82,8 +81,8 @@ static void machine_reset_common(running_machine *machine, int line) ttl7474_preset_w(ttl7474_9m_1, 0); /* start a timer to generate interrupts */ - int_timer = devtag_get_device(machine, "int_timer"); - timer_device_adjust_oneshot(int_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device *int_timer = machine->device("int_timer"); + int_timer->adjust(machine->primary_screen->time_until_pos(0)); } MACHINE_RESET( galaxold ) diff --git a/src/mame/machine/harddriv.c b/src/mame/machine/harddriv.c index 764781431c1..432543034ff 100644 --- a/src/mame/machine/harddriv.c +++ b/src/mame/machine/harddriv.c @@ -62,9 +62,6 @@ MACHINE_START( harddriv ) state->sim_memory = (UINT16 *)memory_region(machine, "user1"); state->sim_memory_size = memory_region_length(machine, "user1") / 2; state->adsp_pgm_memory_word = (UINT16 *)((UINT8 *)state->adsp_pgm_memory + 1); - - /* allocate timers */ - state->duart_timer = devtag_get_device(machine, "duart_timer"); } @@ -242,7 +239,7 @@ READ16_HANDLER( hd68k_port0_r ) 0x8000 = SW1 #1 */ int temp = input_port_read(space->machine, "IN0"); - if (atarigen_get_hblank(space->machine->primary_screen)) temp ^= 0x0002; + if (atarigen_get_hblank(*space->machine->primary_screen)) temp ^= 0x0002; temp ^= 0x0018; /* both EOCs always high for now */ return temp; } @@ -528,16 +525,16 @@ INLINE attotime duart_clock_period(harddriv_state *state) TIMER_DEVICE_CALLBACK( hd68k_duart_callback ) { - harddriv_state *state = (harddriv_state *)timer->machine->driver_data; + harddriv_state *state = (harddriv_state *)timer.machine->driver_data; logerror("DUART timer fired\n"); if (state->duart_write_data[0x05] & 0x08) { logerror("DUART interrupt generated\n"); state->duart_read_data[0x05] |= 0x08; state->duart_irq_state = (state->duart_read_data[0x05] & state->duart_write_data[0x05]) != 0; - atarigen_update_interrupts(timer->machine); + atarigen_update_interrupts(timer.machine); } - timer_device_adjust_oneshot(timer, attotime_mul(duart_clock_period(state), 65536), 0); + timer.adjust(attotime_mul(duart_clock_period(state), 65536)); } @@ -565,14 +562,14 @@ READ16_HANDLER( hd68k_duart_r ) case 0x0e: /* Start-Counter Command 3 */ { int reps = (state->duart_write_data[0x06] << 8) | state->duart_write_data[0x07]; - timer_device_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), reps), 0); + state->duart_timer->adjust(attotime_mul(duart_clock_period(state), reps)); logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(state), reps))); return 0x00ff; } case 0x0f: /* Stop-Counter Command 3 */ { - int reps = attotime_to_double(attotime_mul(timer_device_timeleft(state->duart_timer), duart_clock(state))); - timer_device_adjust_oneshot(state->duart_timer, attotime_never, 0); + int reps = attotime_to_double(attotime_mul(state->duart_timer->time_left(), duart_clock(state))); + state->duart_timer->reset(); state->duart_read_data[0x06] = reps >> 8; state->duart_read_data[0x07] = reps & 0xff; logerror("DUART timer stopped (final count=%04X)\n", reps); @@ -650,7 +647,7 @@ WRITE16_HANDLER( hdgsp_io_w ) /* detect changes to HEBLNK and HSBLNK and force an update before they change */ if ((offset == REG_HEBLNK || offset == REG_HSBLNK) && data != tms34010_io_register_r(space, offset, 0xffff)) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1); tms34010_io_register_w(space, offset, data, mem_mask); } diff --git a/src/mame/machine/irobot.c b/src/mame/machine/irobot.c index 0d9a4797f70..08451978b80 100644 --- a/src/mame/machine/irobot.c +++ b/src/mame/machine/irobot.c @@ -26,7 +26,7 @@ #define IR_CPU_STATE(m) \ logerror(\ - "%s, scanline: %d\n", cpuexec_describe_context(m), video_screen_get_vpos((m)->primary_screen)) + "%s, scanline: %d\n", cpuexec_describe_context(m), (m)->primary_screen->vpos()) UINT8 irobot_vg_clear; @@ -35,8 +35,8 @@ static UINT8 irvg_running; static UINT8 irmb_running; #if IR_TIMING -static running_device *irvg_timer; -static running_device *irmb_timer; +static timer_device *irvg_timer; +static timer_device *irmb_timer; #endif static UINT8 *comRAM[2], *mbRAM, *mbROM; @@ -112,7 +112,7 @@ WRITE8_HANDLER( irobot_statwr_w ) else logerror("vg start [busy!] "); IR_CPU_STATE(space->machine); - timer_device_adjust_oneshot(irvg_timer, ATTOTIME_IN_MSEC(10), 0); + irvg_timer->adjust(ATTOTIME_IN_MSEC(10)); #endif irvg_running=1; } @@ -185,7 +185,7 @@ static TIMER_CALLBACK( scanline_callback ) /* set a callback for the next 32-scanline increment */ scanline += 32; if (scanline >= 256) scanline = 0; - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, scanline_callback); } MACHINE_RESET( irobot ) @@ -200,12 +200,12 @@ MACHINE_RESET( irobot ) irvg_vblank=0; irvg_running = 0; - irvg_timer = devtag_get_device(machine, "irvg_timer"); + irvg_timer = machine->device("irvg_timer"); irmb_running = 0; - irmb_timer = devtag_get_device(machine, "irmb_timer"); + irmb_timer = machine->device("irmb_timer"); /* set an initial timer to go off on scanline 0 */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, scanline_callback); + timer_set(machine, machine->primary_screen->time_until_pos(0), NULL, 0, scanline_callback); irobot_rom_banksel_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0); irobot_out0_w(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM),0,0); @@ -456,7 +456,7 @@ TIMER_DEVICE_CALLBACK( irobot_irmb_done_callback ) { logerror("mb done. "); irmb_running = 0; - cputag_set_input_line(timer->machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); + cputag_set_input_line(timer.machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); } @@ -849,7 +849,7 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break; #if IR_TIMING if (irmb_running == 0) { - timer_device_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_HZ(12000000), icount), 0); + irmb_timer->adjust(attotime_mul(ATTOTIME_IN_HZ(12000000), icount)); logerror("mb start "); IR_CPU_STATE(machine); } @@ -857,7 +857,7 @@ default: case 0x3f: IXOR(irmb_din(curop), 0); break; { logerror("mb start [busy!] "); IR_CPU_STATE(machine); - timer_device_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_NSEC(200), icount), 0); + irmb_timer->adjust(attotime_mul(ATTOTIME_IN_NSEC(200), icount)); } #else cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE); diff --git a/src/mame/machine/leland.c b/src/mame/machine/leland.c index 5e74c7ba664..fcbe8921faf 100644 --- a/src/mame/machine/leland.c +++ b/src/mame/machine/leland.c @@ -372,7 +372,7 @@ MACHINE_START( leland ) MACHINE_RESET( leland ) { - timer_adjust_oneshot(master_int_timer, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), 8); + timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(8), 8); /* reset globals */ leland_gfx_control = 0x00; @@ -426,7 +426,7 @@ MACHINE_START( ataxx ) MACHINE_RESET( ataxx ) { memset(extra_tram, 0, ATAXX_EXTRA_TRAM_SIZE); - timer_adjust_oneshot(master_int_timer, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), 8); + timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(8), 8); /* initialize the XROM */ xrom_length = memory_region_length(machine, "user1"); @@ -478,7 +478,7 @@ static TIMER_CALLBACK( leland_interrupt_callback ) scanline += 16; if (scanline > 248) scanline = 8; - timer_adjust_oneshot(master_int_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -490,7 +490,7 @@ static TIMER_CALLBACK( ataxx_interrupt_callback ) cputag_set_input_line(machine, "master", 0, HOLD_LINE); /* set a timer for the next one */ - timer_adjust_oneshot(master_int_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(master_int_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -1262,7 +1262,7 @@ WRITE8_HANDLER( ataxx_master_output_w ) break; case 0x08: /* */ - timer_adjust_oneshot(master_int_timer, video_screen_get_time_until_pos(space->machine->primary_screen, data + 1, 0), data + 1); + timer_adjust_oneshot(master_int_timer, space->machine->primary_screen->time_until_pos(data + 1), data + 1); break; default: @@ -1447,7 +1447,7 @@ WRITE8_HANDLER( ataxx_slave_banksw_w ) READ8_HANDLER( leland_raster_r ) { - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } diff --git a/src/mame/machine/mathbox.c b/src/mame/machine/mathbox.c index 2d33b761db1..adfef71b16b 100644 --- a/src/mame/machine/mathbox.c +++ b/src/mame/machine/mathbox.c @@ -54,9 +54,8 @@ struct _mathbox_state INLINE mathbox_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == MATHBOX); - return (mathbox_state *)device->token; + assert(device->type() == MATHBOX); + return (mathbox_state *)downcast(device)->token(); } @@ -346,7 +345,6 @@ DEVICE_GET_INFO( mathbox ) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mathbox_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mathbox);break; diff --git a/src/mame/machine/mathbox.h b/src/mame/machine/mathbox.h index 81f35c2f95f..131bc207ebc 100644 --- a/src/mame/machine/mathbox.h +++ b/src/mame/machine/mathbox.h @@ -5,6 +5,7 @@ * */ +#include "devlegcy.h" /*************************************************************************** DEVICE CONFIGURATION MACROS @@ -25,6 +26,4 @@ READ8_DEVICE_HANDLER( mathbox_lo_r ); READ8_DEVICE_HANDLER( mathbox_hi_r ); /* ----- device interface ----- */ - -#define MATHBOX DEVICE_GET_INFO_NAME(mathbox) -DEVICE_GET_INFO( mathbox ); +DECLARE_LEGACY_DEVICE(MATHBOX, mathbox); diff --git a/src/mame/machine/mcr.c b/src/mame/machine/mcr.c index 6d38617c93d..d7ba74693c4 100644 --- a/src/mame/machine/mcr.c +++ b/src/mame/machine/mcr.c @@ -216,14 +216,14 @@ const pia6821_interface zwackery_pia2_intf = * *************************************/ -const z80_daisy_chain mcr_daisy_chain[] = +const z80_daisy_config mcr_daisy_chain[] = { { "ctc" }, { NULL } }; -const z80_daisy_chain mcr_ipu_daisy_chain[] = +const z80_daisy_config mcr_ipu_daisy_chain[] = { { "ipu_ctc" }, { "ipu_pio1" }, @@ -491,7 +491,7 @@ static TIMER_CALLBACK( mcr68_493_callback ) { v493_irq_state = 1; update_mcr68_interrupts(machine); - timer_set(machine, video_screen_get_scan_period(machine->primary_screen), NULL, 0, mcr68_493_off_callback); + timer_set(machine, machine->primary_screen->scan_period(), NULL, 0, mcr68_493_off_callback); logerror("--- (INT1) ---\n"); } @@ -616,7 +616,7 @@ static TIMER_CALLBACK( zwackery_493_callback ) running_device *pia = devtag_get_device(machine, "pia0"); pia6821_ca1_w(pia, 0, 1); - timer_set(machine, video_screen_get_scan_period(machine->primary_screen), NULL, 0, zwackery_493_off_callback); + timer_set(machine, machine->primary_screen->scan_period(), NULL, 0, zwackery_493_off_callback); } diff --git a/src/mame/machine/mhavoc.c b/src/mame/machine/mhavoc.c index 535c121b970..e21af542b50 100644 --- a/src/mame/machine/mhavoc.c +++ b/src/mame/machine/mhavoc.c @@ -44,7 +44,7 @@ TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock ) alpha_irq_clock++; if ((alpha_irq_clock & 0x0c) == 0x0c) { - cputag_set_input_line(timer->machine, "alpha", 0, ASSERT_LINE); + cputag_set_input_line(timer.machine, "alpha", 0, ASSERT_LINE); alpha_irq_clock_enable = 0; } } @@ -53,7 +53,7 @@ TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock ) if (has_gamma_cpu) { gamma_irq_clock++; - cputag_set_input_line(timer->machine, "gamma", 0, (gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(timer.machine, "gamma", 0, (gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE); } } diff --git a/src/mame/machine/mw8080bw.c b/src/mame/machine/mw8080bw.c index d551ba51d17..252e48b4d6f 100644 --- a/src/mame/machine/mw8080bw.c +++ b/src/mame/machine/mw8080bw.c @@ -50,7 +50,7 @@ static TIMER_CALLBACK( mw8080bw_interrupt_callback ) int next_vblank; /* compute vector and set the interrupt line */ - int vpos = video_screen_get_vpos(machine->primary_screen); + int vpos = machine->primary_screen->vpos(); UINT8 counter = vpos_to_vysnc_chain_counter(vpos); UINT8 vector = 0xc7 | ((counter & 0x40) >> 2) | ((~counter & 0x40) >> 3); cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, vector); @@ -68,7 +68,7 @@ static TIMER_CALLBACK( mw8080bw_interrupt_callback ) } next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_vblank); - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(next_vpos), 0); } @@ -83,7 +83,7 @@ static void mw8080bw_start_interrupt_timer( running_machine *machine ) { mw8080bw_state *state = (mw8080bw_state *)machine->driver_data; int vpos = vysnc_chain_counter_to_vpos(MW8080BW_INT_TRIGGER_COUNT_1, MW8080BW_INT_TRIGGER_VBLANK_1); - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(vpos), 0); } diff --git a/src/mame/machine/n64.c b/src/mame/machine/n64.c index 28a2a5c71cc..8f7365dccb2 100644 --- a/src/mame/machine/n64.c +++ b/src/mame/machine/n64.c @@ -135,7 +135,7 @@ WRITE32_HANDLER( n64_mi_reg_w ) } } -static running_device *dmadac[2]; +static dmadac_sound_device *dmadac[2]; void signal_rcp_interrupt(running_machine *machine, int interrupt) { @@ -822,8 +822,8 @@ static void n64_vi_recalculate_resolution(running_machine *machine) int y_end = (n64_vi_vstart & 0x000003ff) / 2; int width = ((n64_vi_xscale & 0x00000fff) * (x_end - x_start)) / 0x400; int height = ((n64_vi_yscale & 0x00000fff) * (y_end - y_start)) / 0x400; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); - attoseconds_t period = video_screen_get_frame_period(machine->primary_screen).attoseconds; + rectangle visarea = machine->primary_screen->visible_area(); + attoseconds_t period = machine->primary_screen->frame_period().attoseconds; if (width == 0 || height == 0) { @@ -855,7 +855,7 @@ static void n64_vi_recalculate_resolution(running_machine *machine) visarea.max_x = width - 1; visarea.max_y = height - 1; - video_screen_configure(machine->primary_screen, width, 525, &visarea, period); + machine->primary_screen->configure(width, 525, visarea, period); } READ32_HANDLER( n64_vi_reg_r ) @@ -875,7 +875,7 @@ READ32_HANDLER( n64_vi_reg_r ) return n64_vi_intr; case 0x10/4: // VI_CURRENT_REG - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); case 0x14/4: // VI_BURST_REG return n64_vi_burst; @@ -1108,8 +1108,8 @@ static void start_audio_dma(running_machine *machine) // mame_printf_debug("DACDMA: %x for %x bytes\n", current->address, current->length); - dmadac[0] = devtag_get_device(machine, "dac1"); - dmadac[1] = devtag_get_device(machine, "dac2"); + dmadac[0] = machine->device("dac1"); + dmadac[1] = machine->device("dac2"); dmadac_transfer(&dmadac[0], 2, 2, 2, current->length/4, ram); ai_status |= 0x40000000; diff --git a/src/mame/machine/namco06.c b/src/mame/machine/namco06.c index 17db437ce17..f009f3abc8a 100644 --- a/src/mame/machine/namco06.c +++ b/src/mame/machine/namco06.c @@ -108,10 +108,9 @@ struct _namco_06xx_state INLINE namco_06xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_06XX); + assert(device->type() == NAMCO_06XX); - return (namco_06xx_state *)device->token; + return (namco_06xx_state *)downcast(device)->token(); } @@ -221,7 +220,7 @@ WRITE8_DEVICE_HANDLER( namco_06xx_ctrl_w ) static DEVICE_START( namco_06xx ) { - const namco_06xx_config *config = (const namco_06xx_config *)device->baseconfig().inline_config; + const namco_06xx_config *config = (const namco_06xx_config *)downcast(device->baseconfig()).inline_config(); namco_06xx_state *state = get_safe_token(device); int devnum; @@ -245,7 +244,7 @@ static DEVICE_START( namco_06xx ) for (devnum = 0; devnum < 4; devnum++) if (state->device[devnum] != NULL) { - device_type type = state->device[devnum]->type; + device_type type = state->device[devnum]->type(); if (type == NAMCO_50XX) { diff --git a/src/mame/machine/namco06.h b/src/mame/machine/namco06.h index 2f80ffd853f..a1def94b349 100644 --- a/src/mame/machine/namco06.h +++ b/src/mame/machine/namco06.h @@ -1,7 +1,7 @@ #ifndef NAMCO06_H #define NAMCO06_H -#include "devintrf.h" +#include "devlegcy.h" typedef struct _namco_06xx_config namco_06xx_config; @@ -31,8 +31,7 @@ WRITE8_DEVICE_HANDLER( namco_06xx_ctrl_w ); /* device get info callback */ -#define NAMCO_06XX DEVICE_GET_INFO_NAME(namco_06xx) -DEVICE_GET_INFO( namco_06xx ); +DECLARE_LEGACY_DEVICE(NAMCO_06XX, namco_06xx); #endif diff --git a/src/mame/machine/namco50.c b/src/mame/machine/namco50.c index 22c5a760298..e502399594e 100644 --- a/src/mame/machine/namco50.c +++ b/src/mame/machine/namco50.c @@ -147,10 +147,9 @@ struct _namco_50xx_state INLINE namco_50xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_50XX); + assert(device->type() == NAMCO_50XX); - return (namco_50xx_state *)device->token; + return (namco_50xx_state *)downcast(device)->token(); } @@ -172,19 +171,19 @@ static TIMER_CALLBACK( namco_50xx_readrequest_callback ) static READ8_HANDLER( namco_50xx_K_r ) { - namco_50xx_state *state = get_safe_token(space->cpu->owner); + namco_50xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd >> 4; } static READ8_HANDLER( namco_50xx_R0_r ) { - namco_50xx_state *state = get_safe_token(space->cpu->owner); + namco_50xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_cmd & 0x0f; } static READ8_HANDLER( namco_50xx_R2_r ) { - namco_50xx_state *state = get_safe_token(space->cpu->owner); + namco_50xx_state *state = get_safe_token(space->cpu->owner()); return state->latched_rw & 1; } @@ -192,7 +191,7 @@ static READ8_HANDLER( namco_50xx_R2_r ) static WRITE8_HANDLER( namco_50xx_O_w ) { - namco_50xx_state *state = get_safe_token(space->cpu->owner); + namco_50xx_state *state = get_safe_token(space->cpu->owner()); UINT8 out = (data & 0x0f); if (data & 0x10) state->portO = (state->portO & 0x0f) | (out << 4); diff --git a/src/mame/machine/namco50.h b/src/mame/machine/namco50.h index f41f89fb2e5..6c367238838 100644 --- a/src/mame/machine/namco50.h +++ b/src/mame/machine/namco50.h @@ -1,6 +1,8 @@ #ifndef NAMCO50_H #define NAMCO50_H +#include "devlegcy.h" + #define MDRV_NAMCO_50XX_ADD(_tag, _clock) \ MDRV_DEVICE_ADD(_tag, NAMCO_50XX, _clock) \ @@ -12,8 +14,7 @@ WRITE8_DEVICE_HANDLER( namco_50xx_write ); /* device get info callback */ -#define NAMCO_50XX DEVICE_GET_INFO_NAME(namco_50xx) -DEVICE_GET_INFO( namco_50xx ); +DECLARE_LEGACY_DEVICE(NAMCO_50XX, namco_50xx); #endif /* NAMCO50_H */ diff --git a/src/mame/machine/namco51.c b/src/mame/machine/namco51.c index 2610d36253d..90db02351a2 100644 --- a/src/mame/machine/namco51.c +++ b/src/mame/machine/namco51.c @@ -85,10 +85,9 @@ struct _namco_51xx_state INLINE namco_51xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_51XX); + assert(device->type() == NAMCO_51XX); - return (namco_51xx_state *)device->token; + return (namco_51xx_state *)downcast(device)->token(); } @@ -264,7 +263,7 @@ READ8_DEVICE_HANDLER( namco_51xx_read ) if (state->mode == 1) { - int on = (video_screen_get_frame_number(device->machine->primary_screen) & 0x10) >> 4; + int on = (device->machine->primary_screen->frame_number() & 0x10) >> 4; if (state->credits >= 2) WRITE_PORT(state,0,0x0c | 3*on); // lamps @@ -361,7 +360,7 @@ ADDRESS_MAP_END static MACHINE_DRIVER_START( namco_51xx ) MDRV_CPU_ADD("mcu", MB8843, DERIVED_CLOCK(1,1)) /* parent clock, internally divided by 6 */ MDRV_CPU_IO_MAP(namco_51xx_map_io) - MDRV_CPU_FLAGS(CPU_DISABLE) + MDRV_DEVICE_DISABLE() MACHINE_DRIVER_END @@ -377,7 +376,7 @@ ROM_END static DEVICE_START( namco_51xx ) { - const namco_51xx_interface *config = (const namco_51xx_interface *)device->baseconfig().static_config; + const namco_51xx_interface *config = (const namco_51xx_interface *)device->baseconfig().static_config(); namco_51xx_state *state = get_safe_token(device); astring tempstring; diff --git a/src/mame/machine/namco51.h b/src/mame/machine/namco51.h index a5a46337bed..870f4ced584 100644 --- a/src/mame/machine/namco51.h +++ b/src/mame/machine/namco51.h @@ -1,7 +1,7 @@ #ifndef NAMCO51_H #define NAMCO51_H -#include "devcb.h" +#include "devlegcy.h" typedef struct _namco_51xx_interface namco_51xx_interface; @@ -21,9 +21,7 @@ READ8_DEVICE_HANDLER( namco_51xx_read ); WRITE8_DEVICE_HANDLER( namco_51xx_write ); -/* device get info callback */ -#define NAMCO_51XX DEVICE_GET_INFO_NAME(namco_51xx) -DEVICE_GET_INFO( namco_51xx ); +DECLARE_LEGACY_DEVICE(NAMCO_51XX, namco_51xx); #endif /* NAMCO51_H */ diff --git a/src/mame/machine/namco53.c b/src/mame/machine/namco53.c index 52554fbacb7..a57a81788b0 100644 --- a/src/mame/machine/namco53.c +++ b/src/mame/machine/namco53.c @@ -74,29 +74,28 @@ struct _namco_53xx_state INLINE namco_53xx_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO_53XX); + assert(device->type() == NAMCO_53XX); - return (namco_53xx_state *)device->token; + return (namco_53xx_state *)downcast(device)->token(); } static READ8_HANDLER( namco_53xx_K_r ) { - namco_53xx_state *state = get_safe_token(space->cpu->owner); + namco_53xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->k, 0); } static READ8_HANDLER( namco_53xx_Rx_r ) { - namco_53xx_state *state = get_safe_token(space->cpu->owner); + namco_53xx_state *state = get_safe_token(space->cpu->owner()); return devcb_call_read8(&state->in[offset], 0); } static WRITE8_HANDLER( namco_53xx_O_w ) { - namco_53xx_state *state = get_safe_token(space->cpu->owner); + namco_53xx_state *state = get_safe_token(space->cpu->owner()); UINT8 out = (data & 0x0f); if (data & 0x10) state->portO = (state->portO & 0x0f) | (out << 4); @@ -106,7 +105,7 @@ static WRITE8_HANDLER( namco_53xx_O_w ) static WRITE8_HANDLER( namco_53xx_P_w ) { - namco_53xx_state *state = get_safe_token(space->cpu->owner); + namco_53xx_state *state = get_safe_token(space->cpu->owner()); devcb_call_write8(&state->p, 0, data); } @@ -171,7 +170,7 @@ ROM_END static DEVICE_START( namco_53xx ) { - const namco_53xx_interface *config = (const namco_53xx_interface *)device->baseconfig().static_config; + const namco_53xx_interface *config = (const namco_53xx_interface *)device->baseconfig().static_config(); namco_53xx_state *state = get_safe_token(device); astring tempstring; diff --git a/src/mame/machine/namco53.h b/src/mame/machine/namco53.h index 45286f78ae8..5c01a8b0218 100644 --- a/src/mame/machine/namco53.h +++ b/src/mame/machine/namco53.h @@ -1,7 +1,7 @@ #ifndef NAMCO53_H #define NAMCO53_H -#include "devcb.h" +#include "devlegcy.h" typedef struct _namco_53xx_interface namco_53xx_interface; @@ -22,9 +22,7 @@ void namco_53xx_read_request(running_device *device); READ8_DEVICE_HANDLER( namco_53xx_read ); -/* device get info callback */ -#define NAMCO_53XX DEVICE_GET_INFO_NAME(namco_53xx) -DEVICE_GET_INFO( namco_53xx ); +DECLARE_LEGACY_DEVICE(NAMCO_53XX, namco_53xx); #endif /* NAMCO53_H */ diff --git a/src/mame/machine/namcoio.c b/src/mame/machine/namcoio.c index 833253df4f9..7b1db293c3a 100644 --- a/src/mame/machine/namcoio.c +++ b/src/mame/machine/namcoio.c @@ -142,17 +142,16 @@ struct _namcoio_state INLINE namcoio_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAMCO56XX || device->type == NAMCO58XX || device->type == NAMCO59XX); + assert(device->type() == NAMCO56XX || device->type() == NAMCO58XX || device->type() == NAMCO59XX); - return (namcoio_state *)device->token; + return (namcoio_state *)downcast(device)->token(); } INLINE const namcoio_interface *get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == NAMCO56XX || device->type == NAMCO58XX || device->type == NAMCO59XX); - return (const namcoio_interface *) device->baseconfig().static_config; + assert(device->type() == NAMCO56XX || device->type() == NAMCO58XX || device->type() == NAMCO59XX); + return (const namcoio_interface *) device->baseconfig().static_config(); } diff --git a/src/mame/machine/namcoio.h b/src/mame/machine/namcoio.h index 1583e338a40..9d28ec5e566 100644 --- a/src/mame/machine/namcoio.h +++ b/src/mame/machine/namcoio.h @@ -1,7 +1,7 @@ #ifndef __NAMCOIO_H__ #define __NAMCOIO_H__ -#include "devcb.h" +#include "devlegcy.h" /*************************************************************************** TYPE DEFINITIONS @@ -16,20 +16,14 @@ struct _namcoio_interface running_device *device; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( namcoio ); +DECLARE_LEGACY_DEVICE(NAMCO56XX, namcoio); +DECLARE_LEGACY_DEVICE(NAMCO58XX, namcoio); +DECLARE_LEGACY_DEVICE(NAMCO59XX, namcoio); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define NAMCO56XX DEVICE_GET_INFO_NAME( namcoio ) -#define NAMCO58XX DEVICE_GET_INFO_NAME( namcoio ) -#define NAMCO59XX DEVICE_GET_INFO_NAME( namcoio ) - #define MDRV_NAMCO56XX_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, NAMCO56XX, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/machine/namcos2.c b/src/mame/machine/namcos2.c index b6ca987b0ec..03ea5d4a8f2 100644 --- a/src/mame/machine/namcos2.c +++ b/src/mame/machine/namcos2.c @@ -675,14 +675,14 @@ static TIMER_CALLBACK( namcos2_posirq_tick ) { if (IsSystem21()) { if (namcos2_68k_gpu_C148[NAMCOS2_C148_POSIRQ]) { - video_screen_update_partial(machine->primary_screen, param); + machine->primary_screen->update_partial(param); cputag_set_input_line(machine, "gpu", namcos2_68k_gpu_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE); } return; } if (namcos2_68k_master_C148[NAMCOS2_C148_POSIRQ]|namcos2_68k_slave_C148[NAMCOS2_C148_POSIRQ]) { - video_screen_update_partial(machine->primary_screen, param); + machine->primary_screen->update_partial(param); if (namcos2_68k_master_C148[NAMCOS2_C148_POSIRQ]) cputag_set_input_line(machine, "maincpu", namcos2_68k_master_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE); if (namcos2_68k_slave_C148[NAMCOS2_C148_POSIRQ]) cputag_set_input_line(machine, "slave", namcos2_68k_slave_C148[NAMCOS2_C148_POSIRQ] , ASSERT_LINE); } @@ -690,7 +690,7 @@ static TIMER_CALLBACK( namcos2_posirq_tick ) void namcos2_adjust_posirq_timer( running_machine *machine, int scanline ) { - timer_adjust_oneshot(namcos2_posirq_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 80), scanline); + timer_adjust_oneshot(namcos2_posirq_timer, machine->primary_screen->time_until_pos(scanline, 80), scanline); } INTERRUPT_GEN( namcos2_68k_master_vblank ) diff --git a/src/mame/machine/naomibd.c b/src/mame/machine/naomibd.c index 7624aff7193..038f73ec638 100644 --- a/src/mame/machine/naomibd.c +++ b/src/mame/machine/naomibd.c @@ -306,10 +306,9 @@ static UINT16 block_decrypt(UINT32 game_key, UINT16 sequence_key, UINT16 counter INLINE naomibd_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NAOMI_BOARD); + assert(device->type() == NAOMI_BOARD); - return (naomibd_state *)device->token; + return (naomibd_state *)downcast(device)->token(); } @@ -322,7 +321,7 @@ INLINE naomibd_state *get_safe_token(running_device *device) int naomibd_interrupt_callback(running_device *device, naomibd_interrupt_func callback) { - naomibd_config *config = (naomibd_config *)device->baseconfig().inline_config; + naomibd_config *config = (naomibd_config *)downcast(device->baseconfig()).inline_config(); //naomibd_state *v = get_safe_token(device); config->interrupt = callback; @@ -336,6 +335,55 @@ int naomibd_get_type(running_device *device) } +void *naomibd_get_memory(running_device *device) +{ + return get_safe_token(device)->memory; +} + + +offs_t naomibd_get_dmaoffset(running_device *device) +{ + offs_t result = 0; + + #if NAOMIBD_PRINTF_PROTECTION + printf("DMA source %08x, flags %x\n", get_safe_token(device)->dma_offset, get_safe_token(device)->dma_offset_flags); + #endif + + // if the flag is cleared that lets the protection chip go, + // we need to handle this specially. but not on DIMM boards. + if (!(get_safe_token(device)->dma_offset_flags & NAOMIBD_FLAG_ADDRESS_SHUFFLE) && (get_safe_token(device)->type == ROM_BOARD)) + { + if (!strcmp(device->machine->gamedrv->name, "qmegamis")) + { + result = 0x9000000; + return result; + } + else if (!strcmp(device->machine->gamedrv->name, "mvsc2")) + { + switch (get_safe_token(device)->dma_offset) + { + case 0x08000000: result = 0x8800000; break; + case 0x08026440: result = 0x8830000; break; + case 0x0803bda0: result = 0x8850000; break; + case 0x0805a560: result = 0x8870000; break; + case 0x0805b720: result = 0x8880000; break; + case 0x0808b7e0: result = 0x88a0000; break; + default: + result = get_safe_token(device)->dma_offset; + break; + } + + return result; + } + else + { + logerror("Protected DMA not handled for this game (dma_offset %x)\n", get_safe_token(device)->dma_offset); + } + } + + return result; +} + /************************************* * @@ -1697,13 +1745,13 @@ static void stream_decrypt(UINT32 game_key, UINT32 sequence_key, UINT16 seed, UI static DEVICE_START( naomibd ) { - const naomibd_config *config = (const naomibd_config *)device->baseconfig().inline_config; + const naomibd_config *config = (const naomibd_config *)downcast(device->baseconfig()).inline_config(); naomibd_state *v = get_safe_token(device); int i; /* validate some basic stuff */ - assert(device->baseconfig().static_config == NULL); - assert(device->baseconfig().inline_config != NULL); + assert(device->baseconfig().static_config() == NULL); + assert(downcast(device->baseconfig()).inline_config() != NULL); assert(device->machine != NULL); assert(device->machine->config != NULL); @@ -1755,7 +1803,7 @@ static DEVICE_START( naomibd ) } /* set the type */ - v->index = device->machine->devicelist.index(device->type, device->tag()); + v->index = device->machine->devicelist.index(device->type(), device->tag()); v->type = config->type; /* initialize some registers */ @@ -1839,68 +1887,14 @@ static DEVICE_NVRAM( naomibd ) device get info callback -------------------------------------------------*/ -static DEVICE_GET_RUNTIME_INFO( naomibd ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_DMAOFFSET: - #if NAOMIBD_PRINTF_PROTECTION - printf("DMA source %08x, flags %x\n", get_safe_token(device)->dma_offset, get_safe_token(device)->dma_offset_flags); - #endif - - // if the flag is cleared that lets the protection chip go, - // we need to handle this specially. but not on DIMM boards. - if (!(get_safe_token(device)->dma_offset_flags & NAOMIBD_FLAG_ADDRESS_SHUFFLE) && (get_safe_token(device)->type == ROM_BOARD)) - { - if (!strcmp(device->machine->gamedrv->name, "qmegamis")) - { - info->i = 0x9000000; - break; - } - else if (!strcmp(device->machine->gamedrv->name, "mvsc2")) - { - switch (get_safe_token(device)->dma_offset) - { - case 0x08000000: info->i = 0x8800000; break; - case 0x08026440: info->i = 0x8830000; break; - case 0x0803bda0: info->i = 0x8850000; break; - case 0x0805a560: info->i = 0x8870000; break; - case 0x0805b720: info->i = 0x8880000; break; - case 0x0808b7e0: info->i = 0x88a0000; break; - default: - info->i = get_safe_token(device)->dma_offset; - break; - } - - return; - } - else - { - logerror("Protected DMA not handled for this game (dma_offset %x)\n", get_safe_token(device)->dma_offset); - } - } - - info->i = get_safe_token(device)->dma_offset; - break; - - /* --- the following bits of info are returned as pointers --- */ - case DEVINFO_PTR_MEMORY: info->p = get_safe_token(device)->memory; break; - - /* default to the standard info */ - default: DEVICE_GET_INFO_NAME(naomibd)(&device->baseconfig(), state, info); break; - } -} - DEVICE_GET_INFO( naomibd ) { - const naomibd_config *config = (device != NULL) ? (const naomibd_config *)device->inline_config : NULL; + const naomibd_config *config = (device != NULL) ? (const naomibd_config *)downcast(device)->inline_config() : NULL; switch (state) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(naomibd_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(naomibd_config); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; /* --- the following bits of info are returned as pointers --- */ case DEVINFO_PTR_ROM_REGION: info->romregion = NULL; break; @@ -1911,7 +1905,6 @@ DEVICE_GET_INFO( naomibd ) case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(naomibd); break; case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(naomibd); break; case DEVINFO_FCT_NVRAM: info->nvram = DEVICE_NVRAM_NAME(naomibd); break; - case DEVINFO_FCT_GET_RUNTIME_INFO: info->get_runtime_info = DEVICE_GET_RUNTIME_INFO_NAME(naomibd); break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: diff --git a/src/mame/machine/nitedrvr.c b/src/mame/machine/nitedrvr.c index 27224ade1f1..4c90bc35281 100644 --- a/src/mame/machine/nitedrvr.c +++ b/src/mame/machine/nitedrvr.c @@ -256,7 +256,7 @@ WRITE8_HANDLER( nitedrvr_out1_w ) TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback ) { - nitedrvr_state *state = (nitedrvr_state *)timer->machine->driver_data; + nitedrvr_state *state = (nitedrvr_state *)timer.machine->driver_data; if (state->crash_en && state->crash_data_en) { @@ -268,14 +268,14 @@ TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback ) if (state->crash_data & 0x01) { /* Invert video */ - palette_set_color(timer->machine, 1, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ - palette_set_color(timer->machine, 0, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ + palette_set_color(timer.machine, 1, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ + palette_set_color(timer.machine, 0, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ } else { /* Normal video */ - palette_set_color(timer->machine, 0, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ - palette_set_color(timer->machine, 1, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ + palette_set_color(timer.machine, 0, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ + palette_set_color(timer.machine, 1, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ } } } diff --git a/src/mame/machine/nmk112.c b/src/mame/machine/nmk112.c index 22c2a8cb4b3..8e1578d89c6 100644 --- a/src/mame/machine/nmk112.c +++ b/src/mame/machine/nmk112.c @@ -33,17 +33,16 @@ struct _nmk112_state INLINE nmk112_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == NMK112); + assert(device->type() == NMK112); - return (nmk112_state *)device->token; + return (nmk112_state *)downcast(device)->token(); } INLINE const nmk112_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == NMK112)); - return (const nmk112_interface *) device->baseconfig().static_config; + assert((device->type() == NMK112)); + return (const nmk112_interface *) device->baseconfig().static_config(); } /***************************************************************************** diff --git a/src/mame/machine/nmk112.h b/src/mame/machine/nmk112.h index cdeae076397..bd1f76920e1 100644 --- a/src/mame/machine/nmk112.h +++ b/src/mame/machine/nmk112.h @@ -7,7 +7,7 @@ #ifndef __NMK112_H__ #define __NMK112_H__ -#include "devcb.h" +#include "devlegcy.h" /*************************************************************************** TYPE DEFINITIONS @@ -20,20 +20,12 @@ struct _nmk112_interface UINT8 disable_page_mask; }; - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( nmk112 ); - +DECLARE_LEGACY_DEVICE(NMK112, nmk112); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define NMK112 DEVICE_GET_INFO_NAME( nmk112 ) - #define MDRV_NMK112_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, NMK112, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/machine/segaic16.c b/src/mame/machine/segaic16.c index b851886ff9a..921fec9b8be 100644 --- a/src/mame/machine/segaic16.c +++ b/src/mame/machine/segaic16.c @@ -136,7 +136,7 @@ void segaic16_memory_mapper_config(running_machine *machine, const UINT8 *map_da void segaic16_memory_mapper_set_decrypted(running_machine *machine, UINT8 *decrypted) { struct memory_mapper_chip *chip = &memory_mapper; - offs_t romsize = chip->cpu->region->length; + offs_t romsize = chip->cpu->region()->length; int rgnum; /* loop over the regions */ @@ -319,7 +319,7 @@ static void update_memory_mapping(running_machine *machine, struct memory_mapper /* ROM areas need extra clamping */ if (rgn->romoffset != ~0) { - offs_t romsize = chip->cpu->region->length; + offs_t romsize = chip->cpu->region()->length; if (region_start >= romsize) read = NULL; else if (region_start + rgn->length > romsize) @@ -355,7 +355,7 @@ static void update_memory_mapping(running_machine *machine, struct memory_mapper decrypted = (UINT8 *)fd1089_get_decrypted_base(); } - memory_configure_bank(machine, readbank, 0, 1, chip->cpu->region->base.u8 + region_start, 0); + memory_configure_bank(machine, readbank, 0, 1, chip->cpu->region()->base.u8 + region_start, 0); if (decrypted) memory_configure_bank_decrypted(machine, readbank, 0, 1, decrypted + region_start, 0); @@ -412,10 +412,9 @@ struct _ic_315_5248_state INLINE ic_315_5248_state *_315_5248_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == _315_5248); + assert(device->type() == _315_5248); - return (ic_315_5248_state *)device->token; + return (ic_315_5248_state *)downcast(device)->token(); } /***************************************************************************** @@ -491,10 +490,9 @@ struct _ic_315_5249_state INLINE ic_315_5249_state *_315_5249_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == _315_5249); + assert(device->type() == _315_5249); - return (ic_315_5249_state *)device->token; + return (ic_315_5249_state *)downcast(device)->token(); } /***************************************************************************** @@ -650,17 +648,16 @@ struct _ic_315_5250_state INLINE ic_315_5250_state *_315_5250_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == _315_5250); + assert(device->type() == _315_5250); - return (ic_315_5250_state *)device->token; + return (ic_315_5250_state *)downcast(device)->token(); } INLINE const ic_315_5250_interface *_315_5250_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == _315_5250)); - return (const ic_315_5250_interface *) device->baseconfig().static_config; + assert((device->type() == _315_5250)); + return (const ic_315_5250_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -809,7 +806,6 @@ DEVICE_GET_INFO( ic_315_5248 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ic_315_5248_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ic_315_5248); break; @@ -831,7 +827,6 @@ DEVICE_GET_INFO( ic_315_5249 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ic_315_5249_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ic_315_5249); break; @@ -853,7 +848,6 @@ DEVICE_GET_INFO( ic_315_5250 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ic_315_5250_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(ic_315_5250); break; diff --git a/src/mame/machine/segaic16.h b/src/mame/machine/segaic16.h index e20a49e041c..12c03c5049b 100644 --- a/src/mame/machine/segaic16.h +++ b/src/mame/machine/segaic16.h @@ -4,6 +4,8 @@ ***************************************************************************/ +#include "devlegcy.h" + /* open bus read helpers */ READ16_HANDLER( segaic16_open_bus_r ); @@ -52,30 +54,20 @@ struct _ic_315_5250_interface }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( ic_315_5248 ); -DEVICE_GET_INFO( ic_315_5249 ); -DEVICE_GET_INFO( ic_315_5250 ); - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define _315_5248 DEVICE_GET_INFO_NAME( ic_315_5248 ) +DECLARE_LEGACY_DEVICE(_315_5248, ic_315_5248); +DECLARE_LEGACY_DEVICE(_315_5249, ic_315_5249); +DECLARE_LEGACY_DEVICE(_315_5250, ic_315_5250); #define MDRV_315_5248_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, _315_5248, 0) -#define _315_5249 DEVICE_GET_INFO_NAME( ic_315_5249 ) - #define MDRV_315_5249_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, _315_5249, 0) -#define _315_5250 DEVICE_GET_INFO_NAME( ic_315_5250 ) - #define MDRV_315_5250_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, _315_5250, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/machine/seicop.c b/src/mame/machine/seicop.c index 3dc76428d66..6ea2648e164 100644 --- a/src/mame/machine/seicop.c +++ b/src/mame/machine/seicop.c @@ -1492,12 +1492,12 @@ static UINT8 xy_check; #define CRT_MODE(_x_,_y_,_flip_) \ { \ - rectangle visarea = *video_screen_get_visible_area(space->machine->primary_screen); \ + rectangle visarea; \ visarea.min_x = 0; \ visarea.max_x = _x_-1; \ visarea.min_y = 0; \ visarea.max_y = _y_-1; \ - video_screen_configure(space->machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds ); \ + space->machine->primary_screen->configure(_x_, _y_, visarea, space->machine->primary_screen->frame_period().attoseconds ); \ flip_screen_set(space->machine, _flip_); \ } \ diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c index a01793ae9c1..d63944b29e2 100644 --- a/src/mame/machine/snes.c +++ b/src/mame/machine/snes.c @@ -120,7 +120,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) snes_state *state = (snes_state *)machine->driver_data; /* Increase current line - we want to latch on this line during it, not after it */ - snes_ppu.beam.current_vert = video_screen_get_vpos(machine->primary_screen); + snes_ppu.beam.current_vert = machine->primary_screen->vpos(); // not in hblank snes_ram[HVBJOY] &= ~0x40; @@ -160,7 +160,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) } else { - timer_adjust_oneshot(state->hirq_timer, video_screen_get_time_until_pos(machine->primary_screen, snes_ppu.beam.current_vert, pixel * state->htmult), 0); + timer_adjust_oneshot(state->hirq_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, pixel * state->htmult), 0); } } } @@ -168,7 +168,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) /* Start of VBlank */ if (snes_ppu.beam.current_vert == snes_ppu.beam.last_visible_line) { - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, snes_ppu.beam.current_vert, 10), NULL, 0, snes_reset_oam_address); + timer_set(machine, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, 10), NULL, 0, snes_reset_oam_address); snes_ram[HVBJOY] |= 0x81; /* Set vblank bit to on & indicate controllers being read */ snes_ram[RDNMI] |= 0x80; /* Set NMI occured bit */ @@ -180,7 +180,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) } /* three lines after start of vblank we update the controllers (value from snes9x) */ - timer_adjust_oneshot(state->io_timer, video_screen_get_time_until_pos(machine->primary_screen, snes_ppu.beam.current_vert + 2, state->hblank_offset * state->htmult), 0); + timer_adjust_oneshot(state->io_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 2, state->hblank_offset * state->htmult), 0); } // hdma reset happens at scanline 0, H=~6 @@ -201,7 +201,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) } timer_adjust_oneshot(state->scanline_timer, attotime_never, 0); - timer_adjust_oneshot(state->hblank_timer, video_screen_get_time_until_pos(machine->primary_screen, snes_ppu.beam.current_vert, state->hblank_offset * state->htmult), 0); + timer_adjust_oneshot(state->hblank_timer, machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert, state->hblank_offset * state->htmult), 0); // printf("%02x %d\n",snes_ram[HVBJOY],snes_ppu.beam.current_vert); } @@ -213,7 +213,7 @@ static TIMER_CALLBACK( snes_hblank_tick ) const address_space *cpu0space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM); int nextscan; - snes_ppu.beam.current_vert = video_screen_get_vpos(machine->primary_screen); + snes_ppu.beam.current_vert = machine->primary_screen->vpos(); /* make sure we halt */ timer_adjust_oneshot(state->hblank_timer, attotime_never, 0); @@ -221,13 +221,13 @@ static TIMER_CALLBACK( snes_hblank_tick ) /* draw a scanline */ if (snes_ppu.beam.current_vert <= snes_ppu.beam.last_visible_line) { - if (video_screen_get_vpos(machine->primary_screen) > 0) + if (machine->primary_screen->vpos() > 0) { /* Do HDMA */ if (snes_ram[HDMAEN]) snes_hdma(cpu0space); - video_screen_update_partial(machine->primary_screen, (snes_ppu.interlace == 2) ? (snes_ppu.beam.current_vert * snes_ppu.interlace) : snes_ppu.beam.current_vert - 1); + machine->primary_screen->update_partial((snes_ppu.interlace == 2) ? (snes_ppu.beam.current_vert * snes_ppu.interlace) : snes_ppu.beam.current_vert - 1); } } @@ -241,7 +241,7 @@ static TIMER_CALLBACK( snes_hblank_tick ) nextscan = 0; } - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, nextscan, 0), 0); + timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(nextscan), 0); } /* FIXME: multiplication should take 8 CPU cycles & division 16 CPU cycles, but @@ -504,7 +504,7 @@ READ8_HANDLER( snes_r_io ) return value; case HVBJOY: /* H/V blank and joypad controller enable */ // electronics test says hcounter 272 is start of hblank, which is beampos 363 -// if (video_screen_get_hpos(space->machine->primary_screen) >= 363) snes_ram[offset] |= 0x40; +// if (space->machine->primary_screen->hpos() >= 363) snes_ram[offset] |= 0x40; // else snes_ram[offset] &= ~0x40; return (snes_ram[offset] & 0xc1) | (snes_open_bus_r(space, 0) & 0x3e); case RDIO: /* Programmable I/O port - echos back what's written to WRIO */ @@ -722,7 +722,7 @@ WRITE8_HANDLER( snes_w_io ) break; case HDMAEN: /* HDMA channel designation */ if (data) //if a HDMA is enabled, data is inited at the next scanline - timer_set(space->machine, video_screen_get_time_until_pos(space->machine->primary_screen, snes_ppu.beam.current_vert + 1, 0), NULL, 0, snes_reset_hdma); + timer_set(space->machine, space->machine->primary_screen->time_until_pos(snes_ppu.beam.current_vert + 1), NULL, 0, snes_reset_hdma); break; case MEMSEL: /* Access cycle designation in memory (2) area */ /* FIXME: Need to adjust the speed only during access of banks 0x80+ @@ -1598,7 +1598,7 @@ static void snes_init_timers( running_machine *machine ) // SNES hcounter has a 0-339 range. hblank starts at counter 260. // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels. state->hblank_offset = 268; - timer_adjust_oneshot(state->hblank_timer, video_screen_get_time_until_pos(machine->primary_screen, ((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->hblank_offset), 0); + timer_adjust_oneshot(state->hblank_timer, machine->primary_screen->time_until_pos(((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->hblank_offset), 0); } static void snes_init_ram( running_machine *machine ) @@ -1670,7 +1670,7 @@ static void snes_init_ram( running_machine *machine ) } // init frame counter so first line is 0 - if (ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds) >= 59) + if (ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) >= 59) snes_ppu.beam.current_vert = SNES_VTOTAL_NTSC; else snes_ppu.beam.current_vert = SNES_VTOTAL_PAL; @@ -1816,9 +1816,9 @@ MACHINE_RESET( snes ) } /* Set STAT78 to NTSC or PAL */ - if (ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds) >= 59.0f) + if (ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) >= 59.0f) snes_ram[STAT78] = SNES_NTSC; - else /* if (ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds) == 50.0f) */ + else /* if (ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) == 50.0f) */ snes_ram[STAT78] = SNES_PAL; // reset does this to these registers diff --git a/src/mame/machine/stvcd.c b/src/mame/machine/stvcd.c index 359345974aa..44c03c2c424 100644 --- a/src/mame/machine/stvcd.c +++ b/src/mame/machine/stvcd.c @@ -105,7 +105,7 @@ typedef enum } trans32T; // local variables -static running_device *sector_timer; +static timer_device *sector_timer; static partitionT partitions[MAX_FILTERS]; static partitionT *transpart; @@ -198,7 +198,7 @@ TIMER_DEVICE_CALLBACK( stv_sector_cb ) cr3 = (cd_curfad>>16)&0xff; cr4 = cd_curfad; - timer_device_adjust_oneshot(timer, ATTOTIME_IN_HZ(150), 0); + timer.adjust(ATTOTIME_IN_HZ(150)); } // global functions @@ -273,8 +273,8 @@ void stvcd_reset(running_machine *machine) cd_stat = CD_STAT_OPEN; } - sector_timer = devtag_get_device(machine, "sector_timer"); - timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second + sector_timer = machine->device("sector_timer"); + sector_timer->adjust(ATTOTIME_IN_HZ(150)); // 150 sectors / second = 300kBytes/second } static blockT *cd_alloc_block(UINT8 *blknum) @@ -765,8 +765,8 @@ static void cd_writeWord(running_machine *machine, UINT32 addr, UINT16 data) // and do the disc I/O // make sure it doesn't come in too early - timer_device_adjust_oneshot(sector_timer, attotime_never, 0); - timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second + sector_timer->reset(); + sector_timer->adjust(ATTOTIME_IN_HZ(150)); // 150 sectors / second = 300kBytes/second break; case 0x1100: // disk seek @@ -1274,7 +1274,7 @@ static void cd_writeWord(running_machine *machine, UINT32 addr, UINT16 data) playtype = 1; // and do the disc I/O -// timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0); // 150 sectors / second = 300kBytes/second +// sector_timer->adjust(ATTOTIME_IN_HZ(150)); // 150 sectors / second = 300kBytes/second break; case 0x7500: diff --git a/src/mame/machine/taitoio.c b/src/mame/machine/taitoio.c index 4fb19dc1747..a1ed7187cbd 100644 --- a/src/mame/machine/taitoio.c +++ b/src/mame/machine/taitoio.c @@ -72,17 +72,16 @@ struct _tc0220ioc_state INLINE tc0220ioc_state *tc0220ioc_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0220IOC); + assert(device->type() == TC0220IOC); - return (tc0220ioc_state *)device->token; + return (tc0220ioc_state *)downcast(device)->token(); } INLINE const tc0220ioc_interface *tc0220ioc_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0220IOC)); - return (const tc0220ioc_interface *) device->baseconfig().static_config; + assert((device->type() == TC0220IOC)); + return (const tc0220ioc_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -230,17 +229,16 @@ struct _tc0510nio_state INLINE tc0510nio_state *tc0510nio_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0510NIO); + assert(device->type() == TC0510NIO); - return (tc0510nio_state *)device->token; + return (tc0510nio_state *)downcast(device)->token(); } INLINE const tc0510nio_interface *tc0510nio_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0510NIO)); - return (const tc0510nio_interface *) device->baseconfig().static_config; + assert((device->type() == TC0510NIO)); + return (const tc0510nio_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -382,17 +380,16 @@ struct _tc0640fio_state INLINE tc0640fio_state *tc0640fio_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0640FIO); + assert(device->type() == TC0640FIO); - return (tc0640fio_state *)device->token; + return (tc0640fio_state *)downcast(device)->token(); } INLINE const tc0640fio_interface *tc0640fio_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0640FIO)); - return (const tc0640fio_interface *) device->baseconfig().static_config; + assert((device->type() == TC0640FIO)); + return (const tc0640fio_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -519,7 +516,6 @@ DEVICE_GET_INFO( tc0220ioc ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0220ioc_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0220ioc); break; @@ -541,7 +537,6 @@ DEVICE_GET_INFO( tc0510nio ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0510nio_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0510nio); break; @@ -563,7 +558,6 @@ DEVICE_GET_INFO( tc0640fio ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0640fio_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0640fio); break; diff --git a/src/mame/machine/taitoio.h b/src/mame/machine/taitoio.h index 3317545c2dd..e008515a461 100644 --- a/src/mame/machine/taitoio.h +++ b/src/mame/machine/taitoio.h @@ -9,7 +9,7 @@ #ifndef __TAITOIO_H__ #define __TAITOIO_H__ -#include "devcb.h" +#include "devlegcy.h" /*************************************************************************** TYPE DEFINITIONS @@ -47,32 +47,22 @@ struct _tc0640fio_interface devcb_read8 read_7; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( tc0220ioc ); -DEVICE_GET_INFO( tc0510nio ); -DEVICE_GET_INFO( tc0640fio ); +DECLARE_LEGACY_DEVICE(TC0220IOC, tc0220ioc); +DECLARE_LEGACY_DEVICE(TC0510NIO, tc0510nio); +DECLARE_LEGACY_DEVICE(TC0640FIO, tc0640fio); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define TC0220IOC DEVICE_GET_INFO_NAME( tc0220ioc ) - #define MDRV_TC0220IOC_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0220IOC, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0510NIO DEVICE_GET_INFO_NAME( tc0510nio ) - #define MDRV_TC0510NIO_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0510NIO, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0640FIO DEVICE_GET_INFO_NAME( tc0640fio ) - #define MDRV_TC0640FIO_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0640FIO, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/machine/ticket.c b/src/mame/machine/ticket.c index 8d09f04aea4..6d556597341 100644 --- a/src/mame/machine/ticket.c +++ b/src/mame/machine/ticket.c @@ -34,10 +34,9 @@ struct _ticket_state INLINE ticket_state *get_safe_token(running_device *device) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TICKET_DISPENSER); + assert(device->type() == TICKET_DISPENSER); - return (ticket_state *)device->token; + return (ticket_state *)downcast(device)->token(); } @@ -122,14 +121,14 @@ WRITE8_DEVICE_HANDLER( ticket_dispenser_w ) static DEVICE_START( ticket ) { - const ticket_config *config = (const ticket_config *)device->baseconfig().inline_config; + const ticket_config *config = (const ticket_config *)downcast(device->baseconfig()).inline_config(); ticket_state *state = get_safe_token(device); assert(config != NULL); /* initialize the state */ state->active_bit = 0x80; - state->time_msec = device->clock; + state->time_msec = device->clock(); state->motoron = config->motorhigh ? state->active_bit : 0; state->ticketdispensed = config->statushigh ? state->active_bit : 0; state->ticketnotdispensed = state->ticketdispensed ^ state->active_bit; diff --git a/src/mame/machine/ticket.h b/src/mame/machine/ticket.h index 6cdcd5416ed..5d3518bfb66 100644 --- a/src/mame/machine/ticket.h +++ b/src/mame/machine/ticket.h @@ -4,6 +4,9 @@ ***************************************************************************/ +#include "devlegcy.h" + + #define TICKET_MOTOR_ACTIVE_LOW 0 /* Ticket motor is triggered by D7=0 */ #define TICKET_MOTOR_ACTIVE_HIGH 1 /* Ticket motor is triggered by D7=1 */ @@ -31,6 +34,4 @@ WRITE8_DEVICE_HANDLER( ticket_dispenser_w ); READ_LINE_DEVICE_HANDLER( ticket_dispenser_line_r ); -/* device interface */ -#define TICKET_DISPENSER DEVICE_GET_INFO_NAME(ticket) -DEVICE_GET_INFO( ticket ); +DECLARE_LEGACY_DEVICE(TICKET_DISPENSER, ticket); diff --git a/src/mame/machine/williams.c b/src/mame/machine/williams.c index 7b071608f9c..c5e65c7d54c 100644 --- a/src/mame/machine/williams.c +++ b/src/mame/machine/williams.c @@ -250,7 +250,7 @@ const pia6821_interface joust2_pia_1_intf = TIMER_DEVICE_CALLBACK( williams_va11_callback ) { - running_device *pia_1 = devtag_get_device(timer->machine, "pia_1"); + pia6821_device *pia_1 = timer.machine->device("pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ @@ -259,13 +259,13 @@ TIMER_DEVICE_CALLBACK( williams_va11_callback ) /* set a timer for the next update */ scanline += 0x20; if (scanline >= 256) scanline = 0; - timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); + timer.adjust(timer.machine->primary_screen->time_until_pos(scanline), scanline); } static TIMER_CALLBACK( williams_count240_off_callback ) { - running_device *pia_1 = devtag_get_device(machine, "pia_1"); + pia6821_device *pia_1 = machine->device("pia_1"); /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */ pia6821_ca1_w(pia_1, 0, 0); @@ -274,22 +274,22 @@ static TIMER_CALLBACK( williams_count240_off_callback ) TIMER_DEVICE_CALLBACK( williams_count240_callback ) { - running_device *pia_1 = devtag_get_device(timer->machine, "pia_1"); + pia6821_device *pia_1 = timer.machine->device("pia_1"); /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */ pia6821_ca1_w(pia_1, 0, 1); /* set a timer to turn it off once the scanline counter resets */ - timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback); + timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(0), NULL, 0, williams_count240_off_callback); /* set a timer for next frame */ - timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 240, 0), 0); + timer.adjust(timer.machine->primary_screen->time_until_pos(240)); } static void williams_main_irq(running_device *device, int state) { - running_device *pia_1 = devtag_get_device(device->machine, "pia_1"); + pia6821_device *pia_1 = device->machine->device("pia_1"); int combined_state = pia6821_get_irq_a(pia_1) | pia6821_get_irq_b(pia_1); /* IRQ to the main CPU */ @@ -306,7 +306,7 @@ static void williams_main_firq(running_device *device, int state) static void williams_snd_irq(running_device *device, int state) { - running_device *pia_2 = devtag_get_device(device->machine, "pia_2"); + pia6821_device *pia_2 = device->machine->device("pia_2"); int combined_state = pia6821_get_irq_a(pia_2) | pia6821_get_irq_b(pia_2); /* IRQ to the sound CPU */ @@ -323,8 +323,8 @@ static void williams_snd_irq(running_device *device, int state) static void mysticm_main_irq(running_device *device, int state) { - running_device *pia_0 = devtag_get_device(device->machine, "pia_0"); - running_device *pia_1 = devtag_get_device(device->machine, "pia_1"); + pia6821_device *pia_0 = device->machine->device("pia_0"); + pia6821_device *pia_1 = device->machine->device("pia_1"); int combined_state = pia6821_get_irq_b(pia_0) | pia6821_get_irq_a(pia_1) | pia6821_get_irq_b(pia_1); /* IRQ to the main CPU */ @@ -334,8 +334,8 @@ static void mysticm_main_irq(running_device *device, int state) static void tshoot_main_irq(running_device *device, int state) { - running_device *pia_0 = devtag_get_device(device->machine, "pia_0"); - running_device *pia_1 = devtag_get_device(device->machine, "pia_1"); + pia6821_device *pia_0 = device->machine->device("pia_0"); + pia6821_device *pia_1 = device->machine->device("pia_1"); int combined_state = pia6821_get_irq_a(pia_0) | pia6821_get_irq_b(pia_0) | pia6821_get_irq_a(pia_1) | pia6821_get_irq_b(pia_1); /* IRQ to the main CPU */ @@ -363,10 +363,12 @@ static MACHINE_START( williams_common ) static MACHINE_RESET( williams_common ) { /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */ - timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device *scan_timer = machine->device("scan_timer"); + scan_timer->adjust(machine->primary_screen->time_until_pos(0)); /* also set a timer to go off on scanline 240 */ - timer_device_adjust_oneshot(devtag_get_device(machine, "240_timer"), video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0); + timer_device *l240_timer = machine->device("240_timer"); + l240_timer->adjust(machine->primary_screen->time_until_pos(240)); } @@ -391,8 +393,8 @@ MACHINE_RESET( williams ) TIMER_DEVICE_CALLBACK( williams2_va11_callback ) { - running_device *pia_0 = devtag_get_device(timer->machine, "pia_0"); - running_device *pia_1 = devtag_get_device(timer->machine, "pia_1"); + pia6821_device *pia_0 = timer.machine->device("pia_0"); + pia6821_device *pia_1 = timer.machine->device("pia_1"); int scanline = param; /* the IRQ signal comes into CB1, and is set to VA11 */ @@ -402,13 +404,13 @@ TIMER_DEVICE_CALLBACK( williams2_va11_callback ) /* set a timer for the next update */ scanline += 0x20; if (scanline >= 256) scanline = 0; - timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline); + timer.adjust(timer.machine->primary_screen->time_until_pos(scanline), scanline); } static TIMER_CALLBACK( williams2_endscreen_off_callback ) { - running_device *pia_0 = devtag_get_device(machine, "pia_0"); + pia6821_device *pia_0 = machine->device("pia_0"); /* the /ENDSCREEN signal comes into CA1 */ pia6821_ca1_w(pia_0, 0, 1); @@ -417,16 +419,16 @@ static TIMER_CALLBACK( williams2_endscreen_off_callback ) TIMER_DEVICE_CALLBACK( williams2_endscreen_callback ) { - running_device *pia_0 = devtag_get_device(timer->machine, "pia_0"); + pia6821_device *pia_0 = timer.machine->device("pia_0"); /* the /ENDSCREEN signal comes into CA1 */ pia6821_ca1_w(pia_0, 0, 0); /* set a timer to turn it off once the scanline counter resets */ - timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback); + timer_set(timer.machine, timer.machine->primary_screen->time_until_pos(8), NULL, 0, williams2_endscreen_off_callback); /* set a timer for next frame */ - timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 254, 0), 0); + timer.adjust(timer.machine->primary_screen->time_until_pos(254)); } @@ -464,10 +466,12 @@ MACHINE_RESET( williams2 ) williams2_bank_select_w(space, 0, 0); /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */ - timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_device *scan_timer = machine->device("scan_timer"); + scan_timer->adjust(machine->primary_screen->time_until_pos(0)); /* also set a timer to go off on scanline 254 */ - timer_device_adjust_oneshot(devtag_get_device(machine, "254_timer"), video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0); + timer_device *l254_timer = machine->device("254_timer"); + l254_timer->adjust(machine->primary_screen->time_until_pos(254)); } @@ -533,7 +537,7 @@ WRITE8_HANDLER( williams2_bank_select_w ) static TIMER_CALLBACK( williams_deferred_snd_cmd_w ) { - running_device *pia_2 = devtag_get_device(machine, "pia_2"); + pia6821_device *pia_2 = machine->device("pia_2"); pia6821_portb_w(pia_2, 0, param); pia6821_cb1_w(pia_2, 0, (param == 0xff) ? 0 : 1); @@ -553,7 +557,7 @@ WRITE8_DEVICE_HANDLER( playball_snd_cmd_w ) static TIMER_CALLBACK( williams2_deferred_snd_cmd_w ) { - running_device *pia_2 = devtag_get_device(machine, "pia_2"); + pia6821_device *pia_2 = machine->device("pia_2"); pia6821_porta_w(pia_2, 0, param); } @@ -949,7 +953,7 @@ MACHINE_START( joust2 ) MACHINE_RESET( joust2 ) { - running_device *pia_3 = devtag_get_device(machine, "cvsdpia"); + pia6821_device *pia_3 = machine->device("cvsdpia"); /* standard init */ MACHINE_RESET_CALL(williams2); @@ -959,14 +963,14 @@ MACHINE_RESET( joust2 ) static TIMER_CALLBACK( joust2_deferred_snd_cmd_w ) { - running_device *pia_2 = devtag_get_device(machine, "pia_2"); + pia6821_device *pia_2 = machine->device("pia_2"); pia6821_porta_w(pia_2, 0, param & 0xff); } static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w ) { - running_device *pia_3 = devtag_get_device(device->machine, "cvsdpia"); + pia6821_device *pia_3 = device->machine->device("cvsdpia"); joust2_current_sound_data = (joust2_current_sound_data & ~0x100) | ((data << 8) & 0x100); pia6821_cb1_w(pia_3, offset, data); diff --git a/src/mame/machine/xevious.c b/src/mame/machine/xevious.c index 00fcc4c0a91..4b874c7dfb7 100644 --- a/src/mame/machine/xevious.c +++ b/src/mame/machine/xevious.c @@ -44,18 +44,18 @@ TIMER_DEVICE_CALLBACK( battles_nmi_generate ) { if( battles_customio_command_count == 0 ) { - cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); } else { - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); } } else { - cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); - cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); + cputag_set_input_line(timer.machine, "sub3", INPUT_LINE_NMI, PULSE_LINE); } battles_customio_command_count++; } @@ -89,7 +89,7 @@ READ8_HANDLER( battles_customio3_r ) WRITE8_HANDLER( battles_customio0_w ) { - running_device *timer = devtag_get_device(space->machine, "battles_nmi"); + timer_device *timer = space->machine->device("battles_nmi"); logerror("CPU0 %04x: custom I/O Write = %02x\n",cpu_get_pc(space->cpu),data); @@ -99,10 +99,10 @@ WRITE8_HANDLER( battles_customio0_w ) switch (data) { case 0x10: - timer_device_adjust_oneshot(timer, attotime_never, 0); + timer->reset(); return; /* nop */ } - timer_device_adjust_periodic(timer, ATTOTIME_IN_USEC(166), 0, ATTOTIME_IN_USEC(166)); + timer->adjust(ATTOTIME_IN_USEC(166), 0, ATTOTIME_IN_USEC(166)); } @@ -157,7 +157,7 @@ WRITE8_HANDLER( battles_noise_sound_w ) { logerror("CPU3 %04x: 50%02x Write = %02x\n",cpu_get_pc(space->cpu),offset,data); if( (battles_sound_played == 0) && (data == 0xFF) ){ - running_device *samples = devtag_get_device(space->machine, "samples"); + samples_sound_device *samples = space->machine->device("samples"); if( customio[0] == 0x40 ){ sample_start (samples, 0, 0, 0); } diff --git a/src/mame/video/40love.c b/src/mame/video/40love.c index a25edae4db4..1f1aa879bcf 100644 --- a/src/mame/video/40love.c +++ b/src/mame/video/40love.c @@ -106,8 +106,8 @@ VIDEO_START( fortyl ) state->pixram1 = auto_alloc_array_clear(machine, UINT8, 0x4000); state->pixram2 = auto_alloc_array_clear(machine, UINT8, 0x4000); - state->tmp_bitmap1 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); - state->tmp_bitmap2 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); + state->tmp_bitmap1 = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); + state->tmp_bitmap2 = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32); diff --git a/src/mame/video/actfancr.c b/src/mame/video/actfancr.c index ae62186d2b4..36604af39ea 100644 --- a/src/mame/video/actfancr.c +++ b/src/mame/video/actfancr.c @@ -184,7 +184,7 @@ VIDEO_UPDATE( actfancr ) x = buffered_spriteram[offs + 4] + (buffered_spriteram[offs + 5] << 8); colour = ((x & 0xf000) >> 12); flash = x & 0x800; - if (flash && (video_screen_get_frame_number(screen) & 1)) + if (flash && (screen->frame_number() & 1)) continue; fx = y & 0x2000; @@ -276,7 +276,7 @@ VIDEO_UPDATE( triothep ) x = buffered_spriteram[offs + 4] + (buffered_spriteram[offs + 5] << 8); colour = ((x & 0xf000) >> 12); flash = x & 0x800; - if (flash && (video_screen_get_frame_number(screen) & 1)) + if (flash && (screen->frame_number() & 1)) continue; fx = y & 0x2000; diff --git a/src/mame/video/airbustr.c b/src/mame/video/airbustr.c index fc40428d06f..a05fd7b9b50 100644 --- a/src/mame/video/airbustr.c +++ b/src/mame/video/airbustr.c @@ -121,7 +121,7 @@ VIDEO_START( airbustr ) state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32); - state->sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->sprites_bitmap = machine->primary_screen->alloc_compatible_bitmap(); tilemap_set_transparent_pen(state->fg_tilemap, 0); tilemap_set_scrolldx(state->bg_tilemap, 0x094, 0x06a); diff --git a/src/mame/video/amiga.c b/src/mame/video/amiga.c index c2caef56d89..5c3f862fc9f 100644 --- a/src/mame/video/amiga.c +++ b/src/mame/video/amiga.c @@ -165,10 +165,10 @@ VIDEO_START( amiga ) * *************************************/ -UINT32 amiga_gethvpos(running_device *screen) +UINT32 amiga_gethvpos(screen_device &screen) { - UINT32 hvpos = (last_scanline << 8) | (video_screen_get_hpos(screen) >> 2); - UINT32 latchedpos = input_port_read_safe(screen->machine, "HVPOS", 0); + UINT32 hvpos = (last_scanline << 8) | (screen.hpos() >> 2); + UINT32 latchedpos = input_port_read_safe(screen.machine, "HVPOS", 0); /* if there's no latched position, or if we are in the active display area */ /* but before the latching point, return the live HV position */ @@ -921,7 +921,7 @@ void amiga_render_scanline(running_machine *machine, bitmap_t *bitmap, int scanl } #if 0 - if ( video_screen_get_frame_number(machine->primary_screen) % 64 == 0 && scanline == 100 ) + if ( machine->primary_screen->frame_number() % 64 == 0 && scanline == 100 ) { const char *m_lores = "LORES"; const char *m_hires = "HIRES"; @@ -958,7 +958,7 @@ void amiga_render_scanline(running_machine *machine, bitmap_t *bitmap, int scanl CUSTOM_REG(REG_COLOR00) = save_color0; #if GUESS_COPPER_OFFSET - if (video_screen_get_frame_number(machine->primary_screen) % 64 == 0 && scanline == 0) + if (machine->primary_screen->frame_number() % 64 == 0 && scanline == 0) { if (input_code_pressed(machine, KEYCODE_Q)) popmessage("%d", wait_offset -= 1); diff --git a/src/mame/video/amigaaga.c b/src/mame/video/amigaaga.c index e8183993380..9191f560faf 100644 --- a/src/mame/video/amigaaga.c +++ b/src/mame/video/amigaaga.c @@ -208,10 +208,10 @@ VIDEO_START( amiga_aga ) * *************************************/ -UINT32 amiga_aga_gethvpos(running_device *screen) +UINT32 amiga_aga_gethvpos(screen_device &screen) { - UINT32 hvpos = (last_scanline << 8) | (video_screen_get_hpos(screen) >> 2); - UINT32 latchedpos = input_port_read_safe(screen->machine, "HVPOS", 0); + UINT32 hvpos = (last_scanline << 8) | (screen.hpos() >> 2); + UINT32 latchedpos = input_port_read_safe(screen.machine, "HVPOS", 0); /* if there's no latched position, or if we are in the active display area */ /* but before the latching point, return the live HV position */ @@ -1119,7 +1119,7 @@ void amiga_aga_render_scanline(running_machine *machine, bitmap_t *bitmap, int s } #if 0 - if ( video_screen_get_frame_number(machine->primary_screen) % 16 == 0 && scanline == 250 ) + if ( machine->primary_screen->frame_number() % 16 == 0 && scanline == 250 ) { const char *m_lores = "LORES"; const char *m_hires = "HIRES"; @@ -1157,7 +1157,7 @@ void amiga_aga_render_scanline(running_machine *machine, bitmap_t *bitmap, int s CUSTOM_REG(REG_COLOR00) = save_color0; #if GUESS_COPPER_OFFSET - if (video_screen_get_frame_number(machine->primary_screen) % 64 == 0 && scanline == 0) + if (machine->primary_screen->frame_number() % 64 == 0 && scanline == 0) { if (input_code_pressed(machine, KEYCODE_Q)) popmessage("%d", wait_offset -= 1); diff --git a/src/mame/video/amspdwy.c b/src/mame/video/amspdwy.c index c50269eb11b..c997bd3ea0b 100644 --- a/src/mame/video/amspdwy.c +++ b/src/mame/video/amspdwy.c @@ -108,8 +108,8 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect amspdwy_state *state = (amspdwy_state *)machine->driver_data; UINT8 *spriteram = state->spriteram; int i; - int max_x = video_screen_get_width(machine->primary_screen) - 1; - int max_y = video_screen_get_height(machine->primary_screen) - 1; + int max_x = machine->primary_screen->width() - 1; + int max_y = machine->primary_screen->height() - 1; for (i = 0; i < state->spriteram_size ; i += 4) { diff --git a/src/mame/video/angelkds.c b/src/mame/video/angelkds.c index 489c317d0a7..77bc3195986 100644 --- a/src/mame/video/angelkds.c +++ b/src/mame/video/angelkds.c @@ -275,7 +275,7 @@ VIDEO_START( angelkds ) VIDEO_UPDATE( angelkds ) { angelkds_state *state = (angelkds_state *)screen->machine->driver_data; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); rectangle clip; bitmap_fill(bitmap, cliprect, 0x3f); /* is there a register controling the colour?, we currently use the last colour of the tx palette */ @@ -283,8 +283,8 @@ VIDEO_UPDATE( angelkds ) /* draw top of screen */ clip.min_x = 8*0; clip.max_x = 8*16-1; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; if ((state->layer_ctrl & 0x80) == 0x00) tilemap_draw(bitmap, &clip, state->bgtop_tilemap, 0, 0); @@ -297,8 +297,8 @@ VIDEO_UPDATE( angelkds ) /* draw bottom of screen */ clip.min_x = 8*16; clip.max_x = 8*32-1; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; if ((state->layer_ctrl & 0x40) == 0x00) tilemap_draw(bitmap, &clip, state->bgbot_tilemap, 0, 0); diff --git a/src/mame/video/argus.c b/src/mame/video/argus.c index a0e909f83c8..ab92bd0d679 100644 --- a/src/mame/video/argus.c +++ b/src/mame/video/argus.c @@ -344,7 +344,7 @@ VIDEO_START( valtric ) tilemap_set_transparent_pen(tx_tilemap, 15); - mosaicbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + mosaicbitmap = machine->primary_screen->alloc_compatible_bitmap(); jal_blend_table = auto_alloc_array(machine, UINT8, 0xc00); } @@ -913,7 +913,7 @@ static void argus_draw_sprites(running_machine *machine, bitmap_t *bitmap, const } #if 1 -static void valtric_draw_mosaic(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect) +static void valtric_draw_mosaic(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect) { static int mosaic=0; @@ -933,8 +933,8 @@ static void valtric_draw_mosaic(running_device *screen, bitmap_t *bitmap, const int step=mosaic; UINT32 *dest; int x,y,xx,yy; - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen.width(); + int height = screen.height(); if (mosaic<0)step*=-1; @@ -964,7 +964,7 @@ static void valtric_draw_mosaic(running_device *screen, bitmap_t *bitmap, const } } #else -static void valtric_draw_mosaic(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect) +static void valtric_draw_mosaic(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect) { int step = 0x10 - (valtric_mosaic & 0x0f); @@ -976,8 +976,8 @@ static void valtric_draw_mosaic(running_device *screen, bitmap_t *bitmap, const { UINT32 *dest; int x,y,xx,yy; - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen.width(); + int height = screen.height(); for (y = 0; y < width+step; y += step) for (x = 0; x < height+step; x += step) @@ -1229,7 +1229,7 @@ VIDEO_UPDATE( valtric ) bg_setting(screen->machine); if (argus_bg_status & 1) /* Backgound enable */ - valtric_draw_mosaic(screen, bitmap, cliprect); + valtric_draw_mosaic(*screen, bitmap, cliprect); else bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); valtric_draw_sprites(screen->machine, bitmap, cliprect); diff --git a/src/mame/video/artmagic.c b/src/mame/video/artmagic.c index 664b2708b5c..de4bbeb80f8 100644 --- a/src/mame/video/artmagic.c +++ b/src/mame/video/artmagic.c @@ -351,7 +351,7 @@ WRITE16_HANDLER( artmagic_blitter_w ) * *************************************/ -void artmagic_scanline(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void artmagic_scanline(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { offs_t offset = (params->rowaddr << 12) & 0x7ff000; UINT16 *vram = address_to_vram(&offset); diff --git a/src/mame/video/astrocde.c b/src/mame/video/astrocde.c index 85141ae6f1a..7b7a8129c35 100644 --- a/src/mame/video/astrocde.c +++ b/src/mame/video/astrocde.c @@ -223,7 +223,7 @@ VIDEO_START( astrocde ) { /* allocate a per-scanline timer */ scanline_timer = timer_alloc(machine, scanline_callback, NULL); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 1, 0), 1); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(1), 1); /* register for save states */ init_savestate(machine); @@ -238,7 +238,7 @@ VIDEO_START( profpac ) { /* allocate a per-scanline timer */ scanline_timer = timer_alloc(machine, scanline_callback, NULL); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 1, 0), 1); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(1), 1); /* allocate videoram */ profpac_videoram = auto_alloc_array(machine, UINT16, 0x4000 * 4); @@ -308,11 +308,11 @@ VIDEO_UPDATE( astrocde ) int y; /* compute the starting point of sparkle for the current frame */ - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); if (astrocade_video_config & AC_STARS) - sparklebase = (video_screen_get_frame_number(screen) * (UINT64)(width * height)) % RNG_PERIOD; + sparklebase = (screen->frame_number() * (UINT64)(width * height)) % RNG_PERIOD; /* iterate over scanlines */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) @@ -441,7 +441,7 @@ static void astrocade_trigger_lightpen(running_machine *machine, UINT8 vfeedback if ((interrupt_enable & 0x01) == 0) { cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector & 0xf0); - timer_set(machine, video_screen_get_time_until_vblank_end(machine->primary_screen), NULL, 0, interrupt_off); + timer_set(machine, machine->primary_screen->time_until_vblank_end(), NULL, 0, interrupt_off); } /* mode 1 means assert for 1 instruction */ @@ -472,7 +472,7 @@ static TIMER_CALLBACK( scanline_callback ) /* force an update against the current scanline */ if (scanline > 0) - video_screen_update_partial(machine->primary_screen, scanline - 1); + machine->primary_screen->update_partial(scanline - 1); /* generate a scanline interrupt if it's time */ if (astrocade_scanline == interrupt_scanline && (interrupt_enable & 0x08) != 0) @@ -481,7 +481,7 @@ static TIMER_CALLBACK( scanline_callback ) if ((interrupt_enable & 0x04) == 0) { cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, interrupt_vector); - timer_set(machine, video_screen_get_time_until_vblank_end(machine->primary_screen), NULL, 0, interrupt_off); + timer_set(machine, machine->primary_screen->time_until_vblank_end(), NULL, 0, interrupt_off); } /* mode 1 means assert for 1 instruction */ @@ -498,9 +498,9 @@ static TIMER_CALLBACK( scanline_callback ) /* advance to the next scanline */ scanline++; - if (scanline >= video_screen_get_height(machine->primary_screen)) + if (scanline >= machine->primary_screen->height()) scanline = 0; - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c index 3d4331fd59e..9dd9df3c8d8 100644 --- a/src/mame/video/atari.c +++ b/src/mame/video/atari.c @@ -755,7 +755,7 @@ VIDEO_START( atari ) LOG(("atari prio_init\n")); prio_init(); - for( i = 0; i < video_screen_get_height(machine->primary_screen); i++ ) + for( i = 0; i < machine->primary_screen->height(); i++ ) { antic.video[i] = auto_alloc_clear(machine, VIDEO); } @@ -946,7 +946,7 @@ static void antic_linerefresh(running_machine *machine) UINT32 scanline[4 + (HCHARS * 2) + 4]; /* increment the scanline */ - if( ++antic.scanline == video_screen_get_height(machine->primary_screen) ) + if( ++antic.scanline == machine->primary_screen->height() ) { /* and return to the top if the frame was complete */ antic.scanline = 0; @@ -1048,12 +1048,12 @@ static void antic_linerefresh(running_machine *machine) static int cycle(running_machine *machine) { - return video_screen_get_hpos(machine->primary_screen) * CYCLES_PER_LINE / video_screen_get_width(machine->primary_screen); + return machine->primary_screen->hpos() * CYCLES_PER_LINE / machine->primary_screen->width(); } static void after(running_machine *machine, int cycles, timer_fired_func function, const char *funcname) { - attotime duration = attotime_make(0, attotime_to_attoseconds(video_screen_get_scan_period(machine->primary_screen)) * cycles / CYCLES_PER_LINE); + attotime duration = attotime_make(0, attotime_to_attoseconds(machine->primary_screen->scan_period()) * cycles / CYCLES_PER_LINE); (void)funcname; LOG((" after %3d (%5.1f us) %s\n", cycles, attotime_to_double(duration) * 1.0e6, funcname)); timer_set(machine, duration, NULL, 0, function); @@ -1354,7 +1354,7 @@ static void antic_scanline_dma(running_machine *machine, int param) /* produce empty scanlines until vblank start */ antic.modelines = VBL_START + 1 - antic.scanline; if( antic.modelines < 0 ) - antic.modelines = video_screen_get_height(machine->primary_screen) - antic.scanline; + antic.modelines = machine->primary_screen->height() - antic.scanline; LOG((" JVB $%04x\n", antic.dpage|antic.doffs)); } else @@ -1521,7 +1521,7 @@ static void generic_atari_interrupt(running_machine *machine, void (*handle_keyb handle_keyboard(machine); /* do nothing new for the rest of the frame */ - antic.modelines = video_screen_get_height(machine->primary_screen) - VBL_START; + antic.modelines = machine->primary_screen->height() - VBL_START; antic.renderer = antic_mode_0_xx; /* if the CPU want's to be interrupted at vertical blank... */ diff --git a/src/mame/video/atarig1.c b/src/mame/video/atarig1.c index 544ca7a4701..342198dbd52 100644 --- a/src/mame/video/atarig1.c +++ b/src/mame/video/atarig1.c @@ -124,16 +124,16 @@ WRITE16_HANDLER( atarig1_mo_control_w ) { atarig1_state *state = (atarig1_state *)space->machine->driver_data; - logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); + logerror("MOCONT = %d (scan = %d)\n", data, space->machine->primary_screen->vpos()); /* set the control value */ COMBINE_DATA(&state->current_control); } -void atarig1_scanline_update(running_device *screen, int scanline) +void atarig1_scanline_update(screen_device &screen, int scanline) { - atarig1_state *state = (atarig1_state *)screen->machine->driver_data; + atarig1_state *state = (atarig1_state *)screen.machine->driver_data; UINT16 *base = &state->atarigen.alpha[(scanline / 8) * 64 + 48]; int i; @@ -142,7 +142,7 @@ void atarig1_scanline_update(running_device *screen, int scanline) /* keep in range */ if (base >= &state->atarigen.alpha[0x800]) return; - video_screen_update_partial(screen, MAX(scanline - 1, 0)); + screen.update_partial(MAX(scanline - 1, 0)); /* update the playfield scrolls */ for (i = 0; i < 8; i++) @@ -156,7 +156,7 @@ void atarig1_scanline_update(running_device *screen, int scanline) int newscroll = ((word >> 6) + state->pfscroll_xoffset) & 0x1ff; if (newscroll != state->playfield_xscroll) { - video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); + screen.update_partial(MAX(scanline + i - 1, 0)); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_xscroll = newscroll; } @@ -170,13 +170,13 @@ void atarig1_scanline_update(running_device *screen, int scanline) int newbank = word & 7; if (newscroll != state->playfield_yscroll) { - video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); + screen.update_partial(MAX(scanline + i - 1, 0)); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_yscroll = newscroll; } if (newbank != state->playfield_tile_bank) { - video_screen_update_partial(screen, MAX(scanline + i - 1, 0)); + screen.update_partial(MAX(scanline + i - 1, 0)); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_tile_bank = newbank; } diff --git a/src/mame/video/atarig42.c b/src/mame/video/atarig42.c index e38df425990..7da0668793f 100644 --- a/src/mame/video/atarig42.c +++ b/src/mame/video/atarig42.c @@ -129,16 +129,16 @@ WRITE16_HANDLER( atarig42_mo_control_w ) { atarig42_state *state = (atarig42_state *)space->machine->driver_data; - logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); + logerror("MOCONT = %d (scan = %d)\n", data, space->machine->primary_screen->vpos()); /* set the control value */ COMBINE_DATA(&state->current_control); } -void atarig42_scanline_update(running_device *screen, int scanline) +void atarig42_scanline_update(screen_device &screen, int scanline) { - atarig42_state *state = (atarig42_state *)screen->machine->driver_data; + atarig42_state *state = (atarig42_state *)screen.machine->driver_data; UINT16 *base = &state->atarigen.alpha[(scanline / 8) * 64 + 48]; int i; @@ -161,14 +161,14 @@ void atarig42_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_xscroll = newscroll; } if (newbank != state->playfield_color_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_color_bank = newbank; } @@ -182,14 +182,14 @@ void atarig42_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_yscroll = newscroll; } if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_tile_bank = newbank; } diff --git a/src/mame/video/atarigt.c b/src/mame/video/atarigt.c index e168e66132a..7dc356c0725 100644 --- a/src/mame/video/atarigt.c +++ b/src/mame/video/atarigt.c @@ -116,8 +116,8 @@ VIDEO_START( atarigt ) state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows, 8,8, 64,32); /* allocate temp bitmaps */ - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); state->pf_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); state->an_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -186,9 +186,9 @@ UINT16 atarigt_colorram_r(atarigt_state *state, offs_t address) * *************************************/ -void atarigt_scanline_update(running_device *screen, int scanline) +void atarigt_scanline_update(screen_device &screen, int scanline) { - atarigt_state *state = (atarigt_state *)screen->machine->driver_data; + atarigt_state *state = (atarigt_state *)screen.machine->driver_data; UINT32 *base = &state->atarigen.alpha32[(scanline / 8) * 32 + 24]; int i; @@ -208,14 +208,14 @@ void atarigt_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_xscroll = newscroll; } if (newbank != state->playfield_color_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_palette_offset(state->atarigen.playfield_tilemap, (newbank & 0x1f) << 8); state->playfield_color_bank = newbank; } @@ -228,14 +228,14 @@ void atarigt_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_yscroll = newscroll; } if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_tile_bank = newbank; } diff --git a/src/mame/video/atarigx2.c b/src/mame/video/atarigx2.c index cddad654a0d..645e7e1b256 100644 --- a/src/mame/video/atarigx2.c +++ b/src/mame/video/atarigx2.c @@ -129,16 +129,16 @@ WRITE16_HANDLER( atarigx2_mo_control_w ) { atarigx2_state *state = (atarigx2_state *)space->machine->driver_data; - logerror("MOCONT = %d (scan = %d)\n", data, video_screen_get_vpos(space->machine->primary_screen)); + logerror("MOCONT = %d (scan = %d)\n", data, space->machine->primary_screen->vpos()); /* set the control value */ COMBINE_DATA(&state->current_control); } -void atarigx2_scanline_update(running_device *screen, int scanline) +void atarigx2_scanline_update(screen_device &screen, int scanline) { - atarigx2_state *state = (atarigx2_state *)screen->machine->driver_data; + atarigx2_state *state = (atarigx2_state *)screen.machine->driver_data; UINT32 *base = &state->atarigen.alpha32[(scanline / 8) * 32 + 24]; int i; @@ -160,14 +160,14 @@ void atarigx2_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_xscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_xscroll = newscroll; } if (newbank != state->playfield_color_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_color_bank = newbank; } @@ -180,14 +180,14 @@ void atarigx2_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_yscroll) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_yscroll = newscroll; } if (newbank != state->playfield_tile_bank) { if (scanline + i > 0) - video_screen_update_partial(screen, scanline + i - 1); + screen.update_partial(scanline + i - 1); tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); state->playfield_tile_bank = newbank; } diff --git a/src/mame/video/atarimo.c b/src/mame/video/atarimo.c index c9917ef35df..b9a8ae351db 100644 --- a/src/mame/video/atarimo.c +++ b/src/mame/video/atarimo.c @@ -318,12 +318,12 @@ static TIMER_CALLBACK( force_update ) int scanline = param; if (scanline > 0) - video_screen_update_partial(machine->primary_screen, scanline - 1); + machine->primary_screen->update_partial(scanline - 1); scanline += 64; - if (scanline >= video_screen_get_visible_area(machine->primary_screen)->max_y) + if (scanline >= machine->primary_screen->visible_area().max_y) scanline = 0; - timer_adjust_oneshot(force_update_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(force_update_timer, machine->primary_screen->time_until_pos(scanline), scanline); } /*--------------------------------------------------------------- @@ -404,7 +404,7 @@ void atarimo_init(running_machine *machine, int map, const atarimo_desc *desc) mo->slipram = (map == 0) ? &atarimo_0_slipram : &atarimo_1_slipram; /* allocate the temp bitmap */ - mo->bitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16); + mo->bitmap = auto_bitmap_alloc(machine, machine->primary_screen->width(), machine->primary_screen->height(), BITMAP_FORMAT_INDEXED16); bitmap_fill(mo->bitmap, NULL, desc->transpen); /* allocate the spriteram */ @@ -425,8 +425,8 @@ void atarimo_init(running_machine *machine, int map, const atarimo_desc *desc) mo->colorlookup[i] = i; /* allocate dirty grid */ - mo->dirtywidth = (video_screen_get_width(machine->primary_screen) >> mo->tilexshift) + 2; - mo->dirtyheight = (video_screen_get_height(machine->primary_screen) >> mo->tileyshift) + 2; + mo->dirtywidth = (machine->primary_screen->width() >> mo->tilexshift) + 2; + mo->dirtyheight = (machine->primary_screen->height() >> mo->tileyshift) + 2; mo->dirtygrid = auto_alloc_array(machine, UINT8, mo->dirtywidth * mo->dirtyheight); /* allocate the gfx lookup */ @@ -441,7 +441,7 @@ void atarimo_init(running_machine *machine, int map, const atarimo_desc *desc) /* start a timer to update a few times during refresh */ force_update_timer = timer_alloc(machine, force_update, NULL); - timer_adjust_oneshot(force_update_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(force_update_timer,machine->primary_screen->time_until_pos(0), 0); init_savestate(machine, map, mo); @@ -689,7 +689,7 @@ bitmap_t *atarimo_render(int map, const rectangle *cliprect, atarimo_rect_list * /* compute minimum Y and wrap around if necessary */ bandclip.min_y = ((band << mo->slipshift) - mo->yscroll + mo->slipoffset) & mo->bitmapymask; - if (bandclip.min_y > video_screen_get_visible_area(mo->machine->primary_screen)->max_y) + if (bandclip.min_y > mo->machine->primary_screen->visible_area().max_y) bandclip.min_y -= mo->bitmapheight; /* maximum Y is based on the minimum */ @@ -807,8 +807,8 @@ if ((temp & 0xff00) == 0xc800) /* adjust the final coordinates */ xpos &= mo->bitmapxmask; ypos &= mo->bitmapymask; - if (xpos > video_screen_get_visible_area(mo->machine->primary_screen)->max_x) xpos -= mo->bitmapwidth; - if (ypos > video_screen_get_visible_area(mo->machine->primary_screen)->max_y) ypos -= mo->bitmapheight; + if (xpos > mo->machine->primary_screen->visible_area().max_x) xpos -= mo->bitmapwidth; + if (ypos > mo->machine->primary_screen->visible_area().max_y) ypos -= mo->bitmapheight; /* is this one special? */ if (mo->specialmask.mask != 0 && EXTRACT_DATA(entry, mo->specialmask) == mo->specialvalue) diff --git a/src/mame/video/atarirle.c b/src/mame/video/atarirle.c index 18401b3ea50..70169e7b9ac 100644 --- a/src/mame/video/atarirle.c +++ b/src/mame/video/atarirle.c @@ -307,7 +307,7 @@ void atarirle_init(running_machine *machine, int map, const atarirle_desc *desc) mo->romlength = memory_region_length(machine, desc->region); mo->objectcount = count_objects(base, mo->romlength); - mo->cliprect = *video_screen_get_visible_area(machine->primary_screen); + mo->cliprect = machine->primary_screen->visible_area(); if (desc->rightclip) { mo->cliprect.min_x = desc->leftclip; @@ -336,8 +336,8 @@ void atarirle_init(running_machine *machine, int map, const atarirle_desc *desc) mo->spriteram = auto_alloc_array_clear(machine, atarirle_entry, mo->spriteramsize); /* allocate bitmaps */ - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); mo->vram[0][0] = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); mo->vram[0][1] = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -380,7 +380,7 @@ void atarirle_init(running_machine *machine, int map, const atarirle_desc *desc) void atarirle_control_w(running_machine *machine, int map, UINT8 bits) { atarirle_data *mo = &atarirle[map]; - int scanline = video_screen_get_vpos(machine->primary_screen); + int scanline = machine->primary_screen->vpos(); int oldbits = mo->control_bits; //logerror("atarirle_control_w(%d)\n", bits); @@ -390,7 +390,7 @@ void atarirle_control_w(running_machine *machine, int map, UINT8 bits) return; /* force a partial update first */ - video_screen_update_partial(machine->primary_screen, scanline); + machine->primary_screen->update_partial(scanline); /* if the erase flag was set, erase the front map */ if (oldbits & ATARIRLE_CONTROL_ERASE) @@ -838,7 +838,7 @@ if (hilite) do { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); int scaled_width = (scale * info->width + 0x7fff) >> 12; int scaled_height = (scale * info->height + 0x7fff) >> 12; int ex, ey, sx = x, sy = y, tx, ty; @@ -852,27 +852,27 @@ if (hilite) ey = sy + scaled_height - 1; /* left edge clip */ - if (sx < visarea->min_x) - sx = visarea->min_x; - if (sx > visarea->max_x) + if (sx < visarea.min_x) + sx = visarea.min_x; + if (sx > visarea.max_x) break; /* right edge clip */ - if (ex > visarea->max_x) - ex = visarea->max_x; - else if (ex < visarea->min_x) + if (ex > visarea.max_x) + ex = visarea.max_x; + else if (ex < visarea.min_x) break; /* top edge clip */ - if (sy < visarea->min_y) - sy = visarea->min_y; - else if (sy > visarea->max_y) + if (sy < visarea.min_y) + sy = visarea.min_y; + else if (sy > visarea.max_y) break; /* bottom edge clip */ - if (ey > visarea->max_y) - ey = visarea->max_y; - else if (ey < visarea->min_y) + if (ey > visarea.max_y) + ey = visarea.max_y; + else if (ey < visarea.min_y) break; for (ty = sy; ty <= ey; ty++) @@ -914,7 +914,7 @@ void draw_rle(atarirle_data *mo, bitmap_t *bitmap, int code, int color, int hfli if (hflip) scaled_xoffs = ((xscale * info->width) >> 12) - scaled_xoffs; -//if (clip->min_y == video_screen_get_visible_area(Machine->primary_screen)->min_y) +//if (clip->min_y == Machine->primary_screen->visible_area().min_y) //logerror(" Sprite: c=%04X l=%04X h=%d X=%4d (o=%4d w=%3d) Y=%4d (o=%4d h=%d) s=%04X\n", // code, color, hflip, // x, -scaled_xoffs, (xscale * info->width) >> 12, diff --git a/src/mame/video/atarisy1.c b/src/mame/video/atarisy1.c index 1bd5a3d78da..f11921e392a 100644 --- a/src/mame/video/atarisy1.c +++ b/src/mame/video/atarisy1.c @@ -196,9 +196,6 @@ VIDEO_START( atarisy1 ) /* reset the statics */ atarimo_set_yscroll(0, 256); state->next_timer_scanline = -1; - state->scanline_timer = devtag_get_device(machine, "scan_timer"); - state->int3off_timer = devtag_get_device(machine, "int3off_timer"); - state->yscroll_reset_timer = devtag_get_device(machine, "yreset_timer"); /* save state */ state_save_register_global(machine, state->playfield_tile_bank); @@ -219,7 +216,7 @@ WRITE16_HANDLER( atarisy1_bankselect_w ) atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; UINT16 oldselect = *state->bankselect; UINT16 newselect = oldselect, diff; - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); /* update memory */ COMBINE_DATA(&newselect); @@ -234,7 +231,7 @@ WRITE16_HANDLER( atarisy1_bankselect_w ) /* if MO or playfield banks change, force a partial update */ if (diff & 0x003c) - video_screen_update_partial(space->machine->primary_screen, scanline); + space->machine->primary_screen->update_partial(scanline); /* motion object bank select */ atarimo_set_bank(0, (newselect >> 3) & 7); @@ -268,7 +265,7 @@ WRITE16_HANDLER( atarisy1_priority_w ) /* force a partial update in case this changes mid-screen */ COMBINE_DATA(&newpens); if (oldpens != newpens) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); state->playfield_priority_pens = newpens; } @@ -289,7 +286,7 @@ WRITE16_HANDLER( atarisy1_xscroll_w ) /* force a partial update in case this changes mid-screen */ COMBINE_DATA(&newscroll); if (oldscroll != newscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* set the new scroll value */ tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll); @@ -308,7 +305,7 @@ WRITE16_HANDLER( atarisy1_xscroll_w ) TIMER_DEVICE_CALLBACK( atarisy1_reset_yscroll_callback ) { - atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer.machine->driver_data; tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, param); } @@ -318,23 +315,23 @@ WRITE16_HANDLER( atarisy1_yscroll_w ) atarisy1_state *state = (atarisy1_state *)space->machine->driver_data; UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); int adjusted_scroll; /* force a partial update in case this changes mid-screen */ COMBINE_DATA(&newscroll); - video_screen_update_partial(space->machine->primary_screen, scanline); + space->machine->primary_screen->update_partial(scanline); /* because this latches a new value into the scroll base, we need to adjust for the scanline */ adjusted_scroll = newscroll; - if (scanline <= video_screen_get_visible_area(space->machine->primary_screen)->max_y) + if (scanline <= space->machine->primary_screen->visible_area().max_y) adjusted_scroll -= (scanline + 1); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, adjusted_scroll); /* but since we've adjusted it, we must reset it to the normal value once we hit scanline 0 again */ - timer_device_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll); + state->yscroll_reset_timer->adjust(space->machine->primary_screen->time_until_pos(0), newscroll); /* update the data */ *state->atarigen.yscroll = newscroll; @@ -364,7 +361,7 @@ WRITE16_HANDLER( atarisy1_spriteram_w ) { /* if the timer is in the active bank, update the display list */ atarimo_0_spriteram_w(space, offset, data, 0xffff); - update_timers(space->machine, video_screen_get_vpos(space->machine->primary_screen)); + update_timers(space->machine, space->machine->primary_screen->vpos()); } /* if we're about to modify data in the active sprite bank, make sure the video is up-to-date */ @@ -372,7 +369,7 @@ WRITE16_HANDLER( atarisy1_spriteram_w ) /* renders the next scanline's sprites to the line buffers, but Road Runner still glitches */ /* without the extra +1 */ else - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) + 2); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() + 2); } /* let the MO handler do the basic work */ @@ -389,7 +386,7 @@ WRITE16_HANDLER( atarisy1_spriteram_w ) TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback ) { - const address_space *space = cputag_get_address_space(timer->machine, "maincpu", ADDRESS_SPACE_PROGRAM); + const address_space *space = cputag_get_address_space(timer.machine, "maincpu", ADDRESS_SPACE_PROGRAM); /* clear the state */ atarigen_scanline_int_ack_w(space, 0, 0, 0xffff); @@ -398,18 +395,18 @@ TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback ) TIMER_DEVICE_CALLBACK( atarisy1_int3_callback ) { - atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data; + atarisy1_state *state = (atarisy1_state *)timer.machine->driver_data; int scanline = param; /* update the state */ - atarigen_scanline_int_gen(devtag_get_device(timer->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(timer.machine, "maincpu")); /* set a timer to turn it off */ - timer_device_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(timer->machine->primary_screen), 0); + state->int3off_timer->adjust(timer.machine->primary_screen->scan_period()); /* determine the time of the next one */ state->next_timer_scanline = -1; - update_timers(timer->machine, scanline); + update_timers(timer.machine, scanline); } @@ -486,9 +483,9 @@ static void update_timers(running_machine *machine, int scanline) /* set a new one */ if (best != -1) - timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best); + state->scanline_timer->adjust(machine->primary_screen->time_until_pos(best), best); else - timer_device_adjust_oneshot(state->scanline_timer, attotime_never, 0); + state->scanline_timer->reset(); } } diff --git a/src/mame/video/atarisy2.c b/src/mame/video/atarisy2.c index 035e83ffbd0..7800ef21b9a 100644 --- a/src/mame/video/atarisy2.c +++ b/src/mame/video/atarisy2.c @@ -136,7 +136,7 @@ WRITE16_HANDLER( atarisy2_xscroll_w ) /* if anything has changed, force a partial update */ if (newscroll != oldscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* update the playfield scrolling - hscroll is clocked on the following scanline */ tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll >> 6); @@ -169,13 +169,13 @@ WRITE16_HANDLER( atarisy2_yscroll_w ) /* if anything has changed, force a partial update */ if (newscroll != oldscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* if bit 4 is zero, the scroll value is clocked in right away */ if (!(newscroll & 0x10)) - tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, (newscroll >> 6) - video_screen_get_vpos(space->machine->primary_screen)); + tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, (newscroll >> 6) - space->machine->primary_screen->vpos()); else - timer_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll >> 6); + timer_adjust_oneshot(state->yscroll_reset_timer, space->machine->primary_screen->time_until_pos(0), newscroll >> 6); /* update the playfield banking */ if (state->playfield_tile_bank[1] != (newscroll & 0x0f) * 0x400) @@ -285,7 +285,7 @@ WRITE16_HANDLER( atarisy2_videoram_w ) { /* force an update if the link of object 0 is about to change */ if (offs == 0x0c03) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); atarimo_0_spriteram_w(space, offs - 0x0c00, data, mem_mask); } diff --git a/src/mame/video/avgdvg.c b/src/mame/video/avgdvg.c index c02cf18f2f8..72994354288 100644 --- a/src/mame/video/avgdvg.c +++ b/src/mame/video/avgdvg.c @@ -1490,15 +1490,15 @@ static void register_state (running_machine *machine) static VIDEO_START( avg_common ) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); vg = &vgd; vg->machine = machine; - xmin = visarea->min_x; - ymin = visarea->min_y; - xmax = visarea->max_x; - ymax = visarea->max_y; + xmin = visarea.min_x; + ymin = visarea.min_y; + xmax = visarea.max_x; + ymax = visarea.max_y; xcenter = ((xmax - xmin) / 2) << 16; ycenter = ((ymax - ymin) / 2) << 16; @@ -1522,14 +1522,14 @@ static VIDEO_START( avg_common ) VIDEO_START( dvg ) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); vgc = &dvg_default; vg = &vgd; vg->machine = machine; - xmin = visarea->min_x; - ymin = visarea->min_y; + xmin = visarea.min_x; + ymin = visarea.min_y; vg_halt_timer = timer_alloc(machine, vg_set_halt_callback, NULL); vg_run_timer = timer_alloc(machine, run_state_machine, NULL); diff --git a/src/mame/video/aztarac.c b/src/mame/video/aztarac.c index 718ae16fdbb..918a366515e 100644 --- a/src/mame/video/aztarac.c +++ b/src/mame/video/aztarac.c @@ -83,12 +83,12 @@ WRITE16_HANDLER( aztarac_ubr_w ) VIDEO_START( aztarac ) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - int xmin = visarea->min_x; - int ymin = visarea->min_y; - int xmax = visarea->max_x; - int ymax = visarea->max_y; + int xmin = visarea.min_x; + int ymin = visarea.min_y; + int xmax = visarea.max_x; + int ymax = visarea.max_y; xcenter=((xmax + xmin) / 2) << 16; ycenter=((ymax + ymin) / 2) << 16; diff --git a/src/mame/video/badlands.c b/src/mame/video/badlands.c index 6924a108c75..40666c39d79 100644 --- a/src/mame/video/badlands.c +++ b/src/mame/video/badlands.c @@ -96,7 +96,7 @@ WRITE16_HANDLER( badlands_pf_bank_w ) if (ACCESSING_BITS_0_7) if (state->playfield_tile_bank != (data & 1)) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); state->playfield_tile_bank = data & 1; tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } diff --git a/src/mame/video/balsente.c b/src/mame/video/balsente.c index b2e11ea6ada..395b9bd967c 100644 --- a/src/mame/video/balsente.c +++ b/src/mame/video/balsente.c @@ -69,11 +69,11 @@ WRITE8_HANDLER( balsente_palette_select_w ) if (state->palettebank_vis != (data & 3)) { /* update the scanline palette */ - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1 + BALSENTE_VBEND); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1 + BALSENTE_VBEND); state->palettebank_vis = data & 3; } - logerror("balsente_palette_select_w(%d) scanline=%d\n", data & 3, video_screen_get_vpos(space->machine->primary_screen)); + logerror("balsente_palette_select_w(%d) scanline=%d\n", data & 3, space->machine->primary_screen->vpos()); } @@ -111,7 +111,7 @@ WRITE8_HANDLER( shrike_sprite_select_w ) if( state->sprite_data != state->sprite_bank[(data & 0x80 >> 7) ^ 1 ]) { logerror( "shrike_sprite_select_w( 0x%02x )\n", data ); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1 + BALSENTE_VBEND); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1 + BALSENTE_VBEND); state->sprite_data = state->sprite_bank[(data & 0x80 >> 7) ^ 1]; } diff --git a/src/mame/video/batman.c b/src/mame/video/batman.c index ed819df2ec8..d07746c6655 100644 --- a/src/mame/video/batman.c +++ b/src/mame/video/batman.c @@ -121,12 +121,12 @@ VIDEO_START( batman ) * *************************************/ -void batman_scanline_update(running_device *screen, int scanline) +void batman_scanline_update(screen_device &screen, int scanline) { - batman_state *state = (batman_state *)screen->machine->driver_data; + batman_state *state = (batman_state *)screen.machine->driver_data; /* update the scanline parameters */ - if (scanline <= video_screen_get_visible_area(screen)->max_y && state->atarigen.atarivc_state.rowscroll_enable) + if (scanline <= screen.visible_area().max_y && state->atarigen.atarivc_state.rowscroll_enable) { UINT16 *base = &state->atarigen.alpha[scanline / 8 * 64 + 48]; int scan, i; @@ -139,14 +139,14 @@ void batman_scanline_update(running_device *screen, int scanline) { case 9: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.mo_xscroll = (data >> 7) & 0x1ff; atarimo_set_xscroll(0, state->atarigen.atarivc_state.mo_xscroll); break; case 10: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.pf1_xscroll_raw = (data >> 7) & 0x1ff; atarivc_update_pf_xscrolls(&state->atarigen); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_xscroll); @@ -155,7 +155,7 @@ void batman_scanline_update(running_device *screen, int scanline) case 11: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.pf0_xscroll_raw = (data >> 7) & 0x1ff; atarivc_update_pf_xscrolls(&state->atarigen); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_xscroll); @@ -163,21 +163,21 @@ void batman_scanline_update(running_device *screen, int scanline) case 13: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.mo_yscroll = (data >> 7) & 0x1ff; atarimo_set_yscroll(0, state->atarigen.atarivc_state.mo_yscroll); break; case 14: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.pf1_yscroll = (data >> 7) & 0x1ff; tilemap_set_scrolly(state->atarigen.playfield2_tilemap, 0, state->atarigen.atarivc_state.pf1_yscroll); break; case 15: if (scanline > 0) - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->atarigen.atarivc_state.pf0_yscroll = (data >> 7) & 0x1ff; tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, state->atarigen.atarivc_state.pf0_yscroll); break; diff --git a/src/mame/video/battlera.c b/src/mame/video/battlera.c index 098f16167e3..b8b94cd8993 100644 --- a/src/mame/video/battlera.c +++ b/src/mame/video/battlera.c @@ -33,8 +33,8 @@ VIDEO_START( battlera ) memset(HuC6270_vram,0,0x20000); memset(vram_dirty,1,0x1000); - tile_bitmap=auto_bitmap_alloc(machine,512,512,video_screen_get_format(machine->primary_screen)); - front_bitmap=auto_bitmap_alloc(machine,512,512,video_screen_get_format(machine->primary_screen)); + tile_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); + front_bitmap=auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); vram_ptr=0; inc_value=1; @@ -377,14 +377,14 @@ INTERRUPT_GEN( battlera_interrupt ) /* If raster interrupt occurs, refresh screen _up_ to this point */ if (rcr_enable && (current_scanline+56)==HuC6270_registers[6]) { - video_screen_update_partial(device->machine->primary_screen, current_scanline); + device->machine->primary_screen->update_partial(current_scanline); cpu_set_input_line(device, 0, HOLD_LINE); /* RCR interrupt */ } /* Start of vblank */ else if (current_scanline==240) { bldwolf_vblank=1; - video_screen_update_partial(device->machine->primary_screen, 240); + device->machine->primary_screen->update_partial(240); if (irq_enable) cpu_set_input_line(device, 0, HOLD_LINE); /* VBL */ } diff --git a/src/mame/video/beathead.c b/src/mame/video/beathead.c index 0b81ce59d31..6fe1d0822c0 100644 --- a/src/mame/video/beathead.c +++ b/src/mame/video/beathead.c @@ -95,9 +95,9 @@ WRITE32_HANDLER( beathead_finescroll_w ) UINT32 newword = COMBINE_DATA(&state->finescroll); /* if VBLANK is going off on a scanline other than the last, suspend time */ - if ((oldword & 8) && !(newword & 8) && video_screen_get_vpos(space->machine->primary_screen) != 261) + if ((oldword & 8) && !(newword & 8) && space->machine->primary_screen->vpos() != 261) { - logerror("Suspending time! (scanline = %d)\n", video_screen_get_vpos(space->machine->primary_screen)); + logerror("Suspending time! (scanline = %d)\n", space->machine->primary_screen->vpos()); cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_HALT, ASSERT_LINE); } } diff --git a/src/mame/video/bfm_dm01.c b/src/mame/video/bfm_dm01.c index 7793327284d..00ed73b15d8 100644 --- a/src/mame/video/bfm_dm01.c +++ b/src/mame/video/bfm_dm01.c @@ -240,7 +240,7 @@ INTERRUPT_GEN( bfm_dm01_vbl ) VIDEO_START( bfm_dm01 ) { - dm_bitmap = auto_bitmap_alloc(machine, DM_BYTESPERROW*8, DM_MAXLINES,video_screen_get_format(machine->primary_screen)); + dm_bitmap = auto_bitmap_alloc(machine, DM_BYTESPERROW*8, DM_MAXLINES,machine->primary_screen->format()); } /////////////////////////////////////////////////////////////////////////// @@ -249,9 +249,9 @@ VIDEO_START( bfm_dm01 ) VIDEO_UPDATE( bfm_dm01 ) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); - copybitmap(bitmap, dm_bitmap, 0,0,0,0, visarea); + copybitmap(bitmap, dm_bitmap, 0,0,0,0, &visarea); LOG(("Busy=%X",data_avail)); LOG(("%X",Scorpion2_GetSwitchState(FEEDBACK_STROBE,FEEDBACK_DATA))); diff --git a/src/mame/video/bigevglf.c b/src/mame/video/bigevglf.c index b3917e6d4bc..d237391137e 100644 --- a/src/mame/video/bigevglf.c +++ b/src/mame/video/bigevglf.c @@ -58,10 +58,10 @@ VIDEO_START( bigevglf ) { bigevglf_state *state = (bigevglf_state *)machine->driver_data; - state->tmp_bitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmp_bitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmp_bitmap[2] = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmp_bitmap[3] = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmp_bitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmp_bitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmp_bitmap[2] = machine->primary_screen->alloc_compatible_bitmap(); + state->tmp_bitmap[3] = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->tmp_bitmap[0]); state_save_register_global_bitmap(machine, state->tmp_bitmap[1]); state_save_register_global_bitmap(machine, state->tmp_bitmap[2]); diff --git a/src/mame/video/bishi.c b/src/mame/video/bishi.c index 51e6a8a7cda..c55339c3216 100644 --- a/src/mame/video/bishi.c +++ b/src/mame/video/bishi.c @@ -29,7 +29,7 @@ VIDEO_START( bishi ) { bishi_state *state = (bishi_state *)machine->driver_data; - assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32); + assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32); k056832_set_layer_association(state->k056832, 0); diff --git a/src/mame/video/bking.c b/src/mame/video/bking.c index abd6fdc51f4..9d71b2c95a2 100644 --- a/src/mame/video/bking.c +++ b/src/mame/video/bking.c @@ -241,8 +241,8 @@ VIDEO_START( bking ) { buggychl_state *state = (buggychl_state *)machine->driver_data; state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - state->tmp_bitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmp_bitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmp_bitmap1 = machine->primary_screen->alloc_compatible_bitmap(); + state->tmp_bitmap2 = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->tmp_bitmap1); state_save_register_global_bitmap(machine, state->tmp_bitmap2); diff --git a/src/mame/video/blockade.c b/src/mame/video/blockade.c index 29988f23a59..a975c251844 100644 --- a/src/mame/video/blockade.c +++ b/src/mame/video/blockade.c @@ -9,7 +9,7 @@ WRITE8_HANDLER( blockade_videoram_w ) if (input_port_read(space->machine, "IN3") & 0x80) { - logerror("blockade_videoram_w: scanline %d\n", video_screen_get_vpos(space->machine->primary_screen)); + logerror("blockade_videoram_w: scanline %d\n", space->machine->primary_screen->vpos()); cpu_spinuntil_int(space->cpu); } } diff --git a/src/mame/video/blockout.c b/src/mame/video/blockout.c index 1fb2c1970e0..eeef6a534e1 100644 --- a/src/mame/video/blockout.c +++ b/src/mame/video/blockout.c @@ -66,7 +66,7 @@ VIDEO_START( blockout ) blockout_state *state = (blockout_state *)machine->driver_data; /* Allocate temporary bitmaps */ - state->tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->tmpbitmap); } @@ -75,9 +75,9 @@ static void update_pixels( running_machine *machine, int x, int y ) blockout_state *state = (blockout_state *)machine->driver_data; UINT16 front, back; int color; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - if (x < visarea->min_x || x > visarea->max_x || y < visarea->min_y || y > visarea->max_y) + if (x < visarea.min_x || x > visarea.max_x || y < visarea.min_y || y > visarea.max_y) return; front = state->videoram[y * 256 + x / 2]; diff --git a/src/mame/video/blstroid.c b/src/mame/video/blstroid.c index 76c33f00d7a..6f9c81b8b4d 100644 --- a/src/mame/video/blstroid.c +++ b/src/mame/video/blstroid.c @@ -105,9 +105,9 @@ static TIMER_CALLBACK( irq_on ) } -void blstroid_scanline_update(running_device *screen, int scanline) +void blstroid_scanline_update(screen_device &screen, int scanline) { - blstroid_state *state = (blstroid_state *)screen->machine->driver_data; + blstroid_state *state = (blstroid_state *)screen.machine->driver_data; int offset = (scanline / 8) * 64 + 40; /* check for interrupts */ @@ -125,13 +125,13 @@ void blstroid_scanline_update(running_device *screen, int scanline) /* set a timer to turn the interrupt on at HBLANK of the 7th scanline */ /* and another to turn it off one scanline later */ - width = video_screen_get_width(screen); - vpos = video_screen_get_vpos(screen); - period_on = video_screen_get_time_until_pos(screen, vpos + 7, width * 0.9); - period_off = video_screen_get_time_until_pos(screen, vpos + 8, width * 0.9); + width = screen.width(); + vpos = screen.vpos(); + period_on = screen.time_until_pos(vpos + 7, width * 0.9); + period_off = screen.time_until_pos(vpos + 8, width * 0.9); - timer_set(screen->machine, period_on, NULL, 0, irq_on); - timer_set(screen->machine, period_off, NULL, 0, irq_off); + timer_set(screen.machine, period_on, NULL, 0, irq_on); + timer_set(screen.machine, period_off, NULL, 0, irq_off); } } diff --git a/src/mame/video/boogwing.c b/src/mame/video/boogwing.c index 9914f01d09d..4e1ad358b8d 100644 --- a/src/mame/video/boogwing.c +++ b/src/mame/video/boogwing.c @@ -20,7 +20,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram_base[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram_base[offs + 2]; diff --git a/src/mame/video/btime.c b/src/mame/video/btime.c index e62b75a5e1d..71d336f02b2 100644 --- a/src/mame/video/btime.c +++ b/src/mame/video/btime.c @@ -129,7 +129,7 @@ VIDEO_START( bnj ) /* the background area is twice as wide as the screen */ int width = 256; int height = 256; - bitmap_format format = video_screen_get_format(machine->primary_screen); + bitmap_format format = machine->primary_screen->format(); state->background_bitmap = auto_bitmap_alloc(machine, 2 * width, height, format); state_save_register_global_bitmap(machine, state->background_bitmap); diff --git a/src/mame/video/btoads.c b/src/mame/video/btoads.c index d4b67e54981..959fad2bebb 100644 --- a/src/mame/video/btoads.c +++ b/src/mame/video/btoads.c @@ -86,9 +86,9 @@ WRITE16_HANDLER( btoads_display_control_w ) if (ACCESSING_BITS_8_15) { /* allow multiple changes during display */ - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); if (scanline > 0) - video_screen_update_partial(space->machine->primary_screen, scanline - 1); + space->machine->primary_screen->update_partial(scanline - 1); /* bit 15 controls which page is rendered and which page is displayed */ if (data & 0x8000) @@ -118,7 +118,7 @@ WRITE16_HANDLER( btoads_display_control_w ) WRITE16_HANDLER( btoads_scroll0_w ) { /* allow multiple changes during display */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* upper bits are Y scroll, lower bits are X scroll */ if (ACCESSING_BITS_8_15) @@ -131,7 +131,7 @@ WRITE16_HANDLER( btoads_scroll0_w ) WRITE16_HANDLER( btoads_scroll1_w ) { /* allow multiple changes during display */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* upper bits are Y scroll, lower bits are X scroll */ if (ACCESSING_BITS_8_15) @@ -343,7 +343,7 @@ void btoads_from_shiftreg(const address_space *space, UINT32 address, UINT16 *sh * *************************************/ -void btoads_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void btoads_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT32 fulladdr = ((params->rowaddr << 16) | params->coladdr) >> 4; UINT16 *bg0_base = &btoads_vram_bg0[(fulladdr + (yscroll0 << 10)) & 0x3fc00]; @@ -524,14 +524,14 @@ void btoads_scanline_update(running_device *screen, bitmap_t *bitmap, int scanli #if BT_DEBUG popmessage("screen_control = %02X", screen_control & 0x7f); - if (input_code_pressed(screen->machine, KEYCODE_X)) + if (input_code_pressed(screen.machine, KEYCODE_X)) { static int count = 0; char name[10]; FILE *f; int i; - while (input_code_pressed(screen->machine, KEYCODE_X)) ; + while (input_code_pressed(screen.machine, KEYCODE_X)) ; sprintf(name, "disp%d.log", count++); f = fopen(name, "w"); diff --git a/src/mame/video/buggychl.c b/src/mame/video/buggychl.c index f55cba518b7..a030641ecee 100644 --- a/src/mame/video/buggychl.c +++ b/src/mame/video/buggychl.c @@ -15,8 +15,8 @@ PALETTE_INIT( buggychl ) VIDEO_START( buggychl ) { buggychl_state *state = (buggychl_state *)machine->driver_data; - state->tmp_bitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tmp_bitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmp_bitmap1 = machine->primary_screen->alloc_compatible_bitmap(); + state->tmp_bitmap2 = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->tmp_bitmap1); state_save_register_global_bitmap(machine, state->tmp_bitmap2); diff --git a/src/mame/video/bwing.c b/src/mame/video/bwing.c index 83c3025df79..9fccd1cf99d 100644 --- a/src/mame/video/bwing.c +++ b/src/mame/video/bwing.c @@ -123,7 +123,7 @@ WRITE8_HANDLER( bwing_scrollreg_w ) state->srbank = data >> 6; #if BW_DEBUG - logerror("(%s)%04x: w=%02x a=%04x f=%d\n", space->cpu->tag, cpu_get_pc(space->cpu), data, 0x1b00 + offset, video_screen_get_frame_number(space->machine->primary_screen)); + logerror("(%s)%04x: w=%02x a=%04x f=%d\n", space->cpu->tag, cpu_get_pc(space->cpu), data, 0x1b00 + offset, space->machine->primary_screen->frame_number()); #endif break; } diff --git a/src/mame/video/carpolo.c b/src/mame/video/carpolo.c index 65bd44aaef4..41cd1f6c3ca 100644 --- a/src/mame/video/carpolo.c +++ b/src/mame/video/carpolo.c @@ -151,7 +151,7 @@ PALETTE_INIT( carpolo ) VIDEO_START( carpolo ) { - bitmap_format format = video_screen_get_format(machine->primary_screen); + bitmap_format format = machine->primary_screen->format(); sprite_sprite_collision_bitmap1 = auto_bitmap_alloc(machine, SPRITE_WIDTH*2, SPRITE_HEIGHT*2, format); sprite_sprite_collision_bitmap2 = auto_bitmap_alloc(machine, SPRITE_WIDTH*2, SPRITE_HEIGHT*2, format); diff --git a/src/mame/video/cave.c b/src/mame/video/cave.c index d9972daf205..eeb152f6efa 100644 --- a/src/mame/video/cave.c +++ b/src/mame/video/cave.c @@ -553,8 +553,8 @@ static void get_sprite_info_cave( running_machine *machine ) int glob_flipx = state->videoregs[0] & 0x8000; int glob_flipy = state->videoregs[1] & 0x8000; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); source = state->spriteram + ((state->spriteram_size / 2) / 2) * state->spriteram_bank; @@ -683,8 +683,8 @@ static void get_sprite_info_donpachi( running_machine *machine ) int glob_flipx = state->videoregs[0] & 0x8000; int glob_flipy = state->videoregs[1] & 0x8000; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); source = state->spriteram + ((state->spriteram_size / 2) / 2) * state->spriteram_bank; @@ -758,8 +758,8 @@ static void get_sprite_info_donpachi( running_machine *machine ) static void sprite_init_cave( running_machine *machine ) { cave_state *state = (cave_state *)machine->driver_data; - int screen_width = video_screen_get_width(machine->primary_screen); - int screen_height = video_screen_get_height(machine->primary_screen); + int screen_width = machine->primary_screen->width(); + int screen_height = machine->primary_screen->height(); if (state->spritetype[0] == 0 || state->spritetype[0] == 2) // most of the games { @@ -797,9 +797,9 @@ static void sprite_init_cave( running_machine *machine ) state_save_register_postload(machine, cave_sprite_postload, NULL); } -static void cave_sprite_check( running_device *screen, const rectangle *clip ) +static void cave_sprite_check( screen_device &screen, const rectangle *clip ) { - cave_state *state = (cave_state *)screen->machine->driver_data; + cave_state *state = (cave_state *)screen.machine->driver_data; { /* set clip */ int left = clip->min_x; @@ -819,7 +819,7 @@ static void cave_sprite_check( running_device *screen, const rectangle *clip ) int i[4] = {0,0,0,0}; int priority_check = 0; int spritetype = state->spritetype[1]; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); while (sprite < finish) { @@ -852,19 +852,19 @@ static void cave_sprite_check( running_device *screen, const rectangle *clip ) case CAVE_SPRITETYPE_ZOOM | CAVE_SPRITETYPE_ZBUF: state->sprite_draw = sprite_draw_cave_zbuf; - if (clip->min_y == visarea->min_y) + if (clip->min_y == visarea.min_y) { if(!(state->sprite_zbuf_baseval += MAX_SPRITE_NUM)) - bitmap_fill(state->sprite_zbuf, visarea, 0); + bitmap_fill(state->sprite_zbuf, &visarea, 0); } break; case CAVE_SPRITETYPE_ZBUF: state->sprite_draw = sprite_draw_donpachi_zbuf; - if (clip->min_y == visarea->min_y) + if (clip->min_y == visarea.min_y) { if(!(state->sprite_zbuf_baseval += MAX_SPRITE_NUM)) - bitmap_fill(state->sprite_zbuf,visarea,0); + bitmap_fill(state->sprite_zbuf,&visarea,0); } break; @@ -1703,7 +1703,7 @@ VIDEO_UPDATE( cave ) } #endif - cave_sprite_check(screen, cliprect); + cave_sprite_check(*screen, cliprect); bitmap_fill(bitmap, cliprect, state->background_color); diff --git a/src/mame/video/cbuster.c b/src/mame/video/cbuster.c index d81734d06a2..90246c166e6 100644 --- a/src/mame/video/cbuster.c +++ b/src/mame/video/cbuster.c @@ -62,7 +62,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect colour += 64; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; fx = y & 0x2000; diff --git a/src/mame/video/ccastles.c b/src/mame/video/ccastles.c index e7b9df3517b..f3ae47fc2ae 100644 --- a/src/mame/video/ccastles.c +++ b/src/mame/video/ccastles.c @@ -32,7 +32,7 @@ VIDEO_START( ccastles ) 3, resistances, state->bweights, 1000, 0); /* allocate a bitmap for drawing sprites */ - state->spritebitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->spritebitmap = machine->primary_screen->alloc_compatible_bitmap(); /* register for savestates */ state_save_register_global_array(machine, state->video_control); @@ -52,7 +52,7 @@ VIDEO_START( ccastles ) WRITE8_HANDLER( ccastles_hscroll_w ) { ccastles_state *state = (ccastles_state *)space->machine->driver_data; - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); state->hscroll = data; } diff --git a/src/mame/video/cchasm.c b/src/mame/video/cchasm.c index 476628eb4cb..1b1398931f0 100644 --- a/src/mame/video/cchasm.c +++ b/src/mame/video/cchasm.c @@ -122,10 +122,10 @@ WRITE16_HANDLER( cchasm_refresh_control_w ) VIDEO_START( cchasm ) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - xcenter=((visarea->max_x + visarea->min_x)/2) << 16; - ycenter=((visarea->max_y + visarea->min_y)/2) << 16; + xcenter=((visarea.max_x + visarea.min_x)/2) << 16; + ycenter=((visarea.max_y + visarea.min_y)/2) << 16; VIDEO_START_CALL(vector); } diff --git a/src/mame/video/changela.c b/src/mame/video/changela.c index 7ca3289796e..1b4e0cfe69a 100644 --- a/src/mame/video/changela.c +++ b/src/mame/video/changela.c @@ -24,13 +24,13 @@ VIDEO_START( changela ) state->memory_devices = auto_alloc_array(machine, UINT8, 4 * 0x800); /* 0 - not connected, 1,2,3 - RAMs*/ state->tree_ram = auto_alloc_array(machine, UINT8, 2 * 0x20); - state->obj0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->river_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tree0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->tree1_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->obj0_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + state->river_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + state->tree0_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + state->tree1_bitmap = machine->primary_screen->alloc_compatible_bitmap(); state->scanline_timer = timer_alloc(machine, changela_scanline_callback, NULL); - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 30, 0), 30); + timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(30), 30); state_save_register_global_pointer(machine, state->memory_devices, 4 * 0x800); state_save_register_global_pointer(machine, state->tree_ram, 2 * 0x20); @@ -719,7 +719,7 @@ static TIMER_CALLBACK( changela_scanline_callback ) sy++; if (sy > 256) sy = 30; - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, sy, 0), sy); + timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(sy), sy); } VIDEO_UPDATE( changela ) diff --git a/src/mame/video/cheekyms.c b/src/mame/video/cheekyms.c index a0d794ce5ea..da26c10cc9e 100644 --- a/src/mame/video/cheekyms.c +++ b/src/mame/video/cheekyms.c @@ -99,8 +99,8 @@ VIDEO_START( cheekyms ) cheekyms_state *state = (cheekyms_state *)machine->driver_data; int width, height; - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); state->bitmap_buffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); state->cm_tilemap = tilemap_create(machine, cheekyms_get_tile_info, tilemap_scan_rows, 8, 8, 32, 32); diff --git a/src/mame/video/cinemat.c b/src/mame/video/cinemat.c index 96f50cf5723..957d6f3349f 100644 --- a/src/mame/video/cinemat.c +++ b/src/mame/video/cinemat.c @@ -48,14 +48,14 @@ static UINT8 last_control; void cinemat_vector_callback(running_device *device, INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift) { - const rectangle *visarea = video_screen_get_visible_area(device->machine->primary_screen); + const rectangle &visarea = device->machine->primary_screen->visible_area(); int intensity = 0xff; /* adjust for slop */ - sx = sx - visarea->min_x; - ex = ex - visarea->min_x; - sy = sy - visarea->min_y; - ey = ey - visarea->min_y; + sx = sx - visarea.min_x; + ex = ex - visarea.min_x; + sy = sy - visarea.min_y; + ey = ey - visarea.min_y; /* point intensity is determined by the shift value */ if (sx == ex && sy == ey) diff --git a/src/mame/video/cloak.c b/src/mame/video/cloak.c index e667e9d8933..12868d3978e 100644 --- a/src/mame/video/cloak.c +++ b/src/mame/video/cloak.c @@ -103,7 +103,7 @@ static void set_current_bitmap_videoram_pointer(void) WRITE8_HANDLER( cloak_clearbmp_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); bitmap_videoram_selected = data & 0x01; set_current_bitmap_videoram_pointer(); diff --git a/src/mame/video/cloud9.c b/src/mame/video/cloud9.c index 329d278e633..d7afdf709c8 100644 --- a/src/mame/video/cloud9.c +++ b/src/mame/video/cloud9.c @@ -36,7 +36,7 @@ VIDEO_START( cloud9 ) 3, resistances, state->bweights, 1000, 0); /* allocate a bitmap for drawing sprites */ - state->spritebitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->spritebitmap = machine->primary_screen->alloc_compatible_bitmap(); /* register for savestates */ state_save_register_global_pointer(machine, state->videoram, 0x8000); diff --git a/src/mame/video/cninja.c b/src/mame/video/cninja.c index d5b3454289a..415c4b26702 100644 --- a/src/mame/video/cninja.c +++ b/src/mame/video/cninja.c @@ -48,7 +48,7 @@ static void cninja_draw_sprites( running_machine *machine, bitmap_t *bitmap, con y = buffered_spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) & 0x1f; @@ -141,7 +141,7 @@ static void cninjabl_draw_sprites( running_machine *machine, bitmap_t *bitmap, c } flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) & 0x1f; @@ -221,7 +221,7 @@ static void robocop2_draw_sprites( running_machine *machine, bitmap_t *bitmap, c y = buffered_spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) & 0x1f; @@ -326,7 +326,7 @@ static void mutantf_draw_sprites( running_machine *machine, bitmap_t *bitmap, co w = (spriteptr[offs + 2] & 0x0f00) >> 8; sy = spriteptr[offs]; - if ((sy & 0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if ((sy & 0x2000) && (machine->primary_screen->frame_number() & 1)) { offs += inc; continue; diff --git a/src/mame/video/contra.c b/src/mame/video/contra.c index 2021007bd52..0e7fefa787a 100644 --- a/src/mame/video/contra.c +++ b/src/mame/video/contra.c @@ -175,12 +175,12 @@ VIDEO_START( contra ) state->spriteram = auto_alloc_array(machine, UINT8, 0x800); state->spriteram_2 = auto_alloc_array(machine, UINT8, 0x800); - state->bg_clip = *video_screen_get_visible_area(machine->primary_screen); + state->bg_clip = machine->primary_screen->visible_area(); state->bg_clip.min_x += 40; state->fg_clip = state->bg_clip; - state->tx_clip = *video_screen_get_visible_area(machine->primary_screen); + state->tx_clip = machine->primary_screen->visible_area(); state->tx_clip.max_x = 39; state->tx_clip.min_x = 0; diff --git a/src/mame/video/cosmic.c b/src/mame/video/cosmic.c index b9d25c79374..9249b279da3 100644 --- a/src/mame/video/cosmic.c +++ b/src/mame/video/cosmic.c @@ -317,7 +317,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect } -static void cosmica_draw_starfield( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) +static void cosmica_draw_starfield( screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) { UINT8 y = 0; UINT8 map = 0; @@ -336,9 +336,9 @@ static void cosmica_draw_starfield( running_device *screen, bitmap_t *bitmap, co int hc, hb_; if (flip_screen_get(screen->machine)) - x1 = x - video_screen_get_frame_number(screen); + x1 = x - screen->frame_number(); else - x1 = x + video_screen_get_frame_number(screen); + x1 = x + screen->frame_number(); hc = (x1 >> 2) & 0x01; hb_ = (x >> 5) & 0x01; /* not a bug, this one is the real x */ @@ -424,10 +424,10 @@ static void devzone_draw_grid( running_machine *machine, bitmap_t *bitmap, const } -static void nomnlnd_draw_background( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) +static void nomnlnd_draw_background( screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) { UINT8 y = 0; - UINT8 water = video_screen_get_frame_number(screen); + UINT8 water = screen->frame_number(); UINT8 *PROM = memory_region(screen->machine, "user2"); /* all positioning is via logic gates: diff --git a/src/mame/video/cps1.c b/src/mame/video/cps1.c index 8b9c657a169..cdfb25b3df9 100644 --- a/src/mame/video/cps1.c +++ b/src/mame/video/cps1.c @@ -2591,7 +2591,7 @@ static void cps2_render_sprites( running_machine *machine, bitmap_t *bitmap, con -static void cps1_render_stars( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) +static void cps1_render_stars( screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) { cps_state *state = (cps_state *)screen->machine->driver_data; int offs; @@ -2622,7 +2622,7 @@ static void cps1_render_stars( running_device *screen, bitmap_t *bitmap, const r sy = 255 - sy; } - col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen) / 16 & 0x0f); + col = ((col & 0xe0) >> 1) + (screen->frame_number() / 16 & 0x0f); if (sx >= cliprect->min_x && sx <= cliprect->max_x && sy >= cliprect->min_y && sy <= cliprect->max_y) @@ -2648,7 +2648,7 @@ static void cps1_render_stars( running_device *screen, bitmap_t *bitmap, const r sy = 255 - sy; } - col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen) / 16 & 0x0f); + col = ((col & 0xe0) >> 1) + (screen->frame_number() / 16 & 0x0f); if (sx >= cliprect->min_x && sx <= cliprect->max_x && sy >= cliprect->min_y && sy <= cliprect->max_y) diff --git a/src/mame/video/crospang.c b/src/mame/video/crospang.c index 908316bd242..ebfd133b11d 100644 --- a/src/mame/video/crospang.c +++ b/src/mame/video/crospang.c @@ -156,7 +156,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = state->spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = state->spriteram[offs + 2]; diff --git a/src/mame/video/cvs.c b/src/mame/video/cvs.c index 788894821e1..5cb0634d7d8 100644 --- a/src/mame/video/cvs.c +++ b/src/mame/video/cvs.c @@ -169,9 +169,9 @@ VIDEO_START( cvs ) } /* create helper bitmaps */ - state->background_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->scrolled_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->background_bitmap = machine->primary_screen->alloc_compatible_bitmap(); + state->collision_background = machine->primary_screen->alloc_compatible_bitmap(); + state->scrolled_collision_background = machine->primary_screen->alloc_compatible_bitmap(); /* register save */ state_save_register_global_bitmap(machine, state->background_bitmap); diff --git a/src/mame/video/cyberbal.c b/src/mame/video/cyberbal.c index 66b63c470de..85eeb765f10 100644 --- a/src/mame/video/cyberbal.c +++ b/src/mame/video/cyberbal.c @@ -261,14 +261,14 @@ READ16_HANDLER( cyberbal_paletteram_1_r ) * *************************************/ -void cyberbal_scanline_update(running_device *screen, int scanline) +void cyberbal_scanline_update(screen_device &screen, int scanline) { - cyberbal_state *state = (cyberbal_state *)screen->machine->driver_data; + cyberbal_state *state = (cyberbal_state *)screen.machine->driver_data; int i; - running_device *update_screen; + screen_device *update_screen; /* loop over screens */ - for (i = 0, update_screen = video_screen_first(screen->machine); update_screen != NULL; i++, update_screen = video_screen_next(update_screen)) + for (i = 0, update_screen = screen_first(*screen.machine); update_screen != NULL; i++, update_screen = screen_next(update_screen)) { UINT16 *vram = i ? state->atarigen.alpha2 : state->atarigen.alpha; UINT16 *base = &vram[((scanline - 8) / 8) * 64 + 47]; @@ -285,7 +285,7 @@ void cyberbal_scanline_update(running_device *screen, int scanline) if (((base[3] >> 1) & 7) != state->playfield_palette_bank[i]) { if (scanline > 0) - video_screen_update_partial(update_screen, scanline - 1); + update_screen->update_partial(scanline - 1); state->playfield_palette_bank[i] = (base[3] >> 1) & 7; tilemap_set_palette_offset(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, state->playfield_palette_bank[i] << 8); } @@ -296,7 +296,7 @@ void cyberbal_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_xscroll[i]) { if (scanline > 0) - video_screen_update_partial(update_screen, scanline - 1); + update_screen->update_partial(scanline - 1); tilemap_set_scrollx(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_xscroll[i] = newscroll; } @@ -308,7 +308,7 @@ void cyberbal_scanline_update(running_device *screen, int scanline) if (newscroll != state->playfield_yscroll[i]) { if (scanline > 0) - video_screen_update_partial(update_screen, scanline - 1); + update_screen->update_partial(scanline - 1); tilemap_set_scrolly(i ? state->atarigen.playfield2_tilemap : state->atarigen.playfield_tilemap, 0, newscroll); state->playfield_yscroll[i] = newscroll; } @@ -318,7 +318,7 @@ void cyberbal_scanline_update(running_device *screen, int scanline) if (state->current_slip[i] != base[7]) { if (scanline > 0) - video_screen_update_partial(update_screen, scanline - 1); + update_screen->update_partial(scanline - 1); state->current_slip[i] = base[7]; } } @@ -333,34 +333,34 @@ void cyberbal_scanline_update(running_device *screen, int scanline) * *************************************/ -static void update_one_screen(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect) +static void update_one_screen(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect) { - cyberbal_state *state = (cyberbal_state *)screen->machine->driver_data; + cyberbal_state *state = (cyberbal_state *)screen.machine->driver_data; atarimo_rect_list rectlist; rectangle tempclip = *cliprect; bitmap_t *mobitmap; int x, y, r, mooffset, temp; - rectangle *visarea = (rectangle *)video_screen_get_visible_area(screen); + rectangle visarea = screen.visible_area(); /* for 2p games, the left screen is the main screen */ - running_device *left_screen = devtag_get_device(screen->machine, "lscreen"); + running_device *left_screen = devtag_get_device(screen.machine, "lscreen"); if (left_screen == NULL) - left_screen = devtag_get_device(screen->machine, "screen"); + left_screen = devtag_get_device(screen.machine, "screen"); /* draw the playfield */ - tilemap_draw(bitmap, cliprect, (screen == left_screen) ? state->atarigen.playfield_tilemap : state->atarigen.playfield2_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, (&screen == left_screen) ? state->atarigen.playfield_tilemap : state->atarigen.playfield2_tilemap, 0, 0); /* draw the MOs -- note some kludging to get this to work correctly for 2 screens */ mooffset = 0; tempclip.min_x -= mooffset; tempclip.max_x -= mooffset; - temp = visarea->max_x; + temp = visarea.max_x; if (temp > SCREEN_WIDTH) - visarea->max_x /= 2; - mobitmap = atarimo_render((screen == left_screen) ? 0 : 1, cliprect, &rectlist); + visarea.max_x /= 2; + mobitmap = atarimo_render((&screen == left_screen) ? 0 : 1, cliprect, &rectlist); tempclip.min_x += mooffset; tempclip.max_x += mooffset; - visarea->max_x = temp; + visarea.max_x = temp; /* draw and merge the MO */ for (r = 0; r < rectlist.numrects; r++, rectlist.rect++) @@ -381,12 +381,12 @@ static void update_one_screen(running_device *screen, bitmap_t *bitmap, const re } /* add the alpha on top */ - tilemap_draw(bitmap, cliprect, (screen == left_screen) ? state->atarigen.alpha_tilemap : state->atarigen.alpha2_tilemap, 0, 0); + tilemap_draw(bitmap, cliprect, (&screen == left_screen) ? state->atarigen.alpha_tilemap : state->atarigen.alpha2_tilemap, 0, 0); } VIDEO_UPDATE( cyberbal ) { - update_one_screen(screen, bitmap, cliprect); + update_one_screen(*screen, bitmap, cliprect); return 0; } diff --git a/src/mame/video/darkseal.c b/src/mame/video/darkseal.c index 331c5e52168..1ace551655c 100644 --- a/src/mame/video/darkseal.c +++ b/src/mame/video/darkseal.c @@ -179,7 +179,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta x = buffered_spriteram16[offs+2]; flash=y&0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) &0x1f; diff --git a/src/mame/video/dassault.c b/src/mame/video/dassault.c index 29e8f76a1fc..d88b4d325a2 100644 --- a/src/mame/video/dassault.c +++ b/src/mame/video/dassault.c @@ -49,7 +49,7 @@ static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rect y = spritebase[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) & 0x1f; if (y & 0x8000) diff --git a/src/mame/video/dc.c b/src/mame/video/dc.c index 405a3a7ba18..618fd18c85c 100644 --- a/src/mame/video/dc.c +++ b/src/mame/video/dc.c @@ -994,19 +994,19 @@ READ64_HANDLER( pvr_ta_r ) { UINT8 fieldnum,vsync,hsync,blank; - fieldnum = (video_screen_get_frame_number(space->machine->primary_screen) & 1) ? 1 : 0; + fieldnum = (space->machine->primary_screen->frame_number() & 1) ? 1 : 0; - vsync = video_screen_get_vblank(space->machine->primary_screen) ? 1 : 0; + vsync = space->machine->primary_screen->vblank() ? 1 : 0; if(spg_vsync_pol) { vsync^=1; } - hsync = video_screen_get_hblank(space->machine->primary_screen) ? 1 : 0; + hsync = space->machine->primary_screen->hblank() ? 1 : 0; if(spg_hsync_pol) { hsync^=1; } /* FIXME: following is just a wild guess */ - blank = (video_screen_get_vblank(space->machine->primary_screen) | video_screen_get_hblank(space->machine->primary_screen)) ? 0 : 1; + blank = (space->machine->primary_screen->vblank() | space->machine->primary_screen->hblank()) ? 0 : 1; if(spg_blank_pol) { blank^=1; } - pvrta_regs[reg] = (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (video_screen_get_vpos(space->machine->primary_screen) & 0x3ff); + pvrta_regs[reg] = (vsync << 13) | (hsync << 12) | (blank << 11) | (fieldnum << 10) | (space->machine->primary_screen->vpos() & 0x3ff); break; } case SPG_TRIGGER_POS: @@ -1258,8 +1258,8 @@ WRITE64_HANDLER( pvr_ta_w ) timer_adjust_oneshot(vbin_timer, attotime_never, 0); timer_adjust_oneshot(vbout_timer, attotime_never, 0); - timer_adjust_oneshot(vbin_timer, video_screen_get_time_until_pos(space->machine->primary_screen, spg_vblank_in_irq_line_num, 0), 0); - timer_adjust_oneshot(vbout_timer, video_screen_get_time_until_pos(space->machine->primary_screen, spg_vblank_out_irq_line_num, 0), 0); + timer_adjust_oneshot(vbin_timer, space->machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); + timer_adjust_oneshot(vbout_timer, space->machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); break; /* TODO: timer adjust for SPG_HBLANK_INT too */ case TA_LIST_CONT: @@ -1278,7 +1278,7 @@ WRITE64_HANDLER( pvr_ta_w ) case VO_STARTX: case VO_STARTY: { - rectangle visarea = *video_screen_get_visible_area(space->machine->primary_screen); + rectangle visarea = space->machine->primary_screen->visible_area(); /* FIXME: right visible area calculations aren't known yet*/ visarea.min_x = 0; visarea.max_x = ((spg_hbstart - spg_hbend - vo_horz_start_pos) <= 0x180 ? 320 : 640) - 1; @@ -1286,7 +1286,7 @@ WRITE64_HANDLER( pvr_ta_w ) visarea.max_y = ((spg_vbstart - spg_vbend - vo_vert_start_pos_f1) <= 0x100 ? 240 : 480) - 1; - video_screen_configure(space->machine->primary_screen, spg_hbstart, spg_vbstart, &visarea, video_screen_get_frame_period(space->machine->primary_screen).attoseconds ); + space->machine->primary_screen->configure(spg_hbstart, spg_vbstart, visarea, space->machine->primary_screen->frame_period().attoseconds ); } break; } @@ -2465,7 +2465,7 @@ static TIMER_CALLBACK(vbin) dc_sysctrl_regs[SB_ISTNRM] |= IST_VBL_IN; // V Blank-in interrupt dc_update_interrupt_status(machine); - timer_adjust_oneshot(vbin_timer, video_screen_get_time_until_pos(machine->primary_screen, spg_vblank_in_irq_line_num, 0), 0); + timer_adjust_oneshot(vbin_timer, machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); } static TIMER_CALLBACK(vbout) @@ -2473,7 +2473,7 @@ static TIMER_CALLBACK(vbout) dc_sysctrl_regs[SB_ISTNRM] |= IST_VBL_OUT; // V Blank-out interrupt dc_update_interrupt_status(machine); - timer_adjust_oneshot(vbout_timer, video_screen_get_time_until_pos(machine->primary_screen, spg_vblank_out_irq_line_num, 0), 0); + timer_adjust_oneshot(vbout_timer, machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); } static TIMER_CALLBACK(hbin) @@ -2503,7 +2503,7 @@ static TIMER_CALLBACK(hbin) next_y = spg_line_comp_val; } - timer_adjust_oneshot(hbin_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, spg_hblank_in_irq-1), 0); + timer_adjust_oneshot(hbin_timer, machine->primary_screen->time_until_pos(scanline, spg_hblank_in_irq-1), 0); } @@ -2566,13 +2566,13 @@ VIDEO_START(dc) computedilated(); vbout_timer = timer_alloc(machine, vbout, 0); - timer_adjust_oneshot(vbout_timer, video_screen_get_time_until_pos(machine->primary_screen, spg_vblank_out_irq_line_num, 0), 0); + timer_adjust_oneshot(vbout_timer, machine->primary_screen->time_until_pos(spg_vblank_out_irq_line_num), 0); vbin_timer = timer_alloc(machine, vbin, 0); - timer_adjust_oneshot(vbin_timer, video_screen_get_time_until_pos(machine->primary_screen, spg_vblank_in_irq_line_num, 0), 0); + timer_adjust_oneshot(vbin_timer, machine->primary_screen->time_until_pos(spg_vblank_in_irq_line_num), 0); hbin_timer = timer_alloc(machine, hbin, 0); - timer_adjust_oneshot(hbin_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, spg_hblank_in_irq-1), 0); + timer_adjust_oneshot(hbin_timer, machine->primary_screen->time_until_pos(0, spg_hblank_in_irq-1), 0); scanline = 0; next_y = 0; @@ -2605,7 +2605,7 @@ VIDEO_UPDATE(dc) ******************/ // static int useframebuffer=1; -// const rectangle *visarea = video_screen_get_visible_area(screen); +// const rectangle &visarea = screen->visible_area(); // int y,x; //printf("videoupdate\n"); diff --git a/src/mame/video/dcheese.c b/src/mame/video/dcheese.c index b5ad36aabf2..3f26c2c1f3d 100644 --- a/src/mame/video/dcheese.c +++ b/src/mame/video/dcheese.c @@ -63,9 +63,9 @@ static void update_scanline_irq( running_machine *machine ) effscan += state->blitter_vidparam[0x1e/2]; /* determine the time; if it's in this scanline, bump to the next frame */ - time = video_screen_get_time_until_pos(machine->primary_screen, effscan, 0); - if (attotime_compare(time, video_screen_get_scan_period(machine->primary_screen)) < 0) - time = attotime_add(time, video_screen_get_frame_period(machine->primary_screen)); + time = machine->primary_screen->time_until_pos(effscan); + if (attotime_compare(time, machine->primary_screen->scan_period()) < 0) + time = attotime_add(time, machine->primary_screen->frame_period()); timer_adjust_oneshot(state->blitter_timer, time, 0); } } @@ -95,7 +95,7 @@ VIDEO_START( dcheese ) dcheese_state *state = (dcheese_state *)machine->driver_data; /* the destination bitmap is not directly accessible to the CPU */ - state->dstbitmap = auto_bitmap_alloc(machine, DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, video_screen_get_format(machine->primary_screen)); + state->dstbitmap = auto_bitmap_alloc(machine, DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, machine->primary_screen->format()); /* create a timer */ state->blitter_timer = timer_alloc(machine, blitter_scanline_callback, NULL); @@ -151,7 +151,7 @@ static void do_clear( running_machine *machine ) memset(BITMAP_ADDR16(state->dstbitmap, y % DSTBITMAP_HEIGHT, 0), 0, DSTBITMAP_WIDTH * 2); /* signal an IRQ when done (timing is just a guess) */ - timer_set(machine, video_screen_get_scan_period(machine->primary_screen), NULL, 1, dcheese_signal_irq_callback); + timer_set(machine, machine->primary_screen->scan_period(), NULL, 1, dcheese_signal_irq_callback); } @@ -206,7 +206,7 @@ static void do_blit( running_machine *machine ) } /* signal an IRQ when done (timing is just a guess) */ - timer_set(machine, attotime_make(0, attotime_to_attoseconds(video_screen_get_scan_period(machine->primary_screen)) / 2), NULL, 2, dcheese_signal_irq_callback); + timer_set(machine, attotime_make(0, attotime_to_attoseconds(machine->primary_screen->scan_period()) / 2), NULL, 2, dcheese_signal_irq_callback); /* these extra parameters are written but they are always zero, so I don't know what they do */ if (state->blitter_xparam[8] != 0 || state->blitter_xparam[9] != 0 || state->blitter_xparam[10] != 0 || state->blitter_xparam[11] != 0 || diff --git a/src/mame/video/dday.c b/src/mame/video/dday.c index 322005ac20a..a61accc5b57 100644 --- a/src/mame/video/dday.c +++ b/src/mame/video/dday.c @@ -219,7 +219,7 @@ VIDEO_START( dday ) state->text_tilemap = tilemap_create(machine, get_text_tile_info, tilemap_scan_rows, 8, 8, 32, 32); state->sl_tilemap = tilemap_create(machine, get_sl_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - state->main_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->main_bitmap = machine->primary_screen->alloc_compatible_bitmap(); tilemap_set_transmask(state->bg_tilemap, 0, 0x00f0, 0xff0f); /* pens 0-3 have priority over the foreground layer */ tilemap_set_transparent_pen(state->fg_tilemap, 0); diff --git a/src/mame/video/dec0.c b/src/mame/video/dec0.c index 41a6e58a025..f5100a77b98 100644 --- a/src/mame/video/dec0.c +++ b/src/mame/video/dec0.c @@ -163,7 +163,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan if ((colour & pri_mask) != pri_val) continue; flash=x&0x800; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; fx = y & 0x2000; fy = y & 0x4000; diff --git a/src/mame/video/dec8.c b/src/mame/video/dec8.c index c5220d57496..c4326d253ef 100644 --- a/src/mame/video/dec8.c +++ b/src/mame/video/dec8.c @@ -326,7 +326,7 @@ static void draw_sprites2( running_machine* machine, bitmap_t *bitmap, const rec x = buffered_spriteram[offs + 5] + (buffered_spriteram[offs + 4] << 8); colour = ((x & 0xf000) >> 12); flash = x & 0x800; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; if (priority == 1 && (colour & 4)) continue; if (priority == 2 && !(colour & 4)) continue; diff --git a/src/mame/video/deco16ic.c b/src/mame/video/deco16ic.c index 14457c6f8db..fc6bc3ef7c5 100644 --- a/src/mame/video/deco16ic.c +++ b/src/mame/video/deco16ic.c @@ -169,7 +169,7 @@ UINT8 *deco16icvdp_get_vram( const device_config *device ) typedef struct _deco16ic_state deco16ic_state; struct _deco16ic_state { - running_device *screen; + screen_device *screen; UINT16 *pf1_data, *pf2_data; UINT16 *pf3_data, *pf4_data; @@ -208,17 +208,16 @@ struct _deco16ic_state INLINE deco16ic_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == DECO16IC); + assert(device->type() == DECO16IC); - return (deco16ic_state *)device->token; + return (deco16ic_state *)downcast(device)->token(); } INLINE const deco16ic_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == DECO16IC)); - return (const deco16ic_interface *) device->baseconfig().static_config; + assert((device->type() == DECO16IC)); + return (const deco16ic_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -805,8 +804,8 @@ WRITE32_DEVICE_HANDLER( deco16ic_pf4_data_dword_w ) void deco_allocate_sprite_bitmap(running_machine *machine) { /* Allow sprite bitmap to be used by Deco32 games as well */ - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); } @@ -1237,9 +1236,9 @@ static DEVICE_START( deco16ic ) const deco16ic_interface *intf = get_interface(device); int width, height; - deco16ic->screen = devtag_get_device(device->machine, intf->screen); - width = video_screen_get_width(deco16ic->screen); - height = video_screen_get_height(deco16ic->screen); + deco16ic->screen = device->machine->device(intf->screen); + width = deco16ic->screen->width(); + height = deco16ic->screen->height(); deco16ic->sprite_priority_bitmap = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED8); @@ -1366,7 +1365,6 @@ DEVICE_GET_INFO( deco16ic ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(deco16ic_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(deco16ic); break; diff --git a/src/mame/video/deco16ic.h b/src/mame/video/deco16ic.h index ed46ceb02bd..9510e4d5e22 100644 --- a/src/mame/video/deco16ic.h +++ b/src/mame/video/deco16ic.h @@ -6,6 +6,10 @@ **************************************************************************/ +#pragma once +#ifndef __DECO16IC_H__ +#define __DECO16IC_H__ + #include "devcb.h" @@ -30,19 +34,13 @@ struct _deco16ic_interface deco16_bank_cb bank_cb0, bank_cb1, bank_cb2, bank_cb3; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( deco16ic ); +DECLARE_LEGACY_DEVICE(DECO16IC, deco16ic); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define DECO16IC DEVICE_GET_INFO_NAME( deco16ic ) - #define MDRV_DECO16IC_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, DECO16IC, 0) \ MDRV_DEVICE_CONFIG(_interface) @@ -122,3 +120,5 @@ void deco16ic_pf34_set_gfxbank(running_device *device, int small, int big); /* used by stoneage */ void deco16ic_set_scrolldx(running_device *device, int tmap, int size, int dx, int dx_if_flipped); + +#endif diff --git a/src/mame/video/deco32.c b/src/mame/video/deco32.c index 029bece71a0..807211c76de 100644 --- a/src/mame/video/deco32.c +++ b/src/mame/video/deco32.c @@ -322,7 +322,7 @@ static void captaven_draw_sprites(running_machine* machine, bitmap_t *bitmap, co sx = spritedata[offs+1]; - if ((sy&0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if ((sy&0x2000) && (machine->primary_screen->frame_number() & 1)) continue; colour = (spritedata[offs+2] >>0) & 0x1f; @@ -389,7 +389,7 @@ static void fghthist_draw_sprites(running_machine* machine, bitmap_t *bitmap, co y = spritedata[offs]; flash=y&0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spritedata[offs+2]; colour = (x >>9) & colourmask; @@ -503,7 +503,7 @@ static void nslasher_draw_sprites(running_machine* machine, bitmap_t *bitmap, co y = spritedata[offs]; flash=y&0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; //trans=TRANSPARENCY_PEN; x = spritedata[offs+2]; @@ -1071,8 +1071,8 @@ VIDEO_START( fghthist ) dirty_palette = auto_alloc_array(machine, UINT8, 4096); /* Allow sprite bitmap */ - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); tilemap_set_transparent_pen(pf1_tilemap,0); @@ -1139,8 +1139,8 @@ VIDEO_START( nslasher ) pf1a_tilemap =0; dirty_palette = auto_alloc_array(machine, UINT8, 4096); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); sprite0_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); sprite1_mix_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); tilemap_alpha_bitmap=auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 ); diff --git a/src/mame/video/deco_mlc.c b/src/mame/video/deco_mlc.c index 99a4dd21a4e..13938dc22d5 100644 --- a/src/mame/video/deco_mlc.c +++ b/src/mame/video/deco_mlc.c @@ -250,7 +250,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectan { if ((mlc_spriteram[offs+0]&0x8000)==0) continue; - if ((mlc_spriteram[offs+1]&0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if ((mlc_spriteram[offs+1]&0x2000) && (machine->primary_screen->frame_number() & 1)) continue; /* diff --git a/src/mame/video/decocass.c b/src/mame/video/decocass.c index 5ebc6907f63..22b91f0bf04 100644 --- a/src/mame/video/decocass.c +++ b/src/mame/video/decocass.c @@ -499,10 +499,10 @@ VIDEO_START( decocass ) tilemap_set_transparent_pen(state->bg_tilemap_r, 0); tilemap_set_transparent_pen(state->fg_tilemap, 0); - state->bg_tilemap_l_clip = *video_screen_get_visible_area(machine->primary_screen); + state->bg_tilemap_l_clip = machine->primary_screen->visible_area(); state->bg_tilemap_l_clip.max_y = 256 / 2 - 1; - state->bg_tilemap_r_clip = *video_screen_get_visible_area(machine->primary_screen); + state->bg_tilemap_r_clip = machine->primary_screen->visible_area(); state->bg_tilemap_r_clip.min_y = 256 / 2; /* background videroam bits D0-D3 are shared with the tileram */ diff --git a/src/mame/video/dietgo.c b/src/mame/video/dietgo.c index c9b82d4f6d3..beb633067d9 100644 --- a/src/mame/video/dietgo.c +++ b/src/mame/video/dietgo.c @@ -19,7 +19,7 @@ static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/dkong.c b/src/mame/video/dkong.c index d43d24c6e39..4dd2057ce8a 100644 --- a/src/mame/video/dkong.c +++ b/src/mame/video/dkong.c @@ -843,15 +843,15 @@ static void radarscp_scanline(running_machine *machine, int scanline) int x,y,offset; UINT16 *pixel; static int counter=0; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); y = scanline; radarscp_step(machine, y); - if (y <= visarea->min_y || y > visarea->max_y) + if (y <= visarea.min_y || y > visarea.max_y) counter = 0; offset = (state->flip ^ state->rflip_sig) ? 0x000 : 0x400; x = 0; - while (x < video_screen_get_width(machine->primary_screen)) + while (x < machine->primary_screen->width()) { pixel = BITMAP_ADDR16(state->bg_bits, y, x); if ((counter < table_len) && (x == 4 * (table[counter|offset] & 0x7f))) @@ -881,11 +881,11 @@ static TIMER_CALLBACK( scanline_callback ) radarscp_scanline(machine, scanline); /* update any video up to the current scanline */ - video_screen_update_now(machine->primary_screen); + machine->primary_screen->update_now(); scanline = (scanline+1) % VTOTAL; /* come back at the next appropriate scanline */ - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } static void check_palette(running_machine *machine) @@ -945,12 +945,12 @@ VIDEO_START( dkong ) VIDEO_START_CALL(dkong_base); state->scanline_timer = timer_alloc(machine, scanline_callback, NULL); - timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(state->scanline_timer, machine->primary_screen->time_until_pos(0), 0); switch (state->hardware_type) { case HARDWARE_TRS02: - state->bg_bits = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->bg_bits = machine->primary_screen->alloc_compatible_bitmap(); state->gfx3 = memory_region(machine, "gfx3"); state->gfx3_len = memory_region_length(machine, "gfx3"); /* fall through */ @@ -963,7 +963,7 @@ VIDEO_START( dkong ) state->bg_tilemap = tilemap_create(machine, radarscp1_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); tilemap_set_scrolldx(state->bg_tilemap, 0, 128); - state->bg_bits = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->bg_bits = machine->primary_screen->alloc_compatible_bitmap(); state->gfx4 = memory_region(machine, "gfx4"); state->gfx3 = memory_region(machine, "gfx3"); state->gfx3_len = memory_region_length(machine, "gfx3"); diff --git a/src/mame/video/dogfgt.c b/src/mame/video/dogfgt.c index 1e723042f31..46b8558f117 100644 --- a/src/mame/video/dogfgt.c +++ b/src/mame/video/dogfgt.c @@ -73,7 +73,7 @@ VIDEO_START( dogfgt ) state->bitmapram = auto_alloc_array(machine, UINT8, BITMAPRAM_SIZE); state_save_register_global_pointer(machine, state->bitmapram, BITMAPRAM_SIZE); - state->pixbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->pixbitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->pixbitmap); } diff --git a/src/mame/video/eprom.c b/src/mame/video/eprom.c index 66bedbe29ce..80d07630214 100644 --- a/src/mame/video/eprom.c +++ b/src/mame/video/eprom.c @@ -210,9 +210,9 @@ VIDEO_START( guts ) * *************************************/ -void eprom_scanline_update(running_device *screen, int scanline) +void eprom_scanline_update(screen_device &screen, int scanline) { - eprom_state *state = (eprom_state *)screen->machine->driver_data; + eprom_state *state = (eprom_state *)screen.machine->driver_data; /* update the playfield */ if (scanline == 0) diff --git a/src/mame/video/equites.c b/src/mame/video/equites.c index 19f960cde6a..06055fa0831 100644 --- a/src/mame/video/equites.c +++ b/src/mame/video/equites.c @@ -130,7 +130,7 @@ VIDEO_START( equites ) VIDEO_START( splndrbt ) { equites_state *state = (equites_state *)machine->driver_data; - assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_INDEXED16); + assert(machine->primary_screen->format() == BITMAP_FORMAT_INDEXED16); state->fg_videoram = auto_alloc_array(machine, UINT8, 0x800); state_save_register_global_pointer(machine, state->fg_videoram, 0x800); diff --git a/src/mame/video/esd16.c b/src/mame/video/esd16.c index e28f2895a3c..fcdd8ea6ff0 100644 --- a/src/mame/video/esd16.c +++ b/src/mame/video/esd16.c @@ -188,8 +188,8 @@ static void esd16_draw_sprites( running_machine *machine, bitmap_t *bitmap, cons esd16_state *state = (esd16_state *)machine->driver_data; int offs; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); for (offs = state->spriteram_size / 2 - 8 / 2; offs >= 0 ; offs -= 8 / 2) { @@ -210,7 +210,7 @@ static void esd16_draw_sprites( running_machine *machine, bitmap_t *bitmap, cons int pri_mask; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; if (sx & 0x8000) @@ -252,8 +252,8 @@ static void hedpanic_draw_sprites( running_machine *machine, bitmap_t *bitmap, c esd16_state *state = (esd16_state *)machine->driver_data; int offs; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); for (offs = state->spriteram_size / 2 - 8 / 2; offs >= 0 ; offs -= 8 / 2) { @@ -274,7 +274,7 @@ static void hedpanic_draw_sprites( running_machine *machine, bitmap_t *bitmap, c int pri_mask; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; if (sx & 0x8000) diff --git a/src/mame/video/esripsys.c b/src/mame/video/esripsys.c index 6dbcb27074d..1ea7ffa1feb 100644 --- a/src/mame/video/esripsys.c +++ b/src/mame/video/esripsys.c @@ -53,7 +53,7 @@ INTERRUPT_GEN( esripsys_vblank_irq ) static TIMER_CALLBACK( hblank_start_callback ) { - int v = video_screen_get_vpos(machine->primary_screen); + int v = machine->primary_screen->vpos(); if (video_firq) { @@ -73,19 +73,19 @@ static TIMER_CALLBACK( hblank_start_callback ) v = 0; /* Set end of HBLANK timer */ - timer_adjust_oneshot(hblank_end_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_END), v); + timer_adjust_oneshot(hblank_end_timer, machine->primary_screen->time_until_pos(v, ESRIPSYS_HBLANK_END), v); esripsys_hblank = 0; } static TIMER_CALLBACK( hblank_end_callback ) { - int v = video_screen_get_vpos(machine->primary_screen); + int v = machine->primary_screen->vpos(); if (v > 0) - video_screen_update_partial(machine->primary_screen, v - 1); + machine->primary_screen->update_partial(v - 1); esripsys__12sel ^= 1; - timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, v, ESRIPSYS_HBLANK_START), 0); + timer_adjust_oneshot(hblank_start_timer, machine->primary_screen->time_until_pos(v, ESRIPSYS_HBLANK_START), 0); esripsys_hblank = 1; } @@ -106,7 +106,7 @@ VIDEO_START( esripsys ) /* Create and initialise the HBLANK timers */ hblank_start_timer = timer_alloc(machine, hblank_start_callback, NULL); hblank_end_timer = timer_alloc(machine, hblank_end_callback, NULL); - timer_adjust_oneshot(hblank_start_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, ESRIPSYS_HBLANK_START), 0); + timer_adjust_oneshot(hblank_start_timer, machine->primary_screen->time_until_pos(0, ESRIPSYS_HBLANK_START), 0); /* Create the sprite scaling table */ scale_table = auto_alloc_array(machine, UINT8, 64 * 64); diff --git a/src/mame/video/exerion.c b/src/mame/video/exerion.c index e52082a6eba..a44ff4785a9 100644 --- a/src/mame/video/exerion.c +++ b/src/mame/video/exerion.c @@ -206,9 +206,9 @@ WRITE8_HANDLER( exerion_videoreg_w ) WRITE8_HANDLER( exerion_video_latch_w ) { exerion_state *state = (exerion_state *)space->machine->driver_data; - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); if (scanline > 0) - video_screen_update_partial(space->machine->primary_screen, scanline - 1); + space->machine->primary_screen->update_partial(scanline - 1); state->background_latches[offset] = data; } @@ -218,13 +218,13 @@ READ8_HANDLER( exerion_video_timing_r ) /* bit 0 is the SNMI signal, which is the negated value of H6, if H7=1 & H8=1 & VBLANK=0, otherwise 1 */ /* bit 1 is VBLANK */ - UINT16 hcounter = video_screen_get_hpos(space->machine->primary_screen) + EXERION_HCOUNT_START; + UINT16 hcounter = space->machine->primary_screen->hpos() + EXERION_HCOUNT_START; UINT8 snmi = 1; - if (((hcounter & 0x180) == 0x180) && !video_screen_get_vblank(space->machine->primary_screen)) + if (((hcounter & 0x180) == 0x180) && !space->machine->primary_screen->vblank()) snmi = !((hcounter >> 6) & 0x01); - return (video_screen_get_vblank(space->machine->primary_screen) << 1) | snmi; + return (space->machine->primary_screen->vblank() << 1) | snmi; } diff --git a/src/mame/video/exidy.c b/src/mame/video/exidy.c index 307aecb8e80..1a5e43296da 100644 --- a/src/mame/video/exidy.c +++ b/src/mame/video/exidy.c @@ -54,9 +54,9 @@ void exidy_video_config(UINT8 _collision_mask, UINT8 _collision_invert, int _is_ VIDEO_START( exidy ) { - bitmap_format format = video_screen_get_format(machine->primary_screen); + bitmap_format format = machine->primary_screen->format(); - background_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + background_bitmap = machine->primary_screen->alloc_compatible_bitmap(); motion_object_1_vid = auto_bitmap_alloc(machine, 16, 16, format); motion_object_2_vid = auto_bitmap_alloc(machine, 16, 16, format); motion_object_2_clip = auto_bitmap_alloc(machine, 16, 16, format); @@ -361,7 +361,7 @@ static void check_collision(running_machine *machine) /* if we got one, trigger an interrupt */ if ((current_collision_mask & collision_mask) && (count++ < 128)) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, org_1_x + sx, org_1_y + sy), NULL, current_collision_mask, collision_irq_callback); + timer_set(machine, machine->primary_screen->time_until_pos(org_1_x + sx, org_1_y + sy), NULL, current_collision_mask, collision_irq_callback); } if (*BITMAP_ADDR16(motion_object_2_vid, sy, sx) != 0xff) @@ -369,7 +369,7 @@ static void check_collision(running_machine *machine) /* check for background collision (M2CHAR) */ if (*BITMAP_ADDR16(background_bitmap, org_2_y + sy, org_2_x + sx) != 0) if ((collision_mask & 0x08) && (count++ < 128)) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, org_2_x + sx, org_2_y + sy), NULL, 0x08, collision_irq_callback); + timer_set(machine, machine->primary_screen->time_until_pos(org_2_x + sx, org_2_y + sy), NULL, 0x08, collision_irq_callback); } } } diff --git a/src/mame/video/exidy440.c b/src/mame/video/exidy440.c index 0a9cffd125b..ba3c43d7a1f 100644 --- a/src/mame/video/exidy440.c +++ b/src/mame/video/exidy440.c @@ -169,7 +169,7 @@ READ8_HANDLER( exidy440_vertical_pos_r ) * caused by collision or beam, ORed together with CHRCLK, * which probably goes off once per scanline; for now, we just * always return the current scanline */ - result = video_screen_get_vpos(space->machine->primary_screen); + result = space->machine->primary_screen->vpos(); return (result < 255) ? result : 255; } @@ -183,7 +183,7 @@ READ8_HANDLER( exidy440_vertical_pos_r ) WRITE8_HANDLER( exidy440_spriteram_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); space->machine->generic.spriteram.u8[offset] = data; } @@ -306,7 +306,7 @@ static TIMER_CALLBACK( collide_firq_callback ) * *************************************/ -static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, +static void draw_sprites(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect, int scroll_offset, int check_collision) { int i; @@ -316,7 +316,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectang int count = 0; /* draw the sprite images, checking for collisions along the way */ - UINT8 *sprite = screen->machine->generic.spriteram.u8 + (SPRITE_COUNT - 1) * 4; + UINT8 *sprite = screen.machine->generic.spriteram.u8 + (SPRITE_COUNT - 1) * 4; for (i = 0; i < SPRITE_COUNT; i++, sprite -= 4) { @@ -374,7 +374,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectang /* check the collisions bit */ if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - timer_set(screen->machine, video_screen_get_time_until_pos(screen, yoffs, currx), NULL, currx, collide_firq_callback); + timer_set(screen.machine, screen.time_until_pos(yoffs, currx), NULL, currx, collide_firq_callback); } currx++; @@ -387,7 +387,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectang /* check the collisions bit */ if (check_collision && (palette[2 * pen] & 0x80) && (count++ < 128)) - timer_set(screen->machine, video_screen_get_time_until_pos(screen, yoffs, currx), NULL, currx, collide_firq_callback); + timer_set(screen.machine, screen.time_until_pos(yoffs, currx), NULL, currx, collide_firq_callback); } currx++; } @@ -406,7 +406,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectang * *************************************/ -static void update_screen(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, +static void update_screen(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect, int scroll_offset, int check_collision) { int y, sy; @@ -438,10 +438,10 @@ static void update_screen(running_device *screen, bitmap_t *bitmap, const rectan static VIDEO_UPDATE( exidy440 ) { /* redraw the screen */ - update_screen(screen, bitmap, cliprect, 0, TRUE); + update_screen(*screen, bitmap, cliprect, 0, TRUE); /* generate an interrupt once/frame for the beam */ - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen->visible_area().max_y) { int i; @@ -454,8 +454,8 @@ static VIDEO_UPDATE( exidy440 ) From this, it appears that they are expecting to get beams over a 12 scanline period, and trying to pick roughly the middle one. This is how it is implemented. */ - attoseconds_t increment = attotime_to_attoseconds(video_screen_get_scan_period(screen)); - attotime time = attotime_sub(video_screen_get_time_until_pos(screen, beamy, beamx), attotime_make(0, increment * 6)); + attoseconds_t increment = attotime_to_attoseconds(screen->scan_period()); + attotime time = attotime_sub(screen->time_until_pos(beamy, beamx), attotime_make(0, increment * 6)); for (i = 0; i <= 12; i++) { timer_set(screen->machine, time, NULL, beamx, beam_firq_callback); @@ -470,7 +470,7 @@ static VIDEO_UPDATE( exidy440 ) static VIDEO_UPDATE( topsecex ) { /* redraw the screen */ - update_screen(screen, bitmap, cliprect, *topsecex_yscroll, FALSE); + update_screen(*screen, bitmap, cliprect, *topsecex_yscroll, FALSE); return 0; } diff --git a/src/mame/video/exterm.c b/src/mame/video/exterm.c index f9d3154549f..b13a53c2209 100644 --- a/src/mame/video/exterm.c +++ b/src/mame/video/exterm.c @@ -67,7 +67,7 @@ void exterm_from_shiftreg_slave(const address_space *space, UINT32 address, UINT * *************************************/ -void exterm_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void exterm_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *bgsrc = &exterm_master_videoram[(params->rowaddr << 8) & 0xff00]; UINT16 *fgsrc = NULL; @@ -78,7 +78,7 @@ void exterm_scanline_update(running_device *screen, bitmap_t *bitmap, int scanli int x; /* get parameters for the slave CPU */ - tms34010_get_display_params(devtag_get_device(screen->machine, "slave"), &fgparams); + tms34010_get_display_params(devtag_get_device(screen.machine, "slave"), &fgparams); /* compute info about the slave vram */ if (fgparams.enabled && scanline >= fgparams.veblnk && scanline < fgparams.vsblnk && fgparams.heblnk < fgparams.hsblnk) diff --git a/src/mame/video/fantland.c b/src/mame/video/fantland.c index 1170abdf8fa..a162fd42de5 100644 --- a/src/mame/video/fantland.c +++ b/src/mame/video/fantland.c @@ -70,8 +70,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan *ram2 = indx_ram; // current sprite pointer in indx_ram // wheelrun is the only game with a smaller visible area - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - int special = (visarea->max_y - visarea->min_y + 1) < 0x100; + const rectangle &visarea = machine->primary_screen->visible_area(); + int special = (visarea.max_y - visarea.min_y + 1) < 0x100; for ( ; ram < indx_ram; ram += 8,ram2++) { diff --git a/src/mame/video/fastlane.c b/src/mame/video/fastlane.c index 156fc3e4aef..b0654ffe141 100644 --- a/src/mame/video/fastlane.c +++ b/src/mame/video/fastlane.c @@ -119,10 +119,10 @@ VIDEO_START( fastlane ) tilemap_set_scroll_rows(state->layer0, 32); - state->clip0 = *video_screen_get_visible_area(machine->primary_screen); + state->clip0 = machine->primary_screen->visible_area(); state->clip0.min_x += 40; - state->clip1 = *video_screen_get_visible_area(machine->primary_screen); + state->clip1 = machine->primary_screen->visible_area(); state->clip1.max_x = 39; state->clip1.min_x = 0; } diff --git a/src/mame/video/fgoal.c b/src/mame/video/fgoal.c index 180f32cf6ce..3e82c8b25b0 100644 --- a/src/mame/video/fgoal.c +++ b/src/mame/video/fgoal.c @@ -32,8 +32,8 @@ WRITE8_HANDLER( fgoal_xpos_w ) VIDEO_START( fgoal ) { fgoal_state *state = (fgoal_state *)machine->driver_data; - state->fgbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->bgbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->fgbitmap = machine->primary_screen->alloc_compatible_bitmap(); + state->bgbitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->fgbitmap); state_save_register_global_bitmap(machine, state->bgbitmap); diff --git a/src/mame/video/finalizr.c b/src/mame/video/finalizr.c index c8510dff7bc..478eb5cc52a 100644 --- a/src/mame/video/finalizr.c +++ b/src/mame/video/finalizr.c @@ -213,12 +213,12 @@ VIDEO_UPDATE( finalizr ) } { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); rectangle clip = *cliprect; /* draw top status region */ - clip.min_x = visarea->min_x; - clip.max_x = visarea->min_x + 31; + clip.min_x = visarea.min_x; + clip.max_x = visarea.min_x + 31; tilemap_set_scrolldx(state->fg_tilemap, 0,-32); tilemap_draw(bitmap, &clip, state->fg_tilemap, 0, 0); } diff --git a/src/mame/video/firetrk.c b/src/mame/video/firetrk.c index 181c312c619..38b8c52fddc 100644 --- a/src/mame/video/firetrk.c +++ b/src/mame/video/firetrk.c @@ -234,8 +234,8 @@ static TILE_GET_INFO( montecar_get_tile_info2 ) VIDEO_START( firetrk ) { - helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper1 = machine->primary_screen->alloc_compatible_bitmap(); + helper2 = machine->primary_screen->alloc_compatible_bitmap(); tilemap1 = tilemap_create(machine, firetrk_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16); tilemap2 = tilemap_create(machine, firetrk_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16); @@ -244,8 +244,8 @@ VIDEO_START( firetrk ) VIDEO_START( superbug ) { - helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper1 = machine->primary_screen->alloc_compatible_bitmap(); + helper2 = machine->primary_screen->alloc_compatible_bitmap(); tilemap1 = tilemap_create(machine, superbug_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16); tilemap2 = tilemap_create(machine, superbug_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16); @@ -254,8 +254,8 @@ VIDEO_START( superbug ) VIDEO_START( montecar ) { - helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper1 = machine->primary_screen->alloc_compatible_bitmap(); + helper2 = machine->primary_screen->alloc_compatible_bitmap(); tilemap1 = tilemap_create(machine, montecar_get_tile_info1, tilemap_scan_rows, 16, 16, 16, 16); tilemap2 = tilemap_create(machine, montecar_get_tile_info2, tilemap_scan_rows, 16, 16, 16, 16); @@ -376,7 +376,7 @@ VIDEO_UPDATE( firetrk ) draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 296, 0x10, 0x10); draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x10, 8, 0x10, 0x10); - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen->visible_area().max_y) { tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0); @@ -409,7 +409,7 @@ VIDEO_UPDATE( superbug ) draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 296, 0x10, 0x10); draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x10, 8, 0x10, 0x10); - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen->visible_area().max_y) { tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0); @@ -439,7 +439,7 @@ VIDEO_UPDATE( montecar ) draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x00, 24, 0x20, 0x08); draw_text(bitmap, cliprect, screen->machine->gfx, firetrk_alpha_num_ram + 0x20, 16, 0x20, 0x08); - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen->visible_area().max_y) { tilemap_draw(helper1, &playfield_window, tilemap2, 0, 0); diff --git a/src/mame/video/flkatck.c b/src/mame/video/flkatck.c index ae477ac9bbe..05bdab42313 100644 --- a/src/mame/video/flkatck.c +++ b/src/mame/video/flkatck.c @@ -136,14 +136,14 @@ VIDEO_UPDATE( flkatck ) { flkatck_state *state = (flkatck_state *)screen->machine->driver_data; rectangle clip[2]; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); if (state->flipscreen) { - clip[0] = *visarea; + clip[0] = visarea; clip[0].max_x -= 40; - clip[1] = *visarea; + clip[1] = visarea; clip[1].min_x = clip[1].max_x - 40; tilemap_set_scrollx(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 0) - 56 ); @@ -152,10 +152,10 @@ VIDEO_UPDATE( flkatck ) } else { - clip[0] = *visarea; + clip[0] = visarea; clip[0].min_x += 40; - clip[1] = *visarea; + clip[1] = visarea; clip[1].max_x = 39; clip[1].min_x = 0; diff --git a/src/mame/video/fromance.c b/src/mame/video/fromance.c index fdbbb86a1aa..b3d7b20a8b8 100644 --- a/src/mame/video/fromance.c +++ b/src/mame/video/fromance.c @@ -266,7 +266,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen ) fromance_state *state = (fromance_state *)machine->driver_data; cpu_set_input_line(state->subcpu, 0, HOLD_LINE); if (param != 0) - timer_adjust_periodic(state->crtc_timer, attotime_div(video_screen_get_frame_period(machine->primary_screen), param), 0, attotime_div(video_screen_get_frame_period(machine->primary_screen), param)); + timer_adjust_periodic(state->crtc_timer, attotime_div(machine->primary_screen->frame_period(), param), 0, attotime_div(machine->primary_screen->frame_period(), param)); } @@ -279,7 +279,7 @@ WRITE8_HANDLER( fromance_crtc_data_w ) { /* only register we know about.... */ case 0x0b: - timer_adjust_oneshot(state->crtc_timer, video_screen_get_time_until_vblank_start(space->machine->primary_screen), (data > 0x80) ? 2 : 1); + timer_adjust_oneshot(state->crtc_timer, space->machine->primary_screen->time_until_vblank_start(), (data > 0x80) ? 2 : 1); break; default: @@ -303,11 +303,11 @@ WRITE8_HANDLER( fromance_crtc_register_w ) * *************************************/ -static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int draw_priority ) +static void draw_sprites( screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect, int draw_priority ) { - fromance_state *state = (fromance_state *)screen->machine->driver_data; + fromance_state *state = (fromance_state *)screen.machine->driver_data; static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); UINT8 *spriteram = state->spriteram; int offs; @@ -341,16 +341,16 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan yzoom = 16 - zoomtable[yzoom] / 8; /* wrap around */ - if (x > visarea->max_x) + if (x > visarea.max_x) x -= 0x200; - if (y > visarea->max_y) + if (y > visarea.max_y) y -= 0x200; /* flip ? */ if (state->flipscreen) { - y = visarea->max_y - y - 16 * ytiles - 4; - x = visarea->max_x - x - 16 * xtiles - 24; + y = visarea.max_y - y - 16 * ytiles - 4; + x = visarea.max_x - x - 16 * xtiles - 24; xflip=!xflip; yflip=!yflip; } @@ -361,10 +361,10 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan for (yt = 0; yt < ytiles; yt++) for (xt = 0; xt < xtiles; xt++, code++) if (!zoomed) - drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 0, 0, + drawgfx_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 0, 0, x + xt * 16, y + yt * 16, 15); else - drawgfxzoom_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 0, 0, + drawgfxzoom_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 0, 0, x + xt * xzoom, y + yt * yzoom, 0x1000 * xzoom, 0x1000 * yzoom, 15); } @@ -375,10 +375,10 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan for (yt = 0; yt < ytiles; yt++) for (xt = 0; xt < xtiles; xt++, code++) if (!zoomed) - drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 1, 0, + drawgfx_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 1, 0, x + (xtiles - 1 - xt) * 16, y + yt * 16, 15); else - drawgfxzoom_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 1, 0, + drawgfxzoom_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 1, 0, x + (xtiles - 1 - xt) * xzoom, y + yt * yzoom, 0x1000 * xzoom, 0x1000 * yzoom, 15); } @@ -389,10 +389,10 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan for (yt = 0; yt < ytiles; yt++) for (xt = 0; xt < xtiles; xt++, code++) if (!zoomed) - drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 0, 1, + drawgfx_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 0, 1, x + xt * 16, y + (ytiles - 1 - yt) * 16, 15); else - drawgfxzoom_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 0, 1, + drawgfxzoom_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 0, 1, x + xt * xzoom, y + (ytiles - 1 - yt) * yzoom, 0x1000 * xzoom, 0x1000 * yzoom, 15); } @@ -403,10 +403,10 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan for (yt = 0; yt < ytiles; yt++) for (xt = 0; xt < xtiles; xt++, code++) if (!zoomed) - drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 1, 1, + drawgfx_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 1, 1, x + (xtiles - 1 - xt) * 16, y + (ytiles - 1 - yt) * 16, 15); else - drawgfxzoom_transpen(bitmap, cliprect, screen->machine->gfx[2], code, color, 1, 1, + drawgfxzoom_transpen(bitmap, cliprect, screen.machine->gfx[2], code, color, 1, 1, x + (xtiles - 1 - xt) * xzoom, y + (ytiles - 1 - yt) * yzoom, 0x1000 * xzoom, 0x1000 * yzoom, 15); } @@ -448,7 +448,7 @@ VIDEO_UPDATE( pipedrm ) tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0); - draw_sprites(screen, bitmap, cliprect, 0); - draw_sprites(screen, bitmap, cliprect, 1); + draw_sprites(*screen, bitmap, cliprect, 0); + draw_sprites(*screen, bitmap, cliprect, 1); return 0; } diff --git a/src/mame/video/funkyjet.c b/src/mame/video/funkyjet.c index a67a8915f84..7c6912f4705 100644 --- a/src/mame/video/funkyjet.c +++ b/src/mame/video/funkyjet.c @@ -24,7 +24,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/fuukifg2.c b/src/mame/video/fuukifg2.c index 5b15a127370..6f0dda66740 100644 --- a/src/mame/video/fuukifg2.c +++ b/src/mame/video/fuukifg2.c @@ -132,16 +132,16 @@ VIDEO_START( fuuki16 ) ***************************************************************************/ -static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_sprites( screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect ) { - fuuki16_state *state = (fuuki16_state *)screen->machine->driver_data; + fuuki16_state *state = (fuuki16_state *)screen.machine->driver_data; int offs; - const gfx_element *gfx = screen->machine->gfx[0]; - bitmap_t *priority_bitmap = screen->machine->priority_bitmap; - const rectangle *visarea = video_screen_get_visible_area(screen); + const gfx_element *gfx = screen.machine->gfx[0]; + bitmap_t *priority_bitmap = screen.machine->priority_bitmap; + const rectangle &visarea = screen.visible_area(); UINT16 *spriteram16 = state->spriteram; - int max_x = visarea->max_x + 1; - int max_y = visarea->max_y + 1; + int max_x = visarea.max_x + 1; + int max_y = visarea.max_y + 1; /* Draw them backwards, for pdrawgfx */ for ( offs = (state->spriteram_size - 8) / 2; offs >=0; offs -= 8 / 2 ) @@ -179,7 +179,7 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan sx = (sx & 0x1ff) - (sx & 0x200); sy = (sy & 0x1ff) - (sy & 0x200); - if (flip_screen_get(screen->machine)) + if (flip_screen_get(screen.machine)) { flipx = !flipx; sx = max_x - sx - xnum * 16; flipy = !flipy; sy = max_y - sy - ynum * 16; @@ -216,7 +216,7 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan #ifdef MAME_DEBUG #if 0 -if (input_code_pressed(screen->machine, KEYCODE_X)) +if (input_code_pressed(screen.machine, KEYCODE_X)) { /* Display some info on each sprite */ char buf[40]; sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); @@ -341,7 +341,7 @@ VIDEO_UPDATE( fuuki16 ) fuuki16_draw_layer(screen->machine, bitmap, cliprect, tm_middle, 0, 2); fuuki16_draw_layer(screen->machine, bitmap, cliprect, tm_front, 0, 4); - draw_sprites(screen, bitmap, cliprect); + draw_sprites(*screen, bitmap, cliprect); return 0; } diff --git a/src/mame/video/fuukifg3.c b/src/mame/video/fuukifg3.c index a813770974b..85bb93f9640 100644 --- a/src/mame/video/fuukifg3.c +++ b/src/mame/video/fuukifg3.c @@ -149,15 +149,15 @@ VIDEO_START( fuuki32 ) ***************************************************************************/ -static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_sprites( screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect ) { - fuuki32_state *state = (fuuki32_state *)screen->machine->driver_data; + fuuki32_state *state = (fuuki32_state *)screen.machine->driver_data; int offs; - const gfx_element *gfx = screen->machine->gfx[0]; - bitmap_t *priority_bitmap = screen->machine->priority_bitmap; - const rectangle *visarea = video_screen_get_visible_area(screen); - int max_x = visarea->max_x + 1; - int max_y = visarea->max_y + 1; + const gfx_element *gfx = screen.machine->gfx[0]; + bitmap_t *priority_bitmap = screen.machine->priority_bitmap; + const rectangle &visarea = screen.visible_area(); + int max_x = visarea.max_x + 1; + int max_y = visarea.max_y + 1; UINT32 *src = state->buf_spriteram2; /* Use spriteram buffered by 2 frames, need palette buffered by one frame? */ @@ -204,7 +204,7 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan sx = (sx & 0x1ff) - (sx & 0x200); sy = (sy & 0x1ff) - (sy & 0x200); - if (flip_screen_get(screen->machine)) + if (flip_screen_get(screen.machine)) { flipx = !flipx; sx = max_x - sx - xnum * 16; flipy = !flipy; sy = max_y - sy - ynum * 16; @@ -217,10 +217,10 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan else { ystart = 0; yend = ynum; yinc = +1; } #if 0 - if(!( (input_code_pressed(screen->machine, KEYCODE_V) && (((attr >> 6)&3) == 0)) - || (input_code_pressed(screen->machine, KEYCODE_B) && (((attr >> 6)&3) == 1)) - || (input_code_pressed(screen->machine, KEYCODE_N) && (((attr >> 6)&3) == 2)) - || (input_code_pressed(screen->machine, KEYCODE_M) && (((attr >> 6)&3) == 3)) + if(!( (input_code_pressed(screen.machine, KEYCODE_V) && (((attr >> 6)&3) == 0)) + || (input_code_pressed(screen.machine, KEYCODE_B) && (((attr >> 6)&3) == 1)) + || (input_code_pressed(screen.machine, KEYCODE_N) && (((attr >> 6)&3) == 2)) + || (input_code_pressed(screen.machine, KEYCODE_M) && (((attr >> 6)&3) == 3)) )) #endif @@ -249,7 +249,7 @@ static void draw_sprites( running_device *screen, bitmap_t *bitmap, const rectan #ifdef MAME_DEBUG #if 0 -if (input_code_pressed(screen->machine, KEYCODE_X)) +if (input_code_pressed(screen.machine, KEYCODE_X)) { /* Display some info on each sprite */ char buf[40]; sprintf(buf, "%Xx%X %X",xnum,ynum,(attr>>6)&3); @@ -369,7 +369,7 @@ VIDEO_UPDATE( fuuki32 ) fuuki32_draw_layer(screen->machine, bitmap, cliprect, tm_middle, 0, 2); fuuki32_draw_layer(screen->machine, bitmap, cliprect, tm_front, 0, 4); - draw_sprites(screen, bitmap, cliprect); + draw_sprites(*screen, bitmap, cliprect); return 0; } diff --git a/src/mame/video/gaelco2.c b/src/mame/video/gaelco2.c index 7d250a462cc..21c9208050d 100644 --- a/src/mame/video/gaelco2.c +++ b/src/mame/video/gaelco2.c @@ -339,7 +339,7 @@ VIDEO_START( gaelco2_dual ) ***************************************************************************/ -static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int mask, int xoffs) +static void draw_sprites(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int mask, int xoffs) { UINT16 *buffered_spriteram16 = screen->machine->generic.buffered_spriteram.u16; int j, x, y, ex, ey, px, py; @@ -350,7 +350,7 @@ static void draw_sprites(running_device *screen, bitmap_t *bitmap, const rectang int end_offset = start_offset + 0x1000; /* sprite offset is based on the visible area */ - int spr_x_adjust = (video_screen_get_visible_area(screen)->max_x - 320 + 1) - (511 - 320 - 1) - ((gaelco2_vregs[0] >> 4) & 0x01) + xoffs; + int spr_x_adjust = (screen->visible_area().max_x - 320 + 1) - (511 - 320 - 1) - ((gaelco2_vregs[0] >> 4) & 0x01) + xoffs; for (j = start_offset; j < end_offset; j += 8){ int data = buffered_spriteram16[(j/2) + 0]; diff --git a/src/mame/video/gaelco3d.c b/src/mame/video/gaelco3d.c index 4bd91df2d5a..a3b284656e8 100644 --- a/src/mame/video/gaelco3d.c +++ b/src/mame/video/gaelco3d.c @@ -78,10 +78,10 @@ VIDEO_START( gaelco3d ) poly = poly_alloc(machine, 2000, sizeof(poly_extra_data), 0); add_exit_callback(machine, gaelco3d_exit); - screenbits = video_screen_auto_bitmap_alloc(machine->primary_screen); + screenbits = machine->primary_screen->alloc_compatible_bitmap(); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); zbuffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); palette = auto_alloc_array(machine, rgb_t, 32768); @@ -129,10 +129,10 @@ VIDEO_START( gaelco3d ) (repeat these two for each additional point in the fan) */ -static void render_poly(running_device *screen, UINT32 *polydata) +static void render_poly(screen_device &screen, UINT32 *polydata) { - float midx = video_screen_get_width(screen) / 2; - float midy = video_screen_get_height(screen) / 2; + float midx = screen.width() / 2; + float midy = screen.height() / 2; float z0 = convert_tms3203x_fp_to_float(polydata[0]); float voz_dy = convert_tms3203x_fp_to_float(polydata[1]) * 256.0f; float voz_dx = convert_tms3203x_fp_to_float(polydata[2]) * 256.0f; @@ -200,19 +200,19 @@ static void render_poly(running_device *screen, UINT32 *polydata) /* if we have a valid number of verts, render them */ if (vertnum >= 3) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); /* special case: no Z buffering and no perspective correction */ if (color != 0x7f00 && z0 < 0 && ooz_dx == 0 && ooz_dy == 0) - poly_render_triangle_fan(poly, screenbits, visarea, render_noz_noperspective, 0, vertnum, &vert[0]); + poly_render_triangle_fan(poly, screenbits, &visarea, render_noz_noperspective, 0, vertnum, &vert[0]); /* general case: non-alpha blended */ else if (color != 0x7f00) - poly_render_triangle_fan(poly, screenbits, visarea, render_normal, 0, vertnum, &vert[0]); + poly_render_triangle_fan(poly, screenbits, &visarea, render_normal, 0, vertnum, &vert[0]); /* color 0x7f seems to be hard-coded as a 50% alpha blend */ else - poly_render_triangle_fan(poly, screenbits, visarea, render_alphablend, 0, vertnum, &vert[0]); + poly_render_triangle_fan(poly, screenbits, &visarea, render_alphablend, 0, vertnum, &vert[0]); polygons += vertnum - 2; } @@ -371,15 +371,15 @@ static void render_alphablend(void *destbase, INT32 scanline, const poly_extent * *************************************/ -void gaelco3d_render(running_device *screen) +void gaelco3d_render(screen_device &screen) { /* wait for any queued stuff to complete */ poly_wait(poly, "Time to render"); #if DISPLAY_STATS { - int scan = video_screen_get_vpos(screen); - popmessage("Polys = %4d Timeleft = %3d", polygons, (lastscan < scan) ? (scan - lastscan) : (scan + (lastscan - video_screen_get_visible_area(screen)->max_y))); + int scan = screen.vpos(); + popmessage("Polys = %4d Timeleft = %3d", polygons, (lastscan < scan) ? (scan - lastscan) : (scan + (lastscan - screen.visible_area().max_y))); } #endif @@ -408,14 +408,14 @@ WRITE32_HANDLER( gaelco3d_render_w ) { if (polydata_count >= 18 && (polydata_count % 2) == 1 && IS_POLYEND(polydata_buffer[polydata_count - 2])) { - render_poly(space->machine->primary_screen, &polydata_buffer[0]); + render_poly(*space->machine->primary_screen, &polydata_buffer[0]); polydata_count = 0; } video_changed = TRUE; } #if DISPLAY_STATS - lastscan = video_screen_get_vpos(space->machine->primary_screen); + lastscan = space->machine->primary_screen->vpos(); #endif } diff --git a/src/mame/video/gaiden.c b/src/mame/video/gaiden.c index 03465c3278a..d749794c3e2 100644 --- a/src/mame/video/gaiden.c +++ b/src/mame/video/gaiden.c @@ -75,8 +75,8 @@ static TILE_GET_INFO( get_tx_tile_info ) VIDEO_START( gaiden ) { gaiden_state *state = (gaiden_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ state->tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -98,8 +98,8 @@ VIDEO_START( mastninj ) { gaiden_state *state = (gaiden_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ state->tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -123,8 +123,8 @@ VIDEO_START( mastninj ) VIDEO_START( raiga ) { gaiden_state *state = (gaiden_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ state->tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); diff --git a/src/mame/video/galastrm.c b/src/mame/video/galastrm.c index b652bd062ff..d8aee464492 100644 --- a/src/mame/video/galastrm.c +++ b/src/mame/video/galastrm.c @@ -45,8 +45,8 @@ VIDEO_START( galastrm ) { spritelist = auto_alloc_array(machine, struct tempsprite, 0x4000); - tmpbitmaps = video_screen_auto_bitmap_alloc(machine->primary_screen); - polybitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + tmpbitmaps = machine->primary_screen->alloc_compatible_bitmap(); + polybitmap = machine->primary_screen->alloc_compatible_bitmap(); poly = poly_alloc(machine, 16, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS); add_exit_callback(machine, galastrm_exit); @@ -460,8 +460,8 @@ VIDEO_UPDATE( galastrm ) clip.min_x = 0; clip.min_y = 0; - clip.max_x = video_screen_get_width(screen) -1; - clip.max_y = video_screen_get_height(screen) -1; + clip.max_x = screen->width() -1; + clip.max_y = screen->height() -1; tc0100scn_tilemap_update(tc0100scn); tc0480scp_tilemap_update(tc0480scp); diff --git a/src/mame/video/galaxian.c b/src/mame/video/galaxian.c index 936ca4e9730..10ddcdfc3a7 100644 --- a/src/mame/video/galaxian.c +++ b/src/mame/video/galaxian.c @@ -544,7 +544,7 @@ static TILE_GET_INFO( bg_get_tile_info ) WRITE8_HANDLER( galaxian_videoram_w ) { /* update any video up to the current scanline */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* store the data and mark the corresponding tile dirty */ space->machine->generic.videoram.u8[offset] = data; @@ -555,7 +555,7 @@ WRITE8_HANDLER( galaxian_videoram_w ) WRITE8_HANDLER( galaxian_objram_w ) { /* update any video up to the current scanline */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* store the data */ space->machine->generic.spriteram.u8[offset] = data; @@ -704,7 +704,7 @@ WRITE8_HANDLER( galaxian_flip_screen_x_w ) { if (flipscreen_x != (data & 0x01)) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* when the direction changes, we count a different number of clocks */ /* per frame, so we need to reset the origin of the stars to the current */ @@ -720,7 +720,7 @@ WRITE8_HANDLER( galaxian_flip_screen_y_w ) { if (flipscreen_y != (data & 0x01)) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); flipscreen_y = data & 0x01; tilemap_set_flip(bg_tilemap, (flipscreen_x ? TILEMAP_FLIPX : 0) | (flipscreen_y ? TILEMAP_FLIPY : 0)); } @@ -743,14 +743,14 @@ WRITE8_HANDLER( galaxian_flip_screen_xy_w ) WRITE8_HANDLER( galaxian_stars_enable_w ) { if ((stars_enabled ^ data) & 0x01) - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); if (!stars_enabled && (data & 0x01)) { /* on the rising edge of this, the CLR on the shift registers is released */ /* this resets the "origin" of this frame to 0 minus the number of clocks */ /* we have counted so far */ - star_rng_origin = STAR_RNG_PERIOD - (video_screen_get_vpos(space->machine->primary_screen) * 512 + video_screen_get_hpos(space->machine->primary_screen)); - star_rng_origin_frame = video_screen_get_frame_number(space->machine->primary_screen); + star_rng_origin = STAR_RNG_PERIOD - (space->machine->primary_screen->vpos() * 512 + space->machine->primary_screen->hpos()); + star_rng_origin_frame = space->machine->primary_screen->frame_number(); } stars_enabled = data & 0x01; } @@ -758,28 +758,28 @@ WRITE8_HANDLER( galaxian_stars_enable_w ) WRITE8_HANDLER( scramble_background_enable_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); background_enable = data & 0x01; } WRITE8_HANDLER( scramble_background_red_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); background_red = data & 0x01; } WRITE8_HANDLER( scramble_background_green_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); background_green = data & 0x01; } WRITE8_HANDLER( scramble_background_blue_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); background_blue = data & 0x01; } @@ -795,7 +795,7 @@ WRITE8_HANDLER( galaxian_gfxbank_w ) { if (gfxbank[offset] != data) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); gfxbank[offset] = data; tilemap_mark_all_tiles_dirty(bg_tilemap); } @@ -847,7 +847,7 @@ static void stars_init(running_machine *machine) static void stars_update_origin(running_machine *machine) { - int curframe = video_screen_get_frame_number(machine->primary_screen); + int curframe = machine->primary_screen->frame_number(); /* only update on a different frame */ if (curframe != star_rng_origin_frame) diff --git a/src/mame/video/galaxold.c b/src/mame/video/galaxold.c index 758ed9eae57..1f4af4d41c9 100644 --- a/src/mame/video/galaxold.c +++ b/src/mame/video/galaxold.c @@ -954,7 +954,7 @@ VIDEO_START( dambustr ) draw_bullets = dambustr_draw_bullets; /* allocate the temporary bitmap for the background priority */ - dambustr_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + dambustr_tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); /* make a copy of the tilemap to emulate background priority */ dambustr_videoram2 = auto_alloc_array(machine, UINT8, 0x0400); @@ -1754,7 +1754,7 @@ static TIMER_CALLBACK( stars_scroll_callback ) static void start_stars_scroll_timer(running_machine *machine) { - timer_adjust_periodic(stars_scroll_timer, video_screen_get_frame_period(machine->primary_screen), 0, video_screen_get_frame_period(machine->primary_screen)); + timer_adjust_periodic(stars_scroll_timer, machine->primary_screen->frame_period(), 0, machine->primary_screen->frame_period()); } diff --git a/src/mame/video/galpanic.c b/src/mame/video/galpanic.c index 637e46bed76..5df8d47ce51 100644 --- a/src/mame/video/galpanic.c +++ b/src/mame/video/galpanic.c @@ -8,8 +8,8 @@ static bitmap_t *sprites_bitmap; VIDEO_START( galpanic ) { - machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + machine->generic.tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); + sprites_bitmap = machine->primary_screen->alloc_compatible_bitmap(); } PALETTE_INIT( galpanic ) diff --git a/src/mame/video/galspnbl.c b/src/mame/video/galspnbl.c index 79cc042d058..7f1980149af 100644 --- a/src/mame/video/galspnbl.c +++ b/src/mame/video/galspnbl.c @@ -52,7 +52,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect int col, row; attr = spriteram[offs]; - if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (video_screen_get_frame_number(machine->primary_screen) & 1)) + if ((attr & 0x0004) && ((attr & 0x0040) == 0 || (machine->primary_screen->frame_number() & 1)) // && ((attr & 0x0030) >> 4) == priority) && ((attr & 0x0020) >> 5) == priority) { diff --git a/src/mame/video/gameplan.c b/src/mame/video/gameplan.c index d7155a1bbbf..db190a88230 100644 --- a/src/mame/video/gameplan.c +++ b/src/mame/video/gameplan.c @@ -272,9 +272,9 @@ static TIMER_CALLBACK( via_0_ca1_timer_callback ) via_ca1_w(state->via_0, param); if (param) - timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(machine->primary_screen, VBSTART, 0), 0); + timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBSTART), 0); else - timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(machine->primary_screen, VBEND, 0), 1); + timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBEND), 1); } @@ -326,7 +326,7 @@ static VIDEO_START( trvquest ) static VIDEO_RESET( gameplan ) { gameplan_state *state = (gameplan_state *)machine->driver_data; - timer_adjust_oneshot(state->via_0_ca1_timer, video_screen_get_time_until_pos(machine->primary_screen, VBSTART, 0), 0); + timer_adjust_oneshot(state->via_0_ca1_timer, machine->primary_screen->time_until_pos(VBSTART), 0); } diff --git a/src/mame/video/gaplus.c b/src/mame/video/gaplus.c index 8e9245b77f3..755fce93893 100644 --- a/src/mame/video/gaplus.c +++ b/src/mame/video/gaplus.c @@ -147,8 +147,8 @@ static void starfield_init(running_machine *machine) int x,y; int set = 0; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); total_stars = 0; @@ -239,8 +239,8 @@ static void starfield_render(running_machine *machine, bitmap_t *bitmap) { int i; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* check if we're running */ if ( ( gaplus_starfield_control[0] & 1 ) == 0 ) @@ -339,8 +339,8 @@ VIDEO_EOF( gaplus ) /* update starfields */ { int i; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* check if we're running */ if ( ( gaplus_starfield_control[0] & 1 ) == 0 ) diff --git a/src/mame/video/gauntlet.c b/src/mame/video/gauntlet.c index 61af29c7254..511f3a1ac08 100644 --- a/src/mame/video/gauntlet.c +++ b/src/mame/video/gauntlet.c @@ -127,7 +127,7 @@ WRITE16_HANDLER( gauntlet_xscroll_w ) /* if something changed, force a partial update */ if (*state->atarigen.xscroll != oldxscroll) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* adjust the scrolls */ tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, *state->atarigen.xscroll); @@ -152,7 +152,7 @@ WRITE16_HANDLER( gauntlet_yscroll_w ) /* if something changed, force a partial update */ if (*state->atarigen.yscroll != oldyscroll) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* if the bank changed, mark all tiles dirty */ if (state->playfield_tile_bank != (*state->atarigen.yscroll & 3)) diff --git a/src/mame/video/genesis.c b/src/mame/video/genesis.c index 20ae25731d3..8ba53ba084c 100644 --- a/src/mame/video/genesis.c +++ b/src/mame/video/genesis.c @@ -68,7 +68,7 @@ static void drawline_sprite(int line, UINT16 *bmap, int priority, UINT8 *spriteb UINT8 genesis_vdp_regs[32]; /* VDP registers */ /* LOCAL */ -static running_device *genesis_screen; +static screen_device *genesis_screen; static UINT8 * vdp_vram; /* VDP video RAM */ static UINT8 * vdp_vsram; /* VDP vertical scroll RAM */ @@ -119,7 +119,7 @@ static UINT8 window_width; /* window width */ ******************************************************************************/ -static void start_genesis_vdp(running_device *screen) +static void start_genesis_vdp(screen_device *screen) { static const UINT8 vdp_init[24] = { @@ -273,8 +273,8 @@ READ16_HANDLER( genesis_vdp_r ) case 0x06: case 0x07: { - int xpos = video_screen_get_hpos(genesis_screen); - int ypos = video_screen_get_vpos(genesis_screen); + int xpos = genesis_screen->hpos(); + int ypos = genesis_screen->vpos(); /* adjust for the weird counting rules */ if (xpos > 0xe9) xpos -= (342 - 0x100); @@ -398,7 +398,7 @@ static void vdp_data_w(running_machine *machine, int data) /* if the hscroll RAM is changing, force an update */ if (vdp_address >= vdp_hscrollbase && vdp_address < vdp_hscrollbase + vdp_hscrollsize) - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* write to VRAM */ if (vdp_address & 1) @@ -417,7 +417,7 @@ static void vdp_data_w(running_machine *machine, int data) case 0x05: /* VSRAM write */ /* vscroll RAM is changing, force an update */ - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* write to VSRAM */ if (vdp_address & 1) @@ -479,11 +479,11 @@ static int vdp_control_r(running_machine *machine) vdp_cmdpart = 0; /* set the VBLANK bit */ - if (video_screen_get_vblank(machine->primary_screen)) + if (machine->primary_screen->vblank()) status |= 0x0008; /* set the HBLANK bit */ - if (video_screen_get_hblank(machine->primary_screen)) + if (machine->primary_screen->hblank()) status |= 0x0004; return (status); @@ -497,7 +497,7 @@ static void vdp_control_w(const address_space *space, int data) { /* if 10xxxxxx xxxxxxxx this is a register setting command */ if ((data & 0xc000) == 0x8000) - vdp_register_w(space->machine, data, video_screen_get_vblank(space->machine->primary_screen)); + vdp_register_w(space->machine, data, space->machine->primary_screen->vblank()); /* otherwise this is the First part of a mode setting command */ else @@ -531,7 +531,7 @@ static void vdp_register_w(running_machine *machine, int data, int vblank) /* these are mostly important writes; force an update if they written */ if (is_important[regnum]) - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* For quite a few of the registers its a good idea to set a couple of variable based upon the writes here */ @@ -594,13 +594,13 @@ static void vdp_register_w(running_machine *machine, int data, int vblank) break; } { - int height = video_screen_get_height(genesis_screen); - rectangle visarea = *video_screen_get_visible_area(genesis_screen); - attoseconds_t refresh = video_screen_get_frame_period(genesis_screen).attoseconds; + int height = genesis_screen->height(); + rectangle visarea = genesis_screen->visible_area(); + attoseconds_t refresh = genesis_screen->frame_period().attoseconds; /* this gets called from the init! */ visarea.max_x = scrwidth*8-1; - video_screen_configure(genesis_screen, scrwidth*8, height, &visarea, refresh); + genesis_screen->configure(scrwidth*8, height, visarea, refresh); } break; diff --git a/src/mame/video/glass.c b/src/mame/video/glass.c index 955d670a610..754cfa31bb9 100644 --- a/src/mame/video/glass.c +++ b/src/mame/video/glass.c @@ -132,7 +132,7 @@ VIDEO_START( glass ) glass_state *state = (glass_state *)machine->driver_data; state->pant[0] = tilemap_create(machine, get_tile_info_glass_screen0, tilemap_scan_rows, 16, 16, 32, 32); state->pant[1] = tilemap_create(machine, get_tile_info_glass_screen1, tilemap_scan_rows, 16, 16, 32, 32); - state->screen_bitmap = auto_bitmap_alloc (machine, 320, 200, video_screen_get_format(machine->primary_screen)); + state->screen_bitmap = auto_bitmap_alloc (machine, 320, 200, machine->primary_screen->format()); state_save_register_global_bitmap(machine, state->screen_bitmap); diff --git a/src/mame/video/gomoku.c b/src/mame/video/gomoku.c index 40156ca5c36..24391eaa074 100644 --- a/src/mame/video/gomoku.c +++ b/src/mame/video/gomoku.c @@ -120,7 +120,7 @@ VIDEO_START( gomoku ) int bgdata; int color; - gomoku_bg_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + gomoku_bg_bitmap = machine->primary_screen->alloc_compatible_bitmap(); fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32, 32); diff --git a/src/mame/video/gottlieb.c b/src/mame/video/gottlieb.c index 433d736aee1..dd5cb8c28f6 100644 --- a/src/mame/video/gottlieb.c +++ b/src/mame/video/gottlieb.c @@ -60,7 +60,7 @@ WRITE8_HANDLER( gottlieb_video_control_w ) { /* bit 0 controls foreground/background priority */ if (background_priority != (data & 0x01)) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); background_priority = data & 0x01; /* bit 1 controls horizonal flip screen */ diff --git a/src/mame/video/grchamp.c b/src/mame/video/grchamp.c index 9a0aea8b338..b2f571bf5b8 100644 --- a/src/mame/video/grchamp.c +++ b/src/mame/video/grchamp.c @@ -107,7 +107,7 @@ VIDEO_START( grchamp ) { grchamp_state *state = (grchamp_state *)machine->driver_data; - state->work_bitmap = auto_bitmap_alloc(machine,32,32,video_screen_get_format(machine->primary_screen)); + state->work_bitmap = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format()); /* allocate tilemaps for each of the three sections */ state->text_tilemap = tilemap_create(machine, get_text_tile_info, tilemap_scan_rows, 8,8, 32,32); @@ -121,7 +121,7 @@ static int collision_check(running_machine *machine, grchamp_state *state, bitma { int bgcolor = machine->pens[0]; int sprite_transp = machine->pens[0x24]; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle *visarea = machine->primary_screen->visible_area(); int y0 = 240 - state->cpu0_out[3]; int x0 = 256 - state->cpu0_out[2]; int x,y,sx,sy; diff --git a/src/mame/video/gridlee.c b/src/mame/video/gridlee.c index 0ecd34ed678..d69488154e7 100644 --- a/src/mame/video/gridlee.c +++ b/src/mame/video/gridlee.c @@ -133,7 +133,7 @@ WRITE8_HANDLER( gridlee_videoram_w ) WRITE8_HANDLER( gridlee_palette_select_w ) { /* update the scanline palette */ - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1 + BALSENTE_VBEND); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1 + BALSENTE_VBEND); palettebank_vis = data & 0x3f; } diff --git a/src/mame/video/gstriker.c b/src/mame/video/gstriker.c index 0ce5d912757..0db05bb8ee8 100644 --- a/src/mame/video/gstriker.c +++ b/src/mame/video/gstriker.c @@ -246,8 +246,8 @@ static void MB60553_draw(running_machine *machine, int numchip, bitmap_t* screen rectangle clip; MB60553_cur_chip = &MB60553[numchip]; - clip.min_x = video_screen_get_visible_area(machine->primary_screen)->min_x; - clip.max_x = video_screen_get_visible_area(machine->primary_screen)->max_x; + clip.min_x = machine->primary_screen->visible_area().min_x; + clip.max_x = machine->primary_screen->visible_area().max_x; for (line = 0; line < 224;line++) { diff --git a/src/mame/video/gtia.c b/src/mame/video/gtia.c index 349deaaacf9..61aece907f8 100644 --- a/src/mame/video/gtia.c +++ b/src/mame/video/gtia.c @@ -146,7 +146,7 @@ static void gtia_state(running_machine *machine) static int is_ntsc(running_machine *machine) { - return ATTOSECONDS_TO_HZ(video_screen_get_frame_period(machine->primary_screen).attoseconds) > 55; + return ATTOSECONDS_TO_HZ(machine->primary_screen->frame_period().attoseconds) > 55; } diff --git a/src/mame/video/gticlub.c b/src/mame/video/gticlub.c index 8993d5de52e..63908ff84ad 100644 --- a/src/mame/video/gticlub.c +++ b/src/mame/video/gticlub.c @@ -198,14 +198,14 @@ void K001005_init(running_machine *machine) { int i; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); K001005_zbuffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED32); gfxrom = memory_region(machine, "gfx1"); - K001005_bitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - K001005_bitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); + K001005_bitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + K001005_bitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); K001005_texture = auto_alloc_array(machine, UINT8, 0x800000); @@ -538,7 +538,7 @@ static void draw_scanline_tex(void *dest, INT32 scanline, const poly_extent *ext static void render_polygons(running_machine *machine) { int i, j; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); // mame_printf_debug("K001005_fifo_ptr = %08X\n", K001005_3d_fifo_ptr); @@ -579,9 +579,9 @@ static void render_polygons(running_machine *machine) ++index; extra->color = color; - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); -// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, 4, v); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); +// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, 4, v); i = index - 1; } @@ -686,13 +686,13 @@ static void render_polygons(running_machine *machine) if (num_verts < 3) { - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &prev_v[2], &v[0], &v[1]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &prev_v[2], &v[0], &v[1]); if (prev_poly_type) - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &prev_v[2], &prev_v[3], &v[0]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &prev_v[2], &prev_v[3], &v[0]); // if (prev_poly_type) -// poly_render_quad(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &prev_v[2], &prev_v[3], &v[0], &v[1]); +// poly_render_quad(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &prev_v[2], &prev_v[3], &v[0], &v[1]); // else -// poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &prev_v[2], &v[0], &v[1]); +// poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &prev_v[2], &v[0], &v[1]); memcpy(&prev_v[0], &prev_v[2], sizeof(poly_vertex)); memcpy(&prev_v[1], &prev_v[3], sizeof(poly_vertex)); @@ -701,10 +701,10 @@ static void render_polygons(running_machine *machine) } else { - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); if (num_verts > 3) - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); -// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, num_verts, v); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); +// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, num_verts, v); memcpy(prev_v, v, sizeof(poly_vertex) * 4); } @@ -785,10 +785,10 @@ static void render_polygons(running_machine *machine) extra->color = color; - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); if (new_verts > 1) - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); -// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline_tex, 4, new_verts + 2, v); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); +// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline_tex, 4, new_verts + 2, v); memcpy(prev_v, v, sizeof(poly_vertex) * 4); }; @@ -844,10 +844,10 @@ static void render_polygons(running_machine *machine) extra->color = color; - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); if (num_verts > 3) - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[2], &v[3], &v[0]); -// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, num_verts, v); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[2], &v[3], &v[0]); +// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, num_verts, v); memcpy(prev_v, v, sizeof(poly_vertex) * 4); @@ -903,10 +903,10 @@ static void render_polygons(running_machine *machine) extra->color = color; - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); if (new_verts > 1) - poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); -// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], visarea, draw_scanline, 1, new_verts + 2, v); + poly_render_triangle(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); +// poly_render_polygon(poly, K001005_bitmap[K001005_bitmap_page], &visarea, draw_scanline, 1, new_verts + 2, v); memcpy(prev_v, v, sizeof(poly_vertex) * 4); }; diff --git a/src/mame/video/gyruss.c b/src/mame/video/gyruss.c index eeca2630b21..6613f218612 100644 --- a/src/mame/video/gyruss.c +++ b/src/mame/video/gyruss.c @@ -94,7 +94,7 @@ PALETTE_INIT( gyruss ) WRITE8_HANDLER( gyruss_spriteram_w ) { gyruss_state *state = (gyruss_state *)space->machine->driver_data; - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); state->spriteram[offset] = data; } @@ -125,7 +125,7 @@ VIDEO_START( gyruss ) READ8_HANDLER( gyruss_scanline_r ) { /* reads 1V - 128V */ - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } @@ -154,7 +154,7 @@ VIDEO_UPDATE( gyruss ) { gyruss_state *state = (gyruss_state *)screen->machine->driver_data; - if (cliprect->min_y == video_screen_get_visible_area(screen)->min_y) + if (cliprect->min_y == screen->visible_area().min_y) { tilemap_mark_all_tiles_dirty_all(screen->machine); tilemap_set_flip_all(screen->machine, (*state->flipscreen & 0x01) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0); diff --git a/src/mame/video/harddriv.c b/src/mame/video/harddriv.c index 164f8a24a15..dd2cf8904cb 100644 --- a/src/mame/video/harddriv.c +++ b/src/mame/video/harddriv.c @@ -165,7 +165,7 @@ void hdgsp_read_from_shiftreg(const address_space *space, UINT32 address, UINT16 static void update_palette_bank(running_machine *machine, int newbank) { harddriv_state *state = (harddriv_state *)machine->driver_data; - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); state->gfx_palettebank = newbank; } @@ -231,7 +231,7 @@ WRITE16_HANDLER( hdgsp_control_hi_w ) case 0x01: data = data & (15 >> state->gsp_multisync); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1); state->gfx_finescroll = data; break; @@ -423,9 +423,9 @@ static void display_speedups(void) } -void harddriv_scanline_driver(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void harddriv_scanline_driver(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - harddriv_state *state = (harddriv_state *)screen->machine->driver_data; + harddriv_state *state = (harddriv_state *)screen.machine->driver_data; UINT8 *vram_base = &state->gsp_vram[(params->rowaddr << 12) & state->vram_mask]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 4) - 15 + (state->gfx_finescroll & 0x0f); @@ -434,14 +434,14 @@ void harddriv_scanline_driver(running_device *screen, bitmap_t *bitmap, int scan for (x = params->heblnk; x < params->hsblnk; x++) dest[x] = state->gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0xfff)]; - if (scanline == video_screen_get_visible_area(screen)->max_y) + if (scanline == screen.visible_area().max_y) display_speedups(); } -void harddriv_scanline_multisync(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void harddriv_scanline_multisync(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - harddriv_state *state = (harddriv_state *)screen->machine->driver_data; + harddriv_state *state = (harddriv_state *)screen.machine->driver_data; UINT8 *vram_base = &state->gsp_vram[(params->rowaddr << 11) & state->vram_mask]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); int coladdr = (params->yoffset << 9) + ((params->coladdr & 0xff) << 3) - 7 + (state->gfx_finescroll & 0x07); @@ -450,6 +450,6 @@ void harddriv_scanline_multisync(running_device *screen, bitmap_t *bitmap, int s for (x = params->heblnk; x < params->hsblnk; x++) dest[x] = state->gfx_palettebank * 256 + vram_base[BYTE_XOR_LE(coladdr++ & 0x7ff)]; - if (scanline == video_screen_get_visible_area(screen)->max_y) + if (scanline == screen.visible_area().max_y) display_speedups(); } diff --git a/src/mame/video/hng64.c b/src/mame/video/hng64.c index dc0f050c66c..751987e4518 100644 --- a/src/mame/video/hng64.c +++ b/src/mame/video/hng64.c @@ -1137,11 +1137,11 @@ static void hng64_drawtilemap(running_machine* machine, bitmap_t *bitmap, const INT32 ytopleft,ymiddle; int xinc,yinc; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + const rectangle &visarea = machine->primary_screen->visible_area(); + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; if (global_tileregs&0x04000000) // globally selects alt scroll register layout??? { @@ -1677,7 +1677,7 @@ VIDEO_UPDATE( hng64 ) VIDEO_START( hng64 ) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); hng64_tilemap0_8x8 = tilemap_create(machine, get_hng64_tile0_8x8_info, tilemap_scan_rows, 8, 8, 128,128); /* 128x128x4 = 0x10000 */ hng64_tilemap0_16x16 = tilemap_create(machine, get_hng64_tile0_16x16_info, tilemap_scan_rows, 16, 16, 128,128); /* 128x128x4 = 0x10000 */ @@ -1716,8 +1716,8 @@ VIDEO_START( hng64 ) additive_tilemap_debug = 0; // 3d Buffer Allocation - depthBuffer3d = auto_alloc_array(machine, float, (visarea->max_x)*(visarea->max_y)); - colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea->max_x)*(visarea->max_y)); + depthBuffer3d = auto_alloc_array(machine, float, (visarea.max_x)*(visarea.max_y)); + colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea.max_x)*(visarea.max_y)); } @@ -2024,7 +2024,7 @@ static void recoverPolygonBlock(running_machine* machine, const UINT16* packet, setIdentity(objectMatrix); struct polygon lastPoly = { 0 }; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); ///////////////// // HEADER INFO // @@ -2515,11 +2515,11 @@ static void recoverPolygonBlock(running_machine* machine, const UINT16* packet, ndCoords[3] = polys[*numPolys].vert[m].clipCoords[3]; // Final pixel values are garnered here : - windowCoords[0] = (ndCoords[0]+1.0f) * ((float)(visarea->max_x) / 2.0f) + 0.0f; - windowCoords[1] = (ndCoords[1]+1.0f) * ((float)(visarea->max_y) / 2.0f) + 0.0f; + windowCoords[0] = (ndCoords[0]+1.0f) * ((float)(visarea.max_x) / 2.0f) + 0.0f; + windowCoords[1] = (ndCoords[1]+1.0f) * ((float)(visarea.max_y) / 2.0f) + 0.0f; windowCoords[2] = (ndCoords[2]+1.0f) * 0.5f; - windowCoords[1] = (float)visarea->max_y - windowCoords[1]; // Flip Y + windowCoords[1] = (float)visarea.max_y - windowCoords[1]; // Flip Y // Store the points in a list for later use... polys[*numPolys].vert[m].clipCoords[0] = windowCoords[0]; @@ -2635,7 +2635,7 @@ static void clear3d(running_machine *machine) { int i; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); // Clear each of the display list buffers after drawing - todo: kill! for (i = 0; i < 0x81; i++) @@ -2645,7 +2645,7 @@ static void clear3d(running_machine *machine) } // Reset the buffers... - for (i = 0; i < (visarea->max_x)*(visarea->max_y); i++) + for (i = 0; i < (visarea.max_x)*(visarea.max_y); i++) { depthBuffer3d[i] = 100.0f; colorBuffer3d[i] = MAKE_ARGB(0,0,0,0); @@ -2912,7 +2912,7 @@ static void performFrustumClip(struct polygon *p) #ifdef UNUSED_FUNCTION static void plot(running_machine *machine, INT32 x, INT32 y, UINT32 color) { - UINT32* cb = &(colorBuffer3d[(y * video_screen_get_visible_area(machine->primary_screen)->max_x) + x]); + UINT32* cb = &(colorBuffer3d[(y * machine->primary_screen->visible_area().max_x) + x]); *cb = color; } @@ -3028,8 +3028,8 @@ INLINE void FillSmoothTexPCHorizontalLine(running_machine *machine, float g_start, float g_delta, float b_start, float b_delta, float s_start, float s_delta, float t_start, float t_delta) { - float* db = &(depthBuffer3d[(y * video_screen_get_visible_area(machine->primary_screen)->max_x) + x_start]); - UINT32* cb = &(colorBuffer3d[(y * video_screen_get_visible_area(machine->primary_screen)->max_x) + x_start]); + float* db = &(depthBuffer3d[(y * machine->primary_screen->visible_area().max_x) + x_start]); + UINT32* cb = &(colorBuffer3d[(y * machine->primary_screen->visible_area().max_x) + x_start]); UINT8 paletteEntry = 0; float t_coord, s_coord; diff --git a/src/mame/video/homedata.c b/src/mame/video/homedata.c index d2195350694..14696b5aacd 100644 --- a/src/mame/video/homedata.c +++ b/src/mame/video/homedata.c @@ -872,7 +872,7 @@ VIDEO_UPDATE( mrokumei ) width = 54; break; } - video_screen_set_visarea(screen, 0*8, width*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, width*8-1, 2*8, 30*8-1); tilemap_set_scrollx(state->bg_tilemap[state->visible_page][0], 0, state->vreg[0xc] << 1); @@ -1013,24 +1013,24 @@ VIDEO_UPDATE( pteacher ) if (state->vreg[0x4] == 0xae || state->vreg[0x4] == 0xb8) { /* kludge for mjkinjas */ - video_screen_set_visarea(screen, 0*8, 42*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, 42*8-1, 2*8, 30*8-1); scroll_low = 0; } else { if (state->vreg[0x3] == 0xa6) - video_screen_set_visarea(screen, 0*8, 33*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, 33*8-1, 2*8, 30*8-1); else - video_screen_set_visarea(screen, 0*8, 35*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, 35*8-1, 2*8, 30*8-1); scroll_low = (11 - (state->vreg[0x4] & 0x0f)) * 8 / 12; } } else { if (state->vreg[0x3] == 0xa6) - video_screen_set_visarea(screen, 0*8, 51*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, 51*8-1, 2*8, 30*8-1); else - video_screen_set_visarea(screen, 0*8, 54*8-1, 2*8, 30*8-1); + screen->set_visible_area(0*8, 54*8-1, 2*8, 30*8-1); scroll_low = 7 - (state->vreg[0x4] & 0x0f); } scroll_high = state->vreg[0xb] >> 2; diff --git a/src/mame/video/homerun.c b/src/mame/video/homerun.c index 0640b565dde..aaf0924d258 100644 --- a/src/mame/video/homerun.c +++ b/src/mame/video/homerun.c @@ -7,7 +7,7 @@ WRITE8_DEVICE_HANDLER(homerun_banking_w) { homerun_state *state = (homerun_state *)device->machine->driver_data; - if (video_screen_get_vpos(device->machine->primary_screen) > half_screen) + if (device->machine->primary_screen->vpos() > half_screen) state->gc_down = data & 3; else state->gc_up = data & 3; diff --git a/src/mame/video/hyhoo.c b/src/mame/video/hyhoo.c index ecf84e3f17c..0a1ba1bd372 100644 --- a/src/mame/video/hyhoo.c +++ b/src/mame/video/hyhoo.c @@ -234,7 +234,7 @@ static void hyhoo_gfxdraw(running_machine *machine) VIDEO_START( hyhoo ) { - hyhoo_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + hyhoo_tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); } diff --git a/src/mame/video/hyprduel.c b/src/mame/video/hyprduel.c index fc26cf0efad..e54ae602d1e 100644 --- a/src/mame/video/hyprduel.c +++ b/src/mame/video/hyprduel.c @@ -465,8 +465,8 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect UINT8 *base_gfx = memory_region(machine, "gfx1"); UINT8 *gfx_max = base_gfx + memory_region_length(machine, "gfx1"); - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); int max_sprites = state->spriteram_size / 8; int sprites = state->videoregs[0x00 / 2] % max_sprites; @@ -702,8 +702,8 @@ VIDEO_UPDATE( hyprduel ) } } - state->sprite_xoffs = state->videoregs[0x06 / 2] - video_screen_get_width(screen) / 2; - state->sprite_yoffs = state->videoregs[0x04 / 2] - video_screen_get_height(screen) / 2 - state->sprite_yoffs_sub; + state->sprite_xoffs = state->videoregs[0x06 / 2] - screen->width() / 2; + state->sprite_yoffs = state->videoregs[0x04 / 2] - screen->height() / 2 - state->sprite_yoffs_sub; /* The background color is selected by a register */ bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); diff --git a/src/mame/video/ikki.c b/src/mame/video/ikki.c index 4102ecb0f53..2f179bf8c64 100644 --- a/src/mame/video/ikki.c +++ b/src/mame/video/ikki.c @@ -119,7 +119,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect VIDEO_START( ikki ) { ikki_state *state = (ikki_state *)machine->driver_data; - state->sprite_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->sprite_bitmap = machine->primary_screen->alloc_compatible_bitmap(); state_save_register_global_bitmap(machine, state->sprite_bitmap); } diff --git a/src/mame/video/irobot.c b/src/mame/video/irobot.c index 1563b97d0d8..dce5a672a7c 100644 --- a/src/mame/video/irobot.c +++ b/src/mame/video/irobot.c @@ -81,7 +81,7 @@ WRITE8_HANDLER( irobot_paletteram_w ) static void _irobot_poly_clear(running_machine *machine, UINT8 *bitmap_base) { - memset(bitmap_base, 0, BITMAP_WIDTH * video_screen_get_height(machine->primary_screen)); + memset(bitmap_base, 0, BITMAP_WIDTH * machine->primary_screen->height()); } void irobot_poly_clear(running_machine *machine) @@ -99,7 +99,7 @@ void irobot_poly_clear(running_machine *machine) VIDEO_START( irobot ) { /* Setup 2 bitmaps for the polygon generator */ - int height = video_screen_get_height(machine->primary_screen); + int height = machine->primary_screen->height(); polybitmap1 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height); polybitmap2 = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * height); @@ -109,8 +109,8 @@ VIDEO_START( irobot ) /* Set clipping */ ir_xmin = ir_ymin = 0; - ir_xmax = video_screen_get_width(machine->primary_screen); - ir_ymax = video_screen_get_height(machine->primary_screen); + ir_xmax = machine->primary_screen->width(); + ir_ymax = machine->primary_screen->height(); } diff --git a/src/mame/video/itech32.c b/src/mame/video/itech32.c index 2484763dcbc..cad4bf07124 100644 --- a/src/mame/video/itech32.c +++ b/src/mame/video/itech32.c @@ -478,10 +478,10 @@ static void update_interrupts(running_machine *machine, int fast) static TIMER_CALLBACK( scanline_interrupt ) { /* set timer for next frame */ - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, VIDEO_INTSCANLINE, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(VIDEO_INTSCANLINE), 0); /* set the interrupt bit in the status reg */ - logerror("-------------- (DISPLAY INT @ %d) ----------------\n", video_screen_get_vpos(machine->primary_screen)); + logerror("-------------- (DISPLAY INT @ %d) ----------------\n", machine->primary_screen->vpos()); VIDEO_INTSTATE |= VIDEOINT_SCANLINE; /* update the interrupt state */ @@ -1346,7 +1346,7 @@ WRITE16_HANDLER( itech32_video_w ) break; case 0x2c/2: /* VIDEO_INTSCANLINE */ - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(space->machine->primary_screen, VIDEO_INTSCANLINE, 0), 0); + timer_adjust_oneshot(scanline_timer, space->machine->primary_screen->time_until_pos(VIDEO_INTSCANLINE), 0); break; case 0x32/2: /* VIDEO_VTOTAL */ @@ -1378,7 +1378,7 @@ WRITE16_HANDLER( itech32_video_w ) logerror("Configure Screen: HTOTAL: %x HBSTART: %x HBEND: %x VTOTAL: %x VBSTART: %x VBEND: %x\n", VIDEO_HTOTAL, VIDEO_HBLANK_START, VIDEO_HBLANK_END, VIDEO_VTOTAL, VIDEO_VBLANK_START, VIDEO_VBLANK_END); - video_screen_configure(space->machine->primary_screen, VIDEO_HTOTAL, VIDEO_VTOTAL, &visarea, HZ_TO_ATTOSECONDS(VIDEO_CLOCK) * VIDEO_HTOTAL * VIDEO_VTOTAL); + space->machine->primary_screen->configure(VIDEO_HTOTAL, VIDEO_VTOTAL, visarea, HZ_TO_ATTOSECONDS(VIDEO_CLOCK) * VIDEO_HTOTAL * VIDEO_VTOTAL); } break; } @@ -1393,7 +1393,7 @@ READ16_HANDLER( itech32_video_r ) } else if (offset == 3) { - return 0xef;/*video_screen_get_vpos(space->machine->primary_screen) - 1;*/ + return 0xef;/*space->machine->primary_screen->vpos() - 1;*/ } return itech32_video[offset]; diff --git a/src/mame/video/itech8.c b/src/mame/video/itech8.c index 44685c7431b..e958448b863 100644 --- a/src/mame/video/itech8.c +++ b/src/mame/video/itech8.c @@ -170,7 +170,7 @@ static void generate_interrupt(running_machine *machine, int state) { itech8_update_interrupts(machine, -1, state, -1); - if (FULL_LOGGING && state) logerror("------------ DISPLAY INT (%d) --------------\n", video_screen_get_vpos(machine->primary_screen)); + if (FULL_LOGGING && state) logerror("------------ DISPLAY INT (%d) --------------\n", machine->primary_screen->vpos()); } @@ -229,8 +229,8 @@ WRITE8_HANDLER( itech8_palette_w ) WRITE8_HANDLER( itech8_page_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); - logerror("%04x:display_page = %02X (%d)\n", cpu_get_pc(space->cpu), data, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); + logerror("%04x:display_page = %02X (%d)\n", cpu_get_pc(space->cpu), data, space->machine->primary_screen->vpos()); page_select = data; } @@ -328,7 +328,7 @@ static void perform_blit(const address_space *space) /* debugging */ if (FULL_LOGGING) logerror("Blit: scan=%d src=%06x @ (%05x) for %dx%d ... flags=%02x\n", - video_screen_get_vpos(space->machine->primary_screen), + space->machine->primary_screen->vpos(), (*itech8_grom_bank << 16) | (BLITTER_ADDRHI << 8) | BLITTER_ADDRLO, tms_state.regs[TMS34061_XYADDRESS] | ((tms_state.regs[TMS34061_XYOFFSET] & 0x300) << 8), BLITTER_WIDTH, BLITTER_HEIGHT, BLITTER_FLAGS); @@ -450,7 +450,7 @@ static TIMER_CALLBACK( blitter_done ) blit_in_progress = 0; itech8_update_interrupts(machine, -1, -1, 1); - if (FULL_LOGGING) logerror("------------ BLIT DONE (%d) --------------\n", video_screen_get_vpos(machine->primary_screen)); + if (FULL_LOGGING) logerror("------------ BLIT DONE (%d) --------------\n", machine->primary_screen->vpos()); } @@ -585,7 +585,7 @@ WRITE8_HANDLER( grmatch_palette_w ) WRITE8_HANDLER( grmatch_xscroll_w ) { /* update the X scroll value */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); grmatch_xscroll = data; } diff --git a/src/mame/video/jaguar.c b/src/mame/video/jaguar.c index ccdf9902047..5c0da7ed44d 100644 --- a/src/mame/video/jaguar.c +++ b/src/mame/video/jaguar.c @@ -237,13 +237,13 @@ static void blitter_x1800x01_xxxxxx_xxxxxx(running_machine *machine, UINT32 comm INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int *y) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - int width = visarea->max_x + 1 - visarea->min_x; - int height = visarea->max_y + 1 - visarea->min_y; + int width = visarea.max_x + 1 - visarea.min_x; + int height = visarea.max_y + 1 - visarea.min_y; /* only 2 lightguns are connected */ - *x = visarea->min_x + (((input_port_read(machine, player ? "FAKE2_X" : "FAKE1_X") & 0xff) * width) >> 8); - *y = visarea->min_y + (((input_port_read(machine, player ? "FAKE2_Y" : "FAKE1_Y") & 0xff) * height) >> 8); + *x = visarea.min_x + (((input_port_read(machine, player ? "FAKE2_X" : "FAKE1_X") & 0xff) * width) >> 8); + *y = visarea.min_y + (((input_port_read(machine, player ? "FAKE2_Y" : "FAKE1_Y") & 0xff) * height) >> 8); } @@ -291,11 +291,11 @@ INLINE int adjust_object_timer(running_machine *machine, int vc) hdb = hdbpix[vc % 2]; /* if setting the second one in a line, make sure we will ever actually hit it */ - if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= video_screen_get_width(machine->primary_screen))) + if (vc % 2 == 1 && (hdbpix[1] == hdbpix[0] || hdbpix[1] >= machine->primary_screen->width())) return FALSE; /* adjust the timer */ - timer_adjust_oneshot(object_timer, video_screen_get_time_until_pos(machine->primary_screen, vc / 2, hdb), vc | (hdb << 16)); + timer_adjust_oneshot(object_timer, machine->primary_screen->time_until_pos(vc / 2, hdb), vc | (hdb << 16)); return TRUE; } @@ -655,18 +655,18 @@ READ16_HANDLER( jaguar_tom_regs_r ) return cpu_irq_state; case HC: - return video_screen_get_hpos(space->machine->primary_screen) % (video_screen_get_width(space->machine->primary_screen) / 2); + return space->machine->primary_screen->hpos() % (space->machine->primary_screen->width() / 2); case VC: { UINT8 half_line; - if(video_screen_get_hpos(space->machine->primary_screen) >= (video_screen_get_width(space->machine->primary_screen) / 2)) + if(space->machine->primary_screen->hpos() >= (space->machine->primary_screen->width() / 2)) half_line = 1; else half_line = 0; - return video_screen_get_vpos(space->machine->primary_screen) * 2 + half_line; + return space->machine->primary_screen->vpos() * 2 + half_line; } } @@ -761,7 +761,7 @@ WRITE16_HANDLER( jaguar_tom_regs_w ) visarea.max_x = hbstart / 2 - 1; visarea.min_y = vbend / 2; visarea.max_y = vbstart / 2 - 1; - video_screen_configure(space->machine->primary_screen, hperiod / 2, vperiod / 2, &visarea, HZ_TO_ATTOSECONDS((double)COJAG_PIXEL_CLOCK * 2 / hperiod / vperiod)); + space->machine->primary_screen->configure(hperiod / 2, vperiod / 2, visarea, HZ_TO_ATTOSECONDS((double)COJAG_PIXEL_CLOCK * 2 / hperiod / vperiod)); } } break; @@ -832,13 +832,13 @@ static TIMER_CALLBACK( cojag_scanline_update ) { int vc = param & 0xffff; int hdb = param >> 16; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* only run if video is enabled and we are past the "display begin" */ if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff)) { UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0); - int maxx = visarea->max_x; + int maxx = visarea.max_x; int hde = effective_hvalue(gpu_regs[HDE]) >> 1; UINT16 x,scanline[760]; UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1; @@ -847,7 +847,7 @@ static TIMER_CALLBACK( cojag_scanline_update ) if (ENABLE_BORDERS && vc % 2 == 0) { rgb_t border = MAKE_RGB(gpu_regs[BORD1] & 0xff, gpu_regs[BORD1] >> 8, gpu_regs[BORD2] & 0xff); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) dest[x] = border; } @@ -885,7 +885,7 @@ static TIMER_CALLBACK( cojag_scanline_update ) } /* point to the next counter value */ - if (++vc / 2 >= video_screen_get_height(machine->primary_screen)) + if (++vc / 2 >= machine->primary_screen->height()) vc = 0; } while (!adjust_object_timer(machine, vc)); diff --git a/src/mame/video/jpmimpct.c b/src/mame/video/jpmimpct.c index 8afa016f6bc..fac3e009c6a 100644 --- a/src/mame/video/jpmimpct.c +++ b/src/mame/video/jpmimpct.c @@ -115,7 +115,7 @@ void jpmimpct_from_shiftreg(const address_space *space, UINT32 address, UINT16 * * *************************************/ -void jpmimpct_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void jpmimpct_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *vram = &jpmimpct_vram[(params->rowaddr << 8) & 0x3ff00]; UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0); @@ -125,8 +125,8 @@ void jpmimpct_scanline_update(running_device *screen, bitmap_t *bitmap, int scan for (x = params->heblnk; x < params->hsblnk; x += 2) { UINT16 pixels = vram[coladdr++ & 0xff]; - dest[x + 0] = screen->machine->pens[pixels & 0xff]; - dest[x + 1] = screen->machine->pens[pixels >> 8]; + dest[x + 0] = screen.machine->pens[pixels & 0xff]; + dest[x + 1] = screen.machine->pens[pixels >> 8]; } } diff --git a/src/mame/video/kan_pand.c b/src/mame/video/kan_pand.c index b515601bfeb..a633c8a18ba 100644 --- a/src/mame/video/kan_pand.c +++ b/src/mame/video/kan_pand.c @@ -53,7 +53,7 @@ typedef struct _kaneko_pandora_state kaneko_pandora_state; struct _kaneko_pandora_state { - running_device *screen; + screen_device *screen; UINT8 * spriteram; bitmap_t *sprites_bitmap; /* bitmap to render sprites to, Pandora seems to be frame'buffered' */ int clear_bitmap; @@ -68,17 +68,16 @@ struct _kaneko_pandora_state INLINE kaneko_pandora_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == KANEKO_PANDORA); + assert(device->type() == KANEKO_PANDORA); - return (kaneko_pandora_state *)device->token; + return (kaneko_pandora_state *)downcast(device)->token(); } INLINE const kaneko_pandora_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == KANEKO_PANDORA)); - return (const kaneko_pandora_interface *) device->baseconfig().static_config; + assert((device->type() == KANEKO_PANDORA)); + return (const kaneko_pandora_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -196,9 +195,9 @@ void pandora_eof( running_device *device ) // the games can disable the clearing of the sprite bitmap, to leave sprite trails if (pandora->clear_bitmap) - bitmap_fill(pandora->sprites_bitmap, video_screen_get_visible_area(pandora->screen), 0); + bitmap_fill(pandora->sprites_bitmap, &pandora->screen->visible_area(), 0); - pandora_draw(device, pandora->sprites_bitmap, video_screen_get_visible_area(pandora->screen)); + pandora_draw(device, pandora->sprites_bitmap, &pandora->screen->visible_area()); } /***************************************************************************** @@ -295,14 +294,14 @@ static DEVICE_START( kaneko_pandora ) kaneko_pandora_state *pandora = get_safe_token(device); const kaneko_pandora_interface *intf = get_interface(device); - pandora->screen = devtag_get_device(device->machine, intf->screen); + pandora->screen = device->machine->device(intf->screen); pandora->region = intf->gfx_region; pandora->xoffset = intf->x; pandora->yoffset = intf->y; pandora->spriteram = auto_alloc_array(device->machine, UINT8, 0x1000); - pandora->sprites_bitmap = video_screen_auto_bitmap_alloc(pandora->screen); + pandora->sprites_bitmap = pandora->screen->alloc_compatible_bitmap(); state_save_register_device_item(device, 0, pandora->clear_bitmap); state_save_register_device_item_pointer(device, 0, pandora->spriteram, 0x1000); @@ -324,5 +323,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "Kaneko Pandora - PX79C480FP-3" #define DEVTEMPLATE_FAMILY "Kaneko Video Chips" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/mame/video/kan_pand.h b/src/mame/video/kan_pand.h index 3b5f5f139fd..2632c77dfde 100644 --- a/src/mame/video/kan_pand.h +++ b/src/mame/video/kan_pand.h @@ -9,7 +9,7 @@ #ifndef __KAN_PAND_H__ #define __KAN_PAND_H__ -#include "devcb.h" +#include "devlegcy.h" /*************************************************************************** TYPE DEFINITIONS @@ -24,19 +24,12 @@ struct _kaneko_pandora_interface int y; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( kaneko_pandora ); - +DECLARE_LEGACY_DEVICE(KANEKO_PANDORA, kaneko_pandora); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define KANEKO_PANDORA DEVICE_GET_INFO_NAME( kaneko_pandora ) - #define MDRV_KANEKO_PANDORA_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, KANEKO_PANDORA, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/video/kaneko16.c b/src/mame/video/kaneko16.c index d095275c54a..7330927a962 100644 --- a/src/mame/video/kaneko16.c +++ b/src/mame/video/kaneko16.c @@ -146,13 +146,13 @@ VIDEO_START( kaneko16_1xVIEW2_tilemaps ) kaneko16_tmap_3 = 0; - sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + sprites_bitmap = machine->primary_screen->alloc_compatible_bitmap(); { int dx, dy; - int xdim = video_screen_get_width(machine->primary_screen); - int ydim = video_screen_get_height(machine->primary_screen); + int xdim = machine->primary_screen->width(); + int ydim = machine->primary_screen->height(); switch (xdim) { @@ -160,7 +160,7 @@ VIDEO_START( kaneko16_1xVIEW2_tilemaps ) case 256: dx = 0x5b; break; default: dx = 0; } - switch (video_screen_get_visible_area(machine->primary_screen)->max_y - video_screen_get_visible_area(machine->primary_screen)->min_y + 1) + switch (machine->primary_screen->visible_area().max_y - machine->primary_screen->visible_area().min_y + 1) { case 240- 8: dy = +0x08; break; /* blazeon */ case 240-16: dy = -0x08; break; /* berlwall, bakubrk */ @@ -202,8 +202,8 @@ VIDEO_START( kaneko16_2xVIEW2 ) { int dx, dy; - int xdim = video_screen_get_width(machine->primary_screen); - int ydim = video_screen_get_height(machine->primary_screen); + int xdim = machine->primary_screen->width(); + int ydim = machine->primary_screen->height(); switch (xdim) { @@ -211,7 +211,7 @@ VIDEO_START( kaneko16_2xVIEW2 ) case 256: dx = 0x5b; break; default: dx = 0; } - switch (video_screen_get_visible_area(machine->primary_screen)->max_y - video_screen_get_visible_area(machine->primary_screen)->min_y + 1) + switch (machine->primary_screen->visible_area().max_y - machine->primary_screen->visible_area().min_y + 1) { case 240- 8: dy = +0x08; break; case 240-16: dy = -0x08; break; @@ -314,13 +314,13 @@ VIDEO_START( galsnew ) kaneko16_tmap_3 = 0; - sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + sprites_bitmap = machine->primary_screen->alloc_compatible_bitmap(); { int dx = 0x5b, dy = 8; - int xdim = video_screen_get_width(machine->primary_screen); - int ydim = video_screen_get_height(machine->primary_screen); + int xdim = machine->primary_screen->width(); + int ydim = machine->primary_screen->height(); tilemap_set_scrolldx( kaneko16_tmap_0, -dx, xdim + dx -1 ); tilemap_set_scrolldx( kaneko16_tmap_1, -(dx+2), xdim + (dx + 2) - 1 ); @@ -425,12 +425,12 @@ static int kaneko16_parse_sprite_type012(running_machine *machine, int i, struct if (kaneko16_sprite_flipy) { s->yoffs -= kaneko16_sprites_regs[0x2/2]; - s->yoffs -= video_screen_get_visible_area(machine->primary_screen)->min_y<<6; + s->yoffs -= machine->primary_screen->visible_area().min_y<<6; } else { s->yoffs -= kaneko16_sprites_regs[0x2/2]; - s->yoffs += video_screen_get_visible_area(machine->primary_screen)->min_y<<6; + s->yoffs += machine->primary_screen->visible_area().min_y<<6; } return ( (attr & 0x2000) ? USE_LATCHED_XY : 0 ) | @@ -550,7 +550,7 @@ void kaneko16_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rec in a temp buffer, then draw the buffer's contents from last to first. */ - int max = (video_screen_get_width(machine->primary_screen) > 0x100) ? (0x200<<6) : (0x100<<6); + int max = (machine->primary_screen->width() > 0x100) ? (0x200<<6) : (0x100<<6); int i = 0; struct tempsprite *s = spritelist.first_sprite; diff --git a/src/mame/video/karnov.c b/src/mame/video/karnov.c index f8603891861..bca1c73b64e 100644 --- a/src/mame/video/karnov.c +++ b/src/mame/video/karnov.c @@ -228,7 +228,7 @@ VIDEO_START( karnov ) karnov_state *state = (karnov_state *)machine->driver_data; /* Allocate bitmap & tilemap */ - state->bitmap_f = auto_bitmap_alloc(machine, 512, 512, video_screen_get_format(machine->primary_screen)); + state->bitmap_f = auto_bitmap_alloc(machine, 512, 512, machine->primary_screen->format()); state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, tilemap_scan_rows, 8, 8, 32, 32); state_save_register_global_bitmap(machine, state->bitmap_f); @@ -241,7 +241,7 @@ VIDEO_START( wndrplnt ) karnov_state *state = (karnov_state *)machine->driver_data; /* Allocate bitmap & tilemap */ - state->bitmap_f = auto_bitmap_alloc(machine, 512, 512, video_screen_get_format(machine->primary_screen)); + state->bitmap_f = auto_bitmap_alloc(machine, 512, 512, machine->primary_screen->format()); state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, tilemap_scan_cols, 8, 8, 32, 32); state_save_register_global_bitmap(machine, state->bitmap_f); diff --git a/src/mame/video/kncljoe.c b/src/mame/video/kncljoe.c index d9c3ca70d3b..6954ddd55f3 100644 --- a/src/mame/video/kncljoe.c +++ b/src/mame/video/kncljoe.c @@ -188,18 +188,18 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect const gfx_element *gfx = machine->gfx[1 + state->sprite_bank]; int i, j; static const int pribase[4]={0x0180, 0x0080, 0x0100, 0x0000}; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* score covers sprites */ if (state->flipscreen) { - if (clip.max_y > visarea->max_y - 64) - clip.max_y = visarea->max_y - 64; + if (clip.max_y > visarea.max_y - 64) + clip.max_y = visarea.max_y - 64; } else { - if (clip.min_y < visarea->min_y + 64) - clip.min_y = visarea->min_y + 64; + if (clip.min_y < visarea.min_y + 64) + clip.min_y = visarea.min_y + 64; } for (i = 0; i < 4; i++) diff --git a/src/mame/video/konamigx.c b/src/mame/video/konamigx.c index 151e0717422..25a44b64521 100644 --- a/src/mame/video/konamigx.c +++ b/src/mame/video/konamigx.c @@ -1057,10 +1057,10 @@ int K055555GX_decode_osmixcolor(int layer, int *color) // (see p.63, p.49-50 and static void gx_wipezbuf(running_machine *machine, int noshadow) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - int w = visarea->max_x - visarea->min_x + 1; - int h = visarea->max_y - visarea->min_y + 1; + int w = visarea.max_x - visarea.min_x + 1; + int h = visarea.max_y - visarea.min_y + 1; UINT8 *zptr = gx_objzbuf; int ecx = h; @@ -1496,7 +1496,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle } // traverse draw list - screenwidth = video_screen_get_width(machine->primary_screen); + screenwidth = machine->primary_screen->width(); for (count=0; countprimary_screen); - int width = visarea->max_x - visarea->min_x + 1; + const rectangle &visarea = machine->primary_screen->visible_area(); + int width = visarea.max_x - visarea.min_x + 1; if (width>512) // vsnetscr case pixeldouble_output = 1; @@ -1620,8 +1620,8 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle if (extra_bitmap) // soccer superstars roz layer { int xx,yy; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); const pen_t *paldata = machine->pens; // the output size of the roz layer has to be doubled horizontally @@ -2148,8 +2148,8 @@ VIDEO_START(konamigx_6bpp) VIDEO_START(konamigx_type3) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); K056832_vh_start(machine, "gfx1", K056832_BPP_6, 0, NULL, konamigx_type2_tile_callback, 1); K055673_vh_start(machine, "gfx2", K055673_LAYOUT_GX6, -132, -23, konamigx_type2_sprite_callback); @@ -2187,8 +2187,8 @@ VIDEO_START(konamigx_type3) VIDEO_START(konamigx_type4) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); K056832_vh_start(machine, "gfx1", K056832_BPP_8, 0, NULL, konamigx_type2_tile_callback, 0); K055673_vh_start(machine, "gfx2", K055673_LAYOUT_GX6, -79, -24, konamigx_type2_sprite_callback); // -23 looks better in intro @@ -2218,8 +2218,8 @@ VIDEO_START(konamigx_type4) VIDEO_START(konamigx_type4_vsn) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); K056832_vh_start(machine, "gfx1", K056832_BPP_8, 0, NULL, konamigx_type2_tile_callback, 2); // set djmain_hack to 2 to kill layer association or half the tilemaps vanish on screen 0 K055673_vh_start(machine, "gfx2", K055673_LAYOUT_GX6, -132, -23, konamigx_type2_sprite_callback); @@ -2248,8 +2248,8 @@ VIDEO_START(konamigx_type4_vsn) VIDEO_START(konamigx_type4_sd2) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); K056832_vh_start(machine, "gfx1", K056832_BPP_8, 0, NULL, konamigx_type2_tile_callback, 0); K055673_vh_start(machine, "gfx2", K055673_LAYOUT_GX6, -81, -23, konamigx_type2_sprite_callback); @@ -2570,7 +2570,7 @@ VIDEO_UPDATE(konamigx) int y,x; // make it flicker, to compare positioning - //if (video_screen_get_frame_number(screen) & 1) + //if (screen->frame_number() & 1) { for (y=0;y<256;y++) diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c index 234cdb3b726..c5eae36ea0f 100644 --- a/src/mame/video/konamiic.c +++ b/src/mame/video/konamiic.c @@ -3794,7 +3794,7 @@ void K053247_vh_start(running_machine *machine, const char *gfx_memory_region, i if (VERBOSE) { - if (video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32) + if (machine->primary_screen->format() == BITMAP_FORMAT_RGB32) { if ((machine->config->video_attributes & (VIDEO_HAS_SHADOWS|VIDEO_HAS_HIGHLIGHTS)) != VIDEO_HAS_SHADOWS+VIDEO_HAS_HIGHLIGHTS) popmessage("driver missing SHADOWS or HIGHLIGHTS flag"); @@ -4207,7 +4207,7 @@ void K053247_sprites_draw(running_machine *machine, bitmap_t *bitmap,const recta int offx = (short)((K053246_regs[0] << 8) | K053246_regs[1]); int offy = (short)((K053246_regs[2] << 8) | K053246_regs[3]); - int screen_width = video_screen_get_width(machine->primary_screen); + int screen_width = machine->primary_screen->width(); UINT8 drawmode_table[256]; UINT8 shadowmode_table[256]; UINT8 *whichtable; @@ -7367,12 +7367,12 @@ void K054338_fill_backcolor(running_machine *machine, bitmap_t *bitmap, int mode int BGC_CBLK, BGC_SET; UINT32 *dst_ptr, *pal_ptr; int bgcolor; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - clipx = visarea->min_x & ~3; - clipy = visarea->min_y; - clipw = (visarea->max_x - clipx + 4) & ~3; - cliph = visarea->max_y - clipy + 1; + clipx = visarea.min_x & ~3; + clipy = visarea.min_y; + clipw = (visarea.max_x - clipx + 4) & ~3; + cliph = visarea.max_y - clipy + 1; dst_ptr = BITMAP_ADDR32(bitmap, clipy, 0); dst_pitch = bitmap->rowpixels; @@ -7537,7 +7537,7 @@ void K053250_dma(running_machine *machine, int chip, int limiter) chip_ptr = &K053250_info.chip[chip]; - current_frame = video_screen_get_frame_number(machine->primary_screen); + current_frame = machine->primary_screen->frame_number(); last_frame = chip_ptr->frame; if (limiter && current_frame == last_frame) return; // make sure we only do DMA transfer once per frame @@ -7840,7 +7840,7 @@ void K053250_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *c static int pmode[2] = {-1,-1}; static int kc=-1, kk=0, kxx=-105, kyy=0; - const rectangle area = *video_screen_get_visible_area(machine->primary_screen); + const rectangle area = *machine->primary_screen->visible_area(); UINT16 *line; int delta, dim1, dim1_max, dim2_max; UINT32 mask1, mask2; diff --git a/src/mame/video/konicdev.c b/src/mame/video/konicdev.c index ccf3a8b05ec..a15fde78060 100644 --- a/src/mame/video/konicdev.c +++ b/src/mame/video/konicdev.c @@ -1347,10 +1347,9 @@ struct _k007121_state INLINE k007121_state *k007121_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K007121); + assert(device->type() == K007121); - return (k007121_state *)device->token; + return (k007121_state *)downcast(device)->token(); } /***************************************************************************** @@ -1621,17 +1620,16 @@ struct _k007342_state INLINE k007342_state *k007342_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K007342); + assert(device->type() == K007342); - return (k007342_state *)device->token; + return (k007342_state *)downcast(device)->token(); } INLINE const k007342_interface *k007342_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K007342)); - return (const k007342_interface *) device->baseconfig().static_config; + assert((device->type() == K007342)); + return (const k007342_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -1912,17 +1910,16 @@ struct _k007420_state INLINE k007420_state *k007420_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K007420); + assert(device->type() == K007420); - return (k007420_state *)device->token; + return (k007420_state *)downcast(device)->token(); } INLINE const k007420_interface *k007420_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K007420)); - return (const k007420_interface *) device->baseconfig().static_config; + assert((device->type() == K007420)); + return (const k007420_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -2190,17 +2187,16 @@ struct _k052109_state INLINE k052109_state *k052109_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K052109); + assert(device->type() == K052109); - return (k052109_state *)device->token; + return (k052109_state *)downcast(device)->token(); } INLINE const k052109_interface *k052109_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K052109)); - return (const k052109_interface *) device->baseconfig().static_config; + assert((device->type() == K052109)); + return (const k052109_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -2826,17 +2822,16 @@ struct _k051960_state INLINE k051960_state *k051960_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K051960); + assert(device->type() == K051960); - return (k051960_state *)device->token; + return (k051960_state *)downcast(device)->token(); } INLINE const k051960_interface *k051960_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K051960)); - return (const k051960_interface *) device->baseconfig().static_config; + assert((device->type() == K051960)); + return (const k051960_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -3369,17 +3364,16 @@ struct _k05324x_state INLINE k05324x_state *k05324x_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == K053244 || device->type == K053245)); + assert((device->type() == K053244 || device->type() == K053245)); - return (k05324x_state *)device->token; + return (k05324x_state *)downcast(device)->token(); } INLINE const k05324x_interface *k05324x_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K053244 || device->type == K053245)); - return (const k05324x_interface *) device->baseconfig().static_config; + assert((device->type() == K053244 || device->type() == K053245)); + return (const k05324x_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -4148,7 +4142,7 @@ struct _k053247_state k05324x_callback callback; const char *memory_region; - running_device *screen; + screen_device *screen; }; @@ -4160,17 +4154,16 @@ struct _k053247_state INLINE k053247_state *k053247_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == K053246 || device->type == K053247 || device->type == K055673)); + assert((device->type() == K053246 || device->type() == K053247 || device->type() == K055673)); - return (k053247_state *)device->token; + return (k053247_state *)downcast(device)->token(); } INLINE const k053247_interface *k053247_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K053246 || device->type == K053247 || device->type == K055673)); - return (const k053247_interface *) device->baseconfig().static_config; + assert((device->type() == K053246 || device->type() == K053247 || device->type() == K055673)); + return (const k053247_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -4503,7 +4496,7 @@ void k053247_sprites_draw( running_device *device, bitmap_t *bitmap, const recta int offx = (short)((k053246->kx46_regs[0] << 8) | k053246->kx46_regs[1]); int offy = (short)((k053246->kx46_regs[2] << 8) | k053246->kx46_regs[3]); - int screen_width = video_screen_get_width(k053246->screen); + int screen_width = k053246->screen->width(); UINT8 drawmode_table[256]; UINT8 shadowmode_table[256]; UINT8 *whichtable; @@ -4906,7 +4899,7 @@ static DEVICE_START( k053247 ) 16*64 }; - k053247->screen = devtag_get_device(device->machine, intf->screen); + k053247->screen = machine->device(intf->screen); /* decode the graphics */ switch (intf->plane_order) @@ -4927,7 +4920,7 @@ static DEVICE_START( k053247 ) if (VERBOSE) { - if (video_screen_get_format(k053247->screen) == BITMAP_FORMAT_RGB32) + if (k053247->screen->format() == BITMAP_FORMAT_RGB32) { if ((machine->config->video_attributes & (VIDEO_HAS_SHADOWS|VIDEO_HAS_HIGHLIGHTS)) != VIDEO_HAS_SHADOWS+VIDEO_HAS_HIGHLIGHTS) popmessage("driver missing SHADOWS or HIGHLIGHTS flag"); @@ -5014,7 +5007,7 @@ static DEVICE_START( k055673 ) 16*16*6 }; - k053247->screen = devtag_get_device(device->machine, intf->screen); + k053247->screen = machine->device(intf->screen); K055673_rom = (UINT16 *)memory_region(machine, intf->gfx_memory_region); @@ -5152,17 +5145,16 @@ struct _k051316_state INLINE k051316_state *k051316_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K051316); + assert(device->type() == K051316); - return (k051316_state *)device->token; + return (k051316_state *)downcast(device)->token(); } INLINE const k051316_interface *k051316_get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == K051316); - return (const k051316_interface *) device->baseconfig().static_config; + assert(device->type() == K051316); + return (const k051316_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -5441,17 +5433,16 @@ struct _k053936_state INLINE k053936_state *k053936_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K053936); + assert(device->type() == K053936); - return (k053936_state *)device->token; + return (k053936_state *)downcast(device)->token(); } INLINE const k053936_interface *k053936_get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == K053936); - return (const k053936_interface *) device->baseconfig().static_config; + assert(device->type() == K053936); + return (const k053936_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -5667,10 +5658,9 @@ struct _k053251_state INLINE k053251_state *k053251_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K053251); + assert(device->type() == K053251); - return (k053251_state *)device->token; + return (k053251_state *)downcast(device)->token(); } /***************************************************************************** @@ -5821,10 +5811,9 @@ struct _k054000_state INLINE k054000_state *k054000_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K054000); + assert(device->type() == K054000); - return (k054000_state *)device->token; + return (k054000_state *)downcast(device)->token(); } /***************************************************************************** @@ -5933,10 +5922,9 @@ struct _k051733_state INLINE k051733_state *k051733_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K051733); + assert(device->type() == K051733); - return (k051733_state *)device->token; + return (k051733_state *)downcast(device)->token(); } /***************************************************************************** @@ -6138,17 +6126,16 @@ struct _k056832_state INLINE k056832_state *k056832_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K056832); + assert(device->type() == K056832); - return (k056832_state *)device->token; + return (k056832_state *)downcast(device)->token(); } INLINE const k056832_interface *k056832_get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == K056832); - return (const k056832_interface *) device->baseconfig().static_config; + assert(device->type() == K056832); + return (const k056832_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -8058,10 +8045,9 @@ struct _k055555_state INLINE k055555_state *k055555_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K055555); + assert(device->type() == K055555); - return (k055555_state *)device->token; + return (k055555_state *)downcast(device)->token(); } /***************************************************************************** @@ -8175,7 +8161,7 @@ struct _k054338_state int shd_rgb[9]; int alphainverted; - running_device *screen; + screen_device *screen; running_device *k055555; /* used to fill BG color */ }; @@ -8186,17 +8172,16 @@ struct _k054338_state INLINE k054338_state *k054338_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K054338); + assert(device->type() == K054338); - return (k054338_state *)device->token; + return (k054338_state *)downcast(device)->token(); } INLINE const k054338_interface *k054338_get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == K054338); - return (const k054338_interface *) device->baseconfig().static_config; + assert(device->type() == K054338); + return (const k054338_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -8280,12 +8265,12 @@ void k054338_fill_backcolor( running_device *device, bitmap_t *bitmap, int mode int BGC_CBLK, BGC_SET; UINT32 *dst_ptr, *pal_ptr; int bgcolor; - const rectangle *visarea = video_screen_get_visible_area(k054338->screen); + const rectangle &visarea = k054338->screen->visible_area(); - clipx = visarea->min_x & ~3; - clipy = visarea->min_y; - clipw = (visarea->max_x - clipx + 4) & ~3; - cliph = visarea->max_y - clipy + 1; + clipx = visarea.min_x & ~3; + clipy = visarea.min_y; + clipw = (visarea.max_x - clipx + 4) & ~3; + cliph = visarea.max_y - clipy + 1; dst_ptr = BITMAP_ADDR32(bitmap, clipy, 0); dst_pitch = bitmap->rowpixels; @@ -8445,7 +8430,7 @@ static DEVICE_START( k054338 ) k054338_state *k054338 = k054338_get_safe_token(device); const k054338_interface *intf = k054338_get_interface(device); - k054338->screen = devtag_get_device(device->machine, intf->screen); + k054338->screen = device->machine->device(intf->screen); k054338->k055555 = devtag_get_device(device->machine, intf->k055555); k054338->alphainverted = intf->alpha_inv; @@ -8480,7 +8465,7 @@ struct _k053250_state int page; int frame, offsx, offsy; - running_device *screen; + screen_device *screen; }; /***************************************************************************** @@ -8490,17 +8475,16 @@ struct _k053250_state INLINE k053250_state *k053250_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K053250); + assert(device->type() == K053250); - return (k053250_state *)device->token; + return (k053250_state *)downcast(device)->token(); } INLINE const k053250_interface *k053250_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K053250)); - return (const k053250_interface *) device->baseconfig().static_config; + assert((device->type() == K053250)); + return (const k053250_interface *) device->baseconfig().static_config(); } @@ -8515,7 +8499,7 @@ void k053250_dma( running_device *device, int limiter ) k053250_state *k053250 = k053250_get_safe_token(device); int last_frame, current_frame; - current_frame = video_screen_get_frame_number(k053250->screen); + current_frame = k053250->screen->frame_number(); last_frame = k053250->frame; if (limiter && current_frame == last_frame) @@ -8981,7 +8965,7 @@ static DEVICE_START( k053250 ) k053250->base = memory_region(device->machine, intf->gfx_memory_region); k053250->rommask = memory_region_length(device->machine, intf->gfx_memory_region); - k053250->screen = devtag_get_device(device->machine, intf->screen); + k053250->screen = device->machine->device(intf->screen); k053250->ram = auto_alloc_array(device->machine, UINT16, 0x6000 / 2); @@ -9034,10 +9018,9 @@ struct _k053252_state INLINE k053252_state *k053252_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K053252); + assert(device->type() == K053252); - return (k053252_state *)device->token; + return (k053252_state *)downcast(device)->token(); } /***************************************************************************** @@ -9102,7 +9085,7 @@ static DEVICE_RESET( k053252 ) typedef struct _k001006_state k001006_state; struct _k001006_state { - running_device *screen; + screen_device *screen; UINT16 * pal_ram; UINT16 * unknown_ram; @@ -9121,17 +9104,16 @@ struct _k001006_state INLINE k001006_state *k001006_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K001006); + assert(device->type() == K001006); - return (k001006_state *)device->token; + return (k001006_state *)downcast(device)->token(); } INLINE const k001006_interface *k001006_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K001006)); - return (const k001006_interface *) device->baseconfig().static_config; + assert((device->type() == K001006)); + return (const k001006_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -9287,7 +9269,7 @@ struct _poly_extra_data typedef struct _k001005_state k001005_state; struct _k001005_state { - running_device *screen; + screen_device *screen; running_device *cpu; running_device *dsp; running_device *k001006_1; @@ -9332,17 +9314,16 @@ static const int decode_y_zr107[16] = { 0, 8, 32, 40, 4, 12, 36, 44, 64, 72, 96 INLINE k001005_state *k001005_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K001005); + assert(device->type() == K001005); - return (k001005_state *)device->token; + return (k001005_state *)downcast(device)->token(); } INLINE const k001005_interface *k001005_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K001005)); - return (const k001005_interface *) device->baseconfig().static_config; + assert((device->type() == K001005)); + return (const k001005_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -9680,7 +9661,7 @@ static void k001005_render_polygons( running_device *device ) k001005_state *k001005 = k001005_get_safe_token(device); int i, j; #if POLY_DEVICE - const rectangle *visarea = video_screen_get_visible_area(k001005->screen); + const rectangle &visarea = k001005->screen->visible_area(); #endif // mame_printf_debug("k001005->fifo_ptr = %08X\n", k001005->_3d_fifo_ptr); @@ -9723,9 +9704,9 @@ static void k001005_render_polygons( running_device *device ) extra->color = color; #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); -// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, 4, v); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); +// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, 4, v); #endif i = index - 1; } @@ -9831,13 +9812,13 @@ static void k001005_render_polygons( running_device *device ) if (num_verts < 3) { #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &v[0], &v[1]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &v[0], &v[1]); if (k001005->prev_poly_type) - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &k001005->prev_v[3], &v[0]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &k001005->prev_v[3], &v[0]); // if (k001005->prev_poly_type) -// poly_render_quad(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &k001005->prev_v[3], &v[0], &v[1]); +// poly_render_quad(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &k001005->prev_v[3], &v[0], &v[1]); // else -// poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &v[0], &v[1]); +// poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &k001005->prev_v[2], &v[0], &v[1]); #endif memcpy(&k001005->prev_v[0], &k001005->prev_v[2], sizeof(poly_vertex)); memcpy(&k001005->prev_v[1], &k001005->prev_v[3], sizeof(poly_vertex)); @@ -9847,10 +9828,10 @@ static void k001005_render_polygons( running_device *device ) else { #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); if (num_verts > 3) - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); -// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, num_verts, v); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); +// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, num_verts, v); #endif memcpy(k001005->prev_v, v, sizeof(poly_vertex) * 4); } @@ -9935,10 +9916,10 @@ static void k001005_render_polygons( running_device *device ) extra->color = color; #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &v[0], &v[1], &v[2]); if (new_verts > 1) - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); -// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline_tex, 4, new_verts + 2, v); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, &v[2], &v[3], &v[0]); +// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline_tex, 4, new_verts + 2, v); #endif memcpy(k001005->prev_v, v, sizeof(poly_vertex) * 4); }; @@ -9995,10 +9976,10 @@ static void k001005_render_polygons( running_device *device ) extra->color = color; #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); if (num_verts > 3) - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[2], &v[3], &v[0]); -// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, num_verts, v); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[2], &v[3], &v[0]); +// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, num_verts, v); #endif memcpy(k001005->prev_v, v, sizeof(poly_vertex) * 4); @@ -10055,10 +10036,10 @@ static void k001005_render_polygons( running_device *device ) extra->color = color; #if POLY_DEVICE - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[1], &v[2]); if (new_verts > 1) - poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); -// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], visarea, draw_scanline, 1, new_verts + 2, v); + poly_render_triangle(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, &v[0], &v[2], &v[3]); +// poly_render_polygon(k001005->poly, k001005->bitmap[k001005->bitmap_page], &visarea, draw_scanline, 1, new_verts + 2, v); #endif memcpy(k001005->prev_v, v, sizeof(poly_vertex) * 4); }; @@ -10120,15 +10101,15 @@ static DEVICE_START( k001005 ) k001005->k001006_1 = devtag_get_device(device->machine, intf->k001006_1); k001005->k001006_2 = devtag_get_device(device->machine, intf->k001006_2); - k001005->screen = devtag_get_device(device->machine, intf->screen); - width = video_screen_get_width(k001005->screen); - height = video_screen_get_height(k001005->screen); + k001005->screen = device->machine->device(intf->screen); + width = k001005->screen->width(); + height = k001005->screen->height(); k001005->zbuffer = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED32); k001005->gfxrom = memory_region(device->machine, intf->gfx_memory_region); - k001005->bitmap[0] = video_screen_auto_bitmap_alloc(k001005->screen); - k001005->bitmap[1] = video_screen_auto_bitmap_alloc(k001005->screen); + k001005->bitmap[0] = k001005->screen->alloc_compatible_bitmap(); + k001005->bitmap[1] = k001005->screen->alloc_compatible_bitmap(); k001005->texture = auto_alloc_array(device->machine, UINT8, 0x800000); @@ -10201,7 +10182,7 @@ static DEVICE_STOP( k001005 ) typedef struct _k001604_state k001604_state; struct _k001604_state { - running_device *screen; + screen_device *screen; tilemap_t *layer_8x8[2]; tilemap_t *layer_roz[2]; int gfx_index[2]; @@ -10225,17 +10206,16 @@ struct _k001604_state INLINE k001604_state *k001604_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K001604); + assert(device->type() == K001604); - return (k001604_state *)device->token; + return (k001604_state *)downcast(device)->token(); } INLINE const k001604_interface *k001604_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K001604)); - return (const k001604_interface *) device->baseconfig().static_config; + assert((device->type() == K001604)); + return (const k001604_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -10620,7 +10600,7 @@ static DEVICE_RESET( k001604 ) typedef struct _k037122_state k037122_state; struct _k037122_state { - running_device *screen; + screen_device *screen; tilemap_t *layer[2]; int gfx_index; @@ -10639,17 +10619,16 @@ struct _k037122_state INLINE k037122_state *k037122_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == K037122); + assert(device->type() == K037122); - return (k037122_state *)device->token; + return (k037122_state *)downcast(device)->token(); } INLINE const k037122_interface *k037122_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == K037122)); - return (const k037122_interface *) device->baseconfig().static_config; + assert((device->type() == K037122)); + return (const k037122_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -10703,18 +10682,18 @@ static TILE_GET_INFO_DEVICE( k037122_tile_info_layer1 ) void k037122_tile_draw( running_device *device, bitmap_t *bitmap, const rectangle *cliprect ) { k037122_state *k037122 = k037122_get_safe_token(device); - const rectangle *visarea = video_screen_get_visible_area(k037122->screen); + const rectangle &visarea = k037122->screen->visible_area(); if (k037122->reg[0xc] & 0x10000) { - tilemap_set_scrolldx(k037122->layer[1], visarea->min_x, visarea->min_x); - tilemap_set_scrolldy(k037122->layer[1], visarea->min_y, visarea->min_y); + tilemap_set_scrolldx(k037122->layer[1], visarea.min_x, visarea.min_x); + tilemap_set_scrolldy(k037122->layer[1], visarea.min_y, visarea.min_y); tilemap_draw(bitmap, cliprect, k037122->layer[1], 0, 0); } else { - tilemap_set_scrolldx(k037122->layer[0], visarea->min_x, visarea->min_x); - tilemap_set_scrolldy(k037122->layer[0], visarea->min_y, visarea->min_y); + tilemap_set_scrolldx(k037122->layer[0], visarea.min_x, visarea.min_x); + tilemap_set_scrolldy(k037122->layer[0], visarea.min_y, visarea.min_y); tilemap_draw(bitmap, cliprect, k037122->layer[0], 0, 0); } } @@ -10821,7 +10800,7 @@ static DEVICE_START( k037122 ) k037122_state *k037122 = k037122_get_safe_token(device); const k037122_interface *intf = k037122_get_interface(device); - k037122->screen = devtag_get_device(device->machine, intf->screen); + k037122->screen = device->machine->device(intf->screen); k037122->gfx_index = intf->gfx_index; k037122->char_ram = auto_alloc_array(device->machine, UINT32, 0x200000 / 4); @@ -10944,7 +10923,6 @@ DEVICE_GET_INFO( k007121 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k007121_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k007121); break; @@ -10967,7 +10945,6 @@ DEVICE_GET_INFO( k007342 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k007342_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k007342); break; @@ -10990,7 +10967,6 @@ DEVICE_GET_INFO( k007420 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k007420_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k007420); break; @@ -11013,7 +10989,6 @@ DEVICE_GET_INFO( k052109 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k052109_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k052109); break; @@ -11035,7 +11010,6 @@ DEVICE_GET_INFO( k051960 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k051960_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k051960); break; @@ -11057,7 +11031,6 @@ DEVICE_GET_INFO( k05324x ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k05324x_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k05324x); break; @@ -11079,7 +11052,6 @@ DEVICE_GET_INFO( k053247 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053247_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053247); break; @@ -11101,7 +11073,6 @@ DEVICE_GET_INFO( k055673 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053247_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k055673); break; @@ -11123,7 +11094,6 @@ DEVICE_GET_INFO( k051316 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k051316_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k051316); break; @@ -11145,7 +11115,6 @@ DEVICE_GET_INFO( k053936 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053936_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053936); break; @@ -11167,7 +11136,6 @@ DEVICE_GET_INFO( k053251 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053251_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053251); break; @@ -11189,7 +11157,6 @@ DEVICE_GET_INFO( k054000 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k054000_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k054000); break; @@ -11211,7 +11178,6 @@ DEVICE_GET_INFO( k051733 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k051733_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k051733); break; @@ -11233,7 +11199,6 @@ DEVICE_GET_INFO( k056832 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k056832_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k056832); break; @@ -11255,7 +11220,6 @@ DEVICE_GET_INFO( k055555 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k055555_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k055555); break; @@ -11277,7 +11241,6 @@ DEVICE_GET_INFO( k054338 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k054338_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k054338); break; @@ -11299,7 +11262,6 @@ DEVICE_GET_INFO( k053250 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053250_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053250); break; @@ -11321,7 +11283,6 @@ DEVICE_GET_INFO( k053252 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k053252_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k053252); break; @@ -11343,7 +11304,6 @@ DEVICE_GET_INFO( k001006 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k001006_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k001006); break; @@ -11366,7 +11326,6 @@ DEVICE_GET_INFO( k001005 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k001005_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k001005); break; @@ -11389,7 +11348,6 @@ DEVICE_GET_INFO( k001604 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k001604_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k001604); break; @@ -11412,7 +11370,6 @@ DEVICE_GET_INFO( k037122 ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(k037122_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k037122); break; diff --git a/src/mame/video/konicdev.h b/src/mame/video/konicdev.h index 9bb63036890..789169aa6a3 100644 --- a/src/mame/video/konicdev.h +++ b/src/mame/video/konicdev.h @@ -6,7 +6,11 @@ **************************************************************************/ -#include "devcb.h" +#pragma once +#ifndef __KONICDEV_H__ +#define __KONICDEV_H__ + +#include "devlegcy.h" /*************************************************************************** @@ -162,70 +166,55 @@ struct _k037122_interface int gfx_index; }; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( k007121 ); -DEVICE_GET_INFO( k007342 ); -DEVICE_GET_INFO( k007420 ); -DEVICE_GET_INFO( k052109 ); -DEVICE_GET_INFO( k051960 ); -DEVICE_GET_INFO( k05324x ); -DEVICE_GET_INFO( k053247 ); -DEVICE_GET_INFO( k055673 ); -DEVICE_GET_INFO( k051316 ); -DEVICE_GET_INFO( k053936 ); -DEVICE_GET_INFO( k053251 ); -DEVICE_GET_INFO( k054000 ); -DEVICE_GET_INFO( k051733 ); -DEVICE_GET_INFO( k056832 ); -DEVICE_GET_INFO( k055555 ); -DEVICE_GET_INFO( k054338 ); -DEVICE_GET_INFO( k053250 ); -DEVICE_GET_INFO( k053252 ); -DEVICE_GET_INFO( k001006 ); -DEVICE_GET_INFO( k001005 ); -DEVICE_GET_INFO( k001604 ); -DEVICE_GET_INFO( k037122 ); +DECLARE_LEGACY_DEVICE(K007121, k007121); +DECLARE_LEGACY_DEVICE(K007342, k007342); +DECLARE_LEGACY_DEVICE(K007420, k007420); +DECLARE_LEGACY_DEVICE(K052109, k052109); +DECLARE_LEGACY_DEVICE(K051960, k051960); +DECLARE_LEGACY_DEVICE(K053244, k05324x); +DECLARE_LEGACY_DEVICE(K053245, k05324x); +DECLARE_LEGACY_DEVICE(K053246, k053247); +DECLARE_LEGACY_DEVICE(K053247, k053247); +DECLARE_LEGACY_DEVICE(K055673, k055673); +DECLARE_LEGACY_DEVICE(K051316, k051316); +DECLARE_LEGACY_DEVICE(K053936, k053936); +DECLARE_LEGACY_DEVICE(K053251, k053251); +DECLARE_LEGACY_DEVICE(K054000, k054000); +DECLARE_LEGACY_DEVICE(K051733, k051733); +DECLARE_LEGACY_DEVICE(K056832, k056832); +DECLARE_LEGACY_DEVICE(K055555, k055555); +DECLARE_LEGACY_DEVICE(K054338, k054338); +DECLARE_LEGACY_DEVICE(K053250, k053250); +DECLARE_LEGACY_DEVICE(K053252, k053252); +DECLARE_LEGACY_DEVICE(K001006, k001006); +DECLARE_LEGACY_DEVICE(K001005, k001005); +DECLARE_LEGACY_DEVICE(K001604, k001604); +DECLARE_LEGACY_DEVICE(K037122, k037122); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define K007121 DEVICE_GET_INFO_NAME( k007121 ) - #define MDRV_K007121_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K007121, 0) -#define K007342 DEVICE_GET_INFO_NAME( k007342 ) - #define MDRV_K007342_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K007342, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K007420 DEVICE_GET_INFO_NAME( k007420 ) - #define MDRV_K007420_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K007420, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K052109 DEVICE_GET_INFO_NAME( k052109 ) - #define MDRV_K052109_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K052109, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K051960 DEVICE_GET_INFO_NAME( k051960 ) - #define MDRV_K051960_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K051960, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053244 DEVICE_GET_INFO_NAME( k05324x ) -#define K053245 DEVICE_GET_INFO_NAME( k05324x ) - #define MDRV_K053244_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K053244, 0) \ MDRV_DEVICE_CONFIG(_interface) @@ -234,9 +223,6 @@ DEVICE_GET_INFO( k037122 ); MDRV_DEVICE_ADD(_tag, K053245, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053246 DEVICE_GET_INFO_NAME( k053247 ) -#define K053247 DEVICE_GET_INFO_NAME( k053247 ) - #define MDRV_K053246_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K053246, 0) \ MDRV_DEVICE_CONFIG(_interface) @@ -245,91 +231,61 @@ DEVICE_GET_INFO( k037122 ); MDRV_DEVICE_ADD(_tag, K053247, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K055673 DEVICE_GET_INFO_NAME( k055673 ) - #define MDRV_K055673_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K055673, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K051316 DEVICE_GET_INFO_NAME( k051316 ) - #define MDRV_K051316_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K051316, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053936 DEVICE_GET_INFO_NAME( k053936 ) - #define MDRV_K053936_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K053936, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053251 DEVICE_GET_INFO_NAME( k053251 ) - #define MDRV_K053251_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K053251, 0) -#define K054000 DEVICE_GET_INFO_NAME( k054000 ) - #define MDRV_K054000_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K054000, 0) -#define K051733 DEVICE_GET_INFO_NAME( k051733 ) - #define MDRV_K051733_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K051733, 0) -#define K056832 DEVICE_GET_INFO_NAME( k056832 ) - #define MDRV_K056832_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K056832, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K055555 DEVICE_GET_INFO_NAME( k055555 ) - #define MDRV_K055555_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K055555, 0) -#define K054338 DEVICE_GET_INFO_NAME( k054338 ) - #define MDRV_K054338_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K054338, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053250 DEVICE_GET_INFO_NAME( k053250 ) - #define MDRV_K053250_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K053250, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K053252 DEVICE_GET_INFO_NAME( k053252 ) - #define MDRV_K053252_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, K053252, 0) -#define K001006 DEVICE_GET_INFO_NAME( k001006 ) - #define MDRV_K001006_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K001006, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K001005 DEVICE_GET_INFO_NAME( k001005 ) - #define MDRV_K001005_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K001005, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K001604 DEVICE_GET_INFO_NAME( k001604 ) - #define MDRV_K001604_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K001604, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define K037122 DEVICE_GET_INFO_NAME( k037122 ) - #define MDRV_K037122_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, K037122, 0) \ MDRV_DEVICE_CONFIG(_interface) @@ -852,3 +808,5 @@ READ32_DEVICE_HANDLER( k053247_reg_long_r ); // OBJSET2 READ32_DEVICE_HANDLER( k055555_long_r ); // PCU2 READ16_DEVICE_HANDLER( k053244_reg_word_r ); // OBJSET0 + +#endif diff --git a/src/mame/video/labyrunr.c b/src/mame/video/labyrunr.c index 891a8a84e07..bffdae1840b 100644 --- a/src/mame/video/labyrunr.c +++ b/src/mame/video/labyrunr.c @@ -140,10 +140,10 @@ VIDEO_START( labyrunr ) tilemap_set_transparent_pen(state->layer0, 0); tilemap_set_transparent_pen(state->layer1, 0); - state->clip0 = *video_screen_get_visible_area(machine->primary_screen); + state->clip0 = machine->primary_screen->visible_area(); state->clip0.min_x += 40; - state->clip1 = *video_screen_get_visible_area(machine->primary_screen); + state->clip1 = machine->primary_screen->visible_area(); state->clip1.max_x = 39; state->clip1.min_x = 0; diff --git a/src/mame/video/leland.c b/src/mame/video/leland.c index a65d859c92b..cb126adb7fd 100644 --- a/src/mame/video/leland.c +++ b/src/mame/video/leland.c @@ -66,7 +66,7 @@ static TIMER_CALLBACK( scanline_callback ) scanline = (scanline+1) % 256; /* come back at the next appropriate scanline */ - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -83,7 +83,7 @@ static VIDEO_START( leland ) /* scanline timer */ scanline_timer = timer_alloc(machine, scanline_callback, NULL); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -107,9 +107,9 @@ static VIDEO_START( ataxx ) WRITE8_HANDLER( leland_scroll_w ) { - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); if (scanline > 0) - video_screen_update_partial(space->machine->primary_screen, scanline - 1); + space->machine->primary_screen->update_partial(scanline - 1); /* adjust the proper scroll value */ switch (offset) @@ -139,7 +139,7 @@ WRITE8_HANDLER( leland_scroll_w ) WRITE8_DEVICE_HANDLER( leland_gfx_port_w ) { - video_screen_update_partial(device->machine->primary_screen, video_screen_get_vpos(device->machine->primary_screen)); + device->machine->primary_screen->update_partial(device->machine->primary_screen->vpos()); gfxbank = data; } @@ -225,9 +225,9 @@ static void leland_vram_port_w(const address_space *space, int offset, int data, /* don't fully understand why this is needed. Isn't the video RAM just one big RAM? */ - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); if (scanline > 0) - video_screen_update_partial(space->machine->primary_screen, scanline - 1); + space->machine->primary_screen->update_partial(scanline - 1); if (LOG_COMM && addr >= 0xf000) logerror("%s:%s comm write %04X = %02X\n", cpuexec_describe_context(space->machine), num ? "slave" : "master", addr, data); diff --git a/src/mame/video/lemmings.c b/src/mame/video/lemmings.c index e412a1d839f..a9c99a08119 100644 --- a/src/mame/video/lemmings.c +++ b/src/mame/video/lemmings.c @@ -30,7 +30,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spritedata[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spritedata[offs + 2]; @@ -87,7 +87,7 @@ static TILE_GET_INFO( get_tile_info ) VIDEO_START( lemmings ) { lemmings_state *state = (lemmings_state *)machine->driver_data; - state->bitmap0 = auto_bitmap_alloc(machine, 2048, 256, video_screen_get_format(machine->primary_screen)); + state->bitmap0 = auto_bitmap_alloc(machine, 2048, 256, machine->primary_screen->format()); state->vram_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_cols, 8, 8, 64, 32); state->vram_buffer = auto_alloc_array(machine, UINT8, 2048 * 64); /* 64 bytes per VRAM character */ diff --git a/src/mame/video/lethalj.c b/src/mame/video/lethalj.c index fd558803474..c1e9a92ec28 100644 --- a/src/mame/video/lethalj.c +++ b/src/mame/video/lethalj.c @@ -36,9 +36,9 @@ static UINT8 blank_palette; INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int *y) { static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" }; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - int width = visarea->max_x + 1 - visarea->min_x; - int height = visarea->max_y + 1 - visarea->min_y; + const rectangle &visarea = machine->primary_screen->visible_area(); + int width = visarea.max_x + 1 - visarea.min_x; + int height = visarea.max_y + 1 - visarea.min_y; *x = ((input_port_read_safe(machine, gunnames[player * 2], 0x00) & 0xff) * width) / 255; *y = ((input_port_read_safe(machine, gunnames[1 + player * 2], 0x00) & 0xff) * height) / 255; @@ -181,7 +181,7 @@ WRITE16_HANDLER( lethalj_blitter_w ) * *************************************/ -void lethalj_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void lethalj_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *src = &screenram[(vispage << 17) | ((params->rowaddr << 9) & 0x3fe00)]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); @@ -193,7 +193,7 @@ void lethalj_scanline_update(running_device *screen, bitmap_t *bitmap, int scanl { for (x = params->heblnk; x < params->hsblnk; x++) dest[x] = 0x7fff; - if (scanline == video_screen_get_visible_area(screen)->max_y) + if (scanline == screen.visible_area().max_y) blank_palette = 0; return; } diff --git a/src/mame/video/liberatr.c b/src/mame/video/liberatr.c index c60cb795b08..c47d780c533 100644 --- a/src/mame/video/liberatr.c +++ b/src/mame/video/liberatr.c @@ -243,7 +243,7 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan /* calculate the bitmap's x coordinate for the western horizon center of bitmap - (the number of planet pixels) / 4 */ - *buffer++ = (video_screen_get_width(machine->primary_screen) / 2) - ((line->max_x + 2) / 4); + *buffer++ = (machine->primary_screen->width() / 2) - ((line->max_x + 2) / 4); for (i = 0; i < segment_count; i++) { diff --git a/src/mame/video/lockon.c b/src/mame/video/lockon.c index 8f1b51e4efa..89926051c66 100644 --- a/src/mame/video/lockon.c +++ b/src/mame/video/lockon.c @@ -69,7 +69,7 @@ static TIMER_CALLBACK( cursor_callback ) if (state->main_inten) cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, 0xff); - timer_adjust_oneshot(state->cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(state->cursor_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); } /************************************* @@ -922,7 +922,7 @@ VIDEO_START( lockon ) /* Timer for the CRTC cursor pulse */ state->cursor_timer = timer_alloc(machine, cursor_callback, NULL); - timer_adjust_oneshot(state->cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(state->cursor_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); state_save_register_global_bitmap(machine, state->back_buffer); state_save_register_global_bitmap(machine, state->front_buffer); diff --git a/src/mame/video/lordgun.c b/src/mame/video/lordgun.c index 610f5eb9602..36ed7f9c6e9 100644 --- a/src/mame/video/lordgun.c +++ b/src/mame/video/lordgun.c @@ -141,8 +141,8 @@ static bitmap_t *bitmaps[5]; VIDEO_START( lordgun ) { int i; - int w = video_screen_get_width(machine->primary_screen); - int h = video_screen_get_height(machine->primary_screen); + int w = machine->primary_screen->width(); + int h = machine->primary_screen->height(); // 0x800 x 200 tilemap_0 = tilemap_create( machine, get_tile_info_0, tilemap_scan_rows, @@ -245,17 +245,17 @@ static void lorddgun_calc_gun_scr(running_machine *machine, int i) void lordgun_update_gun(running_machine *machine, int i) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); lordgun_gun[i].hw_x = input_port_read(machine, gunnames[i]); lordgun_gun[i].hw_y = input_port_read(machine, gunnames[i+2]); lorddgun_calc_gun_scr(machine, i); - if ( (lordgun_gun[i].scr_x < visarea->min_x) || - (lordgun_gun[i].scr_x > visarea->max_x) || - (lordgun_gun[i].scr_y < visarea->min_y) || - (lordgun_gun[i].scr_y > visarea->max_y) ) + if ( (lordgun_gun[i].scr_x < visarea.min_x) || + (lordgun_gun[i].scr_x > visarea.max_x) || + (lordgun_gun[i].scr_y < visarea.min_y) || + (lordgun_gun[i].scr_y > visarea.max_y) ) lordgun_gun[i].hw_x = lordgun_gun[i].hw_y = 0; } diff --git a/src/mame/video/m52.c b/src/mame/video/m52.c index f849029cb00..26058e50ade 100644 --- a/src/mame/video/m52.c +++ b/src/mame/video/m52.c @@ -306,7 +306,7 @@ WRITE8_HANDLER( alpha1v_flipscreen_w ) static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xpos, int ypos, int image) { rectangle rect; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); if (flip_screen_get(machine)) { @@ -335,8 +335,8 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re xpos - 256, ypos, 0); - rect.min_x = visarea->min_x; - rect.max_x = visarea->max_x; + rect.min_x = visarea.min_x; + rect.max_x = visarea.max_x; if (flip_screen_get(machine)) { diff --git a/src/mame/video/m58.c b/src/mame/video/m58.c index af2657c4d8b..07b149d5552 100644 --- a/src/mame/video/m58.c +++ b/src/mame/video/m58.c @@ -180,14 +180,14 @@ VIDEO_START( yard ) { irem_z80_state *state = (irem_z80_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); - bitmap_format format = video_screen_get_format(machine->primary_screen); - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); + bitmap_format format = machine->primary_screen->format(); + const rectangle &visarea = machine->primary_screen->visible_area(); state->bg_tilemap = tilemap_create(machine, yard_get_bg_tile_info, yard_tilemap_scan_rows, 8, 8, 64, 32); - tilemap_set_scrolldx(state->bg_tilemap, visarea->min_x, width - (visarea->max_x + 1)); - tilemap_set_scrolldy(state->bg_tilemap, visarea->min_y - 8, height + 16 - (visarea->max_y + 1)); + tilemap_set_scrolldx(state->bg_tilemap, visarea.min_x, width - (visarea.max_x + 1)); + tilemap_set_scrolldy(state->bg_tilemap, visarea.min_y - 8, height + 16 - (visarea.max_y + 1)); state->scroll_panel_bitmap = auto_bitmap_alloc(machine, SCROLL_PANEL_WIDTH, height, format); } @@ -223,7 +223,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { irem_z80_state *state = (irem_z80_state *)machine->driver_data; int offs; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4) { @@ -261,8 +261,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta sy2 = sy1 + 0x10; } - DRAW_SPRITE(code1 + 256 * bank, visarea->min_y + sy1) - DRAW_SPRITE(code2 + 256 * bank, visarea->min_y + sy2) + DRAW_SPRITE(code1 + 256 * bank, visarea.min_y + sy1) + DRAW_SPRITE(code2 + 256 * bank, visarea.min_y + sy2) } } @@ -291,16 +291,16 @@ static void draw_panel( running_machine *machine, bitmap_t *bitmap, const rectan 1*8, 31*8-1 }; rectangle clip = flip_screen_get(machine) ? clippanelflip : clippanel; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); int sx = flip_screen_get(machine) ? cliprect->min_x - 8 : cliprect->max_x + 1 - SCROLL_PANEL_WIDTH; int yoffs = flip_screen_get(machine) ? -40 : -16; - clip.min_y += visarea->min_y + yoffs; - clip.max_y += visarea->max_y + yoffs; + clip.min_y += visarea.min_y + yoffs; + clip.max_y += visarea.max_y + yoffs; sect_rect(&clip, cliprect); copybitmap(bitmap, state->scroll_panel_bitmap, flip_screen_get(machine), flip_screen_get(machine), - sx, visarea->min_y + yoffs, &clip); + sx, visarea.min_y + yoffs, &clip); } } diff --git a/src/mame/video/madalien.c b/src/mame/video/madalien.c index 44e9e41a289..9f16e66c43b 100644 --- a/src/mame/video/madalien.c +++ b/src/mame/video/madalien.c @@ -161,7 +161,7 @@ static VIDEO_START( madalien ) tilemap_edge2[i] = tilemap_create(machine, get_tile_info_BG_2, scan_functions[i], 16, 16, tilemap_cols[i], 8); tilemap_set_scrolldx(tilemap_edge2[i], 0, 0x50); - tilemap_set_scrolldy(tilemap_edge2[i], 0, video_screen_get_height(machine->primary_screen) - 256); + tilemap_set_scrolldy(tilemap_edge2[i], 0, machine->primary_screen->height() - 256); } headlight_bitmap = auto_bitmap_alloc(machine, 128, 128, BITMAP_FORMAT_INDEXED16); diff --git a/src/mame/video/madmotor.c b/src/mame/video/madmotor.c index 4a6236512ed..eb49a12dc5d 100644 --- a/src/mame/video/madmotor.c +++ b/src/mame/video/madmotor.c @@ -204,7 +204,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect for (y = 0; y < h; y++) { if ((color & pri_mask) == pri_val && - (!flash || (video_screen_get_frame_number(machine->primary_screen) & 1))) + (!flash || (machine->primary_screen->frame_number() & 1))) drawgfx_transpen(bitmap,cliprect,machine->gfx[3], code - y * incy + h * x, color, diff --git a/src/mame/video/magmax.c b/src/mame/video/magmax.c index 6df4d794aa1..6a48ce58ee5 100644 --- a/src/mame/video/magmax.c +++ b/src/mame/video/magmax.c @@ -78,7 +78,7 @@ VIDEO_START( magmax ) prom_tab = auto_alloc_array(machine, UINT32, 256); /* Allocate temporary bitmap */ - machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + machine->generic.tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); for (i=0; i<256; i++) { diff --git a/src/mame/video/mappy.c b/src/mame/video/mappy.c index 5594c0e9a1f..8e235ba5559 100644 --- a/src/mame/video/mappy.c +++ b/src/mame/video/mappy.c @@ -323,7 +323,7 @@ VIDEO_START( superpac ) mappy_state *state = (mappy_state *)machine->driver_data; state->bg_tilemap = tilemap_create(machine, superpac_get_tile_info,superpac_tilemap_scan,8,8,36,28); - state->sprite_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->sprite_bitmap = machine->primary_screen->alloc_compatible_bitmap(); colortable_configure_tilemap_groups(machine->colortable, state->bg_tilemap, machine->gfx[0], 31); } diff --git a/src/mame/video/matmania.c b/src/mame/video/matmania.c index 4335b63a437..5fb3e31118b 100644 --- a/src/mame/video/matmania.c +++ b/src/mame/video/matmania.c @@ -116,9 +116,9 @@ WRITE8_HANDLER( matmania_paletteram_w ) VIDEO_START( matmania ) { matmania_state *state = (matmania_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); - bitmap_format format = video_screen_get_format(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); + bitmap_format format = machine->primary_screen->format(); /* Mat Mania has a virtual screen twice as large as the visible screen */ state->tmpbitmap = auto_bitmap_alloc(machine, width, 2 * height, format); diff --git a/src/mame/video/mcr68.c b/src/mame/video/mcr68.c index de88f5c59c0..0bb0ff9483b 100644 --- a/src/mame/video/mcr68.c +++ b/src/mame/video/mcr68.c @@ -209,7 +209,7 @@ WRITE16_HANDLER( zwackery_spriteram_w ) static void mcr68_update_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority) { - rectangle sprite_clip = *video_screen_get_visible_area(machine->primary_screen); + rectangle sprite_clip = machine->primary_screen->visible_area(); UINT16 *spriteram16 = machine->generic.spriteram.u16; int offs; diff --git a/src/mame/video/meadows.c b/src/mame/video/meadows.c index 02fbe95303d..a9a7e0b58fb 100644 --- a/src/mame/video/meadows.c +++ b/src/mame/video/meadows.c @@ -63,7 +63,7 @@ WRITE8_HANDLER( meadows_videoram_w ) WRITE8_HANDLER( meadows_spriteram_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); space->machine->generic.spriteram.u8[offset] = data; } diff --git a/src/mame/video/megazone.c b/src/mame/video/megazone.c index 6a341ff2116..f47614aba4e 100644 --- a/src/mame/video/megazone.c +++ b/src/mame/video/megazone.c @@ -105,7 +105,7 @@ WRITE8_HANDLER( megazone_flipscreen_w ) VIDEO_START( megazone ) { megazone_state *state = (megazone_state *)machine->driver_data; - state->tmpbitmap = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); + state->tmpbitmap = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); state_save_register_global_bitmap(machine, state->tmpbitmap); } diff --git a/src/mame/video/mermaid.c b/src/mame/video/mermaid.c index dd0ff38b465..4306451b8f6 100644 --- a/src/mame/video/mermaid.c +++ b/src/mame/video/mermaid.c @@ -165,8 +165,8 @@ VIDEO_START( mermaid ) tilemap_set_scroll_cols(state->fg_tilemap, 32); tilemap_set_transparent_pen(state->fg_tilemap, 0); - state->helper = video_screen_auto_bitmap_alloc(machine->primary_screen); - state->helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->helper = machine->primary_screen->alloc_compatible_bitmap(); + state->helper2 = machine->primary_screen->alloc_compatible_bitmap(); } static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) @@ -243,7 +243,7 @@ static UINT8 collision_check( running_machine *machine, rectangle* rect ) VIDEO_EOF( mermaid ) { mermaid_state *state = (mermaid_state *)machine->driver_data; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); UINT8 *spriteram = state->spriteram; int offs, offs2; @@ -291,14 +291,14 @@ VIDEO_EOF( mermaid ) rect.max_x = sx + machine->gfx[1]->width - 1; rect.max_y = sy + machine->gfx[1]->height - 1; - if (rect.min_x < visarea->min_x) - rect.min_x = visarea->min_x; - if (rect.min_y < visarea->min_y) - rect.min_y = visarea->min_y; - if (rect.max_x > visarea->max_x) - rect.max_x = visarea->max_x; - if (rect.max_y > visarea->max_y) - rect.max_y = visarea->max_y; + if (rect.min_x < visarea.min_x) + rect.min_x = visarea.min_x; + if (rect.min_y < visarea.min_y) + rect.min_y = visarea.min_y; + if (rect.max_x > visarea.max_x) + rect.max_x = visarea.max_x; + if (rect.max_y > visarea.max_y) + rect.max_y = visarea.max_y; // check collision sprite - background @@ -401,14 +401,14 @@ VIDEO_EOF( mermaid ) rect.max_x = sx + machine->gfx[1]->width - 1; rect.max_y = sy + machine->gfx[1]->height - 1; - if (rect.min_x < visarea->min_x) - rect.min_x = visarea->min_x; - if (rect.min_y < visarea->min_y) - rect.min_y = visarea->min_y; - if (rect.max_x > visarea->max_x) - rect.max_x = visarea->max_x; - if (rect.max_y > visarea->max_y) - rect.max_y = visarea->max_y; + if (rect.min_x < visarea.min_x) + rect.min_x = visarea.min_x; + if (rect.min_y < visarea.min_y) + rect.min_y = visarea.min_y; + if (rect.max_x > visarea.max_x) + rect.max_x = visarea.max_x; + if (rect.max_y > visarea.max_y) + rect.max_y = visarea.max_y; // check collision sprite - sprite @@ -489,14 +489,14 @@ VIDEO_EOF( mermaid ) rect.max_x = sx + machine->gfx[1]->width - 1; rect.max_y = sy + machine->gfx[1]->height - 1; - if (rect.min_x < visarea->min_x) - rect.min_x = visarea->min_x; - if (rect.min_y < visarea->min_y) - rect.min_y = visarea->min_y; - if (rect.max_x > visarea->max_x) - rect.max_x = visarea->max_x; - if (rect.max_y > visarea->max_y) - rect.max_y = visarea->max_y; + if (rect.min_x < visarea.min_x) + rect.min_x = visarea.min_x; + if (rect.min_y < visarea.min_y) + rect.min_y = visarea.min_y; + if (rect.max_x > visarea.max_x) + rect.max_x = visarea.max_x; + if (rect.max_y > visarea.max_y) + rect.max_y = visarea.max_y; // check collision sprite - sprite diff --git a/src/mame/video/metro.c b/src/mame/video/metro.c index 0d0030b2cd2..99ec39d2ad1 100644 --- a/src/mame/video/metro.c +++ b/src/mame/video/metro.c @@ -445,8 +445,8 @@ void metro_draw_sprites( running_machine *machine, bitmap_t *bitmap, const recta UINT8 *base_gfx = memory_region(machine, "gfx1"); UINT8 *gfx_max = base_gfx + memory_region_length(machine, "gfx1"); - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); int max_sprites = state->spriteram_size / 8; int sprites = state->videoregs[0x00/2] % max_sprites; @@ -726,8 +726,8 @@ VIDEO_UPDATE( metro ) int pri, layers_ctrl = -1; UINT16 screenctrl = *state->screenctrl; - state->sprite_xoffs = state->videoregs[0x06 / 2] - video_screen_get_width(screen) / 2; - state->sprite_yoffs = state->videoregs[0x04 / 2] - video_screen_get_height(screen) / 2; + state->sprite_xoffs = state->videoregs[0x06 / 2] - screen->width() / 2; + state->sprite_yoffs = state->videoregs[0x04 / 2] - screen->height() / 2; /* The background color is selected by a register */ bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); diff --git a/src/mame/video/micro3d.c b/src/mame/video/micro3d.c index 6928822e9ca..0a98051ba07 100644 --- a/src/mame/video/micro3d.c +++ b/src/mame/video/micro3d.c @@ -64,9 +64,9 @@ VIDEO_RESET( micro3d ) * *************************************/ -void micro3d_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void micro3d_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { - micro3d_state *state = (micro3d_state*)screen->machine->driver_data; + micro3d_state *state = (micro3d_state*)screen.machine->driver_data; UINT16 *src = &state->micro3d_sprite_vram[(params->rowaddr << 8) & 0x7fe00]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); diff --git a/src/mame/video/midtunit.c b/src/mame/video/midtunit.c index 4c0a2a502b3..d910fea0dd3 100644 --- a/src/mame/video/midtunit.c +++ b/src/mame/video/midtunit.c @@ -806,7 +806,7 @@ skipdma: * *************************************/ -void midtunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void midtunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *src = &local_videoram[(params->rowaddr << 9) & 0x3fe00]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); @@ -818,7 +818,7 @@ void midtunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scan dest[x] = src[coladdr++ & 0x1ff] & 0x7fff; } -void midxunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void midxunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT32 fulladdr = ((params->rowaddr << 16) | params->coladdr) >> 3; UINT16 *src = &local_videoram[fulladdr & 0x3fe00]; diff --git a/src/mame/video/midvunit.c b/src/mame/video/midvunit.c index 7c32da5789b..cec69ac0958 100644 --- a/src/mame/video/midvunit.c +++ b/src/mame/video/midvunit.c @@ -60,7 +60,7 @@ static TIMER_CALLBACK( scanline_timer_cb ) if (scanline != -1) { cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline + 1, 0), scanline); + timer_adjust_oneshot(scanline_timer, machine->primary_screen->time_until_pos(scanline + 1), scanline); timer_set(machine, ATTOTIME_IN_HZ(25000000), NULL, -1, scanline_timer_cb); } else @@ -365,7 +365,7 @@ static void process_dma_queue(running_machine *machine) extra->dither = ((dma_data[0] & 0x2000) != 0); /* render as a quad */ - poly_render_quad(poly, dest, video_screen_get_visible_area(machine->primary_screen), callback, textured ? 2 : 0, &vert[0], &vert[1], &vert[2], &vert[3]); + poly_render_quad(poly, dest, &machine->primary_screen->visible_area(), callback, textured ? 2 : 0, &vert[0], &vert[1], &vert[2], &vert[3]); } @@ -420,7 +420,7 @@ WRITE32_HANDLER( midvunit_page_control_w ) video_changed = TRUE; if (LOG_DMA && input_code_pressed(space->machine, KEYCODE_L)) logerror("##########################################################\n"); - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1); } page_control = data; } @@ -448,7 +448,7 @@ WRITE32_HANDLER( midvunit_video_control_w ) /* update the scanline timer */ if (offset == 0) - timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(space->machine->primary_screen, (data & 0x1ff) + 1, 0), data & 0x1ff); + timer_adjust_oneshot(scanline_timer, space->machine->primary_screen->time_until_pos((data & 0x1ff) + 1, 0), data & 0x1ff); /* if something changed, update our parameters */ if (old != video_regs[offset] && video_regs[6] != 0 && video_regs[11] != 0) @@ -460,14 +460,14 @@ WRITE32_HANDLER( midvunit_video_control_w ) visarea.max_x = (video_regs[6] + video_regs[2] - video_regs[5]) % video_regs[6]; visarea.min_y = 0; visarea.max_y = (video_regs[11] + video_regs[7] - video_regs[10]) % video_regs[11]; - video_screen_configure(space->machine->primary_screen, video_regs[6], video_regs[11], &visarea, HZ_TO_ATTOSECONDS(MIDVUNIT_VIDEO_CLOCK / 2) * video_regs[6] * video_regs[11]); + space->machine->primary_screen->configure(video_regs[6], video_regs[11], visarea, HZ_TO_ATTOSECONDS(MIDVUNIT_VIDEO_CLOCK / 2) * video_regs[6] * video_regs[11]); } } READ32_HANDLER( midvunit_scanline_r ) { - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } @@ -571,7 +571,7 @@ VIDEO_UPDATE( midvunit ) /* adjust the offset */ offset += xoffs; - offset += 512 * (cliprect->min_y - video_screen_get_visible_area(screen)->min_y); + offset += 512 * (cliprect->min_y - screen->visible_area().min_y); /* loop over rows */ for (y = cliprect->min_y; y <= cliprect->max_y; y++) diff --git a/src/mame/video/midyunit.c b/src/mame/video/midyunit.c index fd2095cfcab..b35fad0fc41 100644 --- a/src/mame/video/midyunit.c +++ b/src/mame/video/midyunit.c @@ -561,7 +561,7 @@ static TIMER_CALLBACK( autoerase_line ) } -void midyunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) +void midyunit_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params) { UINT16 *src = &local_videoram[(params->rowaddr << 9) & 0x3fe00]; UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0); @@ -573,10 +573,10 @@ void midyunit_scanline_update(running_device *screen, bitmap_t *bitmap, int scan dest[x] = pen_map[src[coladdr++ & 0x1ff]]; /* handle autoerase on the previous line */ - autoerase_line(screen->machine, NULL, params->rowaddr - 1); + autoerase_line(screen.machine, NULL, params->rowaddr - 1); /* if this is the last update of the screen, set a timer to clear out the final line */ /* (since we update one behind) */ - if (scanline == video_screen_get_visible_area(screen)->max_y) - timer_set(screen->machine, video_screen_get_time_until_pos(screen, scanline + 1, 0), NULL, params->rowaddr, autoerase_line); + if (scanline == screen.visible_area().max_y) + timer_set(screen.machine, screen.time_until_pos(scanline + 1, 0), NULL, params->rowaddr, autoerase_line); } diff --git a/src/mame/video/midzeus.c b/src/mame/video/midzeus.c index e11eab13451..e5b7a2b4818 100644 --- a/src/mame/video/midzeus.c +++ b/src/mame/video/midzeus.c @@ -320,7 +320,7 @@ VIDEO_UPDATE( midzeus ) if (!input_code_pressed(screen->machine, KEYCODE_W)) { const void *base = waveram1_ptr_from_expanded_addr(zeusbase[0xcc]); - int xoffs = video_screen_get_visible_area(screen)->min_x; + int xoffs = screen->visible_area().min_x; for (y = cliprect->min_y; y <= cliprect->max_y; y++) { UINT16 *dest = (UINT16 *)bitmap->base + y * bitmap->rowpixels; @@ -373,18 +373,18 @@ READ32_HANDLER( zeus_r ) switch (offset & ~1) { case 0xf0: - result = video_screen_get_hpos(space->machine->primary_screen); + result = space->machine->primary_screen->hpos(); logit = 0; break; case 0xf2: - result = video_screen_get_vpos(space->machine->primary_screen); + result = space->machine->primary_screen->vpos(); logit = 0; break; case 0xf4: result = 6; - if (video_screen_get_vblank(space->machine->primary_screen)) + if (space->machine->primary_screen->vblank()) result |= 0x800; logit = 0; break; @@ -526,7 +526,7 @@ static void zeus_register16_w(running_machine *machine, offs_t offset, UINT16 da { /* writes to register $CC need to force a partial update */ if ((offset & ~1) == 0xcc) - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* write to high part on odd addresses */ if (offset & 1) @@ -550,7 +550,7 @@ static void zeus_register32_w(running_machine *machine, offs_t offset, UINT32 da { /* writes to register $CC need to force a partial update */ if ((offset & ~1) == 0xcc) - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* always write to low word? */ zeusbase[offset & ~1] = data; @@ -717,7 +717,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset) case 0xc6: case 0xc8: case 0xca: - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); { int vtotal = zeusbase[0xca] >> 16; int htotal = zeusbase[0xc6] >> 16; @@ -729,7 +729,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset) visarea.max_y = zeusbase[0xc8] & 0xffff; if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) { - video_screen_configure(machine->primary_screen, htotal, vtotal, &visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); + machine->primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); zeus_cliprect = visarea; zeus_cliprect.max_x -= zeus_cliprect.min_x; zeus_cliprect.min_x = 0; @@ -738,7 +738,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset) break; case 0xcc: - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); log_fifo = input_code_pressed(machine, KEYCODE_L); break; diff --git a/src/mame/video/midzeus2.c b/src/mame/video/midzeus2.c index 2b7c0412a59..31b7d8ac482 100644 --- a/src/mame/video/midzeus2.c +++ b/src/mame/video/midzeus2.c @@ -371,7 +371,7 @@ if (input_code_pressed(screen->machine, KEYCODE_DOWN)) { zbase -= 1.0f; popmessa if (!input_code_pressed(screen->machine, KEYCODE_W)) { const void *base = waveram1_ptr_from_expanded_addr(zeusbase[0x38]); - int xoffs = video_screen_get_visible_area(screen)->min_x; + int xoffs = screen->visible_area().min_x; for (y = cliprect->min_y; y <= cliprect->max_y; y++) { UINT32 *dest = (UINT32 *)bitmap->base + y * bitmap->rowpixels; @@ -439,7 +439,7 @@ READ32_HANDLER( zeus2_r ) /* bits $00080000 is tested in a loop until 0 */ /* bit $00000004 is tested for toggling; probably VBLANK */ result = 0x00; - if (video_screen_get_vblank(space->machine->primary_screen)) + if (space->machine->primary_screen->vblank()) result |= 0x04; break; @@ -450,7 +450,7 @@ READ32_HANDLER( zeus2_r ) case 0x54: /* both upper 16 bits and lower 16 bits seem to be used as vertical counters */ - result = (video_screen_get_vpos(space->machine->primary_screen) << 16) | video_screen_get_vpos(space->machine->primary_screen); + result = (space->machine->primary_screen->vpos() << 16) | space->machine->primary_screen->vpos(); break; } @@ -509,7 +509,7 @@ if (regdata_count[offset] < 256) /* writes to register $CC need to force a partial update */ // if ((offset & ~1) == 0xcc) -// video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); +// machine->primary_screen->update_partial(machine->primary_screen->vpos()); /* always write to low word? */ zeusbase[offset] = data; @@ -560,7 +560,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset, UINT32 case 0x35: case 0x36: case 0x37: - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); { int vtotal = zeusbase[0x37] & 0xffff; int htotal = zeusbase[0x34] >> 16; @@ -572,7 +572,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset, UINT32 visarea.max_y = zeusbase[0x35] & 0xffff; if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) { - video_screen_configure(machine->primary_screen, htotal, vtotal, &visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal))); + machine->primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 4.0 / (htotal * vtotal))); zeus_cliprect = visarea; zeus_cliprect.max_x -= zeus_cliprect.min_x; zeus_cliprect.min_x = 0; @@ -584,7 +584,7 @@ static void zeus_register_update(running_machine *machine, offs_t offset, UINT32 { UINT32 temp = zeusbase[0x38]; zeusbase[0x38] = oldval; - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); log_fifo = input_code_pressed(machine, KEYCODE_L); zeusbase[0x38] = temp; } diff --git a/src/mame/video/mitchell.c b/src/mame/video/mitchell.c index ea9e6597275..2aaf2c8eda7 100644 --- a/src/mame/video/mitchell.c +++ b/src/mame/video/mitchell.c @@ -176,8 +176,8 @@ logerror("PC %04x: pang_gfxctrl_w %02x\n",cpu_get_pc(space->cpu),data); /* bit 3 is unknown (used, e.g. marukin pulses it on the title screen) */ /* bit 4 selects OKI M6295 bank */ - if (state->oki != NULL && sound_get_type(state->oki) == SOUND_OKIM6295) - okim6295_set_bank_base(state->oki, (data & 0x10) ? 0x40000 : 0x00000); + if (state->oki != NULL) + state->oki->set_bank_base((data & 0x10) ? 0x40000 : 0x00000); /* bit 5 is palette RAM bank selector (doesn't apply to mgakuen) */ state->paletteram_bank = data & 0x20; diff --git a/src/mame/video/model1.c b/src/mame/video/model1.c index 1e1bed92ce3..c200c404d6d 100644 --- a/src/mame/video/model1.c +++ b/src/mame/video/model1.c @@ -1160,7 +1160,7 @@ static int get_list_number(void) static void end_frame(running_machine *machine) { - if((listctl[0] & 4) && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if((listctl[0] & 4) && (machine->primary_screen->frame_number() & 1)) listctl[0] ^= 0x40; } diff --git a/src/mame/video/model2.c b/src/mame/video/model2.c index 71e871ddbae..fdc49e167b2 100644 --- a/src/mame/video/model2.c +++ b/src/mame/video/model2.c @@ -2686,21 +2686,16 @@ static bitmap_t *sys24_bitmap = NULL; static void model2_exit(running_machine *machine) { poly_free(poly); - if ( sys24_bitmap != NULL ) - { - bitmap_free( sys24_bitmap ); - sys24_bitmap = NULL; - } } VIDEO_START(model2) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - int width = visarea->max_x - visarea->min_x; - int height = visarea->max_y - visarea->min_y; + const rectangle &visarea = machine->primary_screen->visible_area(); + int width = visarea.max_x - visarea.min_x; + int height = visarea.max_y - visarea.min_y; sys24_tile_vh_start(machine, 0x3fff); - sys24_bitmap = bitmap_alloc(width, height+4, BITMAP_FORMAT_INDEXED16); + sys24_bitmap = auto_alloc(machine, bitmap_t(width, height+4, BITMAP_FORMAT_INDEXED16)); poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), 0); add_exit_callback(machine, model2_exit); diff --git a/src/mame/video/model3.c b/src/mame/video/model3.c index 725baf01ce6..18768082904 100644 --- a/src/mame/video/model3.c +++ b/src/mame/video/model3.c @@ -167,9 +167,9 @@ VIDEO_START( model3 ) poly = poly_alloc(machine, 4000, sizeof(poly_extra_data), 0); add_exit_callback(machine, model3_exit); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); - bitmap3d = video_screen_auto_bitmap_alloc(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); + bitmap3d = machine->primary_screen->alloc_compatible_bitmap(); zbuffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED32); m3_char_ram = auto_alloc_array_clear(machine, UINT64, 0x100000/8); diff --git a/src/mame/video/moo.c b/src/mame/video/moo.c index be5199257c0..65661cf83d1 100644 --- a/src/mame/video/moo.c +++ b/src/mame/video/moo.c @@ -39,7 +39,7 @@ VIDEO_START(moo) { moo_state *state = (moo_state *)machine->driver_data; - assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32); + assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32); state->alpha_enabled = 0; diff --git a/src/mame/video/mrflea.c b/src/mame/video/mrflea.c index 7f6c3607409..ffb14eed4cf 100644 --- a/src/mame/video/mrflea.c +++ b/src/mame/video/mrflea.c @@ -49,7 +49,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect const gfx_element *gfx = machine->gfx[0]; const UINT8 *source = state->spriteram; const UINT8 *finish = source + 0x100; - rectangle clip = *video_screen_get_visible_area(machine->primary_screen); + rectangle clip = machine->primary_screen->visible_area(); clip.max_x -= 24; clip.min_x += 16; diff --git a/src/mame/video/ms32.c b/src/mame/video/ms32.c index 7ed9bf1c618..8c267619816 100644 --- a/src/mame/video/ms32.c +++ b/src/mame/video/ms32.c @@ -102,8 +102,8 @@ static int brt_r,brt_g,brt_b; VIDEO_START( ms32 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); ms32_priram_8 = auto_alloc_array_clear(machine, UINT8, 0x2000); ms32_palram_16 = auto_alloc_array_clear(machine, UINT16, 0x20000); @@ -437,8 +437,8 @@ VIDEO_UPDATE( ms32 ) than are supported here.. I don't know, it will need hw tests I think */ { int xx, yy; - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); const pen_t *paldata = screen->machine->pens; UINT16* srcptr_tile; diff --git a/src/mame/video/munchmo.c b/src/mame/video/munchmo.c index 54bff88e29a..5914e75256b 100644 --- a/src/mame/video/munchmo.c +++ b/src/mame/video/munchmo.c @@ -45,7 +45,7 @@ WRITE8_HANDLER( mnchmobl_flipscreen_w ) VIDEO_START( mnchmobl ) { munchmo_state *state = (munchmo_state *)machine->driver_data; - state->tmpbitmap = auto_bitmap_alloc(machine, 512, 512, video_screen_get_format(machine->primary_screen)); + state->tmpbitmap = auto_bitmap_alloc(machine, 512, 512, machine->primary_screen->format()); } static void draw_status( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) diff --git a/src/mame/video/mustache.c b/src/mame/video/mustache.c index fc6dd809e30..a567421cfec 100644 --- a/src/mame/video/mustache.c +++ b/src/mame/video/mustache.c @@ -98,7 +98,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { rectangle clip = *cliprect; const gfx_element *gfx = machine->gfx[1]; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); UINT8 *spriteram = machine->generic.spriteram.u8; int offs; @@ -115,12 +115,12 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta code+=(attr&0x0c)<<6; if ((control_byte & 0xa)) - clip.max_y = visarea->max_y; + clip.max_y = visarea.max_y; else if (flip_screen_get(machine)) - clip.min_y = visarea->min_y + 56; + clip.min_y = visarea.min_y + 56; else - clip.max_y = visarea->max_y - 56; + clip.max_y = visarea.max_y - 56; if (flip_screen_get(machine)) { diff --git a/src/mame/video/mystston.c b/src/mame/video/mystston.c index a5fa29bb160..bb2fdde0e90 100644 --- a/src/mame/video/mystston.c +++ b/src/mame/video/mystston.c @@ -57,7 +57,7 @@ static TIMER_CALLBACK( interrupt_callback ) scanline = FIRST_INT_VPOS; /* the vertical synch chain is clocked by H256 -- this is probably not important, but oh well */ - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline - 1, INT_HPOS), scanline); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(scanline - 1, INT_HPOS), scanline); } @@ -243,7 +243,7 @@ static VIDEO_RESET( mystston ) { mystston_state *state = (mystston_state *)machine->driver_data; - timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, FIRST_INT_VPOS - 1, INT_HPOS), FIRST_INT_VPOS); + timer_adjust_oneshot(state->interrupt_timer, machine->primary_screen->time_until_pos(FIRST_INT_VPOS - 1, INT_HPOS), FIRST_INT_VPOS); } diff --git a/src/mame/video/n8080.c b/src/mame/video/n8080.c index 9e9abe8c385..0757daf66e0 100644 --- a/src/mame/video/n8080.c +++ b/src/mame/video/n8080.c @@ -183,7 +183,7 @@ VIDEO_UPDATE( spacefev ) 6, /* cyan */ }; - int cycle = video_screen_get_frame_number(screen) / 32; + int cycle = screen->frame_number() / 32; color = ufo_color[cycle % 6]; } @@ -355,7 +355,7 @@ VIDEO_UPDATE( helifire ) VIDEO_EOF( helifire ) { n8080_state *state = (n8080_state *)machine->driver_data; - int n = (video_screen_get_frame_number(machine->primary_screen) >> 1) % sizeof state->helifire_LSFR; + int n = (machine->primary_screen->frame_number() >> 1) % sizeof state->helifire_LSFR; int i; @@ -372,7 +372,7 @@ VIDEO_EOF( helifire ) G |= B; } - if (video_screen_get_frame_number(machine->primary_screen) & 0x04) + if (machine->primary_screen->frame_number() & 0x04) { R |= G; } diff --git a/src/mame/video/naughtyb.c b/src/mame/video/naughtyb.c index 80dcc4552df..be24195b82a 100644 --- a/src/mame/video/naughtyb.c +++ b/src/mame/video/naughtyb.c @@ -133,7 +133,7 @@ VIDEO_START( naughtyb ) palreg = bankreg = 0; /* Naughty Boy has a virtual screen twice as large as the visible screen */ - machine->generic.tmpbitmap = auto_bitmap_alloc(machine,68*8,28*8,video_screen_get_format(machine->primary_screen)); + machine->generic.tmpbitmap = auto_bitmap_alloc(machine,68*8,28*8,machine->primary_screen->format()); } diff --git a/src/mame/video/nbmj8688.c b/src/mame/video/nbmj8688.c index b5614c214eb..98de201d7b7 100644 --- a/src/mame/video/nbmj8688.c +++ b/src/mame/video/nbmj8688.c @@ -561,7 +561,7 @@ static void mbmj8688_gfxdraw(running_machine *machine, int gfxtype) static void common_video_start(running_machine *machine) { - mjsikaku_tmpbitmap = auto_bitmap_alloc(machine, 512, 256, video_screen_get_format(machine->primary_screen)); + mjsikaku_tmpbitmap = auto_bitmap_alloc(machine, 512, 256, machine->primary_screen->format()); mjsikaku_videoram = auto_alloc_array_clear(machine, UINT16, 512 * 256); nbmj8688_clut = auto_alloc_array(machine, UINT8, 0x20); diff --git a/src/mame/video/nbmj8891.c b/src/mame/video/nbmj8891.c index 3907ef062ff..a3438ff5372 100644 --- a/src/mame/video/nbmj8891.c +++ b/src/mame/video/nbmj8891.c @@ -296,8 +296,8 @@ void nbmj8891_vramflip(running_machine *machine, int vram) UINT8 color1, color2; UINT8 *vidram; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (nbmj8891_flipscreen == nbmj8891_flipscreen_old) return; @@ -321,13 +321,13 @@ void nbmj8891_vramflip(running_machine *machine, int vram) static void update_pixel0(running_machine *machine, int x, int y) { - UINT8 color = nbmj8891_videoram0[(y * video_screen_get_width(machine->primary_screen)) + x]; + UINT8 color = nbmj8891_videoram0[(y * machine->primary_screen->width()) + x]; *BITMAP_ADDR16(nbmj8891_tmpbitmap0, y, x) = color; } static void update_pixel1(running_machine *machine, int x, int y) { - UINT8 color = nbmj8891_videoram1[(y * video_screen_get_width(machine->primary_screen)) + x]; + UINT8 color = nbmj8891_videoram1[(y * machine->primary_screen->width()) + x]; *BITMAP_ADDR16(nbmj8891_tmpbitmap1, y, x) = (color == 0x7f) ? 0xff : color; } @@ -339,7 +339,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj8891_gfxdraw(running_machine *machine) { UINT8 *GFX = memory_region(machine, "gfx1"); - int width = video_screen_get_width(machine->primary_screen); + int width = machine->primary_screen->width(); int x, y; int dx1, dx2, dy1, dy2; @@ -497,10 +497,10 @@ VIDEO_START( nbmj8891_1layer ) { UINT8 *CLUT = memory_region(machine, "protection"); int i; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj8891_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj8891_tmpbitmap0 = machine->primary_screen->alloc_compatible_bitmap(); nbmj8891_videoram0 = auto_alloc_array(machine, UINT8, width * height); nbmj8891_palette = auto_alloc_array(machine, UINT8, 0x200); nbmj8891_clut = auto_alloc_array(machine, UINT8, 0x800); @@ -513,11 +513,11 @@ VIDEO_START( nbmj8891_1layer ) VIDEO_START( nbmj8891_2layer ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj8891_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj8891_tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj8891_tmpbitmap0 = machine->primary_screen->alloc_compatible_bitmap(); + nbmj8891_tmpbitmap1 = machine->primary_screen->alloc_compatible_bitmap(); nbmj8891_videoram0 = auto_alloc_array(machine, UINT8, width * height); nbmj8891_videoram1 = auto_alloc_array(machine, UINT8, width * height); nbmj8891_palette = auto_alloc_array(machine, UINT8, 0x200); @@ -537,8 +537,8 @@ VIDEO_UPDATE( nbmj8891 ) if (nbmj8891_screen_refresh) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); nbmj8891_screen_refresh = 0; for (y = 0; y < height; y++) diff --git a/src/mame/video/nbmj8900.c b/src/mame/video/nbmj8900.c index 16ba573cf69..7da8c029cd2 100644 --- a/src/mame/video/nbmj8900.c +++ b/src/mame/video/nbmj8900.c @@ -187,8 +187,8 @@ void nbmj8900_vramflip(running_machine *machine, int vram) int x, y; unsigned char color1, color2; unsigned char *vidram; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (nbmj8900_flipscreen == nbmj8900_flipscreen_old) return; @@ -384,11 +384,11 @@ static void nbmj8900_gfxdraw(running_machine *machine) ******************************************************************************/ VIDEO_START( nbmj8900_2layer ) { - screen_width = video_screen_get_width(machine->primary_screen); - screen_height = video_screen_get_height(machine->primary_screen); + screen_width = machine->primary_screen->width(); + screen_height = machine->primary_screen->height(); - nbmj8900_tmpbitmap0 = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj8900_tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj8900_tmpbitmap0 = machine->primary_screen->alloc_compatible_bitmap(); + nbmj8900_tmpbitmap1 = machine->primary_screen->alloc_compatible_bitmap(); nbmj8900_videoram0 = auto_alloc_array(machine, UINT8, screen_width * screen_height); nbmj8900_videoram1 = auto_alloc_array(machine, UINT8, screen_width * screen_height); nbmj8900_palette = auto_alloc_array(machine, UINT8, 0x200); diff --git a/src/mame/video/nbmj8991.c b/src/mame/video/nbmj8991.c index 26a55528bf2..c9bc28cb364 100644 --- a/src/mame/video/nbmj8991.c +++ b/src/mame/video/nbmj8991.c @@ -155,8 +155,8 @@ static void nbmj8991_vramflip(running_machine *machine) static int nbmj8991_flipscreen_old = 0; int x, y; UINT8 color1, color2; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (nbmj8991_flipscreen == nbmj8991_flipscreen_old) return; @@ -183,7 +183,7 @@ static void nbmj8991_vramflip(running_machine *machine) static void update_pixel(running_machine *machine, int x, int y) { - UINT8 color = nbmj8991_videoram[(y * video_screen_get_width(machine->primary_screen)) + x]; + UINT8 color = nbmj8991_videoram[(y * machine->primary_screen->width()) + x]; *BITMAP_ADDR16(nbmj8991_tmpbitmap, y, x) = color; } @@ -195,7 +195,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj8991_gfxdraw(running_machine *machine) { UINT8 *GFX = memory_region(machine, "gfx1"); - int width = video_screen_get_width(machine->primary_screen); + int width = machine->primary_screen->width(); int x, y; int dx1, dx2, dy; @@ -303,10 +303,10 @@ static void nbmj8991_gfxdraw(running_machine *machine) ******************************************************************************/ VIDEO_START( nbmj8991 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj8991_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj8991_tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); nbmj8991_videoram = auto_alloc_array(machine, UINT8, width * height); nbmj8991_clut = auto_alloc_array(machine, UINT8, 0x800); memset(nbmj8991_videoram, 0x00, (width * height * sizeof(UINT8))); @@ -318,8 +318,8 @@ VIDEO_UPDATE( nbmj8991_type1 ) if (nbmj8991_screen_refresh) { - int width = video_screen_get_width(screen->machine->primary_screen); - int height = video_screen_get_height(screen->machine->primary_screen); + int width = screen->machine->primary_screen->width(); + int height = screen->machine->primary_screen->height(); nbmj8991_screen_refresh = 0; @@ -357,8 +357,8 @@ VIDEO_UPDATE( nbmj8991_type2 ) if (nbmj8991_screen_refresh) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); nbmj8991_screen_refresh = 0; diff --git a/src/mame/video/nbmj9195.c b/src/mame/video/nbmj9195.c index ad855198c25..967689a2b98 100644 --- a/src/mame/video/nbmj9195.c +++ b/src/mame/video/nbmj9195.c @@ -132,7 +132,7 @@ static void nbmj9195_blitter_w(running_machine *machine, int vram, int offset, i break; case 0x01: nbmj9195_scrollx[vram] = (nbmj9195_scrollx[vram] & 0x0100) | data; break; case 0x02: nbmj9195_scrollx[vram] = (nbmj9195_scrollx[vram] & 0x00ff) | ((data << 8) & 0x0100); - new_line = video_screen_get_vpos(machine->primary_screen); + new_line = machine->primary_screen->vpos(); if (nbmj9195_flipscreen[vram]) { for ( ; nbmj9195_scanline[vram] < new_line; nbmj9195_scanline[vram]++) @@ -185,8 +185,8 @@ static void nbmj9195_vramflip(running_machine *machine, int vram) static int nbmj9195_flipscreen_old[VRAM_MAX] = { 0, 0 }; int x, y; UINT16 color1, color2; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (nbmj9195_flipscreen[vram] == nbmj9195_flipscreen_old[vram]) return; @@ -221,7 +221,7 @@ static void nbmj9195_vramflip(running_machine *machine, int vram) static void update_pixel(running_machine *machine, int vram, int x, int y) { - UINT16 color = nbmj9195_videoram[vram][(y * video_screen_get_width(machine->primary_screen)) + x]; + UINT16 color = nbmj9195_videoram[vram][(y * machine->primary_screen->width()) + x]; *BITMAP_ADDR16(nbmj9195_tmpbitmap[vram], y, x) = color; } @@ -233,7 +233,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void nbmj9195_gfxdraw(running_machine *machine, int vram) { UINT8 *GFX = memory_region(machine, "gfx1"); - int width = video_screen_get_width(machine->primary_screen); + int width = machine->primary_screen->width(); int x, y; int dx1, dx2, dy; @@ -409,10 +409,10 @@ WRITE8_HANDLER( nbmj9195_clut_1_w ) { nbmj9195_clut_w(1, offset, data); } ******************************************************************************/ VIDEO_START( nbmj9195_1layer ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj9195_tmpbitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); nbmj9195_videoram[0] = auto_alloc_array_clear(machine, UINT16, width * height); nbmj9195_palette = auto_alloc_array(machine, UINT8, 0x200); nbmj9195_clut[0] = auto_alloc_array(machine, UINT8, 0x1000); @@ -423,11 +423,11 @@ VIDEO_START( nbmj9195_1layer ) VIDEO_START( nbmj9195_2layer ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj9195_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj9195_tmpbitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + nbmj9195_tmpbitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); nbmj9195_videoram[0] = auto_alloc_array_clear(machine, UINT16, width * height); nbmj9195_videoram[1] = auto_alloc_array_clear(machine, UINT16, width * height); nbmj9195_palette = auto_alloc_array(machine, UINT8, 0x200); @@ -440,11 +440,11 @@ VIDEO_START( nbmj9195_2layer ) VIDEO_START( nbmj9195_nb22090 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - nbmj9195_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - nbmj9195_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); + nbmj9195_tmpbitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + nbmj9195_tmpbitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); nbmj9195_videoram[0] = auto_alloc_array_clear(machine, UINT16, width * height); nbmj9195_videoram[1] = auto_alloc_array_clear(machine, UINT16, width * height); nbmj9195_videoworkram[0] = auto_alloc_array_clear(machine, UINT16, width * height); @@ -469,8 +469,8 @@ VIDEO_UPDATE( nbmj9195 ) if (nbmj9195_screen_refresh) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); nbmj9195_screen_refresh = 0; diff --git a/src/mame/video/neogeo.c b/src/mame/video/neogeo.c index 29037a0ff83..51b09880ade 100644 --- a/src/mame/video/neogeo.c +++ b/src/mame/video/neogeo.c @@ -236,7 +236,7 @@ static TIMER_CALLBACK( auto_animation_timer_callback ) else state->auto_animation_frame_counter = state->auto_animation_frame_counter - 1; - timer_adjust_oneshot(state->auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0); + timer_adjust_oneshot(state->auto_animation_timer, machine->primary_screen->time_until_pos(NEOGEO_VSSTART), 0); } @@ -250,7 +250,7 @@ static void create_auto_animation_timer( running_machine *machine ) static void start_auto_animation_timer( running_machine *machine ) { neogeo_state *state = (neogeo_state *)machine->driver_data; - timer_adjust_oneshot(state->auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0); + timer_adjust_oneshot(state->auto_animation_timer, machine->primary_screen->time_until_pos(NEOGEO_VSSTART), 0); } @@ -650,14 +650,14 @@ static TIMER_CALLBACK( sprite_line_timer_callback ) /* we are at the beginning of a scanline - we need to draw the previous scanline and parse the sprites on the current one */ if (scanline != 0) - video_screen_update_partial(machine->primary_screen, scanline - 1); + machine->primary_screen->update_partial(scanline - 1); parse_sprites(machine, scanline); /* let's come back at the beginning of the next line */ scanline = (scanline + 1) % NEOGEO_VTOTAL; - timer_adjust_oneshot(state->sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); + timer_adjust_oneshot(state->sprite_line_timer, machine->primary_screen->time_until_pos(scanline), scanline); } @@ -671,7 +671,7 @@ static void create_sprite_line_timer( running_machine *machine ) static void start_sprite_line_timer( running_machine *machine ) { neogeo_state *state = (neogeo_state *)machine->driver_data; - timer_adjust_oneshot(state->sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); + timer_adjust_oneshot(state->sprite_line_timer, machine->primary_screen->time_until_pos(0), 0); } @@ -768,7 +768,7 @@ static UINT16 get_video_control( running_machine *machine ) */ /* the vertical counter chain goes from 0xf8 - 0x1ff */ - v_counter = video_screen_get_vpos(machine->primary_screen) + 0x100; + v_counter = machine->primary_screen->vpos() + 0x100; if (v_counter >= 0x200) v_counter = v_counter - NEOGEO_VTOTAL; diff --git a/src/mame/video/ninjakd2.c b/src/mame/video/ninjakd2.c index 9be50e22a93..24483285b95 100644 --- a/src/mame/video/ninjakd2.c +++ b/src/mame/video/ninjakd2.c @@ -137,7 +137,7 @@ static void videoram_alloc(running_machine* machine, int const size) robokid_bg2_videoram = auto_alloc_array_clear(machine, UINT8, size); } - sp_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + sp_bitmap = machine->primary_screen->alloc_compatible_bitmap(); } static int stencil_ninjakd2( UINT16 pal ); diff --git a/src/mame/video/niyanpai.c b/src/mame/video/niyanpai.c index 341fd84f979..e029457927b 100644 --- a/src/mame/video/niyanpai.c +++ b/src/mame/video/niyanpai.c @@ -153,8 +153,8 @@ static void niyanpai_vramflip(running_machine *machine, int vram) static int niyanpai_flipscreen_old[VRAM_MAX] = { 0, 0, 0 }; int x, y; UINT16 color1, color2; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (niyanpai_flipscreen[vram] == niyanpai_flipscreen_old[vram]) return; @@ -186,7 +186,7 @@ static void niyanpai_vramflip(running_machine *machine, int vram) static void update_pixel(running_machine *machine, int vram, int x, int y) { - UINT16 color = niyanpai_videoram[vram][(y * video_screen_get_width(machine->primary_screen)) + x]; + UINT16 color = niyanpai_videoram[vram][(y * machine->primary_screen->width()) + x]; *BITMAP_ADDR16(niyanpai_tmpbitmap[vram], y, x) = color; } @@ -198,7 +198,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void niyanpai_gfxdraw(running_machine *machine, int vram) { UINT8 *GFX = memory_region(machine, "gfx1"); - int width = video_screen_get_width(machine->primary_screen); + int width = machine->primary_screen->width(); int x, y; int dx1, dx2, dy; @@ -376,12 +376,12 @@ WRITE16_HANDLER( niyanpai_clutsel_2_w ) { niyanpai_clutsel_w(2, data); } ******************************************************************************/ VIDEO_START( niyanpai ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); - niyanpai_tmpbitmap[0] = video_screen_auto_bitmap_alloc(machine->primary_screen); - niyanpai_tmpbitmap[1] = video_screen_auto_bitmap_alloc(machine->primary_screen); - niyanpai_tmpbitmap[2] = video_screen_auto_bitmap_alloc(machine->primary_screen); + niyanpai_tmpbitmap[0] = machine->primary_screen->alloc_compatible_bitmap(); + niyanpai_tmpbitmap[1] = machine->primary_screen->alloc_compatible_bitmap(); + niyanpai_tmpbitmap[2] = machine->primary_screen->alloc_compatible_bitmap(); niyanpai_videoram[0] = auto_alloc_array_clear(machine, UINT16, width * height); niyanpai_videoram[1] = auto_alloc_array_clear(machine, UINT16, width * height); niyanpai_videoram[2] = auto_alloc_array_clear(machine, UINT16, width * height); @@ -407,8 +407,8 @@ VIDEO_UPDATE( niyanpai ) if (niyanpai_screen_refresh) { - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); niyanpai_screen_refresh = 0; diff --git a/src/mame/video/nmk16.c b/src/mame/video/nmk16.c index 009b9009e7a..8a1fe85efd4 100644 --- a/src/mame/video/nmk16.c +++ b/src/mame/video/nmk16.c @@ -138,7 +138,7 @@ VIDEO_START( bioship ) tilemap_set_transparent_pen(tx_tilemap,15); nmk16_video_init(machine); - background_bitmap = auto_bitmap_alloc(machine,8192,512,video_screen_get_format(machine->primary_screen)); + background_bitmap = auto_bitmap_alloc(machine,8192,512,machine->primary_screen->format()); bioship_background_bank=0; redraw_bitmap = 1; diff --git a/src/mame/video/ojankohs.c b/src/mame/video/ojankohs.c index 815b7f747e0..e6c9c58f803 100644 --- a/src/mame/video/ojankohs.c +++ b/src/mame/video/ojankohs.c @@ -298,7 +298,7 @@ VIDEO_START( ojankoc ) { ojankohs_state *state = (ojankohs_state *)machine->driver_data; - state->tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); state->videoram = auto_alloc_array(machine, UINT8, 0x8000); state->paletteram = auto_alloc_array(machine, UINT8, 0x20); diff --git a/src/mame/video/pacland.c b/src/mame/video/pacland.c index abb4a46eb9a..a9e93325ad4 100644 --- a/src/mame/video/pacland.c +++ b/src/mame/video/pacland.c @@ -202,7 +202,7 @@ VIDEO_START( pacland ) { int color; - fg_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + fg_bitmap = machine->primary_screen->alloc_compatible_bitmap(); bitmap_fill(fg_bitmap, NULL, 0xffff); bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,64,32); diff --git a/src/mame/video/paradise.c b/src/mame/video/paradise.c index 3d1d9a490d8..c9f84b6994b 100644 --- a/src/mame/video/paradise.c +++ b/src/mame/video/paradise.c @@ -158,7 +158,7 @@ VIDEO_START( paradise ) state->tilemap_2 = tilemap_create(machine, get_tile_info_2, tilemap_scan_rows, 8, 8, 0x20, 0x20); /* pixmap */ - state->tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); tilemap_set_transparent_pen(state->tilemap_0, 0x0f); tilemap_set_transparent_pen(state->tilemap_1, 0xff); diff --git a/src/mame/video/pastelg.c b/src/mame/video/pastelg.c index ad14f7244dd..a46734b6b4f 100644 --- a/src/mame/video/pastelg.c +++ b/src/mame/video/pastelg.c @@ -141,8 +141,8 @@ static void pastelg_vramflip(running_machine *machine) static int pastelg_flipscreen_old = 0; int x, y; UINT8 color1, color2; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (pastelg_flipscreen == pastelg_flipscreen_old) return; @@ -168,7 +168,7 @@ static TIMER_CALLBACK( blitter_timer_callback ) static void pastelg_gfxdraw(running_machine *machine) { UINT8 *GFX = memory_region(machine, "gfx1"); - int width = video_screen_get_width(machine->primary_screen); + int width = machine->primary_screen->width(); int x, y; int dx, dy; @@ -294,8 +294,8 @@ static void pastelg_gfxdraw(running_machine *machine) ******************************************************************************/ VIDEO_START( pastelg ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); pastelg_videoram = auto_alloc_array_clear(machine, UINT8, width * height); pastelg_clut = auto_alloc_array(machine, UINT8, 0x10); @@ -310,8 +310,8 @@ VIDEO_UPDATE( pastelg ) if (pastelg_dispflag) { int x, y; - int width = video_screen_get_width(screen); - int height = video_screen_get_height(screen); + int width = screen->width(); + int height = screen->height(); for (y = 0; y < height; y++) for (x = 0; x < width; x++) diff --git a/src/mame/video/pitnrun.c b/src/mame/video/pitnrun.c index 72f7a7535ff..06b7ae9955b 100644 --- a/src/mame/video/pitnrun.c +++ b/src/mame/video/pitnrun.c @@ -170,10 +170,10 @@ VIDEO_START(pitnrun) fg = tilemap_create( machine, get_tile_info1,tilemap_scan_rows,8,8,32,32 ); bg = tilemap_create( machine, get_tile_info2,tilemap_scan_rows,8,8,32*4,32 ); tilemap_set_transparent_pen( fg, 0 ); - tmp_bitmap[0] = auto_bitmap_alloc(machine,128,128,video_screen_get_format(machine->primary_screen)); - tmp_bitmap[1] = auto_bitmap_alloc(machine,128,128,video_screen_get_format(machine->primary_screen)); - tmp_bitmap[2] = auto_bitmap_alloc(machine,128,128,video_screen_get_format(machine->primary_screen)); - tmp_bitmap[3] = auto_bitmap_alloc(machine,128,128,video_screen_get_format(machine->primary_screen)); + tmp_bitmap[0] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format()); + tmp_bitmap[1] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format()); + tmp_bitmap[2] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format()); + tmp_bitmap[3] = auto_bitmap_alloc(machine,128,128,machine->primary_screen->format()); pitnrun_spotlights(machine); } diff --git a/src/mame/video/pktgaldx.c b/src/mame/video/pktgaldx.c index 8e6b0311aac..9cc27e2f5aa 100644 --- a/src/mame/video/pktgaldx.c +++ b/src/mame/video/pktgaldx.c @@ -19,7 +19,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const recta y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/playch10.c b/src/mame/video/playch10.c index 417f6367354..b39766da6f3 100644 --- a/src/mame/video/playch10.c +++ b/src/mame/video/playch10.c @@ -151,7 +151,7 @@ VIDEO_UPDATE( playch10 ) } else /* Single Monitor version */ { - rectangle top_monitor = *video_screen_get_visible_area(screen); + rectangle top_monitor = screen->visible_area(); top_monitor.max_y = ( top_monitor.max_y - top_monitor.min_y ) / 2; diff --git a/src/mame/video/policetr.c b/src/mame/video/policetr.c index 26ada8de1b8..8c41f54b025 100644 --- a/src/mame/video/policetr.c +++ b/src/mame/video/policetr.c @@ -274,8 +274,8 @@ WRITE32_HANDLER( policetr_video_w ) READ32_HANDLER( policetr_video_r ) { int inputval; - int width = video_screen_get_width(space->machine->primary_screen); - int height = video_screen_get_height(space->machine->primary_screen); + int width = space->machine->primary_screen->width(); + int height = space->machine->primary_screen->height(); /* the value read is based on the latch */ switch (video_latch) diff --git a/src/mame/video/popeye.c b/src/mame/video/popeye.c index 3aed000bd20..0fa95cee92d 100644 --- a/src/mame/video/popeye.c +++ b/src/mame/video/popeye.c @@ -247,7 +247,7 @@ static TILE_GET_INFO( get_fg_tile_info ) VIDEO_START( skyskipr ) { popeye_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size); - tmpbitmap2 = auto_bitmap_alloc(machine,1024,1024,video_screen_get_format(machine->primary_screen)); /* actually 1024x512 but not rolling over vertically? */ + tmpbitmap2 = auto_bitmap_alloc(machine,1024,1024,machine->primary_screen->format()); /* actually 1024x512 but not rolling over vertically? */ bitmap_type = TYPE_SKYSKIPR; @@ -264,7 +264,7 @@ VIDEO_START( skyskipr ) VIDEO_START( popeye ) { popeye_bitmapram = auto_alloc_array(machine, UINT8, popeye_bitmapram_size); - tmpbitmap2 = auto_bitmap_alloc(machine,512,512,video_screen_get_format(machine->primary_screen)); + tmpbitmap2 = auto_bitmap_alloc(machine,512,512,machine->primary_screen->format()); bitmap_type = TYPE_POPEYE; diff --git a/src/mame/video/popper.c b/src/mame/video/popper.c index 0e5186ef0c0..6a92e488802 100644 --- a/src/mame/video/popper.c +++ b/src/mame/video/popper.c @@ -201,7 +201,7 @@ VIDEO_START( popper ) tilemap_set_transmask(state->ol_p0_tilemap, 0, 0x0f, 0x0e); tilemap_set_transmask(state->ol_p0_tilemap, 1, 0x0e, 0x0f); - state->tilemap_clip = *video_screen_get_visible_area(machine->primary_screen); + state->tilemap_clip = machine->primary_screen->visible_area(); } static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect ) diff --git a/src/mame/video/powerins.c b/src/mame/video/powerins.c index 503290751e5..eb8cdf26895 100644 --- a/src/mame/video/powerins.c +++ b/src/mame/video/powerins.c @@ -271,8 +271,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan UINT16 *source = machine->generic.spriteram.u16 + 0x8000/2; UINT16 *finish = machine->generic.spriteram.u16 + 0x9000/2; - int screen_w = video_screen_get_width(machine->primary_screen); - int screen_h = video_screen_get_height(machine->primary_screen); + int screen_w = machine->primary_screen->width(); + int screen_h = machine->primary_screen->height(); for ( ; source < finish; source += 16/2 ) { diff --git a/src/mame/video/ppu2c0x.c b/src/mame/video/ppu2c0x.c index d44e0752cf8..9f5d3c8e06f 100644 --- a/src/mame/video/ppu2c0x.c +++ b/src/mame/video/ppu2c0x.c @@ -41,11 +41,6 @@ #define SPRITERAM_MASK (0x100-1) /* spriteram size */ #define CHARGEN_NUM_CHARS 512 /* max number of characters handled by the chargen */ -enum -{ - PPU2C0XINFO_INT_SCANLINES_PER_FRAME = DEVINFO_INT_DEVICE_SPECIFIC -}; - /* default monochromatic colortable */ static const pen_t default_colortable_mono[] = { @@ -81,6 +76,7 @@ static const pen_t default_colortable[] = typedef struct _ppu2c0x_state ppu2c0x_state; struct _ppu2c0x_state { + const address_space *space; /* memory space */ bitmap_t *bitmap; /* target bitmap */ UINT8 *spriteram; /* sprite ram */ pen_t *colortable; /* color table modified at run time */ @@ -114,6 +110,7 @@ struct _ppu2c0x_state int security_value; /* 2C05 protection */ }; + /*************************************************************************** PROTOTYPES ***************************************************************************/ @@ -138,22 +135,22 @@ static READ8_HANDLER( ppu2c0x_palette_read ); INLINE ppu2c0x_state *get_token( running_device *device ) { assert(device != NULL); - assert((device->type == PPU_2C02) || (device->type == PPU_2C03B) - || (device->type == PPU_2C04) || (device->type == PPU_2C05_01) - || (device->type == PPU_2C05_02) || (device->type == PPU_2C05_03) - || (device->type == PPU_2C05_04) || (device->type == PPU_2C07)); - return (ppu2c0x_state *) device->token; + assert((device->type() == PPU_2C02) || (device->type() == PPU_2C03B) + || (device->type() == PPU_2C04) || (device->type() == PPU_2C05_01) + || (device->type() == PPU_2C05_02) || (device->type() == PPU_2C05_03) + || (device->type() == PPU_2C05_04) || (device->type() == PPU_2C07)); + return (ppu2c0x_state *) downcast(device)->token(); } INLINE const ppu2c0x_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == PPU_2C02) || (device->type == PPU_2C03B) - || (device->type == PPU_2C04) || (device->type == PPU_2C05_01) - || (device->type == PPU_2C05_02) || (device->type == PPU_2C05_03) - || (device->type == PPU_2C05_04) || (device->type == PPU_2C07)); - return (const ppu2c0x_interface *) device->baseconfig().static_config; + assert((device->type() == PPU_2C02) || (device->type() == PPU_2C03B) + || (device->type() == PPU_2C04) || (device->type() == PPU_2C05_01) + || (device->type() == PPU_2C05_02) || (device->type() == PPU_2C05_03) + || (device->type() == PPU_2C05_04) || (device->type() == PPU_2C07)); + return (const ppu2c0x_interface *) device->baseconfig().static_config(); } @@ -429,14 +426,14 @@ static void draw_background( running_device *device, UINT8 *line_priority ) pos = ((index1 & 0x380) >> 4) | ((index1 & 0x1f) >> 2); page = (index1 & 0x0c00) >> 10; address = 0x3c0 + pos; - color_byte = memory_read_byte(device->space(), (((page * 0x400) + address) & 0xfff) + 0x2000); + color_byte = memory_read_byte(ppu2c0x->space, (((page * 0x400) + address) & 0xfff) + 0x2000); /* figure out which bits in the color table to use */ color_bits = ((index1 & 0x40) >> 4) + (index1 & 0x02); // page2 is the output of the nametable read (this section is the FIRST read per tile!) address = index1 & 0x3ff; - page2 = memory_read_byte(device->space(), index1); + page2 = memory_read_byte(ppu2c0x->space, index1); // 27/12/2002 if (ppu_latch) @@ -454,8 +451,8 @@ static void draw_background( running_device *device, UINT8 *line_priority ) // plus something that accounts for y address += scroll_y_fine; - plane1 = memory_read_byte(device->space(), (address & 0x1fff)); - plane2 = memory_read_byte(device->space(), (address + 8) & 0x1fff); + plane1 = memory_read_byte(ppu2c0x->space, (address & 0x1fff)); + plane2 = memory_read_byte(ppu2c0x->space, (address + 8) & 0x1fff); /* render the pixel */ for (i = 0; i < 8; i++) @@ -601,8 +598,8 @@ static void draw_sprites( running_device *device, UINT8 *line_priority ) if (size == 8) index1 += ((sprite_page == 0) ? 0 : 0x1000); - plane1 = memory_read_byte(device->space(), (index1 + sprite_line + 0) & 0x1fff); - plane2 = memory_read_byte(device->space(), (index1 + sprite_line + 8) & 0x1fff); + plane1 = memory_read_byte(ppu2c0x->space, (index1 + sprite_line + 0) & 0x1fff); + plane2 = memory_read_byte(ppu2c0x->space, (index1 + sprite_line + 8) & 0x1fff); /* if there are more than 8 sprites on this line, set the flag */ if (sprite_count == 8) @@ -854,7 +851,7 @@ static TIMER_CALLBACK( scanline_callback ) /* increment our scanline count */ ppu2c0x->scanline++; -// logerror("starting scanline %d (MAME %d, beam %d)\n", ppu2c0x->scanline, video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)); +// logerror("starting scanline %d (MAME %d, beam %d)\n", ppu2c0x->scanline, device->machine->primary_screen->vpos(), device->machine->primary_screen->hpos()); /* Note: this is called at the _end_ of each scanline */ if (ppu2c0x->scanline == PPU_VBLANK_FIRST_SCANLINE) @@ -901,7 +898,7 @@ static TIMER_CALLBACK( scanline_callback ) timer_adjust_oneshot(ppu2c0x->hblank_timer, cputag_clocks_to_attotime(device->machine, "maincpu", 86.67), 0); // ??? FIXME - hardcoding NTSC, need better calculation // trigger again at the start of the next scanline - timer_adjust_oneshot(ppu2c0x->scanline_timer, video_screen_get_time_until_pos(device->machine->primary_screen, next_scanline * ppu2c0x->scan_scale, 0), 0); + timer_adjust_oneshot(ppu2c0x->scanline_timer, device->machine->primary_screen->time_until_pos(next_scanline * ppu2c0x->scan_scale), 0); } /************************************* @@ -999,14 +996,14 @@ READ8_DEVICE_HANDLER( ppu2c0x_r ) if (ppu2c0x->videomem_addr >= 0x3f00) { - ppu2c0x->data_latch = memory_read_byte(device->space(), ppu2c0x->videomem_addr); + ppu2c0x->data_latch = memory_read_byte(ppu2c0x->space, ppu2c0x->videomem_addr); // buffer the mirrored NT data - ppu2c0x->buffered_data = memory_read_byte(device->space(), ppu2c0x->videomem_addr & 0x2fff); + ppu2c0x->buffered_data = memory_read_byte(ppu2c0x->space, ppu2c0x->videomem_addr & 0x2fff); } else { ppu2c0x->data_latch = ppu2c0x->buffered_data; - ppu2c0x->buffered_data = memory_read_byte(device->space(), ppu2c0x->videomem_addr); + ppu2c0x->buffered_data = memory_read_byte(ppu2c0x->space, ppu2c0x->videomem_addr); } ppu2c0x->videomem_addr += ppu2c0x->add; @@ -1042,8 +1039,8 @@ WRITE8_DEVICE_HANDLER( ppu2c0x_w ) #ifdef MAME_DEBUG if (ppu2c0x->scanline <= PPU_BOTTOM_VISIBLE_SCANLINE) { - running_device *screen = device->machine->primary_screen; - logerror("PPU register %d write %02x during non-vblank scanline %d (MAME %d, beam pos: %d)\n", offset, data, ppu2c0x->scanline, video_screen_get_vpos(screen), video_screen_get_hpos(screen)); + screen_device *screen = device->machine->primary_screen; + logerror("PPU register %d write %02x during non-vblank scanline %d (MAME %d, beam pos: %d)\n", offset, data, ppu2c0x->scanline, screen->vpos(), screen->hpos()); } #endif @@ -1156,12 +1153,12 @@ WRITE8_DEVICE_HANDLER( ppu2c0x_w ) if (tempAddr < 0x2000) { /* store the data */ - memory_write_byte(device->space(), tempAddr, data); + memory_write_byte(ppu2c0x->space, tempAddr, data); } else { - memory_write_byte(device->space(), tempAddr, data); + memory_write_byte(ppu2c0x->space, tempAddr, data); } /* increment the address */ ppu2c0x->videomem_addr += ppu2c0x->add; @@ -1277,27 +1274,28 @@ static DEVICE_START( ppu2c0x ) const ppu2c0x_interface *intf = get_interface(device); memset(ppu2c0x, 0, sizeof(*ppu2c0x)); - ppu2c0x->scanlines_per_frame = (int) device->get_config_int(PPU2C0XINFO_INT_SCANLINES_PER_FRAME); + ppu2c0x->space = device_get_space(device, 0); + ppu2c0x->scanlines_per_frame = (device->type() != PPU_2C07) ? PPU_NTSC_SCANLINES_PER_FRAME : PPU_PAL_SCANLINES_PER_FRAME; /* usually, no security value... */ ppu2c0x->security_value = 0; /* ...except for VS. games which specific PPU types */ - if (device->type == PPU_2C05_01) + if (device->type() == PPU_2C05_01) ppu2c0x->security_value = 0x1b; // game (jajamaru) doesn't seem to ever actually check it - if (device->type == PPU_2C05_02) + if (device->type() == PPU_2C05_02) ppu2c0x->security_value = 0x3d; - if (device->type == PPU_2C05_03) + if (device->type() == PPU_2C05_03) ppu2c0x->security_value = 0x1c; - if (device->type == PPU_2C05_04) + if (device->type() == PPU_2C05_04) ppu2c0x->security_value = 0x1b; /* initialize the scanline handling portion */ ppu2c0x->scanline_timer = timer_alloc(device->machine, scanline_callback, (void *) device); - timer_adjust_oneshot(ppu2c0x->scanline_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 1, 0), 0); + timer_adjust_oneshot(ppu2c0x->scanline_timer, device->machine->primary_screen->time_until_pos(1), 0); ppu2c0x->hblank_timer = timer_alloc(device->machine, hblank_callback, (void *) device); timer_adjust_oneshot(ppu2c0x->hblank_timer, cputag_clocks_to_attotime(device->machine, "maincpu", 86.67), 0); // ??? FIXME - hardcoding NTSC, need better calculation @@ -1309,7 +1307,7 @@ static DEVICE_START( ppu2c0x ) ppu2c0x->color_base = intf->color_base; /* allocate a screen bitmap, videomem and spriteram, a dirtychar array and the monochromatic colortable */ - ppu2c0x->bitmap = auto_bitmap_alloc(device->machine, VISIBLE_SCREEN_WIDTH, VISIBLE_SCREEN_HEIGHT, video_screen_get_format(device->machine->primary_screen)); + ppu2c0x->bitmap = auto_bitmap_alloc(device->machine, VISIBLE_SCREEN_WIDTH, VISIBLE_SCREEN_HEIGHT, device->machine->primary_screen->format()); ppu2c0x->spriteram = auto_alloc_array_clear(device->machine, UINT8, SPRITERAM_SIZE); ppu2c0x->colortable = auto_alloc_array(device->machine, pen_t, ARRAY_LENGTH(default_colortable)); ppu2c0x->colortable_mono = auto_alloc_array(device->machine, pen_t, ARRAY_LENGTH(default_colortable_mono)); @@ -1404,8 +1402,6 @@ DEVICE_GET_INFO(ppu2c02) /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(ppu2c0x_state); break; case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; - case PPU2C0XINFO_INT_SCANLINES_PER_FRAME: info->i = PPU_NTSC_SCANLINES_PER_FRAME; break; case DEVINFO_INT_DATABUS_WIDTH_0: info->i = 8; break; case DEVINFO_INT_ADDRBUS_WIDTH_0: info->i = 14; break; case DEVINFO_INT_ADDRBUS_SHIFT_0: info->i = 0; break; @@ -1434,7 +1430,6 @@ DEVICE_GET_INFO(ppu2c03b) switch (state) { case DEVINFO_STR_NAME: strcpy(info->s, "2C02B PPU"); break; - case PPU2C0XINFO_INT_SCANLINES_PER_FRAME: info->i = PPU_NTSC_SCANLINES_PER_FRAME; break; default: DEVICE_GET_INFO_CALL(ppu2c02); break; } } @@ -1444,7 +1439,6 @@ DEVICE_GET_INFO(ppu2c04) switch (state) { case DEVINFO_STR_NAME: strcpy(info->s, "2C04 PPU"); break; - case PPU2C0XINFO_INT_SCANLINES_PER_FRAME: info->i = PPU_NTSC_SCANLINES_PER_FRAME; break; default: DEVICE_GET_INFO_CALL(ppu2c02); break; } } @@ -1454,7 +1448,6 @@ DEVICE_GET_INFO(ppu2c05_01) switch (state) { case DEVINFO_STR_NAME: strcpy(info->s, "2C05 PPU"); break; - case PPU2C0XINFO_INT_SCANLINES_PER_FRAME: info->i = PPU_NTSC_SCANLINES_PER_FRAME; break; default: DEVICE_GET_INFO_CALL(ppu2c02); break; } } @@ -1479,7 +1472,6 @@ DEVICE_GET_INFO(ppu2c07) switch (state) { case DEVINFO_STR_NAME: strcpy(info->s, "2C07 PPU"); break; - case PPU2C0XINFO_INT_SCANLINES_PER_FRAME: info->i = PPU_PAL_SCANLINES_PER_FRAME; break; default: DEVICE_GET_INFO_CALL(ppu2c02); break; } } diff --git a/src/mame/video/ppu2c0x.h b/src/mame/video/ppu2c0x.h index 0199b1012e6..b7bedf3ec3c 100644 --- a/src/mame/video/ppu2c0x.h +++ b/src/mame/video/ppu2c0x.h @@ -10,6 +10,8 @@ #ifndef __PPU_2C03B_H__ #define __PPU_2C03B_H__ +#include "devlegcy.h" + /*************************************************************************** CONSTANTS @@ -72,16 +74,6 @@ enum // are non-rendering and non-vblank. }; -#define PPU_2C02 DEVICE_GET_INFO_NAME(ppu2c02) // NTSC NES, Famicom -#define PPU_2C03B DEVICE_GET_INFO_NAME(ppu2c03b) // Vs. Unisystem, Playchoice 10 -#define PPU_2C04 DEVICE_GET_INFO_NAME(ppu2c04) // Vs. Unisystem (four versions with different colors) -/* The PPU_2C05 variants have different protection value, set at DEVICE_START, but otherwise are all the same... */ -#define PPU_2C05_01 DEVICE_GET_INFO_NAME(ppu2c05_01) // Vs. Unisystem (Ninja Jajamaru Kun) -#define PPU_2C05_02 DEVICE_GET_INFO_NAME(ppu2c05_02) // Vs. Unisystem (Mighty Bomb Jack) -#define PPU_2C05_03 DEVICE_GET_INFO_NAME(ppu2c05_03) // Vs. Unisystem (Gumshoe) -#define PPU_2C05_04 DEVICE_GET_INFO_NAME(ppu2c05_04) // Vs. Unisystem (Top Gun) -#define PPU_2C07 DEVICE_GET_INFO_NAME(ppu2c07) // PAL NES - /* callback datatypes */ typedef void (*ppu2c0x_scanline_cb)( running_device *device, int scanline, int vblank, int blanked ); typedef void (*ppu2c0x_hblank_cb)( running_device *device, int scanline, int vblank, int blanked ); @@ -102,14 +94,15 @@ struct _ppu2c0x_interface PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO(ppu2c02); -DEVICE_GET_INFO(ppu2c03b); -DEVICE_GET_INFO(ppu2c04); -DEVICE_GET_INFO(ppu2c05_01); -DEVICE_GET_INFO(ppu2c05_02); -DEVICE_GET_INFO(ppu2c05_03); -DEVICE_GET_INFO(ppu2c05_04); -DEVICE_GET_INFO(ppu2c07); +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C02, ppu2c02); // NTSC NES +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C03B, ppu2c03b); // Playchoice 10 +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C04, ppu2c04); // Vs. Unisystem +// The PPU_2C05 variants have different protection value, set at DEVICE_START, but otherwise are all the same... +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C05_01, ppu2c05_01); // Vs. Unisystem (Ninja Jajamaru Kun) +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C05_02, ppu2c05_02); // Vs. Unisystem (Mighty Bomb Jack) +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C05_03, ppu2c05_03); // Vs. Unisystem (Gumshoe) +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C05_04, ppu2c05_04); // Vs. Unisystem (Top Gun) +DECLARE_LEGACY_MEMORY_DEVICE(PPU_2C07, ppu2c07); // PAL NES /* routines */ void ppu2c0x_init_palette(running_machine *machine, int first_entry ) ATTR_NONNULL(1); @@ -131,6 +124,8 @@ extern void (*ppu_latch)( running_device *device, offs_t offset ); WRITE8_DEVICE_HANDLER( ppu2c0x_w ); READ8_DEVICE_HANDLER( ppu2c0x_r ); +int ppu2c0x_get_scanlines_per_frame( running_device *device ); + /*************************************************************************** DEVICE CONFIGURATION MACROS diff --git a/src/mame/video/psikyo.c b/src/mame/video/psikyo.c index ebe368a1635..334e6259b92 100644 --- a/src/mame/video/psikyo.c +++ b/src/mame/video/psikyo.c @@ -274,8 +274,8 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT int TILES_LEN = memory_region_length(machine, "spritelut"); - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* Exit if sprites are disabled */ if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) return; @@ -396,8 +396,8 @@ static void draw_sprites_bootleg( running_machine *machine, bitmap_t *bitmap, co UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT int TILES_LEN = memory_region_length(machine, "spritelut"); - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* Exit if sprites are disabled */ if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) diff --git a/src/mame/video/psikyo4.c b/src/mame/video/psikyo4.c index 8ef3e29d486..346f2dc0058 100644 --- a/src/mame/video/psikyo4.c +++ b/src/mame/video/psikyo4.c @@ -99,7 +99,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect if ((!scr && flipscreen1) || (scr && flipscreen2)) { - ypos = video_screen_get_visible_area(machine->primary_screen)->max_y + 1 - ypos - high * 16; /* Screen Height depends on game */ + ypos = machine->primary_screen->visible_area().max_y + 1 - ypos - high * 16; /* Screen Height depends on game */ xpos = 40 * 8 - xpos - wide * 16; flipx = !flipx; flipy = !flipy; diff --git a/src/mame/video/psikyosh.c b/src/mame/video/psikyosh.c index a7f87ed7f6f..da0976826e8 100644 --- a/src/mame/video/psikyosh.c +++ b/src/mame/video/psikyosh.c @@ -1254,8 +1254,8 @@ static void psikyosh_postlineblend( running_machine *machine, bitmap_t *bitmap, VIDEO_START( psikyosh ) { psikyosh_state *state = (psikyosh_state *)machine->driver_data; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); state->z_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); /* z-buffer */ state->zoom_bitmap = auto_bitmap_alloc(machine, 16*16, 16*16, BITMAP_FORMAT_INDEXED8); /* temp buffer for assembling sprites */ diff --git a/src/mame/video/psx.c b/src/mame/video/psx.c index 5564b523fc0..78b735ab7e3 100644 --- a/src/mame/video/psx.c +++ b/src/mame/video/psx.c @@ -284,8 +284,8 @@ static struct static void DebugMeshInit( running_machine *machine ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); m_debug.b_mesh = 0; m_debug.b_texture = 0; @@ -302,8 +302,8 @@ static void DebugMesh( int n_coordx, int n_coordy ) running_machine *machine = m_debug.machine; int n_coord; int n_colour; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if( m_debug.b_clear ) { @@ -428,12 +428,12 @@ static void DebugCheckKeys( running_machine *machine ) if( m_debug.b_mesh || m_debug.b_texture ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); - video_screen_set_visarea(machine->primary_screen, 0, width - 1, 0, height - 1 ); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); + machine->primary_screen->set_visible_area( 0, width - 1, 0, height - 1 ); } else - video_screen_set_visarea(machine->primary_screen, 0, m_n_screenwidth - 1, 0, m_n_screenheight - 1 ); + machine->primary_screen->set_visible_area( 0, m_n_screenwidth - 1, 0, m_n_screenheight - 1 ); if( input_code_pressed_once( machine, KEYCODE_I ) ) { @@ -510,8 +510,8 @@ static int DebugTextureDisplay( running_machine *machine, bitmap_t *bitmap ) if( m_debug.b_texture ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); for( n_y = 0; n_y < height; n_y++ ) { @@ -614,7 +614,7 @@ static STATE_POSTLOAD( updatevisiblearea ) visarea.min_x = visarea.min_y = 0; visarea.max_x = m_n_screenwidth - 1; visarea.max_y = m_n_screenheight - 1; - video_screen_configure(machine->primary_screen, m_n_screenwidth, m_n_screenheight, &visarea, HZ_TO_ATTOSECONDS(refresh)); + machine->primary_screen->configure(m_n_screenwidth, m_n_screenheight, visarea, HZ_TO_ATTOSECONDS(refresh)); } static void psx_gpu_init( running_machine *machine ) @@ -624,8 +624,8 @@ static void psx_gpu_init( running_machine *machine ) int n_level2; int n_shade; int n_shaded; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); need_sianniv_vblank_hack = !strcmp(machine->gamedrv->name, "sianniv"); diff --git a/src/mame/video/qix.c b/src/mame/video/qix.c index e38f31a1919..b0777c789cc 100644 --- a/src/mame/video/qix.c +++ b/src/mame/video/qix.c @@ -126,7 +126,7 @@ static WRITE8_HANDLER( qix_videoram_w ) /* update the screen in case the game is writing "behind" the beam - Zookeeper likes to do this */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* add in the upper bit of the address latch */ offset += (state->videoram_address[0] & 0x80) << 8; @@ -142,7 +142,7 @@ static WRITE8_HANDLER( slither_videoram_w ) /* update the screen in case the game is writing "behind" the beam - Zookeeper likes to do this */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* add in the upper bit of the address latch */ offset += (state->videoram_address[0] & 0x80) << 8; @@ -183,7 +183,7 @@ static WRITE8_HANDLER( qix_addresslatch_w ) qix_state *state = (qix_state *)space->machine->driver_data; /* update the screen in case the game is writing "behind" the beam */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* compute the value at the address latch */ offset = (state->videoram_address[0] << 8) | state->videoram_address[1]; @@ -198,7 +198,7 @@ static WRITE8_HANDLER( slither_addresslatch_w ) qix_state *state = (qix_state *)space->machine->driver_data; /* update the screen in case the game is writing "behind" the beam */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); /* compute the value at the address latch */ offset = (state->videoram_address[0] << 8) | state->videoram_address[1]; @@ -230,7 +230,7 @@ static WRITE8_HANDLER( qix_paletteram_w ) /* trigger an update if a currently visible pen has changed */ if (((offset >> 8) == state->palette_bank) && (old_data != data)) - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); } @@ -241,7 +241,7 @@ WRITE8_HANDLER( qix_palettebank_w ) /* set the bank value */ if (state->palette_bank != (data & 3)) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); state->palette_bank = data & 3; } @@ -469,6 +469,7 @@ MACHINE_DRIVER_END MACHINE_DRIVER_START( slither_video ) - MDRV_CPU_REPLACE("videocpu", M6809, SLITHER_CLOCK_OSC/4/4) /* 1.34 MHz */ + MDRV_CPU_MODIFY("videocpu") + MDRV_CPU_CLOCK(SLITHER_CLOCK_OSC/4/4) /* 1.34 MHz */ MDRV_CPU_PROGRAM_MAP(slither_video_map) MACHINE_DRIVER_END diff --git a/src/mame/video/quasar.c b/src/mame/video/quasar.c index 585dcfd2058..d09ff56640d 100644 --- a/src/mame/video/quasar.c +++ b/src/mame/video/quasar.c @@ -96,7 +96,7 @@ VIDEO_START( quasar ) state->effectram = auto_alloc_array(machine, UINT8, 0x400); /* create helper bitmap */ - state->collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->collision_background = machine->primary_screen->alloc_compatible_bitmap(); /* register save */ state_save_register_global_bitmap(machine, state->collision_background); diff --git a/src/mame/video/rallyx.c b/src/mame/video/rallyx.c index 48f6227f10e..36ee8b98c0e 100644 --- a/src/mame/video/rallyx.c +++ b/src/mame/video/rallyx.c @@ -375,7 +375,7 @@ VIDEO_START( locomotn ) state->fg_tilemap = tilemap_create(machine, locomotn_fg_get_tile_info, fg_tilemap_scan, 8, 8, 8, 32); /* handle reduced visible area in some games */ - if (video_screen_get_visible_area(machine->primary_screen)->max_x == 32 * 8 - 1) + if (machine->primary_screen->visible_area().max_x == 32 * 8 - 1) { tilemap_set_scrolldx(state->bg_tilemap, 0, 32); tilemap_set_scrolldx(state->fg_tilemap, 0, 32); @@ -396,7 +396,7 @@ VIDEO_START( commsega ) state->fg_tilemap = tilemap_create(machine, locomotn_fg_get_tile_info, fg_tilemap_scan, 8, 8, 8, 32); /* handle reduced visible area in some games */ - if (video_screen_get_visible_area(machine->primary_screen)->max_x == 32 * 8 - 1) + if (machine->primary_screen->visible_area().max_x == 32 * 8 - 1) { tilemap_set_scrolldx(state->bg_tilemap, 0, 32); tilemap_set_scrolldx(state->fg_tilemap, 0, 32); @@ -710,7 +710,7 @@ VIDEO_UPDATE( locomotn ) if (flip_screen_get(screen->machine)) { /* handle reduced visible area in some games */ - if (video_screen_get_visible_area(screen)->max_x == 32 * 8 - 1) + if (screen->visible_area().max_x == 32 * 8 - 1) { bg_clip.min_x = 4 * 8; fg_clip.max_x = 4 * 8 - 1; diff --git a/src/mame/video/realbrk.c b/src/mame/video/realbrk.c index 93b17da5ebf..d269a85868b 100644 --- a/src/mame/video/realbrk.c +++ b/src/mame/video/realbrk.c @@ -162,8 +162,8 @@ VIDEO_START(realbrk) tilemap_set_transparent_pen(tilemap_1,0); tilemap_set_transparent_pen(tilemap_2,0); - tmpbitmap0 = auto_bitmap_alloc(machine,32,32, video_screen_get_format(machine->primary_screen)); - tmpbitmap1 = auto_bitmap_alloc(machine,32,32, video_screen_get_format(machine->primary_screen)); + tmpbitmap0 = auto_bitmap_alloc(machine,32,32, machine->primary_screen->format()); + tmpbitmap1 = auto_bitmap_alloc(machine,32,32, machine->primary_screen->format()); } /*************************************************************************** @@ -216,8 +216,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan UINT16 *spriteram16 = machine->generic.spriteram.u16; int offs; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); rectangle spritetile_clip; spritetile_clip.min_x = 0; @@ -382,8 +382,8 @@ static void dai2kaku_draw_sprites(running_machine *machine, bitmap_t *bitmap,con UINT16 *spriteram16 = machine->generic.spriteram.u16; int offs; - int max_x = video_screen_get_width(machine->primary_screen); - int max_y = video_screen_get_height(machine->primary_screen); + int max_x = machine->primary_screen->width(); + int max_y = machine->primary_screen->height(); for ( offs = 0x3000/2; offs < 0x3600/2; offs += 2/2 ) { diff --git a/src/mame/video/rohga.c b/src/mame/video/rohga.c index f289ee9e781..50034dcf622 100644 --- a/src/mame/video/rohga.c +++ b/src/mame/video/rohga.c @@ -51,7 +51,7 @@ static void rohga_draw_sprites( running_machine *machine, bitmap_t *bitmap, cons y = spriteptr[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; // Sprite colour is different between Rohga (6bpp) and Schmeisr (4bpp plus wire mods on pcb) @@ -155,7 +155,7 @@ static void wizdfire_draw_sprites( running_machine *machine, bitmap_t *bitmap, c y = spriteptr[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; colour = (x >> 9) & 0x1f; @@ -268,7 +268,7 @@ Sprites 2: w = (spriteptr[offs + 2] & 0x0f00) >> 8; sy = spriteptr[offs]; - if ((sy & 0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if ((sy & 0x2000) && (machine->primary_screen->frame_number() & 1)) { offs += inc; continue; diff --git a/src/mame/video/rpunch.c b/src/mame/video/rpunch.c index 225979f2009..4b3b3a9f4e0 100644 --- a/src/mame/video/rpunch.c +++ b/src/mame/video/rpunch.c @@ -78,7 +78,7 @@ static TIMER_CALLBACK( crtc_interrupt_gen ) { cputag_set_input_line(machine, "maincpu", 1, HOLD_LINE); if (param != 0) - timer_adjust_periodic(crtc_timer, attotime_div(video_screen_get_frame_period(machine->primary_screen), param), 0, attotime_div(video_screen_get_frame_period(machine->primary_screen), param)); + timer_adjust_periodic(crtc_timer, attotime_div(machine->primary_screen->frame_period(), param), 0, attotime_div(machine->primary_screen->frame_period(), param)); } @@ -164,7 +164,7 @@ WRITE16_HANDLER( rpunch_crtc_data_w ) { /* only register we know about.... */ case 0x0b: - timer_adjust_oneshot(crtc_timer, video_screen_get_time_until_vblank_start(space->machine->primary_screen), (data == 0xc0) ? 2 : 1); + timer_adjust_oneshot(crtc_timer, space->machine->primary_screen->time_until_vblank_start(), (data == 0xc0) ? 2 : 1); break; default: diff --git a/src/mame/video/sega16sp.c b/src/mame/video/sega16sp.c index a3468af9c45..253f642aaed 100644 --- a/src/mame/video/sega16sp.c +++ b/src/mame/video/sega16sp.c @@ -15,17 +15,16 @@ UINT16 *segaic16_spriteram_1; INLINE sega16sp_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == SEGA16SP); + assert(device->type() == SEGA16SP); - return (sega16sp_state *)device->token; + return (sega16sp_state *)downcast(device)->token(); } INLINE const sega16sp_interface *get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == SEGA16SP)); - return (const sega16sp_interface *) device->baseconfig().static_config; + assert((device->type() == SEGA16SP)); + return (const sega16sp_interface *) device->baseconfig().static_config(); } /******************************************************************************************* @@ -1503,8 +1502,8 @@ void segaic16_sprites_set_bank(running_machine *machine, int which, int banknum, if (sega16sp->bank[banknum] != offset) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); sega16sp->bank[banknum] = offset; } } @@ -1534,8 +1533,8 @@ void segaic16_sprites_set_flip(running_machine *machine, int which, int flip) flip = (flip != 0); if (sega16sp->flip != flip) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); sega16sp->flip = flip; } } @@ -1565,8 +1564,8 @@ void segaic16_sprites_set_shadow(running_machine *machine, int which, int shadow shadow = (shadow != 0); if (sega16sp->shadow != shadow) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); sega16sp->shadow = shadow; } } @@ -1683,7 +1682,6 @@ DEVICE_GET_INFO( sega16sp ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(sega16sp_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(sega16sp); break; diff --git a/src/mame/video/segag80r.c b/src/mame/video/segag80r.c index f4e9fa760e9..5a45df4f15b 100644 --- a/src/mame/video/segag80r.c +++ b/src/mame/video/segag80r.c @@ -347,7 +347,7 @@ WRITE8_HANDLER( segag80r_video_port_w ) READ8_HANDLER( spaceod_back_port_r ) { /* force an update to get the current detection value */ - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); return 0xfe | spaceod_bg_detect; } @@ -400,7 +400,7 @@ WRITE8_HANDLER( spaceod_back_port_w ) /* port 3: clears the background detection flag */ case 3: - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); spaceod_bg_detect = 0; break; diff --git a/src/mame/video/segag80v.c b/src/mame/video/segag80v.c index 7ec82adc6b6..4d8f41b6ec7 100644 --- a/src/mame/video/segag80v.c +++ b/src/mame/video/segag80v.c @@ -327,8 +327,8 @@ VIDEO_START( sega ) { assert_always(vectorram_size != 0, "vectorram==0"); - min_x =video_screen_get_visible_area(machine->primary_screen)->min_x; - min_y =video_screen_get_visible_area(machine->primary_screen)->min_y; + min_x =machine->primary_screen->visible_area().min_x; + min_y =machine->primary_screen->visible_area().min_y; VIDEO_START_CALL(vector); } diff --git a/src/mame/video/segaic16.c b/src/mame/video/segaic16.c index 96147ad726c..6dbc7540e9b 100644 --- a/src/mame/video/segaic16.c +++ b/src/mame/video/segaic16.c @@ -409,7 +409,7 @@ void segaic16_set_display_enable(running_machine *machine, int enable) enable = (enable != 0); if (segaic16_display_enable != enable) { - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); segaic16_display_enable = enable; } } @@ -525,8 +525,8 @@ static void segaic16_draw_virtual_tilemap(running_machine *machine, struct tilem rectangle pageclip; int page; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* which half/halves of the virtual tilemap do we intersect in the X direction? */ if (xscroll < 64*8 - width) @@ -1095,14 +1095,14 @@ static TIMER_CALLBACK( segaic16_tilemap_16b_latch_values ) } /* set a timer to do this again next frame */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 261, 0), NULL, param, segaic16_tilemap_16b_latch_values); + timer_set(machine, machine->primary_screen->time_until_pos(261), NULL, param, segaic16_tilemap_16b_latch_values); } static void segaic16_tilemap_16b_reset(running_machine *machine, struct tilemap_info *info) { /* set a timer to latch values on scanline 261 */ - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 261, 0), NULL, info->index, segaic16_tilemap_16b_latch_values); + timer_set(machine, machine->primary_screen->time_until_pos(261), NULL, info->index, segaic16_tilemap_16b_latch_values); } @@ -1264,8 +1264,8 @@ void segaic16_tilemap_set_bank(running_machine *machine, int which, int banknum, if (info->bank[banknum] != offset) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); info->bank[banknum] = offset; tilemap_mark_all_tiles_dirty_all(machine); } @@ -1287,8 +1287,8 @@ void segaic16_tilemap_set_flip(running_machine *machine, int which, int flip) flip = (flip != 0); if (info->flip != flip) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); info->flip = flip; tilemap_set_flip(info->textmap, flip ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0); for (pagenum = 0; pagenum < info->numpages; pagenum++) @@ -1311,8 +1311,8 @@ void segaic16_tilemap_set_rowscroll(running_machine *machine, int which, int ena enable = (enable != 0); if (info->rowscroll != enable) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); info->rowscroll = enable; } } @@ -1332,8 +1332,8 @@ void segaic16_tilemap_set_colscroll(running_machine *machine, int which, int ena enable = (enable != 0); if (info->colscroll != enable) { - running_device *screen = machine->primary_screen; - video_screen_update_partial(screen, video_screen_get_vpos(screen)); + screen_device *screen = machine->primary_screen; + screen->update_partial(screen->vpos()); info->colscroll = enable; } } @@ -1357,7 +1357,7 @@ WRITE16_HANDLER( segaic16_textram_0_w ) { /* certain ranges need immediate updates */ if (offset >= 0xe80/2) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); COMBINE_DATA(&segaic16_textram_0[offset]); tilemap_mark_tile_dirty(bg_tilemap[0].textmap, offset); diff --git a/src/mame/video/segaic16.h b/src/mame/video/segaic16.h index 926158edc86..14ae7162b97 100644 --- a/src/mame/video/segaic16.h +++ b/src/mame/video/segaic16.h @@ -192,9 +192,7 @@ struct _sega16sp_state FUNCTION PROTOTYPES ***************************************************************************/ -DEVICE_GET_INFO( sega16sp ); - -#define SEGA16SP DEVICE_GET_INFO_NAME( sega16sp ) +DECLARE_LEGACY_DEVICE(SEGA16SP, sega16sp); void segaic16_sprites_hangon_draw(running_machine *machine, running_device *device, bitmap_t *bitmap, const rectangle *cliprect); void segaic16_sprites_sharrier_draw(running_machine *machine, running_device *device, bitmap_t *bitmap, const rectangle *cliprect); diff --git a/src/mame/video/segas18.c b/src/mame/video/segas18.c index 8bacf7c6769..537ce0ee561 100644 --- a/src/mame/video/segas18.c +++ b/src/mame/video/segas18.c @@ -45,8 +45,8 @@ VIDEO_START( system18 ) system18_vdp_start(machine); /* create a temp bitmap to draw the VDP data into */ - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); state->tmp_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -71,7 +71,7 @@ void system18_set_grayscale(running_machine *machine, int enable) enable = (enable != 0); if (enable != state->grayscale_enable) { - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); state->grayscale_enable = enable; // mame_printf_debug("Grayscale = %02X\n", enable); } @@ -85,7 +85,7 @@ void system18_set_vdp_enable(running_machine *machine, int enable) enable = (enable != 0); if (enable != state->vdp_enable) { - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); state->vdp_enable = enable; #if DEBUG_VDP mame_printf_debug("VDP enable = %02X\n", enable); @@ -100,7 +100,7 @@ void system18_set_vdp_mixing(running_machine *machine, int mixing) if (mixing != state->vdp_mixing) { - video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); + machine->primary_screen->update_partial(machine->primary_screen->vpos()); state->vdp_mixing = mixing; #if DEBUG_VDP mame_printf_debug("VDP mixing = %02X\n", mixing); diff --git a/src/mame/video/segas32.c b/src/mame/video/segas32.c index fc3ff969f97..422cc59b591 100644 --- a/src/mame/video/segas32.c +++ b/src/mame/video/segas32.c @@ -805,7 +805,7 @@ static TILE_GET_INFO( get_tile_info ) * *************************************/ -static int compute_clipping_extents(running_device *screen, int enable, int clipout, int clipmask, const rectangle *cliprect, struct extents_list *list) +static int compute_clipping_extents(screen_device &screen, int enable, int clipout, int clipmask, const rectangle *cliprect, struct extents_list *list) { int flip = (system32_videoram[0x1ff00/2] >> 9) & 1; rectangle tempclip; @@ -841,12 +841,12 @@ static int compute_clipping_extents(running_device *screen, int enable, int clip } else { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); - clips[i].max_x = (visarea->max_x + 1) - (system32_videoram[0x1ff60/2 + i * 4] & 0x1ff); - clips[i].max_y = (visarea->max_y + 1) - (system32_videoram[0x1ff62/2 + i * 4] & 0x0ff); - clips[i].min_x = (visarea->max_x + 1) - ((system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1); - clips[i].min_y = (visarea->max_y + 1) - ((system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1); + clips[i].max_x = (visarea.max_x + 1) - (system32_videoram[0x1ff60/2 + i * 4] & 0x1ff); + clips[i].max_y = (visarea.max_y + 1) - (system32_videoram[0x1ff62/2 + i * 4] & 0x0ff); + clips[i].min_x = (visarea.max_x + 1) - ((system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1); + clips[i].min_y = (visarea.max_y + 1) - ((system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1); } sect_rect(&clips[i], &tempclip); sorted[i] = i; @@ -936,7 +936,7 @@ INLINE void get_tilemaps(int bgnum, tilemap_t **tilemaps) } -static void update_tilemap_zoom(running_device *screen, struct layer_info *layer, const rectangle *cliprect, int bgnum) +static void update_tilemap_zoom(screen_device &screen, struct layer_info *layer, const rectangle *cliprect, int bgnum) { int clipenable, clipout, clips, clipdraw_start; bitmap_t *bitmap = layer->bitmap; @@ -954,8 +954,8 @@ static void update_tilemap_zoom(running_device *screen, struct layer_info *layer /* configure the layer */ opaque = 0; //opaque = (system32_videoram[0x1ff8e/2] >> (8 + bgnum)) & 1; -//if (input_code_pressed(screen->machine, KEYCODE_Z) && bgnum == 0) opaque = 1; -//if (input_code_pressed(screen->machine, KEYCODE_X) && bgnum == 1) opaque = 1; +//if (input_code_pressed(screen.machine, KEYCODE_Z) && bgnum == 0) opaque = 1; +//if (input_code_pressed(screen.machine, KEYCODE_X) && bgnum == 1) opaque = 1; /* determine if we're flipped */ flip = ((system32_videoram[0x1ff00/2] >> 9) ^ (system32_videoram[0x1ff00/2] >> bgnum)) & 1; @@ -1000,10 +1000,10 @@ static void update_tilemap_zoom(running_device *screen, struct layer_info *layer /* if we're flipped, simply adjust the start/step parameters */ if (flip) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); - srcx_start += (visarea->max_x - 2 * cliprect->min_x) * srcxstep; - srcy += (visarea->max_y - 2 * cliprect->min_y) * srcystep; + srcx_start += (visarea.max_x - 2 * cliprect->min_x) * srcxstep; + srcy += (visarea.max_y - 2 * cliprect->min_y) * srcystep; srcxstep = -srcxstep; srcystep = -srcystep; } @@ -1089,7 +1089,7 @@ static void update_tilemap_zoom(running_device *screen, struct layer_info *layer * *************************************/ -static void update_tilemap_rowscroll(running_device *screen, struct layer_info *layer, const rectangle *cliprect, int bgnum) +static void update_tilemap_rowscroll(screen_device &screen, struct layer_info *layer, const rectangle *cliprect, int bgnum) { int clipenable, clipout, clips, clipdraw_start; bitmap_t *bitmap = layer->bitmap; @@ -1108,8 +1108,8 @@ static void update_tilemap_rowscroll(running_device *screen, struct layer_info * /* configure the layer */ opaque = 0; //opaque = (system32_videoram[0x1ff8e/2] >> (8 + bgnum)) & 1; -//if (input_code_pressed(screen->machine, KEYCODE_C) && bgnum == 2) opaque = 1; -//if (input_code_pressed(screen->machine, KEYCODE_V) && bgnum == 3) opaque = 1; +//if (input_code_pressed(screen.machine, KEYCODE_C) && bgnum == 2) opaque = 1; +//if (input_code_pressed(screen.machine, KEYCODE_V) && bgnum == 3) opaque = 1; /* determine if we're flipped */ flip = ((system32_videoram[0x1ff00/2] >> 9) ^ (system32_videoram[0x1ff00/2] >> bgnum)) & 1; @@ -1166,12 +1166,12 @@ static void update_tilemap_rowscroll(running_device *screen, struct layer_info * /* otherwise, we have to do some contortions */ else { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); /* get starting scroll values */ srcx = cliprect->max_x + xscroll; srcxstep = -1; - srcy = yscroll + visarea->max_y - y; + srcy = yscroll + visarea.max_y - y; /* apply row scroll/select */ if (rowscroll) @@ -1241,7 +1241,7 @@ static void update_tilemap_rowscroll(running_device *screen, struct layer_info * * *************************************/ -static void update_tilemap_text(running_device *screen, struct layer_info *layer, const rectangle *cliprect) +static void update_tilemap_text(screen_device &screen, struct layer_info *layer, const rectangle *cliprect) { bitmap_t *bitmap = layer->bitmap; UINT16 *tilebase; @@ -1332,10 +1332,10 @@ static void update_tilemap_text(running_device *screen, struct layer_info *layer /* flipped case */ else { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen.visible_area(); - int effdstx = visarea->max_x - x * 8; - int effdsty = visarea->max_y - y * 8; + int effdstx = visarea.max_x - x * 8; + int effdsty = visarea.max_y - y * 8; UINT16 *dst = BITMAP_ADDR16(bitmap, effdsty, effdstx); /* loop over rows */ @@ -1400,7 +1400,7 @@ static void update_tilemap_text(running_device *screen, struct layer_info *layer * *************************************/ -static void update_bitmap(running_device *screen, struct layer_info *layer, const rectangle *cliprect) +static void update_bitmap(screen_device &screen, struct layer_info *layer, const rectangle *cliprect) { int clipenable, clipout, clips, clipdraw_start; bitmap_t *bitmap = layer->bitmap; @@ -1527,7 +1527,7 @@ static void update_background(struct layer_info *layer, const rectangle *cliprec } -static UINT8 update_tilemaps(running_device *screen, const rectangle *cliprect) +static UINT8 update_tilemaps(screen_device &screen, const rectangle *cliprect) { int enable0 = !(system32_videoram[0x1ff02/2] & 0x0001) && !(system32_videoram[0x1ff8e/2] & 0x0002); int enable1 = !(system32_videoram[0x1ff02/2] & 0x0002) && !(system32_videoram[0x1ff8e/2] & 0x0004); @@ -2448,9 +2448,9 @@ VIDEO_UPDATE( system32 ) /* update the visible area */ if (system32_videoram[0x1ff00/2] & 0x8000) - video_screen_set_visarea(screen, 0, 52*8-1, 0, 28*8-1); + screen->set_visible_area(0, 52*8-1, 0, 28*8-1); else - video_screen_set_visarea(screen, 0, 40*8-1, 0, 28*8-1); + screen->set_visible_area(0, 40*8-1, 0, 28*8-1); /* if the display is off, punt */ if (!system32_displayenable[0]) @@ -2461,7 +2461,7 @@ VIDEO_UPDATE( system32 ) /* update the tilemaps */ profiler_mark_start(PROFILER_USER1); - enablemask = update_tilemaps(screen, cliprect); + enablemask = update_tilemaps(*screen, cliprect); profiler_mark_end(); /* debugging */ @@ -2481,54 +2481,54 @@ VIDEO_UPDATE( system32 ) if (LOG_SPRITES && input_code_pressed(screen->machine, KEYCODE_L)) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); FILE *f = fopen("sprite.txt", "w"); int x, y; - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_SPRITES, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } fclose(f); f = fopen("nbg0.txt", "w"); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG0, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } fclose(f); f = fopen("nbg1.txt", "w"); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG1, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } fclose(f); f = fopen("nbg2.txt", "w"); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG2, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } fclose(f); f = fopen("nbg3.txt", "w"); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_NBG3, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } @@ -2576,7 +2576,7 @@ for (showclip = 0; showclip < 4; showclip++) for (i = 0; i < 4; i++) if (clips & (1 << i)) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); rectangle rect; pen_t white = get_white_pen(screen->machine); @@ -2589,12 +2589,12 @@ for (showclip = 0; showclip < 4; showclip++) } else { - rect.max_x = (visarea->max_x + 1) - (system32_videoram[0x1ff60/2 + i * 4] & 0x1ff); - rect.max_y = (visarea->max_y + 1) - (system32_videoram[0x1ff62/2 + i * 4] & 0x0ff); - rect.min_x = (visarea->max_x + 1) - ((system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1); - rect.min_y = (visarea->max_y + 1) - ((system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1); + rect.max_x = (visarea.max_x + 1) - (system32_videoram[0x1ff60/2 + i * 4] & 0x1ff); + rect.max_y = (visarea.max_y + 1) - (system32_videoram[0x1ff62/2 + i * 4] & 0x0ff); + rect.min_x = (visarea.max_x + 1) - ((system32_videoram[0x1ff64/2 + i * 4] & 0x1ff) + 1); + rect.min_y = (visarea.max_y + 1) - ((system32_videoram[0x1ff66/2 + i * 4] & 0x0ff) + 1); } - sect_rect(&rect, video_screen_get_visible_area(screen)); + sect_rect(&rect, &screen->visible_area()); if (rect.min_y <= rect.max_y && rect.min_x <= rect.max_x) { @@ -2628,9 +2628,9 @@ VIDEO_UPDATE( multi32 ) /* update the visible area */ if (system32_videoram[0x1ff00/2] & 0x8000) - video_screen_set_visarea(screen, 0, 52*8-1, 0, 28*8-1); + screen->set_visible_area(0, 52*8-1, 0, 28*8-1); else - video_screen_set_visarea(screen, 0, 40*8-1, 0, 28*8-1); + screen->set_visible_area(0, 40*8-1, 0, 28*8-1); /* if the display is off, punt */ if (!system32_displayenable[(screen == left_screen) ? 0 : 1]) @@ -2641,7 +2641,7 @@ VIDEO_UPDATE( multi32 ) /* update the tilemaps */ profiler_mark_start(PROFILER_USER1); - enablemask = update_tilemaps(screen, cliprect); + enablemask = update_tilemaps(*screen, cliprect); profiler_mark_end(); /* debugging */ @@ -2666,14 +2666,14 @@ if (PRINTF_MIXER_DATA) } if (LOG_SPRITES && input_code_pressed(screen->machine, KEYCODE_L)) { - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); FILE *f = fopen("sprite.txt", "w"); int x, y; - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { UINT16 *src = get_layer_scanline(MIXER_LAYER_SPRITES, y); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) fprintf(f, "%04X ", *src++); fprintf(f, "\n"); } diff --git a/src/mame/video/seta.c b/src/mame/video/seta.c index 55e50c3251e..022205efff5 100644 --- a/src/mame/video/seta.c +++ b/src/mame/video/seta.c @@ -877,7 +877,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan if (flip) { - y = (0x100 - video_screen_get_height(machine->primary_screen)) + max_y - y; + y = (0x100 - machine->primary_screen->height()) + max_y - y; flipx = !flipx; flipy = !flipy; } @@ -926,8 +926,8 @@ static VIDEO_UPDATE( seta_layers ) int order = 0; int flip = (screen->machine->generic.spriteram.u16[ 0x600/2 ] & 0x40) >> 6; - const rectangle *visarea = video_screen_get_visible_area(screen); - int vis_dimy = visarea->max_y - visarea->min_y + 1; + const rectangle &visarea = screen->visible_area(); + int vis_dimy = visarea.max_y - visarea.min_y + 1; flip ^= tilemaps_flip; diff --git a/src/mame/video/shangha3.c b/src/mame/video/shangha3.c index 631c4f605f9..72d5dfc8c03 100644 --- a/src/mame/video/shangha3.c +++ b/src/mame/video/shangha3.c @@ -77,7 +77,7 @@ VIDEO_START( shangha3 ) { int i; - rawbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + rawbitmap = machine->primary_screen->alloc_compatible_bitmap(); for (i = 0;i < 14;i++) drawmode_table[i] = DRAWMODE_SOURCE; diff --git a/src/mame/video/simpl156.c b/src/mame/video/simpl156.c index 578c705be7b..001dec6f429 100644 --- a/src/mame/video/simpl156.c +++ b/src/mame/video/simpl156.c @@ -52,7 +52,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const recta y = spriteram[offs] & 0xffff; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2] & 0xffff; diff --git a/src/mame/video/skullxbo.c b/src/mame/video/skullxbo.c index f964960d900..047e49dfd2f 100644 --- a/src/mame/video/skullxbo.c +++ b/src/mame/video/skullxbo.c @@ -114,7 +114,7 @@ WRITE16_HANDLER( skullxbo_xscroll_w ) /* if something changed, force an update */ if (oldscroll != newscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* adjust the actual scrolls */ tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, 2 * (newscroll >> 7)); @@ -130,7 +130,7 @@ WRITE16_HANDLER( skullxbo_yscroll_w ) skullxbo_state *state = (skullxbo_state *)space->machine->driver_data; /* combine data */ - int scanline = video_screen_get_vpos(space->machine->primary_screen); + int scanline = space->machine->primary_screen->vpos(); UINT16 oldscroll = *state->atarigen.yscroll; UINT16 newscroll = oldscroll; UINT16 effscroll; @@ -138,10 +138,10 @@ WRITE16_HANDLER( skullxbo_yscroll_w ) /* if something changed, force an update */ if (oldscroll != newscroll) - video_screen_update_partial(space->machine->primary_screen, scanline); + space->machine->primary_screen->update_partial(scanline); /* adjust the effective scroll for the current scanline */ - if (scanline > video_screen_get_visible_area(space->machine->primary_screen)->max_y) + if (scanline > space->machine->primary_screen->visible_area().max_y) scanline = 0; effscroll = (newscroll >> 7) - scanline; @@ -163,7 +163,7 @@ WRITE16_HANDLER( skullxbo_yscroll_w ) WRITE16_HANDLER( skullxbo_mobmsb_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); atarimo_set_bank(0, (offset >> 9) & 1); } @@ -221,7 +221,7 @@ void skullxbo_scanline_update(running_machine *machine, int scanline) /* force a partial update with the previous scroll */ if (scanline > 0) - video_screen_update_partial(machine->primary_screen, scanline - 1); + machine->primary_screen->update_partial(scanline - 1); /* update the new scroll */ tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll); diff --git a/src/mame/video/skyfox.c b/src/mame/video/skyfox.c index 418914b30ec..01e05192846 100644 --- a/src/mame/video/skyfox.c +++ b/src/mame/video/skyfox.c @@ -164,8 +164,8 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect skyfox_state *state = (skyfox_state *)machine->driver_data; int offs; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* The 32x32 tiles in the 80-ff range are bankswitched */ int shift =(state->bg_ctrl & 0x80) ? (4 - 1) : 4; diff --git a/src/mame/video/skyraid.c b/src/mame/video/skyraid.c index 07c8ec76b44..1cdfa1637d0 100644 --- a/src/mame/video/skyraid.c +++ b/src/mame/video/skyraid.c @@ -17,7 +17,7 @@ static bitmap_t *helper; VIDEO_START( skyraid ) { - helper = auto_bitmap_alloc(machine, 128, 240, video_screen_get_format(machine->primary_screen)); + helper = auto_bitmap_alloc(machine, 128, 240, machine->primary_screen->format()); } diff --git a/src/mame/video/snes.c b/src/mame/video/snes.c index c639eff2a98..c34afe62bf9 100644 --- a/src/mame/video/snes.c +++ b/src/mame/video/snes.c @@ -1814,8 +1814,8 @@ void snes_latch_counters( running_machine *machine ) { snes_state *state = (snes_state *)machine->driver_data; - snes_ppu.beam.current_horz = video_screen_get_hpos(machine->primary_screen) / state->htmult; - snes_ppu.beam.latch_vert = video_screen_get_vpos(machine->primary_screen); + snes_ppu.beam.current_horz = machine->primary_screen->hpos() / state->htmult; + snes_ppu.beam.latch_vert = machine->primary_screen->vpos(); snes_ppu.beam.latch_horz = snes_ppu.beam.current_horz; snes_ram[STAT78] |= 0x40; // indicate we latched // state->read_ophct = state->read_opvct = 0; // clear read flags - 2009-08: I think we must clear these when STAT78 is read... @@ -1826,7 +1826,7 @@ void snes_latch_counters( running_machine *machine ) static void snes_dynamic_res_change( running_machine *machine ) { snes_state *state = (snes_state *)machine->driver_data; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); + rectangle visarea = machine->primary_screen->visible_area(); attoseconds_t refresh; visarea.min_x = visarea.min_y = 0; @@ -1846,9 +1846,9 @@ static void snes_dynamic_res_change( running_machine *machine ) refresh = HZ_TO_ATTOSECONDS(DOTCLK_PAL) * SNES_HTOTAL * SNES_VTOTAL_PAL; if ((snes_ram[STAT78] & 0x10) == SNES_NTSC) - video_screen_configure(machine->primary_screen, SNES_HTOTAL * 2, SNES_VTOTAL_NTSC * snes_ppu.interlace, &visarea, refresh); + machine->primary_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_NTSC * snes_ppu.interlace, visarea, refresh); else - video_screen_configure(machine->primary_screen, SNES_HTOTAL * 2, SNES_VTOTAL_PAL * snes_ppu.interlace, &visarea, refresh); + machine->primary_screen->configure(SNES_HTOTAL * 2, SNES_VTOTAL_PAL * snes_ppu.interlace, visarea, refresh); } /************************************************* @@ -1891,8 +1891,8 @@ static READ8_HANDLER( snes_vram_read ) res = snes_vram[offset]; else { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); - UINT16 h = video_screen_get_hpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); + UINT16 h = space->machine->primary_screen->hpos(); UINT16 ls = (((snes_ram[STAT78] & 0x10) == SNES_NTSC ? 525 : 625) >> 1) - 1; if (snes_ppu.interlace == 2) @@ -1923,8 +1923,8 @@ static WRITE8_HANDLER( snes_vram_write ) snes_vram[offset] = data; else { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); - UINT16 h = video_screen_get_hpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); + UINT16 h = space->machine->primary_screen->hpos(); if (v == 0) { if (h <= 4) @@ -1986,7 +1986,7 @@ static READ8_HANDLER( snes_oam_read ) if (!snes_ppu.screen_disabled) { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); if (v < snes_ppu.beam.last_visible_line) offset = 0x010c; @@ -2004,7 +2004,7 @@ static WRITE8_HANDLER( snes_oam_write ) if (!snes_ppu.screen_disabled) { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); if (v < snes_ppu.beam.last_visible_line) offset = 0x010c; @@ -2045,8 +2045,8 @@ static READ8_HANDLER( snes_cgram_read ) #if 0 if (!snes_ppu.screen_disabled) { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); - UINT16 h = video_screen_get_hpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); + UINT16 h = space->machine->primary_screen->hpos(); if (v < snes_ppu.beam.last_visible_line && h >= 128 && h < 1096) offset = 0x1ff; @@ -2073,8 +2073,8 @@ static WRITE8_HANDLER( snes_cgram_write ) // writes to the cgram address if (!snes_ppu.screen_disabled) { - UINT16 v = video_screen_get_vpos(space->machine->primary_screen); - UINT16 h = video_screen_get_hpos(space->machine->primary_screen); + UINT16 v = space->machine->primary_screen->vpos(); + UINT16 h = space->machine->primary_screen->hpos(); if (v < snes_ppu.beam.last_visible_line && h >= 128 && h < 1096) offset = 0x1ff; diff --git a/src/mame/video/snk.c b/src/mame/video/snk.c index 5440fdbeb14..d6b548ac22b 100644 --- a/src/mame/video/snk.c +++ b/src/mame/video/snk.c @@ -652,10 +652,10 @@ WRITE8_HANDLER( tdfever_spriteram_w ) /* partial updates avoid flickers in the fsoccer radar. */ if (offset < 0x80 && space->machine->generic.spriteram.u8[offset] != data) { - int vpos = video_screen_get_vpos(space->machine->primary_screen); + int vpos = space->machine->primary_screen->vpos(); if (vpos > 0) - video_screen_update_partial(space->machine->primary_screen, vpos - 1); + space->machine->primary_screen->update_partial(vpos - 1); } space->machine->generic.spriteram.u8[offset] = data; diff --git a/src/mame/video/snk68.c b/src/mame/video/snk68.c index de2514c6cb1..dd999be5fec 100644 --- a/src/mame/video/snk68.c +++ b/src/mame/video/snk68.c @@ -57,8 +57,8 @@ static void common_video_start(running_machine *machine) { tilemap_set_transparent_pen(fg_tilemap,0); - tilemap_set_scrolldx(fg_tilemap, 0, video_screen_get_width(machine->primary_screen) - 256); - tilemap_set_scrolldy(fg_tilemap, 0, video_screen_get_height(machine->primary_screen) - 256); + tilemap_set_scrolldx(fg_tilemap, 0, machine->primary_screen->width() - 256); + tilemap_set_scrolldy(fg_tilemap, 0, machine->primary_screen->height() - 256); } VIDEO_START( pow ) @@ -104,10 +104,10 @@ WRITE16_HANDLER( pow_spriteram_w ) if (spriteram16[offset] != newword) { - int vpos = video_screen_get_vpos(space->machine->primary_screen); + int vpos = space->machine->primary_screen->vpos(); if (vpos > 0) - video_screen_update_partial(space->machine->primary_screen, vpos - 1); + space->machine->primary_screen->update_partial(vpos - 1); spriteram16[offset] = newword; } diff --git a/src/mame/video/spacefb.c b/src/mame/video/spacefb.c index 25bb11167ef..da83f5f8d72 100644 --- a/src/mame/video/spacefb.c +++ b/src/mame/video/spacefb.c @@ -29,14 +29,14 @@ static double color_weights_rg[3], color_weights_b[2]; WRITE8_HANDLER( spacefb_port_0_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); port_0 = data; } WRITE8_HANDLER( spacefb_port_2_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); port_2 = data; } @@ -90,8 +90,8 @@ VIDEO_START( spacefb ) 2, resistances_b, color_weights_b, 470, 0, 0, 0, 0, 0, 0); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); object_present_map = auto_alloc_array(machine, UINT8, width * height); /* this start value positions the stars to match the flyer screen shot, @@ -147,7 +147,7 @@ static void get_starfield_pens(pen_t *pens) } -static void draw_starfield(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect) +static void draw_starfield(screen_device &screen, bitmap_t *bitmap, const rectangle *cliprect) { int y; pen_t pens[NUM_STARFIELD_PENS]; @@ -155,7 +155,7 @@ static void draw_starfield(running_device *screen, bitmap_t *bitmap, const recta get_starfield_pens(pens); /* the shift register is always shifting -- do the portion in the top VBLANK */ - if (cliprect->min_y == video_screen_get_visible_area(screen)->min_y) + if (cliprect->min_y == screen.visible_area().min_y) { int i; @@ -190,7 +190,7 @@ static void draw_starfield(running_device *screen, bitmap_t *bitmap, const recta } /* do the shifting in the bottom VBLANK */ - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen.visible_area().max_y) { int i; int clock_count = (SPACEFB_HBSTART - SPACEFB_HBEND) * (SPACEFB_VTOTAL - SPACEFB_VBSTART); @@ -404,7 +404,7 @@ static void draw_objects(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_UPDATE( spacefb ) { draw_objects(screen->machine, bitmap, cliprect); - draw_starfield(screen, bitmap, cliprect); + draw_starfield(*screen, bitmap, cliprect); return 0; } diff --git a/src/mame/video/spbactn.c b/src/mame/video/spbactn.c index 4efc4b02d21..fcdcacf11ed 100644 --- a/src/mame/video/spbactn.c +++ b/src/mame/video/spbactn.c @@ -111,8 +111,8 @@ VIDEO_START( spbactn ) spbactn_state *state = (spbactn_state *)machine->driver_data; /* allocate bitmaps */ - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); state->tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); state->tile_bitmap_fg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); diff --git a/src/mame/video/spdodgeb.c b/src/mame/video/spdodgeb.c index a40ef08b5b2..a2a04a2e79c 100644 --- a/src/mame/video/spdodgeb.c +++ b/src/mame/video/spdodgeb.c @@ -99,12 +99,12 @@ INTERRUPT_GEN( spdodgeb_interrupt ) if (iloop > 1 && iloop < 32) { cpu_set_input_line(device, M6502_IRQ_LINE, HOLD_LINE); - video_screen_update_partial(device->machine->primary_screen, scanline+7); + device->machine->primary_screen->update_partial(scanline+7); } else if (!iloop) { cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); - video_screen_update_partial(device->machine->primary_screen, 256); + device->machine->primary_screen->update_partial(256); } } diff --git a/src/mame/video/sprint2.c b/src/mame/video/sprint2.c index 58d26c468b9..179918edad9 100644 --- a/src/mame/video/sprint2.c +++ b/src/mame/video/sprint2.c @@ -51,7 +51,7 @@ static TILE_GET_INFO( get_tile_info ) VIDEO_START( sprint2 ) { - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 8, 32, 32); } @@ -146,7 +146,7 @@ VIDEO_EOF( sprint2 ) { int i; int j; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* * Collisions are detected for both player cars: @@ -165,14 +165,14 @@ VIDEO_EOF( sprint2 ) rect.max_x = get_sprite_x(i) + machine->gfx[1]->width - 1; rect.max_y = get_sprite_y(i) + machine->gfx[1]->height - 1; - if (rect.min_x < visarea->min_x) - rect.min_x = visarea->min_x; - if (rect.min_y < visarea->min_y) - rect.min_y = visarea->min_y; - if (rect.max_x > visarea->max_x) - rect.max_x = visarea->max_x; - if (rect.max_y > visarea->max_y) - rect.max_y = visarea->max_y; + if (rect.min_x < visarea.min_x) + rect.min_x = visarea.min_x; + if (rect.min_y < visarea.min_y) + rect.min_y = visarea.min_y; + if (rect.max_x > visarea.max_x) + rect.max_x = visarea.max_x; + if (rect.max_y > visarea.max_y) + rect.max_y = visarea.max_y; /* check for sprite-tilemap collisions */ diff --git a/src/mame/video/sprint4.c b/src/mame/video/sprint4.c index 179e880ec64..793eaef396a 100644 --- a/src/mame/video/sprint4.c +++ b/src/mame/video/sprint4.c @@ -53,7 +53,7 @@ static TILE_GET_INFO( sprint4_tile_info ) VIDEO_START( sprint4 ) { - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); playfield = tilemap_create(machine, sprint4_tile_info, tilemap_scan_rows, 8, 8, 32, 32); } @@ -114,7 +114,7 @@ VIDEO_EOF( sprint4 ) rect.max_x = horz - 15 + machine->gfx[1]->width - 1; rect.max_y = vert - 15 + machine->gfx[1]->height - 1; - sect_rect(&rect, video_screen_get_visible_area(machine->primary_screen)); + sect_rect(&rect, &machine->primary_screen->visible_area()); tilemap_draw(helper, &rect, playfield, 0, 0); diff --git a/src/mame/video/sprint8.c b/src/mame/video/sprint8.c index baf14897160..7a7d9456a02 100644 --- a/src/mame/video/sprint8.c +++ b/src/mame/video/sprint8.c @@ -125,8 +125,8 @@ WRITE8_HANDLER( sprint8_video_ram_w ) VIDEO_START( sprint8 ) { - helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper1 = machine->primary_screen->alloc_compatible_bitmap(); + helper2 = machine->primary_screen->alloc_compatible_bitmap(); tilemap1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 8, 32, 32); tilemap2 = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 8, 32, 32); @@ -178,22 +178,22 @@ VIDEO_EOF( sprint8 ) { int x; int y; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - tilemap_draw(helper2, visarea, tilemap2, 0, 0); + tilemap_draw(helper2, &visarea, tilemap2, 0, 0); - bitmap_fill(helper1, visarea, 0x20); + bitmap_fill(helper1, &visarea, 0x20); - draw_sprites(machine, helper1, visarea); + draw_sprites(machine, helper1, &visarea); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { const UINT16* p1 = BITMAP_ADDR16(helper1, y, 0); const UINT16* p2 = BITMAP_ADDR16(helper2, y, 0); - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) if (p1[x] != 0x20 && p2[x] == 0x23) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, y + 24, x), NULL, + timer_set(machine, machine->primary_screen->time_until_pos(y + 24, x), NULL, colortable_entry_get_value(machine->colortable, p1[x]), sprint8_collision_callback); } diff --git a/src/mame/video/srmp2.c b/src/mame/video/srmp2.c index 4f62a544600..267c8654f55 100644 --- a/src/mame/video/srmp2.c +++ b/src/mame/video/srmp2.c @@ -75,7 +75,7 @@ static void srmp2_draw_sprites(running_machine *machine, bitmap_t *bitmap, const /* Sprites Banking and/or Sprites Buffering */ UINT16 *src = spriteram16_2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 ); - int max_y = video_screen_get_height(machine->primary_screen); + int max_y = machine->primary_screen->height(); xoffs = flip ? 0x10 : 0x10; yoffs = flip ? 0x05 : 0x07; @@ -158,7 +158,7 @@ static void srmp3_draw_sprites_map(running_machine *machine, bitmap_t *bitmap, c int sx = x + xoffs + (offs & 1) * 16; int sy = -(y + yoffs) + (offs / 2) * 16 - - (video_screen_get_height(machine->primary_screen) - (video_screen_get_visible_area(machine->primary_screen)->max_y + 1)); + (machine->primary_screen->height() - (machine->primary_screen->visible_area().max_y + 1)); if (upper & (1 << col)) sx += 256; @@ -232,7 +232,7 @@ static void srmp3_draw_sprites(running_machine *machine, bitmap_t *bitmap, const int offs; int xoffs, yoffs; - int max_y = video_screen_get_height(machine->primary_screen); + int max_y = machine->primary_screen->height(); int ctrl = spriteram[ 0x600/2 ]; //int ctrl2 = spriteram[ 0x602/2 ]; @@ -327,7 +327,7 @@ static void mjyuugi_draw_sprites_map(running_machine *machine, bitmap_t *bitmap, int sx = x + xoffs + (offs & 1) * 16; int sy = -(y + yoffs) + (offs / 2) * 16 - - (video_screen_get_height(machine->primary_screen) - (video_screen_get_visible_area(machine->primary_screen)->max_y + 1)); + (machine->primary_screen->height() - (machine->primary_screen->visible_area().max_y + 1)); if (upper & (1 << col)) sx += 256; @@ -398,7 +398,7 @@ static void mjyuugi_draw_sprites(running_machine *machine, bitmap_t *bitmap, con /* Sprites Banking and/or Sprites Buffering */ UINT16 *src = spriteram16_2 + ( ((ctrl2 ^ (~ctrl2<<1)) & 0x40) ? 0x2000/2 : 0 ); - int max_y = video_screen_get_height(machine->primary_screen); + int max_y = machine->primary_screen->height(); mjyuugi_draw_sprites_map(machine, bitmap, cliprect); @@ -424,7 +424,7 @@ static void mjyuugi_draw_sprites(running_machine *machine, bitmap_t *bitmap, con if (flip) { y = max_y - y - +(video_screen_get_height(machine->primary_screen) - (video_screen_get_visible_area(machine->primary_screen)->max_y + 1)); + +(machine->primary_screen->height() - (machine->primary_screen->visible_area().max_y + 1)); flipx = !flipx; flipy = !flipy; } diff --git a/src/mame/video/sshangha.c b/src/mame/video/sshangha.c index 688d9b797b0..d35b32851e5 100644 --- a/src/mame/video/sshangha.c +++ b/src/mame/video/sshangha.c @@ -56,7 +56,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta y = spritesrc[offs]; flash=y&0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spritesrc[offs+2]; colour = (x >>9) & 0x1f; diff --git a/src/mame/video/ssv.c b/src/mame/video/ssv.c index c04afa08b53..5d75831a50b 100644 --- a/src/mame/video/ssv.c +++ b/src/mame/video/ssv.c @@ -371,7 +371,7 @@ UINT16 *eaglshot_gfxram, *gdfs_tmapram, *gdfs_tmapscroll; READ16_HANDLER( ssv_vblank_r ) { - if (video_screen_get_vblank(space->machine->primary_screen)) + if (space->machine->primary_screen->vblank()) return 0x2000 | 0x1000; else return 0x0000; @@ -721,7 +721,7 @@ static void draw_row(running_machine *machine, bitmap_t *bitmap, const rectangle static void draw_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int nr) { int sy; - for ( sy = 0; sy <= video_screen_get_visible_area(machine->primary_screen)->max_y; sy += 0x40 ) + for ( sy = 0; sy <= machine->primary_screen->visible_area().max_y; sy += 0x40 ) draw_row(machine, bitmap, cliprect, 0, sy, nr); } diff --git a/src/mame/video/st0016.c b/src/mame/video/st0016.c index eed20a49c87..f4708dde3fe 100644 --- a/src/mame/video/st0016.c +++ b/src/mame/video/st0016.c @@ -462,13 +462,13 @@ VIDEO_START( st0016 ) switch(st0016_game&0x3f) { case 0: //renju kizoku - video_screen_set_visarea(machine->primary_screen, 0, 40*8-1, 0, 30*8-1); + machine->primary_screen->set_visible_area(0, 40*8-1, 0, 30*8-1); spr_dx=0; spr_dy=0; break; case 1: //neratte chu! - video_screen_set_visarea(machine->primary_screen, 8,41*8-1,0,30*8-1); + machine->primary_screen->set_visible_area(8,41*8-1,0,30*8-1); spr_dx=0; spr_dy=8; break; @@ -478,15 +478,15 @@ VIDEO_START( st0016 ) break; case 4: //mayjinsen 1&2 - video_screen_set_visarea(machine->primary_screen, 0,32*8-1,0,28*8-1); + machine->primary_screen->set_visible_area(0,32*8-1,0,28*8-1); break; case 10: - video_screen_set_visarea(machine->primary_screen, 0,383,0,255); + machine->primary_screen->set_visible_area(0,383,0,255); break; case 11: - video_screen_set_visarea(machine->primary_screen, 0,383,0,383); + machine->primary_screen->set_visible_area(0,383,0,383); break; } diff --git a/src/mame/video/stadhero.c b/src/mame/video/stadhero.c index ad33d58bedb..7a2c8775b5e 100644 --- a/src/mame/video/stadhero.c +++ b/src/mame/video/stadhero.c @@ -37,7 +37,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan if ((colour & pri_mask) != pri_val) continue; flash=x&0x800; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue; + if (flash && (machine->primary_screen->frame_number() & 1)) continue; fx = y & 0x2000; fy = y & 0x4000; diff --git a/src/mame/video/starcrus.c b/src/mame/video/starcrus.c index 14bca060752..c66eecef8e6 100644 --- a/src/mame/video/starcrus.c +++ b/src/mame/video/starcrus.c @@ -55,11 +55,11 @@ WRITE8_HANDLER( starcrus_p2_y_w ) { p2_y = data^0xff; } VIDEO_START( starcrus ) { - ship1_vid = auto_bitmap_alloc(machine,16,16,video_screen_get_format(machine->primary_screen)); - ship2_vid = auto_bitmap_alloc(machine,16,16,video_screen_get_format(machine->primary_screen)); + ship1_vid = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format()); + ship2_vid = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format()); - proj1_vid = auto_bitmap_alloc(machine,16,16,video_screen_get_format(machine->primary_screen)); - proj2_vid = auto_bitmap_alloc(machine,16,16,video_screen_get_format(machine->primary_screen)); + proj1_vid = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format()); + proj2_vid = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format()); } WRITE8_HANDLER( starcrus_ship_parm_1_w ) @@ -498,7 +498,7 @@ VIDEO_UPDATE( starcrus ) 0); /* Collision detection */ - if (cliprect->max_y == video_screen_get_visible_area(screen)->max_y) + if (cliprect->max_y == screen->visible_area().max_y) { collision_reg = 0x00; diff --git a/src/mame/video/starfire.c b/src/mame/video/starfire.c index 825983d9c35..e1276b6cf86 100644 --- a/src/mame/video/starfire.c +++ b/src/mame/video/starfire.c @@ -79,7 +79,7 @@ WRITE8_HANDLER( starfire_colorram_w ) /* don't modify the palette unless the TRANS bit is set */ if (starfire_vidctrl1 & 0x40) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); starfire_colors[palette_index] = ((((data << 1) & 0x06) | ((offset >> 8) & 0x01)) << 6) | (((data >> 5) & 0x07) << 3) | diff --git a/src/mame/video/starshp1.c b/src/mame/video/starshp1.c index ed8af86c740..7174d78c242 100644 --- a/src/mame/video/starshp1.c +++ b/src/mame/video/starshp1.c @@ -108,16 +108,16 @@ VIDEO_START( starshp1 ) val = (val << 1) | (bit & 1); } - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); } READ8_HANDLER( starshp1_rng_r ) { - int width = video_screen_get_width(space->machine->primary_screen); - int height = video_screen_get_height(space->machine->primary_screen); - int x = video_screen_get_hpos(space->machine->primary_screen); - int y = video_screen_get_vpos(space->machine->primary_screen); + int width = space->machine->primary_screen->width(); + int height = space->machine->primary_screen->height(); + int x = space->machine->primary_screen->hpos(); + int y = space->machine->primary_screen->vpos(); /* the LFSR is only running in the non-blank region of the screen, so this is not quite right */ @@ -406,7 +406,7 @@ VIDEO_UPDATE( starshp1 ) VIDEO_EOF( starshp1 ) { rectangle rect; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); rect.min_x = get_sprite_hpos(13); rect.min_y = get_sprite_vpos(13); @@ -422,12 +422,12 @@ VIDEO_EOF( starshp1 ) if (rect.max_y > helper->height - 1) rect.max_y = helper->height - 1; - bitmap_fill(helper, visarea, 0); + bitmap_fill(helper, &visarea, 0); if (starshp1_attract == 0) - draw_spaceship(machine, helper, visarea); + draw_spaceship(machine, helper, &visarea); - if (circle_collision(visarea)) + if (circle_collision(&visarea)) starshp1_collision_latch |= 1; if (circle_collision(&rect)) @@ -436,6 +436,6 @@ VIDEO_EOF( starshp1 ) if (spaceship_collision(helper, &rect)) starshp1_collision_latch |= 4; - if (spaceship_collision(helper, visarea)) + if (spaceship_collision(helper, &visarea)) starshp1_collision_latch |= 8; } diff --git a/src/mame/video/stvvdp2.c b/src/mame/video/stvvdp2.c index 04c53207a61..941ea562a51 100644 --- a/src/mame/video/stvvdp2.c +++ b/src/mame/video/stvvdp2.c @@ -2911,8 +2911,8 @@ static void stv_vdp2_draw_basic_bitmap(running_machine *machine, bitmap_t *bitma stv2_current_tilemap.bitmap_palette_number+=stv2_current_tilemap.colour_ram_address_offset; stv2_current_tilemap.bitmap_palette_number&=7;//safety check - screen_x = video_screen_get_visible_area(machine->primary_screen)->max_x; - screen_y = video_screen_get_visible_area(machine->primary_screen)->max_y; + screen_x = machine->primary_screen->visible_area().max_x; + screen_y = machine->primary_screen->visible_area().max_y; switch(stv2_current_tilemap.colour_depth) { @@ -4880,7 +4880,7 @@ static void stv_vdp2_draw_rotation_screen(running_machine *machine, bitmap_t *bi else { if ( stv_vdp2_roz_bitmap[iRP-1] == NULL ) - stv_vdp2_roz_bitmap[iRP-1] = bitmap_alloc(4096, 4096, video_screen_get_format(machine->primary_screen)); + stv_vdp2_roz_bitmap[iRP-1] = auto_alloc(machine, bitmap_t(4096, 4096, machine->primary_screen->format())); roz_clip_rect.min_x = roz_clip_rect.min_y = 0; if ( (iRP == 1 && STV_VDP2_RAOVR == 3) || @@ -5295,8 +5295,8 @@ static UINT8 get_hblank(running_machine *machine) { static int cur_h; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); - cur_h = video_screen_get_hpos(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); + cur_h = machine->primary_screen->hpos(); if (cur_h > visarea.max_x) return 1; @@ -5321,8 +5321,8 @@ static int get_hblank_duration(running_machine *machine) UINT8 stv_get_vblank(running_machine *machine) { static int cur_v; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); - cur_v = video_screen_get_vpos(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); + cur_v = machine->primary_screen->vpos(); if (cur_v > visarea.max_y) return 1; @@ -5356,7 +5356,7 @@ static int get_vblank_duration(running_machine *machine) static UINT8 get_odd_bit(running_machine *machine) { static int cur_v; - cur_v = video_screen_get_vpos(machine->primary_screen); + cur_v = machine->primary_screen->vpos(); if(STV_VDP2_HRES & 4) //exclusive monitor mode makes this bit to be always 1 return 1; @@ -5389,8 +5389,8 @@ READ32_HANDLER ( stv_vdp2_regs_r ) { static UINT16 h_count,v_count; /* TODO: handle various h/v settings. */ - h_count = video_screen_get_hpos(space->machine->primary_screen) & 0x3ff; - v_count = video_screen_get_vpos(space->machine->primary_screen) & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); + h_count = space->machine->primary_screen->hpos() & 0x3ff; + v_count = space->machine->primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); stv_vdp2_regs[offset] = (h_count<<16)|(v_count); if(LOG_VDP2) logerror("CPU %s PC(%08x) = VDP2: H/V counter read : %08x\n", space->cpu->tag(), cpu_get_pc(space->cpu),stv_vdp2_regs[offset]); break; @@ -5424,10 +5424,6 @@ static STATE_POSTLOAD( stv_vdp2_state_save_postload ) static void stv_vdp2_exit (running_machine *machine) { - if (stv_vdp2_roz_bitmap[0] != NULL) - bitmap_free(stv_vdp2_roz_bitmap[0]); - if (stv_vdp2_roz_bitmap[1] != NULL) - bitmap_free(stv_vdp2_roz_bitmap[1]); stv_vdp2_roz_bitmap[0] = stv_vdp2_roz_bitmap[1] = NULL; } @@ -5475,8 +5471,6 @@ VIDEO_START( stv_vdp2 ) gfx_element_set_source(machine->gfx[7], stv_vdp1_gfx_decode); } -/*TODO: frame_period should be different for every kind of resolution (needs tests on actual boards)*/ -/* & height / width not yet understood (docs-wise MUST be bigger than normal visible area)*/ static void stv_vdp2_dynamic_res_change(running_machine *machine) { static UINT8 old_vres = 0,old_hres = 0; @@ -5513,7 +5507,7 @@ static void stv_vdp2_dynamic_res_change(running_machine *machine) if(old_vres != vert_res || old_hres != horz_res) { int vblank_period,hblank_period; - rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); + rectangle visarea = machine->primary_screen->visible_area(); visarea.min_x = 0; visarea.max_x = horz_res-1; visarea.min_y = 0; @@ -5523,12 +5517,12 @@ static void stv_vdp2_dynamic_res_change(running_machine *machine) hblank_period = get_hblank_duration(machine); // popmessage("%d",vblank_period); // hblank_period = get_hblank_duration(machine->primary_screen); - video_screen_configure(machine->primary_screen, (horz_res+hblank_period), (vert_res+vblank_period), &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); + machine->primary_screen->configure((horz_res+hblank_period), (vert_res+vblank_period), visarea, machine->primary_screen->frame_period().attoseconds ); old_vres = vert_res; old_hres = horz_res; } -// video_screen_set_visarea(machine->primary_screen, 0*8, horz_res-1,0*8, vert_res-1); +// machine->primary_screen->set_visible_area(0*8, horz_res-1,0*8, vert_res-1); //if(LOG_VDP2) popmessage("%04d %04d",horz_res-1,vert-1); } diff --git a/src/mame/video/suna16.c b/src/mame/video/suna16.c index b49e59a3ffa..71cba2dac09 100644 --- a/src/mame/video/suna16.c +++ b/src/mame/video/suna16.c @@ -120,8 +120,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta { int offs; - int max_x = video_screen_get_width(machine->primary_screen) - 8; - int max_y = video_screen_get_height(machine->primary_screen) - 8; + int max_x = machine->primary_screen->width() - 8; + int max_y = machine->primary_screen->height() - 8; for ( offs = 0xfc00/2; offs < 0x10000/2 ; offs += 4/2 ) { diff --git a/src/mame/video/suna8.c b/src/mame/video/suna8.c index 7594756b055..08f6d5bc20c 100644 --- a/src/mame/video/suna8.c +++ b/src/mame/video/suna8.c @@ -205,8 +205,8 @@ static void draw_normal_sprites(running_machine *machine, bitmap_t *bitmap,const int i; int mx = 0; // multisprite x counter - int max_x = video_screen_get_width(machine->primary_screen) - 8; - int max_y = video_screen_get_height(machine->primary_screen) - 8; + int max_x = machine->primary_screen->width() - 8; + int max_y = machine->primary_screen->height() - 8; for (i = 0x1d00; i < 0x2000; i += 4) { @@ -337,8 +337,8 @@ static void draw_text_sprites(running_machine *machine, bitmap_t *bitmap,const r UINT8 *spriteram = machine->generic.spriteram.u8; int i; - int max_x = video_screen_get_width(machine->primary_screen) - 8; - int max_y = video_screen_get_height(machine->primary_screen) - 8; + int max_x = machine->primary_screen->width() - 8; + int max_y = machine->primary_screen->height() - 8; /* Earlier games only */ if (!(suna8_text_dim > 0)) return; diff --git a/src/mame/video/supbtime.c b/src/mame/video/supbtime.c index 67c6512b3de..5714172f5d3 100644 --- a/src/mame/video/supbtime.c +++ b/src/mame/video/supbtime.c @@ -34,7 +34,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/superqix.c b/src/mame/video/superqix.c index 9cd29954dbe..d7e9b4bc155 100644 --- a/src/mame/video/superqix.c +++ b/src/mame/video/superqix.c @@ -66,8 +66,8 @@ VIDEO_START( pbillian ) VIDEO_START( superqix ) { - fg_bitmap[0] = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); - fg_bitmap[1] = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen)); + fg_bitmap[0] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); + fg_bitmap[1] = auto_bitmap_alloc(machine, 256, 256, machine->primary_screen->format()); bg_tilemap = tilemap_create(machine, sqix_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000); /* split type 0 is totally transparent in front half */ diff --git a/src/mame/video/suprnova.c b/src/mame/video/suprnova.c index 6e9dabcaad3..cbd3f57eebe 100644 --- a/src/mame/video/suprnova.c +++ b/src/mame/video/suprnova.c @@ -673,12 +673,12 @@ void skns_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectang if (sprite_flip&2) { xflip ^= 1; - sx = video_screen_get_visible_area(machine->primary_screen)->max_x+1 - sx; + sx = machine->primary_screen->visible_area().max_x+1 - sx; } if (sprite_flip&1) { yflip ^= 1; - sy = video_screen_get_visible_area(machine->primary_screen)->max_y+1 - sy; + sy = machine->primary_screen->visible_area().max_y+1 - sy; } /* Palette linking */ diff --git a/src/mame/video/suprridr.c b/src/mame/video/suprridr.c index 5a7261e7165..953730b3868 100644 --- a/src/mame/video/suprridr.c +++ b/src/mame/video/suprridr.c @@ -170,22 +170,22 @@ VIDEO_UPDATE( suprridr ) UINT8 *spriteram = screen->machine->generic.spriteram.u8; rectangle subclip; int i; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); /* render left 4 columns with no scroll */ - subclip = *visarea;; + subclip = visarea;; subclip.max_x = subclip.min_x + (flipx ? 1*8 : 4*8) - 1; sect_rect(&subclip, cliprect); tilemap_draw(bitmap, &subclip, bg_tilemap_noscroll, 0, 0); /* render right 1 column with no scroll */ - subclip = *visarea;; + subclip = visarea;; subclip.min_x = subclip.max_x - (flipx ? 4*8 : 1*8) + 1; sect_rect(&subclip, cliprect); tilemap_draw(bitmap, &subclip, bg_tilemap_noscroll, 0, 0); /* render the middle columns normally */ - subclip = *visarea;; + subclip = visarea;; subclip.min_x += flipx ? 1*8 : 4*8; subclip.max_x -= flipx ? 4*8 : 1*8; sect_rect(&subclip, cliprect); diff --git a/src/mame/video/system1.c b/src/mame/video/system1.c index 7662f2264de..ae2c2514957 100644 --- a/src/mame/video/system1.c +++ b/src/mame/video/system1.c @@ -194,19 +194,19 @@ if (data & 0x6e) logerror("videomode = %02x\n",data); READ8_HANDLER( system1_mixer_collision_r ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); return mix_collide[offset & 0x3f] | 0x7e | (mix_collide_summary << 7); } WRITE8_HANDLER( system1_mixer_collision_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); mix_collide[offset & 0x3f] = 0; } WRITE8_HANDLER( system1_mixer_collision_reset_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); mix_collide_summary = 0; } @@ -220,19 +220,19 @@ WRITE8_HANDLER( system1_mixer_collision_reset_w ) READ8_HANDLER( system1_sprite_collision_r ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); return sprite_collide[offset & 0x3ff] | 0x7e | (sprite_collide_summary << 7); } WRITE8_HANDLER( system1_sprite_collision_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); sprite_collide[offset & 0x3ff] = 0; } WRITE8_HANDLER( system1_sprite_collision_reset_w ) { - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); sprite_collide_summary = 0; } @@ -276,7 +276,7 @@ WRITE8_HANDLER( system1_videoram_w ) /* force a partial update if the page is changing */ if (tilemap_pages > 2 && offset >= 0x740 && offset < 0x748 && offset % 2 == 0) - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); } WRITE8_DEVICE_HANDLER( system1_videoram_bank_w ) diff --git a/src/mame/video/taito_b.c b/src/mame/video/taito_b.c index ead1f3ccea4..23186f8edc8 100644 --- a/src/mame/video/taito_b.c +++ b/src/mame/video/taito_b.c @@ -39,8 +39,8 @@ static VIDEO_START( taitob_core ) { taitob_state *state = (taitob_state *)machine->driver_data; - state->framebuffer[0] = auto_bitmap_alloc(machine, 512, 256, video_screen_get_format(machine->primary_screen)); - state->framebuffer[1] = auto_bitmap_alloc(machine, 512, 256, video_screen_get_format(machine->primary_screen)); + state->framebuffer[0] = auto_bitmap_alloc(machine, 512, 256, machine->primary_screen->format()); + state->framebuffer[1] = auto_bitmap_alloc(machine, 512, 256, machine->primary_screen->format()); state->pixel_bitmap = NULL; /* only hitice needs this */ state_save_register_global_array(machine, state->pixel_scroll); @@ -91,7 +91,7 @@ VIDEO_START( hitice ) state->b_fg_color_base = 0x80; /* hitice also uses this for the pixel_bitmap */ - state->pixel_bitmap = auto_bitmap_alloc(machine, 1024, 512, video_screen_get_format(machine->primary_screen)); + state->pixel_bitmap = auto_bitmap_alloc(machine, 1024, 512, machine->primary_screen->format()); state_save_register_global_bitmap(machine, state->pixel_bitmap); } @@ -398,7 +398,7 @@ VIDEO_EOF( taitob ) UINT8 framebuffer_page = tc0180vcu_get_fb_page(state->tc0180vcu, 0); if (~video_control & 0x01) - bitmap_fill(state->framebuffer[framebuffer_page], video_screen_get_visible_area(machine->primary_screen), 0); + bitmap_fill(state->framebuffer[framebuffer_page], &machine->primary_screen->visible_area(), 0); if (~video_control & 0x80) { @@ -406,5 +406,5 @@ VIDEO_EOF( taitob ) tc0180vcu_set_fb_page(state->tc0180vcu, 0, framebuffer_page); } - draw_sprites(machine, state->framebuffer[framebuffer_page], video_screen_get_visible_area(machine->primary_screen)); + draw_sprites(machine, state->framebuffer[framebuffer_page], &machine->primary_screen->visible_area()); } diff --git a/src/mame/video/taito_f3.c b/src/mame/video/taito_f3.c index 1c09270500e..083e3abe03a 100644 --- a/src/mame/video/taito_f3.c +++ b/src/mame/video/taito_f3.c @@ -671,8 +671,8 @@ VIDEO_START( f3 ) pixel_layer = tilemap_create(machine, get_tile_info_pixel,tilemap_scan_cols,8,8,64,32); pf_line_inf = auto_alloc_array(machine, struct f3_playfield_line_inf, 5); sa_line_inf = auto_alloc_array(machine, struct f3_spritealpha_line_inf, 1); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); pri_alp_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8 ); tile_opaque_sp = auto_alloc_array(machine, UINT8, machine->gfx[2]->total_elements); for (i=0; i<4; i++) @@ -2919,9 +2919,9 @@ INLINE void f3_drawgfxzoom( static void get_sprite_info(running_machine *machine, const UINT32 *spriteram32_ptr) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); - const int min_x=visarea->min_x,max_x=visarea->max_x; - const int min_y=visarea->min_y,max_y=visarea->max_y; + const rectangle &visarea = machine->primary_screen->visible_area(); + const int min_x=visarea.min_x,max_x=visarea.max_x; + const int min_y=visarea.min_y,max_y=visarea.max_y; int offs,spritecont,flipx,flipy,/*old_x,*/color,x,y; int sprite,global_x=0,global_y=0,subglobal_x=0,subglobal_y=0; int block_x=0, block_y=0; diff --git a/src/mame/video/taitoic.c b/src/mame/video/taitoic.c index 0405d1a0418..c37d0f3bc2e 100644 --- a/src/mame/video/taitoic.c +++ b/src/mame/video/taitoic.c @@ -570,17 +570,16 @@ struct _pc080sn_state INLINE pc080sn_state *pc080sn_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == PC080SN); + assert(device->type() == PC080SN); - return (pc080sn_state *)device->token; + return (pc080sn_state *)downcast(device)->token(); } INLINE const pc080sn_interface *pc080sn_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == PC080SN)); - return (const pc080sn_interface *) device->baseconfig().static_config; + assert((device->type() == PC080SN)); + return (const pc080sn_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -1064,17 +1063,16 @@ struct _pc090oj_state INLINE pc090oj_state *pc090oj_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == PC090OJ); + assert(device->type() == PC090OJ); - return (pc090oj_state *)device->token; + return (pc090oj_state *)downcast(device)->token(); } INLINE const pc090oj_interface *pc090oj_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == PC090OJ)); - return (const pc090oj_interface *) device->baseconfig().static_config; + assert((device->type() == PC090OJ)); + return (const pc090oj_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -1273,17 +1271,16 @@ struct _tc0080vco_state INLINE tc0080vco_state *tc0080vco_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0080VCO); + assert(device->type() == TC0080VCO); - return (tc0080vco_state *)device->token; + return (tc0080vco_state *)downcast(device)->token(); } INLINE const tc0080vco_interface *tc0080vco_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0080VCO)); - return (const tc0080vco_interface *) device->baseconfig().static_config; + assert((device->type() == TC0080VCO)); + return (const tc0080vco_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -1945,7 +1942,7 @@ struct _tc0100scn_state INT32 bg0_colbank, bg1_colbank, tx_colbank; int dblwidth; - running_device *screen; + screen_device *screen; }; #define TC0100SCN_RAM_SIZE 0x14000 /* enough for double-width tilemaps */ @@ -1958,17 +1955,16 @@ struct _tc0100scn_state INLINE tc0100scn_state *tc0100scn_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0100SCN); + assert(device->type() == TC0100SCN); - return (tc0100scn_state *)device->token; + return (tc0100scn_state *)downcast(device)->token(); } INLINE const tc0100scn_interface *tc0100scn_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0100SCN)); - return (const tc0100scn_interface *) device->baseconfig().static_config; + assert((device->type() == TC0100SCN)); + return (const tc0100scn_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -2429,14 +2425,14 @@ static DEVICE_START( tc0100scn ) const tc0100scn_interface *intf = tc0100scn_get_interface(device); int xd, yd; - tc0100scn->screen = devtag_get_device(device->machine, intf->screen); + tc0100scn->screen = device->machine->device(intf->screen); /* Set up clipping for multi-TC0100SCN games. We assume this code won't ever affect single screen games: Thundfox is the only one of those with two chips, and we're safe as it uses single width tilemaps. */ - tc0100scn->cliprect = *video_screen_get_visible_area(tc0100scn->screen); + tc0100scn->cliprect = tc0100scn->screen->visible_area(); /* use the given gfx sets for bg/tx tiles*/ tc0100scn->bg_gfx = intf->gfxnum; /* 2nd/3rd chips will use the same gfx set */ @@ -2565,17 +2561,16 @@ struct _tc0280grd_state INLINE tc0280grd_state *tc0280grd_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert((device->type == TC0280GRD) || (device->type == TC0430GRW)); + assert((device->type() == TC0280GRD) || (device->type() == TC0430GRW)); - return (tc0280grd_state *)device->token; + return (tc0280grd_state *)downcast(device)->token(); } INLINE const tc0280grd_interface *tc0280grd_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0280GRD) || (device->type == TC0430GRW)); - return (const tc0280grd_interface *) device->baseconfig().static_config; + assert((device->type() == TC0280GRD) || (device->type() == TC0430GRW)); + return (const tc0280grd_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -2736,10 +2731,9 @@ struct _tc0360pri_state INLINE tc0360pri_state *tc0360pri_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0360PRI); + assert(device->type() == TC0360PRI); - return (tc0360pri_state *)device->token; + return (tc0360pri_state *)downcast(device)->token(); } /***************************************************************************** @@ -2829,17 +2823,16 @@ struct _tc0480scp_state INLINE tc0480scp_state *tc0480scp_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0480SCP); + assert(device->type() == TC0480SCP); - return (tc0480scp_state *)device->token; + return (tc0480scp_state *)downcast(device)->token(); } INLINE const tc0480scp_interface *tc0480scp_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0480SCP)); - return (const tc0480scp_interface *) device->baseconfig().static_config; + assert((device->type() == TC0480SCP)); + return (const tc0480scp_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -3772,17 +3765,16 @@ struct _tc0150rod_state INLINE tc0150rod_state *tc0150rod_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0150ROD); + assert(device->type() == TC0150ROD); - return (tc0150rod_state *)device->token; + return (tc0150rod_state *)downcast(device)->token(); } INLINE const tc0150rod_interface *tc0150rod_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0150ROD)); - return (const tc0150rod_interface *) device->baseconfig().static_config; + assert((device->type() == TC0150ROD)); + return (const tc0150rod_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -4583,17 +4575,16 @@ struct _tc0110pcr_state INLINE tc0110pcr_state *tc0110pcr_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0110PCR); + assert(device->type() == TC0110PCR); - return (tc0110pcr_state *)device->token; + return (tc0110pcr_state *)downcast(device)->token(); } INLINE const tc0110pcr_interface *tc0110pcr_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0110PCR)); - return (const tc0110pcr_interface *) device->baseconfig().static_config; + assert((device->type() == TC0110PCR)); + return (const tc0110pcr_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -4814,17 +4805,16 @@ struct _tc0180vcu_state INLINE tc0180vcu_state *tc0180vcu_get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == TC0180VCU); + assert(device->type() == TC0180VCU); - return (tc0180vcu_state *)device->token; + return (tc0180vcu_state *)downcast(device)->token(); } INLINE const tc0180vcu_interface *tc0180vcu_get_interface( running_device *device ) { assert(device != NULL); - assert((device->type == TC0180VCU)); - return (const tc0180vcu_interface *) device->baseconfig().static_config; + assert((device->type() == TC0180VCU)); + return (const tc0180vcu_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -5147,7 +5137,6 @@ DEVICE_GET_INFO( pc080sn ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pc080sn_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pc080sn); break; @@ -5169,7 +5158,6 @@ DEVICE_GET_INFO( pc090oj ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(pc090oj_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(pc090oj); break; @@ -5191,7 +5179,6 @@ DEVICE_GET_INFO( tc0080vco ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0080vco_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0080vco); break; @@ -5213,7 +5200,6 @@ DEVICE_GET_INFO( tc0110pcr ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0110pcr_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0110pcr); break; @@ -5235,7 +5221,6 @@ DEVICE_GET_INFO( tc0100scn ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0100scn_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0100scn); break; @@ -5257,7 +5242,6 @@ DEVICE_GET_INFO( tc0280grd ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0280grd_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0280grd); break; @@ -5279,7 +5263,6 @@ DEVICE_GET_INFO( tc0360pri ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0360pri_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0360pri); break; @@ -5301,7 +5284,6 @@ DEVICE_GET_INFO( tc0480scp ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0480scp_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0480scp); break; @@ -5323,7 +5305,6 @@ DEVICE_GET_INFO( tc0150rod ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0150rod_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0150rod); break; @@ -5345,7 +5326,6 @@ DEVICE_GET_INFO( tc0180vcu ) { /* --- the following bits of info are returned as 64-bit signed integers --- */ case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(tc0180vcu_state); break; - case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_VIDEO; break; /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(tc0180vcu); break; diff --git a/src/mame/video/taitoic.h b/src/mame/video/taitoic.h index 455c00d8236..8c9ba0a2f61 100644 --- a/src/mame/video/taitoic.h +++ b/src/mame/video/taitoic.h @@ -6,7 +6,7 @@ **************************************************************************/ -#include "devcb.h" +#include "devlegcy.h" /*************************************************************************** TYPE DEFINITIONS @@ -106,53 +106,38 @@ struct _tc0180vcu_interface int tx_color_base; }; - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -DEVICE_GET_INFO( pc080sn ); -DEVICE_GET_INFO( pc090oj ); -DEVICE_GET_INFO( tc0080vco ); -DEVICE_GET_INFO( tc0100scn ); -DEVICE_GET_INFO( tc0280grd ); -DEVICE_GET_INFO( tc0360pri ); -DEVICE_GET_INFO( tc0480scp ); -DEVICE_GET_INFO( tc0150rod ); -DEVICE_GET_INFO( tc0110pcr ); -DEVICE_GET_INFO( tc0180vcu ); +DECLARE_LEGACY_DEVICE(PC080SN, pc080sn); +DECLARE_LEGACY_DEVICE(PC090OJ, pc090oj); +DECLARE_LEGACY_DEVICE(TC0080VCO, tc0080vco); +DECLARE_LEGACY_DEVICE(TC0100SCN, tc0100scn); +DECLARE_LEGACY_DEVICE(TC0280GRD, tc0280grd); +DECLARE_LEGACY_DEVICE(TC0430GRW, tc0280grd); +DECLARE_LEGACY_DEVICE(TC0360PRI, tc0360pri); +DECLARE_LEGACY_DEVICE(TC0480SCP, tc0480scp); +DECLARE_LEGACY_DEVICE(TC0150ROD, tc0150rod); +DECLARE_LEGACY_DEVICE(TC0110PCR, tc0110pcr); +DECLARE_LEGACY_DEVICE(TC0180VCU, tc0180vcu); /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define PC080SN DEVICE_GET_INFO_NAME( pc080sn ) - #define MDRV_PC080SN_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, PC080SN, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define PC090OJ DEVICE_GET_INFO_NAME( pc090oj ) - #define MDRV_PC090OJ_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, PC090OJ, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0080VCO DEVICE_GET_INFO_NAME( tc0080vco ) - #define MDRV_TC0080VCO_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0080VCO, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0100SCN DEVICE_GET_INFO_NAME( tc0100scn ) - #define MDRV_TC0100SCN_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0100SCN, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0280GRD DEVICE_GET_INFO_NAME( tc0280grd ) -#define TC0430GRW DEVICE_GET_INFO_NAME( tc0280grd ) - #define MDRV_TC0280GRD_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0280GRD, 0) \ MDRV_DEVICE_CONFIG(_interface) @@ -161,31 +146,21 @@ DEVICE_GET_INFO( tc0180vcu ); MDRV_DEVICE_ADD(_tag, TC0430GRW, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0360PRI DEVICE_GET_INFO_NAME( tc0360pri ) - #define MDRV_TC0360PRI_ADD(_tag) \ MDRV_DEVICE_ADD(_tag, TC0360PRI, 0) -#define TC0150ROD DEVICE_GET_INFO_NAME( tc0150rod ) - #define MDRV_TC0150ROD_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0150ROD, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0480SCP DEVICE_GET_INFO_NAME( tc0480scp ) - #define MDRV_TC0480SCP_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0480SCP, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0110PCR DEVICE_GET_INFO_NAME( tc0110pcr ) - #define MDRV_TC0110PCR_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0110PCR, 0) \ MDRV_DEVICE_CONFIG(_interface) -#define TC0180VCU DEVICE_GET_INFO_NAME( tc0180vcu ) - #define MDRV_TC0180VCU_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, TC0180VCU, 0) \ MDRV_DEVICE_CONFIG(_interface) diff --git a/src/mame/video/taitojc.c b/src/mame/video/taitojc.c index ed080bff40b..36af98fad39 100644 --- a/src/mame/video/taitojc.c +++ b/src/mame/video/taitojc.c @@ -198,10 +198,10 @@ VIDEO_START( taitojc ) state->texture = auto_alloc_array(machine, UINT8, 0x400000); - state->framebuffer = video_screen_auto_bitmap_alloc(machine->primary_screen); + state->framebuffer = machine->primary_screen->alloc_compatible_bitmap(); - width = video_screen_get_width(machine->primary_screen); - height = video_screen_get_height(machine->primary_screen); + width = machine->primary_screen->width(); + height = machine->primary_screen->height(); state->zbuffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); } @@ -481,7 +481,7 @@ void taitojc_render_polygons(running_machine *machine, UINT16 *polygon_fifo, int if (vert[0].p[0] < 0x8000 && vert[1].p[0] < 0x8000 && vert[2].p[0] < 0x8000) { - poly_render_triangle(state->poly, state->framebuffer, video_screen_get_visible_area(machine->primary_screen), render_texture_scan, 4, &vert[0], &vert[1], &vert[2]); + poly_render_triangle(state->poly, state->framebuffer, &machine->primary_screen->visible_area(), render_texture_scan, 4, &vert[0], &vert[1], &vert[2]); } break; } @@ -529,11 +529,11 @@ void taitojc_render_polygons(running_machine *machine, UINT16 *polygon_fifo, int vert[2].p[1] == vert[3].p[1]) { // optimization: all colours the same -> render solid - poly_render_quad(state->poly, state->framebuffer, video_screen_get_visible_area(machine->primary_screen), render_solid_scan, 2, &vert[0], &vert[1], &vert[2], &vert[3]); + poly_render_quad(state->poly, state->framebuffer, &machine->primary_screen->visible_area(), render_solid_scan, 2, &vert[0], &vert[1], &vert[2], &vert[3]); } else { - poly_render_quad(state->poly, state->framebuffer, video_screen_get_visible_area(machine->primary_screen), render_shade_scan, 2, &vert[0], &vert[1], &vert[2], &vert[3]); + poly_render_quad(state->poly, state->framebuffer, &machine->primary_screen->visible_area(), render_shade_scan, 2, &vert[0], &vert[1], &vert[2], &vert[3]); } } break; @@ -601,7 +601,7 @@ void taitojc_render_polygons(running_machine *machine, UINT16 *polygon_fifo, int if (vert[0].p[0] < 0x8000 && vert[1].p[0] < 0x8000 && vert[2].p[0] < 0x8000 && vert[3].p[0] < 0x8000) { - poly_render_quad(state->poly, state->framebuffer, video_screen_get_visible_area(machine->primary_screen), render_texture_scan, 4, &vert[0], &vert[1], &vert[2], &vert[3]); + poly_render_quad(state->poly, state->framebuffer, &machine->primary_screen->visible_area(), render_texture_scan, 4, &vert[0], &vert[1], &vert[2], &vert[3]); } break; } @@ -627,8 +627,8 @@ void taitojc_clear_frame(running_machine *machine) cliprect.min_x = 0; cliprect.min_y = 0; - cliprect.max_x = video_screen_get_width(machine->primary_screen) - 1; - cliprect.max_y = video_screen_get_height(machine->primary_screen) - 1; + cliprect.max_x = machine->primary_screen->width() - 1; + cliprect.max_y = machine->primary_screen->height() - 1; bitmap_fill(state->framebuffer, &cliprect, 0); bitmap_fill(state->zbuffer, &cliprect, 0xffff); diff --git a/src/mame/video/taitosj.c b/src/mame/video/taitosj.c index 2cfbd5b5806..41bec3888ae 100644 --- a/src/mame/video/taitosj.c +++ b/src/mame/video/taitosj.c @@ -192,16 +192,16 @@ VIDEO_START( taitosj ) { int i; - sprite_layer_collbitmap1 = auto_bitmap_alloc(machine,16,16,video_screen_get_format(machine->primary_screen)); + sprite_layer_collbitmap1 = auto_bitmap_alloc(machine,16,16,machine->primary_screen->format()); for (i = 0; i < 3; i++) { - taitosj_layer_bitmap[i] = video_screen_auto_bitmap_alloc(machine->primary_screen); - sprite_layer_collbitmap2[i] = video_screen_auto_bitmap_alloc(machine->primary_screen); + taitosj_layer_bitmap[i] = machine->primary_screen->alloc_compatible_bitmap(); + sprite_layer_collbitmap2[i] = machine->primary_screen->alloc_compatible_bitmap(); } - sprite_sprite_collbitmap1 = auto_bitmap_alloc(machine,32,32,video_screen_get_format(machine->primary_screen)); - sprite_sprite_collbitmap2 = auto_bitmap_alloc(machine,32,32,video_screen_get_format(machine->primary_screen)); + sprite_sprite_collbitmap1 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format()); + sprite_sprite_collbitmap2 = auto_bitmap_alloc(machine,32,32,machine->primary_screen->format()); gfx_element_set_source(machine->gfx[0], taitosj_characterram); gfx_element_set_source(machine->gfx[1], taitosj_characterram); @@ -412,8 +412,8 @@ static void check_sprite_sprite_collision(running_machine *machine) static void calculate_sprite_areas(running_machine *machine, int *sprites_on, rectangle *sprite_areas) { int which; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); for (which = 0; which < 0x20; which++) { diff --git a/src/mame/video/tank8.c b/src/mame/video/tank8.c index a0a3ad8524b..a7f0ef30c72 100644 --- a/src/mame/video/tank8.c +++ b/src/mame/video/tank8.c @@ -115,9 +115,9 @@ static TILE_GET_INFO( tank8_get_tile_info ) VIDEO_START( tank8 ) { - helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen); - helper3 = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper1 = machine->primary_screen->alloc_compatible_bitmap(); + helper2 = machine->primary_screen->alloc_compatible_bitmap(); + helper3 = machine->primary_screen->alloc_compatible_bitmap(); tank8_tilemap = tilemap_create(machine, tank8_get_tile_info, tilemap_scan_rows, 16, 16, 32, 32); @@ -214,17 +214,17 @@ VIDEO_EOF( tank8 ) { int x; int y; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - tilemap_draw(helper1, visarea, tank8_tilemap, 0, 0); + tilemap_draw(helper1, &visarea, tank8_tilemap, 0, 0); - bitmap_fill(helper2, visarea, 8); - bitmap_fill(helper3, visarea, 8); + bitmap_fill(helper2, &visarea, 8); + bitmap_fill(helper3, &visarea, 8); - draw_sprites(machine, helper2, visarea); - draw_bullets(helper3, visarea); + draw_sprites(machine, helper2, &visarea); + draw_bullets(helper3, &visarea); - for (y = visarea->min_y; y <= visarea->max_y; y++) + for (y = visarea.min_y; y <= visarea.max_y; y++) { int state = 0; @@ -232,10 +232,10 @@ VIDEO_EOF( tank8 ) const UINT16* p2 = BITMAP_ADDR16(helper2, y, 0); const UINT16* p3 = BITMAP_ADDR16(helper3, y, 0); - if (y % 2 != video_screen_get_frame_number(machine->primary_screen) % 2) + if (y % 2 != machine->primary_screen->frame_number() % 2) continue; /* video display is interlaced */ - for (x = visarea->min_x; x <= visarea->max_x; x++) + for (x = visarea.min_x; x <= visarea.max_x; x++) { UINT8 index; @@ -291,7 +291,7 @@ VIDEO_EOF( tank8 ) index |= 0x80; /* collision on right side */ } - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, y, x), NULL, index, tank8_collision_callback); + timer_set(machine, machine->primary_screen->time_until_pos(y, x), NULL, index, tank8_collision_callback); state = 1; } diff --git a/src/mame/video/taotaido.c b/src/mame/video/taotaido.c index b206b097c94..d9ba7332081 100644 --- a/src/mame/video/taotaido.c +++ b/src/mame/video/taotaido.c @@ -210,11 +210,11 @@ VIDEO_UPDATE(taotaido) int line; rectangle clip; - const rectangle *visarea = video_screen_get_visible_area(screen); - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + const rectangle &visarea = screen->visible_area(); + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; for (line = 0; line < 224;line++) { diff --git a/src/mame/video/tceptor.c b/src/mame/video/tceptor.c index dfd57c1cd41..1a1a450cfda 100644 --- a/src/mame/video/tceptor.c +++ b/src/mame/video/tceptor.c @@ -403,7 +403,7 @@ VIDEO_START( tceptor ) decode_sprite32(machine, "gfx4"); /* allocate temp bitmaps */ - temp_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + temp_bitmap = machine->primary_screen->alloc_compatible_bitmap(); namco_road_init(machine, gfx_index); @@ -540,7 +540,7 @@ VIDEO_UPDATE( tceptor ) if (screen != _2d_screen) { - int frame = video_screen_get_frame_number(screen); + int frame = screen->frame_number(); if ((frame & 1) == 1 && screen == _3d_left_screen) return UPDATE_HAS_NOT_CHANGED; diff --git a/src/mame/video/tecmo16.c b/src/mame/video/tecmo16.c index be6a2d55e22..bffdc64cc45 100644 --- a/src/mame/video/tecmo16.c +++ b/src/mame/video/tecmo16.c @@ -64,8 +64,8 @@ static TILE_GET_INFO( tx_get_tile_info ) VIDEO_START( fstarfrc ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -89,8 +89,8 @@ VIDEO_START( fstarfrc ) VIDEO_START( ginkun ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); @@ -112,8 +112,8 @@ VIDEO_START( ginkun ) VIDEO_START( riot ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); /* set up tile layers */ tile_bitmap_bg = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); diff --git a/src/mame/video/tia.c b/src/mame/video/tia.c index 89ae5b112b4..b5432bee36f 100644 --- a/src/mame/video/tia.c +++ b/src/mame/video/tia.c @@ -271,18 +271,18 @@ PALETTE_INIT( tia_PAL ) VIDEO_START( tia ) { - int cx = video_screen_get_width(machine->primary_screen); + int cx = machine->primary_screen->width(); - screen_height = video_screen_get_height(machine->primary_screen); - helper[0] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); - helper[1] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); - helper[2] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, video_screen_get_format(machine->primary_screen)); + screen_height = machine->primary_screen->height(); + helper[0] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, machine->primary_screen->format()); + helper[1] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, machine->primary_screen->format()); + helper[2] = auto_bitmap_alloc(machine, cx, TIA_MAX_SCREEN_HEIGHT, machine->primary_screen->format()); } VIDEO_UPDATE( tia ) { - screen_height = video_screen_get_height(screen); + screen_height = screen->height(); copybitmap(bitmap, helper[2], 0, 0, 0, 0, cliprect); return 0; } @@ -872,8 +872,8 @@ static WRITE8_HANDLER( VSYNC_w ) if ( curr_y > 5 ) update_bitmap( - video_screen_get_width(space->machine->primary_screen), - video_screen_get_height(space->machine->primary_screen)); + space->machine->primary_screen->width(), + space->machine->primary_screen->height()); if ( tia_vsync_callback ) { tia_vsync_callback( space, 0, curr_y, 0xFFFF ); diff --git a/src/mame/video/timeplt.c b/src/mame/video/timeplt.c index 3bce015f9f3..9bdeed2afdc 100644 --- a/src/mame/video/timeplt.c +++ b/src/mame/video/timeplt.c @@ -165,7 +165,7 @@ WRITE8_HANDLER( timeplt_flipscreen_w ) READ8_HANDLER( timeplt_scanline_r ) { - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } diff --git a/src/mame/video/toaplan1.c b/src/mame/video/toaplan1.c index 39c3753ce0c..51f373e5e4e 100644 --- a/src/mame/video/toaplan1.c +++ b/src/mame/video/toaplan1.c @@ -427,7 +427,7 @@ VIDEO_START( toaplan1 ) READ16_HANDLER( toaplan1_frame_done_r ) { - return video_screen_get_vblank(space->machine->primary_screen); + return space->machine->primary_screen->vblank(); } WRITE16_HANDLER( toaplan1_tile_offsets_w ) @@ -482,14 +482,14 @@ WRITE16_HANDLER( toaplan1_bcu_flipscreen_w ) tilemap_set_flip_all(space->machine, (data ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0)); if (bcu_flipscreen) { - const rectangle *visarea = video_screen_get_visible_area(space->machine->primary_screen); + const rectangle &visarea = space->machine->primary_screen->visible_area(); scrollx_offs1 = 0x151 - 6; scrollx_offs2 = 0x151 - 4; scrollx_offs3 = 0x151 - 2; scrollx_offs4 = 0x151 - 0; scrolly_offs = 0x1ef; - scrolly_offs += ((visarea->max_y + 1) - ((visarea->max_y + 1) - visarea->min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ + scrolly_offs += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ } else { @@ -1079,11 +1079,11 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta /****** flip the sprite layer ******/ if (fcu_flipscreen) { - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - sx_base = ((visarea->max_x + 1) - visarea->min_x) - (sx_base + 8); /* visarea.x = 320 */ - sy_base = ((visarea->max_y + 1) - visarea->min_y) - (sy_base + 8); /* visarea.y = 240 */ - sy_base += ((visarea->max_y + 1) - ((visarea->max_y + 1) - visarea->min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ + sx_base = ((visarea.max_x + 1) - visarea.min_x) - (sx_base + 8); /* visarea.x = 320 */ + sy_base = ((visarea.max_y + 1) - visarea.min_y) - (sy_base + 8); /* visarea.y = 240 */ + sy_base += ((visarea.max_y + 1) - ((visarea.max_y + 1) - visarea.min_y)) * 2; /* Horizontal games are offset so adjust by +0x20 */ } for (dim_y = 0; dim_y < sprite_sizey; dim_y += 8) diff --git a/src/mame/video/toaplan2.c b/src/mame/video/toaplan2.c index a532a9d1b50..ee4b65cd2bd 100644 --- a/src/mame/video/toaplan2.c +++ b/src/mame/video/toaplan2.c @@ -468,8 +468,8 @@ static void toaplan2_vram_alloc(running_machine *machine, int controller) static void toaplan2_vh_start(running_machine *machine, int controller) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); toaplan2_vram_alloc(machine, controller); @@ -561,8 +561,8 @@ VIDEO_START( toaplan2_1 ) VIDEO_START( truxton2_0 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); toaplan2_vram_alloc(machine, 0); truxton2_create_tilemaps_0(machine); @@ -598,8 +598,8 @@ VIDEO_START( truxton2_0 ) VIDEO_START( bgaregga_0 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); @@ -615,8 +615,8 @@ VIDEO_START( bgaregga_0 ) VIDEO_START( batrider_0 ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); toaplan2_custom_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8); @@ -1038,7 +1038,7 @@ static void toaplan2_scroll_reg_data_w(running_machine *machine, offs_t offset, /* HACK! When tilted, sound CPU needs to be reset. */ running_device *ym = devtag_get_device(machine, "ymsnd"); - if (ym && (sound_get_type(ym) == SOUND_YM3812)) + if (ym && ym->type() == SOUND_YM3812) { cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE); devtag_reset(machine, "ymsnd"); @@ -1534,8 +1534,8 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect void toaplan2_draw_custom_tilemap(running_machine* machine, bitmap_t* bitmap, tilemap_t* tilemap, UINT8* priremap, UINT8* pri_enable ) { - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); int y,x; bitmap_t *tmb = tilemap_get_pixmap(tilemap); UINT16* srcptr; @@ -1659,7 +1659,7 @@ VIDEO_UPDATE( batrider_0 ) { int line; rectangle clip; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); toaplan2_log_vram(screen->machine); @@ -1674,10 +1674,10 @@ VIDEO_UPDATE( batrider_0 ) VIDEO_UPDATE_CALL( toaplan2_0 ); - clip.min_x = visarea->min_x; - clip.max_x = visarea->max_x; - clip.min_y = visarea->min_y; - clip.max_y = visarea->max_y; + clip.min_x = visarea.min_x; + clip.max_x = visarea.max_x; + clip.min_y = visarea.min_y; + clip.max_y = visarea.max_y; /* used for 'for use in' and '8ing' screen on bbakraid, raizing on batrider */ for (line = 0; line < 256;line++) diff --git a/src/mame/video/toki.c b/src/mame/video/toki.c index 52f5e67cb84..39356228d2f 100644 --- a/src/mame/video/toki.c +++ b/src/mame/video/toki.c @@ -32,7 +32,7 @@ remove all the code writing the $a0000 area.) WRITE16_HANDLER( toki_control_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos() - 1); COMBINE_DATA(&toki_scrollram16[offset]); } diff --git a/src/mame/video/toobin.c b/src/mame/video/toobin.c index 2d7bda210f9..ee1fd24f8b6 100644 --- a/src/mame/video/toobin.c +++ b/src/mame/video/toobin.c @@ -96,7 +96,7 @@ VIDEO_START( toobin ) tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0); /* allocate a playfield bitmap for rendering */ - state->pfbitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16); + state->pfbitmap = auto_bitmap_alloc(machine, machine->primary_screen->width(), machine->primary_screen->height(), BITMAP_FORMAT_INDEXED16); state_save_register_global(machine, state->brightness); } @@ -167,7 +167,7 @@ WRITE16_HANDLER( toobin_xscroll_w ) /* if anything has changed, force a partial update */ if (newscroll != oldscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* update the playfield scrolling - hscroll is clocked on the following scanline */ tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, newscroll >> 6); @@ -187,7 +187,7 @@ WRITE16_HANDLER( toobin_yscroll_w ) /* if anything has changed, force a partial update */ if (newscroll != oldscroll) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* if bit 4 is zero, the scroll value is clocked in right away */ tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, newscroll >> 6); @@ -213,7 +213,7 @@ WRITE16_HANDLER( toobin_slip_w ) /* if the SLIP is changing, force a partial update first */ if (oldslip != newslip) - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); /* update the data */ atarimo_0_slipram_w(space, offset, data, mem_mask); diff --git a/src/mame/video/tp84.c b/src/mame/video/tp84.c index 77585f1fd32..da16cd098dd 100644 --- a/src/mame/video/tp84.c +++ b/src/mame/video/tp84.c @@ -116,7 +116,7 @@ PALETTE_INIT( tp84 ) WRITE8_HANDLER( tp84_spriteram_w ) { /* the game multiplexes the sprites, so update now */ - video_screen_update_now(space->machine->primary_screen); + space->machine->primary_screen->update_now(); tp84_spriteram[offset] = data; } @@ -124,7 +124,7 @@ WRITE8_HANDLER( tp84_spriteram_w ) READ8_HANDLER( tp84_scanline_r ) { /* reads 1V - 128V */ - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } @@ -183,9 +183,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_UPDATE( tp84 ) { rectangle clip = *cliprect; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); - if (cliprect->min_y == video_screen_get_visible_area(screen)->min_y) + if (cliprect->min_y == screen->visible_area().min_y) { tilemap_mark_all_tiles_dirty_all(screen->machine); @@ -200,13 +200,13 @@ VIDEO_UPDATE( tp84 ) draw_sprites(screen->machine, bitmap, cliprect); /* draw top status region */ - clip.min_x = visarea->min_x; - clip.max_x = visarea->min_x + 15; + clip.min_x = visarea.min_x; + clip.max_x = visarea.min_x + 15; tilemap_draw(bitmap, &clip, fg_tilemap, 0, 0); /* draw bottom status region */ - clip.min_x = visarea->max_x - 15; - clip.max_x = visarea->max_x; + clip.min_x = visarea.max_x - 15; + clip.max_x = visarea.max_x; tilemap_draw(bitmap, &clip, fg_tilemap, 0, 0); return 0; diff --git a/src/mame/video/triplhnt.c b/src/mame/video/triplhnt.c index 95937ddf010..ca1593c22f3 100644 --- a/src/mame/video/triplhnt.c +++ b/src/mame/video/triplhnt.c @@ -31,7 +31,7 @@ static TILE_GET_INFO( get_tile_info ) VIDEO_START( triplhnt ) { - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 16, 16); } @@ -124,7 +124,7 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta } if (hit_line != 999 && hit_code != 999) - timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, hit_line, 0), NULL, hit_code, triplhnt_hit_callback); + timer_set(machine, machine->primary_screen->time_until_pos(hit_line), NULL, hit_code, triplhnt_hit_callback); } diff --git a/src/mame/video/tumbleb.c b/src/mame/video/tumbleb.c index 876764971ac..0646c3a3fa5 100644 --- a/src/mame/video/tumbleb.c +++ b/src/mame/video/tumbleb.c @@ -35,7 +35,7 @@ static void tumblepb_draw_sprites( running_machine *machine, bitmap_t *bitmap, c y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; @@ -101,7 +101,7 @@ static void jumpkids_draw_sprites( running_machine *machine, bitmap_t *bitmap, c y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs+2]; @@ -168,7 +168,7 @@ static void fncywld_draw_sprites( running_machine *machine, bitmap_t *bitmap, co y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/tumblep.c b/src/mame/video/tumblep.c index d4ed2fe972b..bfea0835a74 100644 --- a/src/mame/video/tumblep.c +++ b/src/mame/video/tumblep.c @@ -33,7 +33,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect y = spriteram[offs]; flash = y & 0x1000; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; x = spriteram[offs + 2]; diff --git a/src/mame/video/tunhunt.c b/src/mame/video/tunhunt.c index f1a259084a5..f631864edb7 100644 --- a/src/mame/video/tunhunt.c +++ b/src/mame/video/tunhunt.c @@ -76,7 +76,7 @@ VIDEO_START( tunhunt ) */ tunhunt_state *state = (tunhunt_state *)machine->driver_data; - machine->generic.tmpbitmap = auto_bitmap_alloc(machine, 256, 64, video_screen_get_format(machine->primary_screen)); + machine->generic.tmpbitmap = auto_bitmap_alloc(machine, 256, 64, machine->primary_screen->format()); state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_cols, 8, 8, 32, 32); diff --git a/src/mame/video/turbo.c b/src/mame/video/turbo.c index afef0df6175..ddd65349292 100644 --- a/src/mame/video/turbo.c +++ b/src/mame/video/turbo.c @@ -208,7 +208,7 @@ WRITE8_HANDLER( turbo_videoram_w ) state->videoram[offset] = data; if (offset < 0x400) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); tilemap_mark_tile_dirty(state->fg_tilemap, offset); } } diff --git a/src/mame/video/twin16.c b/src/mame/video/twin16.c index d8e3adf21db..4b6e68ba031 100644 --- a/src/mame/video/twin16.c +++ b/src/mame/video/twin16.c @@ -156,7 +156,7 @@ static int twin16_set_sprite_timer( running_machine *machine ) // sprite system busy, maybe a dma? time is guessed, assume 4 scanlines twin16_sprite_busy = 1; - timer_adjust_oneshot(twin16_sprite_timer, attotime_make(0,(((screen_config *)(machine->primary_screen->baseconfig()).inline_config)->refresh) / video_screen_get_height(machine->primary_screen) * 4), 0); + timer_adjust_oneshot(twin16_sprite_timer, attotime_make(0,machine->primary_screen->frame_period().attoseconds / machine->primary_screen->height() * 4), 0); return 0; } diff --git a/src/mame/video/tx1.c b/src/mame/video/tx1.c index c5f10ab88d2..74ea1ad172c 100644 --- a/src/mame/video/tx1.c +++ b/src/mame/video/tx1.c @@ -35,7 +35,7 @@ static emu_timer *interrupt_timer; static TIMER_CALLBACK( interrupt_callback ) { cputag_set_input_line_and_vector(machine, "main_cpu", 0, HOLD_LINE, 0xff); - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); } @@ -1133,7 +1133,7 @@ VIDEO_START( tx1 ) interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); /* /CUDISP CRTC interrupt */ - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); } VIDEO_EOF( tx1 ) @@ -3052,7 +3052,7 @@ VIDEO_START( buggyboy ) interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); /* /CUDISP CRTC interrupt */ - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); } VIDEO_START( buggybjr ) @@ -3066,7 +3066,7 @@ VIDEO_START( buggybjr ) interrupt_timer = timer_alloc(machine, interrupt_callback, NULL); /* /CUDISP CRTC interrupt */ - timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0); + timer_adjust_oneshot(interrupt_timer, machine->primary_screen->time_until_pos(CURSOR_YPOS, CURSOR_XPOS), 0); } VIDEO_EOF( buggyboy ) diff --git a/src/mame/video/ultratnk.c b/src/mame/video/ultratnk.c index 7650d244f7f..6c276486d05 100644 --- a/src/mame/video/ultratnk.c +++ b/src/mame/video/ultratnk.c @@ -52,7 +52,7 @@ static TILE_GET_INFO( ultratnk_tile_info ) VIDEO_START( ultratnk ) { - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); playfield = tilemap_create(machine, ultratnk_tile_info, tilemap_scan_rows, 8, 8, 32, 32); } @@ -119,7 +119,7 @@ VIDEO_EOF( ultratnk ) rect.max_x = horz - 15 + machine->gfx[1]->width - 1; rect.max_y = vert - 15 + machine->gfx[1]->height - 1; - sect_rect(&rect, video_screen_get_visible_area(machine->primary_screen)); + sect_rect(&rect, &machine->primary_screen->visible_area()); tilemap_draw(helper, &rect, playfield, 0, 0); diff --git a/src/mame/video/vaportra.c b/src/mame/video/vaportra.c index 87ddad06a99..bb70b667d55 100644 --- a/src/mame/video/vaportra.c +++ b/src/mame/video/vaportra.c @@ -72,7 +72,7 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect continue; flash = x & 0x800; - if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) + if (flash && (machine->primary_screen->frame_number() & 1)) continue; fx = y & 0x2000; diff --git a/src/mame/video/vdc.c b/src/mame/video/vdc.c index 80bbbdfe28c..4815c2d3a3b 100644 --- a/src/mame/video/vdc.c +++ b/src/mame/video/vdc.c @@ -423,7 +423,7 @@ VIDEO_START( pce ) memset(vdc[1].vram, 0, 0x10000); /* create display bitmap */ - vce.bmp = video_screen_auto_bitmap_alloc(machine->primary_screen); + vce.bmp = machine->primary_screen->alloc_compatible_bitmap(); vdc[0].inc = 1; vdc[1].inc = 1; diff --git a/src/mame/video/vicdual.c b/src/mame/video/vicdual.c index 68c281fcdcd..478c67b3d2b 100644 --- a/src/mame/video/vicdual.c +++ b/src/mame/video/vicdual.c @@ -26,7 +26,7 @@ static const pen_t pens_from_color_prom[] = WRITE8_HANDLER( vicdual_palette_bank_w ) { - video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen)); + space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); palette_bank = data & 3; } diff --git a/src/mame/video/victory.c b/src/mame/video/victory.c index e354061da59..11e34b50f8e 100644 --- a/src/mame/video/victory.c +++ b/src/mame/video/victory.c @@ -197,7 +197,7 @@ READ8_HANDLER( victory_video_control_r ) result |= (~fgcoll & 1) << 6; result |= (~vblank_irq & 1) << 5; result |= (~bgcoll & 1) << 4; - result |= (video_screen_get_vpos(space->machine->primary_screen) & 0x100) >> 5; + result |= (space->machine->primary_screen->vpos() & 0x100) >> 5; if (LOG_COLLISION) logerror("%04X:5STAT read = %02X\n", cpu_get_previouspc(space->cpu), result); return result; @@ -1125,7 +1125,7 @@ VIDEO_UPDATE( victory ) int bpix = bg[(x + scrollx) & 255]; scanline[x] = bpix | (fpix << 3); if (fpix && (bpix & bgcollmask) && count++ < 128) - timer_set(screen->machine, video_screen_get_time_until_pos(screen, y, x), NULL, x | (y << 8), bgcoll_irq_callback); + timer_set(screen->machine, screen->time_until_pos(y, x), NULL, x | (y << 8), bgcoll_irq_callback); } } diff --git a/src/mame/video/vigilant.c b/src/mame/video/vigilant.c index 6d4320579f4..89731723210 100644 --- a/src/mame/video/vigilant.c +++ b/src/mame/video/vigilant.c @@ -40,7 +40,7 @@ static bitmap_t *bg_bitmap; VIDEO_START( vigilant ) { - bg_bitmap = auto_bitmap_alloc(machine,512*4,256,video_screen_get_format(machine->primary_screen)); + bg_bitmap = auto_bitmap_alloc(machine,512*4,256,machine->primary_screen->format()); } diff --git a/src/mame/video/vindictr.c b/src/mame/video/vindictr.c index 83d0bd617f0..2136e3f39fa 100644 --- a/src/mame/video/vindictr.c +++ b/src/mame/video/vindictr.c @@ -138,9 +138,9 @@ WRITE16_HANDLER( vindictr_paletteram_w ) * *************************************/ -void vindictr_scanline_update(running_device *screen, int scanline) +void vindictr_scanline_update(screen_device &screen, int scanline) { - vindictr_state *state = (vindictr_state *)screen->machine->driver_data; + vindictr_state *state = (vindictr_state *)screen.machine->driver_data; UINT16 *base = &state->atarigen.alpha[((scanline - 8) / 8) * 64 + 42]; int x; @@ -160,7 +160,7 @@ void vindictr_scanline_update(running_device *screen, int scanline) case 2: /* /PFB */ if (state->playfield_tile_bank != (data & 7)) { - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); state->playfield_tile_bank = data & 7; tilemap_mark_all_tiles_dirty(state->atarigen.playfield_tilemap); } @@ -169,7 +169,7 @@ void vindictr_scanline_update(running_device *screen, int scanline) case 3: /* /PFHSLD */ if (state->playfield_xscroll != (data & 0x1ff)) { - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); tilemap_set_scrollx(state->atarigen.playfield_tilemap, 0, data); state->playfield_xscroll = data & 0x1ff; } @@ -178,7 +178,7 @@ void vindictr_scanline_update(running_device *screen, int scanline) case 4: /* /MOHS */ if (atarimo_get_xscroll(0) != (data & 0x1ff)) { - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); atarimo_set_xscroll(0, data & 0x1ff); } break; @@ -187,20 +187,20 @@ void vindictr_scanline_update(running_device *screen, int scanline) break; case 6: /* /VIRQ */ - atarigen_scanline_int_gen(devtag_get_device(screen->machine, "maincpu")); + atarigen_scanline_int_gen(devtag_get_device(screen.machine, "maincpu")); break; case 7: /* /PFVS */ { /* a new vscroll latches the offset into a counter; we must adjust for this */ int offset = scanline; - const rectangle *visible_area = video_screen_get_visible_area(screen); - if (offset > visible_area->max_y) - offset -= visible_area->max_y + 1; + const rectangle &visible_area = screen.visible_area(); + if (offset > visible_area.max_y) + offset -= visible_area.max_y + 1; if (state->playfield_yscroll != ((data - offset) & 0x1ff)) { - video_screen_update_partial(screen, scanline - 1); + screen.update_partial(scanline - 1); tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, data - offset); atarimo_set_yscroll(0, (data - offset) & 0x1ff); } diff --git a/src/mame/video/volfied.c b/src/mame/video/volfied.c index f850c5cd325..3be6c8bdc1c 100644 --- a/src/mame/video/volfied.c +++ b/src/mame/video/volfied.c @@ -99,8 +99,8 @@ static void refresh_pixel_layer( running_machine *machine, bitmap_t *bitmap ) volfied_state *state = (volfied_state *)machine->driver_data; UINT16* p = state->video_ram; - int width = video_screen_get_width(machine->primary_screen); - int height = video_screen_get_height(machine->primary_screen); + int width = machine->primary_screen->width(); + int height = machine->primary_screen->height(); if (state->video_ctrl & 1) p += 0x20000; diff --git a/src/mame/video/vrender0.c b/src/mame/video/vrender0.c index 87a3b1993f9..58419480354 100644 --- a/src/mame/video/vrender0.c +++ b/src/mame/video/vrender0.c @@ -93,17 +93,16 @@ struct _vr0video_state INLINE vr0video_state *get_safe_token( running_device *device ) { assert(device != NULL); - assert(device->token != NULL); - assert(device->type == VIDEO_VRENDER0); + assert(device->type() == VIDEO_VRENDER0); - return (vr0video_state *)device->token; + return (vr0video_state *)downcast(device)->token(); } INLINE const vr0video_interface *get_interface( running_device *device ) { assert(device != NULL); - assert(device->type == VIDEO_VRENDER0); - return (const vr0video_interface *) device->baseconfig().static_config; + assert(device->type() == VIDEO_VRENDER0); + return (const vr0video_interface *) device->baseconfig().static_config(); } /***************************************************************************** @@ -608,5 +607,4 @@ static const char DEVTEMPLATE_SOURCE[] = __FILE__; #define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET #define DEVTEMPLATE_NAME "VRender0" #define DEVTEMPLATE_FAMILY "???" -#define DEVTEMPLATE_CLASS DEVICE_CLASS_VIDEO #include "devtempl.h" diff --git a/src/mame/video/vrender0.h b/src/mame/video/vrender0.h index 3759981dd2f..d9d5c278e10 100644 --- a/src/mame/video/vrender0.h +++ b/src/mame/video/vrender0.h @@ -13,18 +13,11 @@ struct _vr0video_interface const char *cpu; }; -/*************************************************************************** - FUNCTION PROTOTYPES - ***************************************************************************/ - -DEVICE_GET_INFO( vr0video ); - - /*************************************************************************** DEVICE CONFIGURATION MACROS ***************************************************************************/ -#define VIDEO_VRENDER0 DEVICE_GET_INFO_NAME( vr0video ) +DECLARE_LEGACY_DEVICE(VIDEO_VRENDER0, vr0video); #define MDRV_VIDEO_VRENDER0_ADD(_tag, _interface) \ MDRV_DEVICE_ADD(_tag, VIDEO_VRENDER0, 0) \ diff --git a/src/mame/video/wecleman.c b/src/mame/video/wecleman.c index ce277c83025..cd1bcb7af73 100644 --- a/src/mame/video/wecleman.c +++ b/src/mame/video/wecleman.c @@ -811,10 +811,10 @@ static void hotchase_draw_road(running_machine *machine, bitmap_t *bitmap, const #define YSIZE 512 int sx, sy; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* Let's draw from the top to the bottom of the visible screen */ - for (sy = visarea->min_y;sy <= visarea->max_y;sy++) + for (sy = visarea.min_y;sy <= visarea.max_y;sy++) { int code = wecleman_roadram[sy*4/2+2/2] + (wecleman_roadram[sy*4/2+0/2] << 16); int color = ((code & 0x00f00000) >> 20) + 0x70; @@ -911,7 +911,7 @@ VIDEO_START( wecleman ) UINT8 *buffer; int i, j; - assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32); + assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32); buffer = auto_alloc_array(machine, UINT8, 0x12c00); // working buffer for sprite operations gameid = 0; diff --git a/src/mame/video/welltris.c b/src/mame/video/welltris.c index a3fef9e627a..05be4e3c3b2 100644 --- a/src/mame/video/welltris.c +++ b/src/mame/video/welltris.c @@ -34,7 +34,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan static const UINT8 zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; welltris_state *state = (welltris_state *)machine->driver_data; int offs; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* draw the sprites */ for (offs = 0; offs < 0x200 - 4; offs += 4) { @@ -62,8 +62,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan yzoom = 16 - zoomtable[yzoom] / 8; /* wrap around */ - if (x > visarea->max_x) x -= 0x200; - if (y > visarea->max_y) y -= 0x200; + if (x > visarea.max_x) x -= 0x200; + if (y > visarea.max_y) y -= 0x200; /* normal case */ if (!xflip && !yflip) { diff --git a/src/mame/video/williams.c b/src/mame/video/williams.c index 7c75606b507..787ee0f0a0c 100644 --- a/src/mame/video/williams.c +++ b/src/mame/video/williams.c @@ -257,7 +257,7 @@ VIDEO_UPDATE( blaster ) pens[x] = palette_lookup[screen->machine->generic.paletteram.u8[x]]; /* if we're blitting from the top, start with a 0 for color 0 */ - if (cliprect->min_y == video_screen_get_visible_area(screen)->min_y || !(blaster_video_control & 1)) + if (cliprect->min_y == screen->visible_area().min_y || !(blaster_video_control & 1)) blaster_color0 = pens[0]; /* loop over rows */ @@ -397,13 +397,13 @@ WRITE8_HANDLER( williams2_fg_select_w ) READ8_HANDLER( williams_video_counter_r ) { - return video_screen_get_vpos(space->machine->primary_screen) & 0xfc; + return space->machine->primary_screen->vpos() & 0xfc; } READ8_HANDLER( williams2_video_counter_r ) { - return video_screen_get_vpos(space->machine->primary_screen); + return space->machine->primary_screen->vpos(); } @@ -581,7 +581,7 @@ WRITE8_HANDLER( williams_blitter_w ) /* Log blits */ logerror("%04X:Blit @ %3d : %02X%02X -> %02X%02X, %3dx%3d, mask=%02X, flags=%02X, icount=%d, win=%d\n", - cpu_get_pc(space->cpu), video_screen_get_vpos(space->machine->primary_screen), + cpu_get_pc(space->cpu), space->machine->primary_screen->vpos(), blitterram[2], blitterram[3], blitterram[4], blitterram[5], blitterram[6], blitterram[7], diff --git a/src/mame/video/wolfpack.c b/src/mame/video/wolfpack.c index 12ae20ebf59..98c84f24527 100644 --- a/src/mame/video/wolfpack.c +++ b/src/mame/video/wolfpack.c @@ -125,7 +125,7 @@ VIDEO_START( wolfpack ) LFSR = auto_alloc_array(machine, UINT8, 0x8000); - helper = video_screen_auto_bitmap_alloc(machine->primary_screen); + helper = machine->primary_screen->alloc_compatible_bitmap(); for (i = 0; i < 0x8000; i++) { diff --git a/src/mame/video/xexex.c b/src/mame/video/xexex.c index fc0d737fcf5..c0350b3d005 100644 --- a/src/mame/video/xexex.c +++ b/src/mame/video/xexex.c @@ -35,7 +35,7 @@ VIDEO_START( xexex ) { xexex_state *state = (xexex_state *)machine->driver_data; - assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32); + assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32); state->cur_alpha = 0; diff --git a/src/mame/video/xmen.c b/src/mame/video/xmen.c index b0ffad29e8b..115d1fcf811 100644 --- a/src/mame/video/xmen.c +++ b/src/mame/video/xmen.c @@ -145,7 +145,7 @@ VIDEO_EOF( xmen6p ) state->current_frame ^= 0x01; -// const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); +// const rectangle *visarea = machine->primary_screen->visible_area(); // cliprect.min_x = visarea->min_x; // cliprect.max_x = visarea->max_x; // cliprect.min_y = visarea->min_y; diff --git a/src/mame/video/ygv608.c b/src/mame/video/ygv608.c index 4950ec87efc..56219794b67 100644 --- a/src/mame/video/ygv608.c +++ b/src/mame/video/ygv608.c @@ -497,8 +497,6 @@ static void ygv608_register_state_save(running_machine *machine) static void ygv608_exit(running_machine *machine) { - if( work_bitmap ) - bitmap_free( work_bitmap ); work_bitmap = NULL; } @@ -733,13 +731,13 @@ VIDEO_UPDATE( ygv608 ) double r, alpha, sin_theta, cos_theta; #endif rectangle finalclip; - const rectangle *visarea = video_screen_get_visible_area(screen); + const rectangle &visarea = screen->visible_area(); // clip to the current bitmap finalclip.min_x = 0; - finalclip.max_x = video_screen_get_width(screen) - 1; + finalclip.max_x = screen->width() - 1; finalclip.min_y = 0; - finalclip.max_y = video_screen_get_height(screen) - 1; + finalclip.max_y = screen->height() - 1; sect_rect(&finalclip, cliprect); cliprect = &finalclip; @@ -755,13 +753,12 @@ VIDEO_UPDATE( ygv608 ) #ifdef _ENABLE_SCREEN_RESIZE // hdw should be scaled by 16, not 8 // - is it something to do with double dot-clocks??? - video_screen_set_visarea(screen, 0, ((int)(ygv608.regs.s.hdw)<<3/*4*/)-1, + screen->set_visible_area(0, ((int)(ygv608.regs.s.hdw)<<3/*4*/)-1, 0, ((int)(ygv608.regs.s.vdw)<<3)-1 ); #endif - if( work_bitmap ) - bitmap_free( work_bitmap ); - work_bitmap = bitmap_alloc(video_screen_get_width(screen), video_screen_get_height(screen), video_screen_get_format(screen)); + auto_free( screen->machine, work_bitmap ); + work_bitmap = screen->alloc_compatible_bitmap(); // reset resize flag ygv608.screen_resize = 0; @@ -874,10 +871,10 @@ VIDEO_UPDATE( ygv608 ) if( ygv608.regs.s.zron ) copyrozbitmap( bitmap, cliprect, work_bitmap, - ( visarea->min_x << 16 ) + + ( visarea.min_x << 16 ) + ygv608.ax + 0x10000 * r * ( -sin( alpha ) * cos_theta + cos( alpha ) * sin_theta ), - ( visarea->min_y << 16 ) + + ( visarea.min_y << 16 ) + ygv608.ay + 0x10000 * r * ( cos( alpha ) * cos_theta + sin( alpha ) * sin_theta ), ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0); @@ -888,7 +885,7 @@ VIDEO_UPDATE( ygv608 ) // for some reason we can't use an opaque tilemap_A // so use a transparent but clear the work bitmap first // - look at why this is the case?!? - bitmap_fill( work_bitmap,visarea ,0); + bitmap_fill( work_bitmap,&visarea ,0); if ((ygv608.regs.s.r11 & r11_prm) == PRM_ASBDEX || (ygv608.regs.s.r11 & r11_prm) == PRM_ASEBDX ) @@ -899,8 +896,8 @@ VIDEO_UPDATE( ygv608 ) #ifdef _ENABLE_ROTATE_ZOOM if( ygv608.regs.s.zron ) copyrozbitmap_trans( bitmap, cliprect, work_bitmap, - ygv608.ax, // + ( visarea->min_x << 16 ), - ygv608.ay, // + ( visarea->min_y << 16 ), + ygv608.ax, // + ( visarea.min_x << 16 ), + ygv608.ay, // + ( visarea.min_y << 16 ), ygv608.dx, ygv608.dxy, ygv608.dyx, ygv608.dy, 0, 0 ); else diff --git a/src/mame/video/yunsun16.c b/src/mame/video/yunsun16.c index 85cd7ca1019..a1ca72da2e5 100644 --- a/src/mame/video/yunsun16.c +++ b/src/mame/video/yunsun16.c @@ -140,10 +140,10 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rect { yunsun16_state *state = (yunsun16_state *)machine->driver_data; int offs; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); - int max_x = visarea->max_x + 1; - int max_y = visarea->max_y + 1; + int max_x = visarea.max_x + 1; + int max_y = visarea.max_y + 1; int pri = *state->priorityram & 3; int pri_mask; diff --git a/src/mame/video/zac2650.c b/src/mame/video/zac2650.c index a909fe7b0d8..c615b396892 100644 --- a/src/mame/video/zac2650.c +++ b/src/mame/video/zac2650.c @@ -53,7 +53,7 @@ static int SpriteCollision(running_machine *machine, int first,int second) { int Checksum=0; int x,y; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); if((zac2650_s2636_0_ram[first * 0x10 + 10] < 0xf0) && (zac2650_s2636_0_ram[second * 0x10 + 10] < 0xf0)) { @@ -75,10 +75,10 @@ static int SpriteCollision(running_machine *machine, int first,int second) { for (y = fy; y < fy + machine->gfx[expand]->height; y++) { - if ((x < visarea->min_x) || - (x > visarea->max_x) || - (y < visarea->min_y) || - (y > visarea->max_y)) + if ((x < visarea.min_x) || + (x > visarea.max_x) || + (y < visarea.min_y) || + (y > visarea.max_y)) { continue; } @@ -101,10 +101,10 @@ static int SpriteCollision(running_machine *machine, int first,int second) { for (y = fy; y < fy + machine->gfx[expand]->height; y++) { - if ((x < visarea->min_x) || - (x > visarea->max_x) || - (y < visarea->min_y) || - (y > visarea->max_y)) + if ((x < visarea.min_x) || + (x > visarea.max_x) || + (y < visarea.min_y) || + (y > visarea.max_y)) { continue; } @@ -137,8 +137,8 @@ VIDEO_START( tinvader ) bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 24, 24, 32, 32); - spritebitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); - machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen); + spritebitmap = machine->primary_screen->alloc_compatible_bitmap(); + machine->generic.tmpbitmap = machine->primary_screen->alloc_compatible_bitmap(); gfx_element_set_source(machine->gfx[1], zac2650_s2636_0_ram); gfx_element_set_source(machine->gfx[2], zac2650_s2636_0_ram); @@ -147,7 +147,7 @@ VIDEO_START( tinvader ) static void draw_sprites(running_machine *machine, bitmap_t *bitmap) { int offs; - const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); + const rectangle &visarea = machine->primary_screen->visible_area(); /* -------------------------------------------------------------- */ /* There seems to be a strange setup with this board, in that it */ @@ -163,7 +163,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap) CollisionBackground = 0; /* Read from 0x1e80 bit 7 */ // for collision detection checking - copybitmap(machine->generic.tmpbitmap,bitmap,0,0,0,0,visarea); + copybitmap(machine->generic.tmpbitmap,bitmap,0,0,0,0,&visarea); for(offs=0;offs<0x50;offs+=0x10) { @@ -186,10 +186,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap) { for (y = by; y < by + machine->gfx[expand]->height; y++) { - if ((x < visarea->min_x) || - (x > visarea->max_x) || - (y < visarea->min_y) || - (y > visarea->max_y)) + if ((x < visarea.min_x) || + (x > visarea.max_x) || + (y < visarea.min_y) || + (y > visarea.max_y)) { continue; } diff --git a/src/mame/video/zaxxon.c b/src/mame/video/zaxxon.c index 1e7fb3de5a0..90007bb5388 100644 --- a/src/mame/video/zaxxon.c +++ b/src/mame/video/zaxxon.c @@ -136,8 +136,8 @@ static void video_start_common(running_machine *machine, tile_get_info_func fg_t /* configure the foreground tilemap */ tilemap_set_transparent_pen(state->fg_tilemap, 0); - tilemap_set_scrolldx(state->fg_tilemap, 0, video_screen_get_width(machine->primary_screen) - 256); - tilemap_set_scrolldy(state->fg_tilemap, 0, video_screen_get_height(machine->primary_screen) - 256); + tilemap_set_scrolldx(state->fg_tilemap, 0, machine->primary_screen->width() - 256); + tilemap_set_scrolldy(state->fg_tilemap, 0, machine->primary_screen->height() - 256); /* register for save states */ state_save_register_global(machine, state->bg_enable); diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index a45152ff916..ae08f732c3c 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -71,7 +71,7 @@ class input_type_desc; -class running_device; +class device_t; /*----------------------------------------------------------------------------- @@ -126,7 +126,7 @@ class running_device; -----------------------------------------------------------------------------*/ void osd_init(running_machine *machine); -void osd_wait_for_debugger(running_device *device, int firststop); +void osd_wait_for_debugger(device_t *device, int firststop); diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c index 4608d95ebd3..ebdcc416b1c 100644 --- a/src/osd/sdl/debugwin.c +++ b/src/osd/sdl/debugwin.c @@ -440,7 +440,7 @@ static void debugmain_set_cpu(running_device *cpu) dv = get_view(dmain, DVT_REGISTERS); for (regsubitem = registers_view_get_subview_list(dv->view); regsubitem != NULL; regsubitem = regsubitem->next) - if (regsubitem->device == cpu) + if (regsubitem->cpudevice == cpu) { registers_view_set_subview(dv->view, regsubitem->index); break; diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index a652cba2c66..aee6a1f7826 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -1208,12 +1208,11 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) // figure out if we're vector scrnum = is_vector = 0; - for (screen = video_screen_first(window->machine->config); screen != NULL; screen = video_screen_next(screen)) + for (screen = screen_first(*window->machine->config); screen != NULL; screen = screen_next(screen)) { if (scrnum == window->index) { - scrconfig = (const screen_config *) screen->inline_config; - is_vector = (scrconfig->type == SCREEN_TYPE_VECTOR) ? 1 : 0; + is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0; break; } else @@ -2938,13 +2937,12 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture int uniform_location, scrnum; render_container *container; GLfloat vid_attributes[4]; // gamma, contrast, brightness, effect - const device_config *screen; assert ( sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16 ); scrnum = 0; container = (render_container *)NULL; - for (screen = video_screen_first(window->machine->config); screen != NULL; screen = video_screen_next(screen)) + for (screen_device *screen = screen_first(*window->machine); screen != NULL; screen = screen_next(screen)) { if (scrnum == window->start_viewscreen) { diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index a45babe2f7e..641dc460203 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -818,7 +818,6 @@ static void extract_video_config(running_machine *machine) static void load_effect_overlay(running_machine *machine, const char *filename) { - const device_config *screen; char *tempstr = global_alloc_array(char, strlen(filename) + 5); char *dest; @@ -839,7 +838,7 @@ static void load_effect_overlay(running_machine *machine, const char *filename) } // set the overlay on all screens - for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) render_container_set_overlay(render_container_get_screen(screen), effect_bitmap); global_free(tempstr); diff --git a/src/osd/windows/d3d8intf.c b/src/osd/windows/d3d8intf.c index d91bb7c0864..af07c5f4d23 100644 --- a/src/osd/windows/d3d8intf.c +++ b/src/osd/windows/d3d8intf.c @@ -43,6 +43,7 @@ #define WIN32_LEAN_AND_MEAN #include #include +#undef interface // MAME headers #include "emu.h" diff --git a/src/osd/windows/d3d9intf.c b/src/osd/windows/d3d9intf.c index 6d22435e21d..26f039ab200 100644 --- a/src/osd/windows/d3d9intf.c +++ b/src/osd/windows/d3d9intf.c @@ -43,6 +43,7 @@ #define WIN32_LEAN_AND_MEAN #include #include +#undef interface // MAME headers #include "emu.h" diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 3c1be5e8781..9447b9b87ee 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -2577,12 +2577,15 @@ static void console_set_cpu(running_device *device) break; } if (main_console->view[1].view != NULL) + { + device_state_interface *stateintf = device_state(device); for (regsubitem = registers_view_get_subview_list(main_console->view[1].view); regsubitem != NULL; regsubitem = regsubitem->next) - if (regsubitem->device == device) + if (regsubitem->stateintf == stateintf) { registers_view_set_subview(main_console->view[1].view, regsubitem->index); break; } + } // then update the caption if (regsubitem != NULL) diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 5d48cf9d3e0..b78bdb4c9ab 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -53,6 +53,7 @@ #include #include #include +#undef interface // MAME headers #include "emu.h" @@ -1271,7 +1272,6 @@ static int get_adapter_for_monitor(d3d_info *d3d, win_monitor_info *monitor) static void pick_best_mode(win_window_info *window) { - const device_config *primary_screen = video_screen_first(window->machine->config); double target_refresh = 60.0; INT32 target_width, target_height; d3d_info *d3d = (d3d_info *)window->drawdata; @@ -1281,11 +1281,9 @@ static void pick_best_mode(win_window_info *window) int modenum; // determine the refresh rate of the primary screen + const screen_device_config *primary_screen = screen_first(*window->machine->config); if (primary_screen != NULL) - { - const screen_config *config = (const screen_config *)primary_screen->inline_config; - target_refresh = ATTOSECONDS_TO_HZ(config->refresh); - } + target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh()); // determine the minimum width/height for the selected target // note: technically we should not be calling this from an alternate window diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c index afb7e7728f2..7320471c27b 100644 --- a/src/osd/windows/drawdd.c +++ b/src/osd/windows/drawdd.c @@ -44,6 +44,7 @@ #include #include #include +#undef interface // MAME headers #include "emu.h" @@ -1316,7 +1317,6 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) static void pick_best_mode(win_window_info *window) { - const device_config *primary_screen = video_screen_first(window->machine->config); dd_info *dd = (dd_info *)window->drawdata; mode_enum_info einfo; HRESULT result; @@ -1333,11 +1333,9 @@ static void pick_best_mode(win_window_info *window) // determine the refresh rate of the primary screen einfo.target_refresh = 60.0; + const screen_device_config *primary_screen = screen_first(*window->machine->config); if (primary_screen != NULL) - { - const screen_config *config = (const screen_config *)primary_screen->inline_config; - einfo.target_refresh = ATTOSECONDS_TO_HZ(config->refresh); - } + einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh()); printf("Target refresh = %f\n", einfo.target_refresh); // if we're not stretching, allow some slop on the minimum since we can handle it diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 47a4e229b90..5448395ac8b 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -51,6 +51,7 @@ // undef WINNT for dinput.h to prevent duplicate definition #undef WINNT #include +#undef interface // standard C headers #include diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c index 87a72fbd2d0..2116f1ddc0e 100644 --- a/src/osd/windows/sound.c +++ b/src/osd/windows/sound.c @@ -47,6 +47,7 @@ // undef WINNT for dsound.h to prevent duplicate definition #undef WINNT #include +#undef interface // MAME headers #include "emu.h" diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 6d034add22f..49c6780c73e 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -470,7 +470,6 @@ static void extract_video_config(running_machine *machine) static void load_effect_overlay(running_machine *machine, const char *filename) { - const device_config *screen; char *tempstr = global_alloc_array(char, strlen(filename) + 5); char *dest; @@ -491,7 +490,7 @@ static void load_effect_overlay(running_machine *machine, const char *filename) } // set the overlay on all screens - for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) + for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen)) render_container_set_overlay(render_container_get_screen(screen), effect_bitmap); global_free(tempstr); diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index 568527163c4..8d342b73834 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -147,8 +147,8 @@ CPPONLYFLAGS += /EHsc # disable function pointer warnings in C++ which are evil to work around CPPONLYFLAGS += /wd4191 /wd4060 /wd4065 /wd4640 -# disable warning about exception specifications -CPPONLYFLAGS += /wd4290 +# disable warning about exception specifications and using this in constructors +CPPONLYFLAGS += /wd4290 /wd4355 # explicitly set the entry point for UNICODE builds LDFLAGS += /ENTRY:wmainCRTStartup diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 68ff2b04838..a92b8b6a132 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -712,10 +712,11 @@ static const char *line_to_symbol(const char *line, FPTR &address) // find a matching start if (strncmp(line, " 0x", 18) == 0) if (sscanf(line, " 0x%p %s", &temp, symbol) == 2) - { - address = reinterpret_cast(temp); - return strstr(line, symbol); - } + if (symbol[0] != '0' && symbol[1] != 'x') + { + address = reinterpret_cast(temp); + return strstr(line, symbol); + } #endif #ifdef _MSC_VER -- cgit v1.2.3