From 893c1f3e81f86921eaa27c48adf994f8a1c9d538 Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Fri, 17 Sep 2010 02:42:13 +0000 Subject: [PATCH] Add skeleton Apple Sound Chip device (no whatsnew) --- .gitattributes | 2 + src/emu/sound/asc.c | 190 ++++++++++++++++++++++++++++++++++++++++ src/emu/sound/asc.h | 129 +++++++++++++++++++++++++++ src/emu/sound/sound.mak | 9 ++ src/mame/mame.mak | 1 + 5 files changed, 331 insertions(+) create mode 100644 src/emu/sound/asc.c create mode 100644 src/emu/sound/asc.h diff --git a/.gitattributes b/.gitattributes index cc3d28df887..6773b0d7971 100644 --- a/.gitattributes +++ b/.gitattributes @@ -870,6 +870,8 @@ src/emu/sound/aica.h svneol=native#text/plain src/emu/sound/aicadsp.c svneol=native#text/plain src/emu/sound/aicadsp.h svneol=native#text/plain src/emu/sound/aicalfo.c svneol=native#text/plain +src/emu/sound/asc.c svneol=native#text/plain +src/emu/sound/asc.h svneol=native#text/plain src/emu/sound/astrocde.c svneol=native#text/plain src/emu/sound/astrocde.h svneol=native#text/plain src/emu/sound/ay8910.c svneol=native#text/plain diff --git a/src/emu/sound/asc.c b/src/emu/sound/asc.c new file mode 100644 index 00000000000..5c7855a7e3a --- /dev/null +++ b/src/emu/sound/asc.c @@ -0,0 +1,190 @@ +/*************************************************************************** + + asc.c + + Apple Sound Chip (ASC) 344S0063 + Enhanced Apple Sound Chip (EASC) 343S1063 + + Emulation by R. Belmont + +***************************************************************************/ + +#include "emu.h" +#include "streams.h" +#include "asc.h" + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +//************************************************************************** +// DEVICE CONFIGURATION +//************************************************************************** + +//------------------------------------------------- +// static_set_type - configuration helper to set +// the chip type +//------------------------------------------------- + +void asc_device_config::static_set_type(device_config *device, int type) +{ + asc_device_config *asc = downcast(device); + asc->m_type = type; +} + +//------------------------------------------------- +// asc_device_config - constructor +//------------------------------------------------- + +asc_device_config::asc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) + : device_config(mconfig, static_alloc_device_config, "ASC", tag, owner, clock), + device_config_sound_interface(mconfig, *this) +{ +} + + +//------------------------------------------------- +// static_alloc_device_config - allocate a new +// configuration object +//------------------------------------------------- + +device_config *asc_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) +{ + return global_alloc(asc_device_config(mconfig, tag, owner, clock)); +} + + +//------------------------------------------------- +// alloc_device - allocate a new device object +//------------------------------------------------- + +device_t *asc_device_config::alloc_device(running_machine &machine) const +{ + return auto_alloc(&machine, asc_device(machine, *this)); +} + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// asc_device - constructor +//------------------------------------------------- + +asc_device::asc_device(running_machine &_machine, const asc_device_config &config) + : device_t(_machine, config), + device_sound_interface(_machine, config, *this), + m_config(config), + m_chip_type(m_config.m_type) +{ +} + + +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void asc_device::device_start() +{ + // create the stream + m_stream = stream_create(this, 0, 2, 22257, this, static_stream_generate); +} + + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void asc_device::device_reset() +{ + stream_update(m_stream); +} + +//------------------------------------------------- +// stream_generate - handle update requests for +// our sound stream +//------------------------------------------------- + +STREAM_UPDATE( asc_device::static_stream_generate ) +{ + reinterpret_cast(param)->stream_generate(inputs, outputs, samples); +} + +void asc_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])); +} + +//------------------------------------------------- +// read - read from the chip's registers and internal RAM +//------------------------------------------------- + +UINT8 asc_device::read(UINT16 offset) +{ + if (offset < 0x400) + { + return fifo_a[offset]; + } + else if (offset < 0x800) + { + return fifo_b[offset-0x400]; + } + else + { + switch (offset) + { + case 0x800: // VERSION + switch (m_chip_type) + { + case ASC_TYPE_ASC: + return 0; + + case ASC_TYPE_V8: + return 0xe8; + + case ASC_TYPE_SONORA: + return 0xbc; + + default: + return 0; + } + break; + + case 0x804: // FIFO Interrupt Status + if (m_chip_type == ASC_TYPE_V8) + { + return 3; + } + break; + + default: + break; + } + } + + return regs[offset-0x800]; +} + +//------------------------------------------------- +// write - write to the chip's registers and internal RAM +//------------------------------------------------- + +void asc_device::write(UINT16 offset, UINT8 data) +{ + if (offset < 0x400) + { + fifo_a[offset] = data; + } + else if (offset < 0x800) + { + fifo_b[offset-0x400] = data; + } + else + { + regs[offset-0x800] = data; + } +} + +const device_type ASC = asc_device_config::static_alloc_device_config; + diff --git a/src/emu/sound/asc.h b/src/emu/sound/asc.h new file mode 100644 index 00000000000..d86dc978575 --- /dev/null +++ b/src/emu/sound/asc.h @@ -0,0 +1,129 @@ +/*************************************************************************** + + asc.h + + Apple Sound Chip (ASC) 344S0063 + Enhanced Apple Sound Chip (EASC) 343S1063 + +***************************************************************************/ + +#pragma once + +#ifndef __ASC_H__ +#define __ASC_H__ + +#include "streams.h" + + + +//************************************************************************** +// CONSTANTS +//************************************************************************** + +// chip behavior types +enum +{ + ASC_TYPE_ASC = 0, // original discrete Apple Sound Chip + ASC_TYPE_EASC = 1, // discrete Enhanced Apple Sound Chip + ASC_TYPE_V8 = 2, // Subset of ASC included in the V8 ASIC (LC/LCII) + ASC_TYPE_EAGLE = 3, // Subset of ASC included in the Eagle ASIC (Classic II) + ASC_TYPE_SPICE = 4, // Subset of ASC included in the Spice ASIC (Color Classic) + ASC_TYPE_SONORA = 5, // Subset of ASC included in the Sonora ASIC (LCIII) + ASC_TYPE_VASP = 6, // Subset of ASC included in the VASP ASIC (IIvx/IIvi) + ASC_TYPE_ARDBEG = 7 // Subset of ASC included in the Ardbeg ASIC (LC520) +}; + + + +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MDRV_ASC_ADD(_tag, _clock, _type) \ + MDRV_DEVICE_ADD(_tag, ASC, _clock) \ + MDRV_ASC_TYPE(_type) + +#define MDRV_ASC_REPLACE(_tag, _clock, _type) \ + MDRV_DEVICE_REPLACE(_tag, ASC, _clock) \ + MDRV_ASC_TYPE(_type) + +#define MDRV_ASC_TYPE(_type) \ + asc_device_config::static_set_type(device, _type); \ + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> asc_device_config + +class asc_device_config : public device_config, public device_config_sound_interface +{ + friend class asc_device; + + // construction/destruction + asc_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; + + // inline configuration helpers + static void static_set_type(device_config *device, int type); + +protected: + // device_config overrides + virtual const address_space_config *memory_space_config(int spacenum = 0) const; + + // internal state + const address_space_config m_space_config; + + // inline data + UINT8 m_type; +}; + + + +// ======================> asc_device + +class asc_device : public device_t, public device_sound_interface +{ + friend class asc_device_config; + + // construction/destruction + asc_device(running_machine &_machine, const asc_device_config &config); + +public: + UINT8 read(UINT16 offset); + void write(UINT16 offset, UINT8 data); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // internal callbacks + static STREAM_UPDATE( static_stream_generate ); + virtual void stream_generate(stream_sample_t **inputs, stream_sample_t **outputs, int samples); + + // internal state + const asc_device_config &m_config; + + UINT8 m_chip_type; + sound_stream *m_stream; + + UINT8 fifo_a[0x400]; + UINT8 fifo_b[0x400]; + + UINT8 regs[0x100]; +}; + + +// device type definition +extern const device_type ASC; + + +#endif /* __ASC_H__ */ + diff --git a/src/emu/sound/sound.mak b/src/emu/sound/sound.mak index 2f787900704..c5b60067f6d 100644 --- a/src/emu/sound/sound.mak +++ b/src/emu/sound/sound.mak @@ -72,6 +72,15 @@ $(SOUNDOBJ)/discrete.o: $(SOUNDSRC)/discrete.c \ $(SOUNDSRC)/disc_wav.c +#------------------------------------------------- +# Apple custom sound chips +#------------------------------------------------- + +ifneq ($(filter ASC,$(SOUNDS)),) +SOUNDOBJS += $(SOUNDOBJ)/asc.o +endif + + #------------------------------------------------- # Atari custom sound chips diff --git a/src/mame/mame.mak b/src/mame/mame.mak index 032854e3057..80dad99001c 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -224,6 +224,7 @@ SOUNDS += CDP1864 SOUNDS += ZSG2 SOUNDS += MOS656X SOUNDS += S2636 +#SOUNDS += ASC #------------------------------------------------- # this is the list of driver libraries that