// Initialize Sound Engine ---------------------------------------------------- // FIXME: This is mostly legacy stuff :( static int Sound_Init_Engine (int buffer_mode) { // Stream Buffer Mode //STREAM_BUFFER_MAXA = DEF_STREAM_BUFFER_MAXA; MODEB_FRAME_SIZE = DEF_MODEB_FRAME_SIZE; MODEB_UPDATE_COUNT = DEF_MODEB_UPDATE_COUNT; MODEB_ERROR_MAX = DEF_STREAM_UPDATE_ERROR_MAX; STREAM_BUFFER_MAXB = MODEB_FRAME_SIZE; MODEB_MASK = MODEB_FRAME_SIZE / MODEB_UPDATE_COUNT; sound_stream_mode = buffer_mode; /* SOUND_STREAM_WAIT in MEKA */ //stream_buffer_max = (sound_stream_mode == SOUND_STREAM_NORMAL) ? STREAM_BUFFER_MAXA : STREAM_BUFFER_MAXB; #ifdef INSTALL_SOUND_TIMER buffered_stream_max = stream_buffer_max = 3; // audio_buffer_max_size MODEB_UPDATE_COUNT = 1; #else stream_buffer_max = ((stream_buffer_max / 6) / MODEB_UPDATE_COUNT) * MODEB_UPDATE_COUNT; // buffered_stream_max = stream_buffer_max; // audio_buffer_max_size buffered_stream_max = MODEB_UPDATE_COUNT * 2; // audio_buffer_max_size #endif /**** timer work init ****/ sound_freerun_count = 0; sound_slice = 0; if (change_sample_rate) { // Sample rate has changed, so all emulators must be restarted! change_sample_rate = FALSE; saStopSoundEmulators(); } ConsolePrint (" - SEAL: Ok\n"); // FIXME: should be a message ? #ifdef INSTALL_SOUND_TIMER saInitSoundTimer(); #endif if (SndMachine != NULL) { if (!SndMachine->first) { int i; SndMachine->first = 1; /* first flag clear */ streams_sh_start(); /* streaming system initialize & start */ pause_sound = 0; /* pause flag off */ vbover_err = vbunder_err = 0; /* error initial */ for (i = 0; i < SndMachine->control_max; i++) { if (SndMachine->f_init[i]) { if (SndMachine->f_init[i] (SndMachine->userdata[i]) != MEKA_ERR_OK) { SndMachine = NULL; return (MEKA_ERR_FAIL); } } } } } return (MEKA_ERR_OK); }
void sound_reset(void) { #ifdef Z80_EMULATED //puts("sound_reset"); streams_sh_start(); sound_emulate_start(); sound_unmute(); #endif }
int sound_start(void) { int totalsound = 0; int i; /* Verify the order of entries in the sndintf[] array */ for (i = 0;i < SOUND_COUNT;i++) { if (sndintf[i].sound_num != i) { int j; logerror("Sound #%d wrong ID %d: check enum SOUND_... in src/sndintrf.h!\n",i,sndintf[i].sound_num); for (j = 0; j < i; j++) logerror("ID %2d: %s\n", j, sndintf[j].name); return 1; } } /* samples will be read later if needed */ Machine->samples = 0; refresh_period = TIME_IN_HZ(Machine->drv->frames_per_second); refresh_period_inv = 1.0 / refresh_period; sound_update_timer = timer_alloc(NULL); if (mixer_sh_start() != 0) return 1; if (streams_sh_start() != 0) return 1; while (totalsound < MAX_SOUND && Machine->drv->sound[totalsound].sound_type != 0) { if ((*sndintf[Machine->drv->sound[totalsound].sound_type].start)(&Machine->drv->sound[totalsound]) != 0) goto getout; totalsound++; } return 0; getout: /* TODO: should also free the resources allocated before */ return 1; }
/* called after the rom is opened */ void init_neo(char *rom_name) { cpu_68k_init(); neogeo_init(); pd4990a_init(); setup_misc_patch(rom_name); if (conf.sound) { cpu_z80_init(); ogc_init_audio(); streams_sh_start(); YM2610_sh_start(); conf.snd_st_reg_create=1; } cpu_68k_reset(); arcade = (conf.system != SYS_HOME); }
void init_neo(char *rom_name) { cpu_68k_init(); neogeo_init(); pd4990a_init(); setup_misc_patch(rom_name); if (conf.sound) { cpu_z80_init(); init_sdl_audio(); streams_sh_start(); YM2610_sh_start(); SDL_PauseAudio(0); conf.snd_st_reg_create=1; } cpu_68k_reset(); }
int init_sound_emulators(void) { int i,j; if(change_sample_rate) saStopSoundEmulators(); if (emulators_active) return 0; change_sample_rate = 0; if( SndMachine ){ if( !SndMachine->first ){ saInitVolPan(); /* moved. (hiro-shi) */ SndMachine->first = 1; /* first flag clear */ streams_sh_start(); /* streaming system initialize & start */ for( j = 0; j < SndMachine->control_max; j++ ){ switch( SndMachine->init[j] ){ #if HAS_YM2203 case SOUND_YM2203: i = YM2203_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM2151 case SOUND_YM2151S: i = YM2151_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM2413 case SOUND_YM2413: i = YM2413_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM2151_ALT case SOUND_YM2151J: i = YM2151_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM2610 case SOUND_YM2610: i = YM2610_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM2610B case SOUND_YM2610B: i = YM2610B_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_MSM5205_BUFF case SOUND_MSM5205_BUFF: i = MSM5205buffer_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_ADPCM case SOUND_M6295: i = OKIM6295_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_AY8910 case SOUND_AY8910: i = AY8910_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YM3812 case SOUND_YM3812: i = YM3812_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_SMP16 case SOUND_SMP16: i = SMP16buffer_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_M6585 case SOUND_M6585: i = M6585buffer_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YMZ280B case SOUND_YMZ280B: i = YMZ280B_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_ES5505 case SOUND_ES5505: i = ES5505_sh_start( SndMachine->intf[j] ); break; case SOUND_ES5506: i = ES5506_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_QSOUND case SOUND_QSOUND: i = qsound_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_YMF278B case SOUND_YMF278B: i = YMF278B_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_NAMCO case SOUND_NAMCO: i = namco_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_X1_010 case SOUND_X1_010: i = seta_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_DAC case SOUND_DAC: i = DAC_sh_start( SndMachine->intf[j] ); break; #endif #if HAS_DXSMP case SOUND_DXSMP: i = dxsmp_sh_start( SndMachine->intf[j] ); break; #endif default: i = 1; break; } if( i ){ audio_sample_rate = 0; SndMachine = NULL; printf("emulator init failed\n"); return 1; } } } } emulators_active = 1; return 0; }
int sound_start(void) { #if 0 /* forQUASI88 */ int totalsound = 0; int i; /* Verify the order of entries in the sndintf[] array */ for (i = 0;i < SOUND_COUNT;i++) { if (sndintf[i].sound_num != i) { int j; logerror("Sound #%d wrong ID %d: check enum SOUND_... in src/sndintrf.h!\n",i,sndintf[i].sound_num); for (j = 0; j < i; j++) logerror("ID %2d: %s\n", j, sndintf[j].name); return 1; } } /* samples will be read later if needed */ Machine->samples = 0; refresh_period = TIME_IN_HZ(Machine->drv->frames_per_second); refresh_period_inv = 1.0 / refresh_period; sound_update_timer = timer_alloc(NULL); #endif /* forQUASI88 */ #if 1 /* forQUASI88 */ #ifndef USE_FMGEN if( use_fmgen ){ if(verbose_proc) printf("(cisc's Fmgen liblary not available)..."); use_fmgen = 0; } #endif /* set interface parameter ( volume, mono/stereo, and so on ) */ /* set interface parameter and set xmame interface function */ #ifdef USE_FMGEN if( use_fmgen ){ if( sound_board==SOUND_I ){ /* fmgen ym2203 */ fm_interface = pc88_fmgen_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_fmgen_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; }else{ /* fmgen ym2608 */ fm_interface = pc88_fmgen2_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_fmgen2_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; } }else #endif { if( sound_board==SOUND_I ){ /* xmame ym2203 */ fm_interface = pc88_sound_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_sound_func; Machine__drv__sound_attributes = 0; }else{ /* xmame ym2608 */ fm_interface = pc88_sound2_interface; beep_interface = pc88_beep_interface; xmame_func_sound = pc88_sound2_func; Machine__drv__sound_attributes = SOUND_SUPPORTS_STEREO; } } /* set volume ( fm, psg, beep ) */ if( sound_board==SOUND_I ){ if( Machine__drv__sound_attributes == 0) ym2203_interface.mixing_level[0] = YM2203_VOL(fmvol,psgvol); else ym2203_interface.mixing_level[0] = YM3012_VOL(fmvol,MIXER_PAN_LEFT,fmvol,MIXER_PAN_RIGHT); }else{ ym2608_interface.volumeSSG[0] = psgvol; ym2608_interface.volumeFM[0] = YM3012_VOL(fmvol,MIXER_PAN_LEFT,fmvol,MIXER_PAN_RIGHT); } beep88_interface.mixing_level[0] = beepvol; #endif /* forQUASI88 */ if (mixer_sh_start() != 0) return 1; if (streams_sh_start() != 0) return 1; #if 0 /* forQUASI88 */ while (Machine->drv->sound[totalsound].sound_type != 0 && totalsound < MAX_SOUND) { if ((*sndintf[Machine->drv->sound[totalsound].sound_type].start)(&Machine->drv->sound[totalsound]) != 0) goto getout; totalsound++; } #else /* forQUASI88 */ { if ((*sndintf[ fm_interface.sound_type ].start)(&fm_interface) != 0) goto getout; if ((*sndintf[ beep_interface.sound_type ].start)(&beep_interface) != 0) goto getout; } #endif /* forQUASI88 */ return 0; getout: /* TODO: should also free the resources allocated before */ return 1; }
bool load_state(char *game,int slot) { char *st_name; // char *st_name_len; char *gngeo_dir=DATA_DIRECTORY"/save/"; #ifdef WORDS_BIGENDIAN Uint8 my_endian=1; #else Uint8 my_endian=0; #endif int i; gzFile *gzf; char string[20]; Uint8 a,num; ST_DATA_TYPE type; void *data; Uint32 len; Uint8 endian; Uint32 rate; st_name=(char*)alloca(strlen(gngeo_dir)+strlen(game)+5); sprintf(st_name,"%s%s.%03d",gngeo_dir,game,slot); if ((gzf=gzopen(st_name,"rb"))==NULL) { printf("%s not found\n",st_name); return false; } memset(string,0,20); gzread(gzf,string,6); if (strcmp(string,"GNGST1")) { printf("%s is not a valid gngeo st file\n",st_name); gzclose(gzf); return false; } gzread(gzf,&endian,1); if (my_endian!=endian) { printf("This save state comme from a different endian architecture.\n" "This is not currently supported :(\n"); return false; } gzread(gzf,&rate,4); swap_buf32_if_need(endian,&rate,1); if (rate==0 && conf.sound) { /* disable sound */ conf.sound=0; SDL_PauseAudio(1); close_sdl_audio(); } else if (rate!=0 && conf.sound==0) { /* enable sound */ conf.sound=1; conf.sample_rate=rate; if (!conf.snd_st_reg_create) { cpu_z80_init(); init_sdl_audio(); streams_sh_start(); YM2610_sh_start(); conf.snd_st_reg_create=1; } else init_sdl_audio(); SDL_PauseAudio(0); } else if (rate!=conf.sample_rate && conf.sound) { conf.sample_rate=rate; close_sdl_audio(); init_sdl_audio(); } gzread(gzf,state_img->pixels,304*224*2); swap_buf16_if_need(endian,state_img->pixels,304*224); while(!gzeof(gzf)) { gzread(gzf,&a,1); /* name size */ memset(string,0,20); gzread(gzf,string,a); /* regname */ gzread(gzf,&num,1); /* regname num */ gzread(gzf,&a,1); /* module id */ gzread(gzf,&len,4); gzread(gzf,&type,1); data=find_data_by_name(a,num,string); if (data) { gzread(gzf,data,len); switch(type) { case REG_UINT16: case REG_INT16: swap_buf16_if_need(endian,data,len>>1); break; case REG_UINT32: case REG_INT32: swap_buf32_if_need(endian,data,len>>2); break; case REG_INT8: case REG_UINT8: /* nothing */ break; } } else { /* unknow reg, ignore it*/ printf("skeeping unknow reg %s\n",string); gzseek(gzf,len,SEEK_CUR); } // /*if (a==ST_68k)*/ printf("LO %02d %20s %02x %08x \n",a,string,num,len/*,*(Uint32*)data*/); }