int sound_init(void) { if(sound_lowlevel_init(NULL, &sound_freq,&sound_stereo)) { /* XXX a bit vague, maybe I should put this check in sound_init() */ //fprintf(stderr,"z81: warning: " // "couldn't initialise sound device, sound disabled.\n"); return(1); } /* important to override this if not using stereo */ if(!sound_stereo) sound_stereo_acb=0; sound_enabled=1; sound_framesiz=sound_freq/50; if((sound_buf=malloc(sound_framesiz*(sound_stereo+1)))==NULL) { sound_lowlevel_end(); return(1); } sound_oldval=sound_oldval_orig=128; sound_oldpos=-1; sound_fillpos=0; sound_ptr=sound_buf; beeper_tick=0; beeper_tick_incr=(1<<24)/sound_freq; //if(sound_ay) sound_ay_init(); return(0); }
void AY8910_InitAll(int nClock, unsigned long nSampleRate) { for (unsigned int i=0; i<MAX_8910; i++) { sound_init(&g_AY8910[i], NULL, nSampleRate); // Inits mainly static members (except ay_tick_incr) sound_ay_init(&g_AY8910[i]); } }
/* no need to call this initially, but should be called * on reset otherwise. */ void sound_ay_reset( CAY8910 *_this ) { int f; /* recalculate timings based on new machines ay clock */ sound_ay_init(_this); _this->ay_change_count = 0; for( f = 0; f < 16; f++ ) sound_ay_write( _this, f, 0, 0 ); for( f = 0; f < 3; f++ ) _this->ay_tone_high[f] = 0; _this->ay_tone_subcycles = _this->ay_env_subcycles = 0; }
/* no need to call this initially, but should be called * on reset otherwise. */ void sound_ay_reset( void ) { int f; /* recalculate timings based on new machines ay clock */ sound_ay_init(); ay_change_count = 0; for( f = 0; f < 16; f++ ) sound_ay_write( f, 0, 0 ); for( f = 0; f < 3; f++ ) ay_tone_high[f] = 0; ay_tone_cycles = ay_env_cycles = 0; }
static int internal_init( CONFIG* cfg ) { /* From HW_.cpp */ zx81.machine = cfg->machine; switch ( zx81.machine ) { case MACHINEZX80: strcpy( machine.CurRom, zx81.ROM80 ); break; case MACHINEZX81: strcpy( machine.CurRom, zx81.ROM81 ); break; case MACHINEACE: strcpy( machine.CurRom, zx81.ROMACE ); break; case MACHINETS1500: strcpy( machine.CurRom, zx81.ROMTS1500 ); break; case MACHINELAMBDA: strcpy( machine.CurRom, zx81.ROMLAMBDA ); break; case MACHINEZX97LE: strcpy( machine.CurRom, zx81.ROM97LE ); break; case MACHINETS1000: zx81.machine = MACHINEZX81; strcpy( zx81.ROM81, "zx81.rom" ); strcpy( machine.CurRom, zx81.ROM81 ); break; case MACHINER470: zx81.machine = MACHINEZX81; strcpy( zx81.ROM81, "ringo470.rom" ); strcpy( machine.CurRom, zx81.ROM81 ); break; case MACHINETK85: zx81.machine = MACHINEZX81; strcpy( zx81.ROM81, "tk85.rom" ); strcpy( machine.CurRom, zx81.ROM81 ); break; } if ( cfg->LambdaColour ) { if ( zx81.machine == MACHINEACE ) { zx81.colour = COLOURACE; } else { zx81.colour = COLOURLAMBDA; } } else { zx81.colour = COLOURDISABLED; } zx81.shadowROM = cfg->LowRAMContents == LOWRAM_ROMSHADOW; zx81.RAM816k = cfg->LowRAMContents == LOWRAM_8KRAM || cfg->HiRes == HIRESG007; zx81.protectROM = cfg->ProtectROM; zx81.chrgen = cfg->LowRAMContents == LOWRAM_DK ? CHRGENDK : cfg->ChrGen; zx81.zxprinter = cfg->ZXPrinter; zx81.extfont = 0; if ( zx81.chrgen == CHRGENDK || zx81.chrgen == CHRGENCHR16 ) { zx81.maxireg = 64; } else { zx81.maxireg = 32; } if ( zx81.chrgen == CHRGENLAMBDA ) { zx81.extfont = 1; } zx81.NTSC = cfg->NTSC; if ( zx81.NTSC ) { AnimTimer1_Interval = 16; } else { AnimTimer1_Interval = 19; } if ( cfg->RamPack == RAMPACK96 ) { zx81.RAMTOP = 65535; zx81.ace96k = 1; } else { zx81.RAMTOP = ( 1 << ( cfg->RamPack + 10 ) ) + 16383; if ( cfg->RamPack == RAMPACK32 ) { zx81.RAMTOP = 65535; } if ( zx81.machine == MACHINEACE && cfg->RamPack == RAMPACKNONE ) { zx81.RAMTOP = 16383; } zx81.ace96k = 0; } zx81.truehires = cfg->HiRes; zx81.aytype = cfg->SoundCard; zx81.aysound = cfg->SoundCard != AY_TYPE_DISABLED; zx81.m1not = cfg->M1Not ? 49152 : 32768; zx81.Chroma81 = cfg->Chroma81; if ( zx81.machine == MACHINEZX97LE ) { zx81.RAMTOP = 65535; zx81.m1not = 49152; } zx81.ts2050 = cfg->TS2050; machine.clockspeed = 3250000; machine.tperscanline = 207; machine.scanlines = zx81.NTSC ? 262 : 312; machine.tperframe = machine.tperscanline * machine.scanlines; if ( zx81.machine == MACHINELAMBDA ) { machine.tperscanline = 208; } switch( zx81.machine ) { case MACHINEACE: machine.initialise = ace_initialise; machine.do_scanline = ace_do_scanline; machine.writebyte = ace_writebyte; machine.readbyte = ace_readbyte; machine.opcode_fetch = ace_opcode_fetch; machine.readport = ace_readport; machine.writeport = ace_writeport; machine.contendmem = ace_contend; machine.contendio = ace_contend; machine.reset = NULL; machine.nmi = NULL; machine.exit = NULL; break; default: machine.initialise = zx81_initialise; machine.do_scanline = zx81_do_scanline; machine.writebyte = zx81_writebyte; machine.readbyte = zx81_readbyte; machine.opcode_fetch = zx81_opcode_fetch; machine.readport = zx81_readport; machine.writeport = zx81_writeport; machine.contendmem = zx81_contend; machine.contendio = zx81_contend; machine.reset = NULL; machine.nmi = NULL; machine.exit = NULL; break; } /* From Artifacts_.cpp */ zx81.dirtydisplay= cfg->Artifacts; zx81.simpleghost = cfg->SimpleGhosting; tv.AdvancedEffects = cfg->AdvancedEffects; tv.DotCrawl = cfg->DotCrawl; tv.Interlaced = cfg->Interlaced; /* From HW_.cpp */ AccurateInit( cfg, false ); zx81.speedup = 0; //Speed->Recalc( NULL ); PCKbInit(); PCKeySetCursor( '5', '7', '6', '8', 0 ); if ( ResetRequired ) { machine.initialise(); } sound_ay_init(); zx81.vsyncsound = zx81.machine == MACHINEACE || zx81.machine == MACHINELAMBDA; return 0; }
void sound_init(int cpc_type, int cycles_per_frame) { int f; ////////////// // fpp=fopen("/mnt/sd/sound.bin","wb"); // fpp=fopen("/mnt/sd/sound3.txt","w"); // fprintf(fpp,"%s\n","INICIO"); ///////////// if(cycles_per_frame!=-1) tsmax=cycles_per_frame; //printf("en sound init freq %d speed %d\n",mconfig.sound_freq,mconfig.speed_mode); sound_freq=(mconfig.sound_freq * 100)/ mconfig.speed_mode; //printf("en sound init calculado %d\n",sound_freq); int gain = 1; if(mconfig.sound_gain==0) gain=6; else if(mconfig.sound_gain==1) gain=2; ampl_beeper = (40 * 256) / gain; ampl_tape = (2 * 256); ampl_ay_tone = (28 * 256) / gain ; vol_beeper = (ampl_beeper * 2) / gain; sound_stereo_ay= mconfig.sound_mode==3 || mconfig.sound_mode==4; sound_stereo_beeper= mconfig.sound_mode==2 || mconfig.sound_mode==4; /* only try for stereo if we need it */ sound_stereo= sound_stereo_ay || sound_stereo_beeper; /* important to override these settings if not using stereo * (it would probably be confusing to mess with the stereo * settings in settings_current though, which is why we make copies * rather than using the real ones). */ if(!sound_stereo) { sound_stereo_ay=0; sound_stereo_beeper=0; } sound_channels=(sound_stereo?2:1); sound_framesiz=sound_freq/50; sound_ay_init(); ay_is_in_use=0; if(sound_buf==NULL) sound_buf=(signed short *)malloc(sizeof(signed short)*sound_freq*2*sound_channels); memset(sound_buf,0,sizeof(signed short)*sound_framesiz*sound_channels); //printf("--> tam buf en sound %d ",(sizeof(signed short)*sound_framesiz*sound_channels)); if(tape_buf==NULL) tape_buf=(signed short *)malloc(sizeof(signed short)*sound_freq*2*sound_channels); //rly: *2 'cos I feel i need more room :) // Seleuco Thks rly It seems OK for the extra room needed for the speed emulation mode :) memset(tape_buf,0,sizeof(signed short)*sound_framesiz *2); //rly: *2 'cos I feel i need more room :) /* if we're resuming, we need to be careful about what * gets reset. The minimum we can do is the beeper * buffer positions, so that's here. */ sound_oldpos[0]=sound_oldpos[1]=-1; sound_fillpos[0]=sound_fillpos[1]=0; /* this stuff should only happen on the initial call. * (We currently assume the new sample rate will be the * same as the previous one, hence no need to recalculate * things dependent on that.) */ if(first_init) { first_init=0; for(f=0;f<2;f++) sound_oldval[f]=sound_oldval_orig[f]=0; } if(sound_stereo_beeper) { for(f=0;f<STEREO_BUF_SIZE;f++) pstereobuf[f]=0; pstereopos=0; pstereobufsiz=(sound_freq*psgap)/22000; } if(sound_stereo_ay) { int pos=(sound_stereo_ay_narrow?3:6)*sound_freq/8000; for(f=0;f<STEREO_BUF_SIZE;f++) rstereobuf_l[f]=rstereobuf_r[f]=0; rstereopos=0; /* the actual ACB/ABC bit :-) */ rchan1pos=-pos; if(sound_stereo_ay_abc) rchan2pos=0, rchan3pos=pos; else rchan2pos=pos,rchan3pos=0; } sound_enabled_ever=1; sound_enabled = !(mconfig.sound_mode==0); //fuse_sound_in_use=1; }