summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Zsolt Vasvari <zsoltvas@mamedev.org>2008-01-24 01:53:56 +0000
committer Zsolt Vasvari <zsoltvas@mamedev.org>2008-01-24 01:53:56 +0000
commit6d5ae15ab0aa4b889ed61427c142c314fcacc6ab (patch)
tree79f90cbb761e0952986ace5db6620107622a5a51 /src
parentfeb32d305fc302150ee5b71527231341c08784ef (diff)
Removed the freely distributable Exidy games' dependency on Berzerk. Mainly for tinymame.mak
Diffstat (limited to 'src')
-rw-r--r--src/mame/audio/exidy.c250
-rw-r--r--src/mame/drivers/berzerk.c91
-rw-r--r--src/mame/includes/berzerk.h8
-rw-r--r--src/mame/includes/exidy.h9
4 files changed, 171 insertions, 187 deletions
diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c
index 56896df8523..92a6fdb537e 100644
--- a/src/mame/audio/exidy.c
+++ b/src/mame/audio/exidy.c
@@ -11,9 +11,7 @@
#include "machine/6821pia.h"
#include "sound/hc55516.h"
#include "sound/5220intf.h"
-#include "sound/s14001a.h"
#include "sound/custom.h"
-#include "berzerk.h"
@@ -24,11 +22,11 @@
*************************************/
#define CRYSTAL_OSC (XTAL_3_579545MHz)
-#define SH8253_CLOCK (CRYSTAL_OSC/2)
-#define SH6840_CLOCK (CRYSTAL_OSC/4)
-#define SH6532_CLOCK (CRYSTAL_OSC/4)
+#define SH8253_CLOCK (CRYSTAL_OSC / 2)
+#define SH6840_CLOCK (CRYSTAL_OSC / 4)
+#define SH6532_CLOCK (CRYSTAL_OSC / 4)
#define CVSD_CLOCK (1.0 / (0.693 * (RES_K(2.4) + 2.0 * RES_K(20)) * CAP_P(2200)))
-#define CVSD_Z80_CLOCK (CRYSTAL_OSC/2)
+#define CVSD_Z80_CLOCK (CRYSTAL_OSC / 2)
#define BASE_VOLUME (32767 / 6)
enum
@@ -102,11 +100,11 @@ struct sh8253_timer_channel
UINT32 fraction;
};
static struct sh8253_timer_channel sh8253_timer[3];
-static UINT8 has_sh8253;
+static int has_sh8253;
/* 5220/CVSD variables */
-static UINT8 has_mc3417;
-static UINT8 has_tms5220;
+static int has_mc3417;
+static int has_tms5220;
/* sound streaming variables */
static sound_stream *exidy_stream;
@@ -116,6 +114,16 @@ static double freq_to_step;
/*************************************
*
+ * Prototypes
+ *
+ *************************************/
+
+static TIMER_CALLBACK( riot_interrupt );
+
+
+
+/*************************************
+ *
* Interrupt generation helper
*
*************************************/
@@ -342,39 +350,23 @@ static void exidy_stream_update(void *param, stream_sample_t **inputs, stream_sa
/*************************************
*
- * Sound startup routines
+ * Audio startup routines
*
*************************************/
-static TIMER_CALLBACK( riot_interrupt );
-
-static void *common_sh_start(int _has_sh8253, int _has_tms5220)
+void *exidy_sh6840_sh_start(int clock, const struct CustomSound_interface *config)
{
int sample_rate = SH8253_CLOCK;
- int i;
- has_sh8253 = _has_sh8253;
- has_tms5220 = _has_tms5220;
-
- /* determine which sound hardware is installed */
- has_mc3417 = FALSE;
- for (i = 0; i < MAX_SOUND; i++)
- {
- if (Machine->drv->sound[i].type == SOUND_MC3417)
- has_mc3417 = TRUE;
- }
+ sh6840_clocks_per_sample = (int)((double)SH6840_CLOCK / (double)sample_rate * (double)(1 << 24));
/* allocate the stream */
exidy_stream = stream_create(0, 1, sample_rate, NULL, exidy_stream_update);
- /* 6532 */
- riot_timer = timer_alloc(riot_interrupt, NULL);
-
- /* 6840 */
- sh6840_clocks_per_sample = (int)((double)SH6840_CLOCK / (double)sample_rate * (double)(1 << 24));
-
- /* 8253 */
- freq_to_step = (double)(1 << 24) / (double)sample_rate;
+ /* indicate no additional hardware */
+ has_sh8253 = FALSE;
+ has_tms5220 = FALSE;
+ has_mc3417 = FALSE;
return auto_malloc(1);
}
@@ -383,30 +375,12 @@ static void *common_sh_start(int _has_sh8253, int _has_tms5220)
/*************************************
*
- * Sound reset routines
+ * Audio reset routines
*
*************************************/
-static void common_sh_reset(void)
+void exidy_sh6840_sh_reset(void *token)
{
- /* PIA */
- pia_reset();
-
- /* LFSR */
- sh6840_LFSR_oldxor = 0;
- sh6840_LFSR_0 = 0xffffffff;
- sh6840_LFSR_1 = 0xffffffff;
- sh6840_LFSR_2 = 0xffffffff;
- sh6840_LFSR_3 = 0xffffffff;
-
- /* 6532 */
- riot_irq_flag = 0;
- riot_timer_irq_enable = 0;
- riot_porta_data = 0xff;
- riot_portb_data = 0xff;
- riot_clock_divisor = 1;
- riot_state = RIOT_IDLE;
-
/* 6840 */
memset(sh6840_timer, 0, sizeof(sh6840_timer));
sh6840_MSB = 0;
@@ -415,8 +389,12 @@ static void common_sh_reset(void)
sh6840_volume[2] = 0;
exidy_sfxctrl = 0;
- /* 8253 */
- memset(sh8253_timer, 0, sizeof(sh8253_timer));
+ /* LFSR */
+ sh6840_LFSR_oldxor = 0;
+ sh6840_LFSR_0 = 0xffffffff;
+ sh6840_LFSR_1 = 0xffffffff;
+ sh6840_LFSR_2 = 0xffffffff;
+ sh6840_LFSR_3 = 0xffffffff;
}
@@ -661,7 +639,7 @@ static READ8_HANDLER( exidy_sh6840_r )
}
-static WRITE8_HANDLER( exidy_sh6840_w )
+WRITE8_HANDLER( exidy_sh6840_w )
{
/* force an update of the stream */
stream_update(exidy_stream);
@@ -721,7 +699,7 @@ static WRITE8_HANDLER( exidy_sh6840_w )
*
*************************************/
-static WRITE8_HANDLER( exidy_sfxctrl_w )
+WRITE8_HANDLER( exidy_sfxctrl_w )
{
stream_update(exidy_stream);
@@ -776,18 +754,59 @@ static const pia6821_interface venture_pia_1_intf =
};
+static void *venture_common_sh_start(int clock, const struct CustomSound_interface *config, int _has_tms5220)
+{
+ int i;
+
+ void *ret = exidy_sh6840_sh_start(clock, config);
+
+ has_sh8253 = TRUE;
+ has_tms5220 = _has_tms5220;
+
+ /* determine which sound hardware is installed */
+ has_mc3417 = FALSE;
+ for (i = 0; i < MAX_SOUND; i++)
+ {
+ if (Machine->drv->sound[i].type == SOUND_MC3417)
+ has_mc3417 = TRUE;
+ }
+
+ /* 6532 */
+ riot_timer = timer_alloc(riot_interrupt, NULL);
+
+ /* 8253 */
+ freq_to_step = (double)(1 << 24) / (double)SH8253_CLOCK;
+
+ return ret;
+}
+
+
static void *venture_sh_start(int clock, const struct CustomSound_interface *config)
{
pia_config(0, &venture_pia_0_intf);
pia_config(1, &venture_pia_1_intf);
- return common_sh_start(TRUE, FALSE);
+ return venture_common_sh_start(clock, config, FALSE);
}
static void venture_sh_reset(void *token)
{
- common_sh_reset();
+ exidy_sh6840_sh_reset(token);
+
+ /* PIA */
+ pia_reset();
+
+ /* 6532 */
+ riot_irq_flag = 0;
+ riot_timer_irq_enable = 0;
+ riot_porta_data = 0xff;
+ riot_portb_data = 0xff;
+ riot_clock_divisor = 1;
+ riot_state = RIOT_IDLE;
+
+ /* 8253 */
+ memset(sh8253_timer, 0, sizeof(sh8253_timer));
}
@@ -967,13 +986,13 @@ static void *victory_sh_start(int clock, const struct CustomSound_interface *con
state_save_register_global(victory_sound_response_ack_clk);
- return common_sh_start(TRUE, TRUE);
+ return venture_common_sh_start(clock, config, TRUE);
}
static void victory_sh_reset(void *token)
{
- common_sh_reset();
+ venture_sh_reset(token);
/* the flip-flop @ F4 is reset */
victory_sound_response_ack_clk = 0;
@@ -1021,114 +1040,3 @@ MACHINE_DRIVER_START( victory_audio )
MDRV_SOUND_ADD(TMS5220, 640000)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_DRIVER_END
-
-
-
-/*************************************
- *
- * Berzerk
- *
- * Copyright Alex Judd 1997/98
- * V1.1 for Mame 0.31 13March98
- *
- *************************************/
-
-#define BERZERK_S14001A_CLOCK (BERZERK_MASTER_CLOCK / 2)
-
-
-static void *berzerk_sh_start(int clock, const struct CustomSound_interface *config)
-{
- return common_sh_start(FALSE, FALSE);
-}
-
-
-static void berzerk_sh_reset(void *token)
-{
- common_sh_reset();
-}
-
-
-static const struct S14001A_interface berzerk_s14001a_interface =
-{
- REGION_SOUND1 /* voice data region */
-};
-
-
-static const struct CustomSound_interface berzerk_custom_interface =
-{
- berzerk_sh_start,
- 0,
- berzerk_sh_reset,
-};
-
-
-MACHINE_DRIVER_START( berzerk_audio )
-
- MDRV_SPEAKER_STANDARD_MONO("mono")
-
- MDRV_SOUND_ADD(S14001A, BERZERK_S14001A_CLOCK) /* CPU clock divided by 16 divided by a programmable TTL setup */
- MDRV_SOUND_CONFIG(berzerk_s14001a_interface)
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
-
- MDRV_SOUND_ADD(CUSTOM, 0)
- MDRV_SOUND_CONFIG(berzerk_custom_interface)
- MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
-MACHINE_DRIVER_END
-
-
-WRITE8_HANDLER( berzerk_audio_w )
-{
- switch (offset)
- {
- /* offsets 0-3, 5 and 7 write to the 6840 */
- case 0:
- case 1:
- case 2:
- case 3:
- case 5:
- case 7:
- exidy_sh6840_w(offset, data);
- break;
-
- /* offset 6 writes to the sfxcontrol latch */
- case 6:
- exidy_sfxctrl_w(data >> 6, data);
- break;
-
- /* offset 4 writes to the S14001A */
- case 4:
- if ((data & 0xc0) == 0x40) /* VSU-1000 control write */
- {
- /* volume and frequency control goes here */
- /* mame_printf_debug("TODO: VSU-1000 Control write (ignored for now)\n");*/
- S14001A_set_volume(((data&0x38)>>3)+1);
- S14001A_set_rate((16-(data&0x07))*16); /* second LS161 has load triggered by its own TC(when it equals 16) long before the first ls161 will TC and fire again, so effectively it only divides by 15 and not 16. If the clock, as opposed to the E enable, had been tied to the first LS161's TC instead, it would divide by 16 as expected */
- }
- else if ((data & 0xc0) != 0x00)
- {
- /* vsu-1000 ignores these writes entirely */
- mame_printf_debug("bogus write ignored\n");
- }
- else
- {
- /* select word input */
- if (S14001A_bsy_0_r()) /* skip if busy... */
- {
- mame_printf_debug("S14001A busy, ignoring write\n");
- break;
- }
-
- /* write to the register */
- S14001A_reg_0_w(data & 0x3f);
- S14001A_rst_0_w(1);
- S14001A_rst_0_w(0);
- }
- break;
- }
-}
-
-
-READ8_HANDLER( berzerk_audio_r )
-{
- return ((offset == 4) && !S14001A_bsy_0_r()) ? 0x40 : 0x00;
-}
diff --git a/src/mame/drivers/berzerk.c b/src/mame/drivers/berzerk.c
index b5f1e488ce5..f31a3ff4e1e 100644
--- a/src/mame/drivers/berzerk.c
+++ b/src/mame/drivers/berzerk.c
@@ -9,16 +9,18 @@
***************************************************************************/
#include "driver.h"
-#include "berzerk.h"
#include "exidy.h"
#include "machine/74181.h"
+#include "sound/s14001a.h"
#include "video/resnet.h"
#define MONITOR_TYPE_PORT_TAG ("MONITOR_TYPE")
-#define MAIN_CPU_CLOCK (BERZERK_MASTER_CLOCK / 4)
-#define PIXEL_CLOCK (BERZERK_MASTER_CLOCK / 2)
+#define MASTER_CLOCK (XTAL_10MHz)
+#define MAIN_CPU_CLOCK (MASTER_CLOCK / 4)
+#define PIXEL_CLOCK (MASTER_CLOCK / 2)
+#define S14001A_CLOCK (MASTER_CLOCK / 2)
#define HTOTAL (0x140)
#define HBEND (0x000)
#define HBSTART (0x100)
@@ -459,6 +461,79 @@ static VIDEO_UPDATE( berzerk )
/*************************************
*
+ * Audio system
+ *
+ *************************************/
+
+static const struct S14001A_interface berzerk_s14001a_interface =
+{
+ REGION_SOUND1 /* voice data region */
+};
+
+
+static const struct CustomSound_interface berzerk_custom_interface =
+{
+ exidy_sh6840_sh_start,
+ 0,
+ exidy_sh6840_sh_reset
+};
+
+
+static WRITE8_HANDLER( berzerk_audio_w )
+{
+ switch (offset)
+ {
+ /* offset 6 writes to the sfxcontrol latch */
+ case 6:
+ exidy_sfxctrl_w(data >> 6, data);
+ break;
+
+ /* offset 4 writes to the S14001A */
+ case 4:
+ if ((data & 0xc0) == 0x40) /* VSU-1000 control write */
+ {
+ /* volume and frequency control goes here */
+ /* mame_printf_debug("TODO: VSU-1000 Control write (ignored for now)\n");*/
+ S14001A_set_volume(((data & 0x38) >> 3) + 1);
+ S14001A_set_rate((16 - (data & 0x07)) * 16); /* second LS161 has load triggered by its own TC(when it equals 16) long before the first ls161 will TC and fire again, so effectively it only divides by 15 and not 16. If the clock, as opposed to the E enable, had been tied to the first LS161's TC instead, it would divide by 16 as expected */
+ }
+ else if ((data & 0xc0) != 0x00)
+ /* vsu-1000 ignores these writes entirely */
+ mame_printf_debug("bogus write ignored\n");
+ else
+ {
+ /* select word input */
+ if (S14001A_bsy_0_r()) /* skip if busy... */
+ {
+ mame_printf_debug("S14001A busy, ignoring write\n");
+ break;
+ }
+
+ /* write to the register */
+ S14001A_reg_0_w(data & 0x3f);
+ S14001A_rst_0_w(1);
+ S14001A_rst_0_w(0);
+ }
+ break;
+
+ default:
+ /* everything else writes to the 6840 */
+ exidy_sh6840_w(offset, data);
+ break;
+
+ }
+}
+
+
+static READ8_HANDLER( berzerk_audio_r )
+{
+ return ((offset == 4) && !S14001A_bsy_0_r()) ? 0x40 : 0x00;
+}
+
+
+
+/*************************************
+ *
* Memory handlers
*
*************************************/
@@ -789,8 +864,15 @@ static MACHINE_DRIVER_START( berzerk )
MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART)
/* audio hardware */
- MDRV_IMPORT_FROM(berzerk_audio)
+ MDRV_SPEAKER_STANDARD_MONO("mono")
+
+ MDRV_SOUND_ADD(S14001A, S14001A_CLOCK) /* CPU clock divided by 16 divided by a programmable TTL setup */
+ MDRV_SOUND_CONFIG(berzerk_s14001a_interface)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
+ MDRV_SOUND_ADD(CUSTOM, 0)
+ MDRV_SOUND_CONFIG(berzerk_custom_interface)
+ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_DRIVER_END
@@ -800,7 +882,6 @@ static MACHINE_DRIVER_START( frenzy )
MDRV_IMPORT_FROM(berzerk)
MDRV_CPU_MODIFY("main")
MDRV_CPU_PROGRAM_MAP(frenzy_map,0)
-
MACHINE_DRIVER_END
diff --git a/src/mame/includes/berzerk.h b/src/mame/includes/berzerk.h
deleted file mode 100644
index fb6c98f48f2..00000000000
--- a/src/mame/includes/berzerk.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/***************************************************************************
-
- Berzerk hardware
-
-***************************************************************************/
-
-
-#define BERZERK_MASTER_CLOCK (XTAL_10MHz)
diff --git a/src/mame/includes/exidy.h b/src/mame/includes/exidy.h
index 31a6cb40c76..8d8efb52add 100644
--- a/src/mame/includes/exidy.h
+++ b/src/mame/includes/exidy.h
@@ -24,6 +24,12 @@
/*----------- defined in audio/exidy.c -----------*/
+void *exidy_sh6840_sh_start(int clock, const struct CustomSound_interface *config);
+void exidy_sh6840_sh_reset(void *token);
+
+WRITE8_HANDLER( exidy_sh6840_w );
+WRITE8_HANDLER( exidy_sfxctrl_w );
+
MACHINE_DRIVER_EXTERN( venture_audio );
MACHINE_DRIVER_EXTERN( mtrap_cvsd_audio );
@@ -33,9 +39,6 @@ READ8_HANDLER( victory_sound_response_r );
READ8_HANDLER( victory_sound_status_r );
WRITE8_HANDLER( victory_sound_command_w );
-MACHINE_DRIVER_EXTERN( berzerk_audio );
-WRITE8_HANDLER( berzerk_audio_w );
-READ8_HANDLER( berzerk_audio_r );
/*----------- defined in video/exidy.c -----------*/