mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-10 05:35:20 -05:00
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:
parent
7e7423373e
commit
1a0e885ba0
1 changed files with 67 additions and 61 deletions
|
|
@ -40,8 +40,6 @@ extern char iend[];
|
||||||
|
|
||||||
struct plugin_api* rb;
|
struct plugin_api* rb;
|
||||||
|
|
||||||
static unsigned long frame_counter = 0;
|
|
||||||
|
|
||||||
struct pacman_settings {
|
struct pacman_settings {
|
||||||
int difficulty;
|
int difficulty;
|
||||||
int numlives;
|
int numlives;
|
||||||
|
|
@ -272,14 +270,16 @@ static int gameProc( void )
|
||||||
char str[80];
|
char str[80];
|
||||||
int status;
|
int status;
|
||||||
long end_time;
|
long end_time;
|
||||||
|
int frame_counter = 0;
|
||||||
|
int yield_counter = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
/* Run the machine for one frame (1/60th second) */
|
/* Run the machine for one frame (1/60th second) */
|
||||||
run();
|
run();
|
||||||
|
|
||||||
frame_counter++;
|
frame_counter++;
|
||||||
|
|
||||||
rb->yield();
|
|
||||||
|
|
||||||
/* Check the button status */
|
/* Check the button status */
|
||||||
status = rb->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
|
/* We only update the screen every third frame - Pacman's native
|
||||||
framerate is 60fps, so we are attempting to display 20fps */
|
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++;
|
video_frames++;
|
||||||
|
|
||||||
/* The following functions render the Pacman screen from the contents
|
yield_counter ++;
|
||||||
of the video and color ram. We first update the background, and
|
|
||||||
then draw the Sprites on top.
|
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 );
|
renderBackground( video_buffer );
|
||||||
|
|
@ -337,8 +345,8 @@ static int gameProc( void )
|
||||||
|
|
||||||
if (settings.showfps) {
|
if (settings.showfps) {
|
||||||
fps = (video_frames*HZ*100) / (*rb->current_tick-start_time);
|
fps = (video_frames*HZ*100) / (*rb->current_tick-start_time);
|
||||||
rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ",fps/100,fps%100,
|
rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ",
|
||||||
FPS);
|
fps/100,fps%100,FPS);
|
||||||
rb->lcd_putsxy(0,0,str);
|
rb->lcd_putsxy(0,0,str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -350,14 +358,13 @@ static int gameProc( void )
|
||||||
rb->sleep(1);
|
rb->sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
(void)parameter;
|
(void)parameter;
|
||||||
int status;
|
|
||||||
#ifdef USE_IRAM
|
#ifdef USE_IRAM
|
||||||
void* audiobuf;
|
void* audiobuf;
|
||||||
int audiosize;
|
int audiosize;
|
||||||
|
|
@ -414,9 +421,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
/* Load the romset */
|
/* Load the romset */
|
||||||
if (loadROMS()) {
|
if (loadROMS()) {
|
||||||
start_time = *rb->current_tick-1;
|
start_time = *rb->current_tick-1;
|
||||||
do {
|
|
||||||
status = gameProc();
|
gameProc();
|
||||||
} while (!status);
|
|
||||||
|
|
||||||
/* Save the user settings if they have changed */
|
/* Save the user settings if they have changed */
|
||||||
if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) {
|
if (rb->memcmp(&settings,&old_settings,sizeof(settings))!=0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue