1 // license:BSD-3-Clause
2 // copyright-holders:Zsolt Vasvari
3 /*
4  *  Invinco sound routines
5  */
6 
7 #include "emu.h"
8 #include "includes/vicdual.h"
9 
10 /* output port 0x02 definitions - sound effect drive outputs */
11 #define OUT_PORT_2_SAUCER       0x04
12 #define OUT_PORT_2_MOVE1        0x08
13 #define OUT_PORT_2_MOVE2        0x10
14 #define OUT_PORT_2_FIRE         0x20
15 #define OUT_PORT_2_INVHIT       0x40
16 #define OUT_PORT_2_SHIPHIT      0x80
17 
18 
19 #define PLAY(samp,id,loop)      samp->start( id, id, loop )
20 #define STOP(samp,id)           samp->stop( id )
21 
22 
23 /* sample file names */
24 static const char *const invinco_sample_names[] =
25 {
26 	"*invinco",
27 	"saucer",
28 	"move1",
29 	"move2",
30 	"fire",
31 	"invhit",
32 	"shiphit",
33 	"move3",    /* currently not used */
34 	"move4",    /* currently not used */
35 	nullptr
36 };
37 
38 
39 /* sample IDs - must match sample file name table above */
40 enum
41 {
42 	SND_SAUCER = 0,
43 	SND_MOVE1,
44 	SND_MOVE2,
45 	SND_FIRE,
46 	SND_INVHIT,
47 	SND_SHIPHIT,
48 	SND_MOVE3,
49 	SND_MOVE4
50 };
51 
52 
invinco_audio_w(uint8_t data)53 void vicdual_state::invinco_audio_w(uint8_t data)
54 {
55 	int bitsChanged;
56 	//int bitsGoneHigh;
57 	int bitsGoneLow;
58 
59 	bitsChanged  = m_port2State ^ data;
60 	//bitsGoneHigh = bitsChanged & data;
61 	bitsGoneLow  = bitsChanged & ~data;
62 
63 	m_port2State = data;
64 
65 	if ( bitsGoneLow & OUT_PORT_2_SAUCER )
66 	{
67 		PLAY( m_samples, SND_SAUCER, 0 );
68 	}
69 
70 	if ( bitsGoneLow & OUT_PORT_2_MOVE1 )
71 	{
72 		PLAY( m_samples, SND_MOVE1, 0 );
73 	}
74 
75 	if ( bitsGoneLow & OUT_PORT_2_MOVE2 )
76 	{
77 		PLAY( m_samples, SND_MOVE2, 0 );
78 	}
79 
80 	if ( bitsGoneLow & OUT_PORT_2_FIRE )
81 	{
82 		PLAY( m_samples, SND_FIRE, 0 );
83 	}
84 
85 	if ( bitsGoneLow & OUT_PORT_2_INVHIT )
86 	{
87 		PLAY( m_samples, SND_INVHIT, 0 );
88 	}
89 
90 	if ( bitsGoneLow & OUT_PORT_2_SHIPHIT )
91 	{
92 		PLAY( m_samples, SND_SHIPHIT, 0 );
93 	}
94 }
95 
96 
invinco_audio(machine_config & config)97 void vicdual_state::invinco_audio(machine_config &config)
98 {
99 	/* samples */
100 	SAMPLES(config, m_samples);
101 	m_samples->set_channels(8);
102 	m_samples->set_samples_names(invinco_sample_names);
103 	m_samples->add_route(ALL_OUTPUTS, "mono", 0.5);
104 }
105