1 // license:BSD-3-Clause
2 // copyright-holders:Zsolt Vasvari
3 #include "emu.h"
4 #include "sound/samples.h"
5 #include "includes/gotya.h"
6 
7 
8 struct gotya_sample
9 {
10 	int sound_command;
11 	int channel;
12 	int looping;
13 };
14 
15 
16 static const struct gotya_sample gotya_samples[] =
17 {
18 	{ 0x01, 0, 0 },
19 	{ 0x02, 1, 0 },
20 	{ 0x03, 2, 0 },
21 	{ 0x05, 2, 0 },
22 	{ 0x06, 3, 0 },
23 	{ 0x07, 3, 0 },
24 	{ 0x08, 0, 1 },
25 	{ 0x0a, 0, 0 },
26 	{ 0x0b, 0, 0 },
27 
28 /* all the speech can go to one channel? */
29 
30 	{ 0x10, 3, 0 },
31 	{ 0x11, 3, 0 },
32 	{ 0x12, 0, 0 },     /* this should stop the main tune */
33 	{ 0x13, 3, 0 },
34 	{ 0x14, 3, 0 },
35 	{ 0x15, 3, 0 },
36 	{ 0x16, 3, 0 },
37 	{ 0x17, 3, 0 },
38 	{ 0x18, 3, 0 },
39 	{ 0x19, 3, 0 },
40 	{ 0x1a, 3, 0 },
41 	{   -1, 0, 0 }      /* end of array */
42 };
43 
gotya_soundlatch_w(uint8_t data)44 void gotya_state::gotya_soundlatch_w(uint8_t data)
45 {
46 	int sample_number;
47 
48 	if (data == 0)
49 	{
50 		m_samples->stop(0);
51 		m_theme_playing = 0;
52 		return;
53 	}
54 
55 	/* search for sample to play */
56 	for (sample_number = 0; gotya_samples[sample_number].sound_command != -1; sample_number++)
57 	{
58 		if (gotya_samples[sample_number].sound_command == data)
59 		{
60 			if (gotya_samples[sample_number].looping && m_theme_playing)
61 			{
62 				/* don't restart main theme */
63 				return;
64 			}
65 
66 			m_samples->start(gotya_samples[sample_number].channel, sample_number, gotya_samples[sample_number].looping);
67 
68 			if (gotya_samples[sample_number].channel == 0)
69 			{
70 				m_theme_playing = gotya_samples[sample_number].looping;
71 			}
72 			return;
73 		}
74 	}
75 }
76