- 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
Build system
Soules - document thyself
Soules - gimmedonutnow at gmail dot com
Linux SDL driver maintenance
Radsaq - document thyself
@ -65,4 +66,4 @@ Andrea Mazzoleni
Scale2x/Scale3x scalers
Gilles Vollant
unzip.c PKZIP fileio
unzip.c PKZIP fileio

View File

@ -5,82 +5,127 @@ static uint64 tfreq;
static uint64 desiredfps;
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;
#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=(desiredfps*fps_scale)>>8;
tfreq=10000000;
tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */
desiredfps = FCEUI_GetDesiredFPS() >> 8;
desiredfps = (desiredfps * fps_scale) >> 8;
tfreq = 10000000;
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()
{
static uint64 ttime,ltime=0;
bool doDelay;
// XXX soules - go back through and get rid of static function variables
static uint64 ttime,ltime=0;
waiter:
ttime=SDL_GetTicks();
ttime*=10000;
// loop until we've delayed enough
do {
doDelay = false;
if( (ttime-ltime) < (tfreq/desiredfps) )
{
int64 delay;
delay=(tfreq/desiredfps)-(ttime-ltime);
if(delay>0)
SDL_Delay(delay/10000);
//printf("%d\n",(tfreq/desiredfps)-(ttime-ltime));
//SDL_Delay((tfreq/desiredfps)-(ttime-ltime));
goto waiter;
}
if( (ttime-ltime) >= (tfreq*4/desiredfps))
ltime=ttime;
else
ltime+=tfreq/desiredfps;
// check the current time
ttime = SDL_GetTicks();
ttime *= 10000;
if((ttime - ltime) < (tfreq / desiredfps)) {
int64 delay = (tfreq / desiredfps) - (ttime - ltime);
if(delay > 0) {
SDL_Delay(delay / 10000);
}
doDelay = true;
}
} 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;
}
}
void IncreaseEmulationSpeed(void)
/**
* Set the emulation speed throttling to the next entry in the speed table.
*/
void
IncreaseEmulationSpeed()
{
int i;
for(i=1; fps_scale_table[i]<fps_scale; i++)
;
fps_scale = fps_scale_table[i+1];
int i = 0;
RefreshThrottleFPS();
// 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];
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
// refresh the FPS throttling variables
RefreshThrottleFPS();
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;
for(i=1; fps_scale_table[i]<fps_scale; i++)
;
fps_scale = fps_scale_table[i-1];
int i = 1;
RefreshThrottleFPS();
// 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];
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
// refresh the FPS throttling variables
RefreshThrottleFPS();
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)
{
case EMUSPEED_SLOWEST: fps_scale=fps_scale_table[0]; break;
case EMUSPEED_SLOWER: DecreaseEmulationSpeed(); 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:
return;
}
switch(cmd) {
case EMUSPEED_SLOWEST:
fps_scale = fps_scale_table[0];
break;
case EMUSPEED_SLOWER:
DecreaseEmulationSpeed();
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:
return;
}
RefreshThrottleFPS();
RefreshThrottleFPS();
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
FCEU_DispMessage("emulation speed %d%%",(fps_scale*100)>>8);
}

View File

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