Patch #4870 from Fredrik Öhrn - Call yield() less often (gives a 3-4fps speed increase on H300) plus some minor code reorganisation

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9140 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2006-03-20 23:01:28 +00:00
parent 7e7423373e
commit 1a0e885ba0

View file

@ -40,8 +40,6 @@ extern char iend[];
struct plugin_api* rb;
static unsigned long frame_counter = 0;
struct pacman_settings {
int difficulty;
int numlives;
@ -272,14 +270,16 @@ static int gameProc( void )
char str[80];
int status;
long end_time;
int frame_counter = 0;
int yield_counter = 0;
while (1)
{
/* Run the machine for one frame (1/60th second) */
run();
frame_counter++;
rb->yield();
/* Check the button status */
status = rb->button_status();
@ -321,13 +321,21 @@ static int gameProc( void )
/* We only update the screen every third frame - Pacman's native
framerate is 60fps, so we are attempting to display 20fps */
if( (frame_counter % (60/FPS)) == 0) {
if (frame_counter == 60 / FPS) {
frame_counter = 0;
video_frames++;
/* The following functions render the Pacman screen from the contents
of the video and color ram. We first update the background, and
then draw the Sprites on top.
yield_counter ++;
if (yield_counter == FPS) {
yield_counter = 0;
rb->yield ();
}
/* The following functions render the Pacman screen from the
contents of the video and color ram. We first update the
background, and then draw the Sprites on top.
*/
renderBackground( video_buffer );
@ -337,8 +345,8 @@ static int gameProc( void )
if (settings.showfps) {
fps = (video_frames*HZ*100) / (*rb->current_tick-start_time);
rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ",fps/100,fps%100,
FPS);
rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ",
fps/100,fps%100,FPS);
rb->lcd_putsxy(0,0,str);
}
@ -350,14 +358,13 @@ static int gameProc( void )
rb->sleep(1);
}
}
}
return 0;
}
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
(void)parameter;
int status;
#ifdef USE_IRAM
void* audiobuf;
int audiosize;
@ -414,9 +421,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* Load the romset */
if (loadROMS()) {
start_time = *rb->current_tick-1;
do {
status = gameProc();
} while (!status);
gameProc();
/* Save the user settings if they have changed */
if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) {