1 #include "driver.h"
2 
3 static int channel;
4 static signed char *samplebuf;
5 
pbillian_sh_start(const struct MachineSound * msound)6 int pbillian_sh_start(const struct MachineSound *msound)
7 {
8 	int i;
9 	unsigned char *ROM = memory_region(REGION_SOUND1);
10 	channel = mixer_allocate_channel(50);
11 	mixer_set_name(channel,"Samples");
12 	samplebuf = auto_malloc(memory_region_length(REGION_SOUND1));
13 	for(i=0;i<memory_region_length(REGION_SOUND1);i++)samplebuf[i]=ROM[i]-0x80;
14 	return 0;
15 }
16 
17 #define pb_play_s(start,end) mixer_play_sample(channel,samplebuf + (start<<8),	(end-start)<<8,5000,0) // 5khz ?
18 
WRITE_HANDLER(data_41a_w)19 WRITE_HANDLER(data_41a_w)
20 {
21 	/*
22 	 i/o port $41a wrties are sample related
23 	 playback is done probably using mcu (missing dump)
24 	 It's just a guess for now.
25 	 Value from port $41a can be offset in some  table,
26 	 offset in sample rom , some mixed value of sample offset/length
27 	 or freq
28 
29 	 Code works  (somehow) only for prebillian
30 
31 	*/
32 
33 	switch (data)
34 	{
35 		case 0x00:	pb_play_s(0x00,0x06);break;
36 		case 0x1c:	pb_play_s(0x1c,0x2d);break;
37 		case 0xad:  pb_play_s(0x2d,0x2f);break; //code at 0x0a51,0x1e21,0x2b17  'ball in pocket' .. etc
38 		case 0x2f:	pb_play_s(0x2f,0x38);break;
39 		case 0x38:	pb_play_s(0x38,0x42);break;
40 		case 0xc2:	pb_play_s(0x42,0x46);break; //code at 0x1f42,0x2bc3,
41 		case 0x46:	pb_play_s(0x46,0x57);break;
42 		case 0x57:	pb_play_s(0x57,0x59);break;
43 		case 0x59:	pb_play_s(0x59,0x5f);break;
44 		case 0xdf:  pb_play_s(0x5f,0x62);break; //code at 0x1eb2
45 		case 0x62:	pb_play_s(0x62,0x6d);break;
46 		default: logerror("[41a] W %x at %x\n",data,activecpu_get_previouspc());
47 	}
48 }
49