From a97cfd3431993c3502651ea183fd5b8544d8063d Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Wed, 13 May 2009 20:55:33 +0000 Subject: [PATCH] *Fixed Estimation GameSize before Install BUG *Some small fixes and MP3 Crash fix (STILL BUGGY WHILE PLAYING, DON'T USE IT) --- source/disc.h | 2 -- source/fst.h | 12 +++++++++++- source/libwbfs/libwbfs.c | 8 +++++--- source/libwbfs/libwbfs.h | 2 +- source/menu.cpp | 34 +++++++++++++++++----------------- source/mp3s.c | 2 +- source/mp3s.h | 2 +- source/partition.h | 2 -- source/sys.h | 1 - source/usbstorage.h | 2 -- source/video2.h | 2 -- source/wbfs.c | 20 ++++++++++---------- source/wbfs.h | 2 -- source/wdvd.h | 2 -- source/wpad.h | 2 -- 15 files changed, 46 insertions(+), 49 deletions(-) diff --git a/source/disc.h b/source/disc.h index f9f4aa2f..b80807ce 100644 --- a/source/disc.h +++ b/source/disc.h @@ -1,7 +1,5 @@ #ifndef _DISC_H_ #define _DISC_H_ - -#include #ifdef __cplusplus extern "C" diff --git a/source/fst.h b/source/fst.h index 63fed055..ccd855e0 100644 --- a/source/fst.h +++ b/source/fst.h @@ -22,7 +22,17 @@ #ifndef __FST_H__ #define __FST_H__ +#ifdef __cplusplus +extern "C" +{ +#endif + //u32 do_fst(u32 fstlocation); u32 do_sd_code(char *filename); + +#ifdef __cplusplus +} #endif - \ No newline at end of file + +#endif + diff --git a/source/libwbfs/libwbfs.c b/source/libwbfs/libwbfs.c index abef805a..472d34f1 100644 --- a/source/libwbfs/libwbfs.c +++ b/source/libwbfs/libwbfs.c @@ -553,7 +553,8 @@ error: } u32 wbfs_extract_file(wbfs_disc_t*d, char *path); -u32 wbfs_estimate_disc( +float wbfs_estimate_disc +( wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, partition_selector_t sel) @@ -588,7 +589,7 @@ u32 wbfs_estimate_disc( b = (u8 *)info; read_src_wii_disc(callback_data, 0, 0x100, info->disc_header_copy); - fprintf(stderr, "estimating %c%c%c%c%c%c %s...\n",b[0], b[1], b[2], b[3], b[4], b[5], b + 0x20); + //fprintf(stderr, "estimating %c%c%c%c%c%c %s...\n",b[0], b[1], b[2], b[3], b[4], b[5], b + 0x20); for (i = 0; i < p->n_wbfs_sec_per_disc; i++) { @@ -597,6 +598,7 @@ u32 wbfs_estimate_disc( tot++; } } + //memcpy(header, b,0x100); error: if (d) @@ -608,5 +610,5 @@ error: if (info) wbfs_iofree(info); - return tot * ((p->wbfs_sec_sz / p->hd_sec_sz) * 512); + return tot * (((p->wbfs_sec_sz*1.0) / p->hd_sec_sz) * 512); } diff --git a/source/libwbfs/libwbfs.h b/source/libwbfs/libwbfs.h index d96c6628..2f6f1a9f 100644 --- a/source/libwbfs/libwbfs.h +++ b/source/libwbfs/libwbfs.h @@ -211,7 +211,7 @@ u32 wbfs_extract_file(wbfs_disc_t*d, char *path); // remove some sanity checks void wbfs_set_force_mode(int force); -u32 wbfs_estimate_disc( +float wbfs_estimate_disc( wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, partition_selector_t sel); diff --git a/source/menu.cpp b/source/menu.cpp index e2ea5c5c..64970179 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -846,12 +846,12 @@ int GameWindowPrompt() sizeTxt.SetText(sizeText); msgTxt.SetText(gameName); char* pch; - + pch=strrchr((gameName),'_'); - + if (pch!=NULL){msgTxt.SetPosition(0, 16);} else {msgTxt.SetPosition(0, 1);} - + HaltGui(); mainWindow->SetState(STATE_DISABLED); @@ -2145,8 +2145,8 @@ static int MenuInstall() f32 freespace, used; WBFS_DiskSpace(&used, &freespace); - u32 estimation = wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION); - gamesize = ((f32) estimation)/1073741824; + float estimation = wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION); + gamesize = estimation/1073741824; char gametxt[50]; sprintf(gametxt, "%s : %.2fGB", name, gamesize); @@ -4528,7 +4528,7 @@ int MenuMp3() customOptionList options2(500); char mp3path[30] = "SD:/mp3/"; - char fullpath[100]; + char fullpath[110]; int countmp3 = GetFiles(mp3path); for (cnt = 0; cnt < countmp3; cnt++) { @@ -4588,9 +4588,9 @@ int MenuMp3() GuiImageData pause(imgPath, mp3_pause_png); snprintf(imgPath, sizeof(imgPath), "%sstartgame_arrow_right.png", CFG.theme_path); GuiImageData play(imgPath, startgame_arrow_right_png); - - - + + + GuiImage nextBtnImg(&next); GuiButton nextBtn(next.GetWidth(), next.GetHeight()); nextBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); @@ -4601,7 +4601,7 @@ int MenuMp3() nextBtn.SetTrigger(&trigA); nextBtn.SetTrigger(&trigR); nextBtn.SetEffectGrow(); - + GuiImage prevBtnImg(&prev); prevBtnImg.SetWidescreen(CFG.widescreen); GuiButton prevBtn(prev.GetWidth(), prev.GetHeight()); @@ -4613,7 +4613,7 @@ int MenuMp3() prevBtn.SetTrigger(&trigA); prevBtn.SetTrigger(&trigL); prevBtn.SetEffectGrow(); - + GuiImage playBtnImg(&play); playBtnImg.SetWidescreen(CFG.widescreen); GuiButton playBtn(play.GetWidth(), play.GetHeight()); @@ -4625,7 +4625,7 @@ int MenuMp3() playBtn.SetTrigger(&trigA); playBtn.SetTrigger(&trigPlus); playBtn.SetEffectGrow(); - + GuiImage stopBtnImg(&stop); stopBtnImg.SetWidescreen(CFG.widescreen); GuiButton stopBtn(stop.GetWidth(), stop.GetHeight()); @@ -4637,7 +4637,7 @@ int MenuMp3() stopBtn.SetTrigger(&trigA); stopBtn.SetTrigger(&trigMinus); stopBtn.SetEffectGrow(); - + GuiImage pauseBtnImg(&pause); pauseBtnImg.SetWidescreen(CFG.widescreen); @@ -4685,11 +4685,11 @@ int MenuMp3() //playBtn.SetImage(&playBtnImg);isplaying=true; //if (isplaying==true){playBtn.SetImage(&pauseBtnImg);isplaying=false;} playBtn.ResetState(); - + } - + if(nextBtn.GetState() == STATE_CLICKED) - { + { StopMp3(); songPlaying++; if (songPlaying>(countmp3 - 1)){songPlaying=0;} @@ -4701,7 +4701,7 @@ int MenuMp3() //break; } if(prevBtn.GetState() == STATE_CLICKED) - { + { StopMp3(); songPlaying--; if (songPlaying<0){songPlaying=(countmp3 - 1);} diff --git a/source/mp3s.c b/source/mp3s.c index c70f4dd4..7c71fd67 100644 --- a/source/mp3s.c +++ b/source/mp3s.c @@ -134,7 +134,7 @@ if (dir == NULL) //If empty } } - qsort(mp3files, countmp3, sizeof(char[30]), filenamescmp); + qsort(mp3files, countmp3, sizeof(char[80]), filenamescmp); return countmp3; } diff --git a/source/mp3s.h b/source/mp3s.h index 4a2f7804..f0abdd00 100644 --- a/source/mp3s.h +++ b/source/mp3s.h @@ -6,7 +6,7 @@ extern "C" { #endif -char mp3files[500][30]; +char mp3files[500][80]; void StopMp3(); void SetMp3Volume(u32 vol); diff --git a/source/partition.h b/source/partition.h index 113fe6c0..cc8807de 100644 --- a/source/partition.h +++ b/source/partition.h @@ -1,8 +1,6 @@ #ifndef _PARTITION_H_ #define _PARTITION_H_ -#include - #ifdef __cplusplus extern "C" { diff --git a/source/sys.h b/source/sys.h index 691c8a80..74d7fb62 100644 --- a/source/sys.h +++ b/source/sys.h @@ -1,6 +1,5 @@ #ifndef _SYS_H_ #define _SYS_H_ -#include #ifdef __cplusplus extern "C" diff --git a/source/usbstorage.h b/source/usbstorage.h index 6f8fcbf2..ed6fc2e2 100644 --- a/source/usbstorage.h +++ b/source/usbstorage.h @@ -1,8 +1,6 @@ #ifndef _USBSTORAGE_H_ #define _USBSTORAGE_H_ -#include - #ifdef __cplusplus extern "C" { diff --git a/source/video2.h b/source/video2.h index d7c916d6..01c5b04e 100644 --- a/source/video2.h +++ b/source/video2.h @@ -1,8 +1,6 @@ #ifndef _VIDEO2_H_ #define _VIDEO2_H_ -#include - #ifdef __cplusplus extern "C" { diff --git a/source/wbfs.c b/source/wbfs.c index 798a8a6d..f612a8ae 100644 --- a/source/wbfs.c +++ b/source/wbfs.c @@ -24,7 +24,7 @@ static rw_sector_callback_t readCallback = NULL; static rw_sector_callback_t writeCallback = NULL; /* Variables */ - + static u32 nb_sectors, sector_size; void __WBFS_Spinner(s32 x, s32 max) { @@ -247,7 +247,7 @@ s32 WBFS_Init(u32 device) if (!nb_sectors) return -1; } - else + else return ret; break; case WBFS_DEVICE_SDHC: @@ -262,12 +262,12 @@ s32 WBFS_Init(u32 device) /* Device info */ nb_sectors = 0; sector_size = SDHC_SECTOR_SIZE; - } + } else return -1; break; } - + return 0; } //s32 WBFS_Init(void) @@ -293,15 +293,15 @@ s32 WBFS_Init(u32 device, u32 timeout) u32 cnt; s32 ret; - // Wrong timeout + // Wrong timeout if (!timeout) return -1; - // Try to mount device + // Try to mount device for (cnt = 0; cnt < timeout; cnt++) { switch (device) { case WBFS_DEVICE_USB: { - // Initialize USB storage + // Initialize USB storage ret = USBStorage_Init(); if (ret >= 0) { @@ -317,11 +317,11 @@ s32 WBFS_Init(u32 device, u32 timeout) } case WBFS_DEVICE_SDHC: { - // Initialize SDHC + // Initialize SDHC ret = SDHC_Init(); if (ret) { - // Setup callbacks + // Setup callbacks readCallback = __WBFS_ReadSDHC; writeCallback = __WBFS_WriteSDHC; @@ -338,7 +338,7 @@ s32 WBFS_Init(u32 device, u32 timeout) return -1; } - // Sleep 1 second + // Sleep 1 second sleep(1); } diff --git a/source/wbfs.h b/source/wbfs.h index 7c177e47..13ef6481 100644 --- a/source/wbfs.h +++ b/source/wbfs.h @@ -1,8 +1,6 @@ #ifndef _WBFS_H_ #define _WBFS_H_ -#include - #ifdef __cplusplus extern "C" { diff --git a/source/wdvd.h b/source/wdvd.h index 3626d59f..a36c15b9 100644 --- a/source/wdvd.h +++ b/source/wdvd.h @@ -1,8 +1,6 @@ #ifndef _WDVD_H_ #define _WDVD_H_ -#include - #ifdef __cplusplus extern "C" { diff --git a/source/wpad.h b/source/wpad.h index 2679c8a9..6a541e91 100644 --- a/source/wpad.h +++ b/source/wpad.h @@ -3,8 +3,6 @@ #include -#include - #ifdef __cplusplus extern "C" {