summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/gotya.c
blob: 46fbfdff0dc3d81545854db522ce2658151c66bc (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
#include "driver.h"
#include "sound/samples.h"

struct gotya_sample
{
	int sound_command;
	int channel;
	int looping;
};


static struct gotya_sample gotya_samples[] =
{
	{ 0x01, 0, 0 },
	{ 0x02, 1, 0 },
	{ 0x03, 2, 0 },
	{ 0x05, 2, 0 },
	{ 0x06, 3, 0 },
	{ 0x07, 3, 0 },
	{ 0x08, 0, 1 },
	{ 0x0a, 0, 0 },
	{ 0x0b, 0, 0 },

/* all the speech can go to one channel? */

	{ 0x10, 3, 0 },
	{ 0x11, 3, 0 },
	{ 0x12, 0, 0 },		/* this should stop the main tune */
	{ 0x13, 3, 0 },
	{ 0x14, 3, 0 },
	{ 0x15, 3, 0 },
	{ 0x16, 3, 0 },
	{ 0x17, 3, 0 },
	{ 0x18, 3, 0 },
	{ 0x19, 3, 0 },
	{ 0x1a, 3, 0 },
	{   -1, 0, 0 }		/* end of array */
};

WRITE8_HANDLER( gotya_soundlatch_w )
{
	static int theme_playing;
	int sample_number;


	if (data == 0)
	{
		sample_stop(0);
		theme_playing = 0;
		return;
	}

	/* search for sample to play */

	for (sample_number = 0;
		 gotya_samples[sample_number].sound_command != -1;
		 sample_number++)
	{
		if (gotya_samples[sample_number].sound_command == data)
		{
			if (gotya_samples[sample_number].looping &&
				theme_playing)
			{
				/* don't restart main theme */
				return;
			}

			sample_start(gotya_samples[sample_number].channel,
						 sample_number,
						 gotya_samples[sample_number].looping);

			if (gotya_samples[sample_number].channel == 0)
			{
				theme_playing = gotya_samples[sample_number].looping;
			}
			return;
		}
	}
}