diff --git a/.gitattributes b/.gitattributes index b9eadf9f7c7..37ff002a76b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -762,8 +762,6 @@ src/emu/sound/k053260.c svneol=native#text/plain src/emu/sound/k053260.h svneol=native#text/plain src/emu/sound/k054539.c svneol=native#text/plain src/emu/sound/k054539.h svneol=native#text/plain -src/emu/sound/m58817.c svneol=native#text/plain -src/emu/sound/m58817.h svneol=native#text/plain src/emu/sound/msm5205.c svneol=native#text/plain src/emu/sound/msm5205.h svneol=native#text/plain src/emu/sound/msm5232.c svneol=native#text/plain diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c index 7532aacfd81..52f426c64a6 100644 --- a/src/emu/sndintrf.c +++ b/src/emu/sndintrf.c @@ -164,7 +164,6 @@ void sid6581_get_info(void *token, UINT32 state, sndinfo *info); void sid8580_get_info(void *token, UINT32 state, sndinfo *info); void sp0256_get_info(void *token, UINT32 state, sndinfo *info); void s14001a_get_info(void *token, UINT32 state, sndinfo *info); -void m58817_get_info(void *token, UINT32 state, sndinfo *info); void filter_volume_get_info(void *token, UINT32 state, sndinfo *info); void filter_rc_get_info(void *token, UINT32 state, sndinfo *info); @@ -445,9 +444,6 @@ static const struct #if (HAS_SP0256) { SOUND_SP0256, sp0256_get_info }, #endif -#if (HAS_M58817) - { SOUND_M58817, m58817_get_info }, -#endif { SOUND_FILTER_VOLUME, filter_volume_get_info }, { SOUND_FILTER_RC, filter_rc_get_info }, diff --git a/src/emu/sndintrf.h b/src/emu/sndintrf.h index 67b5271642b..746fa65ee57 100644 --- a/src/emu/sndintrf.h +++ b/src/emu/sndintrf.h @@ -125,7 +125,6 @@ enum _sound_type SOUND_SID8580, SOUND_SP0256, SOUND_S14001A, - SOUND_M58817, /* filters start here */ SOUND_FILTER_VOLUME, diff --git a/src/emu/sound/5110intf.c b/src/emu/sound/5110intf.c index cfc22302e7a..472a5ef02c8 100644 --- a/src/emu/sound/5110intf.c +++ b/src/emu/sound/5110intf.c @@ -27,13 +27,36 @@ struct tms5110_info const struct TMS5110interface *intf; sound_stream *stream; void *chip; + INT32 speech_rom_bitnum; }; /* static function prototypes */ static void tms5110_update(void *param, stream_sample_t **inputs, stream_sample_t **buffer, int length); +static int speech_rom_read_bit(void) +{ + struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0); + const UINT8 *table = memory_region(info->intf->rom_region); + int r; + + if (info->speech_rom_bitnum<0) + r = 0; + else + r = (table[info->speech_rom_bitnum >> 3] >> (0x07 - (info->speech_rom_bitnum & 0x07))) & 1; + + info->speech_rom_bitnum++; + + return r; +} + +static void speech_rom_set_addr(int addr) +{ + struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0); + + info->speech_rom_bitnum = addr * 8 - 1; +} /****************************************************************************** @@ -43,14 +66,14 @@ static void tms5110_update(void *param, stream_sample_t **inputs, stream_sample_ static void *tms5110_start(int sndindex, int clock, const void *config) { - static const struct TMS5110interface dummy = { 0 }; + static const struct TMS5110interface dummy = { TMS5110_IS_5110A, -1 }; struct tms5110_info *info; info = auto_malloc(sizeof(*info)); memset(info, 0, sizeof(*info)); info->intf = config ? config : &dummy; - info->chip = tms5110_create(sndindex); + info->chip = tms5110_create(sndindex, info->intf->variant); if (!info->chip) return NULL; sndintrf_register_token(info); @@ -58,12 +81,21 @@ static void *tms5110_start(int sndindex, int clock, const void *config) /* initialize a stream */ info->stream = stream_create(0, 1, clock / 80, info, tms5110_update); - if (info->intf->M0_callback==NULL) - { - logerror("\n file: 5110intf.c, tms5110_start(), line 53:\n Missing _mandatory_ 'M0_callback' function pointer in the TMS5110 interface\n This function is used by TMS5110 to call for a single bits\n needed to generate the speech\n Aborting startup...\n"); - return NULL; - } - tms5110_set_M0_callback(info->chip, info->intf->M0_callback ); + if (info->intf->rom_region == -1 ) + { + if (info->intf->M0_callback==NULL) + { + logerror("\n file: 5110intf.c, tms5110_start(), line 53:\n Missing _mandatory_ 'M0_callback' function pointer in the TMS5110 interface\n This function is used by TMS5110 to call for a single bits\n needed to generate the speech\n Aborting startup...\n"); + return NULL; + } + tms5110_set_M0_callback(info->chip, info->intf->M0_callback ); + tms5110_set_load_address(info->chip, info->intf->load_address ); + } + else + { + tms5110_set_M0_callback(info->chip, speech_rom_read_bit ); + tms5110_set_load_address(info->chip, speech_rom_set_addr ); + } /* reset the 5110 */ tms5110_reset_chip(info->chip); diff --git a/src/emu/sound/5110intf.h b/src/emu/sound/5110intf.h index 704550b4efa..ee9aa3c24da 100644 --- a/src/emu/sound/5110intf.h +++ b/src/emu/sound/5110intf.h @@ -7,8 +7,10 @@ struct TMS5110interface { - void (*irq)(int state); /* IRQ callback function */ - int (*M0_callback)(void); /* function to be called when chip requests another bit*/ + int variant; /* Variant of the 5110 - see tms5110.h */ + int rom_region; /* set to -1 to specifiy callbacks below */ + int (*M0_callback)(void); /* function to be called when chip requests another bit */ + void (*load_address)(int addr); /* speech ROM load address callback */ }; WRITE8_HANDLER( tms5110_CTL_w ); diff --git a/src/emu/sound/m58817.c b/src/emu/sound/m58817.c deleted file mode 100644 index abccd8f60f5..00000000000 --- a/src/emu/sound/m58817.c +++ /dev/null @@ -1,365 +0,0 @@ -/****************************************************************************** - - M58817 interface - - Written for MAME by couriersud - - - structure from TMS5110 interface - - this is a wrapper around the TMS5110 interface - - M58817 & TMS5110 seem to be similar, however it is very probable - that they use different "coding" tables for energy, pitch - - Speech is understandable, but off - - This driver supports to use a "sample" interface instead as well - -******************************************************************************/ - -#include - -#include "sndintrf.h" -#include "streams.h" -#include "tms5110.h" -#include "m58817.h" -#include "sound/samples.h" - - -#define MAX_SAMPLE_CHUNK 10000 - -enum { - WAIT_CMD, - WAIT_WRITE, - WAIT_DONE1, - WAIT_DONE2 -} m58817_states; - -/* the state of the streamed output */ -struct m58817_info -{ - const struct M58817interface *intf; - sound_stream *stream; - void *chip; - UINT8 state; - UINT8 drq; - UINT8 nibbles[4]; - UINT8 command_latch; - INT32 count; - INT32 address; - INT32 speech_rom_bitnum; -}; - - -/* static function prototypes */ -static void m58817_update(void *param, stream_sample_t **inputs, stream_sample_t **buffer, int length); - -static int speech_rom_read_bit(void) -{ - struct m58817_info *info = sndti_token(SOUND_M58817, 0); - const UINT8 *table = memory_region(info->intf->rom_region); - - int r; - - if (info->speech_rom_bitnum<0) - r = 0; - else - r = (table[info->speech_rom_bitnum >> 3] >> (0x07 - (info->speech_rom_bitnum & 0x07))) & 1; - //r = (table[speech_rom_bitnum >> 3] >> ((speech_rom_bitnum & 0x07))) & 1; - info->speech_rom_bitnum++; - //printf("Byte: 0x%02x\n", speech_rom_bitnum>>3); - return r; -} - -/****************************************************************************** - - m58817_state_loop -- process commands - -******************************************************************************/ - -static void m58817_state_loop(void *chip, int data) -{ - struct m58817_info *info = chip; - int i; - switch (info->state) - { - case WAIT_CMD: - switch (data) - { - case 0x00: // reset ???? - info->count=0; - /*To be extremely accurate there should be a delays between each of - the function calls below. In real they happen with the frequency of 160 kHz. - */ - - if (info->intf->rom_region != -1) - { - tms5110_CTL_set(info->chip, TMS5110_CMD_RESET); - tms5110_PDC_set(info->chip, 0); - tms5110_PDC_set(info->chip, 1); - tms5110_PDC_set(info->chip, 0); - - tms5110_PDC_set(info->chip, 0); - tms5110_PDC_set(info->chip, 1); - tms5110_PDC_set(info->chip, 0); - - tms5110_PDC_set(info->chip, 0); - tms5110_PDC_set(info->chip, 1); - tms5110_PDC_set(info->chip, 0); - - info->speech_rom_bitnum = 0x0; - } - break; - case 0x02: // latch next nibbel - info->state=WAIT_WRITE; - break; - case 0x08: // play ???? - info->state=WAIT_DONE1; - break; - default: - logerror("m58817: unknown cmd : 0x%02x\n", data); - } - break; - case WAIT_WRITE: - info->nibbles[info->count++] = data & 0x0f; - info->state=WAIT_CMD; - break; - case WAIT_DONE1: - if (data != 0x0A) - logerror("m58817: expected 0x0A got 0x%02x\n", data); - info->address = 0; - for (i=0;icount;i++) - { - info->address |= (info->nibbles[i] << (i*4)); - } - logerror("m58817: address: 0x%04x\n", info->address); - - - if (info->intf->rom_region != -1) - { - info->speech_rom_bitnum = info->address * 8 - 1; - tms5110_CTL_set(info->chip, TMS5110_CMD_SPEAK); - tms5110_PDC_set(info->chip, 0); - tms5110_PDC_set(info->chip, 1); - tms5110_PDC_set(info->chip, 0); - } - else - { - for (i=0;iintf->sample_addr[i] == info->address) - { - sample_start(0,i,0); - break; - } - } - - info->state=WAIT_CMD; - break; - } -} - - -/****************************************************************************** - - m58817_start -- allocate buffers and reset the 5110 - -******************************************************************************/ - -static void *m58817_start(int sndindex, int clock, const void *config) -{ - static const struct M58817interface dummy = { 0 }; - struct m58817_info *info; - - info = auto_malloc(sizeof(*info)); - memset(info, 0, sizeof(*info)); - info->intf = config ? config : &dummy; - - if (info->intf->rom_region != -1) - { - info->chip = tms5110_create(sndindex); - if (!info->chip) - return NULL; - } - sndintrf_register_token(info); - - /* initialize a stream */ - if (info->intf->rom_region != -1) - { - info->stream = stream_create(0, 1, clock / 80, info, m58817_update); - tms5110_set_M0_callback(info->chip, speech_rom_read_bit ); - /* reset the 58817 */ - tms5110_reset_chip(info->chip); - } - - state_save_register_item("m58817", sndindex, info->state); - state_save_register_item("m58817", sndindex, info->drq); - state_save_register_item_array("m58817", sndindex, info->nibbles); - state_save_register_item("m58817", sndindex, info->count); - state_save_register_item("m58817", sndindex, info->address); - state_save_register_item("m58817", sndindex, info->speech_rom_bitnum); - - /* request a sound channel */ - return info; -} - - - -/****************************************************************************** - - m58817_stop -- free buffers - -******************************************************************************/ - -static void m58817_stop(void *chip) -{ - struct m58817_info *info = chip; - if (info->intf->rom_region != -1) - tms5110_destroy(info->chip); -} - - -static void m58817_reset(void *chip) -{ - struct m58817_info *info = chip; - if (info->intf->rom_region != -1) - tms5110_reset_chip(info->chip); - info->state = WAIT_CMD; - info->drq = 0; - info->command_latch = 0; - info->count=0; -} - - - -/****************************************************************************** - - m58817_CTL_w -- write Control Command to the sound chip - commands like Speech, Reset, etc., are loaded into the chip via the CTL pins - -******************************************************************************/ - -WRITE8_HANDLER( m58817_CTL_w ) -{ - struct m58817_info *info = sndti_token(SOUND_M58817, 0); - - /* bring up to date first */ - //stream_update(info->stream); - info->command_latch = data & 0x0f; -} - -/****************************************************************************** - - m58817_DRQ_w -- write to DRQ pin on the sound chip - -******************************************************************************/ - -WRITE8_HANDLER( m58817_DRQ_w ) -{ - struct m58817_info *info = sndti_token(SOUND_M58817, 0); - - /* bring up to date first */ - if (info->intf->rom_region != -1) - stream_update(info->stream); - if (!data & info->drq) - m58817_state_loop(info, info->command_latch); - info->drq = data; -} - - - -/****************************************************************************** - - m58817_status_r -- read status from the sound chip - -******************************************************************************/ - -READ8_HANDLER( m58817_status_r ) -{ - struct m58817_info *info = sndti_token(SOUND_M58817, 0); - - /* bring up to date first */ - if (info->intf->rom_region != -1) - stream_update(info->stream); - if (info->intf->rom_region != -1) - return tms5110_status_read(info->chip); - else - return sample_playing(0); -} - - - -/****************************************************************************** - - m58817_update -- update the sound chip so that it is in sync with CPU execution - -******************************************************************************/ - -static void m58817_update(void *param, stream_sample_t **inputs, stream_sample_t **_buffer, int length) -{ - struct m58817_info *info = param; - INT16 sample_data[MAX_SAMPLE_CHUNK]; - stream_sample_t *buffer = _buffer[0]; - - /* loop while we still have samples to generate */ - while (length) - { - int samples = (length > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : length; - int index; - - /* generate the samples and copy to the target buffer */ - tms5110_process(info->chip, sample_data, samples); - for (index = 0; index < samples; index++) - *buffer++ = sample_data[index]; - - /* account for the samples */ - length -= samples; - } -} - - - -/****************************************************************************** - - m58817_set_frequency -- adjusts the playback frequency - -******************************************************************************/ - -void m58817_set_frequency(int frequency) -{ - struct m58817_info *info = sndti_token(SOUND_M58817, 0); - stream_set_sample_rate(info->stream, frequency / 80); -} - - - - -/************************************************************************** - * Generic get_info - **************************************************************************/ - -static void m58817_set_info(void *token, UINT32 state, sndinfo *info) -{ - switch (state) - { - /* no parameters to set */ - } -} - - -void m58817_get_info(void *token, UINT32 state, sndinfo *info) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case SNDINFO_PTR_SET_INFO: info->set_info = m58817_set_info; break; - case SNDINFO_PTR_START: info->start = m58817_start; break; - case SNDINFO_PTR_STOP: info->stop = m58817_stop; break; - case SNDINFO_PTR_RESET: info->reset = m58817_reset; break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case SNDINFO_STR_NAME: info->s = "M58817"; break; - case SNDINFO_STR_CORE_FAMILY: info->s = "Mitsubishi Speech"; break; - case SNDINFO_STR_CORE_VERSION: info->s = "1.0"; break; - case SNDINFO_STR_CORE_FILE: info->s = __FILE__; break; - case SNDINFO_STR_CORE_CREDITS: info->s = "Copyright (c) 2007, The MAME Team"; break; - } -} - diff --git a/src/emu/sound/m58817.h b/src/emu/sound/m58817.h deleted file mode 100644 index 7374f2d03ef..00000000000 --- a/src/emu/sound/m58817.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef m58817_h -#define m58817_h - -/* clock rate = 80 * output sample rate, */ -/* usually 640000 for 8000 Hz sample rate or */ -/* usually 800000 for 10000 Hz sample rate. */ - -#define M58817_MAX_SAMPLES 20 - -struct M58817interface -{ - int rom_region; /* set to -1 to use samples */ - int sample_addr[M58817_MAX_SAMPLES]; -}; - -WRITE8_HANDLER( m58817_CTL_w ); -WRITE8_HANDLER( m58817_DRQ_w ); - -READ8_HANDLER( m58817_status_r ); - -void m58817_set_frequency(int frequency); - -#endif - diff --git a/src/emu/sound/sound.mak b/src/emu/sound/sound.mak index 17f9db32cc9..34b8a47b642 100644 --- a/src/emu/sound/sound.mak +++ b/src/emu/sound/sound.mak @@ -593,18 +593,6 @@ endif -#------------------------------------------------- -# Mitsubishi M58817 speech synthesizer -#------------------------------------------------- - -SOUNDDEFS += -DHAS_M58817=$(if $(filter M58817,$(SOUNDS)),1,0) - -ifneq ($(filter M58817,$(SOUNDS)),) -SOUNDOBJS += $(SOUNDOBJ)/m58817.o -endif - - - #------------------------------------------------- # VLM5030 speech synthesizer #------------------------------------------------- diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index 96ceea772b7..7e882d7753c 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -1,26 +1,92 @@ /********************************************************************************************** - TMS5110 simulator (modified from TMS5220 by Jarek Burczynski) + TMS5110 simulator (modified from TMS5220 by Jarek Burczynski) - Written for MAME by Frank Palazzolo - With help from Neill Corlett - Additional tweaking by Aaron Giles - Various fixes by Lord Nightmare + Written for MAME by Frank Palazzolo + With help from Neill Corlett + Additional tweaking by Aaron Giles + Various fixes by Lord Nightmare + Additional enhancements by Couriersud + + Todo: + - implement CS + - implement missing commands + + TMS5100: + + +-----------------+ + TST | 1 28 | CS + PDC | 2 27 | CTL8 + ROM CK | 3 26 | ADD8 + CPU CK | 4 25 | CTL1 + VDD | 5 24 | ADD1 + CR OSC | 6 23 | CTL2 + RC OSC | 7 22 | ADD2 + T11 | 8 21 | ADD4 + NC | 9 20 | CTL4 + I/O | 10 19 | M1 + SPK1 | 11 18 | NC + SPK2 | 12 17 | NC + PROM OUT | 13 16 | NC + VSS | 14 15 | M0 + +-----------------+ + + M58817 + + The following connections could be derived from radar scope schematics. + The M58817 is not 100% pin compatible to the 5100, but really close. + + +-----------------+ + (NC) | 1 28 | CS + PDC | 2 27 | CTL8 + ROM CK | 3 26 | ADD8 (to 58819) + (NC) | 4 25 | CTL1 + (VDD,-5) | 5 24 | ADD1 (to 58819) + (GND) | 6 23 | CTL2 + Xin | 7 22 | ADD2 (to 58819) + Xout | 8 21 | ADD4 (to 58819) + (NC) | 9 20 | CTL4 + (VDD,-5) | 10 19 | Status back to CPU + (NC) | 11 18 | C1 (to 58819) + SPKR | 12 17 | (NC) + SPKR | 13 16 | C0 (to 58819) + (NC) | 14 15 | (5V) + +-----------------+ ***********************************************************************************************/ #include "sndintrf.h" #include "tms5110.h" +#define MAX_K 10 +#define MAX_SCALE_BITS 6 +#define MAX_SCALE (1<coeff = &tms5110_coeff; + break; + case TMS5110_IS_5100: + tms->coeff = &pat4209836_coeff; + break; + case TMS5110_IS_M58817: + tms->coeff = &pat4403965_coeff; + break; + default: + fatalerror("Unknown variant in tms5110_create\n"); + } + state_save_register_item_array("tms5110", index, tms->fifo); state_save_register_item("tms5110", index, tms->fifo_head); state_save_register_item("tms5110", index, tms->fifo_tail); @@ -111,7 +203,11 @@ void *tms5110_create(int index) state_save_register_item("tms5110", index, tms->sample_count); state_save_register_item("tms5110", index, tms->pitch_count); - state_save_register_item_array("tms5110", index, tms->u); + state_save_register_item("tms5110", index, tms->next_is_address); + state_save_register_item("tms5110", index, tms->address); + state_save_register_item("tms5110", index, tms->schedule_dummy_read); + state_save_register_item("tms5110", index, tms->addr_bit); + state_save_register_item_array("tms5110", index, tms->x); state_save_register_item("tms5110", index, tms->RNG); @@ -138,47 +234,60 @@ void tms5110_reset_chip(void *chip) { struct tms5110 *tms = chip; - /* initialize the FIFO */ - memset(tms->fifo, 0, sizeof(tms->fifo)); - tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0; + /* initialize the FIFO */ + memset(tms->fifo, 0, sizeof(tms->fifo)); + tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0; - /* initialize the chip state */ - tms->speaking_now = tms->speak_delay_frames = tms->talk_status = 0; - tms->CTL_pins = 0; - tms->RNG = 0x1fff; + /* initialize the chip state */ + tms->speaking_now = tms->speak_delay_frames = tms->talk_status = 0; + tms->CTL_pins = 0; + tms->RNG = 0x1fff; - /* initialize the energy/pitch/k states */ - tms->old_energy = tms->new_energy = tms->current_energy = tms->target_energy = 0; - tms->old_pitch = tms->new_pitch = tms->current_pitch = tms->target_pitch = 0; - memset(tms->old_k, 0, sizeof(tms->old_k)); - memset(tms->new_k, 0, sizeof(tms->new_k)); - memset(tms->current_k, 0, sizeof(tms->current_k)); - memset(tms->target_k, 0, sizeof(tms->target_k)); + /* initialize the energy/pitch/k states */ + tms->old_energy = tms->new_energy = tms->current_energy = tms->target_energy = 0; + tms->old_pitch = tms->new_pitch = tms->current_pitch = tms->target_pitch = 0; + memset(tms->old_k, 0, sizeof(tms->old_k)); + memset(tms->new_k, 0, sizeof(tms->new_k)); + memset(tms->current_k, 0, sizeof(tms->current_k)); + memset(tms->target_k, 0, sizeof(tms->target_k)); - /* initialize the sample generators */ - tms->interp_count = tms->sample_count = tms->pitch_count = 0; - memset(tms->u, 0, sizeof(tms->u)); - memset(tms->x, 0, sizeof(tms->x)); + /* initialize the sample generators */ + tms->interp_count = tms->sample_count = tms->pitch_count = 0; + memset(tms->x, 0, sizeof(tms->x)); + tms->next_is_address = FALSE; + tms->address = 0; + tms->schedule_dummy_read = TRUE; + tms->addr_bit = 0; } - /****************************************************************************************** - tms5110_set_M0_callback -- set M0 callback for the TMS5110 + tms5110_set_M0_callback -- set M0 callback for the TMS5110 ******************************************************************************************/ void tms5110_set_M0_callback(void *chip, int (*func)(void)) { struct tms5110 *tms = chip; - tms->M0_callback = func; + tms->M0_callback = func; } - /****************************************************************************************** - FIFO_data_write -- handle bit data write to the TMS5110 (as a result of toggling M0 pin) + tms5110_set_load_address -- set M0 callback for the TMS5110 + +******************************************************************************************/ + +void tms5110_set_load_address(void *chip, void (*func)(int)) +{ + struct tms5110 *tms = chip; + tms->set_load_address = func; +} + +/****************************************************************************************** + + FIFO_data_write -- handle bit data write to the TMS5110 (as a result of toggling M0 pin) ******************************************************************************************/ static void FIFO_data_write(struct tms5110 *tms, int data) @@ -201,21 +310,21 @@ static void FIFO_data_write(struct tms5110 *tms, int data) /****************************************************************************************** - extract_bits -- extract a specific number of bits from the FIFO + extract_bits -- extract a specific number of bits from the FIFO ******************************************************************************************/ static int extract_bits(struct tms5110 *tms, int count) { - int val = 0; + int val = 0; - while (count--) - { - val = (val << 1) | (tms->fifo[tms->fifo_head] & 1); - tms->fifo_count--; - tms->fifo_head = (tms->fifo_head + 1) % FIFO_SIZE; - } - return val; + while (count--) + { + val = (val << 1) | (tms->fifo[tms->fifo_head] & 1); + tms->fifo_count--; + tms->fifo_head = (tms->fifo_head + 1) % FIFO_SIZE; + } + return val; } static void request_bits(struct tms5110 *tms, int no) @@ -235,25 +344,29 @@ int i; static void perform_dummy_read(struct tms5110 *tms) { - if (tms->M0_callback) + if (tms->schedule_dummy_read) { - int data = (*tms->M0_callback)(); - if (DEBUG_5110) logerror("TMS5110 performing dummy read; value read = %1i\n", data&1); + if (tms->M0_callback) + { + int data = (*tms->M0_callback)(); + if (DEBUG_5110) logerror("TMS5110 performing dummy read; value read = %1i\n", data&1); + } + else + if (DEBUG_5110) logerror("-->ERROR: TMS5110 missing M0 callback function\n"); + tms->schedule_dummy_read = FALSE; } - else - if (DEBUG_5110) logerror("-->ERROR: TMS5110 missing M0 callback function\n"); } /********************************************************************************************** - tms5110_status_read -- read status from the TMS5110 + tms5110_status_read -- read status from the TMS5110 - bit 0 = TS - Talk Status is active (high) when the VSP is processing speech data. - Talk Status goes active at the initiation of a SPEAK command. - It goes inactive (low) when the stop code (Energy=1111) is processed, or - immediately(?????? not TMS5110) by a RESET command. - TMS5110 datasheets mention this is only available as a result of executing - TEST TALK command. + bit 0 = TS - Talk Status is active (high) when the VSP is processing speech data. + Talk Status goes active at the initiation of a SPEAK command. + It goes inactive (low) when the stop code (Energy=1111) is processed, or + immediately(?????? not TMS5110) by a RESET command. + TMS5110 datasheets mention this is only available as a result of executing + TEST TALK command. ***********************************************************************************************/ @@ -261,175 +374,178 @@ static void perform_dummy_read(struct tms5110 *tms) int tms5110_status_read(void *chip) { struct tms5110 *tms = chip; - if (DEBUG_5110) logerror("Status read: TS=%d\n", tms->talk_status); + if (DEBUG_5110) logerror("Status read: TS=%d\n", tms->talk_status); - return (tms->talk_status << 0); /*CTL1 = still talking ? */ + return (tms->talk_status << 0); /*CTL1 = still talking ? */ } /********************************************************************************************** - tms5110_ready_read -- returns the ready state of the TMS5110 + tms5110_ready_read -- returns the ready state of the TMS5110 ***********************************************************************************************/ int tms5110_ready_read(void *chip) { struct tms5110 *tms = chip; - return (tms->fifo_count < FIFO_SIZE-1); + return (tms->fifo_count < FIFO_SIZE-1); } /********************************************************************************************** - tms5110_process -- fill the buffer with a specific number of samples + tms5110_process -- fill the buffer with a specific number of samples ***********************************************************************************************/ void tms5110_process(void *chip, INT16 *buffer, unsigned int size) { struct tms5110 *tms = chip; - int buf_count=0; - int i, interp_period, cliptemp; + int buf_count=0; + int i, interp_period; + INT16 Y11, cliptemp; - /* if we're not speaking, fill with nothingness */ - if (!tms->speaking_now) - goto empty; + /* if we're not speaking, fill with nothingness */ + if (!tms->speaking_now) + goto empty; - /* if we're to speak, but haven't started */ - if (!tms->talk_status) - { + /* if we're to speak, but haven't started */ + if (!tms->talk_status) + { - /* a "dummy read" is mentioned in the tms5200 datasheet */ - /* The Bagman speech roms data are organized in such a way that - ** the bit at address 0 is NOT a speech data. The bit at address 1 - ** is the speech data. It seems that the tms5110 performs a dummy read - ** just before it executes a SPEAK command. - */ - perform_dummy_read(tms); + /* a "dummy read" is mentioned in the tms5200 datasheet */ + /* The Bagman speech roms data are organized in such a way that + ** the bit at address 0 is NOT a speech data. The bit at address 1 + ** is the speech data. It seems that the tms5110 performs a dummy read + ** just before it executes a SPEAK command. + ** This has been moved to command logic ... + ** perform_dummy_read(tms); + */ - /* clear out the new frame parameters (it will become old frame just before the first call to parse_frame() ) */ - tms->new_energy = 0; - tms->new_pitch = 0; - for (i = 0; i < 10; i++) - tms->new_k[i] = 0; + /* clear out the new frame parameters (it will become old frame just before the first call to parse_frame() ) */ + tms->new_energy = 0; + tms->new_pitch = 0; + for (i = 0; i < tms->coeff->num_k; i++) + tms->new_k[i] = 0; - tms->talk_status = 1; - } + tms->talk_status = 1; + } - /* loop until the buffer is full or we've stopped speaking */ - while ((size > 0) && tms->speaking_now) - { - int current_val; + /* loop until the buffer is full or we've stopped speaking */ + while ((size > 0) && tms->speaking_now) + { + int current_val; - /* if we're ready for a new frame */ - if ((tms->interp_count == 0) && (tms->sample_count == 0)) - { + /* if we're ready for a new frame */ + if ((tms->interp_count == 0) && (tms->sample_count == 0)) + { - /* remember previous frame */ - tms->old_energy = tms->new_energy; - tms->old_pitch = tms->new_pitch; - for (i = 0; i < 10; i++) - tms->old_k[i] = tms->new_k[i]; + /* remember previous frame */ + tms->old_energy = tms->new_energy; + tms->old_pitch = tms->new_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->old_k[i] = tms->new_k[i]; - /* if the old frame was a stop frame, exit and do not process any more frames */ - if (tms->old_energy == energytable[15]) - { - /*if (DEBUG_5110) logerror("processing frame: stop frame\n");*/ - tms->target_energy = tms->current_energy = 0; - tms->speaking_now = tms->talk_status = 0; - tms->interp_count = tms->sample_count = tms->pitch_count = 0; - goto empty; - } + /* if the old frame was a stop frame, exit and do not process any more frames */ + if (tms->old_energy == COEFF_ENERGY_SENTINEL) + { + /*if (DEBUG_5110) logerror("processing frame: stop frame\n");*/ + tms->target_energy = tms->current_energy = 0; + tms->speaking_now = tms->talk_status = 0; + tms->interp_count = tms->sample_count = tms->pitch_count = 0; + goto empty; + } - /* Parse a new frame into the new_energy, new_pitch and new_k[] */ - parse_frame(tms); + /* Parse a new frame into the new_energy, new_pitch and new_k[] */ + parse_frame(tms); - /* Set old target as new start of frame */ - tms->current_energy = tms->old_energy; - tms->current_pitch = tms->old_pitch; - for (i = 0; i < 10; i++) - tms->current_k[i] = tms->old_k[i]; + /* Set old target as new start of frame */ + tms->current_energy = tms->old_energy; + tms->current_pitch = tms->old_pitch; + + for (i = 0; i < tms->coeff->num_k; i++) + tms->current_k[i] = tms->old_k[i]; - /* is this the stop (ramp down) frame? */ - if (tms->new_energy == energytable[15]) - { - /*logerror("processing frame: ramp down\n");*/ - tms->target_energy = 0; - tms->target_pitch = tms->old_pitch; - for (i = 0; i < 10; i++) - tms->target_k[i] = tms->old_k[i]; - } - else if ((tms->old_energy == 0) && (tms->new_energy != 0)) /* was the old frame a zero-energy frame? */ - { - /* if so, and if the new frame is non-zero energy frame then the new parameters - should become our current and target parameters immediately, - i.e. we should NOT interpolate them slowly in. - */ + /* is this the stop (ramp down) frame? */ + if (tms->new_energy == COEFF_ENERGY_SENTINEL) + { + /*logerror("processing frame: ramp down\n");*/ + tms->target_energy = 0; + tms->target_pitch = tms->old_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->target_k[i] = tms->old_k[i]; + } + else if ((tms->old_energy == 0) && (tms->new_energy != 0)) /* was the old frame a zero-energy frame? */ + { + /* if so, and if the new frame is non-zero energy frame then the new parameters + should become our current and target parameters immediately, + i.e. we should NOT interpolate them slowly in. + */ - /*logerror("processing non-zero energy frame after zero-energy frame\n");*/ - tms->target_energy = tms->new_energy; - tms->target_pitch = tms->current_pitch = tms->new_pitch; - for (i = 0; i < 10; i++) - tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; - } - else if ((tms->old_pitch == 0) && (tms->new_pitch != 0)) /* is this a change from unvoiced to voiced frame ? */ - { - /* if so, then the new parameters should become our current and target parameters immediately, - i.e. we should NOT interpolate them slowly in. - */ - /*if (DEBUG_5110) logerror("processing frame: UNVOICED->VOICED frame change\n");*/ - tms->target_energy = tms->new_energy; - tms->target_pitch = tms->current_pitch = tms->new_pitch; - for (i = 0; i < 10; i++) - tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; - } - else if ((tms->old_pitch != 0) && (tms->new_pitch == 0)) /* is this a change from voiced to unvoiced frame ? */ - { - /* if so, then the new parameters should become our current and target parameters immediately, - i.e. we should NOT interpolate them slowly in. - */ - /*if (DEBUG_5110) logerror("processing frame: VOICED->UNVOICED frame change\n");*/ - tms->target_energy = tms->new_energy; - tms->target_pitch = tms->current_pitch = tms->new_pitch; - for (i = 0; i < 10; i++) - tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; - } - else - { - /*logerror("processing frame: Normal\n");*/ - /*logerror("*** Energy = %d\n",current_energy);*/ - /*logerror("proc: %d %d\n",last_fbuf_head,fbuf_head);*/ + /*logerror("processing non-zero energy frame after zero-energy frame\n");*/ + tms->target_energy = tms->new_energy; + tms->target_pitch = tms->current_pitch = tms->new_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; + } + else if ((tms->old_pitch == 0) && (tms->new_pitch != 0)) /* is this a change from unvoiced to voiced frame ? */ + { + /* if so, then the new parameters should become our current and target parameters immediately, + i.e. we should NOT interpolate them slowly in. + */ + /*if (DEBUG_5110) logerror("processing frame: UNVOICED->VOICED frame change\n");*/ + tms->target_energy = tms->new_energy; + tms->target_pitch = tms->current_pitch = tms->new_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; + } + else if ((tms->old_pitch != 0) && (tms->new_pitch == 0)) /* is this a change from voiced to unvoiced frame ? */ + { + /* if so, then the new parameters should become our current and target parameters immediately, + i.e. we should NOT interpolate them slowly in. + */ + /*if (DEBUG_5110) logerror("processing frame: VOICED->UNVOICED frame change\n");*/ + tms->target_energy = tms->new_energy; + tms->target_pitch = tms->current_pitch = tms->new_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->target_k[i] = tms->current_k[i] = tms->new_k[i]; + } + else + { + /*logerror("processing frame: Normal\n");*/ + /*logerror("*** Energy = %d\n",current_energy);*/ + /*logerror("proc: %d %d\n",last_fbuf_head,fbuf_head);*/ - tms->target_energy = tms->new_energy; - tms->target_pitch = tms->new_pitch; - for (i = 0; i < 10; i++) - tms->target_k[i] = tms->new_k[i]; - } - } - else if (tms->interp_count == 0) - { - /* interpolate (update) values based on step values */ - /*logerror("\n");*/ + tms->target_energy = tms->new_energy; + tms->target_pitch = tms->new_pitch; + for (i = 0; i < tms->coeff->num_k; i++) + tms->target_k[i] = tms->new_k[i]; + } + } + else if (tms->interp_count == 0) + { + /* interpolate (update) values based on step values */ + /*logerror("\n");*/ - interp_period = tms->sample_count / 25; - tms->current_energy += (tms->target_energy - tms->current_energy) / interp_coeff[interp_period]; - tms->current_pitch += (tms->target_pitch - tms->current_pitch) / interp_coeff[interp_period]; + interp_period = tms->sample_count / 25; + tms->current_energy += (tms->target_energy - tms->current_energy) / tms->coeff->interp_coeff[interp_period]; + tms->current_pitch += (tms->target_pitch - tms->current_pitch) / tms->coeff->interp_coeff[interp_period]; - /*logerror("*** Energy = %d\n",current_energy);*/ + /*logerror("*** Energy = %d\n",current_energy);*/ - for (i = 0; i < 10; i++) - { - tms->current_k[i] += (tms->target_k[i] - tms->current_k[i]) / interp_coeff[interp_period]; - } - } + for (i = 0; i < tms->coeff->num_k; i++) + { + tms->current_k[i] += (tms->target_k[i] - tms->current_k[i]) / tms->coeff->interp_coeff[interp_period]; + } + } @@ -437,92 +553,108 @@ void tms5110_process(void *chip, INT16 *buffer, unsigned int size) /* calculate the output */ - if (tms->current_energy == 0) - { - /* generate silent samples here */ - current_val = 0x00; - } - else if (tms->old_pitch == 0) - { - int bitout, randbit; + if (tms->current_energy == 0) + { + /* generate silent samples here */ + current_val = 0x00; + } + else if (tms->old_pitch == 0) + { + int bitout, randbit; - /* generate unvoiced samples here */ - if (tms->RNG&1) - randbit = -64; /* according to the patent it is (either + or -) half of the maximum value in the chirp table */ - else - randbit = 64; + /* generate unvoiced samples here */ + if (tms->RNG&1) + randbit = -64; /* according to the patent it is (either + or -) half of the maximum value in the chirp table */ + else + randbit = 64; - bitout = ((tms->RNG>>12)&1) ^ - ((tms->RNG>>10)&1) ^ - ((tms->RNG>> 9)&1) ^ - ((tms->RNG>> 0)&1); - tms->RNG >>= 1; - tms->RNG |= (bitout<<12); + bitout = ((tms->RNG>>12)&1) ^ + ((tms->RNG>>10)&1) ^ + ((tms->RNG>> 9)&1) ^ + ((tms->RNG>> 0)&1); + tms->RNG >>= 1; + tms->RNG |= (bitout<<12); - current_val = (randbit * tms->current_energy) / 256; - } - else - { - /* generate voiced samples here */ - current_val = (chirptable[tms->pitch_count%sizeof(chirptable)] * tms->current_energy) / 256; - } + current_val = randbit; + } + else + { + /* generate voiced samples here */ + if (tms->coeff->subtype & (SUBTYPE_TMS5100 | SUBTYPE_M58817)) + { + if (tms->pitch_count > 50) + current_val = 0; + else + current_val = tms->coeff->chirptable[tms->pitch_count]; + + } + else + current_val = (tms->coeff->chirptable[tms->pitch_count%sizeof(tms->coeff->chirptable)]); + } - /* Lattice filter here */ + /* Lattice filter here */ - tms->u[10] = current_val; + Y11 = (current_val * 64 * tms->current_energy) / 512; - for (i = 9; i >= 0; i--) - { - tms->u[i] = tms->u[i+1] - ((tms->current_k[i] * tms->x[i]) / 32768); - } - for (i = 9; i >= 1; i--) - { - tms->x[i] = tms->x[i-1] + ((tms->current_k[i-1] * tms->u[i-1]) / 32768); - } + for (i = tms->coeff->num_k - 1; i >= 0; i--) + { + Y11 = Y11 - ((tms->current_k[i] * tms->x[i]) / 512); + tms->x[i+1] = tms->x[i] + ((tms->current_k[i] * Y11) / 512); + } - tms->x[0] = tms->u[0]; + tms->x[0] = Y11; - /* clipping & wrapping, just like the patent */ + /* clipping & wrapping, just like the patent */ - cliptemp = tms->u[0]; - if (cliptemp > 2047) cliptemp = -2048 + (cliptemp-2047); - else if (cliptemp < -2048) cliptemp = 2047 - (cliptemp+2048); + /* YL10 - YL4 ==> DA6 - DA0 */ + cliptemp = Y11 / 16; - if (cliptemp > 511) - buffer[buf_count] = 127<<8; - else if (cliptemp < -512) - buffer[buf_count] = -128<<8; - else - buffer[buf_count] = cliptemp << 6; + /* M58817 seems to be different */ + if (tms->coeff->subtype & (SUBTYPE_M58817)) + cliptemp = cliptemp / 2; - /* Update all counts */ + if (cliptemp > 511) cliptemp = -512 + (cliptemp-511); + else if (cliptemp < -512) cliptemp = 511 - (cliptemp+512); - tms->sample_count = (tms->sample_count + 1) % 200; + if (cliptemp > 127) + buffer[buf_count] = 127*256; + else if (cliptemp < -128) + buffer[buf_count] = -128*256; + else + buffer[buf_count] = cliptemp *256; - if (tms->current_pitch != 0) - tms->pitch_count = (tms->pitch_count + 1) % tms->current_pitch; - else - tms->pitch_count = 0; + /* Update all counts */ - tms->interp_count = (tms->interp_count + 1) % 25; + tms->sample_count = (tms->sample_count + 1) % 200; - buf_count++; - size--; - } + if (tms->current_pitch != 0) + { + tms->pitch_count++; + if (tms->pitch_count >= tms->current_pitch) + tms->pitch_count = 0; + } + else + tms->pitch_count = 0; + + tms->interp_count = (tms->interp_count + 1) % 25; + + buf_count++; + size--; + } empty: - while (size > 0) - { - tms->sample_count = (tms->sample_count + 1) % 200; - tms->interp_count = (tms->interp_count + 1) % 25; + while (size > 0) + { + tms->sample_count = (tms->sample_count + 1) % 200; + tms->interp_count = (tms->interp_count + 1) % 25; - buffer[buf_count] = 0x00; - buf_count++; - size--; - } + buffer[buf_count] = 0x00; + buf_count++; + size--; + } } @@ -530,7 +662,7 @@ empty: /****************************************************************************************** - CTL_set -- set CTL pins named CTL1, CTL2, CTL4 and CTL8 + CTL_set -- set CTL pins named CTL1, CTL2, CTL4 and CTL8 ******************************************************************************************/ @@ -540,10 +672,9 @@ void tms5110_CTL_set(void *chip, int data) tms->CTL_pins = data & 0xf; } - /****************************************************************************************** - PDC_set -- set Processor Data Clock. Execute CTL_pins command on hi-lo transition. + PDC_set -- set Processor Data Clock. Execute CTL_pins command on hi-lo transition. ******************************************************************************************/ @@ -556,23 +687,50 @@ void tms5110_PDC_set(void *chip, int data) if (tms->PDC == 0) /* toggling 1->0 processes command on CTL_pins */ { /* the only real commands we handle now are SPEAK and RESET */ - - switch (tms->CTL_pins & 0xe) /*CTL1 - don't care*/ + if (tms->next_is_address) { - case TMS5110_CMD_SPEAK: - tms->speaking_now = 1; + tms->next_is_address = FALSE; + tms->address = tms->address | ((tms->CTL_pins & 0x0F)<addr_bit); + tms->addr_bit = (tms->addr_bit + 4) % 12; + tms->schedule_dummy_read = TRUE; + if (tms->set_load_address) + tms->set_load_address(tms->address); + } + else + { + switch (tms->CTL_pins & 0xe) /*CTL1 - don't care*/ + { + case TMS5110_CMD_SPEAK: + perform_dummy_read(tms); + tms->speaking_now = 1; - //should FIFO be cleared now ????? + //should FIFO be cleared now ????? + break; - break; + case TMS5110_CMD_RESET: + perform_dummy_read(tms); + tms5110_reset_chip(tms); + break; - case TMS5110_CMD_RESET: - tms->speaking_now = 0; - tms->talk_status = 0; - break; + case TMS5110_CMD_READ_BIT: + if (tms->schedule_dummy_read) + perform_dummy_read(tms); + else + { + request_bits(tms, 1); + tms->CTL_pins = (tms->CTL_pins & 0x0E) | extract_bits(tms, 1); + } + break; + + case TMS5110_CMD_LOAD_ADDRESS: + tms->next_is_address = TRUE; + break; + + default: + logerror("tms5110.c: unknown command: 0x%02x\n", tms->CTL_pins); + break; + } - default: - break; } } } @@ -582,126 +740,129 @@ void tms5110_PDC_set(void *chip, int data) /****************************************************************************************** - parse_frame -- parse a new frame's worth of data; returns 0 if not enough bits in buffer + parse_frame -- parse a new frame's worth of data; returns 0 if not enough bits in buffer ******************************************************************************************/ static void parse_frame(struct tms5110 *tms) { - int bits, indx, i, rep_flag; + int bits, indx, i, rep_flag, ene; - /* count the total number of bits available */ - bits = tms->fifo_count; + /* count the total number of bits available */ + bits = tms->fifo_count; - /* attempt to extract the energy index */ - bits -= 4; - if (bits < 0) - { - request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ - bits = 0; - } - indx = extract_bits(tms,4); - tms->new_energy = energytable[indx]; - - - /* if the energy index is 0 or 15, we're done */ - - if ((indx == 0) || (indx == 15)) - { - if (DEBUG_5110) logerror(" (4-bit energy=%d frame)\n",tms->new_energy); - - /* clear the k's */ - if (indx == 0) - { - for (i = 0; i < 10; i++) - tms->new_k[i] = 0; - } - - /* clear fifo if stop frame encountered */ - if (indx == 15) - { - if (DEBUG_5110) logerror(" (4-bit energy=%d STOP frame)\n",tms->new_energy); - tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0; - //speaking_now = talk_status = 0; - } - return; - } - - - /* attempt to extract the repeat flag */ - bits -= 1; - if (bits < 0) - { - request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ - bits = 0; - } - rep_flag = extract_bits(tms,1); - - /* attempt to extract the pitch */ - bits -= 5; - if (bits < 0) - { - request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ - bits = 0; - } - indx = extract_bits(tms,5); - tms->new_pitch = pitchtable[indx]; - - - /* if this is a repeat frame, just copy the k's */ - if (rep_flag) - { - //actually, we do nothing because the k's were already loaded (on parsing the previous frame) - - if (DEBUG_5110) logerror(" (10-bit energy=%d pitch=%d rep=%d frame)\n", tms->new_energy, tms->new_pitch, rep_flag); - return; - } - - - /* if the pitch index was zero, we need 4 k's */ - if (indx == 0) - { - /* attempt to extract 4 K's */ - bits -= 18; - if (bits < 0) - { + /* attempt to extract the energy index */ + bits -= tms->coeff->energy_bits; + if (bits < 0) + { request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ bits = 0; - } - tms->new_k[0] = k1table[extract_bits(tms,5)]; - tms->new_k[1] = k2table[extract_bits(tms,5)]; - tms->new_k[2] = k3table[extract_bits(tms,4)]; - tms->new_k[3] = k4table[extract_bits(tms,4)]; + } + indx = extract_bits(tms,tms->coeff->energy_bits); + tms->new_energy = tms->coeff->energytable[indx]; + ene = indx; + + /* if the energy index is 0 or 15, we're done */ + + if ((indx == 0) || (indx == 15)) + { + if (DEBUG_5110) logerror(" (4-bit energy=%d frame)\n",tms->new_energy); + + /* clear the k's */ + if (indx == 0) + { + for (i = 0; i < tms->coeff->num_k; i++) + tms->new_k[i] = 0; + } + + /* clear fifo if stop frame encountered */ + if (indx == 15) + { + if (DEBUG_5110) logerror(" (4-bit energy=%d STOP frame)\n",tms->new_energy); + tms->fifo_head = tms->fifo_tail = tms->fifo_count = 0; + } + return; + } + + + /* attempt to extract the repeat flag */ + bits -= 1; + if (bits < 0) + { + request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ + bits = 0; + } + rep_flag = extract_bits(tms,1); + + /* attempt to extract the pitch */ + bits -= tms->coeff->pitch_bits; + if (bits < 0) + { + request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ + bits = 0; + } + indx = extract_bits(tms,tms->coeff->pitch_bits); + tms->new_pitch = tms->coeff->pitchtable[indx]; + + /* if this is a repeat frame, just copy the k's */ + if (rep_flag) + { + //actually, we do nothing because the k's were already loaded (on parsing the previous frame) + + if (DEBUG_5110) logerror(" (10-bit energy=%d pitch=%d rep=%d frame)\n", tms->new_energy, tms->new_pitch, rep_flag); + return; + } + + + /* if the pitch index was zero, we need 4 k's */ + if (indx == 0) + { + /* attempt to extract 4 K's */ + bits -= 18; + if (bits < 0) + { + request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ + bits = 0; + } + for (i = 0; i < 4; i++) + tms->new_k[i] = tms->coeff->ktable[i][extract_bits(tms,tms->coeff->kbits[i])]; /* and clear the rest of the new_k[] */ - for (i = 4; i < 10; i++) - tms->new_k[i] = 0; + for (i = 4; i < tms->coeff->num_k; i++) + tms->new_k[i] = 0; - if (DEBUG_5110) logerror(" (28-bit energy=%d pitch=%d rep=%d 4K frame)\n", tms->new_energy, tms->new_pitch, rep_flag); - return; - } + if (DEBUG_5110) logerror(" (28-bit energy=%d pitch=%d rep=%d 4K frame)\n", tms->new_energy, tms->new_pitch, rep_flag); + return; + } - /* else we need 10 K's */ - bits -= 39; - if (bits < 0) - { - request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ + /* else we need 10 K's */ + bits -= 39; + if (bits < 0) + { + request_bits( tms,-bits ); /* toggle M0 to receive needed bits */ bits = 0; - } - tms->new_k[0] = k1table[extract_bits(tms,5)]; - tms->new_k[1] = k2table[extract_bits(tms,5)]; - tms->new_k[2] = k3table[extract_bits(tms,4)]; - tms->new_k[3] = k4table[extract_bits(tms,4)]; - tms->new_k[4] = k5table[extract_bits(tms,4)]; - tms->new_k[5] = k6table[extract_bits(tms,4)]; - tms->new_k[6] = k7table[extract_bits(tms,4)]; - tms->new_k[7] = k8table[extract_bits(tms,3)]; - tms->new_k[8] = k9table[extract_bits(tms,3)]; - tms->new_k[9] = k10table[extract_bits(tms,3)]; - - if (DEBUG_5110) logerror(" (49-bit energy=%d pitch=%d rep=%d 10K frame)\n", tms->new_energy, tms->new_pitch, rep_flag); + } +#if (DEBUG_5110) + printf("FrameDump %02d ", ene); + for (i = 0; i < tms->coeff->num_k; i++) + { + int x; + x = extract_bits(tms, tms->coeff->kbits[i]); + tms->new_k[i] = tms->coeff->ktable[i][x]; + printf("%02d ", x); + } + printf("\n"); +#else + for (i = 0; i < tms->coeff->num_k; i++) + { + int x; + x = extract_bits(tms, tms->coeff->kbits[i]); + tms->new_k[i] = tms->coeff->ktable[i][x]; + } +#endif + if (DEBUG_5110) logerror(" (49-bit energy=%d pitch=%d rep=%d 10K frame)\n", tms->new_energy, tms->new_pitch, rep_flag); } diff --git a/src/emu/sound/tms5110.h b/src/emu/sound/tms5110.h index faaba5375a2..63ec60dca47 100644 --- a/src/emu/sound/tms5110.h +++ b/src/emu/sound/tms5110.h @@ -13,12 +13,19 @@ #define TMS5110_CMD_READ_BRANCH (12) /* 1 1 0 x | 1 */ #define TMS5110_CMD_TEST_TALK (14) /* 1 1 1 x | 3 */ +/* Variants */ -void *tms5110_create(int index); +#define TMS5110_IS_5110A (1) +#define TMS5110_IS_5100 (2) +#define TMS5110_IS_M58817 (3) + + +void *tms5110_create(int index, int variant); void tms5110_destroy(void *chip); void tms5110_reset_chip(void *chip); void tms5110_set_M0_callback(void *chip, int (*func)(void)); +void tms5110_set_load_address(void *chip, void (*func)(int)); void tms5110_CTL_set(void *chip, int data); void tms5110_PDC_set(void *chip, int data); diff --git a/src/emu/sound/tms5110r.c b/src/emu/sound/tms5110r.c index 7e0040cf839..76d2d3ebcca 100644 --- a/src/emu/sound/tms5110r.c +++ b/src/emu/sound/tms5110r.c @@ -1,136 +1,234 @@ /* TMS5110 ROM Tables */ -/* Note: all the tables in this file were read from the real TMS5110A chip, except +/* Kx is (5-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ + +/* The following table is assumed to be for TMS5100 + * + * US Patent 4209836 + * 4331836 + * 4304964 + * 4234761 + * 4189779 + * 4449233 + * + * All patents give interpolation coefficients + * { 8, 8, 8, 4, 4, 2, 2, 1 } + * This sequence will not calculate the published + * fractions: + * 1 8 0.125 + * 2 8 0.234 + * 3 8 0.330 + * 4 4 0.498 + * 5 4 0.623 + * 6 2 0.717 + * 7 2 0.859 + * 0 1 1.000 + * + * Instead, { 8, 8, 8, 4, 4, 4, 2, 1 } + * will calculate those coefficients and this has been used below. + */ + +static const struct tms5100_coeffs pat4209836_coeff = +{ + /* subtype */ + SUBTYPE_TMS5100, + 10, + 4, + 5, + { 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 }, + /* E */ + { 0, 0, 1, 1, 2, 3, 5, 7, 10, 15, 21, 31, 43, 61, 86, 511 }, + /* P */ + { 0, 41, 43, 45, 47, 49, 51, 53, + 55, 58, 60, 63, 66, 70, 73, 76, + 79, 83, 87, 90, 94, 99, 103, 104, + 112, 118, 120, 129, 134, 140, 147, 153 }, + { + /* K1 */ + { -504, -497, -493, -488, -471, -471, -460, -446, + -427, -405, -378, -344, -501, -259, -206, -148, + -86, -5, 45, 110, 168, 131, 277, 320, + 357, 388, 413, 434, 451, 464, 474, 482 }, + /* K2 */ + { -349, -376, -305, -264, -252, -223, -192, -158, + -124, -88, -51, -14, 23, 60, 97, 133, + 167, 215, 230, 259, 286, 310, 333, 354, + 372, 389, 404, 417, 429, 439, 449, 506 }, + /* K3 */ + { -397, -365, -327, -266, -229, -170, -104, -36, + 35, 104, 169, 228, 281, 326, 364, 396 }, + /* K4 */ + { -369, -334, -296, -246, -191, -131, -67, -1, + 64, 128, 188, 243, 291, 332, 367, 397 }, + /* K5 */ + { -319, -286, -250, -211, -168, -122, -74, -25, + 24, 73, 121, 167, 210, 249, 285, 318 }, + /* K6 */ + { -290, -252, -209, -163, -114, -62, -9, 44, + 97, 147, 194, 255, 278, 313, 344, 371 }, + /* K7 */ + { -291, -256, -216, -174, -128, -96, -31, 19, + 69, 117, 163, 206, 246, 280, 316, 345 }, + /* K8 */ + { -218, -133, -38, 56, 152, 251, 305, 361 }, + /* K9 */ + { -225, -157, -82, -3, 76, 151, 220, 280 }, + /* K10 */ + { -179, -122, -61, 1, 62, 123, 179, 247 }, + }, + /* Chirptable */ + { 0, 42, -44, 50, -78, 18, 37, 20, + 2, -31, -59, 2, 95, 90, 5, 15, + 38, -4, -91,-91, -42,-35,-36, -4, + 37, 43, 34, 33, 15, -1, -8,-18, + -19,-17, -9,-10, -6, 0, 3, 2, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 }, + /* interpolation coefficients */ + { 8, 8, 8, 4, 4, 4, 2, 1 } +}; + +/* + * This table is from patent 4403965 + * also listed in 4331836 + * also listed in 4946391 + * + * Works best with M58817 ... + */ + +static const struct tms5100_coeffs pat4403965_coeff = +{ + /* subtype */ + SUBTYPE_M58817, + 10, + 4, + 5, + { 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 }, + /* E */ + { 0,1,2,3,4,6,8,11,16,23,33,47,63,85,114,511, }, + /* P */ + { 0,41,43,45,47,49,51,53,55,58,60,63,66,70,73,76,79,83,87,90,94,99,103,107,112,118,123,129,134,140,147,153, + }, + { + /* K1 */ + { + -501,-498,-495,-490,-485,-478,-469,-459,-446,-431,-412,-389,-362,-331,-295,-253,-207,-156,-102,-45,13,70,126,179,228,272,311,345,374,399,420,437, + }, + /* K2 */ + { + -376,-357,-335,-312,-286,-258,-227,-195,-161,-124,-87,-49,-10,29,68,106,143,178,212,243,272,299,324,346,366,384,400,414,427,438,448,506, + }, + /* K3 */ + { + -407,-381,-349,-311,-268,-218,-162,-102,-39,25,89,149,206,257,302,341, + }, + /* K4 */ + { + -290,-252,-209,-163,-114,-62,-9,44,97,147,194,238,278,313,344,371, + }, + /* K5 */ + { + -318,-283,-245,-202,-156,-107,-56,-3,49,101,150,196,239,278,313,344, + }, + /* K6 */ + { + -193,-152,-109,-65,-20,26,71,115,158,198,235,270,301,330,355,377, + }, + /* K7 */ + { + -254,-218,-180,-140,-97,-53,-8,36,81,124,165,204,240,274,304,332, + }, + /* K8 */ + { + -205,-112,-10,92,187,269,336,387, + }, + /* K9 */ + { + -249,-183,-110,-19,48,126,198,261, + }, + /* K10 */ + { + -190,-133,-73,-10,53,115,173,227, + }, + }, + /* Chirptable */ + { 0,43,-44,51,-77,18,37,20, + 2,-30,-58,3,96,91,5,15, + 38,-4,-90,-91,-42,-35,-35,-3, + 37,43,35,34,15,-1,-8,-17, + -19,-17,-9,-9,-6,1,4,3, + 1,0,0,0,0,0,0,0, + 0,0,0 + }, + /* interpolation coefficients */ + { 8, 8, 8, 4, 4, 4, 2, 1 } +}; + + +/* Note: the following tables in this file were read from the real TMS5110A chip, except for the chirptable and the interp_coeff */ -/* This is the energy lookup table (4-bits -> 10-bits) */ -const static unsigned short energytable[0x10] = { -0*2, 1*2, 2*2, 3*2, -4*2, 6*2, 8*2, 11*2, -16*2, 23*2, 33*2, 47*2, -63*2, 85*2, 114*2, 511 }; /*note: the last value (511) is not a true energy value, it's just a stop-sentinel */ - - -/* This is the tms5110 pitchtable */ -const static unsigned short pitchtable [0x20]={ -0, 15, 16, 17, -19, 21, 22, 25, -26, 29, 32, 36, -40, 42, 46, 50, -55, 60, 64, 68, -72, 76, 80, 84, -86, 93, 101, 110, -120, 132, 144, 159 }; - - -/* These are the reflection coefficient lookup tables */ - -/* K1 is (5-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k1table[0x20] = { --501*64, -498*64, -497*64, -495*64, --493*64, -491*64, -488*64, -482*64, --478*64, -474*64, -469*64, -464*64, --459*64, -452*64, -445*64, -437*64, --412*64, -380*64, -339*64, -288*64, --227*64, -158*64, -81*64, -1*64, - 80*64, 157*64, 226*64, 287*64, - 337*64, 379*64, 411*64, 436*64 }; - -/* K2 is (5-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k2table[0x20] = { --328*64, -303*64, -274*64, -244*64, --211*64, -175*64, -138*64, -99*64, - -59*64, -18*64, 24*64, 64*64, - 105*64, 143*64, 180*64, 215*64, - 248*64, 278*64, 306*64, 331*64, - 354*64, 374*64, 392*64, 408*64, - 422*64, 435*64, 445*64, 455*64, - 463*64, 470*64, 476*64, 506*64 }; - -/* K3 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k3table[0x10] = { --441*64, -387*64, -333*64, -279*64, --225*64, -171*64, -117*64, -63*64, - -9*64, 45*64, 98*64, 152*64, - 206*64, 260*64, 314*64, 368*64 }; - -/* K4 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k4table[0x10] = { --328*64, -273*64, -217*64, -161*64, --106*64, -50*64, 5*64, 61*64, - 116*64, 172*64, 228*64, 283*64, - 339*64, 394*64, 450*64, 506*64 }; - -/* K5 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k5table[0x10] = { --328*64, -282*64, -235*64, -189*64, --142*64, -96*64, -50*64, -3*64, - 43*64, 90*64, 136*64, 182*64, - 229*64, 275*64, 322*64, 368*64 }; - -/* K6 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k6table[0x10] = { --256*64, -212*64, -168*64, -123*64, - -79*64, -35*64, 10*64, 54*64, - 98*64, 143*64, 187*64, 232*64, - 276*64, 320*64, 365*64, 409*64 }; - -/* K7 is (4-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k7table[0x10] = { --308*64, -260*64, -212*64, -164*64, --117*64, -69*64, -21*64, 27*64, - 75*64, 122*64, 170*64, 218*64, - 266*64, 314*64, 361*64, 409*64 }; - -/* K8 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k8table[0x08] = { --256*64, -161*64, -66*64, 29*64, - 124*64, 219*64, 314*64, 409*64 }; - -/* K9 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k9table[0x08] = { --256*64, -176*64, -96*64, -15*64, - 65*64, 146*64, 226*64, 307*64 }; - -/* K10 is (3-bits -> 9 bits+sign, 2's comp. fractional (-1 < x < 1) */ - -const static int k10table[0x08] = { --205*64, -132*64, -59*64, 14*64, - 87*64, 160*64, 234*64, 307*64 }; - - -/* chirp table */ - -const static signed char chirptable[51] = { -0x00, 0x2a, (char)0xd4, 0x32, -(char)0xb2, 0x12, 0x25, 0x14, -0x02, (char)0xe1, (char)0xc5, 0x02, -0x5f, 0x5a, 0x05, 0x0f, -0x26, (char)0xfc, (char)0xa5, (char)0xa5, -(char)0xd6, (char)0xdd, (char)0xdc, (char)0xfc, -0x25, 0x2b, 0x22, 0x21, -0x0f, (char)0xff, (char)0xf8, (char)0xee, -(char)0xed, (char)0xef, (char)0xf7, (char)0xf6, -(char)0xfa, 0x00, 0x03, 0x02, -0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00 +static const struct tms5100_coeffs tms5110_coeff = +{ + /* subtype */ + SUBTYPE_TMS5110, + 10, + 4, + 5, + { 5, 5, 4, 4, 4, 4, 4, 3, 3, 3 }, + /* E */ + { 0, 1, 2, 3, 4, 6, 8, 11, + 16, 23, 33, 47, 63, 85, 114, 511 }, + /* P */ + { 0, 15, 16, 17, 19, 21, 22, 25, + 26, 29, 32, 36, 40, 42, 46, 50, + 55, 60, 64, 68, 72, 76, 80, 84, + 86, 93, 101, 110, 120, 132, 144, 159 }, + { + /* K1 */ + { -501, -498, -497, -495, -493, -491, -488, -482, + -478, -474, -469, -464, -459, -452, -445, -437, + -412, -380, -339, -288, -227, -158, -81, -1, + 80, 157, 226, 287, 337, 379, 411, 436 }, + /* K2 */ + { -328, -303, -274, -244, -211, -175, -138, -99, + -59, -18, 24, 64, 105, 143, 180, 215, + 248, 278, 306, 331, 354, 374, 392, 408, + 422, 435, 445, 455, 463, 470, 476, 506 }, + /* K3 */ + { -441, -387, -333, -279, -225, -171, -117, -63, + -9, 45, 98, 152, 206, 260, 314, 368 }, + /* K4 */ + { -328, -273, -217, -161, -106, -50, 5, 61, + 116, 172, 228, 283, 339, 394, 450, 506 }, + /* K5 */ + { -328, -282, -235, -189, -142, -96, -50, -3, + 43, 90, 136, 182, 229, 275, 322, 368 }, + /* K6 */ + { -256, -212, -168, -123, -79, -35, 10, 54, + 98, 143, 187, 232, 276, 320, 365, 409 }, + /* K7 */ + { -308, -260, -212, -164, -117, -69, -21, 27, + 75, 122, 170, 218, 266, 314, 361, 409 }, + /* K8 */ + { -256, -161, -66, 29, 124, 219, 314, 409 }, + /* K9 */ + { -256, -176, -96, -15, 65, 146, 226, 307 }, + /* K10 */ + { -205, -132, -59, 14, 87, 160, 234, 307 }, + }, + /* Chirptable */ + { 0, 42, -44, 50, -78, 18, 37, 20, + 2, -31, -59, 2, 95, 90, 5, 15, + 38, -4, -91,-91, -42,-35,-36, -4, + 37, 43, 34, 33, 15, -1, -8,-18, + -19,-17, -9,-10, -6, 0, 3, 2, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 }, + /* interpolation coefficients */ + { 8, 8, 8, 4, 4, 4, 2, 1 } }; -/* interpolation coefficients */ - -const static char interp_coeff[8] = { -8, 8, 8, 4, 4, 2, 2, 1 -}; diff --git a/src/mame/audio/dkong.c b/src/mame/audio/dkong.c index 93907c233ea..51613860abb 100644 --- a/src/mame/audio/dkong.c +++ b/src/mame/audio/dkong.c @@ -6,7 +6,8 @@ #include "sound/discrete.h" #include "sound/dac.h" -#include "sound/m58817.h" +#include "sound/tms5110.h" +#include "sound/5110intf.h" #include "includes/dkong.h" @@ -16,13 +17,6 @@ * ****************************************************************/ -/* Set to 1 to use speech synthesizer instead of samples. - * Disabled by default since M58817 emulation is not - * complete due to missing information about coefficients. - */ - -#define RADARSC1_USE_M58817 (0) - #define ACTIVELOW_PORT_BIT(P,A,D) (((P) & (~(1 << (A)))) | (((D) ^ 1) << (A))) /* Needed for dkongjr ... FIXME */ @@ -80,7 +74,7 @@ /* General defines */ -#define DK_1N5553_V 0.4 // from datasheet at 1mA +#define DK_1N5553_V 0.4 /* from datasheet at 1mA */ #define DK_SUP_V 5.0 #define NE555_INTERNAL_R RES_K(5) @@ -730,7 +724,8 @@ static SOUND_RESET( dkongjr ) http://www.freepatentsonline.com/4633500.html - @0x510, cpu2 +Addresses found at @0x510, cpu2 + 10: 0000 00 00000000 ... 50 53 01010000 01010011 "scramble" 12: 007a 44 01000100 ... 00 0f 00000000 00001111 "all pilots climb up" 14: 018b 13 00010011 ... dc f0 11011100 11110000 @@ -762,14 +757,61 @@ http://www.freepatentsonline.com/4633500.html 5: 10 10 10 trouble, trouble, trouble 6: 12 12 all pilots climb up 7: 20 engine trouble + + PA5 ==> CS 28 + PA4 ==> PDC 2 + PA0 ==> CTL1 25 + PA1 ==> CTL2 23 + PA2 ==> CTL4 20 + PA3 ==> CTL8 27 + M1 19 ==> PA6 M1 on TMS5100 + + 12,13 Speaker + 7,8 Xin, Xout (5100: RC-OSC, T11) + 24 A0 (5100: ADD1) + 22 A1 (5100: ADD2) + 22 A2 (5100: ADD4) + 26 A3 (5100: ADD8) + 16 C0 (5100: NC) + 18 C1 (5100: NC) + 3 CLK (5100: ROM-CK) + + For documentation purposes: + + Addresses + { 0x0000, 0x007a, 0x018b, 0x0320, 0x036c, 0x03c4, 0x041c, 0x0520, 0x063e } + and related samples interface + + static const char *const radarsc1_sample_names[] = + { + "*radarsc1", + "10.wav", + "12.wav", + "14.wav", + "16.wav", + "18.wav", + "1A.wav", + "1C.wav", + "1E.wav", + "20.wav", + 0 + }; + + static const struct Samplesinterface radarsc1_samples_interface = + { + 8, + radarsc1_sample_names + }; + */ static WRITE8_HANDLER( M58817_command_w ) { logerror("PA Write %x\n", data); - m58817_CTL_w(0, data & 0x0f); - m58817_DRQ_w(0, (data>>4) & 0x01); // FIXME 0x20 ?? + tms5110_CTL_w(0, data & 0x0f); + tms5110_PDC_w(0, (data>>4) & 0x01); + // FIXME 0x20 is CS } /**************************************************************** @@ -803,12 +845,15 @@ static READ8_HANDLER( dkong_sh_tune_r ) dkong_state *state = Machine->driver_data; UINT8 *SND = memory_region(REGION_CPU2); - if ( state->page & 0x40 ) + if ( state->page & 0x40 ) { return soundlatch_r(0) & 0x0F; } else + { + printf("rom access at pc = %4x\n",activecpu_get_pc()); return (SND[0x1000+(state->page & 7)*256+offset]); + } } static READ8_HANDLER( dkongjr_sh_tune_r ) @@ -840,7 +885,7 @@ static READ8_HANDLER( radarsc1_sh_p1_r ) { int r; - r = (I8035_P1_R() & 0x80) | (m58817_status_r(0)<<6); + r = (I8035_P1_R() & 0x80) | (tms5110_status_r(0)<<6); return r; } @@ -982,22 +1027,22 @@ WRITE8_HANDLER( dkongjr_snd_w1 ) case 3: /* Port 3 write ==> PB 5 */ I8035_P2_W_AL(5,data & 1); break; -#if 0 // above verified from schematics +#if 0 // above verified from schematics case 3: /* roar */ if (data) sample_start (7,2,0); break; #endif case 4: /* Port 4 write */ - I8035_T_W_AL(1, data & 1); + I8035_T_W_AL(1, data & 1); break; case 5: /* Port 5 write */ - I8035_T_W_AL(0, data & 1); + I8035_T_W_AL(0, data & 1); break; case 6: /* Port 6 write ==> PB 4 */ I8035_P2_W_AL(4,data & 1); break; -#if 0 // above verified from schematics +#if 0 // above verified from schematics case 6: /* snapjaw */ if (data) sample_stop (7); @@ -1022,7 +1067,7 @@ WRITE8_HANDLER( dkongjr_snd_w2 ) case 0: dkong_audio_irq_w(0, data & 1); break; -#if 0 // above verified from schematics +#if 0 // above verified from schematics case 0: /* death */ if (data) sample_stop (7); @@ -1038,8 +1083,6 @@ WRITE8_HANDLER( dkongjr_snd_w2 ) } } - - /************************************* * * Sound CPU memory handlers @@ -1123,42 +1166,16 @@ static const struct Samplesinterface dkongjr_samples_interface = dkongjr_sample_names }; -#if !RADARSC1_USE_M58817 -static const char *const radarsc1_sample_names[] = -{ - "*radarsc1", - "10.wav", - "12.wav", - "14.wav", - "16.wav", - "18.wav", - "1A.wav", - "1C.wav", - "1E.wav", - "20.wav", - 0 /* end of array */ -}; - -static const struct Samplesinterface radarsc1_samples_interface = -{ - 8, /* 8 channels */ - radarsc1_sample_names -}; -#endif - static const struct NESinterface nes_interface_1 = { REGION_CPU2 }; static const struct NESinterface nes_interface_2 = { REGION_CPU3 }; -static const struct M58817interface m58817_interface = +static struct TMS5110interface tms5110_interface = { -#if !RADARSC1_USE_M58817 - -1, -#else + TMS5110_IS_M58817, REGION_SOUND1, /* Sample Rom */ -#endif - { 0x0000, 0x007a, 0x018b, 0x0320, 0x036c, 0x03c4, 0x041c, 0x0520, 0x063e } /* sample address map */ + NULL, + NULL }; - /************************************* * * Machine driver @@ -1186,7 +1203,7 @@ MACHINE_DRIVER_START( radarscp_audio ) MDRV_IMPORT_FROM( dkong2b_audio ) MDRV_SOUND_MODIFY("discrete") MDRV_SOUND_CONFIG_DISCRETE(radarscp) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.7) MACHINE_DRIVER_END @@ -1199,15 +1216,9 @@ MACHINE_DRIVER_START( radarsc1_audio ) MDRV_SOUND_START(radarsc1) - MDRV_SOUND_ADD(M58817, 640000) - MDRV_SOUND_CONFIG(m58817_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.7) - -#if !RADARSC1_USE_M58817 - MDRV_SOUND_ADD(SAMPLES, 0) - MDRV_SOUND_CONFIG(radarsc1_samples_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 3.0) -#endif + MDRV_SOUND_ADD(TMS5110, 640000) + MDRV_SOUND_CONFIG(tms5110_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END diff --git a/src/mame/drivers/bagman.c b/src/mame/drivers/bagman.c index 6bc3b78dc18..28dda17b01c 100644 --- a/src/mame/drivers/bagman.c +++ b/src/mame/drivers/bagman.c @@ -555,7 +555,8 @@ static const struct AY8910interface ay8910_interface = static const struct TMS5110interface tms5110_interface = { - 0, /*irq callback function*/ + TMS5110_IS_5110A, + -1, /* ROM_REGION */ bagman_speech_rom_read_bit /*M0 callback function. Called whenever chip requests a single bit of data*/ }; diff --git a/src/mame/drivers/cvs.c b/src/mame/drivers/cvs.c index 34e51bfed0f..8dfe7aa53d5 100644 --- a/src/mame/drivers/cvs.c +++ b/src/mame/drivers/cvs.c @@ -221,7 +221,9 @@ static READ8_HANDLER( cvs_393hz_Clock_r ) static const struct TMS5110interface tms5110_interface = { - 0, /*irq callback function*/ + //TMS5110_IS_5110A, + TMS5110_IS_5100, + -1, /* ROM Region */ cvs_speech_rom_read_bit /*M0 callback function. Called whenever chip requests a single bit of data*/ }; diff --git a/src/mame/drivers/scramble.c b/src/mame/drivers/scramble.c index 0dc982ba756..78a13ee58df 100644 --- a/src/mame/drivers/scramble.c +++ b/src/mame/drivers/scramble.c @@ -1975,7 +1975,8 @@ static const struct AY8910interface triplep_ay8910_interface = static const struct TMS5110interface tms5110_interface = { - 0, /* irq callback function */ + TMS5110_IS_5110A, + -1, /* rom_region */ ad2083_speech_rom_read_bit /* M0 callback function. Called whenever chip requests a single bit of data */ }; diff --git a/src/mame/mame.mak b/src/mame/mame.mak index ebd672ca450..804ddbf9270 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -287,7 +287,6 @@ SOUNDS += RF5C400 SOUNDS += SPEAKER SOUNDS += CDP1869 SOUNDS += S14001A -SOUNDS += M58817 SOUNDS += BEEP #SOUNDS += WAVE #SOUNDS += SID6581