summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/tranqgun.cpp
blob: c63845f5097de1a5cd43e2db66c66920d052e963 (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
147
148
149
150
// license:BSD-3-Clause
// copyright-holders:Zsolt Vasvari, Jim Hernandez
/*
 *  Tranquillizer Gun audio routines
 */

#include "emu.h"
#include "includes/vicdual.h"

/* output port 0x01 definitions - sound effect drive outputs */
#define OUT_PORT_1_ANIMAL    0x01
#define OUT_PORT_1_CRY       0x02
#define OUT_PORT_1_WALK      0x04
#define OUT_PORT_1_EMAR      0x08
#define OUT_PORT_1_ANIMALHIT 0x10
#define OUT_PORT_1_POINT     0x20
#define OUT_PORT_1_JEEP      0x40
#define OUT_PORT_1_GUN       0x80


#define PLAY(samp,id,loop)      samp->start( id, id, loop )
#define STOP(samp,id)           samp->stop( id )


/* sample file names */
static const char *const tranqgun_sample_names[] =
{
	"*tranqgun",
	"cry",
	"walk",
	"emar",
	"animalhit",
	"point",
	"jeep",
	"gun",
	"animal",
	nullptr
};


/* sample IDs - must match sample file name table above */
enum
{
	SND_CRY = 0,
	SND_WALK,
	SND_EMAR,
	SND_ANIMALHIT,
	SND_POINT,
	SND_JEEP,
	SND_GUN,
	SND_ANIMAL,
};


WRITE8_MEMBER( vicdual_state::tranqgun_audio_w )
{
	int bitsChanged;
	int bitsGoneHigh;
	int bitsGoneLow;

	bitsChanged  = m_port1State ^ data;
	bitsGoneHigh = bitsChanged & data;
	bitsGoneLow  = bitsChanged & ~data;

	m_port1State = data;

	if ( bitsGoneHigh & OUT_PORT_1_ANIMAL )
	{
		PLAY( m_samples, SND_ANIMAL, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_ANIMAL )
	{
		STOP( m_samples, SND_ANIMAL );
	}

	if ( bitsGoneHigh & OUT_PORT_1_CRY )
	{
		PLAY( m_samples, SND_CRY, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_CRY )
	{
		STOP( m_samples, SND_CRY );
	}

	if ( bitsGoneHigh & OUT_PORT_1_WALK )
	{
		PLAY( m_samples, SND_WALK, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_WALK )
	{
		STOP( m_samples, SND_WALK );
	}

	if ( bitsGoneLow & OUT_PORT_1_ANIMAL )
	{
		PLAY( m_samples, SND_ANIMAL,0 );
	}

	if ( bitsGoneHigh & OUT_PORT_1_ANIMALHIT )
	{
		PLAY( m_samples, SND_ANIMALHIT, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_ANIMALHIT )
	{
		STOP( m_samples, SND_ANIMALHIT );
	}

	if ( bitsGoneHigh & OUT_PORT_1_POINT )
	{
		PLAY( m_samples, SND_POINT, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_POINT )
	{
		STOP( m_samples, SND_POINT );
	}

	if ( bitsGoneLow & OUT_PORT_1_JEEP )
	{
		PLAY( m_samples, SND_JEEP, 1 );

	}
	if ( bitsGoneHigh & OUT_PORT_1_JEEP )
	{
		STOP( m_samples, SND_JEEP );
	}

	if ( bitsGoneLow & OUT_PORT_1_EMAR )
	{
		PLAY( m_samples, SND_EMAR, 0 );
	}

	if ( bitsGoneHigh & OUT_PORT_1_GUN )
	{
		PLAY( m_samples, SND_GUN, 0 );
	}
	if ( bitsGoneLow & OUT_PORT_1_GUN )
	{
		STOP( m_samples, SND_GUN );
	}
}


void vicdual_state::tranqgun_audio(machine_config &config)
{
	/* samples */
	SAMPLES(config, m_samples);
	m_samples->set_channels(8);
	m_samples->set_samples_names(tranqgun_sample_names);
	m_samples->add_route(ALL_OUTPUTS, "mono", 0.5);
}