Esempio n. 1
0
/**
 * setSoundYM2612_Improved(): Enable or disable improved YM2612 sound emulation.
 * @param newSoundYM2612_Improved New improved YM2612 sound enable setting.
 */
void Options::setSoundYM2612_Improved(const bool newSoundYM2612_Improved)
{
	unsigned char Reg_1[0x200];
	
	YM2612_Improv = newSoundYM2612_Improved;
	
	if (YM2612_Improv)
	{
		MESSAGE_L("High Quality YM2612 emulation",
			  "High Quality YM2612 emulation", 1000);
	}
	else
	{
		MESSAGE_L("Normal YM2612 emulation",
			  "Normal YM2612 emulation", 1000);
	}
	
	// Save the YM2612 registers.
	// TODO: Use full save instead of partial save?
	YM2612_Save(Reg_1);
	
	if (CPU_Mode)
		YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv);
	else
		YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv);
	
	// Restore the YM2612 registers.
	YM2612_Restore(Reg_1);
}
Esempio n. 2
0
/**
 * setSoundStereo(): Enable or disable stereo sound.
 * @param newSoundStereo New stereo sound enable setting.
 */
void Options::setSoundStereo(const bool newSoundStereo)
{
	// TODO: Move most of this code to the Audio class.
	unsigned char Reg_1[0x200];
	
	audio->setStereo(newSoundStereo);
	
	if (!audio->stereo())
		MESSAGE_L("Mono sound", "Mono sound", 1000);
	else
		MESSAGE_L("Stereo sound", "Stereo sound", 1000);
	
	if (!audio->enabled())
	{
		// Sound isn't enabled, so nothing needs to be changed.
		return;
	}
	
	// Save the current sound state.
	// TODO: Use full save instead of partial save?
	PSG_Save_State();
	YM2612_Save(Reg_1);
	
	// Temporarily disable sound.
	audio->endSound();
	audio->setEnabled(false);
	
	// Reinitialize the sound processors.
	if (CPU_Mode)
	{
		YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv);
		PSG_Init(CLOCK_PAL / 15, audio->soundRate());
	}
	else
	{
		YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv);
		PSG_Init(CLOCK_NTSC / 15, audio->soundRate());
	}
	
	if (SegaCD_Started)
		Set_Rate_PCM(audio->soundRate());
	
	// Restore the sound state.
	YM2612_Restore(Reg_1);
	PSG_Restore_State();
	
	// Attempt to re-enable sound.
	if (!audio->initSound())
		return;
	
	// Sound enabled.
	audio->setEnabled(true);
	audio->playSound();
	return;
}
Esempio n. 3
0
void Start_Play_GYM(int sampleRate)
{
	Seg_Lenght = (int) ceil(sampleRate / 60.0);

/*	memset(Seg_L, 0, Seg_Lenght << 2);
	memset(Seg_R, 0, Seg_Lenght << 2);*/

	YM2612_Init(CLOCK_NTSC / 7, sampleRate, YM2612_Improv);
	PSG_Init(CLOCK_NTSC / 15, sampleRate);
}
Esempio n. 4
0
//static DEVICE_START( ym2612 )
int device_start_ym2612(UINT8 ChipID, int clock)
{
	//static const ym2612_interface dummy = { 0 };
	//ym2612_state *info = get_safe_token(device);
	ym2612_state *info;
	int rate;

	if (ChipID >= MAX_CHIPS)
		return 0;
	
	info = &YM2612Data[ChipID];
	rate = clock/72;
	if (EMU_CORE == EC_MAME && ! (ChipFlags & 0x02))
		rate /= 2;
	if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) ||
		CHIP_SAMPLING_MODE == 0x02)
		rate = CHIP_SAMPLE_RATE;
	//info->intf = device->static_config ? (const ym2612_interface *)device->static_config : &dummy;
	//info->intf = &dummy;
	//info->device = device;

	/* FM init */
	/* Timer Handler set */
	//info->timer[0] = timer_alloc(device->machine, timer_callback_2612_0, info);
	//info->timer[1] = timer_alloc(device->machine, timer_callback_2612_1, info);

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

	/**** initialize YM2612 ****/
	switch(EMU_CORE)
	{
	case EC_MAME:
		//info->chip = ym2612_init(info,clock,rate,timer_handler,IRQHandler);
		info->chip = ym2612_init(info, clock, rate, NULL, NULL);
		break;
#ifdef ENABLE_ALL_CORES
	case EC_GENS:
		if (GensBuf[0x00] == NULL)
		{
			GensBuf[0x00] = malloc(sizeof(int) * 0x100);
			GensBuf[0x01] = GensBuf[0x00] + 0x80;
		}
		info->chip = YM2612_Init(clock, rate, 0x00);
		YM2612_SetMute(info->chip, 0x80);	// Disable SSG-EG
		break;
#endif
	}
	//assert_always(info->chip != NULL, "Error creating YM2612 chip");
	//ym2612_postload(info->chip);

	//state_save_register_postload(device->machine, ym2612_intf_postload, info);
	//ym2612_intf_postload();
	return rate;
}
Esempio n. 5
0
/**
 * setSoundSampleRate(): Change the sample rate.
 * @param Rate Rate ID. (TODO: Make an enum containing the rate IDs.)
 */
