diff options
author | 2015-09-30 17:21:14 +0200 | |
---|---|---|
committer | 2015-09-30 17:21:14 +0200 | |
commit | 1fc48ce120a376c288daeeed98daccecf1b60d7b (patch) | |
tree | 72cefcede17f3a27fa8256b43bfac9756db82312 /src/mess | |
parent | 87a576c55501bd7125b51ca786a010229669df0e (diff) |
move mess into mame (nw)
Diffstat (limited to 'src/mess')
1526 files changed, 0 insertions, 664376 deletions
diff --git a/src/mess/audio/alesis.c b/src/mess/audio/alesis.c deleted file mode 100644 index 7a253db43a2..00000000000 --- a/src/mess/audio/alesis.c +++ /dev/null @@ -1,157 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sandro Ronco -/*************************************************************************** - - Alesis HR-16 sound (DM3AG + PCM54) emulation - - TODO: - - volume - - panning - - output 2 - -****************************************************************************/ - -#include "emu.h" -#include "includes/alesis.h" - -#define LOG 1 - -// device type definition -const device_type ALESIS_DM3AG = &device_creator<alesis_dm3ag_device>; - -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ - -static MACHINE_CONFIG_FRAGMENT( alesis_dm3ag ) - MCFG_SPEAKER_STANDARD_STEREO("out1_left", "out1_right") - MCFG_SOUND_ADD("dac", DAC, 0) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_left", 1.0) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "out1_right", 1.0) -MACHINE_CONFIG_END - -//------------------------------------------------- -// alesis_dm3ag_device - constructor -//------------------------------------------------- - -alesis_dm3ag_device::alesis_dm3ag_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ALESIS_DM3AG, "Alesis DM3AG", tag, owner, clock, "alesis_dm3ag", __FILE__), - m_dac(*this, "dac"), - m_samples(*this, DEVICE_SELF) -{ -} - -//------------------------------------------------- -// device_mconfig_additions -//------------------------------------------------- - -machine_config_constructor alesis_dm3ag_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( alesis_dm3ag ); -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void alesis_dm3ag_device::device_start() -{ - m_dac_update_timer = timer_alloc(TIMER_DAC_UPDATE); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void alesis_dm3ag_device::device_reset() -{ - m_dac_update_timer->adjust(attotime::from_hz(48000), 0, attotime::from_hz(48000)); - - m_output_active = false; - m_count = 0; - m_cur_sample = 0; - m_shift = 0; - memset(m_cmd, 0, sizeof(m_cmd)); -} - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- -void alesis_dm3ag_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - if (m_output_active) - { - INT16 sample = m_samples[m_cur_sample++]; - int count = 0; - - while (sample == -128) - { - count++; - - if (count == 1 && m_shift) - { - /* - The HR-16 seems to use a simple scheme to generate 16-bit samples from its 8-bit sample ROMs. - When the sound starts the 8-bit sample is sent to the most significant bits of the DAC and every - time a -1 sample is found the data is shifted one position to right. - */ - m_shift--; - - if (LOG) logerror("DM3AG '%s' shift: %02x\n", tag(), m_shift); - } - - // every block ends with three or more -1 samples - if (m_cur_sample == 0xfffff || count >= 3) - { - m_output_active = false; - sample = 0; - - if (LOG) logerror("DM3AG '%s' stop: %d, len: %d\n", tag(), m_cur_sample, m_cur_sample-((m_cmd[0]<<12) | (m_cmd[1]<<4) | ((m_cmd[2]>>4) & 0x0f))); - - break; - } - - sample = m_samples[m_cur_sample++]; - } - - m_dac->write_signed16((sample << m_shift) + 0x8000); - } -} - -WRITE8_MEMBER(alesis_dm3ag_device::write) -{ - if (LOG) logerror("DM3AG '%s' write: %02x\n", tag(), data); - - m_cmd[m_count++] = data; - - if (m_count == 5) - { - /* - commands are sent in block of 5 bytes (40 bits) - - bit 00-19 sample position in the roms - bit 20-23 ??? - bit 24-31 volume - bit 32-34 panning - bit 35 output selector: 0 = out2, 1 = out1 - bit 36-39 ??? - */ - - m_cur_sample = (m_cmd[0]<<12) | (m_cmd[1]<<4) | ((m_cmd[2]>>4) & 0x0f); - - if (m_cur_sample > 0) - { - m_output_active = true; - m_shift = 8; - - if (LOG) - { - bool good_pos = (m_cur_sample<2 || m_samples[m_cur_sample-2] == -128); - - logerror("DM3AG '%s' start: %d (%s), vol: %02x out: %d pan: %d\n", tag(), m_cur_sample, good_pos ? "ok": "no", m_cmd[3], m_cmd[4] & 0x10 ? 1 : 2, (m_cmd[4]>>5)&7); - } - } - - m_count = 0; - } -} diff --git a/src/mess/audio/arcadia.c b/src/mess/audio/arcadia.c deleted file mode 100644 index 306932a0b44..00000000000 --- a/src/mess/audio/arcadia.c +++ /dev/null @@ -1,177 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:David Viens, Peter Trauner -/*************************************************************************** - - PeT mess@utanet.at - main part in video/ - - Refined with recording/analysis on MPT-03 (PAL UVI chip) by plgDavid - - NTSC UVI sound clock: 15734Hz (arcadia) - PAL UVI sound clock: 15625Hz (Soundic MPT-03 - owned by plgDavid) -***************************************************************************/ - - -#include "includes/arcadia.h" - -//known UVI audio clocks -#define UVI_NTSC 15734 -#define UVI_PAL 15625 - -/* we need to create pulse transitions that sound 'decent' - with the current mess/mame interp scheme - - this is not needed anymore with the new trick in streams.c -*/ - -#define OSAMP 1 - -//lfsr is 9 bits long (and same as Atari TIA pure noise) -#define LFSR_MASK (1<<8) - -//makes alien invaders samples noise sync. -#define LFSR_INIT 0x00f0 - -//lfsr states at resynch borders -//0x01c1 -//0x01e0 -//0x00f0 //good synch -//0x0178 -//0x01bc - - -// device type definition -const device_type ARCADIA_SOUND = &device_creator<arcadia_sound_device>; - -//------------------------------------------------- -// arcadia_sound_device - constructor -//------------------------------------------------- - -arcadia_sound_device::arcadia_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ARCADIA_SOUND, "Arcadia Audio Custom", tag, owner, clock, "arcadia_sound", __FILE__), - device_sound_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- -void arcadia_sound_device::device_start() -{ - m_channel = machine().sound().stream_alloc(*this, 0, 1, UVI_PAL*OSAMP); - m_lfsr = LFSR_INIT; - m_tval = 1; - logerror("arcadia_sound start\n"); -} - -//------------------------------------------------- -// device_start - device-specific reset -//------------------------------------------------- -void arcadia_sound_device::device_reset() -{ - memset(m_reg, 0, sizeof(m_reg)); - m_omode = 0; - m_pos = 0; -} - -//------------------------------------------------- -// sound_stream_update - handle update requests for -// our sound stream -//------------------------------------------------- - -void arcadia_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - int i; - stream_sample_t *buffer = outputs[0]; - - for (i = 0; i < samples; i++, buffer++) - { - *buffer = 0; - - //if minimal pitch ? - if (m_reg[1]){ - switch (m_mode){ - //dont play anything - case 0:break; - - //tone only - case 1: - *buffer = m_volume * m_tval; - break; - - //noise only - case 2: - *buffer = m_volume * m_nval; - break; - - //tone AND noise (bitwise and) - case 3: - *buffer = m_volume * (m_tval & m_nval); - break; - } - - //counter - m_pos++; - - if (m_pos >= m_size){ - //calculate new noise bit ( taps: 0000T000T) - unsigned char newBit = m_lfsr & 1; //first tap - newBit = (newBit ^ ((m_lfsr & 0x10)?1:0) );//xor with second tap - - m_nval = m_lfsr & 1; //taking new output from LSB - m_lfsr = m_lfsr >> 1;//shifting - - //insert new bit at end position (size-1) (only if non null) - if (newBit) - m_lfsr |= LFSR_MASK; - - //invert tone - m_tval = !m_tval; - - m_pos = 0; - } - } - } -} - - - -//------------------------------------------------- -// soundport_w -//------------------------------------------------- - -WRITE8_MEMBER(arcadia_sound_device::write) -{ - m_channel->update(); - m_reg[offset] = data; - - //logerror("arcadia_sound write:%x=%x\n",offset,data); - - switch (offset) - { - case 1: - //as per Gobbler samples: - //the freq counter is only applied on the next change in the flip flop - m_size = (data & 0x7f)*OSAMP; - //logerror("arcadia_sound write: frq:%d\n",data); - - //reset LFSR - if(!m_size) - m_lfsr = LFSR_INIT; - break; - - case 2: - m_volume = (data & 0x07) * 0x800; - m_mode = (data & 0x18) >> 3; - - //logerror("arcadia_sound write: vol:%d mode:%d\n",m_volume,m_mode ); - - if (m_mode != m_omode){ - //not 100% sure about this, maybe we should not reset anything - //m_pos = 0; - m_tval = 0; - } - m_omode = m_mode; - break; - } -} diff --git a/src/mess/audio/arcadia.h b/src/mess/audio/arcadia.h deleted file mode 100644 index fa54ba1c0a1..00000000000 --- a/src/mess/audio/arcadia.h +++ /dev/null @@ -1,44 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -#ifndef ARCADIA_SOUND_H_ -#define ARCADIA_SOUND_H_ - -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_ARCADIA_SOUND_ADD(_tag) \ - MCFG_SOUND_ADD(_tag, ARCADIA_SOUND, 0) - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> arcadia_sound_device - -class arcadia_sound_device : public device_t, - public device_sound_interface -{ -public: - // construction/destruction - arcadia_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_WRITE8_MEMBER(write); -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - - sound_stream *m_channel; - UINT8 m_reg[3]; - int m_size, m_pos,m_tval,m_nval; - unsigned m_mode, m_omode; - unsigned m_volume; - unsigned m_lfsr; -}; - -// device type definition -extern const device_type ARCADIA_SOUND; - -#endif /* ARCADIA_SOUND_H_ */ diff --git a/src/mess/audio/channelf.c b/src/mess/audio/channelf.c deleted file mode 100644 index c9e07cbd43c..00000000000 --- a/src/mess/audio/channelf.c +++ /dev/null @@ -1,143 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller, Frank Palazzolo, Sean Riddle -#include "emu.h" -#include "audio/channelf.h" - - -#define MAX_AMPLITUDE 0x7fff - -const device_type CHANNELF_SOUND = &device_creator<channelf_sound_device>; - -channelf_sound_device::channelf_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, CHANNELF_SOUND, "Channel F Sound", tag, owner, clock, "channelf_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_channel(NULL), - m_sound_mode(0), - m_incr(0), - m_decay_mult(0), - m_envelope(0), - m_sample_counter(0), - m_forced_ontime(0), - m_min_ontime(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void channelf_sound_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void channelf_sound_device::device_start() -{ - int rate; - - m_channel = stream_alloc(0, 1, machine().sample_rate()); - rate = machine().sample_rate(); - - /* - * 2V = 1000Hz ~= 3579535/224/16 - * Note 2V on the schematic is not the 2V scanline counter - - * it is the 2V vertical pixel counter - * 1 pixel = 4 scanlines high - * - * - * This is a convenient way to generate the relevant frequencies, - * using a DDS (Direct Digital Synthesizer) - * - * Essentially, you want a counter to overflow some bit position - * at a fixed rate. So, you figure out a number which you can add - * to the counter at every sample, so that you will achieve this - * - * In this case, we want to overflow bit 16 and the 2V rate, 1000Hz. - * This means we also get bit 17 = 4V, bit 18 = 8V, etc. - */ - - /* This is the proper value to add per sample */ - m_incr = 65536.0/(rate/1000.0/2.0); - - // added for improved sound - /* This is the minimum forced ontime, in samples */ - m_min_ontime = rate/1000*2; /* approx 2ms - estimated, not verified on HW */ - - /* This was measured, decay envelope with half life of ~9ms */ - /* (this is decay multiplier per sample) */ - m_decay_mult = exp((-0.693/9e-3)/rate); - - /* initial conditions */ - m_envelope = 0; -} - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void channelf_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - UINT32 mask = 0, target = 0; - stream_sample_t *buffer = outputs[0]; - stream_sample_t *sample = buffer; - - switch( m_sound_mode ) - { - case 0: /* sound off */ - memset(buffer,0,sizeof(*buffer)*samples); - return; - - case 1: /* high tone (2V) - 1000Hz */ - mask = 0x00010000; - target = 0x00010000; - break; - case 2: /* medium tone (4V) - 500Hz */ - mask = 0x00020000; - target = 0x00020000; - break; - case 3: /* low (weird) tone (32V & 8V) */ - mask = 0x00140000; - target = 0x00140000; - break; - } - - while (samples-- > 0) - { - if ((m_forced_ontime > 0) || ((m_sample_counter & mask) == target)) // change made for improved sound - *sample++ = m_envelope; - else - *sample++ = 0; - m_sample_counter += m_incr; - m_envelope *= m_decay_mult; - if (m_forced_ontime > 0) // added for improved sound - m_forced_ontime -= 1; // added for improved sound - } -} - -void channelf_sound_device::sound_w(int mode) -{ - if (mode == m_sound_mode) - return; - - m_channel->update(); - m_sound_mode = mode; - - switch(mode) - { - case 0: - m_envelope = 0; - m_forced_ontime = 0; // added for improved sound - break; - case 1: - case 2: - case 3: - m_envelope = MAX_AMPLITUDE; - m_forced_ontime = m_min_ontime; // added for improved sound - break; - } -} diff --git a/src/mess/audio/channelf.h b/src/mess/audio/channelf.h deleted file mode 100644 index f227eb67c07..00000000000 --- a/src/mess/audio/channelf.h +++ /dev/null @@ -1,42 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Juergen Buchmueller, Frank Palazzolo, Sean Riddle -/***************************************************************************** - * - * audio/channelf.h - * - ****************************************************************************/ - -#ifndef CHANNELF_SOUND_H_ -#define CHANNELF_SOUND_H_ - -class channelf_sound_device : public device_t, - public device_sound_interface -{ -public: - channelf_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - void sound_w(int mode); -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); -private: - // internal state - sound_stream *m_channel; - int m_sound_mode; - int m_incr; - float m_decay_mult; - int m_envelope; - UINT32 m_sample_counter; - int m_forced_ontime; // added for improved sound - int m_min_ontime; // added for improved sound - -}; - -extern const device_type CHANNELF_SOUND; - - -#endif /* CHANNELF_SOUND_H_ */ diff --git a/src/mess/audio/dai_snd.c b/src/mess/audio/dai_snd.c deleted file mode 100644 index ae0bf3c79c3..00000000000 --- a/src/mess/audio/dai_snd.c +++ /dev/null @@ -1,141 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha -/*************************************************************************** - - audio/dai_snd.c - - Functions to emulate sound hardware of DAI Personal Computer - - Krzysztof Strzecha - -****************************************************************************/ - -#include "emu.h" -#include "dai_snd.h" - -// device type definition -const device_type DAI_SOUND = &device_creator<dai_sound_device>; - - -//------------------------------------------------- -// dai_sound_device - constructor -//------------------------------------------------- - -dai_sound_device::dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, DAI_SOUND, "DAI Audio Custom", tag, owner, clock, "dai_sound", __FILE__), - device_sound_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void dai_sound_device::device_start() -{ - m_mixer_channel = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate()); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void dai_sound_device::device_reset() -{ - memset(m_dai_input, 0, sizeof(m_dai_input)); - memset(m_osc_volume, 0, sizeof(m_osc_volume)); - m_noise_volume = 0; -} - - -//------------------------------------------------- -// channels 0/1/2 volume table -//------------------------------------------------- - -const UINT16 dai_sound_device::s_osc_volume_table[] = { - 0, 500, 1000, 1500, - 2000, 2500, 3000, 3500, - 4000, 4500, 5000, 5500, - 6000, 6500, 7000, 7500 -}; - -//------------------------------------------------- -// noise volume table -//------------------------------------------------- - -const UINT16 dai_sound_device::s_noise_volume_table[] = { - 0, 0, 0, 0, - 0, 0, 0, 0, - 500, 1000, 1500, 2000, - 2500, 3000, 3500, 4000 -}; - - -//------------------------------------------------- -// set_volume -//------------------------------------------------- - -WRITE8_MEMBER(dai_sound_device::set_volume) -{ - m_mixer_channel->update(); - - switch (offset & 1) - { - case 0x00: - m_osc_volume[0] = data&0x0f; - m_osc_volume[1] = (data&0xf0)>>4; - break; - - case 0x01: - m_osc_volume[2] = data&0x0f; - m_noise_volume = (data&0xf0)>>4; - } -} - -//------------------------------------------------- -// PIT callbacks -//------------------------------------------------- - -WRITE_LINE_MEMBER(dai_sound_device::set_input_ch0) -{ - m_mixer_channel->update(); - m_dai_input[0] = state; -} - -WRITE_LINE_MEMBER(dai_sound_device::set_input_ch1) -{ - m_mixer_channel->update(); - m_dai_input[1] = state; -} - -WRITE_LINE_MEMBER(dai_sound_device::set_input_ch2) -{ - m_mixer_channel->update(); - m_dai_input[2] = state; -} - -//------------------------------------------------- -// sound_stream_update - handle update requests for -// our sound stream -//------------------------------------------------- - -void dai_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *sample_left = outputs[0]; - stream_sample_t *sample_right = outputs[1]; - - INT16 channel_0_signal = m_dai_input[0] ? s_osc_volume_table[m_osc_volume[0]] : -s_osc_volume_table[m_osc_volume[0]]; - INT16 channel_1_signal = m_dai_input[1] ? s_osc_volume_table[m_osc_volume[1]] : -s_osc_volume_table[m_osc_volume[1]]; - INT16 channel_2_signal = m_dai_input[2] ? s_osc_volume_table[m_osc_volume[2]] : -s_osc_volume_table[m_osc_volume[2]]; - - while (samples--) - { - INT16 noise = machine().rand()&0x01 ? s_noise_volume_table[m_noise_volume] : -s_noise_volume_table[m_noise_volume]; - - /* channel 0 + channel 1 + noise */ - *sample_left++ = channel_0_signal + channel_1_signal + noise; - - /* channel 1 + channel 2 + noise */ - *sample_right++ = channel_1_signal + channel_2_signal + noise; - } -} diff --git a/src/mess/audio/dai_snd.h b/src/mess/audio/dai_snd.h deleted file mode 100644 index c1e5ae598e7..00000000000 --- a/src/mess/audio/dai_snd.h +++ /dev/null @@ -1,46 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Krzysztof Strzecha -/***************************************************************************** - * - * dai_snd.h - * - ****************************************************************************/ - -#ifndef DAI_SND_H_ -#define DAI_SND_H_ - -#include "emu.h" - -// ======================> dai_sound_device - -class dai_sound_device : public device_t, - public device_sound_interface -{ -public: - // construction/destruction - dai_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_WRITE_LINE_MEMBER(set_input_ch0); - DECLARE_WRITE_LINE_MEMBER(set_input_ch1); - DECLARE_WRITE_LINE_MEMBER(set_input_ch2); - DECLARE_WRITE8_MEMBER(set_volume); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -private: - sound_stream * m_mixer_channel; - int m_dai_input[3]; - UINT8 m_osc_volume[3]; - UINT8 m_noise_volume; - - static const UINT16 s_osc_volume_table[]; - static const UINT16 s_noise_volume_table[]; -}; - -extern const device_type DAI_SOUND; - -#endif /* DAI_H_ */ diff --git a/src/mess/audio/dave.c b/src/mess/audio/dave.c deleted file mode 100644 index 4adae892e16..00000000000 --- a/src/mess/audio/dave.c +++ /dev/null @@ -1,622 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Intelligent Designs DAVE emulation - -**********************************************************************/ - -#include "dave.h" - - - -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - -#define LOG 0 - -#define STEP 0x08000 - - - -//************************************************************************** -// DEVICE DEFINITIONS -//************************************************************************** - -const device_type DAVE = &device_creator<dave_device>; - - -DEVICE_ADDRESS_MAP_START( z80_program_map, 8, dave_device ) - AM_RANGE(0x0000, 0xffff) AM_READWRITE(program_r, program_w) -ADDRESS_MAP_END - -DEVICE_ADDRESS_MAP_START( z80_io_map, 8, dave_device ) - AM_RANGE(0x0000, 0xffff) AM_READWRITE(io_r, io_w) -ADDRESS_MAP_END - - -static ADDRESS_MAP_START( program_map, AS_PROGRAM, 8, dave_device ) -ADDRESS_MAP_END - -static ADDRESS_MAP_START( io_map, AS_IO, 8, dave_device ) -ADDRESS_MAP_END - - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// dave_device - constructor -//------------------------------------------------- - -dave_device::dave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, DAVE, "DAVE", tag, owner, clock, "dave", __FILE__), - device_memory_interface(mconfig, *this), - device_sound_interface(mconfig, *this), - m_program_space_config("program", ENDIANNESS_LITTLE, 8, 22, 0, *ADDRESS_MAP_NAME(program_map)), - m_io_space_config("i/o", ENDIANNESS_LITTLE, 8, 16, 0, *ADDRESS_MAP_NAME(io_map)), - m_write_irq(*this), - m_write_lh(*this), - m_write_rh(*this), - m_irq_status(0) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void dave_device::device_start() -{ - // resolve callbacks - m_write_irq.resolve_safe(); - m_write_lh.resolve_safe(); - m_write_rh.resolve_safe(); - - // allocate timers - m_timer_1hz = timer_alloc(TIMER_1HZ); - m_timer_1hz->adjust(attotime::from_hz(2), 0, attotime::from_hz(2)); - - m_timer_50hz = timer_alloc(TIMER_50HZ); - m_timer_50hz->adjust(attotime::from_hz(2000), 0, attotime::from_hz(2000)); - - // state saving - save_item(NAME(m_segment)); - save_item(NAME(m_irq_status)); - save_item(NAME(m_irq_enable)); - save_item(NAME(m_period)); - save_item(NAME(m_count)); - save_item(NAME(m_level)); - save_item(NAME(m_level_or)); - save_item(NAME(m_level_and)); - save_item(NAME(m_mame_volumes)); - - for (int i = 0; i < ARRAY_LENGTH(m_period); i++) - m_period[i] = (STEP * machine().sample_rate()) / 125000; - - for (int i = 0; i < ARRAY_LENGTH(m_count); i++) - m_count[i] = (STEP * machine().sample_rate()) / 125000; - - for (int i = 0; i < ARRAY_LENGTH(m_level); i++) - m_level[i] = 0; - - for (int i = 0; i < ARRAY_LENGTH(m_level_or); i++) - m_level_or[i] = 0; - - for (int i = 0; i < ARRAY_LENGTH(m_level_and); i++) - m_level_and[i] = 0; - - for (int i = 0; i < ARRAY_LENGTH(m_mame_volumes); i++) - m_mame_volumes[i] = 0; - - /* dave has 3 tone channels and 1 noise channel. - the volumes are mixed internally and output as left and right volume */ - - /* 3 tone channels + 1 noise channel */ - m_sound_stream_var = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate()); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void dave_device::device_reset() -{ - m_write_irq(CLEAR_LINE); - - for (int i = 0; i < 4; i++) - m_segment[i] = 0; - - m_irq_status = 0; - m_irq_enable = 0; - - for (int i = 0; i < 32; i++) - m_regs[i] = 0; -} - - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- - -void dave_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - switch (id) - { - case TIMER_1HZ: - m_irq_status ^= IRQ_1HZ_DIVIDER; - - if (m_irq_status & IRQ_1HZ_DIVIDER) - m_irq_status |= IRQ_1HZ_LATCH; - break; - - case TIMER_50HZ: - m_irq_status ^= IRQ_50HZ_DIVIDER; - - if (m_irq_status & IRQ_50HZ_DIVIDER) - m_irq_status |= IRQ_50HZ_LATCH; - break; - } - - update_interrupt(); -} - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -const address_space_config *dave_device::memory_space_config(address_spacenum spacenum) const -{ - switch (spacenum) - { - case AS_PROGRAM: return &m_program_space_config; - case AS_IO: return &m_io_space_config; - default: return NULL; - } -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void dave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *buffer1, *buffer2; - /* 0 = channel 0 left volume, 1 = channel 0 right volume, - 2 = channel 1 left volume, 3 = channel 1 right volume, - 4 = channel 2 left volume, 5 = channel 2 right volume - 6 = noise channel left volume, 7 = noise channel right volume */ - int output_volumes[8]; - int left_volume; - int right_volume; - - //logerror("sound update!\n"); - - buffer1 = outputs[0]; - buffer2 = outputs[1]; - - while (samples) - { - int vol[4]; - - /* vol[] keeps track of how long each square wave stays */ - /* in the 1 position during the sample period. */ - vol[0] = vol[1] = vol[2] = vol[3] = 0; - - for (int i = 0; i < 3; i++) - { - if ((m_regs[7] & (1 << i))==0) - { - if (m_level[i]) vol[i] += m_count[i]; - m_count[i] -= STEP; - /* Period[i] is the half period of the square wave. Here, in each */ - /* loop I add Period[i] twice, so that at the end of the loop the */ - /* square wave is in the same status (0 or 1) it was at the start. */ - /* vol[i] is also incremented by Period[i], since the wave has been 1 */ - /* exactly half of the time, regardless of the initial position. */ - /* If we exit the loop in the middle, Output[i] has to be inverted */ - /* and vol[i] incremented only if the exit status of the square */ - /* wave is 1. */ - while (m_count[i] <= 0) - { - m_count[i] += m_period[i]; - if (m_count[i] > 0) - { - m_level[i] ^= 0x0ffffffff; - if (m_level[i]) vol[i] += m_period[i]; - break; - } - m_count[i] += m_period[i]; - vol[i] += m_period[i]; - } - if (m_level[i]) - vol[i] -= m_count[i]; - } - } - - /* update volume outputs */ - - /* setup output volumes for each channel */ - /* channel 0 */ - output_volumes[0] = ((m_level[0] & m_level_and[0]) | m_level_or[0]) & m_mame_volumes[0]; - output_volumes[1] = ((m_level[0] & m_level_and[1]) | m_level_or[1]) & m_mame_volumes[4]; - /* channel 1 */ - output_volumes[2] = ((m_level[1] & m_level_and[2]) | m_level_or[2]) & m_mame_volumes[1]; - output_volumes[3] = ((m_level[1] & m_level_and[3]) | m_level_or[3]) & m_mame_volumes[5]; - /* channel 2 */ - output_volumes[4] = ((m_level[2] & m_level_and[4]) | m_level_or[4]) & m_mame_volumes[2]; - output_volumes[5] = ((m_level[2] & m_level_and[5]) | m_level_or[5]) & m_mame_volumes[6]; - /* channel 3 */ - output_volumes[6] = ((m_level[3] & m_level_and[6]) | m_level_or[6]) & m_mame_volumes[3]; - output_volumes[7] = ((m_level[3] & m_level_and[7]) | m_level_or[7]) & m_mame_volumes[7]; - - left_volume = (output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6])>>2; - right_volume = (output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7])>>2; - - *(buffer1++) = left_volume; - *(buffer2++) = right_volume; - - samples--; - } -} - - -//------------------------------------------------- -// int1_w - interrupt 1 write -//------------------------------------------------- - -WRITE_LINE_MEMBER( dave_device::int1_w ) -{ - if (!(m_irq_status & IRQ_INT1) && state) - m_irq_status |= IRQ_INT1_LATCH; - - if (state) - m_irq_status |= IRQ_INT1; - else - m_irq_status &= ~IRQ_INT1; - - update_interrupt(); -} - - -//------------------------------------------------- -// int2_w - interrupt 2 write -//------------------------------------------------- - -WRITE_LINE_MEMBER( dave_device::int2_w ) -{ - if (!(m_irq_status & IRQ_INT2) && state) - m_irq_status |= IRQ_INT2_LATCH; - - if (state) - m_irq_status |= IRQ_INT2; - else - m_irq_status &= ~IRQ_INT2; - - update_interrupt(); -} - - -//------------------------------------------------- -// program_r - program space read -//------------------------------------------------- - -READ8_MEMBER( dave_device::program_r ) -{ - UINT8 segment = m_segment[offset >> 14]; - offset = (segment << 14) | (offset & 0x3fff); - - return this->space(AS_PROGRAM).read_byte(offset); -} - - -//------------------------------------------------- -// program_w - program space write -//------------------------------------------------- - -WRITE8_MEMBER( dave_device::program_w ) -{ - UINT8 segment = m_segment[offset >> 14]; - offset = (segment << 14) | (offset & 0x3fff); - - this->space(AS_PROGRAM).write_byte(offset, data); -} - - -//------------------------------------------------- -// io_r - I/O space read -//------------------------------------------------- - -READ8_MEMBER( dave_device::io_r ) -{ - UINT8 data = 0; - - switch (offset & 0xff) - { - case 0xa0: - case 0xa1: - case 0xa2: - case 0xa3: - case 0xa4: - case 0xa5: - case 0xa6: - case 0xa7: - case 0xa8: - case 0xa9: - case 0xaa: - case 0xab: - case 0xac: - case 0xad: - case 0xae: - case 0xaf: - case 0xb8: - case 0xb9: - case 0xba: - case 0xbb: - case 0xbc: - case 0xbd: - case 0xbe: - case 0xbf: - data = 0xff; - break; - - case 0xb0: case 0xb1: case 0xb2: case 0xb3: - data = m_segment[offset & 0x03]; - break; - - case 0xb4: - data = m_irq_status; - break; - - default: - data = this->space(AS_IO).read_byte(offset); - } - - return data; -} - - -//------------------------------------------------- -// io_w - I/O space write -//------------------------------------------------- - -WRITE8_MEMBER( dave_device::io_w ) -{ - switch (offset & 0xff) - { - /* channel 0 down-counter */ - case 0xa0: - case 0xa1: - /* channel 1 down-counter */ - case 0xa2: - case 0xa3: - /* channel 2 down-counter */ - case 0xa4: - case 0xa5: - { - int count = 0; - int channel_index = (offset>>1)&3; - - /* Fout = 125,000 / (n+1) Hz */ - - /* sample rate/clock */ - - - /* get down-count */ - switch (offset & 0x01) - { - case 0: - { - count = (data & 0x0ff) | ((m_regs[(offset & 0x1f) + 1] & 0x0f)<<8); - } - break; - - case 1: - { - count = (m_regs[(offset & 0x1f) - 1] & 0x0ff) | ((data & 0x0f)<<8); - - } - break; - } - - count++; - - - m_period[channel_index] = ((STEP * machine().sample_rate())/125000) * count; - - m_regs[offset & 0x1f] = data; - } - break; - - /* channel 0 left volume */ - case 0xa8: - /* channel 1 left volume */ - case 0xa9: - /* channel 2 left volume */ - case 0xaa: - /* noise channel left volume */ - case 0xab: - /* channel 0 right volume */ - case 0xac: - /* channel 1 right volume */ - case 0xad: - /* channel 2 right volume */ - case 0xae: - /* noise channel right volume */ - case 0xaf: - { - /* update mame version of volume from data written */ - /* 0x03f->0x07e00. Max is 0x07fff */ - /* I believe the volume is linear - to be checked! */ - m_mame_volumes[(offset & 0x1f) - 8] = (data & 0x03f) << 9; - - m_regs[offset & 0x1f] = data; - } - break; - - case 0xa6: - break; - - case 0xa7: - { - /* force => the value of this register is forced regardless of the wave - state, - remove => this value is force to zero so that it has no influence over - the final volume calculation, regardless of wave state - use => the volume value is dependant on the wave state and is included - in the final volume calculation */ - - //logerror("selectable int "); - switch ((data>>5) & 0x03) - { - case 0: - { - //logerror("1kHz\n"); - m_timer_50hz->adjust(attotime::from_hz(2000), 0, attotime::from_hz(2000)); - } - break; - - case 1: - { - //logerror("50Hz\n"); - m_timer_50hz->adjust(attotime::from_hz(100), 0, attotime::from_hz(100)); - } - break; - - case 2: - { - //logerror("tone channel 0\n"); - } - break; - - case 3: - { - //logerror("tone channel 1\n"); - } - break; - } - - - - /* turn L.H audio output into D/A, outputting value in R8 */ - if (data & (1<<3)) - { - /* force r8 value */ - m_level_or[0] = 0x0ffff; - m_level_and[0] = 0x00; - - /* remove r9 value */ - m_level_or[2] = 0x000; - m_level_and[2] = 0x00; - - /* remove r10 value */ - m_level_or[4] = 0x000; - m_level_and[4] = 0x00; - - /* remove r11 value */ - m_level_or[6] = 0x000; - m_level_and[6] = 0x00; - } - else - { - /* use r8 value */ - m_level_or[0] = 0x000; - m_level_and[0] = 0xffff; - - /* use r9 value */ - m_level_or[2] = 0x000; - m_level_and[2] = 0xffff; - - /* use r10 value */ - m_level_or[4] = 0x000; - m_level_and[4] = 0xffff; - - /* use r11 value */ - m_level_or[6] = 0x000; - m_level_and[6] = 0xffff; - } - - /* turn L.H audio output into D/A, outputting value in R12 */ - if (data & (1<<4)) - { - /* force r12 value */ - m_level_or[1] = 0x0ffff; - m_level_and[1] = 0x00; - - /* remove r13 value */ - m_level_or[3] = 0x000; - m_level_and[3] = 0x00; - - /* remove r14 value */ - m_level_or[5] = 0x000; - m_level_and[5] = 0x00; - - /* remove r15 value */ - m_level_or[7] = 0x000; - m_level_and[7] = 0x00; - } - else - { - /* use r12 value */ - m_level_or[1] = 0x000; - m_level_and[1] = 0xffff; - - /* use r13 value */ - m_level_or[3] = 0x000; - m_level_and[3] = 0xffff; - - /* use r14 value */ - m_level_or[5] = 0x000; - m_level_and[5] = 0xffff; - - /* use r15 value */ - m_level_or[7] = 0x000; - m_level_and[7] = 0xffff; - } - - m_regs[offset & 0x1f] = data; - } - break; - - case 0xb0: case 0xb1: case 0xb2: case 0xb3: - m_segment[offset & 0x03] = data; - - m_regs[offset & 0x1f] = data; - break; - - case 0xb4: - m_irq_enable = data; - m_irq_status &= ~(m_irq_enable & IRQ_LATCH); - update_interrupt(); - - m_regs[offset & 0x1f] = data; - break; - - case 0xbf: - m_regs[offset & 0x1f] = data; - break; - - default: - this->space(AS_IO).write_byte(offset, data); - } -} - - -//------------------------------------------------- -// update_interrupt - -//------------------------------------------------- - -void dave_device::update_interrupt() -{ - int state = ((m_irq_status & (m_irq_enable << 1)) & IRQ_LATCH) ? ASSERT_LINE : CLEAR_LINE; - - m_write_irq(state); -} diff --git a/src/mess/audio/dave.h b/src/mess/audio/dave.h deleted file mode 100644 index 9bab709bd62..00000000000 --- a/src/mess/audio/dave.h +++ /dev/null @@ -1,156 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Curt Coder -/********************************************************************** - - Intelligent Designs DAVE emulation - -**********************************************************************/ - -#pragma once - -#ifndef __DAVE__ -#define __DAVE__ - -#include "emu.h" - - - -///************************************************************************* -// MACROS / CONSTANTS -///************************************************************************* - - - -///************************************************************************* -// INTERFACE CONFIGURATION MACROS -///************************************************************************* - -#define MCFG_DAVE_ADD(_tag, _clock, _program_map, _io_map) \ - MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") \ - MCFG_SOUND_ADD(_tag, DAVE, _clock) \ - MCFG_SOUND_ROUTE(0, "lspeaker", 0.25) \ - MCFG_SOUND_ROUTE(1, "rspeaker", 0.25) \ - MCFG_DEVICE_ADDRESS_MAP(AS_PROGRAM, _program_map) \ - MCFG_DEVICE_ADDRESS_MAP(AS_IO, _io_map) - - -#define MCFG_DAVE_IRQ_CALLBACK(_write) \ - devcb = &dave_device::set_irq_wr_callback(*device, DEVCB_##_write); - -#define MCFG_DAVE_LH_CALLBACK(_write) \ - devcb = &dave_device::set_lh_wr_callback(*device, DEVCB_##_write); - -#define MCFG_DAVE_RH_CALLBACK(_write) \ - devcb = &dave_device::set_rh_wr_callback(*device, DEVCB_##_write); - - - -///************************************************************************* -// TYPE DEFINITIONS -///************************************************************************* - -// ======================> dave_device - -class dave_device : public device_t, - public device_memory_interface, - public device_sound_interface -{ -public: - dave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - template<class _Object> static devcb_base &set_irq_wr_callback(device_t &device, _Object object) { return downcast<dave_device &>(device).m_write_irq.set_callback(object); } - template<class _Object> static devcb_base &set_lh_wr_callback(device_t &device, _Object object) { return downcast<dave_device &>(device).m_write_lh.set_callback(object); } - template<class _Object> static devcb_base &set_rh_wr_callback(device_t &device, _Object object) { return downcast<dave_device &>(device).m_write_rh.set_callback(object); } - - virtual DECLARE_ADDRESS_MAP(z80_program_map, 8); - virtual DECLARE_ADDRESS_MAP(z80_io_map, 8); - - DECLARE_WRITE_LINE_MEMBER( int1_w ); - DECLARE_WRITE_LINE_MEMBER( int2_w ); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - - // device_memory_interface overrides - virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - - DECLARE_READ8_MEMBER( program_r ); - DECLARE_WRITE8_MEMBER( program_w ); - - DECLARE_READ8_MEMBER( io_r ); - DECLARE_WRITE8_MEMBER( io_w ); - -private: - enum - { - TIMER_1HZ, - TIMER_50HZ - }; - - enum - { - IRQ_50HZ_DIVIDER = 0x01, - IRQ_50HZ_LATCH = 0x02, - IRQ_1HZ_DIVIDER = 0x04, - IRQ_1HZ_LATCH = 0x08, - IRQ_INT1 = 0x10, - IRQ_INT1_LATCH = 0x20, - IRQ_INT2 = 0x40, - IRQ_INT2_LATCH = 0x80, - IRQ_LATCH = IRQ_INT2_LATCH | IRQ_INT1_LATCH | IRQ_1HZ_LATCH | IRQ_50HZ_LATCH - }; - - void update_interrupt(); - - const address_space_config m_program_space_config; - const address_space_config m_io_space_config; - - devcb_write_line m_write_irq; - devcb_write8 m_write_lh; - devcb_write8 m_write_rh; - - UINT8 m_segment[4]; - - UINT8 m_irq_status; - UINT8 m_irq_enable; - - emu_timer *m_timer_1hz; - emu_timer *m_timer_50hz; - - /* SOUND SYNTHESIS */ - UINT8 m_regs[32]; - int m_period[4]; - int m_count[4]; - int m_level[4]; - - /* these are used to force channels on/off */ - /* if one of the or values is 0x0ff, this means - the volume will be forced on,else it is dependant on - the state of the wave */ - int m_level_or[8]; - /* if one of the values is 0x00, this means the - volume is forced off, else it is dependant on the wave */ - int m_level_and[8]; - - /* these are the current channel volumes in MAME form */ - int m_mame_volumes[8]; - - /* update step */ - //int m_update_step; - - sound_stream *m_sound_stream_var; -}; - - -// device type definition -extern const device_type DAVE; - - - -#endif diff --git a/src/mess/audio/gamate.c b/src/mess/audio/gamate.c deleted file mode 100644 index 19555dd7c44..00000000000 --- a/src/mess/audio/gamate.c +++ /dev/null @@ -1,253 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/*************************************************************************** - gamate sound hardware - - PeT mess@utanet.at 2015 -***************************************************************************/ - -#include "emu.h" -#include "includes/gamate.h" -#include "ui/ui.h" - - -enum { ClockDelay=32 }; - -// device type definition -const device_type GAMATE_SND = &device_creator<gamate_sound_device>; - -const int gamate_sound_device::DAConverter[]={ 0, 3, 7, 13, 23, 41, 75, 137, 249, 453, 825, 1499, 2726, 4956, 9011, 16383 }; // (*.55) on the real below index 8 bareless measureable -const UINT8 Mask[]={ 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0x1f, 0x3f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xf }; -const int EnvelopeVolumes[]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// gamate_sound_device - constructor -//------------------------------------------------- - -gamate_sound_device::gamate_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, GAMATE_SND, "Gamate Audio Custom", tag, owner, clock, "gamate_sound", __FILE__) - , device_sound_interface(mconfig, *this) - , m_mixer_channel(NULL) - {} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void gamate_sound_device::device_start() -{ - // bind callbacks -// m_irq_cb.bind_relative_to(*owner()); - - memset(m_channels, 0, sizeof(m_channels)); - memset(reg, 0, sizeof(reg)); - - m_mixer_channel = stream_alloc(0, 2, machine().sample_rate()); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void gamate_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *left=outputs[0], *right=outputs[1]; - int i, j; - Tone *channel; - - for (i = 0; i < samples; i++, left++, right++) - { - noise.pos += noise.step; - while (noise.pos >= 1.0) - { - // guess (white noise register taken from supervision) - noise.level = noise.state & 0x40 ? 1 : 0; - bool b1 = (noise.state & 0x40) != 0, b2 = (noise.state & 0x20) != 0; - noise.state=(noise.state<<1)+(b1!=b2?1:0); - noise.pos -= 1; - } - - envelope.pos += envelope.step; - while (envelope.pos >= 1.0) { - envelope.pos -= 1; - envelope.index++; - switch (envelope.control) - { - case 0: case 1: case 2: case 3: - case 4: case 5: case 6: case 7: - case 8: case 9: case 0xb: - case 0xd: case 0xf: - if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)/2) - { - envelope.index=0; - envelope.first=false; - } - break; - default: - if (envelope.index>=ARRAY_LENGTH(EnvelopeVolumes)) - { - envelope.index=0; - envelope.first=false; - } - break; - } - } - - *left = 0; - *right = 0; - for (channel=m_channels, j=0; j<ARRAY_LENGTH(m_channels); j++, channel++) - { - if (channel->size != 0) - { - channel->level= channel->pos <= channel->size / 2; - bool l= channel->full_cycle? true: channel->level; - if (!channel->tone) - l= l && noise.level; - int volume=0; - if (l) - { - if (channel->envelope_on) - { - switch (envelope.control) - { - case 0: case 1: case 2: case 3: - case 0x9: // one time falling, low - if (envelope.first && channel->level) - volume=0xf-EnvelopeVolumes[envelope.index]; - break; - case 4: case 5: case 6: case 7: - case 0xf: // one time rising, low - if (envelope.first && channel->level) - volume=EnvelopeVolumes[envelope.index]; - break; - case 8: // falling - if (channel->level) - volume=0xf-EnvelopeVolumes[envelope.index]; - break; - case 0xa: // rising, falling - if (channel->level) - volume=0xf-EnvelopeVolumes[envelope.index]; // cube up - break; - case 0xb: // one time falling, high - if (channel->level) - volume=envelope.first ? 0xf-EnvelopeVolumes[envelope.index] : 0xf; - break; - case 0xc: // rising, low - if (channel->level) - volume=envelope.index<ARRAY_LENGTH(EnvelopeVolumes)/2 ? EnvelopeVolumes[envelope.index] : 0; - break; - case 0xd: // one time rising, high - if (channel->level) - volume=envelope.first ? EnvelopeVolumes[envelope.index] : 0xf; - break; - case 0xe: // falling, rising - if (channel->level) - volume=0xf-EnvelopeVolumes[envelope.index]; - break; - } - } - else - { - volume=channel->volume; - } - } - if (j == Right) - *right += Value2Volume(volume); - else - if (j==Left) - *left += Value2Volume(volume); - else - { - *right += Value2Volume(volume); - *left += Value2Volume(volume); - } - channel->pos++; - if (channel->pos >= channel->size) - channel->pos = 0; - } - } - } -} - -WRITE8_MEMBER( gamate_sound_device::device_w ) -{ - UINT16 size; - - m_mixer_channel->update(); - reg[offset] = data; - int chan=-1; - - switch (offset&0xf) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - chan=offset/2; - size = reg[chan*2] | ((reg[chan*2+1] & 0xf) << 8); - if (size) - { - m_channels[chan].size= (int) (machine().sample_rate() * size*ClockDelay / m_clock); - } - else - { - m_channels[chan].size = 0; - } - m_channels[chan].pos = 0; - break; - case 6: - size=data&0x1f; - if (size==0) - size=1; - noise.step= m_clock / (1.0*ClockDelay*machine().sample_rate()*size); - break; - case 7: - m_channels[Right].full_cycle=data&1; - m_channels[Right].tone=data&8; - m_channels[Left].full_cycle=data&2; - m_channels[Left].tone=data&0x10; - m_channels[Both].full_cycle=data&4; - m_channels[Both].tone=data&0x20; - noise.state=1; - noise.pos=0.0; - noise.level=false; - break; - case 8: - case 9: - case 0xa: - chan=offset-8; - m_channels[chan].envelope_on = data & 0x10; // buggy aussetzer cube up - m_channels[chan].volume = data & 0xf; - break; - case 0xb: case 0xc: - size = reg[0xb] | ((reg[0xc]) << 8); - if (size==0) - size=1; - envelope.step= m_clock / (1.0*ClockDelay*machine().sample_rate()*size); - break; - case 0xd: - envelope.control=data&0xf; - envelope.pos=0; - envelope.index=0; - envelope.first=true; - break; - - } - envelope.pos=0; // guess - envelope.index=0; - envelope.first=true; -} - -READ8_MEMBER( gamate_sound_device::device_r ) -{ - UINT8 data=0; - if ((offset&0xf)<ARRAY_LENGTH(Mask)) - data=reg[offset&0xf]&Mask[offset&0xf]; // unused bits set to last write value? in this area - return data; -} diff --git a/src/mess/audio/gb.c b/src/mess/audio/gb.c deleted file mode 100644 index 181eb7ad2fb..00000000000 --- a/src/mess/audio/gb.c +++ /dev/null @@ -1,795 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Anthony Kruize -/************************************************************************************** -* Game Boy sound emulation (c) Anthony Kruize (trandor@labyrinth.net.au) -* -* Anyways, sound on the Game Boy consists of 4 separate 'channels' -* Sound1 = Quadrangular waves with SWEEP and ENVELOPE functions (NR10,11,12,13,14) -* Sound2 = Quadrangular waves with ENVELOPE functions (NR21,22,23,24) -* Sound3 = Wave patterns from WaveRAM (NR30,31,32,33,34) -* Sound4 = White noise with an envelope (NR41,42,43,44) -* -* Each sound channel has 2 modes, namely ON and OFF... whoa -* -* These tend to be the two most important equations in -* converting between Hertz and GB frequency registers: -* (Sounds will have a 2.4% higher frequency on Super GB.) -* gb = 2048 - (131072 / Hz) -* Hz = 131072 / (2048 - gb) -* -* Changes: -* -* 10/2/2002 AK - Preliminary sound code. -* 13/2/2002 AK - Added a hack for mode 4, other fixes. -* 23/2/2002 AK - Use lookup tables, added sweep to mode 1. Re-wrote the square -* wave generation. -* 13/3/2002 AK - Added mode 3, better lookup tables, other adjustments. -* 15/3/2002 AK - Mode 4 can now change frequencies. -* 31/3/2002 AK - Accidently forgot to handle counter/consecutive for mode 1. -* 3/4/2002 AK - Mode 1 sweep can still occur if shift is 0. Don't let frequency -* go past the maximum allowed value. Fixed Mode 3 length table. -* Slight adjustment to Mode 4's period table generation. -* 5/4/2002 AK - Mode 4 is done correctly, using a polynomial counter instead -* of being a total hack. -* 6/4/2002 AK - Slight tweak to mode 3's frequency calculation. -* 13/4/2002 AK - Reset envelope value when sound is initialized. -* 21/4/2002 AK - Backed out the mode 3 frequency calculation change. -* Merged init functions into gameboy_sound_w(). -* 14/5/2002 AK - Removed magic numbers in the fixed point math. -* 12/6/2002 AK - Merged SOUNDx structs into one SOUND struct. -* 26/10/2002 AK - Finally fixed channel 3! -* -***************************************************************************************/ - -#include "emu.h" -#include "gb.h" - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -#define NR10 0x00 -#define NR11 0x01 -#define NR12 0x02 -#define NR13 0x03 -#define NR14 0x04 -#define NR21 0x06 -#define NR22 0x07 -#define NR23 0x08 -#define NR24 0x09 -#define NR30 0x0A -#define NR31 0x0B -#define NR32 0x0C -#define NR33 0x0D -#define NR34 0x0E -#define NR41 0x10 -#define NR42 0x11 -#define NR43 0x12 -#define NR44 0x13 -#define NR50 0x14 -#define NR51 0x15 -#define NR52 0x16 -#define AUD3W0 0x20 -#define AUD3W1 0x21 -#define AUD3W2 0x22 -#define AUD3W3 0x23 -#define AUD3W4 0x24 -#define AUD3W5 0x25 -#define AUD3W6 0x26 -#define AUD3W7 0x27 -#define AUD3W8 0x28 -#define AUD3W9 0x29 -#define AUD3WA 0x2A -#define AUD3WB 0x2B -#define AUD3WC 0x2C -#define AUD3WD 0x2D -#define AUD3WE 0x2E -#define AUD3WF 0x2F - -#define LEFT 1 -#define RIGHT 2 -#define FIXED_POINT 16 - -/* Represents wave duties of 12.5%, 25%, 50% and 75% */ -static const float wave_duty_table[4] = { 8.0f, 4.0f, 2.0f, 1.33f }; - -// device type definition -const device_type GAMEBOY = &device_creator<gameboy_sound_device>; - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// gameboy_sound_device - constructor -//------------------------------------------------- - -gameboy_sound_device::gameboy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, GAMEBOY, "LR35902 Sound", tag, owner, clock, "gameboy_sound", __FILE__), - device_sound_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void gameboy_sound_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void gameboy_sound_device::device_start() -{ - m_channel = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate()); - m_rate = machine().sample_rate(); - - save_item(NAME(m_snd_regs)); - // sound control - save_item(NAME(m_snd_control.on)); - save_item(NAME(m_snd_control.vol_left)); - save_item(NAME(m_snd_control.vol_right)); - save_item(NAME(m_snd_control.mode1_left)); - save_item(NAME(m_snd_control.mode1_right)); - save_item(NAME(m_snd_control.mode2_left)); - save_item(NAME(m_snd_control.mode2_right)); - save_item(NAME(m_snd_control.mode3_left)); - save_item(NAME(m_snd_control.mode3_right)); - save_item(NAME(m_snd_control.mode4_left)); - save_item(NAME(m_snd_control.mode4_right)); - // sound 1 - save_item(NAME(m_snd_1.on)); - save_item(NAME(m_snd_1.channel)); - save_item(NAME(m_snd_1.length)); - save_item(NAME(m_snd_1.pos)); - save_item(NAME(m_snd_1.period)); - save_item(NAME(m_snd_1.count)); - save_item(NAME(m_snd_1.mode)); - save_item(NAME(m_snd_1.duty)); - save_item(NAME(m_snd_1.env_value)); - save_item(NAME(m_snd_1.env_direction)); - save_item(NAME(m_snd_1.env_length)); - save_item(NAME(m_snd_1.env_count)); - save_item(NAME(m_snd_1.signal)); - save_item(NAME(m_snd_1.frequency)); - save_item(NAME(m_snd_1.swp_shift)); - save_item(NAME(m_snd_1.swp_direction)); - save_item(NAME(m_snd_1.swp_time)); - save_item(NAME(m_snd_1.swp_count)); - save_item(NAME(m_snd_1.level)); - save_item(NAME(m_snd_1.offset)); - save_item(NAME(m_snd_1.dutycount)); - save_item(NAME(m_snd_1.ply_step)); - save_item(NAME(m_snd_1.ply_value)); - // sound 2 - save_item(NAME(m_snd_2.on)); - save_item(NAME(m_snd_2.channel)); - save_item(NAME(m_snd_2.length)); - save_item(NAME(m_snd_2.pos)); - save_item(NAME(m_snd_2.period)); - save_item(NAME(m_snd_2.count)); - save_item(NAME(m_snd_2.mode)); - save_item(NAME(m_snd_2.duty)); - save_item(NAME(m_snd_2.env_value)); - save_item(NAME(m_snd_2.env_direction)); - save_item(NAME(m_snd_2.env_length)); - save_item(NAME(m_snd_2.env_count)); - save_item(NAME(m_snd_2.signal)); - save_item(NAME(m_snd_2.frequency)); - save_item(NAME(m_snd_2.swp_shift)); - save_item(NAME(m_snd_2.swp_direction)); - save_item(NAME(m_snd_2.swp_time)); - save_item(NAME(m_snd_2.swp_count)); - save_item(NAME(m_snd_2.level)); - save_item(NAME(m_snd_2.offset)); - save_item(NAME(m_snd_2.dutycount)); - save_item(NAME(m_snd_2.ply_step)); - save_item(NAME(m_snd_2.ply_value)); - // sound 3 - save_item(NAME(m_snd_3.on)); - save_item(NAME(m_snd_3.channel)); - save_item(NAME(m_snd_3.length)); - save_item(NAME(m_snd_3.pos)); - save_item(NAME(m_snd_3.period)); - save_item(NAME(m_snd_3.count)); - save_item(NAME(m_snd_3.mode)); - save_item(NAME(m_snd_3.duty)); - save_item(NAME(m_snd_3.env_value)); - save_item(NAME(m_snd_3.env_direction)); - save_item(NAME(m_snd_3.env_length)); - save_item(NAME(m_snd_3.env_count)); - save_item(NAME(m_snd_3.signal)); - save_item(NAME(m_snd_3.frequency)); - save_item(NAME(m_snd_3.swp_shift)); - save_item(NAME(m_snd_3.swp_direction)); - save_item(NAME(m_snd_3.swp_time)); - save_item(NAME(m_snd_3.swp_count)); - save_item(NAME(m_snd_3.level)); - save_item(NAME(m_snd_3.offset)); - save_item(NAME(m_snd_3.dutycount)); - save_item(NAME(m_snd_3.ply_step)); - save_item(NAME(m_snd_3.ply_value)); - // sound 4 - save_item(NAME(m_snd_4.on)); - save_item(NAME(m_snd_4.channel)); - save_item(NAME(m_snd_4.length)); - save_item(NAME(m_snd_4.pos)); - save_item(NAME(m_snd_4.period)); - save_item(NAME(m_snd_4.count)); - save_item(NAME(m_snd_4.mode)); - save_item(NAME(m_snd_4.duty)); - save_item(NAME(m_snd_4.env_value)); - save_item(NAME(m_snd_4.env_direction)); - save_item(NAME(m_snd_4.env_length)); - save_item(NAME(m_snd_4.env_count)); - save_item(NAME(m_snd_4.signal)); - save_item(NAME(m_snd_4.frequency)); - save_item(NAME(m_snd_4.swp_shift)); - save_item(NAME(m_snd_4.swp_direction)); - save_item(NAME(m_snd_4.swp_time)); - save_item(NAME(m_snd_4.swp_count)); - save_item(NAME(m_snd_4.level)); - save_item(NAME(m_snd_4.offset)); - save_item(NAME(m_snd_4.dutycount)); - save_item(NAME(m_snd_4.ply_step)); - save_item(NAME(m_snd_4.ply_value)); -} - -//------------------------------------------------- -// device_reset -//------------------------------------------------- - -void gameboy_sound_device::device_reset() -{ - memset(&m_snd_1, 0, sizeof(m_snd_1)); - memset(&m_snd_2, 0, sizeof(m_snd_2)); - memset(&m_snd_3, 0, sizeof(m_snd_3)); - memset(&m_snd_4, 0, sizeof(m_snd_4)); - - /* Calculate the envelope and sweep tables */ - for (int i = 0; i < 8; i++) - { - m_env_length_table[i] = (i * ((1 << FIXED_POINT) / 64) * m_rate) >> FIXED_POINT; - m_swp_time_table[i] = (((i << FIXED_POINT) / 128) * m_rate) >> (FIXED_POINT - 1); - } - - /* Calculate the period tables */ - for (int i = 0; i < MAX_FREQUENCIES; i++) - { - m_period_table[i] = ((1 << FIXED_POINT) / (131072 / (2048 - i))) * m_rate; - m_period_mode3_table[i] = ((1 << FIXED_POINT) / (65536 / (2048 - i))) * m_rate; - } - /* Calculate the period table for mode 4 */ - for (int i = 0; i < 8; i++) - { - for (int j = 0; j < 16; j++) - { - // i is the dividing ratio of frequencies - // j is the shift clock frequency - m_period_mode4_table[i][j] = ((1 << FIXED_POINT) / (524288 / ((i == 0) ? 0.5 : i) / (1 << (j + 1)))) * m_rate; - } - } - - /* Calculate the length table */ - for (int i = 0; i < 64; i++) - m_length_table[i] = ((64 - i) * ((1 << FIXED_POINT)/256) * m_rate) >> FIXED_POINT; - - /* Calculate the length table for mode 3 */ - for (int i = 0; i < 256; i++) - m_length_mode3_table[i] = ((256 - i) * ((1 << FIXED_POINT)/256) * m_rate) >> FIXED_POINT; - - sound_w_internal(NR52, 0x00); - m_snd_regs[AUD3W0] = 0xac; - m_snd_regs[AUD3W1] = 0xdd; - m_snd_regs[AUD3W2] = 0xda; - m_snd_regs[AUD3W3] = 0x48; - m_snd_regs[AUD3W4] = 0x36; - m_snd_regs[AUD3W5] = 0x02; - m_snd_regs[AUD3W6] = 0xcf; - m_snd_regs[AUD3W7] = 0x16; - m_snd_regs[AUD3W8] = 0x2c; - m_snd_regs[AUD3W9] = 0x04; - m_snd_regs[AUD3WA] = 0xe5; - m_snd_regs[AUD3WB] = 0x2c; - m_snd_regs[AUD3WC] = 0xac; - m_snd_regs[AUD3WD] = 0xdd; - m_snd_regs[AUD3WE] = 0xda; - m_snd_regs[AUD3WF] = 0x48; -} - - -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ - -READ8_MEMBER( gameboy_sound_device::wave_r ) -{ - /* TODO: properly emulate scrambling of wave ram area when playback is active */ - return m_snd_regs[AUD3W0 + offset] | m_snd_3.on; -} - -READ8_MEMBER( gameboy_sound_device::sound_r ) -{ - switch (offset) - { - case 0x05: - case 0x0f: - return 0xff; - case NR52: - return 0x70 | m_snd_regs[offset]; - default: - return m_snd_regs[offset]; - } -} - -WRITE8_MEMBER( gameboy_sound_device::wave_w ) -{ - m_snd_regs[AUD3W0 + offset] = data; -} - -WRITE8_MEMBER( gameboy_sound_device::sound_w ) -{ - /* change in registers so update first */ - m_channel->update(); - - /* Only register NR52 is accessible if the sound controller is disabled */ - if (!m_snd_control.on && offset != NR52) - return; - - sound_w_internal(offset, data); -} - - -void gameboy_sound_device::sound_w_internal( int offset, UINT8 data ) -{ - /* Store the value */ - m_snd_regs[offset] = data; - - switch (offset) - { - /*MODE 1 */ - case NR10: /* Sweep (R/W) */ - m_snd_1.swp_shift = data & 0x7; - m_snd_1.swp_direction = (data & 0x8) >> 3; - m_snd_1.swp_direction |= m_snd_1.swp_direction - 1; - m_snd_1.swp_time = m_swp_time_table[ (data & 0x70) >> 4 ]; - break; - case NR11: /* Sound length/Wave pattern duty (R/W) */ - m_snd_1.duty = (data & 0xc0) >> 6; - m_snd_1.length = m_length_table[data & 0x3f]; - break; - case NR12: /* Envelope (R/W) */ - m_snd_1.env_value = data >> 4; - m_snd_1.env_direction = (data & 0x8) >> 3; - m_snd_1.env_direction |= m_snd_1.env_direction - 1; - m_snd_1.env_length = m_env_length_table[data & 0x7]; - break; - case NR13: /* Frequency lo (R/W) */ - m_snd_1.frequency = ((m_snd_regs[NR14] & 0x7) << 8) | m_snd_regs[NR13]; - m_snd_1.period = m_period_table[m_snd_1.frequency]; - break; - case NR14: /* Frequency hi / Initialize (R/W) */ - m_snd_1.mode = (data & 0x40) >> 6; - m_snd_1.frequency = ((m_snd_regs[NR14] & 0x7) << 8) | m_snd_regs[NR13]; - m_snd_1.period = m_period_table[m_snd_1.frequency]; - if (data & 0x80) - { - if (!m_snd_1.on) - m_snd_1.pos = 0; - m_snd_1.on = 1; - m_snd_1.count = 0; - m_snd_1.env_value = m_snd_regs[NR12] >> 4; - m_snd_1.env_count = 0; - m_snd_1.swp_count = 0; - m_snd_1.signal = 0x1; - m_snd_regs[NR52] |= 0x1; - } - break; - - /*MODE 2 */ - case NR21: /* Sound length/Wave pattern duty (R/W) */ - m_snd_2.duty = (data & 0xc0) >> 6; - m_snd_2.length = m_length_table[data & 0x3f]; - break; - case NR22: /* Envelope (R/W) */ - m_snd_2.env_value = data >> 4; - m_snd_2.env_direction = (data & 0x8) >> 3; - m_snd_2.env_direction |= m_snd_2.env_direction - 1; - m_snd_2.env_length = m_env_length_table[data & 0x7]; - break; - case NR23: /* Frequency lo (R/W) */ - m_snd_2.period = m_period_table[((m_snd_regs[NR24] & 0x7) << 8) | m_snd_regs[NR23]]; - break; - case NR24: /* Frequency hi / Initialize (R/W) */ - m_snd_2.mode = (data & 0x40) >> 6; - m_snd_2.period = m_period_table[((m_snd_regs[NR24] & 0x7) << 8) | m_snd_regs[NR23]]; - if (data & 0x80) - { - if (!m_snd_2.on) - m_snd_2.pos = 0; - m_snd_2.on = 1; - m_snd_2.count = 0; - m_snd_2.env_value = m_snd_regs[NR22] >> 4; - m_snd_2.env_count = 0; - m_snd_2.signal = 0x1; - m_snd_regs[NR52] |= 0x2; - } - break; - - /*MODE 3 */ - case NR30: /* Sound On/Off (R/W) */ - m_snd_3.on = (data & 0x80) >> 7; - break; - case NR31: /* Sound Length (R/W) */ - m_snd_3.length = m_length_mode3_table[data]; - break; - case NR32: /* Select Output Level */ - m_snd_3.level = (data & 0x60) >> 5; - break; - case NR33: /* Frequency lo (W) */ - m_snd_3.period = m_period_mode3_table[((m_snd_regs[NR34] & 0x7) << 8) + m_snd_regs[NR33]]; - break; - case NR34: /* Frequency hi / Initialize (W) */ - m_snd_3.mode = (data & 0x40) >> 6; - m_snd_3.period = m_period_mode3_table[((m_snd_regs[NR34] & 0x7) << 8) + m_snd_regs[NR33]]; - if (data & 0x80) - { - if (!m_snd_3.on) - { - m_snd_3.pos = 0; - m_snd_3.offset = 0; - m_snd_3.duty = 0; - } - m_snd_3.on = 1; - m_snd_3.count = 0; - m_snd_3.duty = 1; - m_snd_3.dutycount = 0; - m_snd_regs[NR52] |= 0x4; - } - break; - - /*MODE 4 */ - case NR41: /* Sound Length (R/W) */ - m_snd_4.length = m_length_table[data & 0x3f]; - break; - case NR42: /* Envelope (R/W) */ - m_snd_4.env_value = data >> 4; - m_snd_4.env_direction = (data & 0x8) >> 3; - m_snd_4.env_direction |= m_snd_4.env_direction - 1; - m_snd_4.env_length = m_env_length_table[data & 0x7]; - break; - case NR43: /* Polynomial Counter/Frequency */ - m_snd_4.period = m_period_mode4_table[data & 0x7][(data & 0xF0) >> 4]; - m_snd_4.ply_step = (data & 0x8) >> 3; - break; - case NR44: /* Counter/Consecutive / Initialize (R/W) */ - m_snd_4.mode = (data & 0x40) >> 6; - if (data & 0x80) - { - if (!m_snd_4.on) - m_snd_4.pos = 0; - m_snd_4.on = 1; - m_snd_4.count = 0; - m_snd_4.env_value = m_snd_regs[NR42] >> 4; - m_snd_4.env_count = 0; - m_snd_4.signal = machine().rand(); - m_snd_4.ply_value = 0x7fff; - m_snd_regs[NR52] |= 0x8; - } - break; - - /* CONTROL */ - case NR50: /* Channel Control / On/Off / Volume (R/W) */ - m_snd_control.vol_left = data & 0x7; - m_snd_control.vol_right = (data & 0x70) >> 4; - break; - case NR51: /* Selection of Sound Output Terminal */ - m_snd_control.mode1_right = data & 0x1; - m_snd_control.mode1_left = (data & 0x10) >> 4; - m_snd_control.mode2_right = (data & 0x2) >> 1; - m_snd_control.mode2_left = (data & 0x20) >> 5; - m_snd_control.mode3_right = (data & 0x4) >> 2; - m_snd_control.mode3_left = (data & 0x40) >> 6; - m_snd_control.mode4_right = (data & 0x8) >> 3; - m_snd_control.mode4_left = (data & 0x80) >> 7; - break; - case NR52: /* Sound On/Off (R/W) */ - /* Only bit 7 is writable, writing to bits 0-3 does NOT enable or - disable sound. They are read-only */ - m_snd_control.on = (data & 0x80) >> 7; - if (!m_snd_control.on) - { - sound_w_internal(NR10, 0x80); - sound_w_internal(NR11, 0xBF); - sound_w_internal(NR12, 0xF3); - sound_w_internal(NR13, 0xFF); - sound_w_internal(NR14, 0xBF); - //sound_w_internal(NR20, 0xFF); - sound_w_internal(NR21, 0x3F); - sound_w_internal(NR22, 0x00); - sound_w_internal(NR23, 0xFF); - sound_w_internal(NR24, 0xBF); - sound_w_internal(NR30, 0x7F); - sound_w_internal(NR31, 0xFF); - sound_w_internal(NR32, 0x9F); - sound_w_internal(NR33, 0xFF); - sound_w_internal(NR34, 0xBF); - //sound_w_internal(NR40, 0xFF); - sound_w_internal(NR41, 0xFF); - sound_w_internal(NR42, 0x00); - sound_w_internal(NR43, 0x00); - sound_w_internal(NR44, 0xBF); - sound_w_internal(NR50, 0x77); - sound_w_internal(NR51, 0xF3); - m_snd_1.on = 0; - m_snd_2.on = 0; - m_snd_3.on = 0; - m_snd_4.on = 0; - m_snd_regs[offset] = 0; - } - break; - } -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void gameboy_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t sample, left, right, mode4_mask; - - while (samples-- > 0) - { - left = right = 0; - - /* Mode 1 - Wave with Envelope and Sweep */ - if (m_snd_1.on) - { - sample = m_snd_1.signal * m_snd_1.env_value; - m_snd_1.pos++; - if (m_snd_1.pos == (UINT32)(m_snd_1.period / wave_duty_table[m_snd_1.duty]) >> FIXED_POINT) - { - m_snd_1.signal = -m_snd_1.signal; - } - else if (m_snd_1.pos > (m_snd_1.period >> FIXED_POINT)) - { - m_snd_1.pos = 0; - m_snd_1.signal = -m_snd_1.signal; - } - - if (m_snd_1.length && m_snd_1.mode) - { - m_snd_1.count++; - if (m_snd_1.count >= m_snd_1.length) - { - m_snd_1.on = 0; - m_snd_regs[NR52] &= 0xFE; - } - } - - if (m_snd_1.env_length) - { - m_snd_1.env_count++; - if (m_snd_1.env_count >= m_snd_1.env_length) - { - m_snd_1.env_count = 0; - m_snd_1.env_value += m_snd_1.env_direction; - if (m_snd_1.env_value < 0) - m_snd_1.env_value = 0; - if (m_snd_1.env_value > 15) - m_snd_1.env_value = 15; - } - } - - if (m_snd_1.swp_time) - { - m_snd_1.swp_count++; - if (m_snd_1.swp_count >= m_snd_1.swp_time) - { - m_snd_1.swp_count = 0; - if (m_snd_1.swp_direction > 0) - { - m_snd_1.frequency -= m_snd_1.frequency / (1 << m_snd_1.swp_shift); - if (m_snd_1.frequency <= 0) - { - m_snd_1.on = 0; - m_snd_regs[NR52] &= 0xFE; - } - } - else - { - m_snd_1.frequency += m_snd_1.frequency / (1 << m_snd_1.swp_shift); - if (m_snd_1.frequency >= MAX_FREQUENCIES) - { - m_snd_1.frequency = MAX_FREQUENCIES - 1; - } - } - - m_snd_1.period = m_period_table[m_snd_1.frequency]; - } - } - - if (m_snd_control.mode1_left) - left += sample; - if (m_snd_control.mode1_right) - right += sample; - } - - /* Mode 2 - Wave with Envelope */ - if (m_snd_2.on) - { - sample = m_snd_2.signal * m_snd_2.env_value; - m_snd_2.pos++; - if( m_snd_2.pos == (UINT32)(m_snd_2.period / wave_duty_table[m_snd_2.duty]) >> FIXED_POINT) - { - m_snd_2.signal = -m_snd_2.signal; - } - else if (m_snd_2.pos > (m_snd_2.period >> FIXED_POINT)) - { - m_snd_2.pos = 0; - m_snd_2.signal = -m_snd_2.signal; - } - - if (m_snd_2.length && m_snd_2.mode) - { - m_snd_2.count++; - if (m_snd_2.count >= m_snd_2.length) - { - m_snd_2.on = 0; - m_snd_regs[NR52] &= 0xFD; - } - } - - if (m_snd_2.env_length) - { - m_snd_2.env_count++; - if (m_snd_2.env_count >= m_snd_2.env_length) - { - m_snd_2.env_count = 0; - m_snd_2.env_value += m_snd_2.env_direction; - if (m_snd_2.env_value < 0) - m_snd_2.env_value = 0; - if (m_snd_2.env_value > 15) - m_snd_2.env_value = 15; - } - } - - if (m_snd_control.mode2_left) - left += sample; - if (m_snd_control.mode2_right) - right += sample; - } - - /* Mode 3 - Wave patterns from WaveRAM */ - if (m_snd_3.on) - { - /* NOTE: This is extremely close, but not quite right. - The problem is for GB frequencies above 2000 the frequency gets - clipped. This is caused because m_snd_3.pos is never 0 at the test.*/ - sample = m_snd_regs[AUD3W0 + (m_snd_3.offset/2)]; - if (!(m_snd_3.offset % 2)) - { - sample >>= 4; - } - sample = (sample & 0xF) - 8; - - if (m_snd_3.level) - sample >>= (m_snd_3.level - 1); - else - sample = 0; - - m_snd_3.pos++; - if (m_snd_3.pos >= ((UINT32)(((m_snd_3.period) >> 21)) + m_snd_3.duty)) - { - m_snd_3.pos = 0; - if (m_snd_3.dutycount == ((UINT32)(((m_snd_3.period) >> FIXED_POINT)) % 32)) - { - m_snd_3.duty--; - } - m_snd_3.dutycount++; - m_snd_3.offset++; - if (m_snd_3.offset > 31) - { - m_snd_3.offset = 0; - m_snd_3.duty = 1; - m_snd_3.dutycount = 0; - } - } - - if (m_snd_3.length && m_snd_3.mode) - { - m_snd_3.count++; - if (m_snd_3.count >= m_snd_3.length) - { - m_snd_3.on = 0; - m_snd_regs[NR52] &= 0xFB; - } - } - - if (m_snd_control.mode3_left) - left += sample; - if (m_snd_control.mode3_right) - right += sample; - } - - /* Mode 4 - Noise with Envelope */ - if (m_snd_4.on) - { - /* Similar problem to Mode 3, we seem to miss some notes */ - sample = m_snd_4.signal & m_snd_4.env_value; - m_snd_4.pos++; - if (m_snd_4.pos == (m_snd_4.period >> (FIXED_POINT + 1))) - { - /* Using a Polynomial Counter (aka Linear Feedback Shift Register) - Mode 4 has a 7 bit and 15 bit counter so we need to shift the - bits around accordingly */ - mode4_mask = (((m_snd_4.ply_value & 0x2) >> 1) ^ (m_snd_4.ply_value & 0x1)) << (m_snd_4.ply_step ? 6 : 14); - m_snd_4.ply_value >>= 1; - m_snd_4.ply_value |= mode4_mask; - m_snd_4.ply_value &= (m_snd_4.ply_step ? 0x7f : 0x7fff); - m_snd_4.signal = (INT8)m_snd_4.ply_value; - } - else if (m_snd_4.pos > (m_snd_4.period >> FIXED_POINT)) - { - m_snd_4.pos = 0; - mode4_mask = (((m_snd_4.ply_value & 0x2) >> 1) ^ (m_snd_4.ply_value & 0x1)) << (m_snd_4.ply_step ? 6 : 14); - m_snd_4.ply_value >>= 1; - m_snd_4.ply_value |= mode4_mask; - m_snd_4.ply_value &= (m_snd_4.ply_step ? 0x7f : 0x7fff); - m_snd_4.signal = (INT8)m_snd_4.ply_value; - } - - if (m_snd_4.length && m_snd_4.mode) - { - m_snd_4.count++; - if (m_snd_4.count >= m_snd_4.length) - { - m_snd_4.on = 0; - m_snd_regs[NR52] &= 0xF7; - } - } - - if (m_snd_4.env_length) - { - m_snd_4.env_count++; - if (m_snd_4.env_count >= m_snd_4.env_length) - { - m_snd_4.env_count = 0; - m_snd_4.env_value += m_snd_4.env_direction; - if (m_snd_4.env_value < 0) - m_snd_4.env_value = 0; - if (m_snd_4.env_value > 15) - m_snd_4.env_value = 15; - } - } - - if (m_snd_control.mode4_left) - left += sample; - if (m_snd_control.mode4_right) - right += sample; - } - - /* Adjust for master volume */ - left *= m_snd_control.vol_left; - right *= m_snd_control.vol_right; - - /* pump up the volume */ - left <<= 6; - right <<= 6; - - /* Update the buffers */ - *(outputs[0]++) = left; - *(outputs[1]++) = right; - } - - m_snd_regs[NR52] = (m_snd_regs[NR52]&0xf0) | m_snd_1.on | (m_snd_2.on << 1) | (m_snd_3.on << 2) | (m_snd_4.on << 3); - -} diff --git a/src/mess/audio/gb.h b/src/mess/audio/gb.h deleted file mode 100644 index c86cad02b76..00000000000 --- a/src/mess/audio/gb.h +++ /dev/null @@ -1,105 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Anthony Kruize -#ifndef __GBSOUND_H__ -#define __GBSOUND_H__ - - -#define MAX_FREQUENCIES 2048 - - -struct SOUND -{ - /* Common */ - UINT8 on; - UINT8 channel; - INT32 length; - INT32 pos; - UINT32 period; - INT32 count; - INT8 mode; - /* Mode 1, 2, 3 */ - INT8 duty; - /* Mode 1, 2, 4 */ - INT32 env_value; - INT8 env_direction; - INT32 env_length; - INT32 env_count; - INT8 signal; - /* Mode 1 */ - UINT32 frequency; - INT32 swp_shift; - INT32 swp_direction; - INT32 swp_time; - INT32 swp_count; - /* Mode 3 */ - INT8 level; - UINT8 offset; - UINT32 dutycount; - /* Mode 4 */ - INT32 ply_step; - INT16 ply_value; -}; - -struct SOUNDC -{ - UINT8 on; - UINT8 vol_left; - UINT8 vol_right; - UINT8 mode1_left; - UINT8 mode1_right; - UINT8 mode2_left; - UINT8 mode2_right; - UINT8 mode3_left; - UINT8 mode3_right; - UINT8 mode4_left; - UINT8 mode4_right; -}; - - -class gameboy_sound_device : public device_t, - public device_sound_interface -{ -public: - gameboy_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_READ8_MEMBER(sound_r); - DECLARE_READ8_MEMBER(wave_r); - DECLARE_WRITE8_MEMBER(sound_w); - DECLARE_WRITE8_MEMBER(wave_w); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - - virtual void device_reset(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -private: - void sound_w_internal(int offset, UINT8 data); - - sound_stream *m_channel; - int m_rate; - - INT32 m_env_length_table[8]; - INT32 m_swp_time_table[8]; - UINT32 m_period_table[MAX_FREQUENCIES]; - UINT32 m_period_mode3_table[MAX_FREQUENCIES]; - UINT32 m_period_mode4_table[8][16]; - UINT32 m_length_table[64]; - UINT32 m_length_mode3_table[256]; - - struct SOUND m_snd_1; - struct SOUND m_snd_2; - struct SOUND m_snd_3; - struct SOUND m_snd_4; - struct SOUNDC m_snd_control; - - UINT8 m_snd_regs[0x30]; -}; - -extern const device_type GAMEBOY; - -#endif diff --git a/src/mess/audio/lynx.c b/src/mess/audio/lynx.c deleted file mode 100644 index 2e17abde91f..00000000000 --- a/src/mess/audio/lynx.c +++ /dev/null @@ -1,540 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/****************************************************************************** - PeT mess@utanet.at 2000,2001 -******************************************************************************/ - -#include "emu.h" -#include "audio/lynx.h" - - -/* accordingly to atari's reference manual - there were no stereo lynx produced (the manual knows only production until mid 1991) - the howard/developement board might have stereo support - the revised lynx 2 hardware might have stereo support at least at the stereo jacks - - some games support stereo -*/ - - -/* -AUDIO_A EQU $FD20 -AUDIO_B EQU $FD28 -AUDIO_C EQU $FD30 -AUDIO_D EQU $FD38 - -VOLUME_CNTRL EQU 0 -FEEDBACK_ENABLE EQU 1 ; enables 11/10/5..0 -OUTPUT_VALUE EQU 2 -SHIFTER_L EQU 3 -AUD_BAKUP EQU 4 -AUD_CNTRL1 EQU 5 -AUD_COUNT EQU 6 -AUD_CNTRL2 EQU 7 - -; AUD_CNTRL1 -FEEDBACK_7 EQU %10000000 -AUD_RESETDONE EQU %01000000 -AUD_INTEGRATE EQU %00100000 -AUD_RELOAD EQU %00010000 -AUD_CNTEN EQU %00001000 -AUD_LINK EQU %00000111 -; link timers (0->2->4 / 1->3->5->7->Aud0->Aud1->Aud2->Aud3->1 -AUD_64us EQU %00000110 -AUD_32us EQU %00000101 -AUD_16us EQU %00000100 -AUD_8us EQU %00000011 -AUD_4us EQU %00000010 -AUD_2us EQU %00000001 -AUD_1us EQU %00000000 - -; AUD_CNTRL2 (read only) -; B7..B4 ; shifter bits 11..8 -; B3 ; who knows -; B2 ; last clock state (0->1 causes count) -; B1 ; borrow in (1 causes count) -; B0 ; borrow out (count EQU 0 and borrow in) - -ATTEN_A EQU $FD40 -ATTEN_B EQU $FD41 -ATTEN_C EQU $FD42 -ATTEN_D EQU $FD43 -; B7..B4 attenuation left ear (0 silent ..15/16 volume) -; B3..B0 " right ear - -MPAN EQU $FD44 -; B7..B4 left ear -; B3..B0 right ear -; B7/B3 EQU Audio D -; a 1 enables attenuation for channel and side - - -MSTEREO EQU $FD50 ; a 1 disables audio connection -AUD_D_LEFT EQU %10000000 -AUD_C_LEFT EQU %01000000 -AUD_B_LEFT EQU %00100000 -AUD_A_LEFT EQU %00010000 -AUD_D_RIGHT EQU %00001000 -AUD_C_RIGHT EQU %00000100 -AUD_B_RIGHT EQU %00000010 -AUD_A_RIGHT EQU %00000001 - - */ - -#define LYNX_AUDIO_CHANNELS 4 - - -// device type definition -const device_type LYNX_SND = &device_creator<lynx_sound_device>; -const device_type LYNX2_SND = &device_creator<lynx2_sound_device>; - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// lynx_sound_device - constructor -//------------------------------------------------- - -lynx_sound_device::lynx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, LYNX_SND, "Mikey", tag, owner, clock, "lynx_sound", __FILE__), - device_sound_interface(mconfig, *this) -{ - m_timer_delegate = lynx_sound_timer_delegate(); -} - -lynx_sound_device::lynx_sound_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) - : device_t(mconfig, type, name, tag, owner, clock, shortname, source), - device_sound_interface(mconfig, *this) -{ -} - - -lynx2_sound_device::lynx2_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : lynx_sound_device(mconfig, LYNX2_SND, "Mikey (Lynx II)", tag, owner, clock, "lynx2_sound", __FILE__) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void lynx_sound_device::set_timer_delegate(device_t &device, lynx_sound_timer_delegate cb) -{ - lynx_sound_device &dev = downcast<lynx_sound_device &>(device); - dev.m_timer_delegate = cb; -} - -void lynx_sound_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void lynx_sound_device::register_save() -{ - save_item(NAME(m_attenuation_enable)); - save_item(NAME(m_master_enable)); - for (int chan = 0; chan < LYNX_AUDIO_CHANNELS; chan++) - { - save_item(NAME(m_audio[chan].reg.volume), chan); - save_item(NAME(m_audio[chan].reg.feedback), chan); - save_item(NAME(m_audio[chan].reg.output), chan); - save_item(NAME(m_audio[chan].reg.shifter), chan); - save_item(NAME(m_audio[chan].reg.bakup), chan); - save_item(NAME(m_audio[chan].reg.control1), chan); - save_item(NAME(m_audio[chan].reg.counter), chan); - save_item(NAME(m_audio[chan].reg.control2), chan); - save_item(NAME(m_audio[chan].attenuation), chan); - save_item(NAME(m_audio[chan].mask), chan); - save_item(NAME(m_audio[chan].shifter), chan); - save_item(NAME(m_audio[chan].ticks), chan); - save_item(NAME(m_audio[chan].count), chan); - } -} - -void lynx_sound_device::init() -{ - m_shift_mask = auto_alloc_array_clear(machine(), int, 512); - m_shift_xor = auto_alloc_array_clear(machine(), int, 4096); - - for (int i = 0; i < 512; i++) - { - m_shift_mask[i] = 0; - if (i & 1) m_shift_mask[i] |= 1; - if (i & 2) m_shift_mask[i] |= 2; - if (i & 4) m_shift_mask[i] |= 4; - if (i & 8) m_shift_mask[i] |= 8; - if (i & 0x10) m_shift_mask[i] |= 0x10; - if (i & 0x20) m_shift_mask[i] |= 0x20; - if (i & 0x40) m_shift_mask[i] |= 0x400; - if (i & 0x80) m_shift_mask[i] |= 0x800; - if (i & 0x100) m_shift_mask[i] |= 0x80; - } - - for (int i = 0; i < 4096; i++) - { - m_shift_xor[i] = 1; - for (int j = 4096/2; j > 0; j >>= 1) - { - if (i & j) - m_shift_xor[i] ^= 1; - } - } -} - -void lynx_sound_device::device_start() -{ - m_mixer_channel = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate()); - m_usec_per_sample = 1000000 / machine().sample_rate(); - m_timer_delegate.bind_relative_to(*owner()); - init(); - register_save(); -} - - -void lynx2_sound_device::device_start() -{ - m_mixer_channel = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate()); - m_usec_per_sample = 1000000 / machine().sample_rate(); - m_timer_delegate.bind_relative_to(*owner()); - init(); - register_save(); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void lynx_sound_device::device_reset() -{ - for (int i = 0; i < LYNX_AUDIO_CHANNELS; i++) - { - reset_channel(&m_audio[i]); - } -} - - -void lynx_sound_device::reset_channel(LYNX_AUDIO *channel) -{ - channel->reg.volume = 0; - channel->reg.feedback = 0; - channel->reg.output = 0; - channel->reg.shifter = 0; - channel->reg.bakup = 0; - channel->reg.control1 = 0; - channel->reg.counter = 0; - channel->reg.control2 = 0; - - channel->attenuation = 0; - channel->mask = 0; - channel->shifter = 0; - channel->ticks = 0; - channel->count = 0; -} - -void lynx_sound_device::count_down(int nr) -{ - LYNX_AUDIO *channel = &m_audio[nr]; - if (channel->reg.control1 & 8 && (channel->reg.control1 & 7) != 7) - return; - if (nr == 0) - m_mixer_channel->update(); - //if ((channel->reg.control1 & 0x0f) == 0x0f) //count down if linking enabled and count enabled - channel->count--; -} - -void lynx_sound_device::shift(int chan_nr) -{ - INT16 out_temp; - LYNX_AUDIO *channel; - - assert(chan_nr < 4); - - channel = &m_audio[chan_nr]; - //channel->shifter = ((channel->shifter<<1)&0xffe) | (m_shift_xor[ channel->shifter & channel->mask ]&1); - - // alternative method (functionally the same as above) - UINT8 xor_out = 0; - for (int bit = 0; bit < 12; bit++) - { - if ((channel->mask >> bit) & 1) - xor_out ^= (channel->shifter >> bit) & 1; - } - channel->shifter = ((channel->shifter << 1) & 0xffe) | (xor_out ^ 1); // output of xor is inverted - - - if (channel->reg.control1 & 0x20) // integrate mode enabled - { - if (channel->shifter & 1) - out_temp = channel->reg.output + channel->reg.volume; - else - out_temp = channel->reg.output - channel->reg.volume; - - // clipping - if (out_temp > 127) out_temp = 127; - if (out_temp < -128) out_temp = -128; - channel->reg.output = (INT16)out_temp; - } - - switch (chan_nr) - { - case 0: count_down(1); break; - case 1: count_down(2); break; - case 2: count_down(3); break; - case 3: - if (!m_timer_delegate.isnull()) - m_timer_delegate(); - break; - } -} - -void lynx_sound_device::execute(int chan_nr) -{ - LYNX_AUDIO *channel; - - assert(chan_nr < 4); - - channel = &m_audio[chan_nr]; - - if (channel->reg.control1 & 8) // count enable - { - channel->ticks += m_usec_per_sample; - if ((channel->reg.control1 & 7) == 7) // link - { - if (channel->count < 0) // counter finished - { - //channel->count+=channel->reg.counter; // reload (wrong?) - if (channel->reg.control1 & 0x10) - channel->count = channel->reg.bakup; - shift(chan_nr); - } - } - else - { - int t = 1 << (channel->reg.control1 & 7); // microseconds per count - for (;;) - { - for (; (channel->ticks >= t) && (channel->count >= 0); channel->ticks -= t) // at least one sampled worth of time left, timer not expired - channel->count--; - - if (channel->ticks < t) - break; - - if (channel->count < 0) - { - shift(chan_nr); - if (channel->reg.control1 & 0x10) - channel->count = channel->reg.bakup; - else - break; - } - } - } - - if (!(channel->reg.control1 & 0x20)) // normal mode - { - channel->reg.output = (channel->shifter & 1) ? channel->reg.volume : -channel->reg.volume; - } - } - else - { - channel->ticks = 0; - channel->count = 0; - } -} - -READ8_MEMBER(lynx_sound_device::read) -{ - UINT8 value = 0; - LYNX_AUDIO *channel = &m_audio[(offset >> 3) & 3]; - - m_mixer_channel->update(); - - if (offset < 0x40) - { - switch (offset & 7) - { - case 0: - value = channel->reg.volume; - break; - case 1: - value = channel->reg.feedback; - break; - case 2: - value = channel->reg.output; - break; - case 3: - // current shifter state (lower 8 bits) - value = channel->shifter & 0xff; - break; - case 4: - value = channel->reg.bakup; - break; - case 5: - value = channel->reg.control1; - break; - case 6: - //current timer value - if (channel->count >=0) - value = channel->count; - else - value = 0; - break; - case 7: - // current shifter state (upper 4 bits), status bits - value = (channel->shifter >> 4) & 0xf0; - value |= channel->reg.control2 & 0x0f; - break; - } - } - else - { - switch (offset) // Lynx II stereo control registers - { - case 0x40: case 0x41: case 0x42: case 0x43: - value = m_audio[offset & 3].attenuation; - break; - case 0x44: - value = m_attenuation_enable; - break; - case 0x50: - value = m_master_enable; - break; - } - - } - return value; -} - -WRITE8_MEMBER(lynx_sound_device::write) -{ - //logerror("audio write %.2x %.2x\n", offset, data); - LYNX_AUDIO *channel = &m_audio[(offset >> 3) & 3]; - - m_mixer_channel->update(); - - if (offset < 0x40) - { - switch (offset & 0x07) - { - // Volume control (signed) - case 0: - channel->reg.volume = data; - //logerror("write to volume %d\n", data); - break; - // Shift register feedback enable bits 0-5, 11,10 - case 1: - channel->reg.feedback = data; - channel->mask &= 0x80; - channel->mask |= (data & 0x3f) | ((data & 0xc0)<<4); - break; - // Output value - case 2: - channel->reg.output = data; - //logerror("write to output %d\n", data); - break; - // Lower 8 bits of shift register - case 3: - channel->shifter &= 0xf00; - channel->shifter |= data; - break; - // Audio timer backup value - case 4: - channel->reg.bakup = data; - break; - // Audio control bits - case 5: - channel->mask &= ~0x80; - channel->mask |= (data&0x80); - channel->reg.control1 = data; - break; - // Current count - case 6: - channel->count=data; - break; - // Upper 4 bits of shift register and audio status bits - case 7: - channel->shifter&=0xff; - channel->shifter|=(data&0xf0)<<4; - channel->reg.control2 = data; - break; - } - } - else - { - switch (offset) // Stereo Registers - { - case 0x40: case 0x41: case 0x42: case 0x43: - m_audio[offset&3].attenuation = data; - break; - case 0x44: - m_attenuation_enable = data; - break; - case 0x50: - m_master_enable = data; - break; - } - } -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void lynx_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - int v; - stream_sample_t *buffer = outputs[0]; - - for (int i = 0; i < samples; i++, buffer++) - { - *buffer = 0; - for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++) - { - execute(channel); - v = m_audio[channel].reg.output; - *buffer += v * 15; // where does the *15 come from? - } - } -} - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void lynx2_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *left=outputs[0], *right=outputs[1]; - int v; - - for (int i = 0; i < samples; i++, left++, right++) - { - *left = 0; - *right= 0; - for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++) - { - execute(channel); - v = m_audio[channel].reg.output; - if (!(m_master_enable & (0x10 << channel))) - { - if (m_attenuation_enable & (0x10 << channel)) - *left += v * (m_audio[channel].attenuation >> 4); - else - *left += v * 15; - } - if (!(m_master_enable & (1 << channel))) - { - if (m_attenuation_enable & (1 << channel)) - *right += v * (m_audio[channel].attenuation & 0xf); - else - *right += v * 15; - } - } - } -} diff --git a/src/mess/audio/lynx.h b/src/mess/audio/lynx.h deleted file mode 100644 index b99d2b04873..00000000000 --- a/src/mess/audio/lynx.h +++ /dev/null @@ -1,90 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner - -#ifndef __LYNXSOUND_H__ -#define __LYNXSOUND_H__ - -struct LYNX_AUDIO { - struct { - INT8 volume; - UINT8 feedback; - INT8 output; - UINT8 shifter; - UINT8 bakup; - UINT8 control1; - UINT8 counter; - UINT8 control2; - } reg; - UINT8 attenuation; - UINT16 mask; // 12-bit - UINT16 shifter; // 12-bit - float ticks; - int count; -}; - -typedef device_delegate<void (void)> lynx_sound_timer_delegate; - - -class lynx_sound_device : public device_t, - public device_sound_interface -{ -public: - lynx_sound_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); - lynx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_READ8_MEMBER(read); - DECLARE_WRITE8_MEMBER(write); - void count_down(int nr); - static void set_timer_delegate(device_t &device, lynx_sound_timer_delegate cb); - -protected: - // device-level overrides - virtual void device_config_complete(); - virtual void device_start(); - - virtual void device_reset(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - - void reset_channel(LYNX_AUDIO *channel); - void shift(int chan_nr); - void execute(int chan_nr); - void init(); - void register_save(); - - sound_stream *m_mixer_channel; - lynx_sound_timer_delegate m_timer_delegate; // this calls lynx_timer_count_down from the driver state - - float m_usec_per_sample; - int *m_shift_mask; - int *m_shift_xor; - UINT8 m_attenuation_enable; - UINT8 m_master_enable; - LYNX_AUDIO m_audio[4]; -}; - - -class lynx2_sound_device : public lynx_sound_device -{ -public: - lynx2_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - -protected: - // device-level overrides - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); -}; - - -extern const device_type LYNX_SND; -extern const device_type LYNX2_SND; - - -#define MCFG_LYNX_SND_SET_TIMER( _class, _method) \ - lynx_sound_device::set_timer_delegate(*device, lynx_sound_timer_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0)); - - -#endif diff --git a/src/mess/audio/mac.c b/src/mess/audio/mac.c deleted file mode 100644 index 7a0b7a93a62..00000000000 --- a/src/mess/audio/mac.c +++ /dev/null @@ -1,174 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont -/*************************************************************************** - - mac.c - - Sound handler - -****************************************************************************/ - - -#include "emu.h" -#include "sound/asc.h" -#include "includes/mac.h" -#include "machine/ram.h" - -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ - -#define MAC_MAIN_SND_BUF_OFFSET 0x0300 -#define MAC_ALT_SND_BUF_OFFSET 0x5F00 -#define MAC_SND_BUF_SIZE 370 /* total number of scan lines */ -#define MAC_SAMPLE_RATE ( MAC_SND_BUF_SIZE * 60 /*22255*/ ) /* scan line rate, should be 22254.5 Hz */ - - -/* intermediate buffer */ -#define SND_CACHE_SIZE 128 - - - - -const device_type MAC_SOUND = &device_creator<mac_sound_device>; - -mac_sound_device::mac_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, MAC_SOUND, "Mac Audio Custom", tag, owner, clock, "mac_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_sample_enable(0), - m_mac_snd_buf_ptr(NULL), - m_snd_cache_len(0), - m_snd_cache_head(0), - m_snd_cache_tail(0), - m_indexx(0) -{ -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void mac_sound_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void mac_sound_device::device_start() -{ - mac_state *mac = machine().driver_data<mac_state>(); - - m_snd_cache = auto_alloc_array_clear(machine(), UINT8, SND_CACHE_SIZE); - m_mac_stream = machine().sound().stream_alloc(*this, 0, 1, MAC_SAMPLE_RATE); - - m_ram = machine().device<ram_device>(RAM_TAG); - m_mac_model = mac->m_model; - - save_pointer(NAME(m_snd_cache), SND_CACHE_SIZE); - save_item(NAME(m_sample_enable)); - save_item(NAME(m_snd_cache_len)); - save_item(NAME(m_snd_cache_head)); - save_item(NAME(m_snd_cache_tail)); - save_item(NAME(m_indexx)); -} - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void mac_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - INT16 last_val = 0; - stream_sample_t *buffer = outputs[0]; - - if ((m_mac_model == MODEL_MAC_PORTABLE) || (m_mac_model == MODEL_MAC_PB100)) - { - memset(buffer, 0, samples * sizeof(*buffer)); - return; - } - - /* if we're not enabled, just fill with 0 */ - if (machine().sample_rate() == 0) - { - memset(buffer, 0, samples * sizeof(*buffer)); - return; - } - - /* fill in the sample */ - while (samples && m_snd_cache_len) - { - *buffer++ = last_val = ((m_snd_cache[m_snd_cache_head] << 8) ^ 0x8000) & 0xff00; - m_snd_cache_head++; - m_snd_cache_head %= SND_CACHE_SIZE; - m_snd_cache_len--; - samples--; - } - - while (samples--) - { - /* should never happen */ - *buffer++ = last_val; - } -} - - -/*************************************************************************** - IMPLEMENTATION -***************************************************************************/ - - -// Set the sound enable flag (VIA port line) -void mac_sound_device::enable_sound(int on) -{ - m_sample_enable = on; -} - - -// Set the current sound buffer (one VIA port line) -void mac_sound_device::set_sound_buffer(int buffer) -{ - if (buffer) - m_mac_snd_buf_ptr = (UINT16 *) (m_ram->pointer() + m_ram->size() - MAC_MAIN_SND_BUF_OFFSET); - else - m_mac_snd_buf_ptr = (UINT16 *) (m_ram->pointer() + m_ram->size() - MAC_ALT_SND_BUF_OFFSET); -} - - - -// Set the current sound volume (3 VIA port line) -void mac_sound_device::set_volume(int volume) -{ - m_mac_stream->update(); - volume = (100 / 7) * volume; - m_mac_stream->set_output_gain(0, volume / 100.0); -} - - - -// Fetch one byte from sound buffer and put it to sound output (called every scanline) -void mac_sound_device::sh_updatebuffer() -{ - UINT16 *base = m_mac_snd_buf_ptr; - - m_indexx++; - m_indexx %= 370; - - if (m_snd_cache_len >= SND_CACHE_SIZE) - { - /* clear buffer */ - m_mac_stream->update(); - } - - if (m_snd_cache_len >= SND_CACHE_SIZE) - /* should never happen */ - return; - - m_snd_cache[m_snd_cache_tail] = m_sample_enable ? (base[m_indexx] >> 8) & 0xff : 0; - m_snd_cache_tail++; - m_snd_cache_tail %= SND_CACHE_SIZE; - m_snd_cache_len++; -} diff --git a/src/mess/audio/mea8000.c b/src/mess/audio/mea8000.c deleted file mode 100644 index 6936205b79f..00000000000 --- a/src/mess/audio/mea8000.c +++ /dev/null @@ -1,585 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Antoine Mine -/********************************************************************** - - Copyright (C) Antoine Mine' 2006 - - Philips / Signetics MEA 8000 emulation. - - The MEA 8000 is a speech synthesis chip. - The French company TMPI (Techni-musique & parole informatique) provided - speech extensions for several 8-bit computers (Thomson, Amstrad, Oric). - It was quite popular in France because of its ability to spell 'u' - (unlike the more widespread SPO 296 chip). - - The synthesis is based on a 4-formant model. - First, an initial sawtooth noise signal is generated. - The signal passes through a cascade of 4 filters of increasing frequency. - Each filter is a second order digital filter with a programmable - frequency and bandwidth. - All parameters, including filter parameters, are smoothly interpolated - for the duration of a frame (8ms, 16ms, 32ms, or 64 ms). - - TODO: - - REQ output pin - - optimize mea8000_compute_sample - - should we accept new frames in slow-stop mode ? - -**********************************************************************/ - -#include <math.h> - -#include "emu.h" -#include "mea8000.h" - - -#define VERBOSE 0 - -/* define to use double instead of int (slow but useful for debugging) */ -#undef FLOAT_MODE - - -/******************* utilitiy function and macros ********************/ - - -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - -/* digital filters work at 8 kHz */ -#define F0 8096 - -/* filtered output is supersampled x 8 */ -#define SUPERSAMPLING 8 - -/* actual output pediod */ -#define SAMPLING attotime::from_hz((SUPERSAMPLING*F0)) - - - -/************************* quantization tables ***********************/ - - - -/* frequency, in Hz */ - -static const int fm1_table[32] = -{ - 150, 162, 174, 188, 202, 217, 233, 250, - 267, 286, 305, 325, 346, 368, 391, 415, - 440, 466, 494, 523, 554, 587, 622, 659, - 698, 740, 784, 830, 880, 932, 988, 1047 -}; - -static const int fm2_table[32] = -{ - 440, 466, 494, 523, 554, 587, 622, 659, - 698, 740, 784, 830, 880, 932, 988, 1047, - 1100, 1179, 1254, 1337, 1428, 1528, 1639, 1761, - 1897, 2047, 2214, 2400, 2609, 2842, 3105, 3400 -}; - -static const int fm3_table[8] = -{ - 1179, 1337, 1528, 1761, 2047, 2400, 2842, 3400 -}; - -static const int fm4_table[1] = { 3500 }; - - - -/* bandwidth, in Hz */ -static const int bw_table[4] = { 726, 309, 125, 50 }; - - - -/* amplitude * 1000 */ -static const int ampl_table[16] = -{ - 0, 8, 11, 16, 22, 31, 44, 62, - 88, 125, 177, 250, 354, 500, 707, 1000 -}; - - - -/* pitch increment, in Hz / 8 ms */ -static const int pi_table[32] = -{ - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 0 /* noise */, -15, -14, -13, -12, -11, -10, -9, - -8, -7, -6, -5, -4, -3, -2, -1 -}; - - - -const device_type MEA8000 = &device_creator<mea8000_device>; - - -mea8000_device::mea8000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, MEA8000, "Philips / Signetics MEA 8000 speech synthesizer", tag, owner, clock, "mea8000", __FILE__), - m_write_req(*this), - m_dac(*this) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void mea8000_device::device_start() -{ - m_write_req.resolve_safe(); - - init_tables(); - - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(mea8000_device::timer_expire),this)); - - save_item(NAME(m_state)); - save_item(NAME(m_buf)); - save_item(NAME(m_bufpos)); - save_item(NAME(m_cont)); - save_item(NAME(m_roe)); - save_item(NAME(m_framelength)); - save_item(NAME(m_framepos)); - save_item(NAME(m_framelog)); - save_item(NAME(m_lastsample)); - save_item(NAME(m_sample)); - save_item(NAME(m_phi)); - for (int i = 0; i < 4; i++) - { - save_item(NAME(m_f[i].fm), i); - save_item(NAME(m_f[i].last_fm), i); - save_item(NAME(m_f[i].bw), i); - save_item(NAME(m_f[i].last_bw), i); - save_item(NAME(m_f[i].output), i); - save_item(NAME(m_f[i].last_output), i); - } - save_item(NAME(m_last_ampl)); - save_item(NAME(m_ampl)); - save_item(NAME(m_last_pitch)); - save_item(NAME(m_pitch)); - save_item(NAME(m_noise)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void mea8000_device::device_reset() -{ - LOG(("mea8000_reset\n")); - m_timer->reset(); - m_phi = 0; - m_cont = 0; - m_roe = 0; - m_state = MEA8000_STOPPED; - update_req(); - for (int i = 0; i < 4; i++) - { - m_f[i].last_output = 0; - m_f[i].output = 0; - } -} - - - -/***************************** REQ **********************************/ - - -int mea8000_device::accept_byte() -{ - return m_state == MEA8000_STOPPED || m_state == MEA8000_WAIT_FIRST || (m_state == MEA8000_STARTED && m_bufpos < 4); -} - -void mea8000_device::update_req() -{ - // actually, req pulses less than 3us for each new byte, - // it goes back up if there space left in the buffer, or stays low if the - // buffer contains a complete frame and the CPU nees to wait for the next - // frame end to compose a new frame. - m_write_req(accept_byte()); -} - - - -/*********************** sound generation ***************************/ - - -/* precompute tables */ -void mea8000_device::init_tables() -{ - for (int i = 0; i < TABLE_LEN; i++) - { - double f = (double)i / F0; - m_cos_table[i] = 2. * cos(2. * M_PI * f) * QUANT; - m_exp_table[i] = exp(-M_PI * f) * QUANT; - m_exp2_table[i] = exp(-2 * M_PI * f) * QUANT; - } - for (int i = 0; i < NOISE_LEN; i++) - m_noise_table[i] = (machine().rand() % (2 * QUANT)) - QUANT; -} - - -#ifndef FLOAT_MODE /* UINT16 version */ - - - -/* linear interpolation */ -int mea8000_device::interp( UINT16 org, UINT16 dst ) -{ - return org + (((dst - org) * m_framepos) >> m_framelog); -} - - -/* apply second order digital filter, sampling at F0 */ -int mea8000_device::filter_step( int i, int input ) -{ - /* frequency */ - int fm = interp(m_f[i].last_fm, m_f[i].fm); - /* bandwidth */ - int bw = interp(m_f[i].last_bw, m_f[i].bw); - /* filter coefficients */ - int b = (m_cos_table[fm] * m_exp_table[bw]) / QUANT; - int c = m_exp2_table[bw]; - /* transfer function */ - int next_output = input + (b * m_f[i].output - c * m_f[i].last_output) / QUANT; - m_f[i].last_output = m_f[i].output; - m_f[i].output = next_output; - return next_output; -} - - -/* random waveform, in [-QUANT,QUANT] */ -int mea8000_device::noise_gen() -{ - m_phi = (m_phi + 1) % NOISE_LEN; - return m_noise_table[m_phi]; -} - - -/* sawtooth waveform at F0, in [-QUANT,QUANT] */ -int mea8000_device::freq_gen() -{ - int pitch = interp(m_last_pitch, m_pitch); - m_phi = (m_phi + pitch) % F0; - return ((m_phi % F0) * QUANT * 2) / F0 - QUANT; -} - - -/* sample in [-32768,32767], at F0 */ -int mea8000_device::compute_sample() -{ - int out; - int ampl = interp(m_last_ampl, m_ampl); - - if (m_noise) - out = noise_gen(); - else - out = freq_gen(); - - out *= ampl / 32; - - for (int i = 0; i < 4; i++) - out = filter_step(i, out); - - if (out > 32767) - out = 32767; - if (out < -32767) - out = -32767; - return out; -} - - - -#else /* float version */ - - - -/* linear interpolation */ -double mea8000_device::interp(double org, double dst) -{ - return org + ((dst - org) * m_framepos) / m_framelength; -} - - -/* apply second order digital filter, sampling at F0 */ -double mea8000_device::filter_step(int i, double input) -{ - double fm = interp(m_f[i].last_fm, m_f[i].fm); - double bw = interp(m_f[i].last_bw, m_f[i].bw); - double b = 2. * cos(2. * M_PI * fm / F0); - double c = -exp(-M_PI * bw / F0); - double next_output = input - c * (b * m_f[i].output + c * m_f[i].last_output); - m_f[i].last_output = m_f[i].output; - m_f[i].output = next_output; - return next_output; -} - - -/* noise, in [-1,1] */ -double mea8000_device::noise_gen() -{ - m_phi++; - return (double) m_noise_table[m_phi % NOISE_LEN] / QUANT; -} - - - -/* sawtooth waveform at F0, in [-1,1] */ -double mea8000_device::freq_gen() -{ - int pitch = interp(m_last_pitch, m_pitch); - m_phi += pitch; - return (double) (m_phi % F0) / (F0 / 2.) - 1.; -} - - -/* sample in [-32767,32767], at F0 */ -int mea8000_device::compute_sample() -{ - double out; - double ampl = interp(8. * m_last_ampl, 8. * m_ampl); - - if (m_noise) - out = noise_gen(); - else - out = freq_gen(); - - out *= ampl; - - for (int i = 0; i < 4; i++) - { - out = filter_step(i, out); - } - - if (out > 32767) - out = 32767; - if (out < -32767) - out = -32767; - return out; -} - - -#endif - - -/*********************** frame management ***************************/ - - - -/* shift frame parameters from current to last */ -void mea8000_device::shift_frame() -{ - m_last_pitch = m_pitch; - for (int i = 0; i < 4; i++) - { - m_f[i].last_bw = m_f[i].bw; - m_f[i].last_fm = m_f[i].fm; - } - m_last_ampl = m_ampl; -} - - - -/* decode fields from buffer to current frame */ -void mea8000_device::decode_frame() -{ - int fd = (m_buf[3] >> 5) & 3; /* 0=8ms, 1=16ms, 2=32ms, 3=64ms */ - int pi = pi_table[m_buf[3] & 0x1f] << fd; - m_noise = (m_buf[3] & 0x1f) == 16; - m_pitch = m_last_pitch + pi; - m_f[0].bw = bw_table[m_buf[0] >> 6]; - m_f[1].bw = bw_table[(m_buf[0] >> 4) & 3]; - m_f[2].bw = bw_table[(m_buf[0] >> 2) & 3]; - m_f[3].bw = bw_table[m_buf[0] & 3]; - m_f[3].fm = fm4_table[0]; - m_f[2].fm = fm3_table[m_buf[1] >> 5]; - m_f[1].fm = fm2_table[m_buf[1] & 0x1f]; - m_f[0].fm = fm1_table[m_buf[2] >> 3]; - m_ampl = ampl_table[((m_buf[2] & 7) << 1) | (m_buf[3] >> 7)]; - m_framelog = fd + 6 /* 64 samples / ms */ + 3; - m_framelength = 1 << m_framelog; - m_bufpos = 0; -#ifdef FLOAT_MODE - LOG(("mea800_decode_frame: pitch=%i noise=%i fm1=%gHz bw1=%gHz fm2=%gHz bw2=%gHz fm3=%gHz bw3=%gHz fm4=%gHz bw4=%gHz ampl=%g fd=%ims\n", - m_pitch, m_noise, - m_f[0].fm, m_f[0].bw, m_f[1].fm, m_f[1].bw, - m_f[2].fm, m_f[2].bw, m_f[3].fm, m_f[3].bw, - m_ampl/1000., 8 << fd)); -#else - LOG(("mea800_decode_frame: pitch=%i noise=%i fm1=%iHz bw1=%iHz fm2=%iHz bw2=%iHz fm3=%iHz bw3=%iHz fm4=%iHz bw4=%iHz ampl=%g fd=%ims\n", - m_pitch, m_noise, - m_f[0].fm, m_f[0].bw, m_f[1].fm, m_f[1].bw, - m_f[2].fm, m_f[2].bw, m_f[3].fm, m_f[3].bw, - m_ampl/1000., 8 << fd)); -#endif -} - - - -void mea8000_device::start_frame() -{ - /* enter or stay in active mode */ - m_timer->reset(SAMPLING); - m_framepos = 0; -} - - - -void mea8000_device::stop_frame() -{ - /* enter stop mode */ - m_timer->reset(); - m_state = MEA8000_STOPPED; - m_dac->write_signed16(0x8000); -} - - - -/* next sample in frame, sampling at 64 kHz */ -TIMER_CALLBACK_MEMBER( mea8000_device::timer_expire ) -{ - int pos = m_framepos % SUPERSAMPLING; - - if (!pos) - { - /* sample is really computed only every 8-th time */ - m_lastsample = m_sample; - m_sample = compute_sample(); - m_dac->write_signed16(0x8000 + m_lastsample); - } - else - { - /* other samples are simply interpolated */ - int sample = m_lastsample + ((pos * (m_sample-m_lastsample)) / SUPERSAMPLING); - m_dac->write_signed16(0x8000 + sample); - } - - m_framepos++; - if (m_framepos >= m_framelength) - { - shift_frame(); - /* end of frame */ - if (m_bufpos == 4) - { - /* we have a successor */ - LOG(("%f mea8000_timer_expire: new frame\n", machine().time().as_double())); - decode_frame(); - start_frame(); - } - else if (m_cont) - { - /* repeat mode */ - LOG(("%f mea8000_timer_expire: repeat frame\n", machine().time().as_double())); - start_frame(); - } - /* slow stop */ - else if (m_state == MEA8000_STARTED) - { - m_ampl = 0; - LOG(("%f mea8000_timer_expire: fade frame\n", machine().time().as_double())); - start_frame(); - m_state = MEA8000_SLOWING; - } - else if (m_state == MEA8000_SLOWING) - { - LOG(("%f mea8000_timer_expire: stop frame\n", machine().time().as_double())); - stop_frame(); - } - update_req(); - } - else - { - /* continue frame */ - m_timer->reset(SAMPLING); - } -} - - -/************************** CPU interface ****************************/ - - -READ8_MEMBER( mea8000_device::read ) -{ - switch (offset) - { - case 0: /* status register */ - case 1: - /* ready to accept next frame */ -#if 0 - LOG(("%s %f: mea8000_r ready=%i\n", machine().describe_context(), machine().time().as_double(), accept_byte())); -#endif - return accept_byte() << 7; - - default: - logerror("%s mea8000_r invalid read offset %i\n", machine().describe_context(), offset); - } - return 0; -} - -WRITE8_MEMBER( mea8000_device::write ) -{ - switch (offset) - { - case 0: /* data register */ - if (m_state == MEA8000_STOPPED) - { - /* got pitch byte before first frame */ - m_pitch = 2 * data; - LOG(("%s %f: mea8000_w pitch %i\n", machine().describe_context(), machine().time().as_double(), m_pitch)); - m_state = MEA8000_WAIT_FIRST; - m_bufpos = 0; - } - else if (m_bufpos == 4) - { - /* overflow */ - LOG(("%s %f: mea8000_w data overflow %02X\n", machine().describe_context(), machine().time().as_double(), data)); - } - else - { - /* enqueue frame byte */ - LOG(("%s %f: mea8000_w data %02X in frame pos %i\n", machine().describe_context(), machine().time().as_double(), - data, m_bufpos)); - m_buf[m_bufpos] = data; - m_bufpos++; - if (m_bufpos == 4 && m_state == MEA8000_WAIT_FIRST) - { - /* fade-in first frame */ - int old_pitch = m_pitch; - m_last_pitch = old_pitch; - decode_frame(); - shift_frame(); - m_last_pitch = old_pitch; - m_ampl = 0; - start_frame(); - m_state = MEA8000_STARTED; - } - } - update_req(); - break; - - case 1: /* command register */ - { - int stop = BIT(data, 4); - - if (data & 8) - m_cont = BIT(data, 2); - - if (data & 2) - m_roe = BIT(data, 0); - - if (stop) - stop_frame(); - - LOG(( "%s %f: mea8000_w command %02X stop=%i cont=%i roe=%i\n", - machine().describe_context(), machine().time().as_double(), data, - stop, m_cont, m_roe)); - - update_req(); - break; - } - - default: - logerror( "%s mea8000_w invalid write offset %i\n", machine().describe_context(), offset); - } -} diff --git a/src/mess/audio/mea8000.h b/src/mess/audio/mea8000.h deleted file mode 100644 index 5d09ee938c9..00000000000 --- a/src/mess/audio/mea8000.h +++ /dev/null @@ -1,140 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Antoine Mine -/********************************************************************** - - Copyright (C) Antoine Mine' 2006 - - Philips MEA 8000 emulation. - -**********************************************************************/ - -#ifndef __MEA8000_H__ -#define __MEA8000_H__ - -#include "sound/dac.h" - -#define MCFG_MEA8000_DAC(_tag) \ - mea8000_device::static_set_dac_tag(*device, "^" _tag); - -#define MCFG_MEA8000_REQ_CALLBACK(_write) \ - devcb = &mea8000_device::set_reqwr_callback(*device, DEVCB_##_write); - -/* table amplitude [-QUANT,QUANT] */ -#define QUANT 512 - -/* filter coefficients from frequencies */ -#define TABLE_LEN 3600 - -/* noise generator table */ -#define NOISE_LEN 8192 - - -/* finite machine state controling frames */ -enum mea8000_state -{ - MEA8000_STOPPED, /* nothing to do, timer disabled */ - MEA8000_WAIT_FIRST, /* received pitch, wait for first full trame, timer disabled */ - MEA8000_STARTED, /* playing a frame, timer on */ - MEA8000_SLOWING /* repeating last frame with decreasing amplitude, timer on */ -}; - -ALLOW_SAVE_TYPE( mea8000_state ); - - -struct filter_t -{ -#ifdef FLOAT_MODE - double fm, last_fm; /* frequency, in Hz */ - double bw, last_bw; /* band-width, in Hz */ - double output, last_output; /* filter state */ -#else - UINT16 fm, last_fm; - UINT16 bw, last_bw; - INT32 output, last_output; -#endif -}; - -class mea8000_device : public device_t -{ -public: - mea8000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~mea8000_device() {} - - static void static_set_dac_tag(device_t &device, const char *tag) { downcast<mea8000_device &>(device).m_dac.set_tag(tag); } - template<class _Object> static devcb_base &set_req_wr_callback(device_t &device, _Object object) { return downcast<mea8000_device &>(device).m_write_req.set_callback(object); } - - DECLARE_READ8_MEMBER(read); - DECLARE_WRITE8_MEMBER(write); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - -private: - // internal state - - int accept_byte(); - void update_req(); - void init_tables(); -#ifndef FLOAT_MODE /* UINT16 version */ - int interp(UINT16 org, UINT16 dst); - int filter_step(int i, int input); - int noise_gen(); - int freq_gen(); - int compute_sample(); -#else /* float version */ - double interp(double org, double dst); - double filter_step(int i, double input); - double noise_gen(); - double freq_gen(); - double compute_sample(); -#endif - - void shift_frame(); - void decode_frame(); - void start_frame(); - void stop_frame(); - - TIMER_CALLBACK_MEMBER(timer_expire); - - devcb_write8 m_write_req; - - required_device<dac_device> m_dac; - - /* state */ - mea8000_state m_state; /* current state */ - - UINT8 m_buf[4]; /* store 4 consecutive data to form a frame info */ - UINT8 m_bufpos; /* new byte to write in frame info buffer */ - - UINT8 m_cont; /* if no data 0=stop 1=repeat last frame */ - UINT8 m_roe; /* enable req output, now unimplemented */ - - UINT16 m_framelength; /* in samples */ - UINT16 m_framepos; /* in samples */ - UINT16 m_framelog; /* log2 of framelength */ - - INT16 m_lastsample, m_sample; /* output samples are interpolated */ - - UINT32 m_phi; /* absolute phase for frequency / noise generator */ - - filter_t m_f[4]; /* filters */ - - UINT16 m_last_ampl, m_ampl; /* amplitude * 1000 */ - UINT16 m_last_pitch, m_pitch; /* pitch of sawtooth signal, in Hz */ - UINT8 m_noise; - - emu_timer *m_timer; - - int m_cos_table[TABLE_LEN]; /* fm => cos coefficient */ - int m_exp_table[TABLE_LEN]; /* bw => exp coefficient */ - int m_exp2_table[TABLE_LEN]; /* bw => 2*exp coefficient */ - int m_noise_table[NOISE_LEN]; - -}; - -extern const device_type MEA8000; - - -#endif diff --git a/src/mess/audio/socrates.c b/src/mess/audio/socrates.c deleted file mode 100644 index c35896e5c25..00000000000 --- a/src/mess/audio/socrates.c +++ /dev/null @@ -1,127 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Jonathan Gevaryahu -/*************************************************************************** - - audio/socrates.c - Copyright (C) 2010-2011 Jonathan Gevaryahu AKA Lord Nightmare - - This handles the two squarewaves (plus the one weird wave) channels - on the V-tech Socrates system 27-0769 ASIC. - - -****************************************************************************/ - -#include "emu.h" -#include "socrates.h" - - -// device type definition -const device_type SOCRATES_SOUND = &device_creator<socrates_snd_device>; - - -//------------------------------------------------- -// socrates_snd_device - constructor -//------------------------------------------------- - -socrates_snd_device::socrates_snd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, SOCRATES_SOUND, "Socrates Sound", tag, owner, clock, "socrates_snd", __FILE__), - device_sound_interface(mconfig, *this) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void socrates_snd_device::device_start() -{ - m_freq[0] = m_freq[1] = 0xff; /* channel 1,2 frequency */ - m_vol[0] = m_vol[1] = 0x07; /* channel 1,2 volume */ - m_enable[0] = m_enable[1] = 0x01; /* channel 1,2 enable */ - m_channel3 = 0x00; /* channel 3 weird register */ - m_DAC_output = 0x00; /* output */ - m_state[0] = m_state[1] = m_state[2] = 0; - m_accum[0] = m_accum[1] = m_accum[2] = 0xFF; - m_stream = machine().sound().stream_alloc(*this, 0, 1, clock() ? clock() : machine().sample_rate()); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void socrates_snd_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - for (int i = 0; i < samples; i++) - { - snd_clock(); - outputs[0][i] = ((int)m_DAC_output<<4); - } -} - - -const UINT8 socrates_snd_device::s_volumeLUT[16] = -{ -0, 61, 100, 132, 158, 183, 201, 218, -233, 242, 253, 255, 250, 240, 224, 211 -}; // this table is actually quite weird on the real console. -// 0, 0.033, 0.055, 0.07175, 0.086, 0.1, 0.11, 0.119, 0.127, 0.132, 0.138, 0.139, 0.136, 0.131, 0.122, 0.115 are the voltage amplitudes for the steps on channel 2. the last four are particularly bizarre, probably caused by some sort of internal clipping. - -void socrates_snd_device::snd_clock() /* called once per clock */ -{ - for (int channel = 0; channel < 2; channel++) - { - if ((m_accum[channel] == 0) && m_enable[channel]) - { - m_state[channel] = (m_state[channel]^0x1); - m_accum[channel] = m_freq[channel]; - } - else if (m_enable[channel]) - { - m_accum[channel]--; - } - else - { - m_accum[channel] = 0; // channel is disabled - m_state[channel] = 0; - } - } - // handle channel 3 here - m_DAC_output = (m_state[0]?(s_volumeLUT[m_vol[0]]*9.4):0); // channel 1 is ~2.4 times as loud as channel 2 - m_DAC_output += (m_state[1]?(s_volumeLUT[m_vol[1]]<<2):0); - // add channel 3 to dac output here -} - - -void socrates_snd_device::reg0_w(int data) -{ - m_stream->update(); - m_freq[0] = data; -} - -void socrates_snd_device::reg1_w(int data) -{ - m_stream->update(); - m_freq[1] = data; -} - -void socrates_snd_device::reg2_w(int data) -{ - m_stream->update(); - m_vol[0] = data&0xF; - m_enable[0] = (data&0x10)>>4; -} - -void socrates_snd_device::reg3_w(int data) -{ - m_stream->update(); - m_vol[1] = data&0xF; - m_enable[1] = (data&0x10)>>4; -} - -void socrates_snd_device::reg4_w(int data) -{ - m_stream->update(); - m_channel3 = data; -} diff --git a/src/mess/audio/socrates.h b/src/mess/audio/socrates.h deleted file mode 100644 index f1d2b1dd002..00000000000 --- a/src/mess/audio/socrates.h +++ /dev/null @@ -1,44 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Jonathan Gevaryahu -#pragma once - -#ifndef __SOCR_SND_H__ -#define __SOCR_SND_H__ - -class socrates_snd_device : public device_t, - public device_sound_interface -{ -public: - socrates_snd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - void reg0_w(int data); - void reg1_w(int data); - void reg2_w(int data); - void reg3_w(int data); - void reg4_w(int data); - -protected: - // device-level overrides - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); -private: - void snd_clock(); - static const UINT8 s_volumeLUT[]; - - // internal state - sound_stream * m_stream; - UINT8 m_freq[2]; // channel 1,2 frequencies - UINT8 m_vol[2]; // channel 1,2 volume - UINT8 m_enable[2]; // channel 1,2 enable - UINT8 m_channel3; // channel 3 weird register - UINT8 m_state[3]; // output states for channels 1,2,3 - UINT8 m_accum[3]; // accumulators for channels 1,2,3 - UINT16 m_DAC_output; // output -}; - -extern const device_type SOCRATES_SOUND; - - -#endif /* __SOCR_SND_H__ */ diff --git a/src/mess/audio/specimx_snd.c b/src/mess/audio/specimx_snd.c deleted file mode 100644 index 2b56c6b25f8..00000000000 --- a/src/mess/audio/specimx_snd.c +++ /dev/null @@ -1,101 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - audio/special.c - - Functions to emulate sound hardware of Specialist MX - ( based on code of DAI interface ) - -****************************************************************************/ - -#include "specimx_snd.h" - - -// device type definition -const device_type SPECIMX_SND = &device_creator<specimx_sound_device>; - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// specimx_sound_device - constructor -//------------------------------------------------- - -specimx_sound_device::specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, SPECIMX_SND, "Specialist MX Audio Custom", tag, owner, clock, "specimx_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_mixer_channel(NULL) -{ - memset(m_specimx_input, 0, sizeof(int)*3); -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void specimx_sound_device::device_start() -{ - m_specimx_input[0] = m_specimx_input[1] = m_specimx_input[2] = 0; - m_mixer_channel = stream_alloc(0, 1, machine().sample_rate()); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void specimx_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - INT16 channel_0_signal; - INT16 channel_1_signal; - INT16 channel_2_signal; - - stream_sample_t *sample_left = outputs[0]; - - channel_0_signal = m_specimx_input[0] ? 3000 : -3000; - channel_1_signal = m_specimx_input[1] ? 3000 : -3000; - channel_2_signal = m_specimx_input[2] ? 3000 : -3000; - - while (samples--) - { - *sample_left = 0; - - /* music channel 0 */ - *sample_left += channel_0_signal; - - /* music channel 1 */ - *sample_left += channel_1_signal; - - /* music channel 2 */ - *sample_left += channel_2_signal; - - sample_left++; - } -} - - -//------------------------------------------------- -// PIT callbacks -//------------------------------------------------- - -WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch0) -{ - m_mixer_channel->update(); - m_specimx_input[0] = state; -} - -WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch1) -{ - m_mixer_channel->update(); - m_specimx_input[1] = state; -} - -WRITE_LINE_MEMBER(specimx_sound_device::set_input_ch2) -{ - m_mixer_channel->update(); - m_specimx_input[2] = state; -} diff --git a/src/mess/audio/specimx_snd.h b/src/mess/audio/specimx_snd.h deleted file mode 100644 index 0e07b27dc4b..00000000000 --- a/src/mess/audio/specimx_snd.h +++ /dev/null @@ -1,39 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/***************************************************************************** - * - * specimx_snd.h - * - ****************************************************************************/ - -#ifndef SPECIAL_SND_H_ -#define SPECIAL_SND_H_ - -#include "emu.h" - -class specimx_sound_device : public device_t, - public device_sound_interface -{ -public: - specimx_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~specimx_sound_device() { } - - DECLARE_WRITE_LINE_MEMBER(set_input_ch0); - DECLARE_WRITE_LINE_MEMBER(set_input_ch1); - DECLARE_WRITE_LINE_MEMBER(set_input_ch2); - -protected: - // device-level overrides - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -private: - sound_stream *m_mixer_channel; - int m_specimx_input[3]; -}; - -extern const device_type SPECIMX_SND; - -#endif /* SPECIAL_SND_H_ */ diff --git a/src/mess/audio/svis_snd.c b/src/mess/audio/svis_snd.c deleted file mode 100644 index 86408d26820..00000000000 --- a/src/mess/audio/svis_snd.c +++ /dev/null @@ -1,269 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/*************************************************************************** - supervision sound hardware - - PeT mess@utanet.at -***************************************************************************/ - -#include "emu.h" -#include "svis_snd.h" - - -// device type definition -const device_type SVISION_SND = &device_creator<svision_sound_device>; - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// svision_sound_device - constructor -//------------------------------------------------- - -svision_sound_device::svision_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, SVISION_SND, "Super Vision Audio Custom", tag, owner, clock, "svision_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_mixer_channel(NULL) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void svision_sound_device::device_start() -{ - // bind callbacks - m_irq_cb.bind_relative_to(*owner()); - - memset(&m_dma, 0, sizeof(m_dma)); - memset(&m_noise, 0, sizeof(m_noise)); - memset(m_channel, 0, sizeof(m_channel)); - - m_mixer_channel = stream_alloc(0, 2, machine().sample_rate()); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void svision_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *left=outputs[0], *right=outputs[1]; - int i, j; - SVISION_CHANNEL *channel; - - for (i = 0; i < samples; i++, left++, right++) - { - *left = 0; - *right = 0; - for (channel=m_channel, j=0; j<ARRAY_LENGTH(m_channel); j++, channel++) - { - if (channel->size != 0) - { - if (channel->on||channel->count) - { - int on = FALSE; - switch (channel->waveform) - { - case 0: - on = channel->pos <= (28 * channel->size) >> 5; - break; - case 1: - on = channel->pos <= (24 * channel->size) >> 5; - break; - default: - case 2: - on = channel->pos <= channel->size / 2; - break; - case 3: - on = channel->pos <= (9 * channel->size) >> 5; - break; - } - { - INT16 s = on ? channel->volume << 8 : 0; - if (j == 0) - *right += s; - else - *left += s; - } - } - channel->pos++; - if (channel->pos >= channel->size) - channel->pos = 0; - } - } - if (m_noise.on && (m_noise.play || m_noise.count)) - { - INT16 s = (m_noise.value ? 1 << 8: 0) * m_noise.volume; - int b1, b2; - if (m_noise.left) - *left += s; - if (m_noise.right) - *right += s; - m_noise.pos += m_noise.step; - if (m_noise.pos >= 1.0) - { - switch (m_noise.type) - { - case SVISION_NOISE_Type7Bit: - m_noise.value = m_noise.state & 0x40 ? 1 : 0; - b1 = (m_noise.state & 0x40) != 0; - b2 = (m_noise.state & 0x20) != 0; - m_noise.state=(m_noise.state<<1)+(b1!=b2?1:0); - break; - case SVISION_NOISE_Type14Bit: - default: - m_noise.value = m_noise.state & 0x2000 ? 1 : 0; - b1 = (m_noise.state & 0x2000) != 0; - b2 = (m_noise.state & 0x1000) != 0; - m_noise.state = (m_noise.state << 1) + (b1 != b2 ? 1 : 0); - } - m_noise.pos -= 1; - } - } - if (m_dma.on) - { - UINT8 sample; - INT16 s; - UINT16 addr = m_dma.start + (unsigned) m_dma.pos / 2; - if (addr >= 0x8000 && addr < 0xc000) - { - sample = machine().root_device().memregion("user1")->base()[(addr & 0x3fff) | m_dma.ca14to16]; - } - else - { - sample = machine().device("maincpu")->memory().space(AS_PROGRAM).read_byte(addr); - } - if (((unsigned)m_dma.pos) & 1) - s = (sample & 0xf); - else - s = (sample & 0xf0) >> 4; - s <<= 8; - if (m_dma.left) - *left += s; - if (m_dma.right) - *right += s; - m_dma.pos += m_dma.step; - if (m_dma.pos >= m_dma.size) - { - m_dma.finished = TRUE; - m_dma.on = FALSE; - m_irq_cb(); - } - } - } -} - - -WRITE8_MEMBER( svision_sound_device::sounddma_w ) -{ - logerror("%.6f svision snddma write %04x %02x\n", space.machine().time().as_double(),offset+0x18,data); - m_dma.reg[offset] = data; - switch (offset) - { - case 0: - case 1: - m_dma.start = (m_dma.reg[0] | (m_dma.reg[1] << 8)); - break; - case 2: - m_dma.size = (data ? data : 0x100) * 32; - break; - case 3: - m_dma.step = space.machine().device("maincpu")->unscaled_clock() / (256.0 * space.machine().sample_rate() * (1 + (data & 3))); - m_dma.right = data & 4; - m_dma.left = data & 8; - m_dma.ca14to16 = ((data & 0x70) >> 4) << 14; - break; - case 4: - m_dma.on = data & 0x80; - if (m_dma.on) - { - m_dma.pos = 0.0; - } - break; - } -} - - -WRITE8_MEMBER( svision_sound_device::noise_w ) -{ - // logerror("%.6f svision noise write %04x %02x\n",machine.time(),offset+0x28,data); - m_noise.reg[offset]=data; - switch (offset) - { - case 0: - m_noise.volume=data&0xf; - m_noise.step= space.machine().device("maincpu")->unscaled_clock() / (256.0*space.machine().sample_rate()*(1+(data>>4))); - break; - case 1: - m_noise.count = data + 1; - break; - case 2: - m_noise.type = (SVISION_NOISE_Type) (data & 1); - m_noise.play = data & 2; - m_noise.right = data & 4; - m_noise.left = data & 8; - m_noise.on = data & 0x10; /* honey bee start */ - m_noise.state = 1; - break; - } - m_noise.pos=0.0; -} - - -int *svision_sound_device::dma_finished() -{ - return &m_dma.finished; -} - - -void svision_sound_device::sound_decrement() -{ - if (m_channel[0].count > 0) - m_channel[0].count--; - if (m_channel[1].count > 0) - m_channel[1].count--; - if (m_noise.count > 0) - m_noise.count--; -} - - -void svision_sound_device::soundport_w(int which, int offset, int data) -{ - SVISION_CHANNEL *channel = &m_channel[which]; - UINT16 size; - - m_mixer_channel->update(); - channel->reg[offset] = data; - - switch (offset) - { - case 0: - case 1: - size = channel->reg[0] | ((channel->reg[1] & 7) << 8); - if (size) - { - // channel->size=(int)(device->machine().sample_rate()*(size<<5)/4e6); - channel->size= (int) (machine().sample_rate() * (size << 5) / machine().device("maincpu")->unscaled_clock()); - } - else - { - channel->size = 0; - } - channel->pos = 0; - break; - case 2: - channel->on = data & 0x40; - channel->waveform = (data & 0x30) >> 4; - channel->volume = data & 0xf; - break; - case 3: - channel->count = data + 1; - break; - } -} diff --git a/src/mess/audio/svis_snd.h b/src/mess/audio/svis_snd.h deleted file mode 100644 index 7d21bc4fdfb..00000000000 --- a/src/mess/audio/svis_snd.h +++ /dev/null @@ -1,142 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/***************************************************************************** - * - * svis_snd.h - * - ****************************************************************************/ - -#ifndef SVIS_SND_H_ -#define SVIS_SND_H_ - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -enum SVISION_NOISE_Type -{ - SVISION_NOISE_Type7Bit, - SVISION_NOISE_Type14Bit -}; - -struct SVISION_NOISE -{ - SVISION_NOISE() : - on(0), - right(0), - left(0), - play(0), - type(SVISION_NOISE_Type7Bit), - state(0), - volume(0), - count(0), - step(0.0), - pos(0.0), - value(0) - { - memset(reg, 0, sizeof(UINT8)*3); - } - - UINT8 reg[3]; - int on, right, left, play; - SVISION_NOISE_Type type; - int state; - int volume; - int count; - double step, pos; - int value; // currently simple random function -}; - -struct SVISION_DMA -{ - SVISION_DMA() : - on(0), - right(0), - left(0), - ca14to16(0), - start(0), - size(0), - pos(0.0), - step(0.0), - finished(0) - { - memset(reg, 0, sizeof(UINT8)*5); - } - - UINT8 reg[5]; - int on, right, left; - int ca14to16; - int start,size; - double pos, step; - int finished; -}; - -struct SVISION_CHANNEL -{ - SVISION_CHANNEL() : - on(0), - waveform(0), - volume(0), - pos(0), - size(0), - count(0) - { - memset(reg, 0, sizeof(UINT8)*4); - } - - UINT8 reg[4]; - int on; - int waveform, volume; - int pos; - int size; - int count; -}; - -typedef device_delegate<void (void)> svision_snd_irq_delegate; -#define SVISION_SND_IRQ_MEMBER(_name) void _name(void) - -#define SVISION_SND_IRQ_CB(_class, _method) \ - svision_sound_device::set_irq_callback(*device, svision_snd_irq_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); - -// ======================> svision_sound_device - -class svision_sound_device : public device_t, - public device_sound_interface -{ -public: - svision_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~svision_sound_device() { } - - // static configuration - static void set_irq_callback(device_t &device, svision_snd_irq_delegate callback) { downcast<svision_sound_device &>(device).m_irq_cb = callback; } - -protected: - // device-level overrides - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -public: - DECLARE_WRITE8_MEMBER( sounddma_w ); - DECLARE_WRITE8_MEMBER( noise_w ); - -public: - int *dma_finished(); - void sound_decrement(); - void soundport_w(int which, int offset, int data); - -private: - svision_snd_irq_delegate m_irq_cb; - - sound_stream *m_mixer_channel; - SVISION_DMA m_dma; - SVISION_NOISE m_noise; - SVISION_CHANNEL m_channel[2]; -}; - -extern const device_type SVISION_SND; - - -#endif /* SVIS_SND_H_ */ diff --git a/src/mess/audio/tvc_snd.c b/src/mess/audio/tvc_snd.c deleted file mode 100644 index 29d61b5dc7c..00000000000 --- a/src/mess/audio/tvc_snd.c +++ /dev/null @@ -1,142 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sandro Ronco -/*************************************************************************** - - Videotone TVC 32/64 sound emulation - -***************************************************************************/ - -#include "emu.h" -#include "tvc_snd.h" - -// device type definition -const device_type TVC_SOUND = &device_creator<tvc_sound_device>; - -//------------------------------------------------- -// tvc_sound_device - constructor -//------------------------------------------------- - -tvc_sound_device::tvc_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : - device_t(mconfig, TVC_SOUND, "TVC 64 Audio Custom", tag, owner, clock, "tvc_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_write_sndint(*this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- -void tvc_sound_device::device_start() -{ - // resolve callbacks - m_write_sndint.resolve_safe(); - - m_stream = machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate()); - m_sndint_timer = timer_alloc(TIMER_SNDINT); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- -void tvc_sound_device::device_reset() -{ - m_enabled = 0; - m_freq = 0; - m_incr = 0; - m_signal = 1; - m_sndint_timer->reset(); -} - - -//------------------------------------------------- -// device_timer - handler timer events -//------------------------------------------------- - -void tvc_sound_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - m_write_sndint(1); -} - -//------------------------------------------------- -// sound_stream_update - handle update requests for -// our sound stream -//------------------------------------------------- - -void tvc_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - int rate = machine().sample_rate() / 2; - - if (m_enabled && m_freq) - { - while( samples-- > 0 ) - { - *outputs[0]++ = m_signal * (m_volume * 0x0800); - m_incr -= m_freq; - while(m_incr < 0) - { - m_incr += rate; - m_signal = -m_signal; - } - } - } - else - { - // fill output with 0 if the sound is disabled - memset(outputs[0], 0, samples * sizeof(stream_sample_t)); - } -} - - - -//------------------------------------------------- -// ports write -//------------------------------------------------- - -WRITE8_MEMBER(tvc_sound_device::write) -{ - m_stream->update(); - - m_ports[offset] = data; - - switch(offset) - { - case 1: - m_enabled = BIT(data, 4); - // fall through - - case 0: - { - UINT16 pitch = (m_ports[0] | (m_ports[1]<<8)) & 0x0fff; - m_freq = (pitch == 0x0fff) ? 0 : (int)(195312.5 / (4096 - pitch)); - - if ((m_ports[1] & 0x20) && m_freq != 0) - m_sndint_timer->adjust(attotime::from_hz(m_freq), 0, attotime::from_hz(m_freq)); - else - m_sndint_timer->reset(); - - break; - } - - case 2: - m_volume = (data>>2) & 0x0f; - break; - } -} - - -//------------------------------------------------- -// tvc_sound_device::reset_divider -//------------------------------------------------- - -void tvc_sound_device::reset_divider() -{ - m_stream->update(); - - m_incr = 0; - m_signal = 1; - - if (m_ports[1] & 0x20 && m_freq != 0) - m_sndint_timer->adjust(attotime::from_hz(m_freq), 0, attotime::from_hz(m_freq)); - else - m_sndint_timer->reset(); -} diff --git a/src/mess/audio/tvc_snd.h b/src/mess/audio/tvc_snd.h deleted file mode 100644 index b8b955d3c45..00000000000 --- a/src/mess/audio/tvc_snd.h +++ /dev/null @@ -1,59 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Sandro Ronco -/***************************************************************************** - * - * includes/tvc.h - * - ****************************************************************************/ - -#pragma once - -#ifndef _TVC_SND_H_ -#define _TVC_SND_H_ - -#define MCFG_TVC_SOUND_SNDINT_CALLBACK(_write) \ - devcb = &tvc_sound_device::set_sndint_wr_callback(*device, DEVCB_##_write); - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> tvc_sound_device - -class tvc_sound_device : public device_t, - public device_sound_interface -{ -public: - // construction/destruction - tvc_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - template<class _Object> static devcb_base &set_sndint_wr_callback(device_t &device, _Object object) { return downcast<tvc_sound_device &>(device).m_write_sndint.set_callback(object); } - - DECLARE_WRITE8_MEMBER(write); - void reset_divider(); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -private: - static const device_timer_id TIMER_SNDINT = 0; - - sound_stream * m_stream; - int m_freq; - int m_enabled; - int m_volume; - int m_incr; - int m_signal; - UINT8 m_ports[3]; - emu_timer * m_sndint_timer; - devcb_write_line m_write_sndint; -}; - -// device type definition -extern const device_type TVC_SOUND; - -#endif diff --git a/src/mess/audio/upd1771.c b/src/mess/audio/upd1771.c deleted file mode 100644 index 96b3b2bb062..00000000000 --- a/src/mess/audio/upd1771.c +++ /dev/null @@ -1,554 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:David Viens -/********************************************************************** - - NEC uPD1771-017 as used in the Epoch Super Cassette Vision (SCV) - - Made using recording/analysis on a Yeno (PAL Super Cassete Vision) - by plgDavid - - Full markings on my 2 specimens are - "NEC JAPAN 8431K9 D1771C 017" (31st week of 1984, mask rom #017) - - I've since (October 2012) got a Grandstand Firefox F-7 Handheld game - (AKA Epoch GalagaX6/Epoch Astro Thunder 7/Tandy Astro Thunder), - (http://www.handheldmuseum.com/Grandstand/Firefox.htm) - which includes a - "NEC JAPAN 8319K9 D1771C 011" (19th week of 1983, mask rom #011) - Thanks to user 'Blanka' from Dragonslairfans for the nice catch! - (http://www.dragonslairfans.com/smfor/index.php?topic=3061.0) - - Since the chip generates tones using ROM wavetables, - it is perfectly possible to generate other sounds with different rom code and data. - - Most upd17XXX devices are typically 4bit NEC MCUs, however based on information - in "Electronic Speech Synthesis" by Geoff Bristow (ISBN 0-07-007912-9, pages 148-152) - the upd1770/1771 is not one of these 4-bit ones. - - The uPD1770/uPD1771 SSM is a 16-bit-wide rom/ram mcu with 8kb (4kw) of rom code, - 64 bytes of ram (16x16bit words addressable as 16 or 2x8 bits each, the - remaining 32 bytes acting as an 8-level stack), 182 instructions, a complex - noise and tone internal interrupt system, external interrupts, - and two 8-bit ports with multiple modes allowing for chips to operate as master - or slave devices. - SSM stands for "Sound Synthesis Microcomputer". - - People who I *THINK* worked on the uPD1771 and what part I think they worked on: - Toshio Oura - Project Lead(?), VSRSSS/TSRSSS speech synthesis engine (on upd1776C), master/slave i/o controls, author of bristow article and primary author of the IEEE article - Hatsuhide Igarashi - Clock oscillator and pad layout, coauthor on the IEEE article, other IEEE stuff - Tomoaki Isozaki - ? (senior NEC engineer?), coauthor on the IEEE article - Sachiyuki Toufuku - ?, coauthor on the IEEE article - Tojiro Mukawa - IGFETs and the DAC - M. Sakai ? - digital filtering for VSRSSS? (IEEE 4131979, 1169295) - M. Endo ? - digital design system or speech synthesis? (IEEE 4069656, another? person: IEEE 150330, 225838) - H. Aoyama ? - logic design system used to assemble/lay out the chip? (IEEE 1585393) - I. Fujitaka ? (no IEEE) - Eiji Sugimoto - cpu design? 1156033 1155824 - F. Tsukuda ? (no IEEE) - N. Miyake ? switched capacitor stuff? (IEEE nnnnnn) - - - The uPD1771 internal workings are described to some extent by the Bristow book - and the IEEE article "A Single-Chip Sound Synthesis Microcomputer" which complements the book - and are covered by at least four US patents: - 4184152 - on IGFET-based DAC stuff - 4488061 - on the IGFET-based drive circuit part of the DAC. - 4408094 - covers the 3 pin DAC with the volume control/vref pin. Not all that interesting, - except it might describe to some extent how the (9->5bit?) PWM works in the text. - 4470113 - covers the multiplexed PB0/1/2/3 pins and their use as /CS /WR /RD and ALE - note as I have marked the pins below I assume the final pins connected - to /CS /WR /RD and /ALE are PB7,6,5,4 but this is just a guess of mine: - The actual order may well match the patent. - 4577343 - covers the VSRSSS implementation as discussed in the Bristow book. - This patent has an internal diagram of the workings of the chips and - a limited description of how many registers etc it has. - 4805508 - on the operation of the tone divider register and correction for accurate period when - the tone interrupt frequency is not perfectly divisible from the clock. - These next two may not be specific to the 1771 or even related at all! - 4321562 - on a self-adjusting circuit for internal coupling to the clock crystal inputs. - This may be a generic NEC invention and probably isn't limited to the upd1771. - 4656491 - on a new method of distributing resistors and transistors on anti-ESD pin buffers - This may be a generic NEC invention and probably isn't limited to the upd1771. - - - Based on the 4577343 patent mostly, plus the bristow and IEEE article: - * these are the registers: - 8bits: - AH, AL (forming the 16-bit A' accumulator), - B, C (a pair of general purpose registers), - 4bits (may be technically part of ALU): - H -> points to one of the 16 words of ram - 1bit: - L -> selector of left or right half of the ram word - ?bits: - D (having to do with the DAC) - N (3 bits? having to do with the pseudorandom noise interrupt, namely setting the clock divider ratio for the PRNG clock vs cpu clock) - MODE (5 or more bits? enabling/disabling/acking the noise interrupt, and the tone interrupts (there are four!)) - SP (the stack pointer, probably 5 bits, points to the stack ram; may encompass H and L as above!) - FLO: unsure. quite possibly 'flag overflow' used for branching. there likely exists other flags as well... - ODF: 'output data flag?', selects which half of a selected ram word is output to the dac not really sure of this? - - - Mask roms known: - uPD1776C: mentioned in the bristow book, implements VSRSSS speech concatenation - (see US Patent 4577343 which is a patent on this VSRSSS implementation) - uPD1771C-006: used in NEC APC for sound as the "MPU" - -011: used on Firefox F-4/Astro Thunder handheld - -015: unknown, known to exist from part scalper sites only. - -017: used on Epoch Super Cassete Vision for sound; This audio driver HLEs that part only. - - Used pinout in the SCV: - - NC 1 28 NC - NC 2 27 NC - NC 3 26 ACK - !WR 4 25 D7 - !CS 5 24 D6 - RESET 6 23 D5 - NC 7 22 D4 - VCC 8 21 D3 - 6Mhz XIN 9 20 D2 - 6Mhz XOUT 10 19 D1 - AUDOUT 11 18 D0 - NC(recheck!)12 17 GND - AUDOUT(inv) 13 16 VCC - GND 14 15 ? tied to pin 16 (VCC) through a resistor (pullup?) - - Pinout based on guesses and information in "Electronic Speech Synthesis" by Geoff Bristow - (ISBN 0-07-007912-9, pages 148-152), and the data on page 233 of the Nec APC technical manual at - http://bitsavers.trailing-edge.com/pdf/nec/APC/819-000100-1003_APC_System_Reference_Guide_Apr83.pdf - I/O pin purpose based on testing by kevtris. - [x] is unsure: - PB3 <> 1 28 <> PB2 - PB4(/ALE) <> 2 27 <> PB1 - PB5(/RD) <> 3 26 <> PB0 - PB6(/WR) <> 4 25 <> D7(PA7) - PB7(/CS) <> 5 24 <> D6(PA6) - /RESET -> 6 23 <> D5(PA5) - [/TSTOUT?] <- 7 22 <> D4(PA4) - VCC -- 8 21 <> D3(PA3) - XI(CLK) -> 9 20 <> D2(PA2) - XO <- 10 19 <> D1(PA1) - D/A OUT + <- 11 18 <> D0(PA0) - D/A POWER -- 12 17 <- CH2 - D/A OUT - <- 13 16 <> /EXTINT and [/TSTOUT2?] (test out is related to pin 15 state) - GND -- 14 15 <- CH1 tied to pin 16 (VCC) through a resistor, on APC to VCC thru a 12k resistor and thru a 10uf cap to gnd - - CH1 and CH2 are mode selects, purpose based on testing by kevtris: - CH1 CH2 - H L - 'master' mode, pb4-pb7 are i/o? /EXTINT is an input - L L - 'slave' mode where pb4-pb7 are /ale /rd /wr /cs? /EXTINT may be an output in this mode? - X H - test mode: the 512 byte 16-bit wide ROM is output sequentially on pins pa7-pa0 and pb7-pb0 for the high and low bytes of each word respectively - D/A POWER is the FET source for the D/A OUT+ and D/A OUT- push-pull dac drains; it should be tied to VCC or thereabouts - - In the SCV (info from plgDavid): - pin 5 is tied to the !SCPU pin on the Epoch TV chip pin 29 (0x3600 writes) - pin 6 is tied to the PC3 pin of the upD7801 CPU - pin 26 is tied to the INT1 pin of the upD7801 (CPU pin 12), - - 1,2,3,28,27 don't generate any digital signals - 6 seems to be lowered 2.5 ms before an audio write - 7 is always low. - 12 is always high - - (NOTE: the photomicrograph in the bristow book makes it fairly clear due to - pad thicknessess that the real VCC is pin 8 and the real GND is pin 14. - The function of pin 7 is unknown. - - Pins 11 and 13 go to a special circuit, which according to kevtris's analysis - of my schematics, consist of a balanced output (not unlike XLR cables), - which are then combined together then sent to the RF box. - (The bristow book explains that there are two DAC pins and one DAC - VREF/volume pin. The dac+ and dac- are pins 11 and 13, and based on the - photomicrograph it looks like dac vref is probably pin 12) - - HLE: - All writes are made through address 0x3600 on the upD7801 - Instead of using register=value, this chip require sending multiple - bytes for each command, one after the other. - -**********************************************************************/ - -#include "emu.h" -#include "audio/upd1771.h" - - -#define LOG 0 - -/* - Each of the 8 waveforms have been extracted from the uPD1771c-017 internal - ROM, from offset 0x1fd (start of first waveform) to offset 0x2fc (end of - last waveform). - (note: given test mode dumping offset non-clarity it may be 0x200-0x2ff) - The waveforms are stored in an 8-bit sign-magnitude format, so if in ROM the - upper bit is 0x80, invert the lower 7 bits to get the 2's complement result - seen here. - Note that only the last 4 waveforms appear to have been intended for use as - waveforms; the first four look as if they're playing back a piece of code as - wave data. -*/ -const char WAVEFORMS[8][32]={ -{ 0, 0,-123,-123, -61, -23, 125, 107, 94, 83,-128,-128,-128, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0,-128,-128,-128, 0, 0, 0, 0, 0, 0}, -{ 37, 16, 32, -21, 32, 52, 4, 4, 33, 18, 60, 56, 0, 8, 5, 16, 65, 19, 69, 16, -2, 19, 37, 16, 97, 19, 0, 87, 127, -3, 1, 2}, -{ 0, 8, 1, 52, 4, 0, 0, 77, 81,-109, 47, 97, -83,-109, 38, 97, 0, 52, 4, 0, 1, 4, 1, 22, 2, -46, 33, 97, 0, 8, -85, -99}, -{ 47, 97, 40, 97, -3, 25, 64, 17, 0, 52, 12, 5, 12, 5, 12, 5, 12, 5, 12, 5, 8, 4,-114, 19, 0, 52,-122, 21, 2, 5, 0, 8}, -{ -52, -96,-118,-128,-111, -74, -37, -5, 31, 62, 89, 112, 127, 125, 115, 93, 57, 23, 0, -16, -8, 15, 37, 54, 65, 70, 62, 54, 43, 31, 19, 0}, -{ -81,-128, -61, 13, 65, 93, 127, 47, 41, 44, 52, 55, 56, 58, 58, 34, 0, 68, 76, 72, 61, 108, 55, 29, 32, 39, 43, 49, 50, 51, 51, 0}, -{ -21, -45, -67, -88,-105,-114,-122,-128,-123,-116,-103, -87, -70, -53, -28, -9, 22, 46, 67, 86, 102, 114, 123, 125, 127, 117, 104, 91, 72, 51, 28, 0}, -{ -78,-118,-128,-102, -54, -3, 40, 65, 84, 88, 84, 80, 82, 88, 94, 103, 110, 119, 122, 125, 122, 122, 121, 123, 125, 126, 127, 127, 125, 118, 82, 0} -}; - - -#define NOISE_SIZE 255 - - -static unsigned char noise_tbl[]= -{ - 0x1c,0x86,0x8a,0x8f,0x98,0xa1,0xad,0xbe,0xd9,0x8a,0x66,0x4d,0x40,0x33,0x2b,0x23, - 0x1e,0x8a,0x90,0x97,0xa4,0xae,0xb8,0xd6,0xec,0xe9,0x69,0x4a,0x3e,0x34,0x2d,0x27, - 0x24,0x24,0x89,0x8e,0x93,0x9c,0xa5,0xb0,0xc1,0xdd,0x40,0x36,0x30,0x29,0x27,0x24, - 0x8b,0x90,0x96,0x9e,0xa7,0xb3,0xc4,0xe1,0x25,0x21,0x8a,0x8f,0x93,0x9d,0xa5,0xb2, - 0xc2,0xdd,0xdd,0x98,0xa2,0xaf,0xbf,0xd8,0xfd,0x65,0x4a,0x3c,0x31,0x2b,0x24,0x22, - 0x1e,0x87,0x8c,0x91,0x9a,0xa3,0xaf,0xc0,0xdb,0xbe,0xd9,0x8c,0x66,0x4d,0x40,0x34, - 0x2c,0x24,0x1f,0x88,0x90,0x9a,0xa4,0xb2,0xc2,0xda,0xff,0x67,0x4d,0x3d,0x34,0x2d, - 0x26,0x24,0x20,0x89,0x8e,0x93,0x9c,0xa5,0xb1,0xc2,0xde,0xc1,0xda,0xff,0x67,0x4d, - 0x3d,0x33,0x2d,0x26,0x24,0x20,0x89,0x8e,0x93,0x9c,0xa5,0xb1,0xc2,0xdd,0xa3,0xb0, - 0xc0,0xd9,0xfe,0x66,0x4b,0x3c,0x32,0x2b,0x24,0x23,0x1e,0x88,0x8d,0x92,0x9b,0xa4, - 0xb0,0xc1,0xdc,0xad,0xbe,0xda,0x22,0x20,0x1c,0x85,0x8a,0x8f,0x98,0xa1,0xad,0xbe, - 0xda,0x20,0x1b,0x85,0x8d,0x97,0xa1,0xaf,0xbf,0xd8,0xfd,0x64,0x49,0x3a,0x30,0x2a, - 0x23,0x21,0x1d,0x86,0x8b,0x91,0x9a,0xa2,0xae,0xc0,0xdb,0x33,0x2b,0x24,0x1f,0x88, - 0x90,0x9a,0xa4,0xb2,0xc2,0xda,0xff,0x67,0x4c,0x3e,0x33,0x2d,0x25,0x24,0x1f,0x89, - 0x8e,0x93,0x9c,0xa5,0xb1,0xc2,0xde,0x85,0x8e,0x98,0xa2,0xb0,0xc0,0xd9,0xfe,0x64, - 0x4b,0x3b,0x31,0x2a,0x23,0x22,0x1e,0x88,0x8c,0x91,0x9b,0xa3,0xaf,0xc1,0xdc,0xdc -}; - - - -#define STATE_SILENCE 0 -#define STATE_NOISE 1 -#define STATE_TONE 2 -#define STATE_ADPCM 3 - - -const device_type UPD1771C = &device_creator<upd1771c_device>; - - -upd1771c_device::upd1771c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, UPD1771C, "NEC uPD1771C 017", tag, owner, clock, "upd1771c", __FILE__), - device_sound_interface(mconfig, *this), - m_ack_handler(*this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void upd1771c_device::device_start() -{ - /* resolve callbacks */ - m_ack_handler.resolve_safe(); - - m_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(upd1771c_device::ack_callback),this)); - - m_channel = machine().sound().stream_alloc(*this, 0, 1, clock() / 4); - - save_item(NAME(m_packet)); - save_item(NAME(m_index)); - save_item(NAME(m_expected_bytes)); - save_item(NAME(m_state)); - save_item(NAME(m_pc3)); - save_item(NAME(m_t_timbre)); - save_item(NAME(m_t_offset)); - save_item(NAME(m_t_period)); - save_item(NAME(m_t_volume)); - save_item(NAME(m_t_tpos)); - save_item(NAME(m_t_ppos)); - save_item(NAME(m_nw_timbre)); - save_item(NAME(m_nw_volume)); - save_item(NAME(m_nw_period)); - save_item(NAME(m_nw_tpos)); - save_item(NAME(m_nw_ppos)); - save_item(NAME(m_n_value)); - save_item(NAME(m_n_volume)); - save_item(NAME(m_n_period)); - save_item(NAME(m_n_ppos)); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void upd1771c_device::device_reset() -{ - m_index = 0; - m_expected_bytes = 0; - m_pc3 = 0; - m_t_tpos = 0; - m_t_ppos = 0; - m_state = 0; - m_nw_tpos = 0; - memset(m_n_value, 0x00, sizeof(m_n_value)); - memset(m_n_ppos, 0x00, sizeof(m_n_ppos)); -} - - - -READ8_MEMBER( upd1771c_device::read ) -{ - return 0x80; // TODO -} - -/* -*************TONE***************** -Tone consists of a wavetable playback mechanism. -Each wavetable is a looping period of 32 samples but can be played with an offset from any point in the table -effectively shrinking the sample loop, thus allowing different pitch "macros ranges" to be played. -This method is rather crude because the spectrum of the sound get heavily altered... -unless that was the intent. - -Tone Write (4 bytes): - -Byte0: 0x02 - -Byte1: 0bTTTOOOOO - MSB 3 bits of Timbre (8 wavetables) - LSB 5 bits offset in the table. - -Byte2: 0bPPPPPPPP - 8bits of clock divider/period - Anything under <= 0x20 give the same value - -Byte3: 0b???VVVVV - MSB 3 bits unknown - LSB 5 bits of "Volume" - - Note: volume is not a volume in a normal sense but some kind - of bit cropping/rounding. -*/ - - -/* -*************NOISE***************** -Noise consists on 4 different components -A weird Wavetable LFSR (for lack of a better term), -and three independent (but equal) low frequency -50/50 pulse wavs. - -The 4 components are mixed in a mysterious way, -a weird ORing with volume having a huge effect. - -Byte0: 0x01 - -Byte1: 0bTTTOOOOO - MSB 3 bits of LFSR Timbre (8 wavetables) - LSB 5 bits ????????? - -Byte2: 0bPPPPPPPP - 8bits of clock divider/period - -Byte3: 0b???VVVVV - MSB 3 bits unknown - LSB 5 bits of "Volume" - - -Byte4: 0bPPPPPPPP Low Freq0 period(if not 0 this periodically resets the Wavetable LFSR) -Byte5: 0bPPPPPPPP Low Freq1 period(if not 0 this periodically resets the Wavetable LFSR) -Byte6: 0bPPPPPPPP Low Freq2 period(if not 0 this periodically resets the Wavetable LFSR) - -Byte7: 0b???VVVVV Low Freq0 volume -Byte8: 0b???VVVVV Low Freq1 volume -Byte9: 0b???VVVVV Low Freq2 volume -*/ - -WRITE8_MEMBER( upd1771c_device::write ) -{ - //if (LOG) - // logerror( "upd1771_w: received byte 0x%02x\n", data ); - - m_ack_handler(0); - - if (m_index < MAX_PACKET_SIZE) - m_packet[m_index++] = data; - else - { - logerror("upd1771_w: received byte 0x%02x overload!\n", data); - return; - } - - switch (m_packet[0]) - { - case 0: - m_state = STATE_SILENCE; - m_index = 0; - //logerror( "upd1771_w: ----------------silence state reset\n"); - break; - - case 1: - if (m_index == 10) - { - m_state = STATE_NOISE; - m_index = 0; - - m_nw_timbre = (m_packet[1] & 0xe0) >> 5; - m_nw_period = ((UINT32)m_packet[2] + 1) << 7; - m_nw_volume = m_packet[3] & 0x1f; - - //very long clocked periods.. used for engine drones - m_n_period[0] = (((UINT32)m_packet[4]) + 1) << 7; - m_n_period[1] = (((UINT32)m_packet[5]) + 1) << 7; - m_n_period[2] = (((UINT32)m_packet[6]) + 1) << 7; - - m_n_volume[0] = m_packet[7] & 0x1f; - m_n_volume[1] = m_packet[8] & 0x1f; - m_n_volume[2] = m_packet[9] & 0x1f; - - //logerror( "upd1771_w: ----------------noise state reset\n"); - } - else - m_timer->adjust(attotime::from_ticks(512, clock())); - break; - - case 2: - if (m_index == 4) - { - //logerror( "upd1771_w: ----------------tone state reset\n"); - m_t_timbre = (m_packet[1] & 0xe0) >> 5; - m_t_offset = (m_packet[1] & 0x1f); - m_t_period = m_packet[2]; - //smaller periods don't all equal to 0x20 - if (m_t_period < 0x20) - m_t_period = 0x20; - - m_t_volume = m_packet[3] & 0x1f; - m_state = STATE_TONE; - m_index = 0; - } - else - m_timer->adjust(attotime::from_ticks(512, clock())); - break; - - case 0x1f: - //6Khz(ish) DIGI playback - - //end capture - if (m_index >= 2 && m_packet[m_index - 2] == 0xfe && m_packet[m_index - 1] == 0x00) - { - //TODO play capture! - m_index = 0; - m_packet[0] = 0; - m_state = STATE_ADPCM; - } - else - m_timer->adjust(attotime::from_ticks(512, clock())); - break; - - //garbage: wipe stack - default: - m_state = STATE_SILENCE; - m_index = 0; - break; - } -} - - -WRITE_LINE_MEMBER( upd1771c_device::pcm_write ) -{ - //RESET upon HIGH - if (state != m_pc3) - { - logerror("upd1771_pc3 change!: state = %d\n", state); - m_index = 0; - m_packet[0] = 0; - } - - m_pc3 = state; -} - - -TIMER_CALLBACK_MEMBER( upd1771c_device::ack_callback ) -{ - m_ack_handler(1); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void upd1771c_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *buffer = outputs[0]; - - switch (m_state) - { - case STATE_TONE: - //logerror( "upd1771_STATE_TONE samps:%d %d %d %d %d %d\n",(int)samples, - // (int)m_t_timbre,(int)m_t_offset,(int)m_t_volume,(int)m_t_period,(int)m_t_tpos); - - while (--samples >= 0) - { - *buffer++ = (WAVEFORMS[m_t_timbre][m_t_tpos]) * m_t_volume * 2; - - m_t_ppos++; - if (m_t_ppos >= m_t_period) - { - m_t_tpos++; - if (m_t_tpos == 32) - m_t_tpos = m_t_offset; - - m_t_ppos = 0; - } - } - break; - - case STATE_NOISE: - while (--samples >= 0) - { - *buffer = 0; - - //"wavetable-LFSR" component - int wlfsr_val = ((int)noise_tbl[m_nw_tpos]) - 127;//data too wide - - m_nw_ppos++; - if (m_nw_ppos >= m_nw_period) - { - m_nw_tpos++; - if (m_nw_tpos == NOISE_SIZE) - m_nw_tpos = 0; - m_nw_ppos = 0; - } - - //mix in each of the noise's 3 pulse components - char res[3]; - for (int i = 0; i < 3; ++i) - { - res[i] = m_n_value[i] * 127; - m_n_ppos[i]++; - if (m_n_ppos[i] >= m_n_period[i]) - { - m_n_ppos[i] = 0; - m_n_value[i] = !m_n_value[i]; - } - } - //not quite, but close. - *buffer+= ( - (wlfsr_val * m_nw_volume) | - (res[0] * m_n_volume[0]) | - (res[1] * m_n_volume[1]) | - (res[2] * m_n_volume[2]) - ) ; - - buffer++; - } - break; - - default: - //fill buffer with silence - while (--samples >= 0) - { - *buffer++ = 0; - } - break; - } -} diff --git a/src/mess/audio/upd1771.h b/src/mess/audio/upd1771.h deleted file mode 100644 index e0757757e9c..00000000000 --- a/src/mess/audio/upd1771.h +++ /dev/null @@ -1,85 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/********************************************************************** - - NEC uPD1771 - -**********************************************************************/ - -#ifndef __UPD1771_H__ -#define __UPD1771_H__ - -#include "emu.h" - -#define MAX_PACKET_SIZE 0x8000 - -#define MCFG_UPD1771_ACK_HANDLER(_devcb) \ - devcb = &upd1771c_device::set_ack_handler(*device, DEVCB_##_devcb); - - -/*************************************************************************** - MACROS / CONSTANTS -***************************************************************************/ - -class upd1771c_device : public device_t, - public device_sound_interface -{ -public: - upd1771c_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~upd1771c_device() {} - - template<class _Object> static devcb_base &set_ack_handler(device_t &device, _Object object) { return downcast<upd1771c_device &>(device).m_ack_handler.set_callback(object); } - - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - WRITE_LINE_MEMBER( pcm_write ); - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -private: - // internal state - sound_stream *m_channel; - devcb_write_line m_ack_handler; - emu_timer *m_timer; - - TIMER_CALLBACK_MEMBER(ack_callback); - - UINT8 m_packet[MAX_PACKET_SIZE]; - UINT32 m_index; - UINT8 m_expected_bytes; - - UINT8 m_state;//0:silence, 1 noise, 2 tone - UINT8 m_pc3; - - //tone - UINT8 m_t_timbre; //[0; 7] - UINT8 m_t_offset; //[0; 32] - UINT16 m_t_period; //[0;255] - UINT8 m_t_volume; //[0; 31] - UINT8 m_t_tpos;//timbre pos - UINT16 m_t_ppos;//period pos - - //noise wavetable LFSR - UINT8 m_nw_timbre; //[0; 7] - UINT8 m_nw_volume; //[0; 31] - UINT32 m_nw_period; - UINT32 m_nw_tpos; //timbre pos - UINT32 m_nw_ppos; //period pos - - //noise pulse components - UINT8 m_n_value[3]; //[0;1] - UINT16 m_n_volume[3]; //[0; 31] - UINT32 m_n_period[3]; - UINT32 m_n_ppos[3]; //period pos -}; - -extern const device_type UPD1771C; - - -#endif /* __UPD1771_H__ */ diff --git a/src/mess/audio/vboy.c b/src/mess/audio/vboy.c deleted file mode 100644 index b808ee8a333..00000000000 --- a/src/mess/audio/vboy.c +++ /dev/null @@ -1,491 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/* - vboy.c - Virtual Boy audio emulation - - By Richard Bannister and Gil Pedersen. - MESS device adaptation by R. Belmont -*/ - -#include "emu.h" -#include "vboy.h" - -// device type definition -const device_type VBOYSND = &device_creator<vboysnd_device>; - -//#define LAME_COMPILER_BUG - -#define SxINT 0x00 -#define SxLRV 0x04 -#define SxFQL 0x08 -#define SxFQH 0x0c -#define SxEV0 0x10 -#define SxEV1 0x14 -#define SxRAM 0x18 - -#define SxINTb 0x400+SxINT -#define SxLRVb 0x400+SxLRV -#define SxFQLb 0x400+SxFQL -#define SxFQHb 0x400+SxFQH -#define SxEV0b 0x400+SxEV0 -#define SxEV1b 0x400+SxEV1 -#define SxRAMb 0x400+SxRAM - -#define S5SWP 0x51c -#define SST0P 0x580 - -static const UINT16 outTbl[64][32] = { - { 0x0000, 0xffe0, 0xffc0, 0xffa0, 0xff80, 0xff60, 0xff40, 0xff20, 0xff00, 0xfee0, 0xfec0, 0xfea0, 0xfe80, 0xfe60, 0xfe40, 0xfe20, - 0xfe00, 0xfde0, 0xfdc0, 0xfda0, 0xfd80, 0xfd60, 0xfd40, 0xfd20, 0xfd00, 0xfce0, 0xfcc0, 0xfca0, 0xfc80, 0xfc60, 0xfc40, 0xfc20}, - { 0x0000, 0xffe1, 0xffc2, 0xffa3, 0xff84, 0xff65, 0xff46, 0xff27, 0xff08, 0xfee9, 0xfeca, 0xfeab, 0xfe8c, 0xfe6d, 0xfe4e, 0xfe2f, - 0xfe10, 0xfdf1, 0xfdd2, 0xfdb3, 0xfd94, 0xfd75, 0xfd56, 0xfd37, 0xfd18, 0xfcf9, 0xfcda, 0xfcbb, 0xfc9c, 0xfc7d, 0xfc5e, 0xfc3f}, - { 0x0000, 0xffe2, 0xffc4, 0xffa6, 0xff88, 0xff6a, 0xff4c, 0xff2e, 0xff10, 0xfef2, 0xfed4, 0xfeb6, 0xfe98, 0xfe7a, 0xfe5c, 0xfe3e, - 0xfe20, 0xfe02, 0xfde4, 0xfdc6, 0xfda8, 0xfd8a, 0xfd6c, 0xfd4e, 0xfd30, 0xfd12, 0xfcf4, 0xfcd6, 0xfcb8, 0xfc9a, 0xfc7c, 0xfc5e}, - { 0x0000, 0xffe3, 0xffc6, 0xffa9, 0xff8c, 0xff6f, 0xff52, 0xff35, 0xff18, 0xfefb, 0xfede, 0xfec1, 0xfea4, 0xfe87, 0xfe6a, 0xfe4d, - 0xfe30, 0xfe13, 0xfdf6, 0xfdd9, 0xfdbc, 0xfd9f, 0xfd82, 0xfd65, 0xfd48, 0xfd2b, 0xfd0e, 0xfcf1, 0xfcd4, 0xfcb7, 0xfc9a, 0xfc7d}, - { 0x0000, 0xffe4, 0xffc8, 0xffac, 0xff90, 0xff74, 0xff58, 0xff3c, 0xff20, 0xff04, 0xfee8, 0xfecc, 0xfeb0, 0xfe94, 0xfe78, 0xfe5c, - 0xfe40, 0xfe24, 0xfe08, 0xfdec, 0xfdd0, 0xfdb4, 0xfd98, 0xfd7c, 0xfd60, 0xfd44, 0xfd28, 0xfd0c, 0xfcf0, 0xfcd4, 0xfcb8, 0xfc9c}, - { 0x0000, 0xffe5, 0xffca, 0xffaf, 0xff94, 0xff79, 0xff5e, 0xff43, 0xff28, 0xff0d, 0xfef2, 0xfed7, 0xfebc, 0xfea1, 0xfe86, 0xfe6b, - 0xfe50, 0xfe35, 0xfe1a, 0xfdff, 0xfde4, 0xfdc9, 0xfdae, 0xfd93, 0xfd78, 0xfd5d, 0xfd42, 0xfd27, 0xfd0c, 0xfcf1, 0xfcd6, 0xfcbb}, - { 0x0000, 0xffe6, 0xffcc, 0xffb2, 0xff98, 0xff7e, 0xff64, 0xff4a, 0xff30, 0xff16, 0xfefc, 0xfee2, 0xfec8, 0xfeae, 0xfe94, 0xfe7a, - 0xfe60, 0xfe46, 0xfe2c, 0xfe12, 0xfdf8, 0xfdde, 0xfdc4, 0xfdaa, 0xfd90, 0xfd76, 0xfd5c, 0xfd42, 0xfd28, 0xfd0e, 0xfcf4, 0xfcda}, - { 0x0000, 0xffe7, 0xffce, 0xffb5, 0xff9c, 0xff83, 0xff6a, 0xff51, 0xff38, 0xff1f, 0xff06, 0xfeed, 0xfed4, 0xfebb, 0xfea2, 0xfe89, - 0xfe70, 0xfe57, 0xfe3e, 0xfe25, 0xfe0c, 0xfdf3, 0xfdda, 0xfdc1, 0xfda8, 0xfd8f, 0xfd76, 0xfd5d, 0xfd44, 0xfd2b, 0xfd12, 0xfcf9}, - { 0x0000, 0xffe8, 0xffd0, 0xffb8, 0xffa0, 0xff88, 0xff70, 0xff58, 0xff40, 0xff28, 0xff10, 0xfef8, 0xfee0, 0xfec8, 0xfeb0, 0xfe98, - 0xfe80, 0xfe68, 0xfe50, 0xfe38, 0xfe20, 0xfe08, 0xfdf0, 0xfdd8, 0xfdc0, 0xfda8, 0xfd90, 0xfd78, 0xfd60, 0xfd48, 0xfd30, 0xfd18}, - { 0x0000, 0xffe9, 0xffd2, 0xffbb, 0xffa4, 0xff8d, 0xff76, 0xff5f, 0xff48, 0xff31, 0xff1a, 0xff03, 0xfeec, 0xfed5, 0xfebe, 0xfea7, - 0xfe90, 0xfe79, 0xfe62, 0xfe4b, 0xfe34, 0xfe1d, 0xfe06, 0xfdef, 0xfdd8, 0xfdc1, 0xfdaa, 0xfd93, 0xfd7c, 0xfd65, 0xfd4e, 0xfd37}, - { 0x0000, 0xffea, 0xffd4, 0xffbe, 0xffa8, 0xff92, 0xff7c, 0xff66, 0xff50, 0xff3a, 0xff24, 0xff0e, 0xfef8, 0xfee2, 0xfecc, 0xfeb6, - 0xfea0, 0xfe8a, 0xfe74, 0xfe5e, 0xfe48, 0xfe32, 0xfe1c, 0xfe06, 0xfdf0, 0xfdda, 0xfdc4, 0xfdae, 0xfd98, 0xfd82, 0xfd6c, 0xfd56}, - { 0x0000, 0xffeb, 0xffd6, 0xffc1, 0xffac, 0xff97, 0xff82, 0xff6d, 0xff58, 0xff43, 0xff2e, 0xff19, 0xff04, 0xfeef, 0xfeda, 0xfec5, - 0xfeb0, 0xfe9b, 0xfe86, 0xfe71, 0xfe5c, 0xfe47, 0xfe32, 0xfe1d, 0xfe08, 0xfdf3, 0xfdde, 0xfdc9, 0xfdb4, 0xfd9f, 0xfd8a, 0xfd75}, - { 0x0000, 0xffec, 0xffd8, 0xffc4, 0xffb0, 0xff9c, 0xff88, 0xff74, 0xff60, 0xff4c, 0xff38, 0xff24, 0xff10, 0xfefc, 0xfee8, 0xfed4, - 0xfec0, 0xfeac, 0xfe98, 0xfe84, 0xfe70, 0xfe5c, 0xfe48, 0xfe34, 0xfe20, 0xfe0c, 0xfdf8, 0xfde4, 0xfdd0, 0xfdbc, 0xfda8, 0xfd94}, - { 0x0000, 0xffed, 0xffda, 0xffc7, 0xffb4, 0xffa1, 0xff8e, 0xff7b, 0xff68, 0xff55, 0xff42, 0xff2f, 0xff1c, 0xff09, 0xfef6, 0xfee3, - 0xfed0, 0xfebd, 0xfeaa, 0xfe97, 0xfe84, 0xfe71, 0xfe5e, 0xfe4b, 0xfe38, 0xfe25, 0xfe12, 0xfdff, 0xfdec, 0xfdd9, 0xfdc6, 0xfdb3}, - { 0x0000, 0xffee, 0xffdc, 0xffca, 0xffb8, 0xffa6, 0xff94, 0xff82, 0xff70, 0xff5e, 0xff4c, 0xff3a, 0xff28, 0xff16, 0xff04, 0xfef2, - 0xfee0, 0xfece, 0xfebc, 0xfeaa, 0xfe98, 0xfe86, 0xfe74, 0xfe62, 0xfe50, 0xfe3e, 0xfe2c, 0xfe1a, 0xfe08, 0xfdf6, 0xfde4, 0xfdd2}, - { 0x0000, 0xffef, 0xffde, 0xffcd, 0xffbc, 0xffab, 0xff9a, 0xff89, 0xff78, 0xff67, 0xff56, 0xff45, 0xff34, 0xff23, 0xff12, 0xff01, - 0xfef0, 0xfedf, 0xfece, 0xfebd, 0xfeac, 0xfe9b, 0xfe8a, 0xfe79, 0xfe68, 0xfe57, 0xfe46, 0xfe35, 0xfe24, 0xfe13, 0xfe02, 0xfdf1}, - { 0x0000, 0xfff0, 0xffe0, 0xffd0, 0xffc0, 0xffb0, 0xffa0, 0xff90, 0xff80, 0xff70, 0xff60, 0xff50, 0xff40, 0xff30, 0xff20, 0xff10, - 0xff00, 0xfef0, 0xfee0, 0xfed0, 0xfec0, 0xfeb0, 0xfea0, 0xfe90, 0xfe80, 0xfe70, 0xfe60, 0xfe50, 0xfe40, 0xfe30, 0xfe20, 0xfe10}, - { 0x0000, 0xfff1, 0xffe2, 0xffd3, 0xffc4, 0xffb5, 0xffa6, 0xff97, 0xff88, 0xff79, 0xff6a, 0xff5b, 0xff4c, 0xff3d, 0xff2e, 0xff1f, - 0xff10, 0xff01, 0xfef2, 0xfee3, 0xfed4, 0xfec5, 0xfeb6, 0xfea7, 0xfe98, 0xfe89, 0xfe7a, 0xfe6b, 0xfe5c, 0xfe4d, 0xfe3e, 0xfe2f}, - { 0x0000, 0xfff2, 0xffe4, 0xffd6, 0xffc8, 0xffba, 0xffac, 0xff9e, 0xff90, 0xff82, 0xff74, 0xff66, 0xff58, 0xff4a, 0xff3c, 0xff2e, - 0xff20, 0xff12, 0xff04, 0xfef6, 0xfee8, 0xfeda, 0xfecc, 0xfebe, 0xfeb0, 0xfea2, 0xfe94, 0xfe86, 0xfe78, 0xfe6a, 0xfe5c, 0xfe4e}, - { 0x0000, 0xfff3, 0xffe6, 0xffd9, 0xffcc, 0xffbf, 0xffb2, 0xffa5, 0xff98, 0xff8b, 0xff7e, 0xff71, 0xff64, 0xff57, 0xff4a, 0xff3d, - 0xff30, 0xff23, 0xff16, 0xff09, 0xfefc, 0xfeef, 0xfee2, 0xfed5, 0xfec8, 0xfebb, 0xfeae, 0xfea1, 0xfe94, 0xfe87, 0xfe7a, 0xfe6d}, - { 0x0000, 0xfff4, 0xffe8, 0xffdc, 0xffd0, 0xffc4, 0xffb8, 0xffac, 0xffa0, 0xff94, 0xff88, 0xff7c, 0xff70, 0xff64, 0xff58, 0xff4c, - 0xff40, 0xff34, 0xff28, 0xff1c, 0xff10, 0xff04, 0xfef8, 0xfeec, 0xfee0, 0xfed4, 0xfec8, 0xfebc, 0xfeb0, 0xfea4, 0xfe98, 0xfe8c}, - { 0x0000, 0xfff5, 0xffea, 0xffdf, 0xffd4, 0xffc9, 0xffbe, 0xffb3, 0xffa8, 0xff9d, 0xff92, 0xff87, 0xff7c, 0xff71, 0xff66, 0xff5b, - 0xff50, 0xff45, 0xff3a, 0xff2f, 0xff24, 0xff19, 0xff0e, 0xff03, 0xfef8, 0xfeed, 0xfee2, 0xfed7, 0xfecc, 0xfec1, 0xfeb6, 0xfeab}, - { 0x0000, 0xfff6, 0xffec, 0xffe2, 0xffd8, 0xffce, 0xffc4, 0xffba, 0xffb0, 0xffa6, 0xff9c, 0xff92, 0xff88, 0xff7e, 0xff74, 0xff6a, - 0xff60, 0xff56, 0xff4c, 0xff42, 0xff38, 0xff2e, 0xff24, 0xff1a, 0xff10, 0xff06, 0xfefc, 0xfef2, 0xfee8, 0xfede, 0xfed4, 0xfeca}, - { 0x0000, 0xfff7, 0xffee, 0xffe5, 0xffdc, 0xffd3, 0xffca, 0xffc1, 0xffb8, 0xffaf, 0xffa6, 0xff9d, 0xff94, 0xff8b, 0xff82, 0xff79, - 0xff70, 0xff67, 0xff5e, 0xff55, 0xff4c, 0xff43, 0xff3a, 0xff31, 0xff28, 0xff1f, 0xff16, 0xff0d, 0xff04, 0xfefb, 0xfef2, 0xfee9}, - { 0x0000, 0xfff8, 0xfff0, 0xffe8, 0xffe0, 0xffd8, 0xffd0, 0xffc8, 0xffc0, 0xffb8, 0xffb0, 0xffa8, 0xffa0, 0xff98, 0xff90, 0xff88, - 0xff80, 0xff78, 0xff70, 0xff68, 0xff60, 0xff58, 0xff50, 0xff48, 0xff40, 0xff38, 0xff30, 0xff28, 0xff20, 0xff18, 0xff10, 0xff08}, - { 0x0000, 0xfff9, 0xfff2, 0xffeb, 0xffe4, 0xffdd, 0xffd6, 0xffcf, 0xffc8, 0xffc1, 0xffba, 0xffb3, 0xffac, 0xffa5, 0xff9e, 0xff97, - 0xff90, 0xff89, 0xff82, 0xff7b, 0xff74, 0xff6d, 0xff66, 0xff5f, 0xff58, 0xff51, 0xff4a, 0xff43, 0xff3c, 0xff35, 0xff2e, 0xff27}, - { 0x0000, 0xfffa, 0xfff4, 0xffee, 0xffe8, 0xffe2, 0xffdc, 0xffd6, 0xffd0, 0xffca, 0xffc4, 0xffbe, 0xffb8, 0xffb2, 0xffac, 0xffa6, - 0xffa0, 0xff9a, 0xff94, 0xff8e, 0xff88, 0xff82, 0xff7c, 0xff76, 0xff70, 0xff6a, 0xff64, 0xff5e, 0xff58, 0xff52, 0xff4c, 0xff46}, - { 0x0000, 0xfffb, 0xfff6, 0xfff1, 0xffec, 0xffe7, 0xffe2, 0xffdd, 0xffd8, 0xffd3, 0xffce, 0xffc9, 0xffc4, 0xffbf, 0xffba, 0xffb5, - 0xffb0, 0xffab, 0xffa6, 0xffa1, 0xff9c, 0xff97, 0xff92, 0xff8d, 0xff88, 0xff83, 0xff7e, 0xff79, 0xff74, 0xff6f, 0xff6a, 0xff65}, - { 0x0000, 0xfffc, 0xfff8, 0xfff4, 0xfff0, 0xffec, 0xffe8, 0xffe4, 0xffe0, 0xffdc, 0xffd8, 0xffd4, 0xffd0, 0xffcc, 0xffc8, 0xffc4, - 0xffc0, 0xffbc, 0xffb8, 0xffb4, 0xffb0, 0xffac, 0xffa8, 0xffa4, 0xffa0, 0xff9c, 0xff98, 0xff94, 0xff90, 0xff8c, 0xff88, 0xff84}, - { 0x0000, 0xfffd, 0xfffa, 0xfff7, 0xfff4, 0xfff1, 0xffee, 0xffeb, 0xffe8, 0xffe5, 0xffe2, 0xffdf, 0xffdc, 0xffd9, 0xffd6, 0xffd3, - 0xffd0, 0xffcd, 0xffca, 0xffc7, 0xffc4, 0xffc1, 0xffbe, 0xffbb, 0xffb8, 0xffb5, 0xffb2, 0xffaf, 0xffac, 0xffa9, 0xffa6, 0xffa3}, - { 0x0000, 0xfffe, 0xfffc, 0xfffa, 0xfff8, 0xfff6, 0xfff4, 0xfff2, 0xfff0, 0xffee, 0xffec, 0xffea, 0xffe8, 0xffe6, 0xffe4, 0xffe2, - 0xffe0, 0xffde, 0xffdc, 0xffda, 0xffd8, 0xffd6, 0xffd4, 0xffd2, 0xffd0, 0xffce, 0xffcc, 0xffca, 0xffc8, 0xffc6, 0xffc4, 0xffc2}, - { 0x0000, 0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8, 0xfff7, 0xfff6, 0xfff5, 0xfff4, 0xfff3, 0xfff2, 0xfff1, - 0xfff0, 0xffef, 0xffee, 0xffed, 0xffec, 0xffeb, 0xffea, 0xffe9, 0xffe8, 0xffe7, 0xffe6, 0xffe5, 0xffe4, 0xffe3, 0xffe2, 0xffe1}, - { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}, - { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f}, - { 0x0000, 0x0002, 0x0004, 0x0006, 0x0008, 0x000a, 0x000c, 0x000e, 0x0010, 0x0012, 0x0014, 0x0016, 0x0018, 0x001a, 0x001c, 0x001e, - 0x0020, 0x0022, 0x0024, 0x0026, 0x0028, 0x002a, 0x002c, 0x002e, 0x0030, 0x0032, 0x0034, 0x0036, 0x0038, 0x003a, 0x003c, 0x003e}, - { 0x0000, 0x0003, 0x0006, 0x0009, 0x000c, 0x000f, 0x0012, 0x0015, 0x0018, 0x001b, 0x001e, 0x0021, 0x0024, 0x0027, 0x002a, 0x002d, - 0x0030, 0x0033, 0x0036, 0x0039, 0x003c, 0x003f, 0x0042, 0x0045, 0x0048, 0x004b, 0x004e, 0x0051, 0x0054, 0x0057, 0x005a, 0x005d}, - { 0x0000, 0x0004, 0x0008, 0x000c, 0x0010, 0x0014, 0x0018, 0x001c, 0x0020, 0x0024, 0x0028, 0x002c, 0x0030, 0x0034, 0x0038, 0x003c, - 0x0040, 0x0044, 0x0048, 0x004c, 0x0050, 0x0054, 0x0058, 0x005c, 0x0060, 0x0064, 0x0068, 0x006c, 0x0070, 0x0074, 0x0078, 0x007c}, - { 0x0000, 0x0005, 0x000a, 0x000f, 0x0014, 0x0019, 0x001e, 0x0023, 0x0028, 0x002d, 0x0032, 0x0037, 0x003c, 0x0041, 0x0046, 0x004b, - 0x0050, 0x0055, 0x005a, 0x005f, 0x0064, 0x0069, 0x006e, 0x0073, 0x0078, 0x007d, 0x0082, 0x0087, 0x008c, 0x0091, 0x0096, 0x009b}, - { 0x0000, 0x0006, 0x000c, 0x0012, 0x0018, 0x001e, 0x0024, 0x002a, 0x0030, 0x0036, 0x003c, 0x0042, 0x0048, 0x004e, 0x0054, 0x005a, - 0x0060, 0x0066, 0x006c, 0x0072, 0x0078, 0x007e, 0x0084, 0x008a, 0x0090, 0x0096, 0x009c, 0x00a2, 0x00a8, 0x00ae, 0x00b4, 0x00ba}, - { 0x0000, 0x0007, 0x000e, 0x0015, 0x001c, 0x0023, 0x002a, 0x0031, 0x0038, 0x003f, 0x0046, 0x004d, 0x0054, 0x005b, 0x0062, 0x0069, - 0x0070, 0x0077, 0x007e, 0x0085, 0x008c, 0x0093, 0x009a, 0x00a1, 0x00a8, 0x00af, 0x00b6, 0x00bd, 0x00c4, 0x00cb, 0x00d2, 0x00d9}, - { 0x0000, 0x0008, 0x0010, 0x0018, 0x0020, 0x0028, 0x0030, 0x0038, 0x0040, 0x0048, 0x0050, 0x0058, 0x0060, 0x0068, 0x0070, 0x0078, - 0x0080, 0x0088, 0x0090, 0x0098, 0x00a0, 0x00a8, 0x00b0, 0x00b8, 0x00c0, 0x00c8, 0x00d0, 0x00d8, 0x00e0, 0x00e8, 0x00f0, 0x00f8}, - { 0x0000, 0x0009, 0x0012, 0x001b, 0x0024, 0x002d, 0x0036, 0x003f, 0x0048, 0x0051, 0x005a, 0x0063, 0x006c, 0x0075, 0x007e, 0x0087, - 0x0090, 0x0099, 0x00a2, 0x00ab, 0x00b4, 0x00bd, 0x00c6, 0x00cf, 0x00d8, 0x00e1, 0x00ea, 0x00f3, 0x00fc, 0x0105, 0x010e, 0x0117}, - { 0x0000, 0x000a, 0x0014, 0x001e, 0x0028, 0x0032, 0x003c, 0x0046, 0x0050, 0x005a, 0x0064, 0x006e, 0x0078, 0x0082, 0x008c, 0x0096, - 0x00a0, 0x00aa, 0x00b4, 0x00be, 0x00c8, 0x00d2, 0x00dc, 0x00e6, 0x00f0, 0x00fa, 0x0104, 0x010e, 0x0118, 0x0122, 0x012c, 0x0136}, - { 0x0000, 0x000b, 0x0016, 0x0021, 0x002c, 0x0037, 0x0042, 0x004d, 0x0058, 0x0063, 0x006e, 0x0079, 0x0084, 0x008f, 0x009a, 0x00a5, - 0x00b0, 0x00bb, 0x00c6, 0x00d1, 0x00dc, 0x00e7, 0x00f2, 0x00fd, 0x0108, 0x0113, 0x011e, 0x0129, 0x0134, 0x013f, 0x014a, 0x0155}, - { 0x0000, 0x000c, 0x0018, 0x0024, 0x0030, 0x003c, 0x0048, 0x0054, 0x0060, 0x006c, 0x0078, 0x0084, 0x0090, 0x009c, 0x00a8, 0x00b4, - 0x00c0, 0x00cc, 0x00d8, 0x00e4, 0x00f0, 0x00fc, 0x0108, 0x0114, 0x0120, 0x012c, 0x0138, 0x0144, 0x0150, 0x015c, 0x0168, 0x0174}, - { 0x0000, 0x000d, 0x001a, 0x0027, 0x0034, 0x0041, 0x004e, 0x005b, 0x0068, 0x0075, 0x0082, 0x008f, 0x009c, 0x00a9, 0x00b6, 0x00c3, - 0x00d0, 0x00dd, 0x00ea, 0x00f7, 0x0104, 0x0111, 0x011e, 0x012b, 0x0138, 0x0145, 0x0152, 0x015f, 0x016c, 0x0179, 0x0186, 0x0193}, - { 0x0000, 0x000e, 0x001c, 0x002a, 0x0038, 0x0046, 0x0054, 0x0062, 0x0070, 0x007e, 0x008c, 0x009a, 0x00a8, 0x00b6, 0x00c4, 0x00d2, - 0x00e0, 0x00ee, 0x00fc, 0x010a, 0x0118, 0x0126, 0x0134, 0x0142, 0x0150, 0x015e, 0x016c, 0x017a, 0x0188, 0x0196, 0x01a4, 0x01b2}, - { 0x0000, 0x000f, 0x001e, 0x002d, 0x003c, 0x004b, 0x005a, 0x0069, 0x0078, 0x0087, 0x0096, 0x00a5, 0x00b4, 0x00c3, 0x00d2, 0x00e1, - 0x00f0, 0x00ff, 0x010e, 0x011d, 0x012c, 0x013b, 0x014a, 0x0159, 0x0168, 0x0177, 0x0186, 0x0195, 0x01a4, 0x01b3, 0x01c2, 0x01d1}, - { 0x0000, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070, 0x0080, 0x0090, 0x00a0, 0x00b0, 0x00c0, 0x00d0, 0x00e0, 0x00f0, - 0x0100, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160, 0x0170, 0x0180, 0x0190, 0x01a0, 0x01b0, 0x01c0, 0x01d0, 0x01e0, 0x01f0}, - { 0x0000, 0x0011, 0x0022, 0x0033, 0x0044, 0x0055, 0x0066, 0x0077, 0x0088, 0x0099, 0x00aa, 0x00bb, 0x00cc, 0x00dd, 0x00ee, 0x00ff, - 0x0110, 0x0121, 0x0132, 0x0143, 0x0154, 0x0165, 0x0176, 0x0187, 0x0198, 0x01a9, 0x01ba, 0x01cb, 0x01dc, 0x01ed, 0x01fe, 0x020f}, - { 0x0000, 0x0012, 0x0024, 0x0036, 0x0048, 0x005a, 0x006c, 0x007e, 0x0090, 0x00a2, 0x00b4, 0x00c6, 0x00d8, 0x00ea, 0x00fc, 0x010e, - 0x0120, 0x0132, 0x0144, 0x0156, 0x0168, 0x017a, 0x018c, 0x019e, 0x01b0, 0x01c2, 0x01d4, 0x01e6, 0x01f8, 0x020a, 0x021c, 0x022e}, - { 0x0000, 0x0013, 0x0026, 0x0039, 0x004c, 0x005f, 0x0072, 0x0085, 0x0098, 0x00ab, 0x00be, 0x00d1, 0x00e4, 0x00f7, 0x010a, 0x011d, - 0x0130, 0x0143, 0x0156, 0x0169, 0x017c, 0x018f, 0x01a2, 0x01b5, 0x01c8, 0x01db, 0x01ee, 0x0201, 0x0214, 0x0227, 0x023a, 0x024d}, - { 0x0000, 0x0014, 0x0028, 0x003c, 0x0050, 0x0064, 0x0078, 0x008c, 0x00a0, 0x00b4, 0x00c8, 0x00dc, 0x00f0, 0x0104, 0x0118, 0x012c, - 0x0140, 0x0154, 0x0168, 0x017c, 0x0190, 0x01a4, 0x01b8, 0x01cc, 0x01e0, 0x01f4, 0x0208, 0x021c, 0x0230, 0x0244, 0x0258, 0x026c}, - { 0x0000, 0x0015, 0x002a, 0x003f, 0x0054, 0x0069, 0x007e, 0x0093, 0x00a8, 0x00bd, 0x00d2, 0x00e7, 0x00fc, 0x0111, 0x0126, 0x013b, - 0x0150, 0x0165, 0x017a, 0x018f, 0x01a4, 0x01b9, 0x01ce, 0x01e3, 0x01f8, 0x020d, 0x0222, 0x0237, 0x024c, 0x0261, 0x0276, 0x028b}, - { 0x0000, 0x0016, 0x002c, 0x0042, 0x0058, 0x006e, 0x0084, 0x009a, 0x00b0, 0x00c6, 0x00dc, 0x00f2, 0x0108, 0x011e, 0x0134, 0x014a, - 0x0160, 0x0176, 0x018c, 0x01a2, 0x01b8, 0x01ce, 0x01e4, 0x01fa, 0x0210, 0x0226, 0x023c, 0x0252, 0x0268, 0x027e, 0x0294, 0x02aa}, - { 0x0000, 0x0017, 0x002e, 0x0045, 0x005c, 0x0073, 0x008a, 0x00a1, 0x00b8, 0x00cf, 0x00e6, 0x00fd, 0x0114, 0x012b, 0x0142, 0x0159, - 0x0170, 0x0187, 0x019e, 0x01b5, 0x01cc, 0x01e3, 0x01fa, 0x0211, 0x0228, 0x023f, 0x0256, 0x026d, 0x0284, 0x029b, 0x02b2, 0x02c9}, - { 0x0000, 0x0018, 0x0030, 0x0048, 0x0060, 0x0078, 0x0090, 0x00a8, 0x00c0, 0x00d8, 0x00f0, 0x0108, 0x0120, 0x0138, 0x0150, 0x0168, - 0x0180, 0x0198, 0x01b0, 0x01c8, 0x01e0, 0x01f8, 0x0210, 0x0228, 0x0240, 0x0258, 0x0270, 0x0288, 0x02a0, 0x02b8, 0x02d0, 0x02e8}, - { 0x0000, 0x0019, 0x0032, 0x004b, 0x0064, 0x007d, 0x0096, 0x00af, 0x00c8, 0x00e1, 0x00fa, 0x0113, 0x012c, 0x0145, 0x015e, 0x0177, - 0x0190, 0x01a9, 0x01c2, 0x01db, 0x01f4, 0x020d, 0x0226, 0x023f, 0x0258, 0x0271, 0x028a, 0x02a3, 0x02bc, 0x02d5, 0x02ee, 0x0307}, - { 0x0000, 0x001a, 0x0034, 0x004e, 0x0068, 0x0082, 0x009c, 0x00b6, 0x00d0, 0x00ea, 0x0104, 0x011e, 0x0138, 0x0152, 0x016c, 0x0186, - 0x01a0, 0x01ba, 0x01d4, 0x01ee, 0x0208, 0x0222, 0x023c, 0x0256, 0x0270, 0x028a, 0x02a4, 0x02be, 0x02d8, 0x02f2, 0x030c, 0x0326}, - { 0x0000, 0x001b, 0x0036, 0x0051, 0x006c, 0x0087, 0x00a2, 0x00bd, 0x00d8, 0x00f3, 0x010e, 0x0129, 0x0144, 0x015f, 0x017a, 0x0195, - 0x01b0, 0x01cb, 0x01e6, 0x0201, 0x021c, 0x0237, 0x0252, 0x026d, 0x0288, 0x02a3, 0x02be, 0x02d9, 0x02f4, 0x030f, 0x032a, 0x0345}, - { 0x0000, 0x001c, 0x0038, 0x0054, 0x0070, 0x008c, 0x00a8, 0x00c4, 0x00e0, 0x00fc, 0x0118, 0x0134, 0x0150, 0x016c, 0x0188, 0x01a4, - 0x01c0, 0x01dc, 0x01f8, 0x0214, 0x0230, 0x024c, 0x0268, 0x0284, 0x02a0, 0x02bc, 0x02d8, 0x02f4, 0x0310, 0x032c, 0x0348, 0x0364}, - { 0x0000, 0x001d, 0x003a, 0x0057, 0x0074, 0x0091, 0x00ae, 0x00cb, 0x00e8, 0x0105, 0x0122, 0x013f, 0x015c, 0x0179, 0x0196, 0x01b3, - 0x01d0, 0x01ed, 0x020a, 0x0227, 0x0244, 0x0261, 0x027e, 0x029b, 0x02b8, 0x02d5, 0x02f2, 0x030f, 0x032c, 0x0349, 0x0366, 0x0383}, - { 0x0000, 0x001e, 0x003c, 0x005a, 0x0078, 0x0096, 0x00b4, 0x00d2, 0x00f0, 0x010e, 0x012c, 0x014a, 0x0168, 0x0186, 0x01a4, 0x01c2, - 0x01e0, 0x01fe, 0x021c, 0x023a, 0x0258, 0x0276, 0x0294, 0x02b2, 0x02d0, 0x02ee, 0x030c, 0x032a, 0x0348, 0x0366, 0x0384, 0x03a2}, - { 0x0000, 0x001f, 0x003e, 0x005d, 0x007c, 0x009b, 0x00ba, 0x00d9, 0x00f8, 0x0117, 0x0136, 0x0155, 0x0174, 0x0193, 0x01b2, 0x01d1, - 0x01f0, 0x020f, 0x022e, 0x024d, 0x026c, 0x028b, 0x02aa, 0x02c9, 0x02e8, 0x0307, 0x0326, 0x0345, 0x0364, 0x0383, 0x03a2, 0x03c1} -}; - -static const INT8 outLvlTbl[16][16] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}, - { 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4}, - { 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6}, - { 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8}, - { 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 9, 9, 10}, - { 0, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12}, - { 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 8, 10, 11, 12, 13, 14}, - { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, - { 0, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17}, - { 0, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19}, - { 0, 2, 3, 5, 6, 7, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21}, - { 0, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23}, - { 0, 2, 4, 5, 7, 9, 10, 12, 14, 15, 17, 18, 20, 22, 23, 25}, - { 0, 2, 4, 6, 8, 9, 11, 13, 15, 16, 18, 20, 22, 23, 25, 27}, - { 0, 2, 4, 6, 8, 10, 12, 14, 16, 17, 19, 21, 23, 25, 27, 29} -}; - -INLINE UINT8 mgetb(register UINT8 *ptr) { return *ptr; } -INLINE void mputb(UINT8 *ptr, INT8 data) { *ptr = data; } - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// vboysnd_device - constructor -//------------------------------------------------- - -vboysnd_device::vboysnd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, VBOYSND, "Virtual Boy audio", tag, owner, clock, "vboysnd", __FILE__), - device_sound_interface(mconfig, *this) -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void vboysnd_device::device_start() -{ - int i; - - // create the stream - m_stream = machine().sound().stream_alloc(*this, 0, 2, AUDIO_FREQ); - - for (i=0; i<2048; i++) - waveFreq2LenTbl[i] = AUDIO_FREQ / (5000000.0f/(float)((2048-i) * 32)); - for (i=0; i<32; i++) - waveTimer2LenTbl[i] = ((0.00384f*(float)(i+1)) * (float)AUDIO_FREQ); - for (i=0; i<8; i++) - waveEnv2LenTbl[i] = ((0.01536f*(float)(i+1)) * (float)AUDIO_FREQ); - - for (i = 0; i < 5; i++) - memset(&snd_channel[i], 0, sizeof(s_snd_channel)); - - memset(m_aram, 0, 0x600); - - m_timer = timer_alloc(0, NULL); - m_timer->adjust(attotime::zero, 0, attotime::from_hz(AUDIO_FREQ/4)); -} - - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void vboysnd_device::device_reset() -{ - m_stream->update(); - - int i; - - for (i=0; i<4; i++) - snd_channel[i].playing = false; -} - -//------------------------------------------------- -// device_timer - called when our device timer expires -//------------------------------------------------- - -void vboysnd_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr) -{ - m_stream->update(); -} - -//------------------------------------------------- -// sound_stream_update - handle update requests for -// our sound stream -//------------------------------------------------- - -void vboysnd_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t *outL, *outR; - int len, i, j, channel; - - outL = outputs[0]; - outR = outputs[1]; - - len = samples; - -// if (mgetb(m_aram+SST0P) & 0x1) // Sound Stop Reg -// goto end; - - for (channel=0; channel<5; channel++) - { - float size; - int k = 0, waveAddr; - - i = channel * 0x40; - snd_channel[channel].sample_len = waveFreq2LenTbl[((mgetb(m_aram+SxFQHb+i) & 0x7) << 8) | mgetb(m_aram+SxFQLb+i)]; - waveAddr = (mgetb(m_aram + SxRAMb + i) & 0x3) << 7; - - size = (float)snd_channel[channel].sample_len / 32.0f; - for (j=0; j<32;) - { - INT8 byte = mgetb(m_aram + waveAddr + (j++ << 2)) & 0x3f; -// INT8 nbyte = mgetb(m_aram + waveAddr + (j << 2)) & 0x3f; - int end = (int)(((float)j)*size); - float val, add; - - val = (float)byte; - add = /*(nbyte-byte)/(end-k)*/ 0.0; // no interpolation - - for (; k<end; k++, val+=add) - { -#ifdef LAME_COMPILER_BUG - if ((INT32)&snd_channel[channel].sample[k] == (INT32)&snd_channel[channel].offset) - Debugger(); -#endif - snd_channel[channel].sample[k] = ((UINT8)val); - } - } - } - - for (j=0; j<len; j++) - { - INT32 note_left = 0; - INT32 note_right = 0; - - // process first 4 sound channels - for (i=0; i</*5*/5; i++) - { - UINT8 outLeft, outRight; - const INT16 *outTblPtr; -// UINT8 env0, env1; - s_snd_channel *channel = &snd_channel[i]; - - if (!channel->playing) - continue; - - outLeft = outLvlTbl[channel->volLeft][channel->envelope]; - outRight = outLvlTbl[channel->volRight][channel->envelope]; -// env1 = ((UINT8)mgetb(m_aram+SxEV1b+i*0x40)); - if (channel->env1 & 0x01) - { - channel->env_time++; - -// env0 = ((UINT8)mgetb(m_aram+SxEV0b+i*0x40)); - if (channel->env_time >= channel->env_steptime /*waveEnv2LenTbl[env0 & 0x7]*/) - { - // it's time for a step - channel->env_time = 0; - if (channel->env0 & 0x08) - { - // step up - channel->envelope++; - if (channel->envelope >= 0xf) - { - if (channel->env1 & 0x02) channel->envelope = channel->env0 >> 4; - else { channel->env1 &= ~0x01; channel->envelope = 0xf; } - } - } - else - { - // step down - channel->envelope--; - if (channel->envelope <= 0) - { - if (channel->env1 & 0x02) channel->envelope = channel->env0 >> 4; - else { channel->env1 &= ~0x01; channel->envelope = 0x0; } - } - } - } - } - - outTblPtr = (INT16 *) outTbl[channel->sample[channel->offset]]; - if (outLeft) note_left += outTblPtr[outLeft ]; - if (outRight) note_right += outTblPtr[outRight]; - channel->offset++; - - if (channel->offset >= channel->sample_len) - channel->offset = 0; - - if (channel->time > 0) - { - channel->time--; - if (channel->time <= 0) - channel->playing = false; - } - } - - - // scale to 16 bits - note_left = (note_left << 5) | ((note_left >> 6) & 0x1f); - note_right = (note_right << 5) | ((note_right >> 6) & 0x1f); - if (note_left < -32767) note_left = -32767; if (note_left > 32767) note_left = 32767; - if (note_right < -32767) note_right = -32767; if (note_right > 32767) note_right = 32767; - - *(outL++) = ((INT16)note_left); - *(outR++) = ((INT16)note_right); - } -} - -//------------------------------------------------- -// read - read from the chip's registers and internal RAM -//------------------------------------------------- - -READ8_MEMBER( vboysnd_device::read ) -{ - m_stream->update(); - return m_aram[offset]; -} - -//------------------------------------------------- -// write - write to the chip's registers and internal RAM -//------------------------------------------------- - -WRITE8_MEMBER( vboysnd_device::write ) -{ - int freq, i; -// int waveAddr; - int volReg, intervalReg; - int channel, ouroffs; - - mputb((UINT8 *)m_aram+offset, data); - if (offset < 0x400) - return; - - channel = (offset-0x400) >> 6; - ouroffs = offset & 0x3f; - - ///process_sound(cpu.vcount); - - if (channel == 6 && ouroffs == 0) - { - if (mgetb(m_aram+SST0P) & 0x1) - for (i=0; i<4; i++) - snd_channel[i].playing = 0; - return; - } - - // Extract frequencies and build the wave for the first 4 sound sources - i = channel * 0x40; - switch (ouroffs) - { - case SxLRV: - if (channel < 5) - { - volReg = mgetb(m_aram + SxLRVb + i); // 6-4-4 - L/R output level setting - if (snd_channel[channel].playing) - { - snd_channel[channel].volLeft = ((UINT8)volReg) >> 4; - snd_channel[channel].volRight = ((UINT8)volReg) & 0xf; - break; - } - } - case SxINT: - if (channel < 5) - { - UINT8 env0, env1; - // find out if the sound is playing - intervalReg = mgetb(m_aram + SxINTb + i); // 6-4-6 - Sound Interval - volReg = mgetb(m_aram + SxLRVb + i); // 6-4-4 - L/R output level setting - - if (((intervalReg & 0x80) == 0) || (volReg == 0)) - { - snd_channel[channel].playing = false; - return; - } - snd_channel[channel].playing = true; - - // 6-4-1 - Waveform address comes from SxRAM. -// waveAddr = (mgetb(m_aram + SxRAMb + i) & 0x3) << 7; - - // 6-4-15 - Frequency comes from here - freq = ((mgetb(m_aram+SxFQHb+i) & 0x7) << 8) | mgetb(m_aram+SxFQLb+i); - - env0 = mgetb(m_aram+SxEV0b+i); env1 = mgetb(m_aram+SxEV1b+i); - snd_channel[channel].env0 = env0; - snd_channel[channel].env1 = env1; - snd_channel[channel].volLeft = ((UINT8)volReg) >> 4; - snd_channel[channel].volRight = ((UINT8)volReg) & 0xf; - snd_channel[channel].env_steptime = (env1 & 0x1) ? waveEnv2LenTbl[env0 & 0x7] : 0; - snd_channel[channel].sample_len = waveFreq2LenTbl[freq]; - - snd_channel[channel].offset = 0; - snd_channel[channel].time = (intervalReg & 0x20) ? waveTimer2LenTbl[intervalReg & 0x1f] : 0; - snd_channel[channel].envelope = ((UINT8)mgetb(m_aram+SxEV0b+i)) >> 4; - snd_channel[channel].env_time = 0; - } - else - { - intervalReg = mgetb(m_aram + SxINTb + i); // 6-4-6 - Sound Interval - volReg = mgetb(m_aram + SxLRVb + i); // 6-4-4 - L/R output level setting - - if (((intervalReg & 0x80) == 0) || (volReg == 0)) - { -// snd_channel[channel].playing = false; - return; - } -// Debugger(); // uses white noise -// snd_channel[channel].playing = true; - } - break; - - case SxEV0: - if (channel < 5) - if (snd_channel[channel].playing) - snd_channel[channel].envelope = ((UINT8)mgetb(m_aram+SxEV0b+i)) >> 4; - break; - } -} diff --git a/src/mess/audio/vboy.h b/src/mess/audio/vboy.h deleted file mode 100644 index 8849ecf292e..00000000000 --- a/src/mess/audio/vboy.h +++ /dev/null @@ -1,108 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:R. Belmont -/* - vboy.h - Virtual Boy audio emulation - - By Richard Bannister and Gil Pedersen. - MESS device adaptation by R. Belmont -*/ - -#pragma once - -#ifndef __VBOY_SND_H__ -#define __VBOY_SND_H__ - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -#define AUDIO_FREQ 44100 -#define CHANNELS 4 - -//************************************************************************** -// INTERFACE CONFIGURATION MACROS -//************************************************************************** - -#define MCFG_VBOYSND_ADD(_tag) \ - MCFG_DEVICE_ADD(_tag, VBOYSND, AUDIO_FREQ) - -#define MCFG_VBOYSND_REPLACE(_tag) \ - MCFG_DEVICE_REPLACE(_tag, VBOYSND, AUDIO_FREQ) - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -struct s_snd_channel { - INT8 playing; // the sound is playing - - // state when sound was enabled - UINT32 env_steptime; // Envelope step time - UINT8 env0; // Envelope data - UINT8 env1; // Envelope data - UINT8 volLeft; // Left output volume - UINT8 volRight; // Right output volume - UINT8 sample[580]; // sample to play - int sample_len; // length of sample - - // values that change, as the sample is played - int offset; // current offset in sample - int time; // the duration that this sample is to be played - UINT8 envelope; // Current envelope level (604) - int env_time; // The duration between envelope decay/grow (608) -}; - -struct s_regchan { - INT32 sINT; - INT32 sLRV; - INT32 sFQL; - INT32 sFQH; - INT32 sEV0; - INT32 sEV1; - INT32 sRAM; -}; - -struct s_sreg { - // Sound registers structure - s_regchan c[4]; -}; - -// ======================> vboysnd_device - -class vboysnd_device : public device_t, public device_sound_interface -{ -public: - // construction/destruction - vboysnd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - DECLARE_READ8_MEMBER(read); - DECLARE_WRITE8_MEMBER(write); - - sound_stream *m_stream; - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - - // inline data - s_sreg sound_registers(void); - - s_snd_channel snd_channel[5]; - - UINT16 waveFreq2LenTbl[2048]; - UINT16 waveTimer2LenTbl[32]; - UINT16 waveEnv2LenTbl[8]; - - emu_timer *m_timer; - - UINT8 m_aram[0x600]; -}; - -// device type definition -extern const device_type VBOYSND; - -#endif //__VBOY_SND_H__ diff --git a/src/mess/audio/vc4000snd.c b/src/mess/audio/vc4000snd.c deleted file mode 100644 index 00b33d308ae..00000000000 --- a/src/mess/audio/vc4000snd.c +++ /dev/null @@ -1,74 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/*************************************************************************** - - PeT mess@utanet.at - main part in video/ - -***************************************************************************/ - -#include "vc4000snd.h" - - -const device_type VC4000_SND = &device_creator<vc4000_sound_device>; - -vc4000_sound_device::vc4000_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, VC4000_SND, "Intertion Electronic VC 4000 Audio Custom", tag, owner, clock, "vc4000_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_channel(NULL), - m_size(0), - m_pos(0), - m_level(0) -{ - memset(m_reg, 0, sizeof(UINT8)*1); -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void vc4000_sound_device::device_start() -{ - m_channel = stream_alloc(0, 1, machine().sample_rate()); -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void vc4000_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - int i; - stream_sample_t *buffer = outputs[0]; - - for (i = 0; i < samples; i++, buffer++) - { - *buffer = 0; - if (m_reg[0] && m_pos <= m_size / 2) - { - *buffer = 0x7fff; - } - if (m_pos <= m_size) - m_pos++; - if (m_pos > m_size) - m_pos = 0; - } -} - - -void vc4000_sound_device::soundport_w(int offset, int data) -{ - m_channel->update(); - m_reg[offset] = data; - switch (offset) - { - case 0: - m_pos = 0; - m_level = TRUE; - // frequency 7874/(data+1) - m_size = machine().sample_rate() * (data + 1) /7874; - break; - } -} diff --git a/src/mess/audio/vc4000snd.h b/src/mess/audio/vc4000snd.h deleted file mode 100644 index 611ad0188d8..00000000000 --- a/src/mess/audio/vc4000snd.h +++ /dev/null @@ -1,47 +0,0 @@ -// license:GPL-2.0+ -// copyright-holders:Peter Trauner -/***************************************************************************** - * - * includes/vc4000snd.h - * - ****************************************************************************/ - -#ifndef _VC4000SND_H_ -#define _VC4000SND_H_ - -#include "emu.h" - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> vc4000_sound_device - -class vc4000_sound_device : public device_t, - public device_sound_interface -{ -public: - vc4000_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~vc4000_sound_device() { } - -protected: - // device-level overrides - virtual void device_start(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -public: - void soundport_w(int mode, int data); - -private: - sound_stream *m_channel; - UINT8 m_reg[1]; - int m_size; - int m_pos; - unsigned m_level; -}; - -extern const device_type VC4000_SND; - -#endif /* _VC4000SND_H_ */ diff --git a/src/mess/audio/wswan_snd.c b/src/mess/audio/wswan_snd.c deleted file mode 100644 index 77a21d7cb3b..00000000000 --- a/src/mess/audio/wswan_snd.c +++ /dev/null @@ -1,374 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/************************************************************************************** - - Wonderswan sound emulation - - Wilbert Pol - - Sound emulation is preliminary and not complete - - -The noise taps and behavior are the same as the Virtual Boy. - -**************************************************************************************/ - -#include "wswan_snd.h" - - -// device type definition -const device_type WSWAN_SND = &device_creator<wswan_sound_device>; - - -//************************************************************************** -// LIVE DEVICE -//************************************************************************** - -//------------------------------------------------- -// wswan_sound_device - constructor -//------------------------------------------------- - -wswan_sound_device::wswan_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, WSWAN_SND, "WonderSwan Audio Custom", tag, owner, clock, "wswan_sound", __FILE__), - device_sound_interface(mconfig, *this), - m_channel(NULL), - m_sweep_step(0), - m_sweep_time(0), - m_sweep_count(0), - m_noise_type(0), - m_noise_reset(0), - m_noise_enable(0), - m_sample_address(0), - m_audio2_voice(0), - m_audio3_sweep(0), - m_audio4_noise(0), - m_mono(0), - m_voice_data(0), - m_output_volume(0), - m_external_stereo(0), - m_external_speaker(0), - m_noise_shift(0), - m_master_volume(0) -{ -} - - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void wswan_sound_device::device_start() -{ - m_channel = stream_alloc(0, 2, machine().sample_rate()); - - save_item(NAME(m_sweep_step)); - save_item(NAME(m_sweep_time)); - save_item(NAME(m_sweep_count)); - save_item(NAME(m_noise_type)); - save_item(NAME(m_noise_reset)); - save_item(NAME(m_noise_enable)); - save_item(NAME(m_sample_address)); - save_item(NAME(m_audio2_voice)); - save_item(NAME(m_audio3_sweep)); - save_item(NAME(m_audio4_noise)); - save_item(NAME(m_mono)); - save_item(NAME(m_voice_data)); - save_item(NAME(m_output_volume)); - save_item(NAME(m_external_stereo)); - save_item(NAME(m_external_speaker)); - save_item(NAME(m_noise_shift)); - save_item(NAME(m_master_volume)); - - save_item(NAME(m_audio1.freq)); - save_item(NAME(m_audio1.period)); - save_item(NAME(m_audio1.pos)); - save_item(NAME(m_audio1.vol_left)); - save_item(NAME(m_audio1.vol_right)); - save_item(NAME(m_audio1.on)); - save_item(NAME(m_audio1.signal)); - - save_item(NAME(m_audio2.freq)); - save_item(NAME(m_audio2.period)); - save_item(NAME(m_audio2.pos)); - save_item(NAME(m_audio2.vol_left)); - save_item(NAME(m_audio2.vol_right)); - save_item(NAME(m_audio2.on)); - save_item(NAME(m_audio2.signal)); - - save_item(NAME(m_audio3.freq)); - save_item(NAME(m_audio3.period)); - save_item(NAME(m_audio3.pos)); - save_item(NAME(m_audio3.vol_left)); - save_item(NAME(m_audio3.vol_right)); - save_item(NAME(m_audio3.on)); - save_item(NAME(m_audio3.signal)); - - save_item(NAME(m_audio4.freq)); - save_item(NAME(m_audio4.period)); - save_item(NAME(m_audio4.pos)); - save_item(NAME(m_audio4.vol_left)); - save_item(NAME(m_audio4.vol_right)); - save_item(NAME(m_audio4.on)); - save_item(NAME(m_audio4.signal)); -} - - -//------------------------------------------------- -// device_reset -//------------------------------------------------- - -void wswan_sound_device::device_reset() -{ - m_audio1.on = 0; - m_audio1.signal = 16; - m_audio1.pos = 0; - m_audio2.on = 0; - m_audio2.signal = 16; - m_audio2.pos = 0; - m_audio3.on = 0; - m_audio3.signal = 16; - m_audio3.pos = 0; - m_audio4.on = 0; - m_audio4.signal = 16; - m_audio4.pos = 0; -} - - -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void wswan_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) -{ - stream_sample_t sample, left, right; - - while( samples-- > 0 ) - { - left = right = 0; - - if ( m_audio1.on ) - { - sample = m_audio1.signal; - m_audio1.pos++; - if ( m_audio1.pos >= m_audio1.period / 2 ) - { - m_audio1.pos = 0; - m_audio1.signal = -m_audio1.signal; - } - left += m_audio1.vol_left * sample; - right += m_audio1.vol_right * sample; - } - - if ( m_audio2.on ) - { - if ( m_audio2_voice ) - { - left += (m_voice_data - 128)*(m_master_volume & 0x0f); - right += (m_voice_data - 128)*(m_master_volume & 0x0f); - } - else - { - sample = m_audio2.signal; - m_audio2.pos++; - if ( m_audio2.pos >= m_audio2.period / 2 ) - { - m_audio2.pos = 0; - m_audio2.signal = -m_audio2.signal; - } - left += m_audio2.vol_left * sample; - right += m_audio2.vol_right * sample; - } - } - - if ( m_audio3.on ) - { - sample = m_audio3.signal; - m_audio3.pos++; - if ( m_audio3.pos >= m_audio3.period / 2 ) - { - m_audio3.pos = 0; - m_audio3.signal = -m_audio3.signal; - } - if ( m_audio3_sweep && m_sweep_time ) - { - m_sweep_count++; - if ( m_sweep_count >= m_sweep_time ) - { - m_sweep_count = 0; - m_audio3.freq += m_sweep_step; - m_audio3.period = machine().sample_rate() / (3072000 / ((2048 - (m_audio3.freq & 0x7ff)) << 5)); - } - } - left += m_audio3.vol_left * sample; - right += m_audio3.vol_right * sample; - } - - if ( m_audio4.on ) - { - sample = m_audio4.signal; - m_audio4.pos++; - if ( m_audio4.pos >= m_audio4.period / 2 ) - { - m_audio4.signal = -m_audio4.signal; - m_audio4.pos = 0; - - if (m_noise_enable) - { - UINT16 new_bit = 0; - - if (m_noise_type == 0) - { - new_bit = (m_noise_shift ^ (m_noise_shift >> 5) ^ (m_noise_shift >> 8)) & 1; - } - else - { - static int shift_bit[] = { 0, 10, 13, 4, 8, 6, 9, 11 }; - - new_bit = (1 ^ (m_noise_shift >> 7) ^ (m_noise_shift >> shift_bit[m_noise_type])) & 1; - } - m_noise_shift = (m_noise_shift << 1) | new_bit; - - if (m_audio4_noise) - { - m_audio4.signal = (m_noise_shift & 0x8000) ? 16 : -16; - } - - m_noise_shift &= 0x7fff; - - if (m_noise_shift == 0x7fff) - { - m_noise_shift = (m_noise_type == 0) ? 0x80 : 0; - } - } - } - left += m_audio4.vol_left * sample; - right += m_audio4.vol_right * sample; - } - - left <<= 5; - right <<= 5; - - *(outputs[0]++) = left; - *(outputs[1]++) = right; - } -} - - -void wswan_sound_device::wswan_ch_set_freq( CHAN *ch, UINT16 freq ) -{ - freq &= 0x7ff; // docs say freq is 11bits and a few games (Morita Shougi, World Stadium + others) write 0x800 causing a divide by 0 crash - ch->freq = freq; - ch->period = machine().sample_rate() / (3072000 / ((2048 - freq) << 5)); -} - -WRITE8_MEMBER( wswan_sound_device::port_w ) -{ - m_channel->update(); - - switch( offset ) - { - case 0x80: /* Audio 1 freq (lo) */ - wswan_ch_set_freq(&m_audio1, (m_audio1.freq & 0xff00) | data); - break; - - case 0x81: /* Audio 1 freq (hi) */ - wswan_ch_set_freq(&m_audio1, (data << 8 ) | (m_audio1.freq & 0x00ff)); - break; - - case 0x82: /* Audio 2 freq (lo) */ - wswan_ch_set_freq(&m_audio2, (m_audio2.freq & 0xff00) | data); - break; - - case 0x83: /* Audio 2 freq (hi) */ - wswan_ch_set_freq(&m_audio2, (data << 8 ) | (m_audio2.freq & 0x00ff)); - break; - - case 0x84: /* Audio 3 freq (lo) */ - wswan_ch_set_freq(&m_audio3, (m_audio3.freq & 0xff00) | data); - break; - - case 0x85: /* Audio 3 freq (hi) */ - wswan_ch_set_freq(&m_audio3, (data << 8) | (m_audio3.freq & 0x00ff)); - break; - - case 0x86: /* Audio 4 freq (lo) */ - wswan_ch_set_freq(&m_audio4, (m_audio4.freq & 0xff00) | data); - break; - - case 0x87: /* Audio 4 freq (hi) */ - wswan_ch_set_freq(&m_audio4, (data << 8) | (m_audio4.freq & 0x00ff)); - break; - - case 0x88: /* Audio 1 volume */ - m_audio1.vol_left = ( data & 0xF0 ) >> 4; - m_audio1.vol_right = data & 0x0F; - break; - - case 0x89: /* Audio 2 volume */ - m_voice_data = data; - m_audio2.vol_left = ( data & 0xF0 ) >> 4; - m_audio2.vol_right = data & 0x0F; - break; - - case 0x8A: /* Audio 3 volume */ - m_audio3.vol_left = ( data & 0xF0 ) >> 4; - m_audio3.vol_right = data & 0x0F; - break; - - case 0x8B: /* Audio 4 volume */ - m_audio4.vol_left = ( data & 0xF0 ) >> 4; - m_audio4.vol_right = data & 0x0F; - break; - - case 0x8C: /* Sweep step */ - m_sweep_step = (INT8)data; - break; - - case 0x8D: /* Sweep time */ - m_sweep_time = space.machine().sample_rate() / ( 3072000 / ( 8192 * (data + 1) ) ); - break; - - case 0x8E: /* Noise control */ - m_noise_type = data & 0x07; - m_noise_reset = ( data & 0x08 ) >> 3; - m_noise_enable = ( data & 0x10 ) >> 4; - if (m_noise_reset) - { - m_noise_shift = (m_noise_type == 0) ? 0x80 : 0; - } - break; - - case 0x8F: /* Sample location */ - m_sample_address = data << 6; - break; - - case 0x90: /* Audio control */ - m_audio1.on = data & 0x01; - m_audio2.on = ( data & 0x02 ) >> 1; - m_audio3.on = ( data & 0x04 ) >> 2; - m_audio4.on = ( data & 0x08 ) >> 3; - m_audio2_voice = ( data & 0x20 ) >> 5; - m_audio3_sweep = ( data & 0x40 ) >> 6; - m_audio4_noise = ( data & 0x80 ) >> 7; - break; - - case 0x91: /* Audio output */ - m_mono = data & 0x01; - m_output_volume = ( data & 0x06 ) >> 1; - m_external_stereo = ( data & 0x08 ) >> 3; - m_external_speaker = 1; - break; - - case 0x92: /* Noise counter shift register (lo) */ - m_noise_shift = ( m_noise_shift & 0xFF00 ) | data; - break; - - case 0x93: /* Noise counter shift register (hi) */ - m_noise_shift = ( ( data & 0x7f ) << 8 ) | ( m_noise_shift & 0x00FF ); - break; - - case 0x94: /* Master volume */ - m_master_volume = data; - break; - } -} diff --git a/src/mess/audio/wswan_snd.h b/src/mess/audio/wswan_snd.h deleted file mode 100644 index 42ba3ed5160..00000000000 --- a/src/mess/audio/wswan_snd.h +++ /dev/null @@ -1,91 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Wilbert Pol -/***************************************************************************** - * - * includes/wswan_snd.h - * - ****************************************************************************/ - -#pragma once - -#ifndef _WSWAN_SND_H_ -#define _WSWAN_SND_H_ - -#include "emu.h" - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -struct CHAN -{ - CHAN() : - freq(0), - period(0), - pos(0), - vol_left(0), - vol_right(0), - on(0), - signal(0) { } - - UINT16 freq; /* frequency */ - UINT32 period; /* period */ - UINT32 pos; /* position */ - UINT8 vol_left; /* volume left */ - UINT8 vol_right; /* volume right */ - UINT8 on; /* on/off */ - INT8 signal; /* signal */ -}; - - -// ======================> wswan_sound_device - -class wswan_sound_device : public device_t, - public device_sound_interface -{ -public: - wswan_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~wswan_sound_device() { } - -protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); - - // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); - -public: - DECLARE_WRITE8_MEMBER( port_w ); - -private: - void wswan_ch_set_freq( CHAN *ch, UINT16 freq ); - -private: - sound_stream *m_channel; - CHAN m_audio1; /* Audio channel 1 */ - CHAN m_audio2; /* Audio channel 2 */ - CHAN m_audio3; /* Audio channel 3 */ - CHAN m_audio4; /* Audio channel 4 */ - INT8 m_sweep_step; /* Sweep step */ - UINT32 m_sweep_time; /* Sweep time */ - UINT32 m_sweep_count; /* Sweep counter */ - UINT8 m_noise_type; /* Noise generator type */ - UINT8 m_noise_reset; /* Noise reset */ - UINT8 m_noise_enable; /* Noise enable */ - UINT16 m_sample_address; /* Sample address */ - UINT8 m_audio2_voice; /* Audio 2 voice */ - UINT8 m_audio3_sweep; /* Audio 3 sweep */ - UINT8 m_audio4_noise; /* Audio 4 noise */ - UINT8 m_mono; /* mono */ - UINT8 m_voice_data; /* voice data */ - UINT8 m_output_volume; /* output volume */ - UINT8 m_external_stereo; /* external stereo */ - UINT8 m_external_speaker; /* external speaker */ - UINT16 m_noise_shift; /* Noise counter shift register */ - UINT8 m_master_volume; /* Master volume */ -}; - -extern const device_type WSWAN_SND; - -#endif diff --git a/src/mess/drivers/4004clk.c b/src/mess/drivers/4004clk.c deleted file mode 100644 index 0d750822b7c..00000000000 --- a/src/mess/drivers/4004clk.c +++ /dev/null @@ -1,193 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Miodrag Milanovic -/*************************************************************************** - - 4004 Nixie Clock - - 03/08/2009 Initial driver - -****************************************************************************/ - -#include "emu.h" -#include "cpu/i4004/i4004.h" -#include "sound/dac.h" -#include "4004clk.lh" - -class nixieclock_state : public driver_device -{ -public: - nixieclock_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_dac(*this, "dac"), - m_input(*this, "INPUT") - { } - - required_device<i4004_cpu_device> m_maincpu; - required_device<dac_device> m_dac; - required_ioport m_input; - DECLARE_READ8_MEMBER( data_r ); - DECLARE_WRITE8_MEMBER( nixie_w ); - DECLARE_WRITE8_MEMBER( neon_w ); - DECLARE_WRITE8_MEMBER( relays_w ); - UINT16 m_nixie[16]; - UINT8 m_timer; - virtual void machine_start(); - TIMER_DEVICE_CALLBACK_MEMBER(timer_callback); - UINT8 nixie_to_num(UINT16 val); - inline void output_set_nixie_value(int index, int value); - inline void output_set_neon_value(int index, int value); -}; - -READ8_MEMBER(nixieclock_state::data_r) -{ - return m_input->read() & 0x0f; -} - -UINT8 nixieclock_state::nixie_to_num(UINT16 val) -{ - if (BIT(val,0)) return 0; - if (BIT(val,1)) return 1; - if (BIT(val,2)) return 2; - if (BIT(val,3)) return 3; - if (BIT(val,4)) return 4; - if (BIT(val,5)) return 5; - if (BIT(val,6)) return 6; - if (BIT(val,7)) return 7; - if (BIT(val,8)) return 8; - if (BIT(val,9)) return 9; - return 10; -} - -inline void nixieclock_state::output_set_nixie_value(int index, int value) -{ - output_set_indexed_value("nixie", index, value); -} - -inline void nixieclock_state::output_set_neon_value(int index, int value) -{ - output_set_indexed_value("neon", index, value); -} - -WRITE8_MEMBER(nixieclock_state::nixie_w) -{ - m_nixie[offset] = data; - output_set_nixie_value(5,nixie_to_num(((m_nixie[2] & 3)<<8) | (m_nixie[1] << 4) | m_nixie[0])); - output_set_nixie_value(4,nixie_to_num((m_nixie[4] << 6) | (m_nixie[3] << 2) | (m_nixie[2] >>2))); - output_set_nixie_value(3,nixie_to_num(((m_nixie[7] & 3)<<8) | (m_nixie[6] << 4) | m_nixie[5])); - output_set_nixie_value(2,nixie_to_num((m_nixie[9] << 6) | (m_nixie[8] << 2) | (m_nixie[7] >>2))); - output_set_nixie_value(1,nixie_to_num(((m_nixie[12] & 3)<<8) | (m_nixie[11] << 4) | m_nixie[10])); - output_set_nixie_value(0,nixie_to_num((m_nixie[14] << 6) | (m_nixie[13] << 2) | (m_nixie[12] >>2))); -} - -WRITE8_MEMBER(nixieclock_state::neon_w) -{ - output_set_neon_value(0,BIT(data,3)); - output_set_neon_value(1,BIT(data,2)); - output_set_neon_value(2,BIT(data,1)); - output_set_neon_value(3,BIT(data,0)); -} - -WRITE8_MEMBER(nixieclock_state::relays_w) -{ - m_dac->write_unsigned8((data & 1) ? 0x80 : 0x40); //tick - tock -} - -static ADDRESS_MAP_START(4004clk_rom, AS_PROGRAM, 8, nixieclock_state) - AM_RANGE(0x0000, 0x0FFF) AM_ROM -ADDRESS_MAP_END - -static ADDRESS_MAP_START(4004clk_mem, AS_DATA, 8, nixieclock_state) - ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x0000, 0x007F) AM_RAM -ADDRESS_MAP_END - -static ADDRESS_MAP_START( 4004clk_io, AS_IO, 8, nixieclock_state) - ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x00, 0x0e) AM_WRITE(nixie_w) - AM_RANGE(0x00, 0x00) AM_READ(data_r) - AM_RANGE(0x0f, 0x0f) AM_WRITE(neon_w) - AM_RANGE(0x10, 0x10) AM_WRITE(relays_w) -ADDRESS_MAP_END - -/* Input ports */ -static INPUT_PORTS_START( 4004clk ) - PORT_START("INPUT") - PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Select") PORT_CODE(KEYCODE_1) - PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("Browse") PORT_CODE(KEYCODE_2) - - PORT_CONFNAME( 0x04, 0x00, "Tick-Tock") - PORT_CONFSETTING( 0x00, "ON" ) - PORT_CONFSETTING( 0x04, "OFF" ) - PORT_CONFNAME( 0x08, 0x08, "50/60 Hz") - PORT_CONFSETTING( 0x00, "50 Hz" ) - PORT_CONFSETTING( 0x08, "60 Hz" ) -INPUT_PORTS_END - -/* - 16ms Int generator - __ __ - _| |_| - 0 1 0 1 - -*/ - -TIMER_DEVICE_CALLBACK_MEMBER(nixieclock_state::timer_callback) -{ - m_maincpu->set_test(m_timer); - m_timer^=1; -} - -void nixieclock_state::machine_start() -{ - m_timer = 0; - - /* register for state saving */ - save_item(NAME(m_timer)); - save_pointer(NAME(m_nixie), 6); -} - -static MACHINE_CONFIG_START( 4004clk, nixieclock_state ) - - /* basic machine hardware */ - MCFG_CPU_ADD("maincpu",I4004, XTAL_5MHz / 8) - MCFG_CPU_PROGRAM_MAP(4004clk_rom) - MCFG_CPU_DATA_MAP(4004clk_mem) - MCFG_CPU_IO_MAP(4004clk_io) - - /* video hardware */ - MCFG_DEFAULT_LAYOUT(layout_4004clk) - - /* sound hardware */ - MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("dac", DAC, 0) - MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - - MCFG_TIMER_DRIVER_ADD_PERIODIC("4004clk_timer", nixieclock_state, timer_callback, attotime::from_hz(120)) -MACHINE_CONFIG_END - -/* ROM definition */ -ROM_START( 4004clk ) - ROM_REGION( 0x1000, "maincpu", ROMREGION_ERASEFF ) - ROM_LOAD( "clock.u30", 0x0000, 0x0100, CRC(3d8608a5) SHA1(47fa0a91779e1afc34592f91068f8af2e74593d4)) - ROM_LOAD( "clock.u31", 0x0100, 0x0100, CRC(c83af4bc) SHA1(c8bd7ff1322e5ad280364ed87fc9e2ed38120c21)) - ROM_LOAD( "clock.u32", 0x0200, 0x0100, CRC(72442ae7) SHA1(dc25269cf9db7a9e70a86fededeb01efecf80fe7)) - ROM_LOAD( "clock.u33", 0x0300, 0x0100, CRC(74789383) SHA1(ca5ef2c42dae1761599ead56498fb0bfa0db80a5)) - ROM_LOAD( "clock.u34", 0x0400, 0x0100, CRC(d817cc54) SHA1(a54e744465dde20d37ba54bf2bdb1c4708235f9a)) - ROM_LOAD( "clock.u35", 0x0500, 0x0100, CRC(ece36d21) SHA1(c8cf7e08e90463e910ed2d21d8e562e73d7e0b08)) - ROM_LOAD( "clock.u36", 0x0600, 0x0100, CRC(65aa3cb1) SHA1(9b134bd46747a1bccc004c347b3162e9dc846426)) - ROM_LOAD( "clock.u37", 0x0700, 0x0100, CRC(4c2a2632) SHA1(5f75c2d67571ffcfb98f37944f7f4bc7f531c109)) - ROM_LOAD( "clock.u38", 0x0800, 0x0100, CRC(133da0d6) SHA1(08863a287471c0e77f27cea087cb4a3b372d49c1)) - ROM_LOAD( "clock.u39", 0x0900, 0x0100, CRC(0628593c) SHA1(34249753056cd425e0d48c188c830d64464006c9)) - ROM_LOAD( "clock.u40", 0x0A00, 0x0100, CRC(1c2e94b5) SHA1(89e6c70b936fd9882a229de671dcada7c39b9e8e)) - ROM_LOAD( "clock.u41", 0x0B00, 0x0100, CRC(48b4510d) SHA1(17c5eedc36b469bfae23e204c614ccc01bd4df02)) - ROM_LOAD( "clock.u42", 0x0C00, 0x0100, CRC(4b768675) SHA1(8862b9911bd5907e679539c1e98921f0686b8a76)) - ROM_LOAD( "clock.u43", 0x0D00, 0x0100, CRC(df8db80f) SHA1(34ef8e9ae9fd4e88659e1e14759a2baf1cf589a5)) - ROM_LOAD( "clock.u44", 0x0E00, 0x0100, CRC(23037c71) SHA1(87702bdf5985fa58d4cabcc0d4530e229bfebcbb)) - ROM_LOAD( "clock.u45", 0x0F00, 0x0100, CRC(a8d419ef) SHA1(86742a5ad410c027e9cf9a95e2006dc1128715e5)) -ROM_END - -/* Driver */ - -/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ -SYST( 2008, 4004clk, 0, 0, 4004clk, 4004clk, driver_device, 0, "John L. Weinrich", "4004 Nixie Clock", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mess/drivers/68ksbc.c b/src/mess/drivers/68ksbc.c deleted file mode 100644 index 2ff1bc85cac..00000000000 --- a/src/mess/drivers/68ksbc.c +++ /dev/null @@ -1,98 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Robbbert -/*************************************************************************** - - Skeleton driver for 68k Single Board Computer - - 29/03/2011 - - http://www.kmitl.ac.th/~kswichit/68k/68k.html - - TODO: - - Add RTC (type DS12887) - - All of the address and i/o decoding is done by a pair of XC9536 - mask-programmed custom devices. - - There are some chips used for unclear purposes (GPI, GPO, LCD). - - This computer has no sound, and no facility for saving or loading programs. - - When started, press ? key for a list of commands. - - Has 1MB of flash (which is actually just 12k of program), - and 1MB of RAM. Memory map should probably be corrected. - - -****************************************************************************/ - -#include "bus/rs232/rs232.h" -#include "cpu/m68000/m68000.h" -#include "machine/6850acia.h" -#include "machine/clock.h" - - -class c68ksbc_state : public driver_device -{ -public: - c68ksbc_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_acia(*this, "acia") - { - } - - DECLARE_WRITE_LINE_MEMBER(write_acia_clock); - -private: - required_device<cpu_device> m_maincpu; - required_device<acia6850_device> m_acia; -}; - -static ADDRESS_MAP_START(c68ksbc_mem, AS_PROGRAM, 16, c68ksbc_state) - ADDRESS_MAP_UNMAP_HIGH - AM_RANGE(0x000000, 0x002fff) AM_ROM - AM_RANGE(0x003000, 0x5fffff) AM_RAM - AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("acia", acia6850_device, status_r, control_w, 0x00ff) - AM_RANGE(0x600002, 0x600003) AM_DEVREADWRITE8("acia", acia6850_device, data_r, data_w, 0x00ff) -ADDRESS_MAP_END - - -/* Input ports */ -static INPUT_PORTS_START( c68ksbc ) -INPUT_PORTS_END - - -WRITE_LINE_MEMBER(c68ksbc_state::write_acia_clock) -{ - m_acia->write_txc(state); - m_acia->write_rxc(state); -} - -static MACHINE_CONFIG_START( c68ksbc, c68ksbc_state ) - /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", M68000, 8000000) // text says 8MHz, schematic says 10MHz - MCFG_CPU_PROGRAM_MAP(c68ksbc_mem) - - MCFG_DEVICE_ADD("acia", ACIA6850, 0) - MCFG_ACIA6850_TXD_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd)) - MCFG_ACIA6850_RTS_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_rts)) - - MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, "terminal") - MCFG_RS232_RXD_HANDLER(DEVWRITELINE("acia", acia6850_device, write_rxd)) - MCFG_RS232_CTS_HANDLER(DEVWRITELINE("acia", acia6850_device, write_cts)) - - MCFG_DEVICE_ADD("acia_clock", CLOCK, 153600) - MCFG_CLOCK_SIGNAL_HANDLER(WRITELINE(c68ksbc_state, write_acia_clock)) -MACHINE_CONFIG_END - -/* ROM definition */ -ROM_START( 68ksbc ) - ROM_REGION(0x1000000, "maincpu", 0) - ROM_LOAD( "t68k.bin", 0x0000, 0x2f78, CRC(20a8d0d0) SHA1(544fd8bd8ed017115388c8b0f7a7a59a32253e43) ) -ROM_END - -/* Driver */ - -/* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ -COMP( 2002, 68ksbc, 0, 0, c68ksbc, c68ksbc, driver_device, 0, "Wichit Sirichote", "68k Single Board Computer", MACHINE_NO_SOUND_HW) diff --git a/src/mess/drivers/a2600.c b/src/mess/drivers/a2600.c deleted file mode 100644 index cf61e133b62..00000000000 --- a/src/mess/drivers/a2600.c +++ /dev/null @@ -1,552 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nathan Woods, Wilbert Pol -/*************************************************************************** - - Atari VCS 2600 driver - -TODO: -- Move the 2 32-in-1 rom dumps into their own driver -- Add 128-in-1 driver - -***************************************************************************/ - -#include "emu.h" -#include "machine/mos6530n.h" -#include "cpu/m6502/m6502.h" -#include "sound/tiaintf.h" -#include "video/tia.h" -#include "bus/vcs/vcs_slot.h" -#include "bus/vcs/rom.h" -#include "bus/vcs/dpc.h" -#include "bus/vcs/scharger.h" -#include "bus/vcs/compumat.h" -#include "bus/vcs_ctrl/ctrl.h" - -#define CONTROL1_TAG "joyport1" -#define CONTROL2_TAG "joyport2" - - -class a2600_state : public driver_device -{ -public: - a2600_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_riot_ram(*this, "riot_ram"), - m_joy1(*this, CONTROL1_TAG), - m_joy2(*this, CONTROL2_TAG) , - m_cart(*this, "cartslot"), - m_tia(*this, "tia_video"), - m_maincpu(*this, "maincpu"), - m_screen(*this, "screen"), - m_swb(*this, "SWB") - { } - - required_shared_ptr<UINT8> m_riot_ram; - UINT16 m_current_screen_height; - - DECLARE_MACHINE_START(a2600); - DECLARE_WRITE8_MEMBER(switch_A_w); - DECLARE_READ8_MEMBER(switch_A_r); - DECLARE_WRITE8_MEMBER(switch_B_w); - DECLARE_WRITE_LINE_MEMBER(irq_callback); - DECLARE_READ8_MEMBER(riot_input_port_8_r); - DECLARE_READ16_MEMBER(a2600_read_input_port); - DECLARE_READ8_MEMBER(a2600_get_databus_contents); - DECLARE_WRITE16_MEMBER(a2600_tia_vsync_callback); - DECLARE_WRITE16_MEMBER(a2600_tia_vsync_callback_pal); - DECLARE_WRITE8_MEMBER(cart_over_tia_w); - // investigate how the carts mapped here (Mapper JVP) interact with the RIOT device - DECLARE_READ8_MEMBER(cart_over_riot_r); - DECLARE_WRITE8_MEMBER(cart_over_riot_w); - -protected: - required_device<vcs_control_port_device> m_joy1; - required_device<vcs_control_port_device> m_joy2; - required_device<vcs_cart_slot_device> m_cart; - required_device<tia_video_device> m_tia; - - unsigned long detect_2600controllers(); - required_device<m6502_device> m_maincpu; - required_device<screen_device> m_screen; - required_ioport m_swb; -}; - - - -#define MASTER_CLOCK_NTSC 3579545 -#define MASTER_CLOCK_PAL 3546894 -#define CATEGORY_SELECT 16 - -static const UINT16 supported_screen_heights[4] = { 262, 312, 328, 342 }; - - -static ADDRESS_MAP_START(a2600_mem, AS_PROGRAM, 8, a2600_state ) - ADDRESS_MAP_GLOBAL_MASK(0x1fff) - AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0f00) AM_DEVREADWRITE("tia_video", tia_video_device, read, write) - AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0d00) AM_RAM AM_SHARE("riot_ram") - AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d00) AM_DEVICE("riot", mos6532_t, io_map) - // AM_RANGE(0x1000, 0x1fff) is cart data and it is configured at reset time, depending on the mounted cart! -ADDRESS_MAP_END - -WRITE8_MEMBER(a2600_state::switch_A_w) -{ - /* Left controller port */ - m_joy1->joy_w( data >> 4 ); - - /* Right controller port */ - m_joy2->joy_w( data & 0x0f ); - -// switch( ioport("CONTROLLERS")->read() % CATEGORY_SELECT ) -// { -// case 0x0a: /* KidVid voice module */ -// m_cassette->change_state(( data & 0x02 ) ? (cassette_state)CASSETTE_MOTOR_DISABLED : (cassette_state)(CASSETTE_MOTOR_ENABLED | CASSETTE_PLAY), (cassette_state)CASSETTE_MOTOR_DISABLED ); -// break; -// } -} - -READ8_MEMBER(a2600_state::switch_A_r) -{ - UINT8 val = 0; - - /* Left controller port PINs 1-4 ( 4321 ) */ - val |= ( m_joy1->joy_r() & 0x0F ) << 4; - - /* Right controller port PINs 1-4 ( 4321 ) */ - val |= m_joy2->joy_r() & 0x0F; - - return val; -} - -WRITE8_MEMBER(a2600_state::switch_B_w) -{ -} - -WRITE_LINE_MEMBER(a2600_state::irq_callback) -{ -} - -READ8_MEMBER(a2600_state::riot_input_port_8_r) -{ - return m_swb->read(); -} - - -READ16_MEMBER(a2600_state::a2600_read_input_port) -{ - switch( offset ) - { - case 0: /* Left controller port PIN 5 */ - return m_joy1->pot_x_r(); - - case 1: /* Left controller port PIN 9 */ - return m_joy1->pot_y_r(); - - case 2: /* Right controller port PIN 5 */ - return m_joy2->pot_x_r(); - - case 3: /* Right controller port PIN 9 */ - return m_joy2->pot_y_r(); - - case 4: /* Left controller port PIN 6 */ - return ( m_joy1->joy_r() & 0x20 ) ? 0xff : 0x7f; - - case 5: /* Right controller port PIN 6 */ - return ( m_joy2->joy_r() & 0x20 ) ? 0xff : 0x7f; - } - return 0xff; -} - -/* There are a few games that do an LDA ($80-$FF),Y instruction. - The contents off the databus then depend on whatever was read - from the RAM. To do this really properly the 6502 core would - need to keep track of the last databus contents so we can query - that. For now this is a quick hack to determine that value anyway. - Examples: - Q-Bert's Qubes (NTSC,F6) at 0x1594 - Berzerk at 0xF093. -*/ -READ8_MEMBER(a2600_state::a2600_get_databus_contents) -{ - UINT16 last_address, prev_address; - UINT8 last_byte, prev_byte; - address_space& prog_space = m_maincpu->space(AS_PROGRAM); - - last_address = m_maincpu->pc() + 1; - if ( ! ( last_address & 0x1080 ) ) - { - return offset; - } - last_byte = prog_space.read_byte(last_address ); - if ( last_byte < 0x80 || last_byte == 0xFF ) - { - return last_byte; - } - prev_address = last_address - 1; - if ( ! ( prev_address & 0x1080 ) ) - { - return last_byte; - } - prev_byte = prog_space.read_byte(prev_address ); - if ( prev_byte == 0xB1 ) - { /* LDA (XX),Y */ - return prog_space.read_byte(last_byte + 1 ); - } - return last_byte; -} - -#if 0 -static const rectangle visarea[4] = { - { 26, 26 + 160 + 16, 24, 24 + 192 + 31 }, /* 262 */ - { 26, 26 + 160 + 16, 32, 32 + 228 + 31 }, /* 312 */ - { 26, 26 + 160 + 16, 45, 45 + 240 + 31 }, /* 328 */ - { 26, 26 + 160 + 16, 48, 48 + 240 + 31 } /* 342 */ -}; -#endif - -WRITE16_MEMBER(a2600_state::a2600_tia_vsync_callback) -{ - int i; - - for ( i = 0; i < ARRAY_LENGTH(supported_screen_heights); i++ ) - { - if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 ) - { - if ( supported_screen_heights[i] != m_current_screen_height ) - { - m_current_screen_height = supported_screen_heights[i]; -// m_screen->configure(228, m_current_screen_height, &visarea[i], HZ_TO_ATTOSECONDS( MASTER_CLOCK_NTSC ) * 228 * m_current_screen_height ); - } - } - } -} - -WRITE16_MEMBER(a2600_state::a2600_tia_vsync_callback_pal) -{ - int i; - - for ( i = 0; i < ARRAY_LENGTH(supported_screen_heights); i++ ) - { - if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 ) - { - if ( supported_screen_heights[i] != m_current_screen_height ) - { - m_current_screen_height = supported_screen_heights[i]; -// m_screen->configure(228, m_current_screen_height, &visarea[i], HZ_TO_ATTOSECONDS( MASTER_CLOCK_PAL ) * 228 * m_current_screen_height ); - } - } - } -} - -// TODO: is this the correct behavior for the real hardware?!? -READ8_MEMBER(a2600_state::cart_over_riot_r) -{ - if (!space.debugger_access()) - m_cart->write_bank(space, offset, 0); - return m_riot_ram[0x20 + offset]; -} - -WRITE8_MEMBER(a2600_state::cart_over_riot_w) -{ - m_cart->write_bank(space, offset, 0); - m_riot_ram[0x20 + offset] = data; - -} - -WRITE8_MEMBER(a2600_state::cart_over_tia_w) -{ - // Both Cart & TIA see these addresses - m_cart->write_bank(space, offset, data); - m_tia->write(space, offset, data); -} - -MACHINE_START_MEMBER(a2600_state,a2600) -{ - m_current_screen_height = m_screen->height(); - memset(m_riot_ram, 0x00, 0x80); - - switch (m_cart->get_cart_type()) - { - case A26_2K: - case A26_4K: - case A26_F4: - case A26_F8: - case A26_F8SW: - case A26_FA: - case A26_E0: - case A26_E7: - case A26_CV: - case A26_DC: - case A26_FV: - case A26_8IN1: - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_bank),(vcs_cart_slot_device*)m_cart)); - break; - case A26_F6: - case A26_DPC: - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_bank),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate(FUNC(vcs_cart_slot_device::cart_opbase),(vcs_cart_slot_device*)m_cart)); - break; - case A26_FE: - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_ram),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).install_read_handler(0x01fe, 0x01ff, read8_delegate(FUNC(vcs_cart_slot_device::read_bank),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x01fe, 0x01fe, write8_delegate(FUNC(vcs_cart_slot_device::write_bank),(vcs_cart_slot_device*)m_cart)); - break; - case A26_3E: - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_ram),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x00, 0x3f, write8_delegate(FUNC(a2600_state::cart_over_tia_w), this)); - break; - case A26_3F: - m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).install_write_handler(0x00, 0x3f, write8_delegate(FUNC(a2600_state::cart_over_tia_w), this)); - break; - case A26_UA: - m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x200, 0x27f, read8_delegate(FUNC(vcs_cart_slot_device::read_bank),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_bank),(vcs_cart_slot_device*)m_cart)); - break; - case A26_JVP: - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart), write8_delegate(FUNC(vcs_cart_slot_device::write_bank),(vcs_cart_slot_device*)m_cart)); - // to verify the actual behavior... - m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xfa0, 0xfc0, read8_delegate(FUNC(a2600_state::cart_over_riot_r), this), write8_delegate(FUNC(a2600_state::cart_over_riot_w), this)); - break; - case A26_4IN1: - case A26_32IN1: - m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); - break; - case A26_SS: - m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); - break; - case A26_CM: - m_maincpu->space(AS_PROGRAM).install_read_handler(0x1000, 0x1fff, read8_delegate(FUNC(vcs_cart_slot_device::read_rom),(vcs_cart_slot_device*)m_cart)); - break; - } - - /* Banks may have changed, reset the cpu so it uses the correct reset vector */ - m_maincpu->reset(); - - save_item(NAME(m_current_screen_height)); -} - - -#ifdef UNUSED_FUNCTIONS -// try to detect 2600 controller setup. returns 32bits with left/right controller info -unsigned a2600_state::long detect_2600controllers() -{ -#define JOYS 0x001 -#define PADD 0x002 -#define KEYP 0x004 -#define LGUN 0x008 -#define INDY 0x010 -#define BOOS 0x020 -#define KVID 0x040 -#define CMTE 0x080 -#define MLNK 0x100 -#define AMSE 0x200 -#define CX22 0x400 |