more stable threading, file IO corrections, inline video functions

This commit is contained in:
dborth 2009-05-06 06:33:57 +00:00
parent 0695e04b42
commit 911881421b
3 changed files with 54 additions and 46 deletions

View File

@ -481,7 +481,8 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
else
{
struct stat fileinfo;
fstat(file->_file, &fileinfo);
if(fstat(file->_file, &fileinfo) == 0)
{
size = fileinfo.st_size;
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
@ -508,6 +509,7 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
}
}
}
}
fclose (file);
}
}

View File

@ -57,6 +57,8 @@ extern "C" {
#include "gui/gui.h"
#include "menu.h"
#define THREAD_SLEEP 100
#ifdef HW_RVL
static GuiImageData * pointer[4];
#endif
@ -117,7 +119,7 @@ HaltGui()
// wait for thread to finish
while(!LWP_ThreadIsSuspended(guithread))
usleep(50);
usleep(THREAD_SLEEP);
}
/****************************************************************************
@ -212,7 +214,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
while(choice == -1)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
if(btn1.GetState() == STATE_CLICKED)
choice = 1;
@ -221,7 +223,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
}
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
while(promptWindow.GetEffect() > 0) usleep(50);
while(promptWindow.GetEffect() > 0) usleep(THREAD_SLEEP);
HaltGui();
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
@ -322,6 +324,7 @@ UpdateGUI (void *arg)
#endif
}
}
usleep(THREAD_SLEEP);
}
return NULL;
}
@ -411,7 +414,7 @@ ProgressWindow(char *title, char *msg)
while(showProgress)
{
VIDEO_WaitVSync();
usleep(20000);
if(showProgress == 1)
{
@ -444,6 +447,7 @@ static void * ProgressThread (void *arg)
LWP_SuspendThread (progressthread);
ProgressWindow(progressTitle, progressMsg);
usleep(THREAD_SLEEP);
}
return NULL;
}
@ -474,7 +478,7 @@ CancelAction()
// wait for thread to finish
while(!LWP_ThreadIsSuspended(progressthread))
usleep(50);
usleep(THREAD_SLEEP);
}
/****************************************************************************
@ -629,7 +633,7 @@ static void OnScreenKeyboard(char * var, u32 maxlen)
while(save == -1)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
if(okBtn.GetState() == STATE_CLICKED)
save = 1;
@ -722,7 +726,7 @@ SettingWindow(const char * title, GuiWindow * w)
while(save == -1)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
if(okBtn.GetState() == STATE_CLICKED)
save = 1;
@ -857,6 +861,7 @@ static void WindowCredits(void * ptr)
if(userInput[i].wpad.btns_d || userInput[i].pad.btns_d)
exit = true;
}
usleep(THREAD_SLEEP);
}
// clear buttons pressed
@ -971,7 +976,7 @@ static int MenuGameSelection()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
// update gameWindow based on arrow buttons
// set MENU_EXIT if A button pressed on a game
@ -1340,7 +1345,7 @@ static int MenuGame()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
#ifdef HW_RVL
int level;
@ -1629,7 +1634,7 @@ static int MenuGameSaves(int action)
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
ret = saveBrowser.GetClickedSave();
@ -1876,7 +1881,7 @@ static int MenuGameSettings()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
if(mappingBtn.GetState() == STATE_CLICKED)
{
@ -1990,7 +1995,7 @@ static int MenuGameCheats()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
for(i=0; i < Cheat.num_cheats; i++)
sprintf (options.value[i], "%s", Cheat.c[i].enabled == true ? "On" : "Off");
@ -2139,7 +2144,7 @@ static int MenuSettingsMappings()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
if(snesBtn.GetState() == STATE_CLICKED)
{
@ -2313,7 +2318,7 @@ static int MenuSettingsMappingsController()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
if(wiimoteBtn.GetState() == STATE_CLICKED)
{
@ -2413,7 +2418,7 @@ ButtonMappingWindow()
while(pressed == 0)
{
VIDEO_WaitVSync();
usleep(THREAD_SLEEP);
if(mapMenuCtrl == CTRLR_GCPAD)
{
@ -2572,7 +2577,7 @@ static int MenuSettingsMappingsMap()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
for(i=0; i < options.length; i++)
{
@ -2878,7 +2883,7 @@ static int MenuSettingsVideo()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
// don't allow original render mode if progressive video mode detected
if (GCSettings.render==0 && progressive)
@ -3092,7 +3097,7 @@ static int MenuSettings()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
if(savingBtn.GetState() == STATE_CLICKED)
{
@ -3197,7 +3202,7 @@ static int MenuSettingsFile()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
// some load/save methods are not implemented - here's where we skip them
// they need to be skipped in the order they were enumerated in snes9xGX.h
@ -3378,7 +3383,7 @@ static int MenuSettingsMenu()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
#ifdef HW_RVL
if (GCSettings.ExitAction == 1)
@ -3512,7 +3517,7 @@ static int MenuSettingsNetwork()
while(menu == MENU_NONE)
{
VIDEO_WaitVSync ();
usleep(THREAD_SLEEP);
strncpy (options.value[0], GCSettings.smbip, 15);
strncpy (options.value[1], GCSettings.smbshare, 19);
@ -3689,6 +3694,7 @@ MainMenu (int menu)
break;
}
lastMenu = currentMenu;
usleep(THREAD_SLEEP);
}
#ifdef HW_RVL

View File

@ -313,7 +313,7 @@ InitVideoThread ()
* Stock code to copy the GX buffer to the current display mode.
* Also increments the frameticker, as it's called for each vb.
***************************************************************************/
static void
static inline void
copy_to_xfb (u32 arg)
{
if (copynow == GX_TRUE)
@ -329,7 +329,7 @@ copy_to_xfb (u32 arg)
/****************************************************************************
* Scaler Support Functions
***************************************************************************/
static void
static inline void
draw_init ()
{
GX_ClearVtxDesc ();
@ -358,7 +358,7 @@ draw_init ()
GX_InvVtxCache (); // update vertex cache
}
static void
static inline void
draw_vert (u8 pos, u8 c, f32 s, f32 t)
{
GX_Position1x8 (pos);
@ -366,7 +366,7 @@ draw_vert (u8 pos, u8 c, f32 s, f32 t)
GX_TexCoord2f32 (s, t);
}
static void
static inline void
draw_square (Mtx v)
{
Mtx m; // model matrix.
@ -460,7 +460,7 @@ UpdatePadsCB ()
*
* - modified for a buffer with an offset (border)
****************************************************************************/
static void
static inline void
MakeTexture (const void *src, void *dst, s32 width, s32 height)
{
register u32 tmp0 = 0, tmp1 = 0, tmp2 = 0, tmp3 = 0;