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
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
ShowProgress ((char *)"Loading...", 2048, size);
u32 offset = 2048;
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
***************************************************************************/
void ShowProgress(char *msg, int done, int total)
void
ShowProgress (char *msg, int done, int total)
{
if(total <= 0) // division by 0 is bad!
return;
else if(done > total) // this shouldn't happen
done = total;
int ypos = (screenheight - 30) >> 1;
if (screenheight == 480)
ypos += 52;
else
ypos += 32;
int xpos;
int xpos, ypos;
int i;
clearscreen();
DrawText(-1, ypos, msg);
if(done < 5000) // we just started!
{
ypos = (screenheight - 30) >> 1;
/*** Draw a white outline box ***/
for (i = 380; i < 401; i++)
DrawLine(100, i, 540, i, 0xff, 0xff, 0xff);
if (screenheight == 480)
ypos += 52;
else
ypos += 32;
clearscreen ();
setfontsize(20);
DrawText (-1, ypos, msg);
/*** Draw a white outline box ***/
for (i = 380; i < 401; i++)
DrawLine (100, i, 540, i, 0xff, 0xff, 0xff);
}
/*** Show progess ***/
xpos = (int) (((float) done / (float) total) * 438);
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 ();
}
}
/****************************************************************************