*Bit code clean up in the fat mounter - no change here

*Changed the image resource manager to only be used for images from memory (embedded images) and not those from a device. It used the same cover/disc image for multiple game.
This commit is contained in:
dimok321 2010-09-29 17:47:51 +00:00
parent 71a95a57d7
commit ac56e5ec10
4 changed files with 45 additions and 108 deletions

View File

@ -2,8 +2,8 @@
<app version="1">
<name> USB Loader GX</name>
<coder>USB Loader GX Team</coder>
<version>1.0 r981</version>
<release_date>201009282041</release_date>
<version>1.0 r982</version>
<release_date>201009291737</release_date>
<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.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -27,7 +27,6 @@
/* Disc interfaces */
extern const DISC_INTERFACE __io_sdhc;
void _FAT_mem_init();
extern sec_t _FAT_startSector;
extern s32 wbfsDev;
@ -46,62 +45,41 @@ sec_t fs_ntfs_sec = 0;
int USBDevice_Init()
{
#ifdef DEBUG_FAT
gprintf("USBDevice_Init()");
#endif
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
//right now mounts first FAT-partition
//try first mount with cIOS
// if (!fatMount("USB", &__io_wiiums, 0, CACHE, SECTORS)) {
// //try now mount with libogc
if (!fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
{
#ifdef DEBUG_FAT
gprintf(":-1\n");
#endif
// libogc usbstorage
if(!fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS))
return -1;
}
// }
fat_usb_mount = 1;
fat_usb_sec = _FAT_startSector;
#ifdef DEBUG_FAT
gprintf(":0\n");
#endif
return 0;
}
void USBDevice_deInit()
{
#ifdef DEBUG_FAT
gprintf("USBDevice_deInit(): ");
#endif
//closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/");
fat_usb_mount = 0;
fat_usb_sec = 0;
#ifdef DEBUG_FAT
gprintf("ok\n");
#endif
}
int WBFSDevice_Init(u32 sector)
{
//closing all open Files write back the cache and then shutdown em!
fatUnmount("WBFS:/");
//right now mounts first FAT-partition
//try first mount with cIOS
// if (!fatMount("WBFS", &__io_wiiums, 0, CACHE, SECTORS)) {
//try now mount with libogc
if (!fatMount("WBFS", &__io_usbstorage2, 0, CACHE, SECTORS))
{
return -1;
}
// }
fat_wbfs_mount = 1;
fat_wbfs_sec = _FAT_startSector;
@ -115,7 +93,6 @@ int WBFSDevice_Init(u32 sector)
void WBFSDevice_deInit()
{
//closing all open Files write back the cache and then shutdown em!
fatUnmount("WBFS:/");
fat_wbfs_mount = 0;
@ -129,94 +106,52 @@ int isInserted(const char *path)
return __io_sdhc.isInserted() || __io_wiisd.isInserted();
}
static u8 sdIsInited = 0;
int SDCard_Init()
{
#ifdef DEBUG_FAT
gprintf("SDCard_Init()");
#endif
//closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/");
//right now mounts first FAT-partition
if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS))
{
fat_sd_mount = MOUNT_SD;
fat_sd_sec = _FAT_startSector;
sdIsInited = 1;
#ifdef DEBUG_FAT
gprintf(":1\n");
#endif
return 1;
}
else if (fatMount("SD", &__io_sdhc, 0, CACHE, SDHC_SECTOR_SIZE))
{
fat_sd_mount = MOUNT_SDHC;
fat_sd_sec = _FAT_startSector;
sdIsInited = 1;
#ifdef DEBUG_FAT
gprintf(":1\n");
#endif
return 1;
}
#ifdef DEBUG_FAT
gprintf(":-1\n");
#endif
return -1;
}
void SDCard_deInit()
{
#ifdef DEBUG_FAT
gprintf("SDCard_deInit( %d ): ", sdIsInited);
#endif
//closing all open Files write back the cache and then shutdown em!
if (sdIsInited)
{
fatUnmount("SD:/");
fat_sd_mount = MOUNT_NONE;
fat_sd_sec = 0;
sdIsInited = 0;
}
#ifdef DEBUG_FAT
gprintf("ok\n");
#endif
}
void ntfsInit();
s32 MountNTFS(u32 sector)
{
s32 ret;
if (fs_ntfs_mount) return 0;
ntfsInit(); // Call ntfs init here, to prevent locale resets
// ntfsInit resets locale settings
// which breaks unicode in console
// so we change it back to C-UTF-8
setlocale(LC_CTYPE, "C-UTF-8");
setlocale(LC_MESSAGES, "C-UTF-8");
if (fs_ntfs_mount)
return 0;
if (wbfsDev == WBFS_DEVICE_USB)
{
/* Initialize WBFS interface */
// if (!__io_wiiums.startup()) {
ret = __io_usbstorage2.startup();
if (!ret)
{
return -1;
}
// }
/* Mount device */
// if (!ntfsMount("NTFS", &__io_wiiums, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER)) {
ret = ntfsMount("NTFS", &__io_usbstorage2, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER);
if (!ret)
{
ret = ntfsMount("NTFS", &__io_usbstorage, sector, CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER);
if(!ret)
return -2;
}
// }
}
else if (wbfsDev == WBFS_DEVICE_SDHC)
{
@ -234,8 +169,14 @@ s32 MountNTFS(u32 sector)
}
}
// ntfsInit() resets locals
// which breaks unicode in console
// so we change it back to C-UTF-8
setlocale(LC_CTYPE, "C-UTF-8");
setlocale(LC_MESSAGES, "C-UTF-8");
fs_ntfs_mount = 1;
fs_ntfs_sec = sector; //_FAT_startSector;
fs_ntfs_sec = sector;
return 0;
}

