Example #1
0
int rockola_sh_start(const struct MachineSound *msound)
{
	int vol[3];

	Machine->samples = readsamples(vanguard_sample_names,Machine->gamedrv->name);

	vol[0] = vol[1] = vol[2] = TONE_VOLUME;
	tonechannels = mixer_allocate_channels(3,vol);
	vol[0] = vol[1] = vol[2] = SAMPLE_VOLUME;
	samplechannels = mixer_allocate_channels(3,vol);

	NoSound0=1;
	Sound0Offset=0;
	Sound0Base=0x0000;
	NoSound1=1;
	Sound1Offset=0;
	Sound1Base=0x0800;
	NoSound2=1;
	Sound2Offset=0;
	Sound2Base=0x1000;

	mixer_set_volume(tonechannels+0,0);
	mixer_play_sample(tonechannels+0,(signed char*)waveform,32,1000,1);
	mixer_set_volume(tonechannels+1,0);
	mixer_play_sample(tonechannels+1,(signed char*)waveform,32,1000,1);
	mixer_set_volume(tonechannels+2,0);
	mixer_play_sample(tonechannels+2,(signed char*)waveform,32,1000,1);

	return 0;
}
Example #2
0
void sh_votrax_start(int Channel)
{
	VotraxSamples = readsamples(VotraxTable,"votrax");
    VotraxBaseFrequency = 8000;
    VotraxBaseVolume = 230;
    VotraxChannel = Channel;
}
Example #3
0
    /*
     *	information from a gmon.out file is in two parts:
     *	an array of sampling hits within pc ranges,
     *	and the arcs.
     */
void
getpfile(const char *filename)
{
    FILE		*pfile;
    struct rawarc	arc;

    pfile = openpfile(filename);
    readsamples(pfile);
	/*
	 *	the rest of the file consists of
	 *	a bunch of <from,self,count> tuples.
	 */
    while ( fread( &arc , sizeof arc , 1 , pfile ) == 1 ) {
#	ifdef DEBUG
	    if ( debug & SAMPLEDEBUG ) {
		printf( "[getpfile] frompc 0x%lx selfpc 0x%lx count %ld\n" ,
			arc.raw_frompc , arc.raw_selfpc , arc.raw_count );
	    }
#	endif /* DEBUG */
	    /*
	     *	add this arc
	     */
	tally( &arc );
    }
    fclose(pfile);
}
Example #4
0
int gorf_sh_start(const struct MachineSound *msound)
{
	Machine->samples = readsamples(gorf_sample_names,Machine->gamedrv->name);

    GorfBaseFrequency = 11025;
    GorfBaseVolume = 230;
    GorfChannel = 0;
    return 0;
}
Example #5
0
void
ibs_stop(int cid)
{
    if (!ibs_enabled)
	return;
    cid = lcpu_to_pcpu[cid];
    char path[512];
    // set opctl to stop
    sprintf(path, "/sys/kernel/amd10h-ibs/cpu%d/opctl", cid);
    writefile(path, "0");
    sprintf(path, "/sys/kernel/amd10h-ibs/cpu%d/record", cid);
    readsamples(path);
}
Example #6
0
int samples_sh_start(const struct MachineSound *msound)
{
    int i;
    int vol[MIXER_MAX_CHANNELS];
    const struct Samplesinterface *intf = msound->sound_interface;

    /* read audio samples if available */
    Machine->samples = readsamples(intf->samplenames,Machine->gamedrv->name);

    numchannels = intf->channels;
    for (i = 0; i < numchannels; i++)
        vol[i] = intf->volume;
    firstchannel = mixer_allocate_channels(numchannels,vol);
    for (i = 0; i < numchannels; i++)
    {
        char buf[40];

        sprintf(buf,"Sample #%d",i);
        mixer_set_name(firstchannel + i,buf);
    }
    return 0;
}
Example #7
0
/***************************************************************************

  Initialize the emulated machine (load the roms, initialize the various
  subsystems...). Returns 0 if successful.

***************************************************************************/
int init_machine(const char *gamename,int argc,char **argv)
{
	int i;


	frameskip = 0;
	for (i = 1;i < argc;i++)
	{
		if (stricmp(argv[i],"-frameskip") == 0)
		{
			i++;
			if (i < argc)
			{
				frameskip = atoi(argv[i]);
				if (frameskip < 0) frameskip = 0;
				if (frameskip > 3) frameskip = 3;
			}
		}
	}

	i = 0;
	while (drivers[i] && stricmp(gamename,drivers[i]->name) != 0)
		i++;

	if (drivers[i] == 0)
	{
		printf("game \"%s\" not supported\n",gamename);
		return 1;
	}

	Machine->gamedrv = gamedrv = drivers[i];
	Machine->drv = drv = gamedrv->drv;

	if (readroms(gamedrv->rom,gamename) != 0)
		return 1;

	RAM = Machine->memory_region[drv->cpu[0].memory_region];
	ROM = RAM;

	/* decrypt the ROMs if necessary */
	if (gamedrv->rom_decode)
	{
		int j;


		for (j = 0;j < 0x10000;j++)
			RAM[j] = (*gamedrv->rom_decode)(j);
	}

	if (gamedrv->opcode_decode)
	{
		int j;


		/* find the first avaialble memory region pointer */
		j = 0;
		while (Machine->memory_region[j]) j++;

		if ((ROM = (unsigned char *)malloc(0x10000)) == 0)
			return 1;

		Machine->memory_region[j] = ROM;

		for (j = 0;j < 0x10000;j++)
			ROM[j] = (*gamedrv->opcode_decode)(j);
	}


	/* read audio samples if available */
        Machine->samples = readsamples(gamedrv->samplenames,gamename);


	if (*drv->init_machine && (*drv->init_machine)(gamename) != 0)
		return 1;

	if (*drv->vh_init && (*drv->vh_init)(gamename) != 0)
		return 1;

	if (*drv->sh_init && (*drv->sh_init)(gamename) != 0)
		return 1;

	return 0;
}
Example #8
0
int YM2608_sh_start(const struct MachineSound *msound)
{
	int i,j;
	int rate = Machine->sample_rate;
	char buf[YM2608_NUMBUF][40];
	const char *name[YM2608_NUMBUF];
	int mixed_vol,vol[YM2608_NUMBUF];
	void *pcmbufa[YM2608_NUMBUF];
	int  pcmsizea[YM2608_NUMBUF];
	int rhythm_pos[6+1];
	struct GameSamples	*psSamples;
	int total_size,r_offset,s_size;

	intf = (const struct YM2608interface *)msound->sound_interface;
	if( intf->num > MAX_2608 ) 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 < YM2608_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(YM2608_NUMBUF,name,vol,rate,i,YM2608UpdateOne);
		/* setup adpcm buffers */
		pcmbufa[i]  = (void *)(memory_region(intf->pcmrom[i]));
		pcmsizea[i] = memory_region_length(intf->pcmrom[i]);
	}

	/* rythm rom build */
	rhythm_buf = 0;
