summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/berzerk.c
blob: 7728212bda8d4a2412f32c2737b93fc4dc281f63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * Berzerk/Frenzy Soundhardware Driver
 * Copyright Alex Judd 1997/98
 * V1.1 for Mame 0.31 13March98
 *
 */

#include "driver.h"
#include "berzerk.h"
#include "exidy.h"
#include "sound/s14001a.h"



#define BERZERK_AUDIO_DEBUG		(0)


static struct S14001A_interface berzerk_s14001a_interface =
{
	REGION_SOUND1	/* voice data region */
};


static struct CustomSound_interface custom_interface =
{
	berzerk_sh_start
};


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(custom_interface)
	MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MACHINE_DRIVER_END



#if BERZERK_AUDIO_DEBUG
static void berzerk_audio_debug(UINT8 data)
{
	mame_printf_debug("not busy, triggering S14001A core with %x\n", data);
	mame_printf_debug("S14001a word play command: ");

	switch (data)
	{
		case 0: mame_printf_debug("help\n"); break;
		case 1: mame_printf_debug("kill\n"); break;
		case 2: mame_printf_debug("attack\n"); break;
		case 3: mame_printf_debug("charge\n"); break;
		case 4: mame_printf_debug("got\n"); break;
		case 5: mame_printf_debug("shoot\n"); break;
		case 6: mame_printf_debug("get\n"); break;
		case 7: mame_printf_debug("is\n"); break;
		case 8: mame_printf_debug("alert\n"); break;
		case 9: mame_printf_debug("detected\n"); break;
		case 10: mame_printf_debug("the\n"); break;
		case 11: mame_printf_debug("in\n"); break;
		case 12: mame_printf_debug("it\n"); break;
		case 13: mame_printf_debug("there\n"); break;
		case 14: mame_printf_debug("where\n"); break;
		case 15: mame_printf_debug("humanoid\n"); break;
		case 16: mame_printf_debug("coins\n"); break;
		case 17: mame_printf_debug("pocket\n"); break;
		case 18: mame_printf_debug("intruder\n"); break;
		case 19: mame_printf_debug("no\n"); break;
		case 20: mame_printf_debug("escape\n"); break;
		case 21: mame_printf_debug("destroy\n"); break;
		case 22: mame_printf_debug("must\n"); break;
		case 23: mame_printf_debug("not\n"); break;
		case 24: mame_printf_debug("chicken\n"); break;
		case 25: mame_printf_debug("fight\n"); break;
		case 26: mame_printf_debug("like\n"); break;
		case 27: mame_printf_debug("a\n"); break;
		case 28: mame_printf_debug("robot\n"); break;
		default: mame_printf_debug("ERROR: data %2x; you should NOT see this!\n", data); break;
	}
}
#endif


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);

#if BERZERK_AUDIO_DEBUG
			berzerk_audio_debug(data);
#endif
		}
		break;
	}
}


READ8_HANDLER( berzerk_audio_r )
{
	return ((offset == 4) && !S14001A_bsy_0_r()) ? 0x40 : 0x00;
}