/** * setSoundStereo(): Enable or disable stereo sound. * @param newSoundStereo New stereo sound enable setting. */ void Options::setSoundStereo(const bool newSoundStereo) { // TODO: Move most of this code to the Audio class. unsigned char Reg_1[0x200]; audio->setStereo(newSoundStereo); if (!audio->stereo()) MESSAGE_L("Mono sound", "Mono sound", 1000); else MESSAGE_L("Stereo sound", "Stereo sound", 1000); if (!audio->enabled()) { // Sound isn't enabled, so nothing needs to be changed. return; } // Save the current sound state. // TODO: Use full save instead of partial save? PSG_Save_State(); YM2612_Save(Reg_1); // Temporarily disable sound. audio->endSound(); audio->setEnabled(false); // Reinitialize the sound processors. if (CPU_Mode) { YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_PAL / 15, audio->soundRate()); } else { YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_NTSC / 15, audio->soundRate()); } if (SegaCD_Started) Set_Rate_PCM(audio->soundRate()); // Restore the sound state. YM2612_Restore(Reg_1); PSG_Restore_State(); // Attempt to re-enable sound. if (!audio->initSound()) return; // Sound enabled. audio->setEnabled(true); audio->playSound(); return; }
int device_start_c6280(UINT8 ChipID, int clock) { c6280_state* info; int rate; if (ChipID >= MAX_CHIPS) return 0; info = &C6280Data[ChipID]; switch(EMU_CORE) { #ifdef ENABLE_ALL_CORES case EC_MAME: rate = (clock & 0x7FFFFFFF)/16; if (((CHIP_SAMPLING_MODE & 0x01) && rate < CHIP_SAMPLE_RATE) || CHIP_SAMPLING_MODE == 0x02) rate = CHIP_SAMPLE_RATE; info->chip = device_start_c6280m(clock, rate); if (info->chip == NULL) return 0; break; #endif case EC_OOTAKE: rate = SampleRate; info->chip = PSG_Init(clock, rate); if (info->chip == NULL) return 0; break; } return rate; }
void Start_Play_GYM(int sampleRate) { Seg_Lenght = (int) ceil(sampleRate / 60.0); /* memset(Seg_L, 0, Seg_Lenght << 2); memset(Seg_R, 0, Seg_Lenght << 2);*/ YM2612_Init(CLOCK_NTSC / 7, sampleRate, YM2612_Improv); PSG_Init(CLOCK_NTSC / 15, sampleRate); }
int device_start_c6280(void **_info, int EMU_CORE, int clock, int SampleRate, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE) { c6280_state* info; int rate; #ifdef ENABLE_ALL_CORES if (EMU_CORE >= 0x02) EMU_CORE = EC_OOTAKE; #else EMU_CORE = EC_OOTAKE; #endif info = (c6280_state *) calloc(1, sizeof(c6280_state)); *_info = (void *) info; info->EMU_CORE = EMU_CORE; switch(EMU_CORE) { #ifdef ENABLE_ALL_CORES case EC_MAME: rate = (clock & 0x7FFFFFFF)/16; if (((CHIP_SAMPLING_MODE & 0x01) && rate < CHIP_SAMPLE_RATE) || CHIP_SAMPLING_MODE == 0x02) rate = CHIP_SAMPLE_RATE; info->chip = device_start_c6280m(clock, rate); if (info->chip == NULL) return 0; break; #endif case EC_OOTAKE: rate = SampleRate; info->chip = PSG_Init(clock, rate); if (info->chip == NULL) return 0; break; } return rate; }
/** * setSoundSampleRate(): Change the sample rate. * @param Rate Rate ID. (TODO: Make an enum containing the rate IDs.) */ void Options::setSoundSampleRate(const int newRate) { // Make sure the rate ID is valid. assert(newRate >= 0 && newRate <= 2); switch (newRate) { case 0: audio->setSoundRate(11025); break; case 1: audio->setSoundRate(22050); break; case 2: audio->setSoundRate(44100); break; } MESSAGE_NUM_L("Sound rate set to %d Hz", "Sound rate set to %d Hz", audio->soundRate(), 2500); // If sound isn't enabled, we're done. if (!audio->enabled()) return; // Sound's enabled. Reinitialize it. unsigned char Reg_1[0x200]; // Save the sound registers. // TODO: Use a full save instead of a partial save? PSG_Save_State(); YM2612_Save(Reg_1); // Stop sound. audio->endSound(); audio->setEnabled(false); // Reinitialize the sound processors. if (CPU_Mode) { YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_PAL / 15, audio->soundRate()); } else { YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_NTSC / 15, audio->soundRate()); } if (SegaCD_Started) Set_Rate_PCM(audio->soundRate()); // Restore the sound registers YM2612_Restore(Reg_1); PSG_Restore_State(); // Attempt to reinitialize sound. if (!audio->initSound()) return; // Sound is reinitialized. audio->setEnabled(true); audio->playSound(); return; }
/** * setCountry(): Set the current country code. * @param newCountry New country code. */ void Options::setCountry(const int newCountry) { unsigned char Reg_1[0x200]; Flag_Clr_Scr = 1; Country = newCountry; switch (Country) { default: case -1: // Auto-detect. if (Genesis_Started || _32X_Started) Detect_Country_Genesis(); else if (SegaCD_Started) Detect_Country_SegaCD(); break; case 0: // Japan (NTSC) Game_Mode = 0; CPU_Mode = 0; break; case 1: // USA (NTSC) Game_Mode = 1; CPU_Mode = 0; break; case 2: // Europe (PAL) Game_Mode = 1; CPU_Mode = 1; break; case 3: // Japan (PAL) Game_Mode = 0; CPU_Mode = 1; break; } // TODO: Combine this with gens.cpp:Set_Clock_Freq(). if (CPU_Mode) { CPL_Z80 = roundDouble((((double)CLOCK_PAL / 15.0) / 50.0) / 312.0); CPL_M68K = roundDouble((((double)CLOCK_PAL / 7.0) / 50.0) / 312.0); CPL_MSH2 = roundDouble(((((((double)CLOCK_PAL / 7.0) * 3.0) / 50.0) / 312.0) * (double)MSH2_Speed) / 100.0); CPL_SSH2 = roundDouble(((((((double)CLOCK_PAL / 7.0) * 3.0) / 50.0) / 312.0) * (double)SSH2_Speed) / 100.0); VDP_Num_Lines = 312; VDP_Status |= 0x0001; _32X_VDP.Mode &= ~0x8000; CD_Access_Timer = 2080; Timer_Step = 136752; } else { CPL_Z80 = roundDouble((((double)CLOCK_NTSC / 15.0) / 60.0) / 262.0); CPL_M68K = roundDouble((((double)CLOCK_NTSC / 7.0) / 60.0) / 262.0); CPL_MSH2 = roundDouble(((((((double)CLOCK_NTSC / 7.0) * 3.0) / 60.0) / 262.0) * (double)MSH2_Speed) / 100.0); CPL_SSH2 = roundDouble(((((((double) CLOCK_NTSC / 7.0) * 3.0) / 60.0) / 262.0) * (double)SSH2_Speed) / 100.0); VDP_Num_Lines = 262; VDP_Status &= 0xFFFE; _32X_VDP.Mode |= 0x8000; CD_Access_Timer = 2096; Timer_Step = 135708; } if (audio->enabled()) { PSG_Save_State(); YM2612_Save(Reg_1); audio->endSound(); audio->setEnabled(false); if (CPU_Mode) { YM2612_Init(CLOCK_PAL / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_PAL / 15, audio->soundRate()); } else { YM2612_Init(CLOCK_NTSC / 7, audio->soundRate(), YM2612_Improv); PSG_Init(CLOCK_NTSC / 15, audio->soundRate()); } if (SegaCD_Started) Set_Rate_PCM(audio->soundRate()); YM2612_Restore (Reg_1); PSG_Restore_State(); if (!audio->initSound()) return; audio->setEnabled(true); audio->playSound(); } if (Game_Mode) { if (CPU_Mode) MESSAGE_L("Europe system (50 FPS)", "Europe system (50 FPS)", 1500); else MESSAGE_L("USA system (60 FPS)", "USA system (60 FPS)", 1500); } else { if (CPU_Mode) MESSAGE_L("Japan system (50 FPS)", "Japan system (50 FPS)", 1500); else MESSAGE_L("Japan system (60 FPS)", "Japan system (60 FPS)", 1500); } setGameName(); return; }