View File

@ -60,7 +60,27 @@ GuiImageData::GuiImageData(const u8 * img, int imgSize)
height = 0;
format = GX_TF_RGBA8;
ImageData * Image = ResourceManager::GetImageData(img);
if(Image != NULL && Image->data != NULL)
{
data = Image->data;
width = Image->width;
height = Image->height;
format = Image->format;
return;
}
LoadImage(img, imgSize);
if(data)
{
ImageData NewImage;
NewImage.data = data;
NewImage.width = width;
NewImage.height = height;
NewImage.format = format;
ResourceManager::AddImageData(img, NewImage);
}
}
/**
@ -77,16 +97,6 @@ void GuiImageData::LoadImage(const u8 * img, int imgSize)
if(!img)
return;
ImageData * Image = ResourceManager::GetImageData(img);
if(Image != NULL && Image->data != NULL)
{
data = Image->data;
width = Image->width;
height = Image->height;
format = Image->format;
return;
}
else if (imgSize < 8)
{
return;
@ -116,13 +126,6 @@ void GuiImageData::LoadImage(const u8 * img, int imgSize)
// IMAGE_TPL
LoadTPL(img, imgSize);
}
ImageData NewImage;
NewImage.data = data;
NewImage.width = width;
NewImage.height = height;
NewImage.format = format;
ResourceManager::AddImageData(img, NewImage);
}
void GuiImageData::LoadPNG(const u8 *img, int imgSize)

View File

@ -181,17 +181,10 @@ s32 USBStorage2_ReadSectors(u32 sector, u32 numSectors, void *buffer)
if (!mem2_ptr)
mem2_ptr = (u8 *) MEM2_alloc(sector_size * MAX_BUFFER_SECTORS);
/* MEM1 buffer */
// Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
if (!isMEM2Buffer(buffer))
{
/* Allocate memory */
buf = mem2_ptr;
if (!buf) return IPC_ENOMEM;
}
// Do not read more than 256 sectors at once and create a mem overflow!
if(buf != buffer)
{
s32 read_size;
s32 sectors_done = 0;
@ -236,7 +229,7 @@ s32 USBStorage2_WriteSectors(u32 sector, u32 numSectors, const void *buffer)
/* MEM1 buffer */
if (!isMEM2Buffer(buffer))
{
// Do not read more than 256 sectors at once and create a mem overflow!
// Do not read more than MAX_BUFFER_SECTORS sectors at once and create a mem overflow!
buf = mem2_ptr;
s32 write_size;
s32 sectors_done = 0;