- updated myself in the AUTHORS

- more commenting of code.

I hope to comment it all before I start really cleaning house so that I have a sense of how it all fits together.
This commit is contained in:
gimmedonutnow 2006-08-01 18:20:31 +00:00
parent 22dc101896
commit c4c3b82d00
3 changed files with 104 additions and 58 deletions

View File

@ -51,7 +51,8 @@ Windows driver maintenance
Lukas Sabota - punkrockguy318 at comcast.net Lukas Sabota - punkrockguy318 at comcast.net
Build system Build system
Soules - document thyself Soules - gimmedonutnow at gmail dot com
Linux SDL driver maintenance
Radsaq - document thyself Radsaq - document thyself

View File

@ -5,77 +5,122 @@ static uint64 tfreq;
static uint64 desiredfps; static uint64 desiredfps;
static int32 fps_scale_table[]= static int32 fps_scale_table[]=
{ 3, 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 2048 }; { 3, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 };
int32 fps_scale = 256; int32 fps_scale = 256;
#define fps_table_size (sizeof(fps_scale_table)/sizeof(fps_scale_table[0])) #define fps_table_size (sizeof(fps_scale_table) / sizeof(fps_scale_table[0]))
void RefreshThrottleFPS(void) /**
* Refreshes the FPS throttling variables.
*/
void
RefreshThrottleFPS()
{ {
desiredfps=FCEUI_GetDesiredFPS()>>8; desiredfps = FCEUI_GetDesiredFPS() >> 8;
desiredfps=(desiredfps*fps_scale)>>8; desiredfps = (desiredfps * fps_scale) >> 8;
tfreq=10000000; tfreq = 10000000;
tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ tfreq <<= 16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
} }
void SpeedThrottle(void) /**
* Perform FPS speed throttling by delaying until the next time slot.
*/
void
SpeedThrottle()
{ {
bool doDelay;
// XXX soules - go back through and get rid of static function variables
static uint64 ttime,ltime=0; static uint64 ttime,ltime=0;
waiter: // loop until we've delayed enough
do {
doDelay = false;
ttime=SDL_GetTicks(); // check the current time
ttime*=10000; ttime = SDL_GetTicks();
ttime *= 10000;
if( (ttime-ltime) < (tfreq/desiredfps) ) if((ttime - ltime) < (tfreq / desiredfps)) {
{ int64 delay = (tfreq / desiredfps) - (ttime - ltime);
int64 delay; if(delay > 0) {
delay=(tfreq/desiredfps)-(ttime-ltime); SDL_Delay(delay / 10000);
if(delay>0) }
SDL_Delay(delay/10000);
//printf("%d\n",(tfreq/desiredfps)-(ttime-ltime)); doDelay = true;
//SDL_Delay((tfreq/desiredfps)-(ttime-ltime)); }
goto waiter; } while(doDelay);
// update the "last time" to match when we want the next tick
if((ttime - ltime) >= ((tfreq * 4) / desiredfps)) {
ltime = ttime;
} else {
ltime += tfreq / desiredfps;
} }
if( (ttime-ltime) >= (tfreq*4/desiredfps))
ltime=ttime;
else
ltime+=tfreq/desiredfps;
} }
void IncreaseEmulationSpeed(void) /**
* Set the emulation speed throttling to the next entry in the speed table.
*/
void
IncreaseEmulationSpeed()
{ {
int i; int i = 0;
for(i=1; fps_scale_table[i]<fps_scale; i++)
; // find the next entry in the FPS rate table
while(i < (fps_table_size - 1) && fps_scale_table[i] < fps_scale) {
i++;
}
fps_scale = fps_scale_table[i+1]; fps_scale = fps_scale_table[i+1];
// refresh the FPS throttling variables
RefreshThrottleFPS(); RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8); FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
} }
void DecreaseEmulationSpeed(void) /**
* Set the emulation speed throttling to the previous entry in the speed table.
*/
void
DecreaseEmulationSpeed()
{ {
int i; int i = 1;
for(i=1; fps_scale_table[i]<fps_scale; i++)
;
fps_scale = fps_scale_table[i-1];
// find the previous entry in the FPS rate table
while(i < fps_table_size && fps_scale_table[i] < fps_scale) {
i++;
}
fps_scale = fps_scale_table[i - 1];
// refresh the FPS throttling variables
RefreshThrottleFPS(); RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8); FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
} }
void FCEUD_SetEmulationSpeed(int cmd) /**
* Set the emulation speed throttling to a specific value.
*/
void
FCEUD_SetEmulationSpeed(int cmd)
{ {
switch(cmd) switch(cmd) {
{ case EMUSPEED_SLOWEST:
case EMUSPEED_SLOWEST: fps_scale=fps_scale_table[0]; break; fps_scale = fps_scale_table[0];
case EMUSPEED_SLOWER: DecreaseEmulationSpeed(); break; break;
case EMUSPEED_NORMAL: fps_scale=256; break; case EMUSPEED_SLOWER:
case EMUSPEED_FASTER: IncreaseEmulationSpeed(); break; DecreaseEmulationSpeed();
case EMUSPEED_FASTEST: fps_scale=fps_scale_table[fps_table_size-1]; break; break;
case EMUSPEED_NORMAL:
fps_scale = 256;
break;
case EMUSPEED_FASTER:
IncreaseEmulationSpeed();
break;
case EMUSPEED_FASTEST:
fps_scale = fps_scale_table[fps_table_size - 1];
break;
default: default:
return; return;
} }

View File

@ -48,8 +48,8 @@ static int usingogl;
static double exs,eys; static double exs,eys;
static int eefx; static int eefx;
#define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0)) #define NWIDTH (256 - ((eoptions & EO_CLIPSIDES) ? 16 : 0))
#define NOFFSET (eoptions&EO_CLIPSIDES?8:0) #define NOFFSET (eoptions & EO_CLIPSIDES ? 8 : 0)
static int paletterefresh; static int paletterefresh;