void Options::setSoundSampleRate(const int newRate)
{
	// Make sure the rate ID is valid.
	assert(newRate >= 0 && newRate <= 2);
	
	switch (newRate)
	{
		case 0:
			audio->setSoundRate(11025);
			break;
		case 1:
			audio->setSoundRate(22050);
			break;
		case 2:
			audio->setSoundRate(44100);
			break;
	}
	MESSAGE_NUM_L("Sound rate set to %d Hz", "Sound rate set to %d Hz", audio->soundRate(), 2500);
	
	// If sound isn't enabled, we're done.
	if (!audio->enabled())
		return;
	
	// Sound's enabled. Reinitialize it.
	unsigned char Reg_1[0x200];
	
	// Save the sound registers.
	// TODO: Use a full save instead of a partial save?
	PSG_Save_State();
	YM2612_Save(Reg_1);
	
	// Stop sound.
	audio->endSound();
	audio->setEnabled(false);
	
	// Reinitialize the sound processors.
	if (CPU_Mode)
	{
		YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv);
		PSG_Init(CLOCK_PAL / 15, audio->soundRate());
	}
	else
	{
		YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv);
		PSG_Init(CLOCK_NTSC / 15, audio->soundRate());
	}

	if (SegaCD_Started)
		Set_Rate_PCM(audio->soundRate());
	
	// Restore the sound registers
	YM2612_Restore(Reg_1);
	PSG_Restore_State();
	
	// Attempt to reinitialize sound.
	if (!audio->initSound())
		return;
	
	// Sound is reinitialized.
	audio->setEnabled(true);
	audio->playSound();
	
	return;
}
Esempio n. 6
0
/**
 * setCountry(): Set the current country code.
 * @param newCountry New country code.
 */
void Options::setCountry(const int newCountry)
{
	unsigned char Reg_1[0x200];
	
	Flag_Clr_Scr = 1;
	
	Country = newCountry;
	switch (Country)
	{
		default:
		case -1:
			// Auto-detect.
			if (Genesis_Started || _32X_Started)
				Detect_Country_Genesis();
			else if (SegaCD_Started)
				Detect_Country_SegaCD();
			break;
		
		case 0:
			// Japan (NTSC)
			Game_Mode = 0;
			CPU_Mode = 0;
			break;
		
		case 1:
			// USA (NTSC)
			Game_Mode = 1;
			CPU_Mode = 0;
			break;
		
		case 2:
			// Europe (PAL)
			Game_Mode = 1;
			CPU_Mode = 1;
			break;
		
		case 3:
			// Japan (PAL)
			Game_Mode = 0;
			CPU_Mode = 1;
			break;
	}
	
	// TODO: Combine this with gens.cpp:Set_Clock_Freq().
	if (CPU_Mode)
	{
		CPL_Z80 = roundDouble((((double)CLOCK_PAL / 15.0) / 50.0) / 312.0);
		CPL_M68K = roundDouble((((double)CLOCK_PAL / 7.0) / 50.0) / 312.0);
		CPL_MSH2 = roundDouble(((((((double)CLOCK_PAL / 7.0) * 3.0) / 50.0) / 312.0) *
					(double)MSH2_Speed) / 100.0);
		CPL_SSH2 = roundDouble(((((((double)CLOCK_PAL / 7.0) * 3.0) / 50.0) / 312.0) *
					(double)SSH2_Speed) / 100.0);
		
		VDP_Num_Lines = 312;
		VDP_Status |= 0x0001;
		_32X_VDP.Mode &= ~0x8000;
		
		CD_Access_Timer = 2080;
		Timer_Step = 136752;
	}
	else
	{
		CPL_Z80 = roundDouble((((double)CLOCK_NTSC / 15.0) / 60.0) / 262.0);
		CPL_M68K = roundDouble((((double)CLOCK_NTSC / 7.0) / 60.0) / 262.0);
		CPL_MSH2 = roundDouble(((((((double)CLOCK_NTSC / 7.0) * 3.0) / 60.0) / 262.0) *
					(double)MSH2_Speed) / 100.0);
		CPL_SSH2 = roundDouble(((((((double) CLOCK_NTSC / 7.0) * 3.0) / 60.0) / 262.0) *
					(double)SSH2_Speed) / 100.0);
		
		VDP_Num_Lines = 262;
		VDP_Status &= 0xFFFE;
		_32X_VDP.Mode |= 0x8000;
		
		CD_Access_Timer = 2096;
		Timer_Step = 135708;
	}
	
	if (audio->enabled())
	{
		PSG_Save_State();
		YM2612_Save(Reg_1);
		
		audio->endSound();
		audio->setEnabled(false);
		
		if (CPU_Mode)
		{
			YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv);
			PSG_Init(CLOCK_PAL / 15, audio->soundRate());
		}
		else
		{
			YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv);
			PSG_Init(CLOCK_NTSC / 15, audio->soundRate());
		}
		
		if (SegaCD_Started)
			Set_Rate_PCM(audio->soundRate());
		
		YM2612_Restore (Reg_1);
		PSG_Restore_State();
		
		if (!audio->initSound())
			return;
		
		audio->setEnabled(true);
		audio->playSound();
	}
	
	if (Game_Mode)
	{
		if (CPU_Mode)
			MESSAGE_L("Europe system (50 FPS)", "Europe system (50 FPS)", 1500);
		else
			MESSAGE_L("USA system (60 FPS)", "USA system (60 FPS)", 1500);
	}
	else
	{
		if (CPU_Mode)
			MESSAGE_L("Japan system (50 FPS)", "Japan system (50 FPS)", 1500);
		else
			MESSAGE_L("Japan system (60 FPS)", "Japan system (60 FPS)", 1500);
	}
	
	setGameName();
	return;
}