fix bug w/ reading files < 2048 bytes

This commit is contained in:
dborth 2009-01-02 22:32:16 +00:00
parent 03e69b1974
commit 2a40be8d1b
4 changed files with 25 additions and 26 deletions

View File

@ -62,7 +62,7 @@ Tantric. The project is currently being maintained by michniewski and Tantric.
* added: Added console/remote power button support (Wii only)
* added: Added reset button support - resets game (Wii only)
* changed: Settings file is now named settings.xml and is stored in the same
folder as the DOL - eg: apps/vbagx/settings.xml (Wii only)
folder as the DOL - eg: apps/Snes9xGX/settings.xml (Wii only)
* fixed: swc, sfc file support
* fixed: inverted sound channels
* fixed: some game crashes

View File

@ -443,13 +443,12 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
fstat(file->_file, &fileinfo);
size = fileinfo.st_size;
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
ShowProgress ("Loading...", 2048, length);
u32 offset = 2048;
u32 offset = readsize;
while(offset < size)
{
ShowProgress ("Loading...", offset, size);
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
if(readsize <= 0 || readsize > (1024*512))
@ -457,7 +456,6 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
if(readsize > 0)
offset += readsize;
ShowProgress ("Loading...", offset, length);
}
if(offset != size) // # bytes read doesn't match # expected

View File

@ -936,6 +936,8 @@ ShowProgress (const char *msg, int done, int total)
return;
else if(done > total) // this shouldn't happen
done = total;
else if(total < (256*1024)) // don't bother showing progress for small files
return;
int xpos, ypos;
int i;

View File

@ -517,41 +517,40 @@ InitGCVideo ()
}
#endif
VIDEO_Configure (vmode);
screenheight = vmode->xfbHeight;
VIDEO_Configure (vmode);
screenheight = vmode->xfbHeight;
// Allocate the video buffers
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
// A console is always useful while debugging.
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
// A console is always useful while debugging
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
// Clear framebuffers etc.
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer (xfb[0]);
// Clear framebuffers etc.
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
VIDEO_SetNextFramebuffer (xfb[0]);
// video callbacks
VIDEO_SetPostRetraceCallback ((VIRetraceCallback)UpdatePadsCB);
VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb);
VIDEO_SetPreRetraceCallback ((VIRetraceCallback)copy_to_xfb);
VIDEO_SetBlack (FALSE);
VIDEO_Flush ();
VIDEO_WaitVSync ();
if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_SetBlack (FALSE);
VIDEO_Flush ();
VIDEO_WaitVSync ();
if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync ();
copynow = GX_FALSE;
StartGX ();
copynow = GX_FALSE;
StartGX ();
draw_init ();
InitVideoThread ();
InitVideoThread ();
// Finally, the video is up and ready for use :)
// Finally, the video is up and ready for use :)
}
/****************************************************************************