s32 sal_Init(void) { if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return SAL_ERROR; } sal_TimerInit(60); memset(mInputRepeatTimer,0,sizeof(mInputRepeatTimer)); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); return SAL_OK; }
static int Run(int sound) { int skip=0, done=0, doneLast=0,aim=0,i; Settings.NextAPUEnabled = Settings.APUEnabled = sound; sal_TimerInit(Settings.FrameTime); done=sal_TimerRead()-1; if (sound) { /* Settings.SoundPlaybackRate = mMenuOptions.soundRate; Settings.Stereo = mMenuOptions.stereo ? TRUE : FALSE; */ Settings.SixteenBitSound=true; sal_AudioInit(mMenuOptions.soundRate, 16, mMenuOptions.stereo, Memory.ROMFramesPerSecond); S9xInitSound (mMenuOptions.soundRate, mMenuOptions.stereo, sal_AudioGetBufferSize()); S9xSetPlaybackRate(mMenuOptions.soundRate); S9xSetSoundMute (FALSE); } else { S9xSetSoundMute (TRUE); } while(!mEnterMenu) { for (i=0;i<10;i++) { aim=sal_TimerRead(); if (done < aim) { done++; if (mMenuOptions.frameSkip == 0) //Auto IPPU.RenderThisFrame = (done >= aim); else if (IPPU.RenderThisFrame = (--skip <= 0)) skip = mMenuOptions.frameSkip; //Run SNES for one glorious frame S9xMainLoop (); if (sound) { S9xMixSamples((uint8 *) sal_GetCurrentAudioBuffer(), sal_AudioGetSampleCount()); sal_SubmitSamples(); } // HandleQuickStateRequests(); } if (done>=aim) break; // Up to date now if (mEnterMenu) break; } done=aim; // Make sure up to date HandleQuickStateRequests(); } if (sound) sal_AudioClose(); mEnterMenu=0; return mEnterMenu; }