summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Zsolt Vasvari <zsoltvas@mamedev.org>2008-01-21 03:36:21 +0000
committer Zsolt Vasvari <zsoltvas@mamedev.org>2008-01-21 03:36:21 +0000
commitadcf70548a1457bb5b20647e19472964d5df8508 (patch)
tree0e8b3ddf7bd48365229b087f339f45572df9ae64 /src
parent08efd6203a698b17777ea9fc8c51bce094040401 (diff)
- Added MC3417 and MC3418 variants
- Changed Mouse Trap to use MC3417
Diffstat (limited to 'src')
-rw-r--r--src/emu/sndintrf.c4
-rw-r--r--src/emu/sndintrf.h2
-rw-r--r--src/emu/sound/hc55516.c138
-rw-r--r--src/emu/sound/hc55516.h7
-rw-r--r--src/mame/audio/exidy.c14
5 files changed, 113 insertions, 52 deletions
diff --git a/src/emu/sndintrf.c b/src/emu/sndintrf.c
index 7d7a9031ccd..7a421f09c3b 100644
--- a/src/emu/sndintrf.c
+++ b/src/emu/sndintrf.c
@@ -124,6 +124,8 @@ void msm5205_get_info(void *token, UINT32 state, sndinfo *info);
void msm5232_get_info(void *token, UINT32 state, sndinfo *info);
void upd7759_get_info(void *token, UINT32 state, sndinfo *info);
void hc55516_get_info(void *token, UINT32 state, sndinfo *info);
+void mc3417_get_info(void *token, UINT32 state, sndinfo *info);
+void mc3418_get_info(void *token, UINT32 state, sndinfo *info);
void k005289_get_info(void *token, UINT32 state, sndinfo *info);
void k007232_get_info(void *token, UINT32 state, sndinfo *info);
void k051649_get_info(void *token, UINT32 state, sndinfo *info);
@@ -336,6 +338,8 @@ static const struct
#endif
#if (HAS_HC55516)
{ SOUND_HC55516, hc55516_get_info },
+ { SOUND_MC3417, mc3417_get_info },
+ { SOUND_MC3418, mc3418_get_info },
#endif
#if (HAS_K005289)
{ SOUND_K005289, k005289_get_info },
diff --git a/src/emu/sndintrf.h b/src/emu/sndintrf.h
index 12f4ba7ca02..4a1fd97c34a 100644
--- a/src/emu/sndintrf.h
+++ b/src/emu/sndintrf.h
@@ -88,6 +88,8 @@ enum _sound_type
SOUND_MSM5232,
SOUND_UPD7759,
SOUND_HC55516,
+ SOUND_MC3417,
+ SOUND_MC3418,
SOUND_K005289,
SOUND_K007232,
SOUND_K051649,
diff --git a/src/emu/sound/hc55516.c b/src/emu/sound/hc55516.c
index ff0b6492212..fe0448e31df 100644
--- a/src/emu/sound/hc55516.c
+++ b/src/emu/sound/hc55516.c
@@ -1,15 +1,25 @@
+/*****************************************************************************
+
+ Harris HC-55516 (and related) emulator
+
+ Copyright Nicola Salmoria and the MAME Team
+
+ Notes:
+ * The only difference between MC3417 and MC3418 is the number
+ of bits checked for the Coincidence Output. For the MC3417,
+ it is three bits, while for the MC3418 it is four.
+ This is not emulated.
+
+*****************************************************************************/
+
#include "sndintrf.h"
#include "streams.h"
-#include "hc55516.h"
#include <math.h>
-#include "cpuintrf.h"
-
-/* default to 4x oversampling */
+/* 4x oversampling */
#define SAMPLE_RATE (48000 * 4)
-
#define INTEGRATOR_LEAK_TC 0.001
#define FILTER_DECAY_TC 0.004
#define FILTER_CHARGE_TC 0.004
@@ -22,8 +32,9 @@ struct hc55516_data
{
sound_stream *channel;
int clock; /* 0 = software driven, non-0 = oscillator */
+ int active_clock_hi;
- UINT8 last_clock;
+ UINT8 last_clock_state;
UINT8 databit;
UINT8 new_databit;
UINT8 shiftreg;
@@ -45,7 +56,7 @@ static void hc55516_update(void *param, stream_sample_t **inputs, stream_sample_
-static void *hc55516_start(int sndindex, int clock, const void *config)
+static void *start_common(int sndindex, int clock, const void *config, int _active_clock_hi)
{
struct hc55516_data *chip;
@@ -60,9 +71,11 @@ static void *hc55516_start(int sndindex, int clock, const void *config)
/* create the stream */
chip->clock = clock;
+ chip->active_clock_hi = _active_clock_hi;
+ chip->last_clock_state = 0;
chip->channel = stream_create(0, 1, SAMPLE_RATE, chip, hc55516_update);
- state_save_register_item("hc55516", sndindex, chip->last_clock);
+ state_save_register_item("hc55516", sndindex, chip->last_clock_state);
state_save_register_item("hc55516", sndindex, chip->databit);
state_save_register_item("hc55516", sndindex, chip->new_databit);
state_save_register_item("hc55516", sndindex, chip->shiftreg);
@@ -77,7 +90,40 @@ static void *hc55516_start(int sndindex, int clock, const void *config)
}
-INLINE int current_clock_edge(struct hc55516_data *chip)
+static void *hc55516_start(int sndindex, int clock, const void *config)
+{
+ return start_common(sndindex, clock, config, TRUE);
+}
+
+
+static void *mc3417_start(int sndindex, int clock, const void *config)
+{
+ return start_common(sndindex, clock, config, FALSE);
+}
+
+
+static void *mc3418_start(int sndindex, int clock, const void *config)
+{
+ return start_common(sndindex, clock, config, FALSE);
+}
+
+
+
+static void hc55516_reset(void *chip)
+{
+ ((struct hc55516_data *)chip)->last_clock_state = 0;
+}
+
+
+
+INLINE int is_active_clock_transition(struct hc55516_data *chip, int clock_state)
+{
+ return (( chip->active_clock_hi && !chip->last_clock_state && clock_state) ||
+ (!chip->active_clock_hi && chip->last_clock_state && !clock_state));
+}
+
+
+INLINE int current_clock_state(struct hc55516_data *chip)
{
return ((UINT64)chip->update_count * chip->clock * 2 / SAMPLE_RATE) & 0x01;
}
@@ -159,28 +205,26 @@ static void hc55516_update(void *param, stream_sample_t **inputs, stream_sample_
if (chip->clock != 0)
{
- int edge = current_clock_edge(chip);
-
/* external oscillator */
for (i = 0; i < length; i++, data += slope)
{
- int new_edge;
+ UINT8 clock_state;
*buffer++ = data;
chip->update_count++;
- new_edge = current_clock_edge(chip);
+ clock_state = current_clock_state(chip);
- /* pull in next data bit on falling edge of the clock */
- if (edge && !new_edge)
+ /* pull in next data bit on the appropriate edge of the clock */
+ if (is_active_clock_transition(chip, clock_state))
{
chip->databit = chip->new_databit;
process_bit(chip);
}
- edge = new_edge;
+ chip->last_clock_state = clock_state;
}
}
@@ -194,16 +238,12 @@ static void hc55516_update(void *param, stream_sample_t **inputs, stream_sample_
void hc55516_clock_w(int num, int state)
{
struct hc55516_data *chip = sndti_token(SOUND_HC55516, num);
- int clock = state & 1, diffclock;
+ UINT8 clock_state = state ? TRUE : FALSE;
assert(chip->clock == 0);
- /* update the clock */
- diffclock = clock ^ chip->last_clock;
- chip->last_clock = clock;
-
- /* speech clock changing (active on rising edge) */
- if (diffclock && clock)
+ /* speech clock changing? */
+ if (is_active_clock_transition(chip, clock_state))
{
/* update the output buffer before changing the registers */
stream_update(chip->channel);
@@ -213,6 +253,9 @@ void hc55516_clock_w(int num, int state)
process_bit(chip);
}
+
+ /* update the clock */
+ chip->last_clock_state = clock_state;
}
@@ -250,7 +293,7 @@ void hc55516_digit_clock_clear_w(int num, int data)
}
-int hc55516_clock_edge_r(int num)
+int hc55516_clock_state_r(int num)
{
struct hc55516_data *chip = sndti_token(SOUND_HC55516, num);
@@ -258,7 +301,7 @@ int hc55516_clock_edge_r(int num)
stream_update(chip->channel);
- return current_clock_edge(chip);
+ return current_clock_state(chip);
}
@@ -268,16 +311,14 @@ WRITE8_HANDLER( hc55516_0_clock_w ) { hc55516_clock_w(0,data); }
WRITE8_HANDLER( hc55516_0_clock_clear_w ) { hc55516_clock_clear_w(0,data); }
WRITE8_HANDLER( hc55516_0_clock_set_w ) { hc55516_clock_set_w(0,data); }
WRITE8_HANDLER( hc55516_0_digit_clock_clear_w ) { hc55516_digit_clock_clear_w(0,data); }
-READ8_HANDLER ( hc55516_0_clock_edge_r ) { return hc55516_clock_edge_r(0); }
+READ8_HANDLER ( hc55516_0_clock_state_r ) { return hc55516_clock_state_r(0); }
WRITE8_HANDLER( hc55516_1_digit_w ) { hc55516_digit_w(1,data); }
WRITE8_HANDLER( hc55516_1_clock_w ) { hc55516_clock_w(1,data); }
WRITE8_HANDLER( hc55516_1_clock_clear_w ) { hc55516_clock_clear_w(1,data); }
WRITE8_HANDLER( hc55516_1_clock_set_w ) { hc55516_clock_set_w(1,data); }
WRITE8_HANDLER( hc55516_1_digit_clock_clear_w ) { hc55516_digit_clock_clear_w(1,data); }
-READ8_HANDLER ( hc55516_1_clock_edge_r ) { return hc55516_clock_edge_r(1); }
-
-
+READ8_HANDLER ( hc55516_1_clock_state_r ) { return hc55516_clock_state_r(1); }
@@ -285,29 +326,19 @@ READ8_HANDLER ( hc55516_1_clock_edge_r ) { return hc55516_clock_edge_r(1); }
* Generic get_info
**************************************************************************/
-static void hc55516_set_info(void *token, UINT32 state, sndinfo *info)
-{
- switch (state)
- {
- /* no parameters to set */
- }
-}
-
-
void hc55516_get_info(void *token, UINT32 state, sndinfo *info)
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
+ case SNDINFO_INT_ALIAS: info->i = SOUND_HC55516; break;
/* --- the following bits of info are returned as pointers to data or functions --- */
- case SNDINFO_PTR_SET_INFO: info->set_info = hc55516_set_info; break;
case SNDINFO_PTR_START: info->start = hc55516_start; break;
- case SNDINFO_PTR_STOP: /* nothing */ break;
- case SNDINFO_PTR_RESET: /* nothing */ break;
+ case SNDINFO_PTR_RESET: info->reset = hc55516_reset; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
- case SNDINFO_STR_NAME: info->s = "HC55516"; break;
+ case SNDINFO_STR_NAME: info->s = "HC-55516"; break;
case SNDINFO_STR_CORE_FAMILY: info->s = "CVSD"; break;
case SNDINFO_STR_CORE_VERSION: info->s = "2.0"; break;
case SNDINFO_STR_CORE_FILE: info->s = __FILE__; break;
@@ -315,3 +346,26 @@ void hc55516_get_info(void *token, UINT32 state, sndinfo *info)
}
}
+
+void mc3417_get_info(void *token, UINT32 state, sndinfo *info)
+{
+ switch (state)
+ {
+ case SNDINFO_PTR_START: info->start = mc3417_start; break;
+ case SNDINFO_PTR_RESET: /* chip has no reset pin */ break;
+ case SNDINFO_STR_NAME: info->s = "MC3417"; break;
+ default: hc55516_get_info(token, state, info); break;
+ }
+}
+
+
+void mc3418_get_info(void *token, UINT32 state, sndinfo *info)
+{
+ switch (state)
+ {
+ case SNDINFO_PTR_START: info->start = mc3418_start; break;
+ case SNDINFO_PTR_RESET: /* chip has no reset pin */ break;
+ case SNDINFO_STR_NAME: info->s = "MC3418"; break;
+ default: hc55516_get_info(token, state, info); break;
+ }
+}
diff --git a/src/emu/sound/hc55516.h b/src/emu/sound/hc55516.h
index 318f7296aad..45c8ed83d80 100644
--- a/src/emu/sound/hc55516.h
+++ b/src/emu/sound/hc55516.h
@@ -15,21 +15,22 @@ void hc55516_clock_set_w(int num, int data);
/* clears the clock state and sets the databit */
void hc55516_digit_clock_clear_w(int num, int data);
-int hc55516_clock_edge_r(int num);
+/* returns whether the clock is currently LO or HI */
+int hc55516_clock_state_r(int num);
WRITE8_HANDLER( hc55516_0_digit_w );
WRITE8_HANDLER( hc55516_0_clock_w );
WRITE8_HANDLER( hc55516_0_clock_clear_w );
WRITE8_HANDLER( hc55516_0_clock_set_w );
WRITE8_HANDLER( hc55516_0_digit_clock_clear_w );
-READ8_HANDLER ( hc55516_0_clock_edge_r );
+READ8_HANDLER ( hc55516_0_clock_state_r );
WRITE8_HANDLER( hc55516_1_digit_w );
WRITE8_HANDLER( hc55516_1_clock_w );
WRITE8_HANDLER( hc55516_1_clock_clear_w );
WRITE8_HANDLER( hc55516_1_clock_set_w );
WRITE8_HANDLER( hc55516_1_digit_clock_clear_w );
-READ8_HANDLER ( hc55516_1_clock_edge_r );
+READ8_HANDLER ( hc55516_1_clock_state_r );
#endif
diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c
index 4c72c0266a3..56896df8523 100644
--- a/src/mame/audio/exidy.c
+++ b/src/mame/audio/exidy.c
@@ -105,7 +105,7 @@ static struct sh8253_timer_channel sh8253_timer[3];
static UINT8 has_sh8253;
/* 5220/CVSD variables */
-static UINT8 has_hc55516;
+static UINT8 has_mc3417;
static UINT8 has_tms5220;
/* sound streaming variables */
@@ -357,11 +357,11 @@ static void *common_sh_start(int _has_sh8253, int _has_tms5220)
has_tms5220 = _has_tms5220;
/* determine which sound hardware is installed */
- has_hc55516 = FALSE;
+ has_mc3417 = FALSE;
for (i = 0; i < MAX_SOUND; i++)
{
- if (Machine->drv->sound[i].type == SOUND_HC55516)
- has_hc55516 = TRUE;
+ if (Machine->drv->sound[i].type == SOUND_MC3417)
+ has_mc3417 = TRUE;
}
/* allocate the stream */
@@ -466,7 +466,7 @@ static WRITE8_HANDLER( exidy_shriot_w )
switch (offset & 0x03)
{
case 0: /* port A */
- if (has_hc55516)
+ if (has_mc3417)
cpunum_set_input_line(2, INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
riot_porta_data = (riot_porta_data & ~riot_porta_ddr) | (data & riot_porta_ddr);
break;
@@ -854,7 +854,7 @@ static READ8_HANDLER( mtrap_voiceio_r )
}
if (!(offset & 0x40))
- return hc55516_clock_edge_r(0) << 7;
+ return hc55516_clock_state_r(0) << 7;
return 0;
}
@@ -879,7 +879,7 @@ MACHINE_DRIVER_START( mtrap_cvsd_audio )
MDRV_CPU_IO_MAP(cvsd_iomap,0)
/* audio hardware */
- MDRV_SOUND_ADD(HC55516, CVSD_CLOCK)
+ MDRV_SOUND_ADD(MC3417, CVSD_CLOCK)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
MACHINE_DRIVER_END