*Added support for Wiimms virtual sector sizes for WBFS (sector sizes other than 512 bytes per sector). Sector sizes other than 512 bytes support more games than 500 (sector size - 12 games). You can just format your drive with Wiimms tools and use it.

*Changed USB Loader GX WBFS formatter to choose 2048 as virtual sector size if a drive with a size > 500GB is formatted.

NOTE: Don't use this feature with IOS58 mode. It might damage the partition. I did not build in a safety check for IOS58 mode because it will be removed soon anyway.
This commit is contained in:
dimok321 2011-02-04 15:25:27 +00:00
parent ca55f426c0
commit ae77bd1b7e
12 changed files with 56 additions and 44 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>2.0 r1061</version>
<release_date>201102021831</release_date>
<version>2.0 r1062</version>
<release_date>201102032147</release_date>
<no_ios_reload/>
<short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.

View File

@ -94,7 +94,7 @@ void BoxCover::WiiPADControl(GuiTrigger *t)
}
else if((t->wpad.btns_h & WPAD_BUTTON_A) && moveChan == t->chan && t->wpad.ir.valid)
{
movePosX = (t->wpad.ir.x-moveStartPosX) / 220.0f;
movePosX = (t->wpad.ir.x-moveStartPosX) / 180.0f;
movePosY = (moveStartPosY-t->wpad.ir.y) / 180.0f;
last_manual_move_frame = frameCount;
}
@ -199,10 +199,10 @@ void BoxCover::Draw()
GX_LoadPosMtxImm(modelView, GX_PNMTX0);
//! Border quads
GX_LoadTexObj(&boxBorderTex, GX_TEXMAP0);
GX_InvalidateTexAll();
//! Border quads
GX_SetArray(GX_VA_POS, (void *) &g_boxMeshQ[0].pos, sizeof(g_boxMeshQ[0]));
GX_SetArray(GX_VA_TEX0, (void *) &g_boxMeshQ[0].texCoord, sizeof(g_boxMeshQ[0]));
@ -228,10 +228,10 @@ void BoxCover::Draw()
}
GX_End();
//! Back Cover (Might be flat)
GX_LoadTexObj(flatCover ? &defaultBoxTex : &coverTex, GX_TEXMAP0);
GX_InvalidateTexAll();
//! Back Cover
GX_SetArray(GX_VA_POS, (void *) &g_boxBackCoverMesh[0].pos, sizeof(g_boxBackCoverMesh[0]));
GX_SetArray(GX_VA_TEX0, (void *) &g_boxBackCoverMesh[0].texCoord, sizeof(g_boxBackCoverMesh[0]));

View File

