summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/audio/suna8.c
blob: cd55e34eb3f7d1115bda8b0c900a3ae224e0ee55 (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
/*

    SunA 8 Bit Games samples

    Format: PCM unsigned 8 bit mono 4Khz

*/

#include "driver.h"
#include "deprecat.h"
#include "sound/samples.h"

static INT16 *samplebuf;
static int sample;

WRITE8_HANDLER( suna8_play_samples_w )
{
	if( data )
	{
		if( ~data & 0x10 )
		{
			sample_start_raw(0, &samplebuf[0x800*sample], 0x0800, 4000, 0);
		}
		else if( ~data & 0x08 )
		{
			sample &= 3;
			sample_start_raw(0, &samplebuf[0x800*(sample+7)], 0x0800, 4000, 0);
		}
	}
}

WRITE8_HANDLER( suna8_samples_number_w )
{
	sample = data & 0xf;
}

void suna8_sh_start(void)
{
	int i, len = memory_region_length(Machine, "samples");
	UINT8 *ROM = memory_region(Machine, "samples");

	samplebuf = auto_malloc(len * sizeof(samplebuf[0]));

	for(i=0;i<len;i++)
		samplebuf[i] = (INT8)(ROM[i] ^ 0x80) * 256;
}