mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-05 19:15:07 +01:00
037edbe7ea
*Fixed freeze in theme menu when its empty *Optimized the game list loading on fat/ntfs/ext. This should speed up the loading process. *Added cache of game titles. This will speed up the startup after the cache file is written (in other words on second start of this rev). A TitlesCache.bin will be created in the same path as the wiitdb.xml for this. This should especial speed up the startup of fat/ntfs/ext partitions by a lot if no sub folders with the game titles are used, like GAMEID.wbfs only. That must have been painfully slow before on a lot of games. Should be at about the same speed as with sub folders now. I would still recommend to use sub folders. *Removed wiilight (disc slot) blinking when switching USB port on Hermes cIOSes (thanks rodries) *Added the ehcmodule sources from rodries to the branches *Updated language files
99 lines
1.8 KiB
C++
99 lines
1.8 KiB
C++
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <malloc.h>
|
|
#include <ogcsys.h>
|
|
#include <errno.h>
|
|
|
|
#include "Controls/DeviceHandler.hpp"
|
|
#include "usbloader/sdhc.h"
|
|
#include "usbloader/usbstorage2.h"
|
|
#include "usbloader/wbfs.h"
|
|
#include "wbfs_rw.h"
|
|
|
|
#include "wbfs_base.h"
|
|
|
|
Wbfs::Wbfs(u32 l, u32 s, u32 part)
|
|
: hdd(NULL), lba(l), size(s), partition(part)
|
|
{
|
|
}
|
|
|
|
s32 Wbfs::Init(u32 device)
|
|
{
|
|
s32 ret;
|
|
const DISC_INTERFACE * handle = DeviceHandler::GetUSBInterface();
|
|
|
|
switch (WBFS_DEVICE_USB)
|
|
{
|
|
case WBFS_DEVICE_USB:
|
|
/* Initialize USB storage */
|
|
ret = handle->startup();
|
|
if (ret)
|
|
{
|
|
currentHandle = handle;
|
|
/* Setup callbacks */
|
|
readCallback = __ReadUSB;
|
|
writeCallback = __WriteUSB;
|
|
}
|
|
else
|
|
return -1;
|
|
break;
|
|
case WBFS_DEVICE_SDHC:
|
|
/* Initialize SDHC */
|
|
ret = SDHC_Init();
|
|
|
|
if (ret)
|
|
{
|
|
/* Setup callbacks */
|
|
readCallback = __ReadSDHC;
|
|
writeCallback = __WriteSDHC;
|
|
}
|
|
else return -1;
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
// Default behavior: can't format
|
|
s32 Wbfs::Format()
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
s32 Wbfs::CheckGame(u8 *discid)
|
|
{
|
|
wbfs_disc_t *disc = NULL;
|
|
|
|
/* Try to open game disc */
|
|
disc = OpenDisc(discid);
|
|
if (disc)
|
|
{
|
|
/* Close disc */
|
|
CloseDisc(disc);
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
s32 Wbfs::GameSize(u8 *discid, f32 *size)
|
|
{
|
|
if(!discid) return 0;
|
|
|
|
/* Open disc */
|
|
wbfs_disc_t *disc = OpenDisc(discid);
|
|
if (!disc) return -2;
|
|
|
|
u32 sectors = wbfs_disc_sector_used(disc);
|
|
|
|
/* Copy value */
|
|
if(size)
|
|
*size = (disc->p->wbfs_sec_sz / GB_SIZE) * sectors;
|
|
|
|
/* Close disc */
|
|
CloseDisc(disc);
|
|
|
|
return 0;
|
|
}
|