Example #1
0
INT32 BurnYM2610Init(INT32 nClockFrequency, UINT8* YM2610ADPCMAROM, INT32* nYM2610ADPCMASize, UINT8* YM2610ADPCMBROM, INT32* nYM2610ADPCMBSize, FM_IRQHANDLER IRQCallback, INT32 (*StreamCallback)(INT32), double (*GetTimeCallback)(), INT32 bAddSignal)
{
	DebugSnd_YM2610Initted = 1;
	
	BurnTimerInit(&YM2610TimerOver, GetTimeCallback);

	if (nBurnSoundRate <= 0) {
		BurnYM2610StreamCallback = YM2610StreamCallbackDummy;

		BurnYM2610Update = YM2610UpdateDummy;

		AY8910InitYM(0, nClockFrequency, 11025, NULL, NULL, NULL, NULL, BurnAY8910UpdateRequest);
		YM2610Init(1, nClockFrequency, 11025, (void**)(&YM2610ADPCMAROM), nYM2610ADPCMASize, (void**)(&YM2610ADPCMBROM), nYM2610ADPCMBSize, &BurnOPNTimerCallback, IRQCallback);
		return 0;
	}

	BurnYM2610StreamCallback = StreamCallback;

   nBurnYM2610SoundRate = nBurnSoundRate;

   BurnYM2610Update = YM2610UpdateNormal;

	AY8910InitYM(0, nClockFrequency, nBurnYM2610SoundRate, NULL, NULL, NULL, NULL, BurnAY8910UpdateRequest);
	YM2610Init(1, nClockFrequency, nBurnYM2610SoundRate, (void**)(&YM2610ADPCMAROM), nYM2610ADPCMASize, (void**)(&YM2610ADPCMBROM), nYM2610ADPCMBSize, &BurnOPNTimerCallback, IRQCallback);

	pBuffer = (INT16*)malloc(4096 * 6 * sizeof(INT16));
	memset(pBuffer, 0, 4096 * 6 * sizeof(INT16));

	pAYBuffer = (INT32*)malloc(4096 * sizeof(INT32));
	memset(pAYBuffer, 0, 4096 * sizeof(INT32));
	
	nYM2610Position = 0;
	nAY8910Position = 0;

	nFractionalPosition = 0;
	bYM2610AddSignal = bAddSignal;
	
	// default routes
	YM2610Volumes[BURN_SND_YM2610_YM2610_ROUTE_1] = 1.00;
	YM2610Volumes[BURN_SND_YM2610_YM2610_ROUTE_2] = 1.00;
	YM2610Volumes[BURN_SND_YM2610_AY8910_ROUTE] = 1.00;
	YM2610RouteDirs[BURN_SND_YM2610_YM2610_ROUTE_1] = BURN_SND_ROUTE_LEFT;
	YM2610RouteDirs[BURN_SND_YM2610_YM2610_ROUTE_2] = BURN_SND_ROUTE_RIGHT;
	YM2610RouteDirs[BURN_SND_YM2610_AY8910_ROUTE] = BURN_SND_ROUTE_BOTH;
	
	bYM2610UseSeperateVolumes = 0;
	YM2610LeftVolumes[BURN_SND_YM2610_YM2610_ROUTE_1] = 1.00;
	YM2610LeftVolumes[BURN_SND_YM2610_YM2610_ROUTE_2] = 1.00;
	YM2610LeftVolumes[BURN_SND_YM2610_AY8910_ROUTE] = 1.00;
	YM2610RightVolumes[BURN_SND_YM2610_YM2610_ROUTE_1] = 1.00;
	YM2610RightVolumes[BURN_SND_YM2610_YM2610_ROUTE_2] = 1.00;
	YM2610RightVolumes[BURN_SND_YM2610_AY8910_ROUTE] = 1.00;

	return 0;
}
Example #2
0
int YM2610_sh_start(const struct MachineSound *msound)
{
	int i,j;
	int rate = Machine->sample_rate;
	char buf[YM2610_NUMBUF][40];
	const char *name[YM2610_NUMBUF];
	int mixed_vol,vol[YM2610_NUMBUF];
	void *pcmbufa[YM2610_NUMBUF],*pcmbufb[YM2610_NUMBUF];
	int  pcmsizea[YM2610_NUMBUF],pcmsizeb[YM2610_NUMBUF];

	intf = msound->sound_interface;
	if( intf->num > MAX_2610 ) return 1;

	if (AY8910_sh_start(msound)) return 1;

	/* Timer Handler set */
	FMTimerInit();

	/* stream system initialize */
	for (i = 0;i < intf->num;i++)
	{
		/* stream setup */
		mixed_vol = intf->volumeFM[i];
		/* stream setup */
		for (j = 0 ; j < YM2610_NUMBUF ; j++)
		{
			name[j]=buf[j];
			vol[j] = mixed_vol & 0xffff;
			mixed_vol>>=16;
			sprintf(buf[j],"%s #%d Ch%d",sound_name(msound),i,j+1);
		}
		stream[i] = stream_init_multi(YM2610_NUMBUF,name,vol,rate,i,YM2610UpdateOne);
		/* setup adpcm buffers */
		pcmbufa[i]  = (void *)(memory_region(intf->pcmroma[i]));
		pcmsizea[i] = memory_region_length(intf->pcmroma[i]);
		pcmbufb[i]  = (void *)(memory_region(intf->pcmromb[i]));
		pcmsizeb[i] = memory_region_length(intf->pcmromb[i]);
	}

	/**** initialize YM2610 ****/
	if (YM2610Init(intf->num,intf->baseclock,rate,
		           pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
		           TimerHandler,IRQHandler) == 0)
		return 0;

	/* error */
	return 1;
}
Example #3
0
static void *ym2610_start(int sndindex, int clock, const void *config)
{
	static const struct YM2610interface generic_2610 = { 0 };
	const struct YM2610interface *intf = config ? config : &generic_2610;
	int rate = Machine->sample_rate;
	void *pcmbufa,*pcmbufb;
	int  pcmsizea,pcmsizeb;
	struct ym2610_info *info;

	sound_type = SOUND_YM2610;

	info = auto_malloc(sizeof(*info));
	memset(info, 0, sizeof(*info));

	info->intf = intf;
	info->psg = ay8910_start_ym(SOUND_YM2610, sndindex, clock, 1, NULL, NULL, NULL, NULL);
	if (!info->psg) return NULL;

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

	/* stream system initialize */
	info->stream = stream_create(0,2,rate,info,ym2610_stream_update);
	/* setup adpcm buffers */
	pcmbufa  = (void *)(memory_region(info->intf->pcmroma));
	pcmsizea = memory_region_length(info->intf->pcmroma);
	pcmbufb  = (void *)(memory_region(info->intf->pcmromb));
	pcmsizeb = memory_region_length(info->intf->pcmromb);

	/**** initialize YM2610 ****/
	info->chip = YM2610Init(info,sndindex,clock,rate,
		           pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
		           TimerHandler,IRQHandler,&psgintf);

	state_save_register_func_postload_ptr(ym2610_postload, info);

	if (info->chip)
		return info;

	/* error */
	return NULL;
}
Example #4
0
/*-------------------------------------------------------------------------

	Do all one time initializations.

---------------------------------------------------------------------------*/
void neogeo_initialize ( void )
{
	neogeo_audio_track = NULL;

	/* Create and register the watchdog timer */
	timer_create ( &neogeo_watchdog_timer, neogeo_watchdog_callback );
	timer_register ( &neogeo_watchdog_timer );

	/* Create and register the drawline timer. */
	timer_create ( &neogeo_drawline_timer, neogeo_drawline_callback );
	timer_register ( &neogeo_drawline_timer );

	/* Create and register the screen timer. */
	timer_create ( &neogeo_screen_timer, neogeo_screen_callback );
	timer_register ( &neogeo_screen_timer );

	/* Create and register the VBL timer */
	timer_create ( &neogeo_VBL_timer, neogeo_VBL_callback );
	timer_register ( &neogeo_VBL_timer );

	/* Create and register the HBL timer */
	timer_create ( &neogeo_HIRQ_timer, neogeo_HIRQ_callback );
	timer_register ( &neogeo_HIRQ_timer );

	/* Create and register the CDROM IRQ1 Timer */
	timer_create ( &neogeo_cdrom_irq1_timer, neogeo_cdrom_irq1_callback );
	timer_register ( &neogeo_cdrom_irq1_timer );

	/* Create and register the CDROM IRQ2 Timer */
	timer_create ( &neogeo_cdrom_irq2_timer, neogeo_cdrom_irq2_callback );
	timer_register ( &neogeo_cdrom_irq2_timer );

	/* Create and register the timer for audio commands */
	timer_create ( &neogeo_audio_command_timer, neogeo_audio_command_timer_callback );
	timer_register ( &neogeo_audio_command_timer );

	/* Create and register the YM2610 timers */
	timer_create ( &neogeo_ym2610_timer_a, neogeo_ym2610_timer_callback );
	timer_set_data ( &neogeo_ym2610_timer_a, 0 );
	timer_register ( &neogeo_ym2610_timer_a );

	timer_create ( &neogeo_ym2610_timer_b, neogeo_ym2610_timer_callback );
	timer_set_data ( &neogeo_ym2610_timer_b, 1 );
	timer_register ( &neogeo_ym2610_timer_b );

	/* Initialize the memory lookup table */
	memory_init_lookup();

	/* Initialize the 68000 emulation core */
	m68k_set_cpu_type ( M68K_CPU_TYPE_68000 );
	m68k_init();

	/* Inizialize the z80 core */
	z80_init ( 0, Z80_CLOCK, NULL, neogeo_z80_irq_callback );

	/* Initialize the YM2610 */
	YM2610Init ( 8000000, neogeo_audio_frequency, neogeo_PCM_RAM, 0x100000, YM2610TimerHandler, YM2610IrqHandler );

	/* Patch protection check 1 (Disc recognition) */
	m68k_debug_write_memory_16 ( 0xC0D280, 0x4E71 );

	/* Patch protection check 2 ("Now loading" screen) */
	m68k_debug_write_memory_16 ( 0xC0EB82, 0x4E71 );

	/* CD-Loading "speed hack" ^.^ */
	m68k_debug_write_memory_32 ( 0xC0E764, 0x4E722000 );
	m68k_debug_write_memory_16 ( 0xC0E768, 0x4E71 );

	/* Reset all internal register and variables to a known state */
	neogeo_cold_reset();

	/* Test if the underlying OS has accurate sleep() */
	neogeo_test_delay_accurate();
}