mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-04 18:45:05 +01:00
e8f5ab07bd
* Fixed bug in http.c (where realloc *might* choose another address, thanks Dr. Clipper) * Added support to /wbfs/Game Title [GAMEID].wbfs files (thanks oggzee) * Fixed bug in cfg_cleanup when switching partitions * Added BGM class again (for playing background music, requested by dimok) * Added settings for background music again * Fixed bug in MEM2 class (returning an invalid handle when no memory could be allocated, thanks to dimok) * Updated DIP module to OpenDIP (report bugs with this one if you've found them, but report them here: http://github.com/spacemanspiff/odip-plugin) * Added initial code for cios 222 rev5 (THIS DOES NOT WORK YET! DON'T FILE BUGS ON THIS ONE!) * Added fatffs module by Hermes and Waninkoko (THIS DOES NOT WORK YET! DON'T FILE BUGS ON THIS ONE!) * Fixed bug in Settings, which resulted in a crash when the partition was changed. * Added caching for gamelist entries, so switching between different screens/sort options/display modes should be faster * Changed defines in ehc_module, in order to prevent clashes with new defines in rev5
157 lines
2.8 KiB
C++
157 lines
2.8 KiB
C++
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <malloc.h>
|
|
#include <ogcsys.h>
|
|
#include <errno.h>
|
|
|
|
#include "usbloader/sdhc.h"
|
|
#include "usbloader/usbstorage.h"
|
|
#include "fatmounter.h"
|
|
|
|
#include "wbfs_base.h"
|
|
|
|
rw_sector_callback_t Wbfs::readCallback = NULL;
|
|
rw_sector_callback_t Wbfs::writeCallback = NULL;
|
|
s32 Wbfs::done = -1;
|
|
s32 Wbfs::total = -1;
|
|
u32 Wbfs::nb_sectors;
|
|
u32 Wbfs::sector_size;
|
|
|
|
Wbfs::Wbfs(u32 device, u32 lba, u32 size) : hdd(NULL)
|
|
{
|
|
this->device = device;
|
|
this->lba = lba;
|
|
this->size = size;
|
|
}
|
|
|
|
void Wbfs::GetProgressValue(s32 * d, s32 * m) {
|
|
*d = done;
|
|
*m = total;
|
|
}
|
|
|
|
s32 Wbfs::Init(u32 device)
|
|
{
|
|
s32 ret;
|
|
|
|
switch (device) {
|
|
case WBFS_DEVICE_USB:
|
|
/* Initialize USB storage */
|
|
ret = USBStorage_Init();
|
|
if (ret >= 0) {
|
|
/* Setup callbacks */
|
|
readCallback = __ReadUSB;
|
|
writeCallback = __WriteUSB;
|
|
/* Device info */
|
|
/* Get USB capacity */
|
|
nb_sectors = USBStorage_GetCapacity(§or_size);
|
|
if (!nb_sectors)
|
|
return -1;
|
|
} else
|
|
return ret;
|
|
break;
|
|
case WBFS_DEVICE_SDHC:
|
|
/* Initialize SDHC */
|
|
ret = SDHC_Init();
|
|
|
|
if (ret) {
|
|
/* Setup callbacks */
|
|
readCallback = __ReadSDHC;
|
|
writeCallback = __WriteSDHC;
|
|
|
|
/* Device info */
|
|
nb_sectors = 0;
|
|
sector_size = SDHC_SECTOR_SIZE;
|
|
} else
|
|
return -1;
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Wbfs::Close()
|
|
{
|
|
if (hdd) {
|
|
wbfs_close(hdd);
|
|
hdd = NULL;
|
|
}
|
|
|
|
WBFSDevice_deInit();
|
|
}
|
|
|
|
// 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)
|
|
{
|
|
wbfs_disc_t *disc = NULL;
|
|
|
|
u32 sectors;
|
|
|
|
/* Open disc */
|
|
disc = OpenDisc(discid);
|
|
if (!disc)
|
|
return -2;
|
|
|
|
/* Get game size in sectors */
|
|
sectors = wbfs_sector_used(disc->p, disc->header);
|
|
|
|
/* Copy value */
|
|
*size = (disc->p->wbfs_sec_sz / GB_SIZE) * sectors;
|
|
|
|
/* Close disc */
|
|
CloseDisc(disc);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Wbfs::Spinner(s32 x, s32 max)
|
|
{
|
|
done = x;
|
|
total = max;
|
|
}
|
|
|
|
wbfs_t *Wbfs::GetHddInfo()
|
|
{
|
|
return hdd;
|
|
}
|
|
|
|
bool Wbfs::Mounted()
|
|
{
|
|
return hdd == NULL;
|
|
}
|
|
|
|
int Wbfs::GetFragList(u8 *id)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int Wbfs::GetFragList(char *filename, _frag_append_t append_fragment, FragList *)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
bool Wbfs::ShowFreeSpace(void)
|
|
{
|
|
return true;
|
|
}
|