#ifdef YM2608_USE_SAMPLES
	psSamples = readsamples(ym2608_pDrumNames,"ym2608");
#else
	psSamples = 0;
#endif
	if( psSamples )
	{
		/* calcrate total data size */
		total_size = 0;
		for( i=0;i<6;i++)
		{
			s_size = psSamples->sample[i]->length;
			total_size += s_size ? s_size : 1;
		}
		/* aloocate rythm data */
		rhythm_buf = (short int*)malloc(total_size * sizeof(signed short));
		if( rhythm_buf==0 ) return 0;

		r_offset = 0;
		/* merge sampling data */
		for(i=0;i<6;i++)
		{
			/* set start point */
			rhythm_pos[i] = r_offset*2;
			/* copy sample data */
			s_size = psSamples->sample[i]->length;
			if(s_size && psSamples->sample[i]->data)
			{
				if( psSamples->sample[i]->resolution==16 )
				{
					signed short *s_ptr = (signed short *)psSamples->sample[i]->data;
					for(j=0;j<s_size;j++) rhythm_buf[r_offset++] = *s_ptr++;
				}else{
					signed char *s_ptr = (signed char *)psSamples->sample[i]->data;
					for(j=0;j<s_size;j++) rhythm_buf[r_offset++] = (*s_ptr++)*0x0101;
				}
			}else rhythm_buf[r_offset++] = 0;
			/* set end point */
			rhythm_pos[i+1] = r_offset*2;
		}
		freesamples( psSamples );
	}else
	{
		/* aloocate rythm data */
		rhythm_buf = (short int*)malloc(6 * sizeof(signed short));
		if( rhythm_buf==0 ) return 0;
		for(i=0;i<6;i++)
		{
			/* set start point */
			rhythm_pos[i] = i*2;
			rhythm_buf[i] = 0;
			/* set end point */
			rhythm_pos[i+1] = (i+1)*2;
		}
	}

	/**** initialize YM2608 ****/
	if (YM2608Init(intf->num,intf->baseclock,rate,
		           pcmbufa,pcmsizea,rhythm_buf,rhythm_pos,
		           TimerHandler,IRQHandler) == 0)
		return 0;

	/* error */
	return 1;
}