diff options
Diffstat (limited to 'src/devices/sound/tms5110.cpp')
-rw-r--r-- | src/devices/sound/tms5110.cpp | 96 |
1 files changed, 36 insertions, 60 deletions
diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp index 42899a0ac4d..e2d77d130fc 100644 --- a/src/devices/sound/tms5110.cpp +++ b/src/devices/sound/tms5110.cpp @@ -237,6 +237,7 @@ void tms5110_device::register_for_save_states() save_item(NAME(m_romclk_hack_state)); } + /********************************************************************************************** printbits helper function: takes a long int input and prints the resulting bits to stderr @@ -277,11 +278,11 @@ static void printbits(long data, int num) /****************************************************************************************** - extract_bits -- extract a specific number of bits from the VSM + read_bits -- read a specific number of bits from the VSM ******************************************************************************************/ -int tms5110_device::extract_bits(int count) +int tms5110_device::read_bits(int count) { int val = 0; if (DEBUG_5110) logerror("requesting %d bits", count); @@ -307,7 +308,6 @@ void tms5110_device::perform_dummy_read() - /********************************************************************************************** tms5110_process -- fill the buffer with a specific number of samples @@ -585,6 +585,7 @@ void tms5110_device::process(int16_t *buffer, unsigned int size) } } + /********************************************************************************************** clip_analog -- clips the 14 bit return value from the lattice filter to its final 10 bit value (-512 to 511), and upshifts/range extends this to 16 bits @@ -595,7 +596,8 @@ static int16_t clip_analog(int16_t cliptemp) { /* clipping, just like the patent shows: * the top 10 bits of this result are visible on the digital output IO pin. - * next, if the top 3 bits of the 14 bit result are all the same, the lowest of those 3 bits plus the next 7 bits are the signed analog output, otherwise the low bits are all forced to match the inverse of the topmost bit, i.e.: + * next, if the top 3 bits of the 14 bit result are all the same, the lowest of those 3 bits plus the next 7 bits are the signed analog output, + * otherwise the low bits are all forced to match the inverse of the topmost bit, i.e.: * 1x xxxx xxxx xxxx -> 0b10000000 * 11 1bcd efgh xxxx -> 0b1bcdefgh * 00 0bcd efgh xxxx -> 0b0bcdefgh @@ -633,6 +635,7 @@ static int16_t clip_analog(int16_t cliptemp) output, this makes almost no difference in the computation. **********************************************************************************************/ + static int32_t matrix_multiply(int32_t a, int32_t b) { int32_t result; @@ -648,6 +651,7 @@ static int32_t matrix_multiply(int32_t a, int32_t b) return result; } + /********************************************************************************************** lattice_filter -- executes one 'full run' of the lattice filter on a specific byte of @@ -724,7 +728,6 @@ int32_t tms5110_device::lattice_filter() - /****************************************************************************************** PDC_set -- set Processor Data Clock. Execute CTL_pins command on hi-lo transition. @@ -846,7 +849,7 @@ void tms5110_device::PDC_set(int data) fprintf(stderr,"actually reading a bit now\n"); #endif m_CTL_buffer >>= 1; - m_CTL_buffer |= (extract_bits(1)<<3); + m_CTL_buffer |= (read_bits(1)<<3); m_CTL_buffer &= 0xF; } break; @@ -924,7 +927,7 @@ void tms5110_device::parse_frame() m_uv_zpar = m_zpar = 0; // attempt to extract the energy index - m_new_frame_energy_idx = extract_bits(m_coeff->energy_bits); + m_new_frame_energy_idx = read_bits(m_coeff->energy_bits); #ifdef DEBUG_PARSE_FRAME_DUMP printbits(m_new_frame_energy_idx,m_coeff->energy_bits); fprintf(stderr," "); @@ -934,13 +937,13 @@ void tms5110_device::parse_frame() if ((m_new_frame_energy_idx == 0) || (m_new_frame_energy_idx == 15)) return; - rep_flag = extract_bits(1); + rep_flag = read_bits(1); #ifdef DEBUG_PARSE_FRAME_DUMP printbits(rep_flag, 1); fprintf(stderr," "); #endif - m_new_frame_pitch_idx = extract_bits(m_coeff->pitch_bits); + m_new_frame_pitch_idx = read_bits(m_coeff->pitch_bits); #ifdef DEBUG_PARSE_FRAME_DUMP printbits(m_new_frame_pitch_idx,m_coeff->pitch_bits); fprintf(stderr," "); @@ -954,7 +957,7 @@ void tms5110_device::parse_frame() // extract first 4 K coefficients for (i = 0; i < 4; i++) { - m_new_frame_k_idx[i] = extract_bits(m_coeff->kbits[i]); + m_new_frame_k_idx[i] = read_bits(m_coeff->kbits[i]); #ifdef DEBUG_PARSE_FRAME_DUMP printbits(m_new_frame_k_idx[i],m_coeff->kbits[i]); fprintf(stderr," "); @@ -971,7 +974,7 @@ void tms5110_device::parse_frame() // If we got here, we need the remaining 6 K's for (i = 4; i < m_coeff->num_k; i++) { - m_new_frame_k_idx[i] = extract_bits(m_coeff->kbits[i]); + m_new_frame_k_idx[i] = read_bits(m_coeff->kbits[i]); #ifdef DEBUG_PARSE_FRAME_DUMP printbits(m_new_frame_k_idx[i],m_coeff->kbits[i]); fprintf(stderr," "); @@ -984,29 +987,6 @@ void tms5110_device::parse_frame() } -#if 0 -/*This is an example word TEN taken from the TMS5110A datasheet*/ -static const unsigned int example_word_TEN[619]={ -/* 1*/1,0,0,0, 0, 0,0,0,0,0, 1,1,0,0,0, 0,0,0,1,0, 0,1,1,1, 0,1,0,1, -/* 2*/1,0,0,0, 0, 0,0,0,0,0, 1,0,0,1,0, 0,0,1,1,0, 0,0,1,1, 0,1,0,1, -/* 3*/1,1,0,0, 0, 1,0,0,0,0, 1,0,1,0,0, 0,1,0,1,0, 0,1,0,0, 1,0,1,0, 1,0,0,0, 1,0,0,1, 0,1,0,1, 0,0,1, 0,1,0, 0,1,1, -/* 4*/1,1,1,0, 0, 0,1,1,1,1, 1,0,1,0,1, 0,1,1,1,0, 0,1,0,1, 0,1,1,1, 0,1,1,1, 1,0,1,1, 1,0,1,0, 0,1,1, 0,1,0, 0,1,1, -/* 5*/1,1,1,0, 0, 1,0,0,0,0, 1,0,1,0,0, 0,1,1,1,0, 0,1,0,1, 1,0,1,0, 1,0,0,0, 1,1,0,0, 1,0,1,1, 1,0,0, 0,1,0, 0,1,1, -/* 6*/1,1,1,0, 0, 1,0,0,0,1, 1,0,1,0,1, 0,1,1,0,1, 0,1,1,0, 0,1,1,1, 0,1,1,1, 1,0,1,0, 1,0,1,0, 1,1,0, 0,0,1, 1,0,0, -/* 7*/1,1,1,0, 0, 1,0,0,1,0, 1,0,1,1,1, 0,1,1,1,0, 0,1,1,1, 0,1,1,1, 0,1,0,1, 0,1,1,0, 1,0,0,1, 1,1,0, 0,1,0, 0,1,1, -/* 8*/1,1,1,0, 1, 1,0,1,0,1, -/* 9*/1,1,1,0, 0, 1,1,0,0,1, 1,0,1,1,1, 0,1,0,1,1, 1,0,1,1, 0,1,1,1, 0,1,0,0, 1,0,0,0, 1,0,0,0, 1,1,0, 0,1,1, 0,1,1, -/*10*/1,1,0,1, 0, 1,1,0,1,0, 1,0,1,0,1, 0,1,1,0,1, 1,0,1,1, 0,1,0,1, 0,1,0,0, 1,0,0,0, 1,0,1,0, 1,1,0, 0,1,0, 1,0,0, -/*11*/1,0,1,1, 0, 1,1,0,1,1, 1,0,0,1,1, 1,0,0,1,0, 0,1,1,0, 0,0,1,1, 0,1,0,1, 1,0,0,1, 1,0,1,0, 1,0,0, 0,1,1, 0,1,1, -/*12*/1,0,0,0, 0, 1,1,1,0,0, 1,0,0,1,1, 0,0,1,1,0, 0,1,0,0, 0,1,1,0, 1,1,0,0, 0,1,0,1, 1,0,0,0, 1,0,0, 0,1,0, 1,0,1, -/*13*/0,1,1,1, 1, 1,1,1,0,1, -/*14*/0,1,1,1, 0, 1,1,1,1,0, 1,0,0,1,1, 0,0,1,1,1, 0,1,0,1, 0,1,0,1, 1,1,0,0, 0,1,1,1, 1,0,0,0, 1,0,0, 0,1,0, 1,0,1, -/*15*/0,1,1,0, 0, 1,1,1,1,0, 1,0,1,0,1, 0,0,1,1,0, 0,1,0,0, 0,0,1,1, 1,1,0,0, 1,0,0,1, 0,1,1,1, 1,0,1, 0,1,0, 1,0,1, -/*16*/1,1,1,1 -}; -#endif - - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- @@ -1109,7 +1089,8 @@ void tms5110_device::device_reset() /****************************************************************************** tms5110_ctl_w -- write Control Command to the sound chip -commands like Speech, Reset, etc., are loaded into the chip via the CTL pins + + commands like Speech, Reset, etc., are loaded into the chip via the CTL pins ******************************************************************************/ @@ -1178,7 +1159,7 @@ uint8_t m58817_device::status_r() { /* bring up to date first */ m_stream->update(); - return (TALK_STATUS() << 0); /*CTL1 = still talking ? */ + return (TALK_STATUS() << 0); /* CTL1 = still talking ? */ } TIMER_CALLBACK_MEMBER(tms5110_device::romclk_hack_toggle) @@ -1207,30 +1188,25 @@ int tms5110_device::romclk_hack_r() /****************************************************************************** - tms5110_update -- update the sound chip so that it is in sync with CPU execution + sound_stream_update -- update the sound chip so that it is in sync with CPU execution ******************************************************************************/ -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -void tms5110_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms5110_device::sound_stream_update(sound_stream &stream) { int16_t sample_data[MAX_SAMPLE_CHUNK]; - auto &buffer = outputs[0]; /* loop while we still have samples to generate */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int length = buffer.samples() - sampindex; + int length = stream.samples() - sampindex; if (length > MAX_SAMPLE_CHUNK) length = MAX_SAMPLE_CHUNK; /* generate the samples and copy to the target buffer */ process(sample_data, length); for (int index = 0; index < length; index++) - buffer.put_int(sampindex++, sample_data[index], 32768); + stream.put_int(0, sampindex++, sample_data[index], 32768); } } @@ -1238,7 +1214,7 @@ void tms5110_device::sound_stream_update(sound_stream &stream, std::vector<read_ /****************************************************************************** - tms5110_set_frequency -- adjusts the playback frequency + device_clock_changed -- adjusts the playback frequency ******************************************************************************/ @@ -1493,18 +1469,18 @@ m58817_device::m58817_device(const machine_config &mconfig, const char *tag, dev DEFINE_DEVICE_TYPE(TMSPROM, tmsprom_device, "tmsprom", "TMSPROM") tmsprom_device::tmsprom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, TMSPROM, tag, owner, clock), - m_rom(*this, DEVICE_SELF), - m_prom(*this, finder_base::DUMMY_TAG), - m_rom_size(0), - m_pdc_bit(0), - m_ctl1_bit(0), - m_ctl2_bit(0), - m_ctl4_bit(0), - m_ctl8_bit(0), - m_reset_bit(0), - m_stop_bit(0), - m_pdc_cb(*this), - m_ctl_cb(*this) + : device_t(mconfig, TMSPROM, tag, owner, clock) + , m_rom(*this, DEVICE_SELF) + , m_prom(*this, finder_base::DUMMY_TAG) + , m_rom_size(0) + , m_pdc_bit(0) + , m_ctl1_bit(0) + , m_ctl2_bit(0) + , m_ctl4_bit(0) + , m_ctl8_bit(0) + , m_reset_bit(0) + , m_stop_bit(0) + , m_pdc_cb(*this) + , m_ctl_cb(*this) { } |