@ -754,8 +754,11 @@ int wbfs_extract_file(wbfs_disc_t*d, char *path, void **data)
int wbfs_get_fragments(wbfs_disc_t *d, _frag_append_t append_fragment, void *callback_data)
{
if (!d) return -1;
//! Use here real physical HDD sector size
u32 phys_hdd_sec_sz = *(((u32 *) d->p->callback_data)+1);
wbfs_t *p = d->p;
int src_wbs_nlb = p->wbfs_sec_sz / p->hd_sec_sz;
int src_wbs_nlb = p->wbfs_sec_sz / phys_hdd_sec_sz;
int i, ret, last = 0;
for (i = 0; i < p->n_wbfs_sec_per_disc; i++)
{

View File

@ -351,7 +351,7 @@ static void ProgressWindow(const char *title, const char *msg1, const char *msg2
while (showProgress)
{
usleep(30000);
usleep(50000);
if (shutdown)
Sys_Shutdown();

View File

@ -300,9 +300,6 @@ int LoaderSettings::GetMenuInternal()
//! Settings: Game/Install Partition
else if (ret == ++Idx)
{
if(DeviceHandler::Instance()->GetUSBHandle()->GetPartitionCount() < 2)
return MENU_NONE;
// Select the next valid partition, even if that's the same one
int fs_type = 0;
int ios = IOS_GetVersion();

View File

@ -48,6 +48,7 @@ void GameList::clear()
//! Clear memory of the vector completely
std::vector<struct discHdr *>().swap(FilteredList);
std::vector<struct discHdr>().swap(FullGameList);
std::vector<int>().swap(GamePartitionList);
}
struct discHdr * GameList::GetDiscHeader(const char * gameID) const
@ -78,8 +79,6 @@ int GameList::GetPartitionNumber(const u8 *gameID) const
void GameList::RemovePartition(int part)
{
wString filter(GameFilter);
for(u32 i = 0; i < GamePartitionList.size(); ++i)
{
if(GamePartitionList[i] == part)
@ -91,7 +90,10 @@ void GameList::RemovePartition(int part)
}
if(FullGameList.size() > 0)
{
wString filter(GameFilter);
FilterList(filter.c_str());
}
}
int GameList::InternalReadList(int part)

View File

@ -35,16 +35,12 @@ void WBFS_CloseDisc(wbfs_disc_t *disc)
{
if(!disc) return;
for(u32 i = 0; i < WbfsList.size(); ++i)
{
if(!WbfsList[i]) continue;
struct discHdr * header = (struct discHdr *) disc->header;
int part_num = gameList.GetPartitionNumber(header->id);
if(!VALID(part_num))
return;
if(WbfsList[i]->GetHDDHandle() == disc->p)
{
WbfsList[i]->CloseDisc(disc);
break;
}
}
WbfsList[part_num]->CloseDisc(disc);
}
s32 WBFS_Init(u32 device)
@ -117,7 +113,6 @@ bool WBFS_Close(int part_num)
if(!VALID(part_num))
return false;
WbfsList[part_num]->Close();
delete WbfsList[part_num];
WbfsList[part_num] = NULL;
@ -128,6 +123,8 @@ bool WBFS_Close(int part_num)
void WBFS_CloseAll()
{
gameList.clear();
for(u32 i = 0; i < WbfsList.size(); ++i)
WBFS_Close(i);
}
@ -159,7 +156,7 @@ s32 WBFS_CheckGame(u8 *discid)
{
int part_num = gameList.GetPartitionNumber(discid);
if(!VALID(part_num))
return -1;
return 0;
return WbfsList[part_num]->CheckGame(discid);
}

View File

@ -12,7 +12,7 @@ class Wbfs
{
public:
Wbfs(u32, u32, u32);
~Wbfs() { Close(); };
static s32 Init(u32);
s32 CheckGame(u8 *);
s32 GameSize(u8 *, f32 *);
@ -21,7 +21,7 @@ class Wbfs
virtual bool ShowFreeSpace(void);
virtual s32 Open() = 0;
virtual void Close() = 0;
virtual void Close() {};
virtual wbfs_disc_t* OpenDisc(u8 *discid) = 0;
virtual void CloseDisc(wbfs_disc_t *disc) = 0;
virtual s32 Format();

View File

@ -36,7 +36,7 @@ using namespace std;
static const char wbfs_fat_dir[] = "/wbfs";
static const char invalid_path[] = "/\\:|<>?*\"'";
static const u32 fat_sector_size = 512;
extern u32 hdd_sector_size;
Wbfs_Fat::Wbfs_Fat(u32 device, u32 lba, u32 size) :
Wbfs(device, lba, size), fat_hdr_list(NULL), fat_hdr_count(0)
@ -96,13 +96,13 @@ wbfs_disc_t* Wbfs_Fat::OpenDisc(u8 *discid)
return iso_file;
}
hdd = OpenPart(fname);
if (!hdd) return NULL;
wbfs_t *part = OpenPart(fname);
if (!part) return NULL;
wbfs_disc_t *disc = wbfs_open_disc(hdd, discid);
wbfs_disc_t *disc = wbfs_open_disc(part, discid);
if(!disc)
{
ClosePart(hdd);
ClosePart(part);
return NULL;
}
@ -318,12 +318,12 @@ u64 Wbfs_Fat::EstimateGameSize()
{
wbfs_t *part = NULL;
u64 size = (u64) 143432 * 2 * 0x8000ULL;
u32 n_sector = size / fat_sector_size;
u32 n_sector = size / hdd_sector_size;
u32 wii_sec_sz;
// init a temporary dummy part
// as a placeholder for wbfs_size_disc
part = wbfs_open_partition(nop_rw_sector, nop_rw_sector, NULL, fat_sector_size, n_sector, 0, 1);
part = wbfs_open_partition(nop_rw_sector, nop_rw_sector, NULL, hdd_sector_size, n_sector, 0, 1);
if (!part) return -1;
wii_sec_sz = part->wii_sec_sz;
@ -687,7 +687,7 @@ wbfs_t* Wbfs_Fat::OpenPart(char *fname)
ret = split_open(&split, fname);
if (ret) return NULL;
part = wbfs_open_partition(split_read_sector, nop_rw_sector, //readonly //split_write_sector,
&split, fat_sector_size, split.total_sec, 0, 0);
&split, hdd_sector_size, split.total_sec, 0, 0);
if (!part)
{
split_close(&split);
@ -769,7 +769,7 @@ wbfs_t* Wbfs_Fat::CreatePart(u8 *id, char *path)
return NULL;
}
part = wbfs_open_partition(split_read_sector, split_write_sector, &split, fat_sector_size, n_sector, 0, 1);
part = wbfs_open_partition(split_read_sector, split_write_sector, &split, hdd_sector_size, n_sector, 0, 1);
if (!part)
{
split_close(&split);

View File

@ -11,7 +11,6 @@ class Wbfs_Fat: public Wbfs
{
public:
Wbfs_Fat(u32 device, u32 lba, u32 size);
~Wbfs_Fat();
virtual s32 Open();
virtual void Close();

View File

@ -68,12 +68,12 @@ s32 __ReadUSB(void *fp, u32 lba, u32 count, void *iobuf)
u32 cnt = 0;
s32 ret;
u32 partition_offset = info->partition_lba + (lba-info->partition_lba)*(info->wbfs_sector_size/info->hdd_sector_size);
count *= info->wbfs_sector_size/info->hdd_sector_size;
count *= (info->wbfs_sector_size/info->hdd_sector_size);
/* Do reads */
while (cnt < count)
{
u8 *ptr = ((u8 *) iobuf) + (cnt * info->wbfs_sector_size);
u8 *ptr = ((u8 *) iobuf) + (cnt * info->hdd_sector_size);
u32 sectors = (count - cnt);
/* Read sectors is too big */
@ -96,12 +96,12 @@ s32 __WriteUSB(void *fp, u32 lba, u32 count, void *iobuf)
u32 cnt = 0;
s32 ret;
u32 partition_offset = info->partition_lba + (lba-info->partition_lba)*(info->wbfs_sector_size/info->hdd_sector_size);
count *= info->wbfs_sector_size/info->hdd_sector_size;
count *= (info->wbfs_sector_size/info->hdd_sector_size);
/* Do writes */
while (cnt < count)
{
u8 *ptr = ((u8 *) iobuf) + (cnt * info->wbfs_sector_size);
u8 *ptr = ((u8 *) iobuf) + (cnt * info->hdd_sector_size);
u32 sectors = (count - cnt);
/* Write sectors is too big */

View File

@ -4,19 +4,21 @@
#include "usbloader/wbfs.h"
#include "wbfs_rw.h"
#define MAX_WBFS_SECTORSIZE 4096
extern u32 hdd_sector_size;
s32 Wbfs_Wbfs::Open()
{
wbfs_t *part = NULL;
PartInfo.wbfs_sector_size = hdd_sector_size;
PartInfo.wbfs_sector_size = MAX_WBFS_SECTORSIZE;
PartInfo.hdd_sector_size = hdd_sector_size;
PartInfo.partition_lba = lba;
PartInfo.partition_num_sec = size;
u8 * buffer = (u8 *) malloc(hdd_sector_size);
memset(buffer, 0, hdd_sector_size);
u8 * buffer = (u8 *) malloc(MAX_WBFS_SECTORSIZE);
memset(buffer, 0, MAX_WBFS_SECTORSIZE);
if(readCallback(&PartInfo, lba, 1, buffer) < 0)
{
@ -31,10 +33,14 @@ s32 Wbfs_Wbfs::Open()
if (head.magic != wbfs_htonl(WBFS_MAGIC))
return -1;
/* Set correct sector values for wbfs read/write */
PartInfo.wbfs_sector_size = 1 << head.hd_sec_sz_s;
PartInfo.partition_num_sec = head.n_hd_sec;
/* Open partition */
part = wbfs_open_partition(readCallback, writeCallback, &PartInfo, 1 << head.hd_sec_sz_s, head.n_hd_sec, lba, 0);
part = wbfs_open_partition(readCallback, writeCallback, &PartInfo,
PartInfo.wbfs_sector_size, PartInfo.partition_num_sec,
lba, 0);
if (!part) return -1;
/* Close current hard disk */
@ -79,10 +85,18 @@ s32 Wbfs_Wbfs::Format()
HDD_Inf.partition_lba = lba;
HDD_Inf.partition_num_sec = size;
//! If size is over 500GB in sectors and sector size is 512
//! set 2048 as hdd sector size
if(size > 1048576000 && hdd_sector_size == 512)
{
HDD_Inf.wbfs_sector_size = 2048;
HDD_Inf.partition_num_sec = size/(2048/hdd_sector_size);
}
wbfs_t *partition = NULL;
/* Reset partition */
partition = wbfs_open_partition(readCallback, writeCallback, &PartInfo, hdd_sector_size, size, lba, 1);
partition = wbfs_open_partition(readCallback, writeCallback, &HDD_Inf, HDD_Inf.wbfs_sector_size, HDD_Inf.partition_num_sec, lba, 1);
if (!partition) return -1;
/* Free memory */