int YM2612_sh_start(const struct MachineSound *msound) { int i,j; int rate = Machine->sample_rate; char buf[YM2612_NUMBUF][40]; const char *name[YM2612_NUMBUF]; intf = msound->sound_interface; if( intf->num > MAX_2612 ) return 1; /* FM init */ /* Timer Handler set */ FMTimerInit(); /* stream system initialize */ for (i = 0;i < intf->num;i++) { int vol[YM2612_NUMBUF]; /* stream setup */ for (j = 0 ; j < YM2612_NUMBUF ; j++) { vol[j] = intf->mixing_level[i]; name[j] = buf[j]; sprintf(buf[j],"YM2612(%s) #%d",j < 2 ? "FM" : "ADPCM",i); } stream[i] = stream_init_multi(YM2612_NUMBUF, name,vol,rate,FM_OUTPUT_BIT, i,YM2612UpdateOne); } /**** initialize YM2612 ****/ if (YM2612Init(intf->num,intf->baseclock,rate,TimerHandler,IRQHandler) == 0) return 0; /* error */ return 1; }
int YM2203_sh_start(const struct MachineSound *msound) { int i; if (AY8910_sh_start_ym(msound)) return 1; intf = msound->sound_interface; /* Timer Handler set */ FMTimerInit(); /* stream system initialize */ for (i = 0;i < intf->num;i++) { int volume; char name[20]; sprintf(name,"%s #%d FM",sound_name(msound),i); volume = intf->mixing_level[i]>>16; /* high 16 bit */ stream[i] = stream_init(name,volume,Machine->sample_rate,i,YM2203UpdateOne/*YM2203UpdateCallback*/); } /* Initialize FM emurator */ if (YM2203Init(intf->num,intf->baseclock,Machine->sample_rate,TimerHandler,IRQHandler) == 0) { /* Ready */ return 0; } /* error */ /* stream close */ return 1; }
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; }
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; }