From 1fe96748b7ba2e5d586bc32c9adc9590533afec9 Mon Sep 17 00:00:00 2001 From: giantpune Date: Wed, 2 Sep 2009 08:03:51 +0000 Subject: [PATCH] Made game ID text into a button to change the ID for custom games based off a retail disc (Guitar Hero baby!). *NOTE* it is possible to change any game ID to more or less than 6 characters, but since most of the functions use header->id[0] through [5], more will be useless and less may result in code dumps. it is not advised to change the ID for games that are not custom, as the cover and wiitdb data will not be available for made up ID it is possible to have multiple games with the same ID on the wbfs partition, but when any of them are clicked, the wii will perform the selected action (play, delete, etc) on the first one it finds. --- Languages/czech.lang | 5 +- Languages/danish.lang | 5 +- Languages/dutch.lang | 5 +- Languages/english.lang | 5 +- Languages/finnish.lang | 5 +- Languages/french.lang | 5 +- Languages/german.lang | 5 +- Languages/hungarian.lang | 5 +- Languages/italian.lang | 5 +- Languages/japanese.lang | 5 +- Languages/korean.lang | 5 +- Languages/norwegian.lang | 5 +- Languages/polish.lang | 5 +- Languages/portuguese_br.lang | 6 +- Languages/portuguese_pt.lang | 5 +- Languages/russian.lang | 5 +- Languages/schinese.lang | 5 +- Languages/spanish.lang | 5 +- Languages/swedish.lang | 5 +- Languages/tchinese.lang | 5 +- Languages/turkish.lang | 5 +- gui.pnproj | 2 +- source/libwbfs/libwbfs.c | 316 ++++++++++++++++++----------------- source/menu.cpp | 45 ++++- source/usbloader/wbfs.c | 13 ++ source/usbloader/wbfs.h | 1 + 26 files changed, 305 insertions(+), 178 deletions(-) diff --git a/Languages/czech.lang b/Languages/czech.lang index 30588fea..9b99a1d9 100644 --- a/Languages/czech.lang +++ b/Languages/czech.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: David Jelinek (djelinek@hotmail.com) \n" "Language-Team: r713 - last version on http://djelinek.sweb.cz/czech.lang \n" @@ -205,6 +205,9 @@ msgstr "Zjištuji dostupné aktualiazce" msgid "Click to Download Covers" msgstr "Kliknete pro stažení obalu" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Hodiny" diff --git a/Languages/danish.lang b/Languages/danish.lang index 143d688e..3e545536 100644 --- a/Languages/danish.lang +++ b/Languages/danish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Leder efter opdateringer" msgid "Click to Download Covers" msgstr "Klik for at downloade covers" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Ur" diff --git a/Languages/dutch.lang b/Languages/dutch.lang index 987a016e..0ef18855 100644 --- a/Languages/dutch.lang +++ b/Languages/dutch.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: tj_cool\n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Controleren op updates" msgid "Click to Download Covers" msgstr "Klik om hoesjes te downloaden" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Klok" diff --git a/Languages/english.lang b/Languages/english.lang index f108205e..da8bdbb9 100644 --- a/Languages/english.lang +++ b/Languages/english.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "" msgid "Click to Download Covers" msgstr "" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "" diff --git a/Languages/finnish.lang b/Languages/finnish.lang index b566fabe..72d0b109 100644 --- a/Languages/finnish.lang +++ b/Languages/finnish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "" msgid "Click to Download Covers" msgstr "Klikkaa ladataksesi kansia" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Kello" diff --git a/Languages/french.lang b/Languages/french.lang index fab2668f..f3ba1a2f 100644 --- a/Languages/french.lang +++ b/Languages/french.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: Kin8\n" "Language-Team: Badablek, Amour, ikya, OuahOuah, dj_skual & Kin8\n" @@ -205,6 +205,9 @@ msgstr "Recherche de Mise à Jour" msgid "Click to Download Covers" msgstr "Téléchargement des jaquettes" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Horloge" diff --git a/Languages/german.lang b/Languages/german.lang index 55a53d39..8f27e2b6 100644 --- a/Languages/german.lang +++ b/Languages/german.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Suche nach Aktualisierung" msgid "Click to Download Covers" msgstr "Klicken zum Coverdownloaden" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Uhr" diff --git a/Languages/hungarian.lang b/Languages/hungarian.lang index 00225679..b6d674ae 100644 --- a/Languages/hungarian.lang +++ b/Languages/hungarian.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: Tusk\n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Frissitések Keresése" msgid "Click to Download Covers" msgstr "Kattints, hogy letöltsd a borítókat" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Óra" diff --git a/Languages/italian.lang b/Languages/italian.lang index 7ab0049a..d3c66f4e 100644 --- a/Languages/italian.lang +++ b/Languages/italian.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-08-05 10:00+0200\n" "Last-Translator: Cambo \n" "Language-Team: FoxeJoe & Cambo\n" @@ -205,6 +205,9 @@ msgstr "Verifica Aggiornamenti" msgid "Click to Download Covers" msgstr "Premi per scaricare le Copertine" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Orologio" diff --git a/Languages/japanese.lang b/Languages/japanese.lang index 8a246506..253e83f0 100644 --- a/Languages/japanese.lang +++ b/Languages/japanese.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "最新版を確認中" msgid "Click to Download Covers" msgstr "クリックでカバーをダウンロード" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "時計" diff --git a/Languages/korean.lang b/Languages/korean.lang index 652d065f..77b1ea72 100644 --- a/Languages/korean.lang +++ b/Languages/korean.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "" msgid "Click to Download Covers" msgstr "표지를 다운하려면 클릭하세요" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "시계" diff --git a/Languages/norwegian.lang b/Languages/norwegian.lang index 8372e521..87040c6e 100644 --- a/Languages/norwegian.lang +++ b/Languages/norwegian.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Søker etter oppdateringer" msgid "Click to Download Covers" msgstr "Klikk for å laste ned cover" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Klokke" diff --git a/Languages/polish.lang b/Languages/polish.lang index b5b819ba..1e602ade 100644 --- a/Languages/polish.lang +++ b/Languages/polish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: ziom666 (zadania_prog@vp.pl)\n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Sprawdzanie aktualizacji" msgid "Click to Download Covers" msgstr "Kliknij aby pobrac okladki" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Zegar" diff --git a/Languages/portuguese_br.lang b/Languages/portuguese_br.lang index 68c0b3a8..d02e14fa 100644 --- a/Languages/portuguese_br.lang +++ b/Languages/portuguese_br.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-08-11 19:45\n" "Last-Translator: boto12\n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Procurando Atualizações" msgid "Click to Download Covers" msgstr "Aperte para baixar capas" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Relógio" @@ -1169,4 +1172,3 @@ msgstr "de" msgid "seconds left" msgstr "segundos restantes" - diff --git a/Languages/portuguese_pt.lang b/Languages/portuguese_pt.lang index ed19b595..696dbb90 100644 --- a/Languages/portuguese_pt.lang +++ b/Languages/portuguese_pt.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-08-11 12:25\n" "Last-Translator: Sky8000\n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Procurando Actualizações" msgid "Click to Download Covers" msgstr "Carregue para descarregar capas" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Relógio" diff --git a/Languages/russian.lang b/Languages/russian.lang index 1613e8ed..b75cb2c2 100644 --- a/Languages/russian.lang +++ b/Languages/russian.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: Kir\n" "Language-Team: Kir\n" @@ -205,6 +205,9 @@ msgstr "Проверяю обновления" msgid "Click to Download Covers" msgstr "Нажми, чтобы скачать обложки" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Часы" diff --git a/Languages/schinese.lang b/Languages/schinese.lang index 0b2f079f..aba61d43 100644 --- a/Languages/schinese.lang +++ b/Languages/schinese.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "" msgid "Click to Download Covers" msgstr "点击下载封面" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "时钟" diff --git a/Languages/spanish.lang b/Languages/spanish.lang index f9c7ce9b..33d770f0 100644 --- a/Languages/spanish.lang +++ b/Languages/spanish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "Verificando Actualizaciones" msgid "Click to Download Covers" msgstr "Click para bajar Carátulas" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Reloj" diff --git a/Languages/swedish.lang b/Languages/swedish.lang index 098f66ac..d8e83467 100644 --- a/Languages/swedish.lang +++ b/Languages/swedish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-08-02 12:20+0200\n" "Last-Translator: Katsurou\n" "Language-Team: Katsurou, pirateX\n" @@ -205,6 +205,9 @@ msgstr "Letar efter uppdateringar" msgid "Click to Download Covers" msgstr "Klicka för att ladda ner omslag" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Klocka" diff --git a/Languages/tchinese.lang b/Languages/tchinese.lang index f3a65b45..3f51edce 100644 --- a/Languages/tchinese.lang +++ b/Languages/tchinese.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 17:05+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "正在檢查更新" msgid "Click to Download Covers" msgstr "點擊進行封面下載" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "時鐘" diff --git a/Languages/turkish.lang b/Languages/turkish.lang index 8fb90b42..95f90910 100644 --- a/Languages/turkish.lang +++ b/Languages/turkish.lang @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: USB Loader GX\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-08-21 04:07+0200\n" +"POT-Creation-Date: 2009-09-02 02:36-0400\n" "PO-Revision-Date: 2009-07-18 15:18+0200\n" "Last-Translator: \n" "Language-Team: \n" @@ -205,6 +205,9 @@ msgstr "" msgid "Click to Download Covers" msgstr "Kapaklari Indirmek için Tiklayin" +msgid "Click to change game ID" +msgstr "" + msgid "Clock" msgstr "Saat" diff --git a/gui.pnproj b/gui.pnproj index 9c8c1fea..dc46785d 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/libwbfs/libwbfs.c b/source/libwbfs/libwbfs.c index cd1c5a9a..382fd7c2 100644 --- a/source/libwbfs/libwbfs.c +++ b/source/libwbfs/libwbfs.c @@ -394,96 +394,96 @@ static void free_block(wbfs_t *p,int bl) u32 v = wbfs_ntohl(p->freeblks[i]); p->freeblks[i] = wbfs_htonl(v | 1<wbfs_sec_sz_s-p->wii_sec_sz_s); - wiidisc_t *d = 0; - u8 *used = 0; - wbfs_disc_info_t *info = 0; - u8* copy_buffer = 0; - used = wbfs_malloc(p->n_wii_sec_per_disc); - if(!used) - ERROR("unable to alloc memory"); - if(!copy_1_1) - { - d = wd_open_disc(read_src_wii_disc,callback_data); - if(!d) - ERROR("unable to open wii disc"); - wd_build_disc_usage(d,sel,used); - wd_close_disc(d); - d = 0; - } - - - for(i=0;imax_disc;i++)// find a free slot. - if(p->head->disc_table[i]==0) - break; - if(i==p->max_disc) - ERROR("no space left on device (table full)"); - p->head->disc_table[i] = 1; - discn = i; - load_freeblocks(p); - - // build disc info - info = wbfs_ioalloc(p->disc_info_sz); - read_src_wii_disc(callback_data,0,0x100,info->disc_header_copy); - - copy_buffer = wbfs_ioalloc(p->wii_sec_sz); - if(!copy_buffer) - ERROR("alloc memory"); - tot=0; - cur=0; - if(spinner){ - // count total number to write for spinner - for(i=0; in_wbfs_sec_per_disc;i++) - if(copy_1_1 || block_used(used,i,wii_sec_per_wbfs_sect)) tot += wii_sec_per_wbfs_sect; - spinner(0,tot); - } - for(i=0; in_wbfs_sec_per_disc;i++){ - u16 bl = 0; - if(copy_1_1 || block_used(used,i,wii_sec_per_wbfs_sect)) { - u16 j; - - bl = alloc_block(p); - if (bl==0xffff) - ERROR("no space left on device (disc full)"); - for(j=0; jwbfs_sec_sz>>2)) + (j*(p->wii_sec_sz>>2)); - - read_src_wii_disc(callback_data,offset,p->wii_sec_sz,copy_buffer); - - //fix the partition table - if(offset == (0x40000>>2)) - wd_fix_partition_table(d, sel, copy_buffer); - p->write_hdsector(p->callback_data,p->part_lba+bl*(p->wbfs_sec_sz/p->hd_sec_sz)+j*(p->wii_sec_sz/p->hd_sec_sz), - p->wii_sec_sz/p->hd_sec_sz,copy_buffer); - cur++; - if(spinner) - spinner(cur,tot); - } - } - info->wlba_table[i] = wbfs_htons(bl); - } - // write disc info - int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s; - p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,info); - wbfs_sync(p); -error: - if(d) - wd_close_disc(d); - if(used) - wbfs_free(used); - if(info) - wbfs_iofree(info); - if(copy_buffer) - wbfs_iofree(copy_buffer); - // init with all free blocks - - return 0; -} +u32 wbfs_add_disc(wbfs_t*p,read_wiidisc_callback_t read_src_wii_disc, + void *callback_data,progress_callback_t spinner,partition_selector_t sel,int copy_1_1) +{ + int i,discn; + u32 tot,cur; + u32 wii_sec_per_wbfs_sect = 1<<(p->wbfs_sec_sz_s-p->wii_sec_sz_s); + wiidisc_t *d = 0; + u8 *used = 0; + wbfs_disc_info_t *info = 0; + u8* copy_buffer = 0; + used = wbfs_malloc(p->n_wii_sec_per_disc); + if(!used) + ERROR("unable to alloc memory"); + if(!copy_1_1) + { + d = wd_open_disc(read_src_wii_disc,callback_data); + if(!d) + ERROR("unable to open wii disc"); + wd_build_disc_usage(d,sel,used); + wd_close_disc(d); + d = 0; + } + + + for(i=0;imax_disc;i++)// find a free slot. + if(p->head->disc_table[i]==0) + break; + if(i==p->max_disc) + ERROR("no space left on device (table full)"); + p->head->disc_table[i] = 1; + discn = i; + load_freeblocks(p); + + // build disc info + info = wbfs_ioalloc(p->disc_info_sz); + read_src_wii_disc(callback_data,0,0x100,info->disc_header_copy); + + copy_buffer = wbfs_ioalloc(p->wii_sec_sz); + if(!copy_buffer) + ERROR("alloc memory"); + tot=0; + cur=0; + if(spinner){ + // count total number to write for spinner + for(i=0; in_wbfs_sec_per_disc;i++) + if(copy_1_1 || block_used(used,i,wii_sec_per_wbfs_sect)) tot += wii_sec_per_wbfs_sect; + spinner(0,tot); + } + for(i=0; in_wbfs_sec_per_disc;i++){ + u16 bl = 0; + if(copy_1_1 || block_used(used,i,wii_sec_per_wbfs_sect)) { + u16 j; + + bl = alloc_block(p); + if (bl==0xffff) + ERROR("no space left on device (disc full)"); + for(j=0; jwbfs_sec_sz>>2)) + (j*(p->wii_sec_sz>>2)); + + read_src_wii_disc(callback_data,offset,p->wii_sec_sz,copy_buffer); + + //fix the partition table + if(offset == (0x40000>>2)) + wd_fix_partition_table(d, sel, copy_buffer); + p->write_hdsector(p->callback_data,p->part_lba+bl*(p->wbfs_sec_sz/p->hd_sec_sz)+j*(p->wii_sec_sz/p->hd_sec_sz), + p->wii_sec_sz/p->hd_sec_sz,copy_buffer); + cur++; + if(spinner) + spinner(cur,tot); + } + } + info->wlba_table[i] = wbfs_htons(bl); + } + // write disc info + int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s; + p->write_hdsector(p->callback_data,p->part_lba+1+discn*disc_info_sz_lba,disc_info_sz_lba,info); + wbfs_sync(p); +error: + if(d) + wd_close_disc(d); + if(used) + wbfs_free(used); + if(info) + wbfs_iofree(info); + if(copy_buffer) + wbfs_iofree(copy_buffer); + // init with all free blocks + + return 0; +} u32 wbfs_rm_disc(wbfs_t*p, u8* discid) { @@ -525,6 +525,22 @@ u32 wbfs_ren_disc(wbfs_t*p, u8* discid, u8* newname) return 0; } +u32 wbfs_rID_disc(wbfs_t*p, u8* discid, u8* newID) +{ + wbfs_disc_t *d = wbfs_open_disc(p,discid); + int disc_info_sz_lba = p->disc_info_sz>>p->hd_sec_sz_s; + + if(!d) + return 1; + + memset(d->header->disc_header_copy, 0, 0x10); + strncpy((char *) d->header->disc_header_copy, (char *) newID, 0x9); + + p->write_hdsector(p->callback_data,p->part_lba+1+d->i*disc_info_sz_lba,disc_info_sz_lba,d->header); + wbfs_close_disc(d); + return 0; +} + // trim the file-system to its minimum size u32 wbfs_trim(wbfs_t*p); @@ -557,64 +573,64 @@ u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector,v error: return 1; } -u32 wbfs_extract_file(wbfs_disc_t*d, char *path); - -float wbfs_estimate_disc -( - wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, - void *callback_data, - partition_selector_t sel) -{ - u8 *b; - int i; - u32 tot; - u32 wii_sec_per_wbfs_sect = 1 << (p->wbfs_sec_sz_s-p->wii_sec_sz_s); - wiidisc_t *d = 0; - u8 *used = 0; - wbfs_disc_info_t *info = 0; - - tot = 0; - - used = wbfs_malloc(p->n_wii_sec_per_disc); - if (!used) - { - ERROR("unable to alloc memory"); - } - - d = wd_open_disc(read_src_wii_disc, callback_data); - if (!d) - { - ERROR("unable to open wii disc"); - } - - wd_build_disc_usage(d,sel,used); - wd_close_disc(d); - d = 0; - - info = wbfs_ioalloc(p->disc_info_sz); - 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); - - for (i = 0; i < p->n_wbfs_sec_per_disc; i++) - { - if (block_used(used, i, wii_sec_per_wbfs_sect)) - { - tot++; - } - } - //memcpy(header, b,0x100); - -error: - if (d) - wd_close_disc(d); - - if (used) - wbfs_free(used); - - if (info) - wbfs_iofree(info); - - return tot * (((p->wbfs_sec_sz*1.0) / p->hd_sec_sz) * 512); +u32 wbfs_extract_file(wbfs_disc_t*d, char *path); + +float wbfs_estimate_disc +( + wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, + void *callback_data, + partition_selector_t sel) +{ + u8 *b; + int i; + u32 tot; + u32 wii_sec_per_wbfs_sect = 1 << (p->wbfs_sec_sz_s-p->wii_sec_sz_s); + wiidisc_t *d = 0; + u8 *used = 0; + wbfs_disc_info_t *info = 0; + + tot = 0; + + used = wbfs_malloc(p->n_wii_sec_per_disc); + if (!used) + { + ERROR("unable to alloc memory"); + } + + d = wd_open_disc(read_src_wii_disc, callback_data); + if (!d) + { + ERROR("unable to open wii disc"); + } + + wd_build_disc_usage(d,sel,used); + wd_close_disc(d); + d = 0; + + info = wbfs_ioalloc(p->disc_info_sz); + 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); + + for (i = 0; i < p->n_wbfs_sec_per_disc; i++) + { + if (block_used(used, i, wii_sec_per_wbfs_sect)) + { + tot++; + } + } + //memcpy(header, b,0x100); + +error: + if (d) + wd_close_disc(d); + + if (used) + wbfs_free(used); + + if (info) + wbfs_iofree(info); + + return tot * (((p->wbfs_sec_sz*1.0) / p->hd_sec_sz) * 512); } diff --git a/source/menu.cpp b/source/menu.cpp index bab516f4..bde6b3a1 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -593,13 +593,30 @@ int MenuDiscList() { DownloadBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); DownloadBtn.SetPosition(THEME.cover_x,THEME.cover_y); + GuiTooltip IDBtnTT(tr("Click to change game ID")); + if (Settings.wsprompt == yes) + IDBtnTT.SetWidescreen(CFG.widescreen); + IDBtnTT.SetAlpha(THEME.tooltipAlpha); + GuiButton idBtn(0,0); + idBtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); + idBtn.SetPosition(THEME.id_x,THEME.id_y); + + + if (Settings.godmode == 1) {//only make the button have trigger & tooltip if in godmode DownloadBtn.SetSoundOver(&btnSoundOver); DownloadBtn.SetTrigger(&trigA); DownloadBtn.SetTrigger(&trig1); DownloadBtn.SetToolTip(&DownloadBtnTT,205,-30); + + idBtn.SetSoundOver(&btnSoundOver); + idBtn.SetTrigger(&trigA); + idBtn.SetToolTip(&IDBtnTT,205,-30); } else + { DownloadBtn.SetRumble(false); + idBtn.SetRumble(false); + } GuiGameBrowser * gameBrowser = NULL; GuiGameGrid * gameGrid = NULL; @@ -645,6 +662,7 @@ int MenuDiscList() { w.Append(&homeBtn); w.Append(&settingsBtn); w.Append(&DownloadBtn); + w.Append(&idBtn); w.Append(&favoriteBtn); w.Append(&abcBtn); w.Append(&countBtn); @@ -1014,7 +1032,6 @@ int MenuDiscList() { if (choice==2) homeBtn.SetState(STATE_CLICKED); } - if (Settings.gameDisplay==grid) { int selectimg; DownloadBtn.SetSize(0,0); @@ -1034,6 +1051,7 @@ int MenuDiscList() { //Get selected game under cursor int selectimg; DownloadBtn.SetSize(160,224); + idBtn.SetSize(100,40); selectimg = gameBrowser->GetSelectedOption(); gameSelected = gameBrowser->GetClickedOption(); @@ -1051,7 +1069,7 @@ int MenuDiscList() { w.Remove(&DownloadBtn); if (GameIDTxt) { - w.Remove(GameIDTxt); + w.Remove(&idBtn); delete GameIDTxt; GameIDTxt = NULL; } @@ -1120,9 +1138,10 @@ int MenuDiscList() { if ((Settings.sinfo == GameID) || (Settings.sinfo == Both)) { GameIDTxt = new GuiText(IDfull, 22, (GXColor) {THEME.info_r, THEME.info_g, THEME.info_b, 255}); GameIDTxt->SetAlignment(ALIGN_LEFT, ALIGN_TOP); - GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); - GameIDTxt->SetEffect(EFFECT_FADE, 20); - w.Append(GameIDTxt); + //GameIDTxt->SetPosition(THEME.id_x,THEME.id_y); + idBtn.SetEffect(EFFECT_FADE, 20); + idBtn.SetLabel(GameIDTxt); + w.Append(&idBtn); } if ((Settings.sinfo == GameRegion) || (Settings.sinfo == Both)) { @@ -1134,6 +1153,22 @@ int MenuDiscList() { } } } + + if (idBtn.GetState() == STATE_CLICKED) { + struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()]; + //enter new game ID + char entered[10]; + snprintf(entered, sizeof(entered), "%s", IDfull); + //entered[9] = '\0'; + int result = OnScreenKeyboard(entered, 7,0); + if (result == 1) { + WBFS_ReIDGame(header->id, entered); + //__Menu_GetEntries(); + menu = MENU_DISCLIST; + } + + idBtn.ResetState(); + } } if ((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) { diff --git a/source/usbloader/wbfs.c b/source/usbloader/wbfs.c index 673992d0..f84d2fe1 100644 --- a/source/usbloader/wbfs.c +++ b/source/usbloader/wbfs.c @@ -476,6 +476,19 @@ s32 WBFS_RenameGame(u8 *discid, const void *newname) { return 0; } +s32 WBFS_ReIDGame(u8 *discid, const void *newID) { + s32 ret; + + /* No USB device open */ + if (!hdd) + return -1; + ret = wbfs_rID_disc(hdd, discid,(u8*)newID); + if (ret < 0) + return ret; + + return 0; +} + f32 WBFS_EstimeGameSize(void) { return wbfs_estimate_disc(hdd, __WBFS_ReadDVD, NULL, ONLY_GAME_PARTITION); diff --git a/source/usbloader/wbfs.h b/source/usbloader/wbfs.h index a942de11..4846f310 100644 --- a/source/usbloader/wbfs.h +++ b/source/usbloader/wbfs.h @@ -32,6 +32,7 @@ extern "C" { s32 WBFS_GameSize(u8 *, f32 *); s32 WBFS_DiskSpace(f32 *, f32 *); s32 WBFS_RenameGame(u8 *, const void *); + s32 WBFS_ReIDGame(u8 *discid, const void *newID); f32 WBFS_EstimeGameSize(void); s32 __WBFS_ReadUSB(void *fp, u32 lba, u32 count, void *iobuf);