Example #1
0
int RunIdle()
{
	int nTime=0,nCount=0;
	int i=0;

	if (bDSoundPlaying)
	{
		// Run with sound
		AudSoundCheck();
		return 0;
	}

	// Run without sound
	nTime=timeGetTime()-nNormalLast;
	nCount=(nTime*nAppVirtualFps - nNormalFrac) /10000;
	if (nCount<=0)
	{
		Sleep(2);    // No need to do anything for a bit
		return 0;
	}

	nNormalFrac+=nCount*10000;
	nNormalLast+=nNormalFrac/nAppVirtualFps;
	nNormalFrac%=nAppVirtualFps;

	if (bAppDoFast)
	{
		nCount*=nFastSpeed;    // temporary increase virtual fps
	}

	if (bRunPause)
	{
		if (bAppStep)
		{
			nCount=1;    // Step one frame
		}
		else
		{
			RunFrame(1,1); // paused
			return 0;
		}
	}
	bAppStep=0;

	for (i=0; i<nCount-1; i++)
	{
		// TODO: Something wrong with the frameskip code as it skips frames all the time for no reason
//		RunFrame(0,0);    // mid-frames  
	}
	RunFrame(1,0); // end-frame
	return 0;
}
Example #2
0
int RunIdle()
{
	int nTime, nCount;

	if (bAudPlaying) {
		// Run with sound
		AudSoundCheck();
		return 0;
	}

	// Run without sound
	nTime = SDL_GetTicks() - nNormalLast;
	nCount = (nTime * nAppVirtualFps - nNormalFrac) / 100000;
	if (nCount <= 0) {						// No need to do anything for a bit
		SDL_Delay(3);

		return 0;
	}

	nNormalFrac += nCount * 100000;
	nNormalLast += nNormalFrac / nAppVirtualFps;
	nNormalFrac %= nAppVirtualFps;

	if (bAppDoFast){						// Temporarily increase virtual fps
		nCount *= nFastSpeed;
	}
	if (nCount > 100) {						// Limit frame skipping
		nCount = 100;
	}
	if (bRunPause) {
		if (bAppDoStep) {					// Step one frame
			nCount = 10;
		} else {
			RunFrame(1, 1);					// Paused
			return 0;
		}
	}
	bAppDoStep = 0;

	for (int i = nCount / 10; i > 0; i--) {	// Mid-frames
		RunFrame(!bAlwaysDrawFrames, 0);
	}
	RunFrame(1, 0);							// End-frame
	// temp added for SDLFBA
	//VidPaint(0);
	return 0;
}
Example #3
0
int RunIdle()
{
	int nTime, nCount;

	if (bAudPlaying) {
		// Run with sound
		
		if(bRunFrame) {
			bRunFrame = false;
			if(bAlwaysDrawFrames) {
				RunFrame(1, 0);
			} else {
				RunGetNextSound(0);
			}
			return 0;
		} else {
			AudSoundCheck();
			return 0;
		}
	}

	// Run without sound
	nTime = timeGetTime() - nNormalLast;
	nCount = (nTime * nAppVirtualFps - nNormalFrac) / 100000;
	if (nCount <= 0) {						// No need to do anything for a bit
		//Sleep(2);
		return 0;
	}

	nNormalFrac += nCount * 100000;
	nNormalLast += nNormalFrac / nAppVirtualFps;
	nNormalFrac %= nAppVirtualFps;

	//if (bAppDoFast){						// Temporarily increase virtual fps
	//	nCount *= nFastSpeed;
	//}
	if (nCount > 100) {						// Limit frame skipping
		nCount = 100;
	}
	if (bRunPause) {
		if (bAppDoStep) {					// Step one frame
			nCount = 10;
		} else {
			RunFrame(1, 1);					// Paused
			return 0;
		}
	}
	bAppDoStep = 0;

	if (bAppDoFast) {									// do more frames
		for (int i = 0; i < nFastSpeed; i++) {
			RunFrame(0, 0);
		}
	}

	if(!bAlwaysDrawFrames) {
		for (int i = nCount / 10; i > 0; i--) {	// Mid-frames
			RunFrame(0, 0);
		}
	}
	RunFrame(1, 0);							// End-frame

	return 0;
}
Example #4
0
int RunIdle() {
	int nTime, nCount;
    float frame_limit = (float)nBurnFPS/100.0f, frametime = 100000.0f/(float)nBurnFPS;
    
	if (bAudPlaying) {
		// Run with sound
		AudSoundCheck();
		return 0;
	}
    
    
#if BENCH_MODE
    timer = SDL_GetTicks();
    if(timer-tick>1000 && cur_ifba_conf->show_fps) {
        sdl_fps = nFramesRendered;
        nFramesRendered = 0;
        tick = timer;
        //printf("fps:%d\n",sdl_fps);
    }
    now = timer;
    ticks=now-done;
    RunFrame(1,0);
#else
    if (!bAppDoFast) {  //Normal
        timer = SDL_GetTicks()/frametime;
        if(timer-tick>frame_limit && cur_ifba_conf->show_fps) {
            sdl_fps = nFramesRendered;
            nFramesRendered = 0;
            tick = timer;
            //printf("fps:%d\n",fps);
        }
        now = timer;
        ticks=now-done;
        
        if(ticks<1) { //TO FAST, Limit rendering speed
            usleep(100); //0.1ms
            return 0;
        }
        
        if (cur_ifba_conf->video_fskip==10) {//AUTO FSKIP        
            if(ticks>10) ticks=10;
            for (int i=0; i<ticks-1; i++) {
                RunFrame(0,0);	
            }
            RunFrame(1,0);
        } else {
            video_fskipcounter++;
            if (video_fskipcounter>cur_ifba_conf->video_fskip) {
                video_fskipcounter=0;
                RunFrame(1,0);
            } else RunFrame(0,0);
            
        }
    } else {  //TURBO
        for (int i=0;i<10;i++) RunFrame(0,0);
        timer = SDL_GetTicks()/frametime;
        sdl_fps = 0;
        nFramesRendered=0;
        tick = timer;
        now = timer;
        ticks=now-done;
        video_fskipcounter=0;
        RunFrame(1,0);
    }
#endif            
    
    done = now;
    
    return 0;
}