mirror of
https://github.com/modmii/SysCheck-ModMii-Edition.git
synced 2024-11-25 09:36:54 +01:00
-It needs some work, but I've got the basics of threading.
This commit is contained in:
parent
3f30c6bbf9
commit
bb7dcdf19d
@ -27,6 +27,9 @@ extern GRRLIB_texImg *tex_window_png;
|
||||
extern GRRLIB_texImg *tex_Cogs_png[5];
|
||||
extern GRRLIB_texImg *tex_ScreenBuf;
|
||||
|
||||
extern u8 Cog_Num;
|
||||
extern u64 Last_Cog_Turn;
|
||||
|
||||
int initGUI(void);
|
||||
void deinitGUI(void);
|
||||
int printError(const char* msg);
|
||||
|
11
include/thread.h
Normal file
11
include/thread.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __THREAD_H__
|
||||
#define __THREAD_H__
|
||||
|
||||
extern vu8 done;
|
||||
extern lwp_t Cog_Thread;
|
||||
|
||||
void InitThread(void);
|
||||
void * DrawCogThread(void *arg);
|
||||
s32 PauseThread(void);
|
||||
s32 ResumeThread(void);
|
||||
#endif
|
28
source/gui.c
28
source/gui.c
@ -27,6 +27,7 @@
|
||||
#include "gecko.h"
|
||||
#include "sys.h"
|
||||
#include "fatMounter.h"
|
||||
#include "thread.h"
|
||||
|
||||
GRRLIB_ttfFont *myFont;
|
||||
GRRLIB_texImg *tex_background_png;
|
||||
@ -55,8 +56,8 @@ static const u8 WIIFONT_HASH[] = {0x32, 0xb3, 0x39, 0xcb, 0xbb, 0x50, 0x7d, 0x5
|
||||
static const u8 WIIFONT_HASH_KOR[] = {0xb7, 0x15, 0x6d, 0xf0, 0xf4, 0xae, 0x07, 0x8f, 0xd1, 0x53, 0x58, 0x3e, 0x93, 0x6e, 0x07, 0xc0, 0x98, 0x77, 0x49, 0x0e};
|
||||
u8 *systemFont;
|
||||
s32 systemFontSize = 0;
|
||||
static u8 Cog_Num = 0;
|
||||
static u64 Last_Cog_Turn = 0;
|
||||
u8 Cog_Num = 0;
|
||||
u64 Last_Cog_Turn = 0;
|
||||
|
||||
bool loadSystemFont(bool korean)
|
||||
{
|
||||
@ -161,11 +162,14 @@ int initGUI(void) {
|
||||
tex_Cogs_png[3] = GRRLIB_LoadTexturePNG(Cog4);
|
||||
tex_Cogs_png[4] = GRRLIB_LoadTexturePNG(Cog5);
|
||||
tex_ScreenBuf = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
|
||||
InitThread();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void deinitGUI(void) {
|
||||
//StopThread();
|
||||
done = 1;
|
||||
GRRLIB_FreeTTF(myFont);
|
||||
GRRLIB_FreeTexture(tex_background_png);
|
||||
GRRLIB_FreeTexture(tex_Checkicon_png);
|
||||
@ -199,6 +203,7 @@ void DrawDuringSort(void) {
|
||||
|
||||
int printError(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Deleteicon_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_PrintfTTF((640-strlen(msg)*9)/2, 256, myFont, msg, 20, HEX_WHITE);
|
||||
@ -213,6 +218,8 @@ int printError(const char* msg) {
|
||||
|
||||
int printSuccess(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
//GRRLIB_ClearTex(tex_ScreenBuf);
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Checkicon_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_PrintfTTF((640-strlen(msg)*9)/2, 256, myFont, msg, 20, HEX_WHITE);
|
||||
@ -226,6 +233,7 @@ int printSuccess(const char* msg) {
|
||||
|
||||
int printLoading(const char* msg) {
|
||||
//int i;
|
||||
//ResumeThread();
|
||||
u64 current_ticks = gettick();
|
||||
//GRRLIB_DrawImg(256, 112, tex_Refreshicon_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
@ -233,15 +241,16 @@ int printLoading(const char* msg) {
|
||||
CopyBuf();
|
||||
//for (i = 0; i < 3; i++) { //Workaround for GRRLIB_Render() bug
|
||||
while(!CheckTime(current_ticks, 250)) {
|
||||
DrawBuf();
|
||||
DrawCog();
|
||||
GRRLIB_Render();
|
||||
//DrawBuf();
|
||||
//DrawCog();
|
||||
//GRRLIB_Render();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int printSelectIOS(const char* msg, const char* ios) {
|
||||
int i;
|
||||
PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Refreshicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
@ -278,15 +287,16 @@ int printLoadingBar(const char* msg, const f32 percent) {
|
||||
CopyBuf();
|
||||
//for (i = 0; i < 3; i++) { //Workaround for GRRLIB_Render() bug
|
||||
while(!CheckTime(current_ticks, 250)) {
|
||||
DrawBuf();
|
||||
DrawCog();
|
||||
GRRLIB_Render();
|
||||
//DrawBuf();
|
||||
//DrawCog();
|
||||
//GRRLIB_Render();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int printEndSuccess(const char* msg) {
|
||||
int i;
|
||||
//PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Checkicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
@ -324,7 +334,7 @@ inline void DrawCog(void) {
|
||||
|
||||
int printEndError(const char* msg) {
|
||||
int i;
|
||||
|
||||
//PauseThread();
|
||||
GRRLIB_DrawImg(0, 0, tex_background_png, 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_DrawImg(256, 112, tex_Deleteicon_png, 0, 1, 1, HEX_WHITE);
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "tmdIdentification.h"
|
||||
#include "gecko.h"
|
||||
#include "update.h"
|
||||
#include "thread.h"
|
||||
|
||||
// Filename
|
||||
#define REPORT "sd:/sysCheck.csv"
|
||||
@ -731,6 +732,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
// Test vulnerabilities in IOS
|
||||
ResumeThread();
|
||||
for (i = 0; i < nbTitles; i++)
|
||||
{
|
||||
if (selectedIOS > -1) i = selectedIOS; //If specific IOS is selected
|
||||
@ -1118,6 +1120,7 @@ int main(int argc, char **argv)
|
||||
// Initialise the FAT file system
|
||||
printLoading(MSG_InitFAT);
|
||||
//usleep(250000);
|
||||
PauseThread();
|
||||
if (!fatInitDefault())
|
||||
{
|
||||
sprintf(MSG_Buffer, ERR_InitFAT);
|
||||
|
46
source/thread.c
Normal file
46
source/thread.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include <stdlib.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
#include <ogc/lwp.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "gui.h"
|
||||
|
||||
#define STACKSIZE (1024 * 64) // 64KB
|
||||
#define PRIORITY 50 // Medium-ish
|
||||
|
||||
lwp_t Cog_Thread;
|
||||
u8 stack[STACKSIZE] ATTRIBUTE_ALIGN (32);
|
||||
vu8 done = 0;
|
||||
|
||||
void * DrawCogThread(void *arg) {
|
||||
while(!done) {
|
||||
GRRLIB_DrawImg(0, 0, tex_ScreenBuf, 0, 1, 1, HEX_WHITE);
|
||||
if (CheckTime(Last_Cog_Turn, 25)) {
|
||||
Cog_Num++;
|
||||
if (Cog_Num > 4) Cog_Num = 0;
|
||||
Last_Cog_Turn = gettick();
|
||||
}
|
||||
GRRLIB_DrawImg(220, 150, tex_Cogs_png[Cog_Num], 0, 1, 1, HEX_WHITE);
|
||||
GRRLIB_Render();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void InitThread(void) {
|
||||
memset (&stack, 0, STACKSIZE);
|
||||
LWP_CreateThread (&Cog_Thread, DrawCogThread, NULL, stack, STACKSIZE, PRIORITY);
|
||||
}
|
||||
|
||||
inline s32 PauseThread(void) {
|
||||
//if(!LWP_ThreadIsSuspended(Cog_Thread)) return 0;
|
||||
return LWP_SuspendThread(Cog_Thread);
|
||||
}
|
||||
|
||||
inline s32 ResumeThread(void) {
|
||||
//if(LWP_ThreadIsSuspended(Cog_Thread)) return 0;
|
||||
return LWP_ResumeThread(Cog_Thread);
|
||||
}
|
||||
|
||||
//inline s32 StopThread(void) {
|
||||
// return LWP_JoinThread(Cog_Thread, NULL);
|
||||
//}
|
Loading…
Reference in New Issue
Block a user