diff options
author | 2017-05-07 23:18:47 +1000 | |
---|---|---|
committer | 2017-05-14 21:44:11 +1000 | |
commit | 0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch) | |
tree | 201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/sound/es1373.h | |
parent | e6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff) |
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are:
* Short name, full name and source file are no longer members of device_t, they are part of the device type
* MACHINE_COFIG_START no longer needs a driver class
* MACHINE_CONFIG_DERIVED_CLASS is no longer necessary
* Specify the state class you want in the GAME/COMP/CONS line
* The compiler will work out the base class where the driver init member is declared
* There is one static device type object per driver rather than one per machine configuration
Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type.
* DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders.
* DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type.
Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types.
* These macros declare storage for the static data, and instantiate the device type and device finder templates.
The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate.
Things I've actually messed with substantially:
* More descriptive names for a lot of devices
* Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes
* Changed DECO BSMT2000 ready callback into a device delegate
* Untangled Microprose 3D noise from driver state
* Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices
* Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly
* Started to break out common parts of Samsung ARM SoC devices
* Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++
* Tried to make Z180 table allocation/setup a bit safer
* Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant
* Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size
* Imporved encapsulation of Z80DART channels
* Refactored the SPC7110 bit table generator loop to make it more readable
* Added wrappers for SNES PPU operations so members can be made protected
* Factored out some boilerplate for YM chips with PSG
* toaplan2 gfx
* stic/intv resolution
* Video System video
* Out Run/Y-board sprite alignment
* GIC video hookup
* Amstrad CPC ROM box members
* IQ151 ROM cart region
* MSX cart IRQ callback resolution time
* SMS passthrough control devices starting subslots
I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo).
And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros.
It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/sound/es1373.h')
-rw-r--r-- | src/devices/sound/es1373.h | 117 |
1 files changed, 29 insertions, 88 deletions
diff --git a/src/devices/sound/es1373.h b/src/devices/sound/es1373.h index f66c5a0c75b..848e175fa58 100644 --- a/src/devices/sound/es1373.h +++ b/src/devices/sound/es1373.h @@ -2,10 +2,10 @@ // copyright-holders:Ted Green // Creative Labs Ensonic AudioPCI97 ES1373 -#pragma once +#ifndef MAME_SOUND_ES1373_H +#define MAME_SOUND_ES1373_H -#ifndef ES1373_H -#define ES1373_H +#pragma once #include "machine/pci.h" @@ -16,86 +16,11 @@ #define MCFG_ES1373_IRQ_ADD(_cpu_tag, _irq_num) \ downcast<es1373_device *>(device)->set_irq_info(_cpu_tag, _irq_num); -/* Ensonic ES1373 registers 0x00-0x3f */ -#define ES_INT_CS_CTRL (0x00/4) -#define ES_INT_CS_STATUS (0x04/4) -#define ES_UART_DATA (0x08/4) -#define ES_UART_STATUS (0x09/4) -#define ES_UART_CTRL (0x09/4) -#define ES_UART_RSVD (0x0A/4) -#define ES_MEM_PAGE (0x0C/4) -#define ES_SRC_IF (0x10/4) -#define ES_CODEC (0x14/4) -#define ES_LEGACY (0x18/4) -#define ES_CHAN_CTRL (0x1C/4) -#define ES_SERIAL_CTRL (0x20/4) -#define ES_DAC1_CNT (0x24/4) -#define ES_DAC2_CNT (0x28/4) -#define ES_ADC_CNT (0x2C/4) -#define ES_HOST_IF0 (0x30/4) -#define ES_HOST_IF1 (0x34/4) -#define ES_HOST_IF2 (0x38/4) -#define ES_HOST_IF3 (0x3C/4) - -// Interrupt/Chip Select Control Register (ES_INT_CS_CTRL) bits -#define ICCTRL_ADC_STOP_MASK 0x00002000 -#define ICCTRL_DAC1_EN_MASK 0x00000040 -#define ICCTRL_DAC2_EN_MASK 0x00000020 -#define ICCTRL_ADC_EN_MASK 0x00000010 -#define ICCTRL_UART_EN_MASK 0x00000008 -#define ICCTRL_JYSTK_EN_MASK 0x00000004 - -// Interrupt/Chip Select Status Register (ES_INT_CS_STATUS) bits -#define ICSTATUS_INTR_MASK 0x80000000 -#define ICSTATUS_DAC1_INT_MASK 0x00000004 -#define ICSTATUS_DAC2_INT_MASK 0x00000002 -#define ICSTATUS_ADC_INT_MASK 0x00000001 - -// Serial Interface Control Register (ES_SERIAL_CTRL) bits -#define SCTRL_P2_END_MASK 0x00380000 -#define SCTRL_P2_START_MASK 0x00070000 -#define SCTRL_R1_LOOP_MASK 0x00008000 -#define SCTRL_P2_LOOP_MASK 0x00004000 -#define SCTRL_P1_LOOP_MASK 0x00002000 -#define SCTRL_P2_PAUSE_MASK 0x00001000 -#define SCTRL_P1_PAUSE_MASK 0x00000800 -#define SCTRL_R1_INT_EN_MASK 0x00000400 -#define SCTRL_P2_INT_EN_MASK 0x00000200 -#define SCTRL_P1_INT_EN_MASK 0x00000100 -#define SCTRL_P1_RELOAD_MASK 0x00000080 -#define SCTRL_P2_STOP_MASK 0x00000040 -#define SCTRL_R1_S_MASK 0x00000030 -#define SCTRL_P2_S_MASK 0x0000000C -#define SCTRL_P1_S_MASK 0x00000003 - -#define SCTRL_8BIT_MONO 0x0 -#define SCTRL_8BIT_STEREO 0x1 -#define SCTRL_16BIT_MONO 0x2 -#define SCTRL_16BIT_STEREO 0x3 - -#define ES_PCI_READ 0 -#define ES_PCI_WRITE 1 - -struct chan_info { - int number; - bool enable; - bool int_en; - bool loop_en; - bool initialized; - uint8_t format; // Format of channel - uint32_t buf_wptr; // Address to sample cache memory - uint32_t buf_rptr; // Address to sample cache memory - uint16_t buf_count; // Number of samples that have been played - uint16_t buf_size; // Number of samples minus one to play - uint32_t pci_addr; // PCI Address for system memory accesses - uint16_t pci_count; // Number of 32 bits transferred - uint16_t pci_size; // Total number of words (32 bits) minus one in system memory -}; - class es1373_device : public pci_device, public device_sound_interface { public: es1373_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space, uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override; @@ -108,9 +33,6 @@ public: // optional information overrides virtual machine_config_constructor device_mconfig_additions() const override; - // Sound stream - sound_stream *m_stream; - protected: virtual void device_start() override; virtual void device_stop() override; @@ -118,9 +40,32 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; + // Sound stream + sound_stream *m_stream; + FILE *m_eslog; private: + struct chan_info { + int number; + bool enable; + bool int_en; + bool loop_en; + bool initialized; + uint8_t format; // Format of channel + uint32_t buf_wptr; // Address to sample cache memory + uint32_t buf_rptr; // Address to sample cache memory + uint16_t buf_count; // Number of samples that have been played + uint16_t buf_size; // Number of samples minus one to play + uint32_t pci_addr; // PCI Address for system memory accesses + uint16_t pci_count; // Number of 32 bits transferred + uint16_t pci_size; // Total number of words (32 bits) minus one in system memory + }; + + void transfer_pci_audio(chan_info& chan, int type); + uint32_t calc_size(const uint8_t &format); + void send_audio_out(chan_info& chan, uint32_t intr_mask, stream_sample_t *outL, stream_sample_t *outR, int samples); + uint32_t m_tempCount; emu_timer *m_timer; address_space *m_memory_space; @@ -135,12 +80,8 @@ private: chan_info m_dac1; chan_info m_dac2; chan_info m_adc; - void transfer_pci_audio(chan_info& chan, int type); - uint32_t calc_size(const uint8_t &format); - void send_audio_out(chan_info& chan, uint32_t intr_mask, stream_sample_t *outL, stream_sample_t *outR, int samples); - }; -extern const device_type ES1373; +DECLARE_DEVICE_TYPE(ES1373, es1373_device) -#endif +#endif // MAME_SOUND_ES1373_H |