documenting, fixing update feature

This commit is contained in:
dborth 2009-04-01 05:47:01 +00:00
parent e5b85d62a6
commit b5cbaedfe9
5 changed files with 116 additions and 30 deletions

View File

@ -91,7 +91,7 @@ GCMixSamples ()
void void
InitAudio () InitAudio ()
{ {
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 150); LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 100);
} }
/**************************************************************************** /****************************************************************************

View File

@ -13,11 +13,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <network.h> #include <network.h>
#include <ogc/lwp_watchdog.h> #include <ogc/lwp_watchdog.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <fcntl.h> #include <fcntl.h>
@ -25,7 +23,6 @@
#include "menu.h" #include "menu.h"
#include "http.h" #include "http.h"
static s32 tcp_socket(void) static s32 tcp_socket(void)
{ {
s32 s, res; s32 s, res;

View File

@ -73,8 +73,11 @@ static int mapMenuCtrl = 0;
static int mapMenuCtrlSNES = 0; static int mapMenuCtrlSNES = 0;
static lwp_t guithread = LWP_THREAD_NULL; static lwp_t guithread = LWP_THREAD_NULL;
static bool guiHalt = true;
static lwp_t progressthread = LWP_THREAD_NULL; static lwp_t progressthread = LWP_THREAD_NULL;
#ifdef HW_RVL
static lwp_t updatethread = LWP_THREAD_NULL;
#endif
static bool guiHalt = true;
static int showProgress = 0; static int showProgress = 0;
static char progressTitle[100]; static char progressTitle[100];
@ -82,6 +85,13 @@ static char progressMsg[200];
static int progressDone = 0; static int progressDone = 0;
static int progressTotal = 0; static int progressTotal = 0;
/****************************************************************************
* ResumeGui
*
* Signals the GUI thread to start, and resumes the thread. This is called
* after finishing the removal/insertion of new elements, and after initial
* GUI setup.
***************************************************************************/
static void static void
ResumeGui() ResumeGui()
{ {
@ -89,6 +99,14 @@ ResumeGui()
LWP_ResumeThread (guithread); LWP_ResumeThread (guithread);
} }
/****************************************************************************
* HaltGui
*
* Signals the GUI thread to stop, and waits for GUI thread to stop
* This is necessary whenever removing/inserting new elements into the GUI.
* This eliminates the possibility that the GUI is in the middle of accessing
* an element that is being changed.
***************************************************************************/
static void static void
HaltGui() HaltGui()
{ {
@ -101,8 +119,10 @@ HaltGui()
/**************************************************************************** /****************************************************************************
* WindowPrompt * WindowPrompt
*
* Displays a prompt window to user, with information, an error message, or
* presenting a user with a choice
***************************************************************************/ ***************************************************************************/
int int
WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label) WindowPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label)
{ {
@ -203,8 +223,32 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
return choice; return choice;
} }
#ifdef HW_RVL
/****************************************************************************
* EmulatorUpdate
*
* Prompts for confirmation, and downloads/installs updates
***************************************************************************/
static void *
EmulatorUpdate (void *arg)
{
sleep(5);
bool installUpdate = WindowPrompt(
"Update Available",
"An update is available!",
"Update now",
"Update later");
if(installUpdate)
if(DownloadUpdate())
ExitRequested = 1;
return NULL;
}
#endif
/**************************************************************************** /****************************************************************************
* UpdateGUI * UpdateGUI
*
* Primary thread to allow GUI to respond to state changes, and draws GUI
***************************************************************************/ ***************************************************************************/
/*static u32 arena1mem = 0; /*static u32 arena1mem = 0;
@ -250,14 +294,8 @@ UpdateGUI (void *arg)
#ifdef HW_RVL #ifdef HW_RVL
if(updateFound) if(updateFound)
{ {
updateFound = WindowPrompt( updateFound = false;
"Update Available", LWP_CreateThread (&updatethread, EmulatorUpdate, NULL, NULL, 0, 70);
"An update is available!",
"Update now",
"Update later");
if(updateFound)
if(DownloadUpdate())
ExitRequested = 1;
} }
#endif #endif
@ -284,8 +322,11 @@ UpdateGUI (void *arg)
/**************************************************************************** /****************************************************************************
* ProgressWindow * ProgressWindow
*
* Opens a window, which displays progress to the user. Can either display a
* progress bar showing % completion, or a throbber that only shows that an
* action is in progress.
***************************************************************************/ ***************************************************************************/
static void static void
ProgressWindow(char *title, char *msg) ProgressWindow(char *title, char *msg)
{ {
@ -401,8 +442,9 @@ static void * ProgressThread (void *arg)
/**************************************************************************** /****************************************************************************
* InitGUIThread * InitGUIThread
*
* Startup GUI threads
***************************************************************************/ ***************************************************************************/
void void
InitGUIThreads() InitGUIThreads()
{ {
@ -411,11 +453,12 @@ InitGUIThreads()
} }
/**************************************************************************** /****************************************************************************
* Progress Bar * CancelAction
* *
* Show the user what's happening * Signals the GUI progress window thread to halt, and waits for it to
* finish. Prevents multiple progress window events from interfering /
* overriding each other.
***************************************************************************/ ***************************************************************************/
void void
CancelAction() CancelAction()
{ {
@ -426,6 +469,12 @@ CancelAction()
usleep(50); usleep(50);
} }
/****************************************************************************
* ShowProgress
*
* Updates the variables used by the progress window for drawing a progress
* bar. Also resumes the progress window thread if it is suspended.
***************************************************************************/
void void
ShowProgress (const char *msg, int done, int total) ShowProgress (const char *msg, int done, int total)
{ {
@ -448,6 +497,12 @@ ShowProgress (const char *msg, int done, int total)
LWP_ResumeThread (progressthread); LWP_ResumeThread (progressthread);
} }
/****************************************************************************
* ShowAction
*
* Shows that an action is underway. Also resumes the progress window thread
* if it is suspended.
***************************************************************************/
void void
ShowAction (const char *msg) ShowAction (const char *msg)
{ {
@ -477,6 +532,11 @@ void InfoPrompt(const char *msg)
WindowPrompt("Information", msg, "OK", NULL); WindowPrompt("Information", msg, "OK", NULL);
} }
/****************************************************************************
* AutoSave
*
* Automatically saves SRAM/snapshot when returning from in-game to the menu
***************************************************************************/
void AutoSave() void AutoSave()
{ {
if (GCSettings.AutoSave == 1) if (GCSettings.AutoSave == 1)
@ -498,6 +558,12 @@ void AutoSave()
} }
} }
/****************************************************************************
* OnScreenKeyboard
*
* Opens an on-screen keyboard window, with the data entered being stored
* into the specified variable.
***************************************************************************/
static void OnScreenKeyboard(char * var, u16 maxlen) static void OnScreenKeyboard(char * var, u16 maxlen)
{ {
int save = -1; int save = -1;
@ -571,6 +637,12 @@ static void OnScreenKeyboard(char * var, u16 maxlen)
ResumeGui(); ResumeGui();
} }
/****************************************************************************
* SettingWindow
*
* Opens a new window, with the specified window element appended. Allows
* for a customizable prompted setting.
***************************************************************************/
static int static int
SettingWindow(const char * title, GuiWindow * w) SettingWindow(const char * title, GuiWindow * w)
{ {
@ -657,7 +729,6 @@ SettingWindow(const char * title, GuiWindow * w)
* *
* THIS MUST NOT BE REMOVED OR DISABLED IN ANY DERIVATIVE WORK * THIS MUST NOT BE REMOVED OR DISABLED IN ANY DERIVATIVE WORK
***************************************************************************/ ***************************************************************************/
static void WindowCredits(void * ptr) static void WindowCredits(void * ptr)
{ {
if(btnLogo->GetState() != STATE_CLICKED) if(btnLogo->GetState() != STATE_CLICKED)
@ -787,8 +858,10 @@ static void WindowCredits(void * ptr)
/**************************************************************************** /****************************************************************************
* MenuGameSelection * MenuGameSelection
*
* Displays a list of games on the specified load device, and allows the user
* to browse and select from this list.
***************************************************************************/ ***************************************************************************/
static int MenuGameSelection() static int MenuGameSelection()
{ {
#ifdef HW_RVL #ifdef HW_RVL
@ -937,6 +1010,11 @@ static int MenuGameSelection()
return menu; return menu;
} }
/****************************************************************************
* ControllerWindowUpdate
*
* Callback for controller window. Responds to clicks on window elements.
***************************************************************************/
static void ControllerWindowUpdate(void * ptr, int dir) static void ControllerWindowUpdate(void * ptr, int dir)
{ {
GuiButton * b = (GuiButton *)ptr; GuiButton * b = (GuiButton *)ptr;
@ -954,9 +1032,19 @@ static void ControllerWindowUpdate(void * ptr, int dir)
} }
} }
/****************************************************************************
* ControllerWindowLeftClick / ControllerWindowRightsClick
*
* Callbacks for controller window arrows. Responds arrow clicks.
***************************************************************************/
static void ControllerWindowLeftClick(void * ptr) { ControllerWindowUpdate(ptr, -1); } static void ControllerWindowLeftClick(void * ptr) { ControllerWindowUpdate(ptr, -1); }
static void ControllerWindowRightClick(void * ptr) { ControllerWindowUpdate(ptr, +1); } static void ControllerWindowRightClick(void * ptr) { ControllerWindowUpdate(ptr, +1); }
/****************************************************************************
* ControllerWindow
*
* Opens a window to allow the user to select the controller to be used.
***************************************************************************/
static void ControllerWindow() static void ControllerWindow()
{ {
GuiWindow * w = new GuiWindow(300,250); GuiWindow * w = new GuiWindow(300,250);
@ -1017,8 +1105,9 @@ static void ControllerWindow()
/**************************************************************************** /****************************************************************************
* MenuGame * MenuGame
*
* Menu displayed when returning to the menu from in-game.
***************************************************************************/ ***************************************************************************/
static int MenuGame() static int MenuGame()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1362,8 +1451,9 @@ static int MenuGame()
/**************************************************************************** /****************************************************************************
* MenuGameSaves * MenuGameSaves
*
* Allows the user to load or save progress.
***************************************************************************/ ***************************************************************************/
static int MenuGameSaves(int action) static int MenuGameSaves(int action)
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1633,8 +1723,10 @@ static int MenuGameSaves(int action)
/**************************************************************************** /****************************************************************************
* MenuGameCheats * MenuGameCheats
*
* Displays a list of cheats available, and allows the user to enable/disable
* them.
***************************************************************************/ ***************************************************************************/
static int MenuGameCheats() static int MenuGameCheats()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1750,7 +1842,6 @@ static int MenuGameCheats()
/**************************************************************************** /****************************************************************************
* MenuSettings * MenuSettings
***************************************************************************/ ***************************************************************************/
static int MenuSettings() static int MenuSettings()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -1960,7 +2051,6 @@ static int MenuSettings()
/**************************************************************************** /****************************************************************************
* MenuSettingsMappings * MenuSettingsMappings
***************************************************************************/ ***************************************************************************/
static int MenuSettingsMappings() static int MenuSettingsMappings()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;

View File

@ -16,7 +16,6 @@
#include "unzip.h" #include "unzip.h"
#include "miniunz.h" #include "miniunz.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "menu.h" #include "menu.h"
#include "fileop.h" #include "fileop.h"
@ -81,8 +80,8 @@ void UpdateCheck()
verMinor >= 0 && verMinor <= 9 && verMinor >= 0 && verMinor <= 9 &&
verPoint >= 0 && verPoint <= 9) && verPoint >= 0 && verPoint <= 9) &&
(verMajor > curMajor || (verMajor > curMajor ||
verMinor > curMinor || (verMajor == curMajor && verMinor > curMinor) ||
verPoint > curPoint)) (verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
{ {
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND); item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
if(item) if(item)

View File

@ -304,7 +304,7 @@ InitVideoThread ()
LWP_InitQueue (&videoblankqueue); LWP_InitQueue (&videoblankqueue);
/*** Create the thread on this queue ***/ /*** Create the thread on this queue ***/
LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 150); LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 100);
} }
/**************************************************************************** /****************************************************************************