示例#1
0
void CS5B::SetSampleSpeed(uint32 SampleRate, double ClockRate, uint32 FrameRate)
{
	if (psg != NULL) {
		PSG_delete(psg);
	}

	PSG_init((uint32)ClockRate, SampleRate);
	psg = PSG_new();
	PSG_setVolumeMode(psg, 1);
	PSG_reset(psg);

//	psg = PSG_new();

//	PSG_setVolumeMode(psg, 1);
//	PSG_reset(psg);
}
示例#2
0
int device_start_ayxx(UINT8 ChipID, int clock, UINT8 chip_type, UINT8 Flags)
{
	ayxx_state *info;
	int rate;
	
	if (ChipID >= MAX_CHIPS)
		return 0;
	
	info = &AYxxData[ChipID];
	if (Flags & YM2149_PIN26_LOW)
		rate = clock / 16;
	else
		rate = clock / 8;
	if (((CHIP_SAMPLING_MODE & 0x01) && rate < CHIP_SAMPLE_RATE) ||
		CHIP_SAMPLING_MODE == 0x02)
		rate = CHIP_SAMPLE_RATE;
	
	switch(EMU_CORE)
	{
#ifdef ENABLE_ALL_CORES
	case EC_MAME:
		rate = ay8910_start(&info->chip, clock, chip_type, Flags);
		break;
#endif
	case EC_EMU2149:
		if (Flags & YM2149_PIN26_LOW)
			clock /= 2;
		info->chip = PSG_new(clock, rate);
		if (info->chip == NULL)
			return 0;
		PSG_setVolumeMode((PSG*)info->chip, (chip_type & 0x10) ? 1 : 2);
		PSG_setFlags((PSG*)info->chip, Flags & ~YM2149_PIN26_LOW);
		break;
	}
 
	return rate;
}
示例#3
0
//static DEVICE_START( ym2610 )
int device_start_ym2610(void **_info, int AY_EMU_CORE, int clock, UINT8 AYDisable, int* AYrate, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE)
{
	// clock bit 31:	0 - YM2610
	//					1 - YM2610B
	
	//static const ym2610_interface generic_2610 = { 0 };
#ifdef ENABLE_ALL_CORES
	static const ay8910_interface generic_ay8910 =
	{
		AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
		AY8910_DEFAULT_LOADS
		//DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
	};
#endif
	//const ym2610_interface *intf = device->static_config ? (const ym2610_interface *)device->static_config : &generic_2610;
	//const ym2610_interface *intf = &generic_2610;
	int rate;
	int ay_clock;
	//void *pcmbufa,*pcmbufb;
	//int  pcmsizea,pcmsizeb;
	//ym2610_state *info = get_safe_token(device);
	ym2610_state *info;
	//astring *name = astring_alloc();
	//sound_type type = sound_get_type(device);
	unsigned char ChipType;

#ifdef ENABLE_ALL_CORES
	if (AY_EMU_CORE >= 0x02)
		AY_EMU_CORE = EC_EMU2149;
#else
	AY_EMU_CORE = EC_EMU2149;
#endif

	info = (ym2610_state *) calloc(1, sizeof(ym2610_state));
	*_info = (void *) info;

	info->AY_EMU_CORE = AY_EMU_CORE;
	ChipType = (clock & 0x80000000) ? 0x01 : 0x00;
	clock &= 0x7FFFFFFF;
	rate = clock/72;
	if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) ||
		CHIP_SAMPLING_MODE == 0x02)
		rate = CHIP_SAMPLE_RATE;
	//info->intf = intf;
	//info->device = device;
	//info->psg = ay8910_start_ym(NULL, sound_get_type(device), device, device->clock, &generic_ay8910);
	if (! AYDisable)
	{
		ay_clock = clock / 4;
		*AYrate = ay_clock / 8;
		switch(AY_EMU_CORE)
		{
#ifdef ENABLE_ALL_CORES
		case EC_MAME:
			info->psg = ay8910_start_ym(NULL, CHTYPE_YM2610 + ChipType, ay_clock, &generic_ay8910);
			break;
#endif
		case EC_EMU2149:
			info->psg = PSG_new(ay_clock, *AYrate);
			if (info->psg == NULL)
				return 0;
			PSG_setVolumeMode((PSG*)info->psg, 1);	// YM2149 volume mode
			break;
		}
	}
	else
	{
		info->psg = NULL;
		*AYrate = 0;
	}
	//assert_always(info->psg != NULL, "Error creating YM2610/AY8910 chip");

	/* Timer Handler set */
	//info->timer[0] = timer_alloc(device->machine, timer_callback_0, info);
	//info->timer[1] = timer_alloc(device->machine, timer_callback_1, info);

	/* stream system initialize */
	//info->stream = stream_create(device,0,2,rate,info,(type == SOUND_YM2610) ? ym2610_stream_update : ym2610b_stream_update);
	/* setup adpcm buffers */
	//pcmbufa  = device->region;
	//pcmsizea = device->regionbytes;
	//astring_printf(name, "%s.deltat", device->tag);
	//pcmbufb  = (void *)(memory_region(device->machine, astring_c(name)));
	//pcmsizeb = memory_region_length(device->machine, astring_c(name));
	//astring_free(name);
	/*if (pcmbufb == NULL || pcmsizeb == 0)
	{
		pcmbufb = pcmbufa;
		pcmsizeb = pcmsizea;
	}*/

	/**** initialize YM2610 ****/
	//info->chip = ym2610_init(info,device,device->clock,rate,
	//	           pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
	//	           timer_handler,IRQHandler,&psgintf);
	info->chip = ym2610_init(info, clock & 0x7FFFFFFF, rate, NULL, NULL, &psgintf);
	//assert_always(info->chip != NULL, "Error creating YM2610 chip");

	//state_save_register_postload(device->machine, ym2610_intf_postload, info);
	
	return rate;
}
示例#4
0
//static DEVICE_START( ym2203 )
int device_start_ym2203(UINT8 ChipID, int clock, UINT8 AYDisable, UINT8 AYFlags, int* AYrate)
{
	static const ym2203_interface generic_2203 =
	{
		{
			AY8910_LEGACY_OUTPUT,
			AY8910_DEFAULT_LOADS
			//DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
		},
		NULL
	};
	//const ym2203_interface *intf = device->static_config ? (const ym2203_interface *)device->static_config : &generic_2203;
	ym2203_interface* intf;
	//ym2203_state *info = get_safe_token(device);
	ym2203_state *info;
	int rate;
	int ay_clock;

	if (ChipID >= MAX_CHIPS)
		return 0;
	
	info = &YM2203Data[ChipID];
	rate = clock/72; /* ??? */
	if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) ||
		CHIP_SAMPLING_MODE == 0x02)
		rate = CHIP_SAMPLE_RATE;

	info->intf = generic_2203;
	intf = &info->intf;
	if (AYFlags)
		intf->ay8910_intf.flags = AYFlags;
	//info->device = device;
	//info->psg = ay8910_start_ym(NULL, SOUND_YM2203, device, device->clock, &intf->ay8910_intf);
	if (! AYDisable)
	{
		ay_clock = clock / 2;
		*AYrate = ay_clock / 8;
		if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) ||
			CHIP_SAMPLING_MODE == 0x02)
			*AYrate = CHIP_SAMPLE_RATE;
		
		switch(AY_EMU_CORE)
		{
#ifdef ENABLE_ALL_CORES
		case EC_MAME:
			// fits in the most common cases
			// TODO: remove after being able to change the resampler's sampling rate
			info->psg = ay8910_start_ym(NULL, CHTYPE_YM2203, ay_clock, &intf->ay8910_intf);
			break;
#endif
		case EC_EMU2149:
			info->psg = PSG_new(ay_clock, *AYrate);
			if (info->psg == NULL)
				return 0;
			PSG_setVolumeMode((PSG*)info->psg, 1);	// YM2149 volume mode
			break;
		}
	}
	else
	{
		info->psg = NULL;
		*AYrate = 0;
	}
	//assert_always(info->psg != NULL, "Error creating YM2203/AY8910 chip");

	/* Timer Handler set */
	//info->timer[0] = timer_alloc(device->machine, timer_callback_2203_0, info);
	//info->timer[1] = timer_alloc(device->machine, timer_callback_2203_1, info);

	/* stream system initialize */
	//info->stream = stream_create(device,0,1,rate,info,ym2203_stream_update);

	/* Initialize FM emurator */
	//info->chip = ym2203_init(info,clock,rate,timer_handler,IRQHandler,&psgintf);
	info->chip = ym2203_init(info,clock,rate,NULL,NULL,&psgintf);
	//assert_always(info->chip != NULL, "Error creating YM2203 chip");

	//state_save_register_postload(device->machine, ym2203_intf_postload, info);
	
	return rate;
}
示例#5
0
//static DEVICE_START( ym2608 )
int device_start_ym2608(UINT8 ChipID, int clock, UINT8 AYDisable, UINT8 AYFlags, int* AYrate)
{
	static const ym2608_interface generic_2608 =
	{
		{
			AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT,
			AY8910_DEFAULT_LOADS
			//DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
		},
		NULL
	};
	//const ym2608_interface *intf = device->static_config ? (const ym2608_interface *)device->static_config : &generic_2608;
	ym2608_interface *intf;
	int rate;
	int ay_clock;
	//void *pcmbufa;
	//int  pcmsizea;

	//ym2608_state *info = get_safe_token(device);
	ym2608_state *info;

	if (ChipID >= MAX_CHIPS)
		return 0;
	
	info = &YM2608Data[ChipID];
	rate = clock/72;
	if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) ||
		CHIP_SAMPLING_MODE == 0x02)
		rate = CHIP_SAMPLE_RATE;
	info->intf = generic_2608;
	intf = &info->intf;
	if (AYFlags)
		intf->ay8910_intf.flags = AYFlags;
	//info->device = device;

	/* FIXME: Force to use single output */
	//info->psg = ay8910_start_ym(NULL, SOUND_YM2608, clock, &intf->ay8910_intf);
	if (! AYDisable)
	{
		ay_clock = clock / 4;
		*AYrate = ay_clock / 8;
		switch(AY_EMU_CORE)
		{
#ifdef ENABLE_ALL_CORES
		case EC_MAME:
			info->psg = ay8910_start_ym(NULL, CHTYPE_YM2608, ay_clock, &intf->ay8910_intf);
			break;
#endif
		case EC_EMU2149:
			info->psg = PSG_new(ay_clock, *AYrate);
			if (info->psg == NULL)
				return 0;
			PSG_setVolumeMode((PSG*)info->psg, 1);	// YM2149 volume mode
			break;
		}
	}
	else
	{
		info->psg = NULL;
		*AYrate = 0;
	}
	//assert_always(info->psg != NULL, "Error creating YM2608/AY8910 chip");

	/* Timer Handler set */
	//info->timer[0] = timer_alloc(device->machine, timer_callback_2608_0, info);
	//info->timer[1] = timer_alloc(device->machine, timer_callback_2608_1, info);

	/* stream system initialize */
	//info->stream = stream_create(device,0,2,rate,info,ym2608_stream_update);
	/* setup adpcm buffers */
	//pcmbufa  = device->region;
	//pcmsizea = device->regionbytes;

	/* initialize YM2608 */
	//info->chip = ym2608_init(info,device,device->clock,rate,
	//	           pcmbufa,pcmsizea,
	//	           timer_handler,IRQHandler,&psgintf);
	info->chip = ym2608_init(info, clock, rate, NULL, NULL, &psgintf);
	//assert_always(info->chip != NULL, "Error creating YM2608 chip");

	//state_save_register_postload(device->machine, ym2608_intf_postload, info);
	
	return rate;
}