fix performance for progress bar

This commit is contained in:
dborth 2008-10-15 07:04:46 +00:00
parent e222775a1a
commit 2f85a83ef9
2 changed files with 26 additions and 16 deletions

View File

@ -206,6 +206,8 @@ LoadFATFile (char * rbuffer, int length)
fseek(fatfile, 2048, SEEK_SET); // seek back to point where we left off fseek(fatfile, 2048, SEEK_SET); // seek back to point where we left off
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
ShowProgress ((char *)"Loading...", 2048, size);
u32 offset = 2048; u32 offset = 2048;
while(offset < size) while(offset < size)
{ {

View File

@ -920,37 +920,45 @@ DrawLine (int x1, int y1, int x2, int y2, u8 r, u8 g, u8 b)
* *
* Show the user what's happening * Show the user what's happening
***************************************************************************/ ***************************************************************************/
void ShowProgress(char *msg, int done, int total) void
ShowProgress (char *msg, int done, int total)
{ {
if(total <= 0) // division by 0 is bad! if(total <= 0) // division by 0 is bad!
return; return;
else if(done > total) // this shouldn't happen else if(done > total) // this shouldn't happen
done = total; done = total;
int ypos = (screenheight - 30) >> 1; int xpos, ypos;
int i;
if(done < 5000) // we just started!
{
ypos = (screenheight - 30) >> 1;
if (screenheight == 480) if (screenheight == 480)
ypos += 52; ypos += 52;
else else
ypos += 32; ypos += 32;
int xpos; clearscreen ();
int i; setfontsize(20);
DrawText (-1, ypos, msg);
clearscreen();
DrawText(-1, ypos, msg);
/*** Draw a white outline box ***/ /*** Draw a white outline box ***/
for (i = 380; i < 401; i++) for (i = 380; i < 401; i++)
DrawLine(100, i, 540, i, 0xff, 0xff, 0xff); DrawLine (100, i, 540, i, 0xff, 0xff, 0xff);
}
/*** Show progess ***/ /*** Show progess ***/
xpos = (int) (((float) done / (float) total) * 438); xpos = (int) (((float) done / (float) total) * 438);
for (i = 381; i < 400; i++) for (i = 381; i < 400; i++)
DrawLine(101, i, 101 + xpos, i, 0x00, 0x00, 0x80); DrawLine (101, i, 101 + xpos, i, 0x00, 0x00, 0x80);
showscreen(); if(done < 5000) // we just started!
{
showscreen ();
}
} }
/**************************************************************************** /****************************************************************************