summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/astinvad.c
blob: 4183624ff93f278aaf16fc3e6001548b5a3d2d92 (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
/***********************************
 updated: 1997-04-09 08:46 TT
 updated  20-3-1998 LT Added colour changes on base explosion
 updated  02-6-1998 HJB copied from 8080bw and removed unneeded code
 *
 * Author      : Tormod Tjaberg
 * Created     : 1997-04-09
 * Description : Sound routines for the 'astinvad' games
 *
 * The samples were taken from Michael Strutt's (mstrutt@pixie.co.za)
 * excellent space invader emulator and converted to signed samples so
 * they would work under SEAL. The port info was also gleaned from
 * his emulator. These sounds should also work on all the invader games.
 *
 */

#include "driver.h"
#include "sound/samples.h"
#include "includes/astinvad.h"

static const char *const astinvad_sample_names[] =
{
	"*invaders",
	"0.wav",
	"1.wav",
	"2.wav",
	"3.wav",
	"4.wav",
	"5.wav",
	"6.wav",
	"7.wav",
	"8.wav",
	0
};

/* sample sound IDs - must match sample file name table above */
enum
{
	SND_UFO = 0,
	SND_SHOT,
	SND_BASEHIT,
	SND_INVADERHIT,
	SND_FLEET1,
	SND_FLEET2,
	SND_FLEET3,
	SND_FLEET4,
	SND_UFOHIT
};


const struct Samplesinterface astinvad_samples_interface =
{
	6,   /* channels */
	astinvad_sample_names
};


WRITE8_HANDLER( astinvad_sound1_w )
{
	static int state;

	int bitsGoneHi = data & ~state;

	sound_global_enable(data & 0x20);

	if (!(data & 1))
	{
		sample_stop(0);
	}

	if (bitsGoneHi & 0x01) sample_start(0, SND_UFO, 1);
	if (bitsGoneHi & 0x02) sample_start(1, SND_SHOT, 0);
	if (bitsGoneHi & 0x04) sample_start(2, SND_BASEHIT, 0);
	if (bitsGoneHi & 0x08) sample_start(3, SND_INVADERHIT, 0);

	astinvad_set_screen_red(data & 0x04);

	state = data;
}


WRITE8_HANDLER( astinvad_sound2_w )
{
	static int state;

	int bitsGoneHi = data & ~state;

	if (bitsGoneHi & 0x01) sample_start(5, SND_FLEET1, 0);
	if (bitsGoneHi & 0x02) sample_start(5, SND_FLEET2, 0);
	if (bitsGoneHi & 0x04) sample_start(5, SND_FLEET3, 0);
	if (bitsGoneHi & 0x08) sample_start(5, SND_FLEET4, 0);
	if (bitsGoneHi & 0x10) sample_start(4, SND_UFOHIT, 0);

	flip_screen_set(readinputport(3) & data & 0x20);

	state = data;
}


WRITE8_HANDLER( spaceint_sound1_w )
{
	static int state;

	int bitsGoneHi = data & ~state;

	if (!(data & 0x08))
	{
		sample_stop(0);
	}

	if (bitsGoneHi & 0x01) sample_start(1, SND_SHOT, 0);
	if (bitsGoneHi & 0x02) sample_start(2, SND_BASEHIT, 0);
	if (bitsGoneHi & 0x04) sample_start(4, SND_UFOHIT, 0);
	if (bitsGoneHi & 0x08) sample_start(0, SND_UFO, 1);

	if (bitsGoneHi & 0x10) sample_start(5, SND_FLEET1, 0);
	if (bitsGoneHi & 0x20) sample_start(5, SND_FLEET2, 0);
	if (bitsGoneHi & 0x40) sample_start(5, SND_FLEET3, 0);
	if (bitsGoneHi & 0x80) sample_start(5, SND_FLEET4, 0);

	state = data;
}


WRITE8_HANDLER( spaceint_sound2_w )
{
	static int state;

	int bitsGoneHi = data & ~state;

	sound_global_enable(data & 0x02);

	if (bitsGoneHi & 0x04) sample_start(3, SND_INVADERHIT, 0);

	flip_screen_set(readinputport(3) & data & 0x80);

	state = data;
}