mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-16 00:15:08 +01:00
*added loading screen
*Removed the console loading screen (no more console at all) *Complete rework of device handle. You need to reset all your custom paths for this rev. *Support for writing images/settings/... on any writable partition (FAT/NTFS/EXT). (Theoretically you can run the loader from NTFS only without the need of any other partition or SD if run from new forwarder channel, for example) *Support for Primary/Logical partitions and GUID Partition Table (GPT) Forwarder Channel in last revision was not using IOS58 (not sure about AHBPROT) Here a corrected version (thx to Cyan): http://www.mediafire.com/?a9y3ywqcm4v3lz3
This commit is contained in:
parent
01bef0b2c4
commit
7bccfd2b17
1
Makefile
1
Makefile
@ -21,6 +21,7 @@ SOURCES := source \
|
||||
source/images \
|
||||
source/fonts \
|
||||
source/sounds \
|
||||
source/Controls \
|
||||
source/system \
|
||||
source/libs/libwbfs \
|
||||
source/language \
|
||||
|
File diff suppressed because one or more lines are too long
2
gui.pnps
2
gui.pnps
@ -1 +1 @@
|
||||
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\utils" x="false"></e><e p="gui\source\SoundOperations" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\libs" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\system" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\FileOperations" x="false"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\ImageOperations" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>
|
||||
<pd><ViewState><e p="gui\source\Controls" x="false"></e><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\utils" x="false"></e><e p="gui\source\SoundOperations" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\libs" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\system" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\FileOperations" x="false"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\ImageOperations" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>
|
240
source/Controls/DeviceHandler.cpp
Normal file
240
source/Controls/DeviceHandler.cpp
Normal file
@ -0,0 +1,240 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ogc/mutex.h>
|
||||
#include <ogc/system.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <sdcard/gcsd.h>
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "DeviceHandler.hpp"
|
||||
#include "usbloader/wbfs.h"
|
||||
|
||||
DeviceHandler * DeviceHandler::instance = NULL;
|
||||
|
||||
DeviceHandler::~DeviceHandler()
|
||||
{
|
||||
UnMountAll();
|
||||
}
|
||||
|
||||
DeviceHandler * DeviceHandler::Instance()
|
||||
{
|
||||
if (instance == NULL)
|
||||
{
|
||||
instance = new DeviceHandler();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
void DeviceHandler::DestroyInstance()
|
||||
{
|
||||
if(instance)
|
||||
{
|
||||
delete instance;
|
||||
}
|
||||
instance = NULL;
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountAll()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
for(u32 i = SD; i < MAXDEVICES; i++)
|
||||
{
|
||||
if(Mount(i))
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountAll()
|
||||
{
|
||||
for(u32 i = SD; i < MAXDEVICES; i++)
|
||||
UnMount(i);
|
||||
|
||||
if(sd)
|
||||
delete sd;
|
||||
if(usb)
|
||||
delete usb;
|
||||
|
||||
sd = NULL;
|
||||
usb = NULL;
|
||||
}
|
||||
|
||||
bool DeviceHandler::Mount(int dev)
|
||||
{
|
||||
if(dev == SD)
|
||||
return MountSD();
|
||||
|
||||
else if(dev >= USB1 && dev <= USB8)
|
||||
return MountUSB(dev-USB1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceHandler::IsInserted(int dev)
|
||||
{
|
||||
if(dev == SD)
|
||||
return SD_Inserted() && sd->IsMounted(0);
|
||||
|
||||
else if(dev >= USB1 && dev <= USB8)
|
||||
return USB_Inserted() && usb->IsMounted(dev-USB1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMount(int dev)
|
||||
{
|
||||
if(dev == SD)
|
||||
UnMountSD();
|
||||
|
||||
else if(dev >= USB1 && dev <= USB8)
|
||||
UnMountUSB(dev-USB1);
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountSD()
|
||||
{
|
||||
if(!sd)
|
||||
sd = new PartitionHandle(&__io_wiisd);
|
||||
|
||||
if(sd->GetPartitionCount() < 1)
|
||||
{
|
||||
delete sd;
|
||||
sd = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Mount only one SD Partition
|
||||
return sd->Mount(0, DeviceName[SD]);
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountUSB(int pos)
|
||||
{
|
||||
if(!usb)
|
||||
usb = new PartitionHandle(&__io_usbstorage2);
|
||||
|
||||
if(usb->GetPartitionCount() < 1)
|
||||
{
|
||||
delete usb;
|
||||
usb = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(pos >= usb->GetPartitionCount())
|
||||
return false;
|
||||
|
||||
return usb->Mount(pos, DeviceName[USB1+pos]);
|
||||
}
|
||||
|
||||
bool DeviceHandler::MountAllUSB()
|
||||
{
|
||||
if(!usb)
|
||||
usb = new PartitionHandle(&__io_usbstorage2);
|
||||
|
||||
bool result = false;
|
||||
|
||||
for(int i = 0; i < usb->GetPartitionCount(); i++)
|
||||
{
|
||||
if(MountUSB(i))
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountUSB(int pos)
|
||||
{
|
||||
if(!usb)
|
||||
return;
|
||||
|
||||
if(pos >= usb->GetPartitionCount())
|
||||
return;
|
||||
|
||||
usb->UnMount(pos);
|
||||
}
|
||||
|
||||
void DeviceHandler::UnMountAllUSB()
|
||||
{
|
||||
if(!usb)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < usb->GetPartitionCount(); i++)
|
||||
usb->UnMount(i);
|
||||
|
||||
delete usb;
|
||||
usb = NULL;
|
||||
}
|
||||
|
||||
int DeviceHandler::PathToDriveType(const char * path)
|
||||
{
|
||||
if(!path)
|
||||
return -1;
|
||||
|
||||
for(int i = SD; i < MAXDEVICES; i++)
|
||||
{
|
||||
if(strncmp(path, DeviceName[i], strlen(DeviceName[i])) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char * DeviceHandler::GetFSName(int dev)
|
||||
{
|
||||
if(dev == SD && DeviceHandler::instance->sd)
|
||||
{
|
||||
return DeviceHandler::instance->sd->GetFSName(0);
|
||||
}
|
||||
else if(dev >= USB1 && dev <= USB8 && DeviceHandler::instance->usb)
|
||||
{
|
||||
return DeviceHandler::instance->usb->GetFSName(dev-USB1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int DeviceHandler::GetUSBFilesystemType(int partition)
|
||||
{
|
||||
if(!instance)
|
||||
return -1;
|
||||
|
||||
PartitionHandle * usbHandle = instance->GetUSBHandle();
|
||||
|
||||
const char * FSName = usbHandle->GetFSName(partition);
|
||||
|
||||
if(strncmp(FSName, "WBFS", 4) == 0)
|
||||
return PART_FS_WBFS;
|
||||
else if(strncmp(FSName, "FAT", 3) == 0)
|
||||
return PART_FS_FAT;
|
||||
else if(strncmp(FSName, "NTFS", 4) == 0)
|
||||
return PART_FS_NTFS;
|
||||
else if(strncmp(FSName, "LINUX", 4) == 0)
|
||||
return PART_FS_EXT;
|
||||
|
||||
return -1;
|
||||
}
|
97
source/Controls/DeviceHandler.hpp
Normal file
97
source/Controls/DeviceHandler.hpp
Normal file
@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#ifndef DEVICE_HANDLER_HPP_
|
||||
#define DEVICE_HANDLER_HPP_
|
||||
|
||||
#include "PartitionHandle.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SD = 0,
|
||||
USB1,
|
||||
USB2,
|
||||
USB3,
|
||||
USB4,
|
||||
USB5,
|
||||
USB6,
|
||||
USB7,
|
||||
USB8,
|
||||
MAXDEVICES
|
||||
};
|
||||
|
||||
const char DeviceName[MAXDEVICES][6] =
|
||||
{
|
||||
"sd",
|
||||
"usb1",
|
||||
"usb2",
|
||||
"usb3",
|
||||
"usb4",
|
||||
"usb5",
|
||||
"usb6",
|
||||
"usb7",
|
||||
"usb8",
|
||||
};
|
||||
|
||||
class DeviceHandler
|
||||
{
|
||||
public:
|
||||
static DeviceHandler * Instance();
|
||||
static void DestroyInstance();
|
||||
|
||||
bool MountAll();
|
||||
void UnMountAll();
|
||||
bool Mount(int dev);
|
||||
bool IsInserted(int dev);
|
||||
void UnMount(int dev);
|
||||
|
||||
//! Individual Mounts/UnMounts...
|
||||
bool MountSD();
|
||||
bool MountAllUSB();
|
||||
bool MountUSB(int part);
|
||||
bool SD_Inserted() { if(sd) return sd->IsInserted(); return false; };
|
||||
bool USB_Inserted() { if(usb) return usb->IsInserted(); return false; };
|
||||
void UnMountSD() { if(sd) delete sd; sd = NULL; };
|
||||
void UnMountUSB(int pos);
|
||||
void UnMountAllUSB();
|
||||
PartitionHandle * GetSDHandle() { return sd; };
|
||||
PartitionHandle * GetUSBHandle() { return usb; };
|
||||
static int GetUSBFilesystemType(int part);
|
||||
static int PathToDriveType(const char * path);
|
||||
static const char * GetFSName(int dev);
|
||||
static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); };
|
||||
private:
|
||||
DeviceHandler() : sd(0), usb(0) { };
|
||||
~DeviceHandler();
|
||||
|
||||
static DeviceHandler *instance;
|
||||
|
||||
PartitionHandle * sd;
|
||||
PartitionHandle * gca;
|
||||
PartitionHandle * gcb;
|
||||
PartitionHandle * usb;
|
||||
};
|
||||
|
||||
#endif
|
333
source/Controls/PartitionHandle.cpp
Normal file
333
source/Controls/PartitionHandle.cpp
Normal file
@ -0,0 +1,333 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <fat.h>
|
||||
#include <ntfs.h>
|
||||
#include <ext2.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include "libs/libwbfs/libwbfs.h"
|
||||
#include "utils/uncompress.h"
|
||||
#include "PartitionHandle.h"
|
||||
|
||||
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ extended partition */
|
||||
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
||||
|
||||
#define CACHE 32
|
||||
#define SECTORS 64
|
||||
|
||||
static inline const char * PartFromType(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0x00: return "Unused";
|
||||
case 0x01: return "FAT12";
|
||||
case 0x04: return "FAT16";
|
||||
case 0x05: return "Extended";
|
||||
case 0x06: return "FAT16";
|
||||
case 0x07: return "NTFS";
|
||||
case 0x0b: return "FAT32";
|
||||
case 0x0c: return "FAT32";
|
||||
case 0x0e: return "FAT16";
|
||||
case 0x0f: return "Extended";
|
||||
case 0x82: return "LxSWP";
|
||||
case 0x83: return "LINUX";
|
||||
case 0x8e: return "LxLVM";
|
||||
case 0xa8: return "OSX";
|
||||
case 0xab: return "OSXBT";
|
||||
case 0xaf: return "OSXHF";
|
||||
case 0xbf: return "WBFS";
|
||||
case 0xe8: return "LUKS";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
PartitionHandle::PartitionHandle(const DISC_INTERFACE *discio)
|
||||
{
|
||||
interface = discio;
|
||||
|
||||
// Sanity check
|
||||
if (!interface)
|
||||
return;
|
||||
|
||||
// Start the device and check that it is inserted
|
||||
if (!interface->startup())
|
||||
return;
|
||||
|
||||
if (!interface->isInserted())
|
||||
return;
|
||||
|
||||
FindPartitions();
|
||||
}
|
||||
|
||||
PartitionHandle::~PartitionHandle()
|
||||
{
|
||||
UnMountAll();
|
||||
|
||||
//shutdown device
|
||||
interface->shutdown();
|
||||
}
|
||||
|
||||
bool PartitionHandle::IsMounted(int pos)
|
||||
{
|
||||
if(pos < 0 || pos >= (int) MountNameList.size())
|
||||
return false;
|
||||
|
||||
if(MountNameList[pos].size() == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartitionHandle::Mount(int pos, const char * name)
|
||||
{
|
||||
if(!valid(pos))
|
||||
return false;
|
||||
|
||||
if(!name)
|
||||
return false;
|
||||
|
||||
UnMount(pos);
|
||||
|
||||
if(pos >= (int) MountNameList.size())
|
||||
MountNameList.resize(GetPartitionCount());
|
||||
|
||||
MountNameList[pos] = name;
|
||||
|
||||
if(strncmp(GetFSName(pos), "FAT", 3) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
|
||||
{
|
||||
if (fatMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS))
|
||||
{
|
||||
if(strcmp(GetFSName(pos), "GUID-Entry") == 0)
|
||||
PartitionList[pos].FSName = "FAT";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(strncmp(GetFSName(pos), "NTFS", 4) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
|
||||
{
|
||||
if(ntfsMount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER))
|
||||
{
|
||||
PartitionList[pos].FSName = "NTFS";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(strncmp(GetFSName(pos), "LINUX", 5) == 0 || strcmp(GetFSName(pos), "GUID-Entry") == 0)
|
||||
{
|
||||
if(ext2Mount(MountNameList[pos].c_str(), interface, GetLBAStart(pos), CACHE, SECTORS, EXT2_FLAG_DEFAULT))
|
||||
{
|
||||
PartitionList[pos].FSName = "LINUX";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
MountNameList[pos].clear();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PartitionHandle::UnMount(int pos)
|
||||
{
|
||||
if(!interface)
|
||||
return;
|
||||
|
||||
if(pos >= (int) MountNameList.size())
|
||||
return;
|
||||
|
||||
if(MountNameList[pos].size() == 0)
|
||||
return;
|
||||
|
||||
char DeviceSyn[20];
|
||||
snprintf(DeviceSyn, sizeof(DeviceSyn), "%s:", MountNameList[pos].c_str());
|
||||
|
||||
//closing all open Files write back the cache
|
||||
fatUnmount(DeviceSyn);
|
||||
//closing all open Files write back the cache
|
||||
ntfsUnmount(DeviceSyn, true);
|
||||
//closing all open Files write back the cache
|
||||
ext2Unmount(DeviceSyn);
|
||||
//Remove name from list
|
||||
MountNameList[pos].clear();
|
||||
}
|
||||
|
||||
bool PartitionHandle::IsExisting(u64 lba)
|
||||
{
|
||||
for(u32 i = 0; i < PartitionList.size(); ++i)
|
||||
{
|
||||
if(PartitionList[i].LBA_Start == lba)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int PartitionHandle::FindPartitions()
|
||||
{
|
||||
MASTER_BOOT_RECORD mbr;
|
||||
|
||||
// Read the first sector on the device
|
||||
if (!interface->readSectors(0, 1, &mbr))
|
||||
return -1;
|
||||
|
||||
// If this is the devices master boot record
|
||||
if (mbr.signature != MBR_SIGNATURE)
|
||||
return -1;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
PARTITION_RECORD * partition = (PARTITION_RECORD *) &mbr.partitions[i];
|
||||
|
||||
if(partition->type == PARTITION_TYPE_GPT)
|
||||
{
|
||||
int ret = CheckGPT(i);
|
||||
if(ret == 0) // if it's a GPT we don't need to go on looking through the mbr anymore
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(partition->type == PARTITION_TYPE_DOS33_EXTENDED || partition->type == PARTITION_TYPE_WIN95_EXTENDED)
|
||||
{
|
||||
CheckEBR(i, le32(partition->lba_start));
|
||||
continue;
|
||||
}
|
||||
|
||||
if(le32(partition->block_count) > 0 && !IsExisting(le32(partition->lba_start)))
|
||||
{
|
||||
AddPartition(PartFromType(partition->type), le32(partition->lba_start),
|
||||
le32(partition->block_count), (partition->status == PARTITION_BOOTABLE),
|
||||
partition->type, i);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
||||
{
|
||||
EXTENDED_BOOT_RECORD ebr;
|
||||
sec_t next_erb_lba = 0;
|
||||
|
||||
do
|
||||
{
|
||||
// Read and validate the extended boot record
|
||||
if (!interface->readSectors(ebr_lba + next_erb_lba, 1, &ebr))
|
||||
return;
|
||||
|
||||
if (ebr.signature != EBR_SIGNATURE)
|
||||
return;
|
||||
|
||||
if(le32(ebr.partition.block_count) > 0 && !IsExisting(ebr_lba + next_erb_lba + le32(ebr.partition.lba_start)))
|
||||
{
|
||||
AddPartition(PartFromType(ebr.partition.type), ebr_lba + next_erb_lba + le32(ebr.partition.lba_start),
|
||||
le32(ebr.partition.block_count), (ebr.partition.status == PARTITION_BOOTABLE),
|
||||
ebr.partition.type, PartNum);
|
||||
}
|
||||
// Get the start sector of the current partition
|
||||
// and the next extended boot record in the chain
|
||||
next_erb_lba = le32(ebr.next_ebr.lba_start);
|
||||
}
|
||||
while(next_erb_lba > 0);
|
||||
}
|
||||
|
||||
static const u8 TYPE_UNUSED[16] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
static const u8 TYPE_BIOS[16] = { 0x48,0x61,0x68,0x21,0x49,0x64,0x6F,0x6E,0x74,0x4E,0x65,0x65,0x64,0x45,0x46,0x49 };
|
||||
static const u8 TYPE_LINUX_MS_BASIC_DATA[16] = { 0xA2,0xA0,0xD0,0xEB,0xE5,0xB9,0x33,0x44,0x87,0xC0,0x68,0xB6,0xB7,0x26,0x99,0xC7 };
|
||||
|
||||
int PartitionHandle::CheckGPT(u8 PartNum)
|
||||
{
|
||||
GPT_HEADER gpt_header;
|
||||
|
||||
// Read and validate the extended boot record
|
||||
if (!interface->readSectors(1, 1, &gpt_header))
|
||||
return -1;
|
||||
|
||||
if(strncmp(gpt_header.magic, "EFI PART", 8) != 0)
|
||||
return -1;
|
||||
|
||||
gpt_header.part_table_lba = le64(gpt_header.part_table_lba);
|
||||
gpt_header.part_entries = le32(gpt_header.part_entries);
|
||||
gpt_header.part_entry_size = le32(gpt_header.part_entry_size);
|
||||
gpt_header.part_entry_checksum = le32(gpt_header.part_entry_checksum);
|
||||
|
||||
u8 * sector_buf = new u8[BYTES_PER_SECTOR];
|
||||
|
||||
u64 next_lba = gpt_header.part_table_lba;
|
||||
|
||||
for(u32 i = 0; i < gpt_header.part_entries; ++i)
|
||||
{
|
||||
if (!interface->readSectors(next_lba, 1, sector_buf))
|
||||
break;
|
||||
|
||||
for(u32 n = 0; n < BYTES_PER_SECTOR/gpt_header.part_entry_size; ++n, ++i)
|
||||
{
|
||||
GUID_PART_ENTRY * part_entry = (GUID_PART_ENTRY *) (sector_buf+gpt_header.part_entry_size*n);
|
||||
|
||||
if(memcmp(part_entry->part_type_guid, TYPE_UNUSED, 16) == 0)
|
||||
continue;
|
||||
|
||||
if(IsExisting(le64(part_entry->part_first_lba)))
|
||||
continue;
|
||||
|
||||
bool bootable = (memcmp(part_entry->part_type_guid, TYPE_BIOS, 16) == 0);
|
||||
|
||||
AddPartition("GUID-Entry", le64(part_entry->part_first_lba), le64(part_entry->part_last_lba), bootable, PARTITION_TYPE_GPT, PartNum);
|
||||
}
|
||||
|
||||
next_lba++;
|
||||
}
|
||||
|
||||
delete [] sector_buf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PartitionHandle::AddPartition(const char * name, u64 lba_start, u64 sec_count, bool bootable, u8 part_type, u8 part_num)
|
||||
{
|
||||
char buffer[BYTES_PER_SECTOR];
|
||||
|
||||
if (!interface->readSectors(lba_start, 1, buffer))
|
||||
return;
|
||||
|
||||
wbfs_head_t *head = (wbfs_head_t *) buffer;
|
||||
|
||||
if (head->magic == wbfs_htonl(WBFS_MAGIC))
|
||||
{
|
||||
name = "WBFS";
|
||||
part_type = 0xBF; //Override partition type on WBFS
|
||||
}
|
||||
|
||||
PartitionFS PartitionEntrie;
|
||||
PartitionEntrie.FSName = name;
|
||||
PartitionEntrie.LBA_Start = lba_start;
|
||||
PartitionEntrie.SecCount = sec_count;
|
||||
PartitionEntrie.Bootable = bootable;
|
||||
PartitionEntrie.PartitionType = part_type;
|
||||
PartitionEntrie.PartitionNum = part_num;
|
||||
|
||||
PartitionList.push_back(PartitionEntrie);
|
||||
|
||||
}
|
167
source/Controls/PartitionHandle.h
Normal file
167
source/Controls/PartitionHandle.h
Normal file
@ -0,0 +1,167 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2010
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*
|
||||
* for WiiXplorer 2010
|
||||
***************************************************************************/
|
||||
#ifndef PARTITION_HANDLE_H
|
||||
#define PARTITION_HANDLE_H
|
||||
|
||||
#include <gccore.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define MAX_PARTITIONS 32 /* Maximum number of partitions that can be found */
|
||||
#define MAX_MOUNTS 10 /* Maximum number of mounts available at one time */
|
||||
#define MAX_SYMLINK_DEPTH 10 /* Maximum search depth when resolving symbolic links */
|
||||
|
||||
#define MBR_SIGNATURE 0x55AA
|
||||
#define EBR_SIGNATURE MBR_SIGNATURE
|
||||
|
||||
#define PARTITION_BOOTABLE 0x80 /* Bootable (active) */
|
||||
#define PARTITION_NONBOOTABLE 0x00 /* Non-bootable */
|
||||
#define PARTITION_TYPE_GPT 0xEE /* Indicates that a GPT header is available */
|
||||
|
||||
#define GUID_SYSTEM_PARTITION 0x0000000000000001LL /* System partition (disk partitioning utilities must reserve the partition as is) */
|
||||
#define GUID_READ_ONLY_PARTITION 0x0800000000000000LL /* Read-only partition */
|
||||
#define GUID_HIDDEN_PARTITION 0x2000000000000000LL /* Hidden partition */
|
||||
#define GUID_NO_AUTOMOUNT_PARTITION 0x4000000000000000LL /* Do not automount (e.g., do not assign drive letter) */
|
||||
|
||||
#define BYTES_PER_SECTOR 512 /* Default in libogc */
|
||||
|
||||
typedef struct _PARTITION_RECORD {
|
||||
u8 status; /* Partition status; see above */
|
||||
u8 chs_start[3]; /* Cylinder-head-sector address to first block of partition */
|
||||
u8 type; /* Partition type; see above */
|
||||
u8 chs_end[3]; /* Cylinder-head-sector address to last block of partition */
|
||||
u32 lba_start; /* Local block address to first sector of partition */
|
||||
u32 block_count; /* Number of blocks in partition */
|
||||
} __attribute__((__packed__)) PARTITION_RECORD;
|
||||
|
||||
|
||||
typedef struct _MASTER_BOOT_RECORD {
|
||||
u8 code_area[446]; /* Code area; normally empty */
|
||||
PARTITION_RECORD partitions[4]; /* 4 primary partitions */
|
||||
u16 signature; /* MBR signature; 0xAA55 */
|
||||
} __attribute__((__packed__)) MASTER_BOOT_RECORD;
|
||||
|
||||
typedef struct _EXTENDED_BOOT_RECORD {
|
||||
u8 code_area[446]; /* Code area; normally empty */
|
||||
PARTITION_RECORD partition; /* Primary partition */
|
||||
PARTITION_RECORD next_ebr; /* Next extended boot record in the chain */
|
||||
u8 reserved[32]; /* Normally empty */
|
||||
u16 signature; /* EBR signature; 0xAA55 */
|
||||
} __attribute__((__packed__)) EXTENDED_BOOT_RECORD;
|
||||
|
||||
typedef struct _GPT_HEADER
|
||||
{
|
||||
char magic[8]; /* "EFI PART" */
|
||||
u32 revision; /* For version 1.0 */
|
||||
u32 header_size; /* Header size in bytes */
|
||||
u32 checksum; /* CRC32 of header (0 to header size), with this field zeroed during calculation */
|
||||
u32 reserved; /* must be 0 */
|
||||
u64 header_lba; /* Current LBA (location of this header copy) */
|
||||
u64 backup_lba; /* Backup LBA (location of the other header copy) */
|
||||
u64 first_part_lba; /* First usable LBA for partitions (primary partition table last LBA + 1) */
|
||||
u64 last_part_lba; /* Last usable LBA (secondary partition table first LBA - 1) */
|
||||
u8 disk_guid[16]; /* Disk GUID (also referred as UUID on UNIXes) */
|
||||
u64 part_table_lba; /* Partition entries starting LBA (always 2 in primary copy) */
|
||||
u32 part_entries; /* Number of partition entries */
|
||||
u32 part_entry_size; /* Size of a partition entry (usually 128) */
|
||||
u32 part_entry_checksum; /* CRC32 of partition array */
|
||||
u8 zeros[420];
|
||||
} __attribute__((__packed__)) GPT_HEADER;
|
||||
|
||||
typedef struct _GUID_PART_ENTRY
|
||||
{
|
||||
u8 part_type_guid[16]; /* Partition type GUID */
|
||||
u8 uniq_part_guid[16]; /* Unique partition GUID */
|
||||
u64 part_first_lba; /* First LBA (little-endian) */
|
||||
u64 part_last_lba; /* Last LBA (inclusive, usually odd) */
|
||||
u64 attribute_flags; /* GUID Attribute flags (e.g. bit 60 denotes read-only) */
|
||||
char partition_name[72]; /* Partition name (36 UTF-16LE code units) */
|
||||
} __attribute__((__packed__)) GUID_PART_ENTRY;
|
||||
|
||||
typedef struct _PartitionFS
|
||||
{
|
||||
const char * FSName;
|
||||
u64 LBA_Start;
|
||||
u64 SecCount;
|
||||
bool Bootable;
|
||||
u8 PartitionType;
|
||||
u8 PartitionNum;
|
||||
} __attribute__((__packed__)) PartitionFS;
|
||||
|
||||
|
||||
class PartitionHandle
|
||||
{
|
||||
public:
|
||||
//! Constructor reads the MBR and all EBRs and lists up the Partitions
|
||||
PartitionHandle(const DISC_INTERFACE *discio);
|
||||
//! Destructor unmounts drives
|
||||
~PartitionHandle();
|
||||
//! Is Drive inserted
|
||||
bool IsInserted() { if(!interface) return false; else return interface->isInserted(); };
|
||||
//! Is the partition Mounted
|
||||
bool IsMounted(int pos);
|
||||
//! Mount a specific Partition
|
||||
bool Mount(int pos, const char * name);
|
||||
//! UnMount a specific Partition
|
||||
void UnMount(int pos);
|
||||
//! UnMount all Partition
|
||||
void UnMountAll() { for(u32 i = 0; i < PartitionList.size(); ++i) UnMount(i); };
|
||||
//! Get the Mountname
|
||||
const char * MountName(int pos) { if(pos < 0 || pos >= (int) MountNameList.size() || !MountNameList[pos].size()) return NULL; else return MountNameList[pos].c_str(); };
|
||||
//! Get the Name of the FileSystem e.g. "FAT32"
|
||||
const char * GetFSName(int pos) { if(valid(pos)) return PartitionList[pos].FSName; else return NULL; };
|
||||
//! Get the LBA where the partition is located
|
||||
u32 GetLBAStart(int pos) { if(valid(pos)) return PartitionList[pos].LBA_Start; else return 0; };
|
||||
//! Get the partition size in sectors of this partition
|
||||
u32 GetSecCount(int pos) { if(valid(pos)) return PartitionList[pos].SecCount; else return 0; };
|
||||
//! Check if the partition is Active or NonBootable
|
||||
bool IsActive(int pos) { if(valid(pos)) return PartitionList[pos].Bootable; else return false; };
|
||||
//! Get the partition type
|
||||
int GetPartitionType(int pos) { if(valid(pos)) return PartitionList[pos].PartitionType; else return -1; };
|
||||
//! Get the entrie number in MBR of this partition
|
||||
int GetPartitionNum(int pos) { if(valid(pos)) return PartitionList[pos].PartitionNum; else return -1; };
|
||||
//! Get the count of found partitions
|
||||
int GetPartitionCount() { return PartitionList.size(); };
|
||||
//! Get the partition size in bytes
|
||||
u64 GetSize(int pos) { if(valid(pos)) return (u64) PartitionList[pos].SecCount*BYTES_PER_SECTOR; else return 0; };
|
||||
//! Get the whole partition record struct
|
||||
PartitionFS * GetPartitionRecord(int pos) { if(valid(pos)) return &PartitionList[pos]; else return NULL; };
|
||||
//! Get the disc interface of this handle
|
||||
const DISC_INTERFACE * GetDiscInterface() { return interface; };
|
||||
protected:
|
||||
bool valid(int pos) { return (pos >= 0 && pos < (int) PartitionList.size()); }
|
||||
void AddPartition(const char * name, u64 lba_start, u64 sec_count, bool bootable, u8 part_type, u8 part_num);
|
||||
int FindPartitions();
|
||||
bool IsExisting(u64 lba);
|
||||
void CheckEBR(u8 PartNum, sec_t ebr_lba);
|
||||
int CheckGPT(u8 PartNum);
|
||||
|
||||
const DISC_INTERFACE *interface;
|
||||
std::vector<PartitionFS> PartitionList;
|
||||
std::vector<std::string> MountNameList;
|
||||
};
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#include "mload/mload.h"
|
||||
#include "mload/mload_modules.h"
|
||||
#include "system/IosLoader.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "usbloader/disc.h"
|
||||
#include "usbloader/apploader.h"
|
||||
#include "usbloader/wdvd.h"
|
||||
@ -11,6 +12,7 @@
|
||||
#include "usbloader/frag.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "usbloader/playlog.h"
|
||||
#include "usbloader/MountGamePartition.h"
|
||||
#include "settings/newtitles.h"
|
||||
#include "patches/fst.h"
|
||||
#include "patches/gamepatches.h"
|
||||
@ -20,7 +22,6 @@
|
||||
#include "wad/nandtitle.h"
|
||||
#include "menu/menus.h"
|
||||
#include "memory/memory.h"
|
||||
#include "fatmounter.h"
|
||||
#include "sys.h"
|
||||
|
||||
//appentrypoint has to be global because of asm
|
||||
@ -209,8 +210,7 @@ int BootGame(const char * gameID)
|
||||
|
||||
shadow_mload();
|
||||
WBFS_Close();
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
DeviceHandler::DestroyInstance();
|
||||
USB_Deinitialize();
|
||||
|
||||
if(Settings.PlaylogUpdate)
|
||||
|
185
source/StartUpProcess.cpp
Normal file
185
source/StartUpProcess.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
#include <unistd.h>
|
||||
#include "StartUpProcess.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "video.h"
|
||||
#include "audio.h"
|
||||
#include "input.h"
|
||||
#include "themes/CTheme.h"
|
||||
#include "gecko.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "system/IosLoader.h"
|
||||
#include "settings/CSettings.h"
|
||||
#include "settings/CGameSettings.h"
|
||||
#include "settings/CGameStatistics.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "sys.h"
|
||||
|
||||
StartUpProcess::StartUpProcess()
|
||||
{
|
||||
//! Load default font for the next text outputs
|
||||
Theme::LoadFont("");
|
||||
|
||||
background = new GuiImage(screenwidth, screenheight, (GXColor) {0, 0, 0, 255});
|
||||
|
||||
GXImageData = Resources::GetImageData("gxlogo.png");
|
||||
GXImage = new GuiImage(GXImageData);
|
||||
GXImage->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
||||
GXImage->SetPosition(screenwidth/2, screenheight/2-50);
|
||||
|
||||
titleTxt = new GuiText("Loading...", 24, (GXColor) {255, 255, 255, 255});
|
||||
titleTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
||||
titleTxt->SetPosition(screenwidth/2, screenheight/2+30);
|
||||
|
||||
messageTxt = new GuiText(" ", 22, (GXColor) {255, 255, 255, 255});
|
||||
messageTxt->SetAlignment(ALIGN_CENTER, ALIGN_MIDDLE);
|
||||
messageTxt->SetPosition(screenwidth/2, screenheight/2+60);
|
||||
}
|
||||
|
||||
StartUpProcess::~StartUpProcess()
|
||||
{
|
||||
delete background;
|
||||
delete GXImageData;
|
||||
delete GXImage;
|
||||
delete titleTxt;
|
||||
delete messageTxt;
|
||||
}
|
||||
|
||||
void StartUpProcess::TextFade(int direction)
|
||||
{
|
||||
if(direction > 0)
|
||||
{
|
||||
for(int i = 0; i < 255; i += direction)
|
||||
{
|
||||
messageTxt->SetAlpha(i);
|
||||
Draw();
|
||||
}
|
||||
messageTxt->SetAlpha(255);
|
||||
Draw();
|
||||
}
|
||||
else if(direction < 0)
|
||||
{
|
||||
for(int i = 255; i > 0; i += direction)
|
||||
{
|
||||
messageTxt->SetAlpha(i);
|
||||
Draw();
|
||||
}
|
||||
messageTxt->SetAlpha(0);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
void StartUpProcess::SetTextf(const char * format, ...)
|
||||
{
|
||||
char * tmp = NULL;
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
||||
{
|
||||
TextFade(-40);
|
||||
gprintf(tmp);
|
||||
messageTxt->SetText(tmp);
|
||||
TextFade(40);
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
if(tmp)
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
bool StartUpProcess::USBSpinUp()
|
||||
{
|
||||
bool started = false;
|
||||
int retries = 400;
|
||||
// wait 10 sec for the USB to spin up...stupid slow ass HDD
|
||||
do
|
||||
{
|
||||
started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted());
|
||||
usleep(50000);
|
||||
|
||||
if(retries < 400 && retries % 20 == 0)
|
||||
{
|
||||
messageTxt->SetTextf("Waiting for slow HDD: %i sec left\n", retries/20);
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
while(!started && --retries > 0);
|
||||
|
||||
return started;
|
||||
}
|
||||
|
||||
bool StartUpProcess::Run()
|
||||
{
|
||||
StartUpProcess Process;
|
||||
|
||||
return Process.Execute();
|
||||
}
|
||||
|
||||
bool StartUpProcess::Execute()
|
||||
{
|
||||
//! Now we startup the GUI so no need for console prints. Output only to gecko.
|
||||
USBGeckoOutput();
|
||||
|
||||
// Let's try loading some cIOS
|
||||
if (IosLoader::LoadAppCios() < 0)
|
||||
{
|
||||
titleTxt->SetText("WARNING!");
|
||||
messageTxt->SetMaxWidth(400, WRAP);
|
||||
messageTxt->SetText("USB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+. \
|
||||
We cannot determine the versions on your system, since you have no patched ios 36 or 236 installed. \
|
||||
Therefor, if loading of USB Loader GX fails, you probably have installed the 4.2 update, \
|
||||
and you should go figure out how to get some cios action going on\n\tin your Wii. \
|
||||
ERROR: No cIOS could be loaded. Exiting....");
|
||||
sleep(10);
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
|
||||
SetTextf("Initialize sd card\n");
|
||||
DeviceHandler::Instance()->MountSD();
|
||||
|
||||
SetTextf("Initialize usb device\n");
|
||||
USBSpinUp();
|
||||
DeviceHandler::Instance()->MountAllUSB();
|
||||
|
||||
SetTextf("Loading config files");
|
||||
gprintf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed");
|
||||
gprintf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed");
|
||||
gprintf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed");
|
||||
gprintf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed");
|
||||
gprintf("\tLoading font...%s\n", Theme::LoadFont(Settings.theme_path) ? "done" : "failed (using default)");
|
||||
gprintf("\tLoading theme...%s\n", Theme::Load(Settings.theme) ? "done" : "failed (using default)");
|
||||
|
||||
if(Settings.cios != IOS_GetVersion())
|
||||
{
|
||||
SetTextf("Loading cIOS %i\n", Settings.cios);
|
||||
|
||||
DeviceHandler::Instance()->UnMountAll();
|
||||
|
||||
// Loading now the cios setup in the settings
|
||||
IosLoader::LoadAppCios();
|
||||
|
||||
SetTextf("Loaded cIOS %i R%i\n", IOS_GetVersion(), IOS_GetRevision());
|
||||
|
||||
DeviceHandler::Instance()->MountAll();
|
||||
}
|
||||
else
|
||||
SetTextf("Loaded cIOS %i R%i\n", IOS_GetVersion(), IOS_GetRevision());
|
||||
|
||||
//! Init the rest of the System
|
||||
Sys_Init();
|
||||
SetupPads();
|
||||
InitAudio();
|
||||
setlocale(LC_CTYPE, "C-UTF-8");
|
||||
setlocale(LC_MESSAGES, "C-UTF-8");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StartUpProcess::Draw()
|
||||
{
|
||||
background->Draw();
|
||||
GXImage->Draw();
|
||||
titleTxt->Draw();
|
||||
messageTxt->Draw();
|
||||
Menu_Render();
|
||||
}
|
26
source/StartUpProcess.h
Normal file
26
source/StartUpProcess.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef STARTUPPROCESS_H_
|
||||
#define STARTUPPROCESS_H_
|
||||
|
||||
#include "libwiigui/gui.h"
|
||||
|
||||
class StartUpProcess
|
||||
{
|
||||
public:
|
||||
static bool Run();
|
||||
private:
|
||||
StartUpProcess();
|
||||
~StartUpProcess();
|
||||
bool Execute();
|
||||
bool USBSpinUp();
|
||||
void TextFade(int direction);
|
||||
void SetTextf(const char * format, ...);
|
||||
void Draw();
|
||||
|
||||
GuiImageData * GXImageData;
|
||||
GuiImage * background;
|
||||
GuiImage * GXImage;
|
||||
GuiText * titleTxt;
|
||||
GuiText * messageTxt;
|
||||
};
|
||||
|
||||
#endif
|
@ -7,7 +7,6 @@
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "language/gettext.h"
|
||||
#include "themes/CTheme.h"
|
||||
#include "fatmounter.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "menu.h"
|
||||
#include "filelist.h"
|
||||
|
@ -1,158 +0,0 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
#include <ogc/mutex.h>
|
||||
#include <ogc/system.h>
|
||||
#include <ogc/usbstorage.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <locale.h>
|
||||
#include <fat.h>
|
||||
#include <ntfs.h>
|
||||
#include <ext2.h>
|
||||
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "usbloader/sdhc.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "fatmounter.h"
|
||||
#include "gecko.h"
|
||||
|
||||
//these are the only stable and speed is good
|
||||
#define CACHE 32
|
||||
#define SECTORS 64
|
||||
#define SECTORS_SD 32
|
||||
|
||||
#define MOUNT_NONE 0
|
||||
#define MOUNT_SD 1
|
||||
#define MOUNT_SDHC 2
|
||||
|
||||
#define DEBUG_FAT
|
||||
|
||||
/* Disc interfaces */
|
||||
extern const DISC_INTERFACE __io_sdhc;
|
||||
|
||||
extern sec_t _FAT_startSector;
|
||||
|
||||
extern s32 wbfsDev;
|
||||
|
||||
int fat_sd_mount = MOUNT_NONE;
|
||||
sec_t fat_sd_sec = 0; // u32
|
||||
|
||||
int fat_usb_mount = 0;
|
||||
sec_t fat_usb_sec = 0;
|
||||
|
||||
int USBDevice_Init()
|
||||
{
|
||||
//closing all open Files write back the cache and then shutdown em!
|
||||
USBDevice_deInit();
|
||||
//right now mounts first FAT-partition
|
||||
|
||||
bool started = false;
|
||||
int retries = 10;
|
||||
|
||||
// wait 0.5 sec for the USB to spin up...stupid slow ass HDD
|
||||
do
|
||||
{
|
||||
started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted());
|
||||
usleep(50000);
|
||||
--retries;
|
||||
}
|
||||
while(!started && retries > 0);
|
||||
|
||||
if(!started)
|
||||
return -1;
|
||||
|
||||
if (fatMount("USB", &__io_usbstorage2, 0, CACHE, SECTORS))
|
||||
{
|
||||
fat_usb_sec = _FAT_startSector;
|
||||
return (fat_usb_mount = 1);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int USBDevice_Init_Loop()
|
||||
{
|
||||
time_t starttime = time(0);
|
||||
time_t timenow = starttime;
|
||||
bool StatusPrinted = false;
|
||||
bool started = false;
|
||||
|
||||
do
|
||||
{
|
||||
started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted());
|
||||
|
||||
if(!started)
|
||||
{
|
||||
if(timenow != time(0))
|
||||
{
|
||||
timenow = time(0);
|
||||
if(!StatusPrinted)
|
||||
{
|
||||
printf("\tWaiting for slow HDD...");
|
||||
StatusPrinted = true;
|
||||
}
|
||||
printf("%i ", (int) (timenow-starttime));
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
}
|
||||
while(!started && timenow-starttime < 30);
|
||||
|
||||
if(StatusPrinted)
|
||||
printf("\n");
|
||||
|
||||
return USBDevice_Init();
|
||||
}
|
||||
|
||||
void USBDevice_deInit()
|
||||
{
|
||||
//closing all open Files write back the cache and then shutdown em!
|
||||
fatUnmount("USB:/");
|
||||
//only shutdown libogc usb and not the cios one
|
||||
__io_usbstorage2.shutdown();
|
||||
|
||||
fat_usb_mount = 0;
|
||||
fat_usb_sec = 0;
|
||||
}
|
||||
|
||||
int isInserted(const char *path)
|
||||
{
|
||||
if (!strncmp(path, "USB:", 4)) return 1;
|
||||
|
||||
return __io_sdhc.isInserted() || __io_wiisd.isInserted();
|
||||
}
|
||||
|
||||
int SDCard_Init()
|
||||
{
|
||||
//closing all open Files write back the cache and then shutdown em!
|
||||
SDCard_deInit();
|
||||
|
||||
//right now mounts first FAT-partition
|
||||
if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS))
|
||||
{
|
||||
fat_sd_mount = MOUNT_SD;
|
||||
fat_sd_sec = _FAT_startSector;
|
||||
return 1;
|
||||
}
|
||||
|
||||
__io_wiisd.shutdown();
|
||||
|
||||
if (fatMount("SD", &__io_sdhc, 0, CACHE, SECTORS))
|
||||
{
|
||||
fat_sd_mount = MOUNT_SDHC;
|
||||
fat_sd_sec = _FAT_startSector;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void SDCard_deInit()
|
||||
{
|
||||
fatUnmount("SD:/");
|
||||
__io_wiisd.shutdown();
|
||||
__io_sdhc.shutdown();
|
||||
|
||||
fat_sd_mount = MOUNT_NONE;
|
||||
fat_sd_sec = 0;
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
#ifndef _FATMOUNTER_H_
|
||||
#define _FATMOUNTER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <gccore.h>
|
||||
|
||||
extern int fat_sd_mount;
|
||||
extern sec_t fat_sd_sec;
|
||||
extern int fat_usb_mount;
|
||||
extern sec_t fat_usb_sec;
|
||||
extern int fat_wbfs_mount;
|
||||
extern sec_t fat_wbfs_sec;
|
||||
|
||||
int USBDevice_Init();
|
||||
int USBDevice_Init_Loop(); //! Wait's for the drive before mounting it, only used on bootup
|
||||
void USBDevice_deInit();
|
||||
int WBFSDevice_Init(u32 sector);
|
||||
void WBFSDevice_deInit();
|
||||
int isInserted(const char *path);
|
||||
int SDCard_Init();
|
||||
void SDCard_deInit();
|
||||
|
||||
s32 MountNTFS(u32 sector);
|
||||
s32 UnmountNTFS(void);
|
||||
s32 MountEXT(u32 sector);
|
||||
s32 UnmountEXT(void);
|
||||
|
||||
extern int fat_usb_mount;
|
||||
extern sec_t fat_usb_sec;
|
||||
extern int fat_wbfs_mount;
|
||||
extern sec_t fat_wbfs_sec;
|
||||
extern int fs_ntfs_mount;
|
||||
extern sec_t fs_ntfs_sec;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -8,11 +8,11 @@
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "../lstub.h"
|
||||
#include "../sys.h"
|
||||
#include "../gecko.h"
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "dolloader.h"
|
||||
|
||||
static u8 *homebrewbuffer = (u8 *) 0x92000000;
|
||||
@ -146,8 +146,7 @@ int BootHomebrew(const char * filepath)
|
||||
{
|
||||
fclose(file);
|
||||
free(buffer);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
DeviceHandler::DestroyInstance();
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,10 @@ GuiImageData *LoadCoverImage(struct discHdr *header, bool Prefere3D, bool noCove
|
||||
flag = Prefere3D;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
flag = !flag;
|
||||
delete Cover;
|
||||
Cover = Resources::GetImageData(flag ? "nocover.png" : "nocoverFlat.png");
|
||||
if (Cover && Cover->GetImage()) break;
|
||||
flag = !flag;
|
||||
}
|
||||
}
|
||||
if (Cover && !Cover->GetImage())
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "language/gettext.h"
|
||||
#include "menu.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
@ -18,53 +18,29 @@
|
||||
#include <di/di.h>
|
||||
#include <sys/iosupport.h>
|
||||
|
||||
#include "libwiigui/gui.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "language/gettext.h"
|
||||
#include "mload/mload.h"
|
||||
#include "mload/mload_modules.h"
|
||||
#include "video.h"
|
||||
#include "audio.h"
|
||||
#include "menu/menus.h"
|
||||
#include "menu.h"
|
||||
#include "input.h"
|
||||
#include "filelist.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "settings/CGameSettings.h"
|
||||
#include "settings/CGameStatistics.h"
|
||||
#include "themes/CTheme.h"
|
||||
#include "menu/menus.h"
|
||||
#include "main.h"
|
||||
#include "fatmounter.h"
|
||||
#include "sys.h"
|
||||
#include "gecko.h"
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "settings/CSettings.h"
|
||||
#include "memory/mem2.h"
|
||||
#include "lstub.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "system/IosLoader.h"
|
||||
#include "usbloader/MountGamePartition.h"
|
||||
#include "StartUpProcess.h"
|
||||
#include "GameBootProcess.h"
|
||||
#include "sys.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void __exception_setreload(int t);
|
||||
}
|
||||
|
||||
PartList partitions;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int QuickGameBoot(const char * gameID)
|
||||
{
|
||||
MEM2_init(48);
|
||||
setlocale(LC_ALL, "en.UTF-8");
|
||||
InitVideo();
|
||||
InitGecko();
|
||||
__exception_setreload(20);
|
||||
|
||||
printf("\tStarting up\n");
|
||||
NandTitles.Get();
|
||||
|
||||
// Let's try loading some cIOS
|
||||
//if a ID was passed via args copy it and try to boot it after the partition is mounted
|
||||
//its not really a headless mode. more like hairless.
|
||||
if (IosLoader::LoadAppCios() < 0)
|
||||
{
|
||||
printf("\n\tWARNING!\n");
|
||||
@ -79,49 +55,26 @@ int main(int argc, char *argv[])
|
||||
Sys_BackToLoader();
|
||||
}
|
||||
|
||||
//Let's use libogc sd/usb for config loading
|
||||
printf("\tInitialize sd card...%s\n", SDCard_Init() < 0 ? "failed" : "done");
|
||||
printf("\tInitialize usb device...%s\n", USBDevice_Init_Loop() < 0 ? "failed" : "done");
|
||||
DeviceHandler::Instance()->MountAll();
|
||||
Settings.Load();
|
||||
|
||||
//Load configurations
|
||||
printf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed");
|
||||
printf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed");
|
||||
printf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed");
|
||||
printf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed");
|
||||
printf("\tLoading theme...%s\n", Theme::Load(Settings.theme_path) ? "done" : "failed (using default)");
|
||||
|
||||
VIDEO_SetWidescreen(Settings.widescreen);
|
||||
|
||||
if(Settings.cios != IOS_GetVersion())
|
||||
{
|
||||
// Unmount fat before reloading IOS.
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
// Loading now the cios setup in the settings
|
||||
IosLoader::LoadAppCios();
|
||||
|
||||
// Remount devices after reloading IOS.
|
||||
SDCard_Init();
|
||||
USBDevice_Init_Loop();
|
||||
}
|
||||
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
|
||||
|
||||
//if a ID was passed via args copy it and try to boot it after the partition is mounted
|
||||
//its not really a headless mode. more like hairless.
|
||||
if (argc > 1 && argv[1])
|
||||
{
|
||||
MountGamePartition(false);
|
||||
return BootGame(argv[1]);
|
||||
return BootGame(gameID);
|
||||
}
|
||||
|
||||
//! Now we startup the GUI so no need for console prints. Output only to gecko.
|
||||
USBGeckoOutput();
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
MEM2_init(48);
|
||||
__exception_setreload(20);
|
||||
InitVideo();
|
||||
InitGecko();
|
||||
NandTitles.Get();
|
||||
setlocale(LC_ALL, "en.UTF-8");
|
||||
|
||||
//! Init the rest of the System
|
||||
Sys_Init();
|
||||
SetupPads();
|
||||
InitAudio();
|
||||
if(argc > 1 && argv[1])
|
||||
return QuickGameBoot(argv[1]);
|
||||
|
||||
StartUpProcess::Run();
|
||||
|
||||
MainMenu(MENU_DISCLIST);
|
||||
return 0;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "themes/Theme_Downloader.h"
|
||||
#include "usbloader/disc.h"
|
||||
#include "usbloader/GameList.h"
|
||||
#include "usbloader/MountGamePartition.h"
|
||||
#include "mload/mload_modules.h"
|
||||
#include "xml/xml.h"
|
||||
#include "audio.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <unistd.h>
|
||||
#include "GameBrowseMenu.hpp"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "libwiigui/LoadCoverImage.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "prompts/gameinfo.h"
|
||||
@ -25,7 +26,6 @@
|
||||
#include "utils/ShowError.h"
|
||||
#include "utils/tools.h"
|
||||
#include "utils/PasswordCheck.h"
|
||||
#include "fatmounter.h"
|
||||
#include "gecko.h"
|
||||
#include "menus.h"
|
||||
#include "wpad.h"
|
||||
@ -803,7 +803,7 @@ int GameBrowseMenu::MainLoop()
|
||||
HaltGui();
|
||||
bgMusic->Pause();
|
||||
Settings.Save();
|
||||
SDCard_Init();
|
||||
DeviceHandler::Instance()->MountSD();
|
||||
Settings.Load();
|
||||
bgMusic->Resume();
|
||||
wString oldFilter(gameList.GetCurrentFilter());
|
||||
|
@ -1,174 +0,0 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "system/IosLoader.h"
|
||||
#include "menus.h"
|
||||
#include "wpad.h"
|
||||
#include "fatmounter.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "usbloader/GameList.h"
|
||||
#include "settings/GameTitles.h"
|
||||
#include "xml/WiiTDB.hpp"
|
||||
|
||||
extern int load_from_fs;
|
||||
extern char game_partition[6];
|
||||
extern PartList partitions;
|
||||
|
||||
static int FindGamesPartition(PartList * partitions)
|
||||
{
|
||||
if (partitions->wbfs_n != 0)
|
||||
{
|
||||
WBFS_Open();
|
||||
|
||||
for (int p = 0; p < partitions->num; p++)
|
||||
{
|
||||
if (partitions->pinfo[p].fs_type == FS_TYPE_WBFS)
|
||||
{
|
||||
Settings.partition = p;
|
||||
load_from_fs = PART_FS_WBFS;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, IOS_GetVersion())) < 18)
|
||||
return -1;
|
||||
|
||||
// Loop through FAT/NTFS/EXT partitions, and find the first partition with games on it (if there is one)
|
||||
for (int i = 0; i < partitions->num; i++)
|
||||
{
|
||||
if (partitions->pinfo[i].fs_type == FS_TYPE_FAT32 || partitions->pinfo[i].fs_type == FS_TYPE_NTFS ||
|
||||
partitions->pinfo[i].fs_type == FS_TYPE_EXT)
|
||||
{
|
||||
if (!WBFS_OpenPart(partitions->pinfo[i].part_fs, partitions->pinfo[i].index,
|
||||
partitions->pentry[i].sector, partitions->pentry[i].size, (char *) &game_partition))
|
||||
{
|
||||
u32 count;
|
||||
// Get the game count...
|
||||
WBFS_GetCount(&count);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
load_from_fs = partitions->pinfo[i].part_fs;
|
||||
Settings.partition = i;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
WBFS_Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int PartitionChoice()
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
int choice = WindowPrompt(tr( "No WBFS or FAT/NTFS/EXT partition found" ),
|
||||
tr( "You need to select or format a partition" ), tr( "Select" ), tr( "Format" ), tr( "Return" ));
|
||||
|
||||
if (choice == 0)
|
||||
{
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
else if(choice == 1)
|
||||
{
|
||||
int part_num = SelectPartitionMenu();
|
||||
if(part_num >= 0)
|
||||
{
|
||||
if(IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, IOS_GetVersion())) < 18
|
||||
&& (partitions.pinfo[part_num].part_fs == FS_TYPE_FAT32 || partitions.pinfo[part_num].part_fs == FS_TYPE_NTFS
|
||||
|| partitions.pinfo[part_num].part_fs == FS_TYPE_EXT))
|
||||
WindowPrompt(tr("Warning:"), tr("You are trying to select a FAT32/NTFS/EXT partition with cIOS 249 Rev < 18. This is not supported. Continue on your own risk."), tr("OK"));
|
||||
|
||||
ret = WBFS_OpenPart(partitions.pinfo[part_num].part_fs, partitions.pinfo[part_num].index, partitions.pentry[part_num].sector, partitions.pentry[part_num].size, (char *) &game_partition);
|
||||
|
||||
load_from_fs = partitions.pinfo[part_num].part_fs;
|
||||
Settings.partition = part_num;
|
||||
Settings.Save();
|
||||
}
|
||||
}
|
||||
else if(choice == 2)
|
||||
{
|
||||
while(ret < 0 || ret == -666)
|
||||
{
|
||||
int part_num = SelectPartitionMenu();
|
||||
if(part_num >= 0)
|
||||
ret = FormatingPartition(tr( "Formatting, please wait..." ), &partitions.pentry[part_num]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MountGamePartition
|
||||
***************************************************************************/
|
||||
int MountGamePartition(bool ShowGUI)
|
||||
{
|
||||
gprintf("MountGamePartition()\n");
|
||||
|
||||
s32 wbfsinit = MountWBFS(ShowGUI);
|
||||
if (wbfsinit < 0)
|
||||
{
|
||||
if(ShowGUI) WindowPrompt(tr( "Error !" ), tr( "USB Device not found" ), tr( "OK" ));
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
||||
s32 ret = -1;
|
||||
memset(game_partition, 0, 6);
|
||||
load_from_fs = -1;
|
||||
|
||||
gprintf("\tPartition_GetList\n");
|
||||
// Added for slow HDD
|
||||
for (int retries = 10; retries > 0; retries--)
|
||||
{
|
||||
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) == 0)
|
||||
break;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
gprintf("\tWBFS_OpenPart: start sector %u, sector count: %u\n", partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size);
|
||||
if (Settings.partition != -1 && partitions.num > Settings.partition)
|
||||
{
|
||||
PartInfo pinfo = partitions.pinfo[Settings.partition];
|
||||
if (!WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector,
|
||||
partitions.pentry[Settings.partition].size, (char *) &game_partition))
|
||||
{
|
||||
ret = 0;
|
||||
load_from_fs = pinfo.part_fs;
|
||||
}
|
||||
}
|
||||
|
||||
if(ret < 0)
|
||||
ret = FindGamesPartition(&partitions);
|
||||
|
||||
if (ret < 0 && ShowGUI)
|
||||
ret = PartitionChoice();
|
||||
|
||||
if(ret < 0)
|
||||
Sys_LoadMenu();
|
||||
|
||||
gprintf("\tDisc_Init\n");
|
||||
ret = Disc_Init();
|
||||
if (ret < 0)
|
||||
{
|
||||
if(ShowGUI)
|
||||
WindowPrompt(tr( "Error !" ), tr( "Could not initialize DIP module!" ), tr( "OK" ));
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
||||
gprintf("\tOpenXMLDatabase\n");
|
||||
|
||||
GameTitles.LoadTitlesFromWiiTDB(Settings.titlestxt_path);
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "menus.h"
|
||||
#include "fatmounter.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "usbloader/utils.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "libwiigui/gui_customoptionbrowser.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "themes/CTheme.h"
|
||||
|
||||
extern PartList partitions;
|
||||
|
||||
/****************************************************************************
|
||||
* SelectPartitionMenu
|
||||
***************************************************************************/
|
||||
@ -18,21 +16,21 @@ int SelectPartitionMenu()
|
||||
bool ExitSelect = false;
|
||||
OptionList options;
|
||||
|
||||
u32 cnt, counter = 0;
|
||||
u32 counter = 0;
|
||||
int choice = -1;
|
||||
int ret = -1;
|
||||
|
||||
//create the partitionlist
|
||||
for (cnt = 0; cnt < (u32) partitions.num; cnt++)
|
||||
{
|
||||
partitionEntry *entry = &partitions.pentry[cnt];
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
|
||||
//create the partitionlist
|
||||
for (int cnt = 0; cnt < usbHandle->GetPartitionCount(); cnt++)
|
||||
{
|
||||
/* Calculate size in gigabytes */
|
||||
f32 size = entry->size * (partitions.sector_size / GB_SIZE);
|
||||
f32 size = usbHandle->GetSize(cnt) / GB_SIZE;
|
||||
|
||||
if (size)
|
||||
{
|
||||
options.SetName(counter, "%s %d:", tr( "Partition" ), cnt + 1);
|
||||
options.SetName(counter, "%s %d %s: ", tr( "Partition" ), cnt + 1, usbHandle->GetFSName(cnt));
|
||||
options.SetValue(counter, "%.2fGB", size);
|
||||
}
|
||||
else
|
||||
@ -100,8 +98,7 @@ int SelectPartitionMenu()
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
partitionEntry *entry = &partitions.pentry[ret];
|
||||
if (entry->size)
|
||||
if (usbHandle->GetSize(ret))
|
||||
{
|
||||
choice = ret;
|
||||
ExitSelect = true;
|
||||
|
@ -15,6 +15,5 @@ extern u8 reset;
|
||||
int MenuInstall();
|
||||
int MenuDiscList();
|
||||
int SelectPartitionMenu();
|
||||
int MountGamePartition(bool ShowGUI = true);
|
||||
|
||||
#endif // _MENUS_H
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include "fst.h"
|
||||
#include "dvd_broadway.h"
|
||||
#include "fatmounter.h"
|
||||
#include "mload/mload.h"
|
||||
#include "mload/mload_modules.h"
|
||||
#include "gecko.h"
|
||||
@ -129,11 +128,11 @@ void app_loadgameconfig(char *discid)
|
||||
|
||||
if (!fp)
|
||||
{
|
||||
snprintf(filepath, sizeof(filepath), "SD:/gameconfig.txt");
|
||||
snprintf(filepath, sizeof(filepath), "sd:/gameconfig.txt");
|
||||
fp = fopen(filepath, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
snprintf(filepath, sizeof(filepath), "USB:/gameconfig.txt");
|
||||
snprintf(filepath, sizeof(filepath), "usb:/gameconfig.txt");
|
||||
fp = fopen(filepath, "rb");
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "usbloader/wdvd.h"
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "usbloader/GameList.h"
|
||||
#include "usbloader/utils.h"
|
||||
@ -27,7 +27,6 @@
|
||||
#include "themes/CTheme.h"
|
||||
#include "utils/StringTools.h"
|
||||
#include "mload/mload.h"
|
||||
#include "fatmounter.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "menu.h"
|
||||
#include "menu.h"
|
||||
@ -525,7 +524,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
|
||||
msgTxt.SetPosition(0, -40);
|
||||
msgTxt.SetMaxWidth(430);
|
||||
|
||||
GuiText btn1Txt(btn1Label, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiText btn1Txt(btn1Label, 20, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiImage btn1Img(&btnOutline);
|
||||
if (Settings.wsprompt)
|
||||
{
|
||||
@ -537,7 +536,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
|
||||
btn1.SetLabel(&btn1Txt);
|
||||
btn1.SetState(STATE_SELECTED);
|
||||
|
||||
GuiText btn2Txt(btn2Label, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiText btn2Txt(btn2Label, 20, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiImage btn2Img(&btnOutline);
|
||||
if (Settings.wsprompt)
|
||||
{
|
||||
@ -548,7 +547,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
|
||||
btn2.SetLabel(&btn2Txt);
|
||||
if (!btn3Label && !btn4Label) btn2.SetTrigger(&trigB);
|
||||
|
||||
GuiText btn3Txt(btn3Label, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiText btn3Txt(btn3Label, 20, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiImage btn3Img(&btnOutline);
|
||||
if (Settings.wsprompt)
|
||||
{
|
||||
@ -559,7 +558,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label, cons
|
||||
btn3.SetLabel(&btn3Txt);
|
||||
if (!btn4Label) btn3.SetTrigger(&trigB);
|
||||
|
||||
GuiText btn4Txt(btn4Label, 22, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiText btn4Txt(btn4Label, 20, thColor("r=0 g=0 b=0 a=255 - prompt windows text color"));
|
||||
GuiImage btn4Img(&btnOutline);
|
||||
if (Settings.wsprompt)
|
||||
{
|
||||
@ -1194,8 +1193,8 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
|
||||
if (ret >= 0) break;
|
||||
|
||||
timerTxt.SetTextf("%i %s", (int) (30-(timenow-starttime)), tr( "seconds left" ));
|
||||
USBDevice_deInit();
|
||||
USBDevice_Init();
|
||||
DeviceHandler::Instance()->UnMountAllUSB();
|
||||
DeviceHandler::Instance()->MountAllUSB();
|
||||
timenow = time(0);
|
||||
}
|
||||
while (timenow-starttime < 30);
|
||||
@ -1228,12 +1227,12 @@ int DiscWait(const char *title, const char *msg, const char *btn1Label, const ch
|
||||
/****************************************************************************
|
||||
* FormatingPartition
|
||||
***************************************************************************/
|
||||
int FormatingPartition(const char *title, partitionEntry *entry)
|
||||
int FormatingPartition(const char *title, int part_num)
|
||||
{
|
||||
extern PartList partitions;
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
|
||||
char text[255];
|
||||
sprintf(text, "%s: %.2fGB", tr( "Partition" ), entry->size * (partitions.sector_size / GB_SIZE));
|
||||
sprintf(text, "%s: %.2fGB", tr( "Partition" ), usbHandle->GetSize(part_num) / GB_SIZE);
|
||||
int choice = WindowPrompt(tr( "Do you want to format:" ), text, tr( "Yes" ), tr( "No" ));
|
||||
if (choice == 0)
|
||||
return -666;
|
||||
@ -1270,7 +1269,7 @@ int FormatingPartition(const char *title, partitionEntry *entry)
|
||||
ResumeGui();
|
||||
|
||||
VIDEO_WaitVSync();
|
||||
ret = WBFS_Format(entry->sector, entry->size);
|
||||
ret = WBFS_Format(usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -1278,8 +1277,11 @@ int FormatingPartition(const char *title, partitionEntry *entry)
|
||||
}
|
||||
else
|
||||
{
|
||||
PartitionFS * partition = usbHandle->GetPartitionRecord(part_num);
|
||||
partition->PartitionType = 0xBF;
|
||||
partition->FSName = "WBFS";
|
||||
sleep(1);
|
||||
ret = WBFS_Open();
|
||||
ret = WBFS_OpenPart(part_num);
|
||||
sprintf(text, "%s %s", text, tr( "formatted!" ));
|
||||
WindowPrompt(tr( "Success:" ), text, tr( "OK" ));
|
||||
if (ret < 0)
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define _PROMPTWINDOWS_H_
|
||||
|
||||
#include "libwiigui/gui.h"
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
|
||||
int WindowPrompt(const char *title, const char *msg = NULL, const char * btn1Label = NULL, const char * btn2Label =
|
||||
NULL, const char * btn3Label = NULL, const char * btn4Label = NULL, int wait = -1);
|
||||
@ -19,7 +18,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min);
|
||||
int OnScreenNumpad(char * var, u32 maxlen);
|
||||
int WindowExitPrompt();
|
||||
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);
|
||||
int FormatingPartition(const char *title, partitionEntry *entry);
|
||||
int FormatingPartition(const char *title, int part_num);
|
||||
bool NetworkInitPrompt();
|
||||
int WindowScreensaver();
|
||||
int CodeDownload(const char *id);
|
||||
|
@ -282,7 +282,6 @@ int ParseDirectory(int Device, int Flags, FILTERCASCADE *Filter)
|
||||
* BrowseDevice
|
||||
* Displays a list of files on the selected path
|
||||
***************************************************************************/
|
||||
|
||||
int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=NULL*/)
|
||||
{
|
||||
int result = -1;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "filelist.h"
|
||||
#include "sys.h"
|
||||
#include "wpad.h"
|
||||
#include "fatmounter.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "themes/CTheme.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "CSettings.h"
|
||||
#include "CGameSettings.h"
|
||||
#include "CGameStatistics.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "language/gettext.h"
|
||||
#include "themes/CTheme.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
@ -39,7 +40,7 @@ CSettings Settings;
|
||||
CSettings::CSettings()
|
||||
{
|
||||
CONF_Init();
|
||||
strcpy(BootDevice, "SD:");
|
||||
strcpy(BootDevice, "sd:");
|
||||
snprintf(ConfigPath, sizeof(ConfigPath), "%s/config/", BootDevice);
|
||||
this->SetDefault();
|
||||
}
|
||||
@ -64,6 +65,7 @@ void CSettings::SetDefault()
|
||||
snprintf(WipCodepath, sizeof(WipCodepath), "%s/wip/", BootDevice);
|
||||
snprintf(theme_path, sizeof(theme_path), "%stheme/", ConfigPath);
|
||||
snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice);
|
||||
strcpy(theme, "");
|
||||
strcpy(language_path, "");
|
||||
strcpy(ogg_path, "");
|
||||
strcpy(unlockCode, "");
|
||||
@ -187,6 +189,7 @@ bool CSettings::Save()
|
||||
fprintf(file, "covers_path = %s\n ", covers_path);
|
||||
fprintf(file, "covers2d_path = %s\n ", covers2d_path);
|
||||
fprintf(file, "theme_path = %s\n ", theme_path);
|
||||
fprintf(file, "theme = %s\n ", theme);
|
||||
fprintf(file, "disc_path = %s\n ", disc_path);
|
||||
fprintf(file, "language_path = %s\n ", language_path);
|
||||
fprintf(file, "languagefiles_path = %s\n ", languagefiles_path);
|
||||
@ -475,6 +478,11 @@ bool CSettings::SetSetting(char *name, char *value)
|
||||
strcpy(theme_path, value);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "theme") == 0)
|
||||
{
|
||||
strcpy(theme, value);
|
||||
return true;
|
||||
}
|
||||
else if (strcmp(name, "disc_path") == 0)
|
||||
{
|
||||
strcpy(disc_path, value);
|
||||
@ -554,11 +562,10 @@ bool CSettings::FindConfig()
|
||||
bool found = false;
|
||||
char CheckDevice[10];
|
||||
char CheckPath[300];
|
||||
strcpy(CheckDevice, "SD:");
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int i = SD; i < MAXDEVICES; ++i)
|
||||
{
|
||||
if (i == 1) strcpy(CheckDevice, "USB:");
|
||||
sprintf(CheckDevice, "%s:", DeviceName[i]);
|
||||
|
||||
if(!found)
|
||||
{
|
||||
@ -579,11 +586,11 @@ bool CSettings::FindConfig()
|
||||
if (!found)
|
||||
{
|
||||
FILE * testFp = NULL;
|
||||
strcpy(CheckDevice, "SD:");
|
||||
//! No existing config so try to find a place where we can write it too
|
||||
for (int i = 0; i < 2; ++i)
|
||||
for (int i = SD; i < MAXDEVICES; ++i)
|
||||
{
|
||||
if (i == 1) strcpy(CheckDevice, "USB:");
|
||||
sprintf(CheckDevice, "%s:", DeviceName[i]);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
strcpy(BootDevice, CheckDevice);
|
||||
|
@ -82,6 +82,7 @@ class CSettings
|
||||
char covers_path[100];
|
||||
char covers2d_path[100];
|
||||
char theme_path[100];
|
||||
char theme[100];
|
||||
char theme_downloadpath[100];
|
||||
char disc_path[100];
|
||||
char titlestxt_path[100];
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "FileOperations/DirList.h"
|
||||
#include "main.h"
|
||||
#include "fatmounter.h"
|
||||
#include "filelist.h"
|
||||
#include "prompts/filebrowser.h"
|
||||
#include "sys.h"
|
||||
@ -278,16 +277,6 @@ int MenuLanguageSelect()
|
||||
strcat (entered, "/");
|
||||
snprintf(Settings.languagefiles_path, sizeof(Settings.languagefiles_path), entered);
|
||||
WindowPrompt(tr("Languagepath changed."), 0, tr("OK"));
|
||||
if (isInserted(Settings.BootDevice))
|
||||
{
|
||||
Settings.Save();
|
||||
returnhere = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowPrompt( tr( "No SD-Card inserted!" ), tr( "Insert an SD-Card to save." ), tr( "OK" ) );
|
||||
}
|
||||
}
|
||||
if ( Dir.GetFilecount() > 0 )
|
||||
{
|
||||
@ -342,16 +331,10 @@ int MenuLanguageSelect()
|
||||
***************************************************************************/
|
||||
int MenuThemeSelect()
|
||||
{
|
||||
char themepath[250];
|
||||
int cnt = 0;
|
||||
int ret = 0, choice = 0;
|
||||
int returnVal = 0;
|
||||
|
||||
snprintf(themepath, sizeof(themepath), Settings.theme_path);
|
||||
|
||||
char * ptr = strrchr(themepath, '/');
|
||||
if(ptr && *ptr != '\0') ptr[1] = '\0';
|
||||
|
||||
GuiImageData btnOutline(Resources::GetFile("button_dialogue_box.png"), Resources::GetFileSize("button_dialogue_box.png"));
|
||||
GuiImageData settingsbg(Resources::GetFile("settings_background.png"), Resources::GetFileSize("settings_background.png"));
|
||||
|
||||
@ -360,7 +343,7 @@ int MenuThemeSelect()
|
||||
GuiTrigger trigB;
|
||||
trigB.SetButtonOnlyTrigger( -1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B );
|
||||
|
||||
GuiText titleTxt(themepath, 24, ( GXColor ) {0, 0, 0, 255} );
|
||||
GuiText titleTxt(Settings.theme_path, 24, ( GXColor ) {0, 0, 0, 255} );
|
||||
titleTxt.SetAlignment( ALIGN_CENTRE, ALIGN_MIDDLE );
|
||||
titleTxt.SetPosition( 0, 0 );
|
||||
GuiButton pathBtn( 300, 50 );
|
||||
@ -413,7 +396,7 @@ int MenuThemeSelect()
|
||||
defaultBtn.SetTrigger( &trigA );
|
||||
defaultBtn.SetEffectGrow();
|
||||
|
||||
DirList * Dir = new DirList(themepath, ".them");
|
||||
DirList * Dir = new DirList(Settings.theme_path, ".them");
|
||||
OptionList options2;
|
||||
|
||||
for ( cnt = 0; cnt < Dir->GetFilecount(); cnt++ )
|
||||
@ -462,6 +445,7 @@ int MenuThemeSelect()
|
||||
if ( choice == 1 )
|
||||
{
|
||||
snprintf(Settings.theme_path, sizeof(Settings.theme_path), "%stheme/", Settings.ConfigPath);
|
||||
strcpy(Settings.theme, "");
|
||||
Theme::SetDefault();
|
||||
Settings.Save();
|
||||
returnVal = 1;
|
||||
@ -475,19 +459,19 @@ int MenuThemeSelect()
|
||||
w.Remove( &backBtn );
|
||||
w.Remove( &pathBtn );
|
||||
w.Remove( &defaultBtn );
|
||||
int result = BrowseDevice(themepath, sizeof(themepath), FB_DEFAULT, noFILES);
|
||||
int result = BrowseDevice(Settings.theme_path, sizeof(Settings.theme_path), FB_DEFAULT, noFILES);
|
||||
w.Append( &optionBrowser4 );
|
||||
w.Append( &pathBtn );
|
||||
w.Append( &backBtn );
|
||||
w.Append( &defaultBtn );
|
||||
if (result == 1)
|
||||
{
|
||||
if (themepath[strlen(themepath)-1] != '/')
|
||||
strcat(themepath, "/");
|
||||
if (Settings.theme_path[strlen(Settings.theme_path)-1] != '/')
|
||||
strcat(Settings.theme_path, "/");
|
||||
|
||||
HaltGui();
|
||||
delete Dir;
|
||||
Dir = new DirList(themepath, ".them");
|
||||
Dir = new DirList(Settings.theme_path, ".them");
|
||||
options2.ClearList();
|
||||
for ( cnt = 0; cnt < Dir->GetFilecount(); cnt++ )
|
||||
{
|
||||
@ -498,7 +482,7 @@ int MenuThemeSelect()
|
||||
options2.SetName( cnt, "%s", filename );
|
||||
options2.SetValue( cnt, NULL );
|
||||
}
|
||||
titleTxt.SetText(themepath);
|
||||
titleTxt.SetText(Settings.theme_path);
|
||||
ResumeGui();
|
||||
WindowPrompt( tr( "Theme path is changed." ), 0, tr( "OK" ) );
|
||||
}
|
||||
@ -512,16 +496,17 @@ int MenuThemeSelect()
|
||||
choice = WindowPrompt( tr( "Do you want to load this theme?" ), Dir->GetFilename(ret), tr( "Yes" ), tr( "Cancel" ) );
|
||||
if ( choice == 1 )
|
||||
{
|
||||
snprintf(Settings.theme_path, sizeof( Settings.theme_path ), "%s", Dir->GetFilepath(ret));
|
||||
if ( !CheckFile( Settings.theme_path ) )
|
||||
snprintf(Settings.theme, sizeof( Settings.theme ), "%s", Dir->GetFilepath(ret));
|
||||
if ( !CheckFile( Settings.theme ) )
|
||||
{
|
||||
WindowPrompt( tr( "File not found." ), tr( "Loading default theme." ), tr( "OK" ) );
|
||||
Theme::SetDefault();
|
||||
strcpy(Settings.theme, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
HaltGui();
|
||||
Theme::Load(Settings.theme_path);
|
||||
Theme::Load(Settings.theme);
|
||||
ResumeGui();
|
||||
}
|
||||
Settings.Save();
|
||||
|
@ -66,7 +66,7 @@ void CustomPathsSM::SetOptionValues()
|
||||
Options->SetValue(Idx++, Settings.disc_path);
|
||||
|
||||
//! Settings: Theme Path
|
||||
Options->SetValue(Idx++, Settings.theme_path);
|
||||
Options->SetValue(Idx++, strlen(Settings.theme) == 0 ? tr("Default") : Settings.theme);
|
||||
|
||||
//! Settings: WiiTDB Path
|
||||
Options->SetValue(Idx++, Settings.titlestxt_path);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "settings/SettingsPrompts.h"
|
||||
#include "settings/GameTitles.h"
|
||||
#include "xml/xml.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
static const char * OnOffText[MAX_ON_OFF] =
|
||||
{
|
||||
@ -200,11 +199,6 @@ int GuiSettingsMenu::GetMenuInternal()
|
||||
//! Settings: App Language
|
||||
if (ret == ++Idx)
|
||||
{
|
||||
if (!isInserted(Settings.BootDevice))
|
||||
{
|
||||
WindowPrompt(tr( "No SD-Card inserted!" ), tr( "Insert an SD-Card to use this option." ), tr( "OK" ));
|
||||
return MENU_NONE;
|
||||
}
|
||||
if (!Settings.godmode)
|
||||
{
|
||||
WindowPrompt(tr( "Language change:" ), tr( "Console should be unlocked to modify it." ), tr( "OK" ));
|
||||
|
@ -23,6 +23,7 @@
|
||||
***************************************************************************/
|
||||
#include <unistd.h>
|
||||
#include "GameLoadSM.hpp"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "settings/CSettings.h"
|
||||
#include "prompts/PromptWindows.h"
|
||||
#include "language/gettext.h"
|
||||
@ -36,10 +37,6 @@
|
||||
#include "xml/xml.h"
|
||||
#include "menu.h"
|
||||
|
||||
extern PartList partitions;
|
||||
extern char game_partition[6];
|
||||
extern u8 load_from_fs;
|
||||
|
||||
static const char * OnOffText[MAX_ON_OFF] =
|
||||
{
|
||||
trNOOP( "OFF" ),
|
||||
@ -96,11 +93,11 @@ static inline bool IsValidPartition(int fs_type, int cios)
|
||||
{
|
||||
if (IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, cios)) < 18)
|
||||
{
|
||||
return fs_type == FS_TYPE_WBFS;
|
||||
return fs_type == PART_FS_WBFS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fs_type == FS_TYPE_WBFS || fs_type == FS_TYPE_FAT32 || fs_type == FS_TYPE_NTFS || fs_type == FS_TYPE_EXT;
|
||||
return fs_type == PART_FS_WBFS || fs_type == PART_FS_FAT || fs_type == PART_FS_NTFS || fs_type == PART_FS_EXT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,10 +131,7 @@ GameLoadSM::~GameLoadSM()
|
||||
//! if partition has changed, Reinitialize it
|
||||
if (Settings.partition != OldSettingsPartition)
|
||||
{
|
||||
PartInfo pinfo = partitions.pinfo[Settings.partition];
|
||||
partitionEntry pentry = partitions.pentry[Settings.partition];
|
||||
WBFS_OpenPart(pinfo.part_fs, pinfo.index, pentry.sector, pentry.size, (char *) &game_partition);
|
||||
load_from_fs = pinfo.part_fs;
|
||||
WBFS_OpenPart(Settings.partition);
|
||||
|
||||
//! Reload the new game titles
|
||||
gameList.ReadGameList();
|
||||
@ -171,13 +165,9 @@ void GameLoadSM::SetOptionValues()
|
||||
Options->SetValue(Idx++, "********");
|
||||
|
||||
//! Settings: Partition
|
||||
PartInfo pInfo = partitions.pinfo[Settings.partition];
|
||||
f32 partition_size = partitions.pentry[Settings.partition].size
|
||||
* (partitions.sector_size / GB_SIZE);
|
||||
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
// Get the partition name and it's size in GB's
|
||||
Options->SetValue(Idx++, "%s%d (%.2fGB)", pInfo.fs_type == FS_TYPE_FAT32 ? "FAT"
|
||||
: pInfo.fs_type == FS_TYPE_NTFS ? "NTFS" : pInfo.fs_type == FS_TYPE_EXT ? "LINUX" : "WBFS", pInfo.index, partition_size);
|
||||
Options->SetValue(Idx++, "%s (%.2fGB)", usbHandle->GetFSName(Settings.partition), usbHandle->GetSize(Settings.partition)/GB_SIZE);
|
||||
|
||||
//! Settings: Install directories
|
||||
Options->SetValue(Idx++, "%s", tr( InstallToText[Settings.InstallToDir] ));
|
||||
@ -279,16 +269,16 @@ int GameLoadSM::GetMenuInternal()
|
||||
else if (ret == ++Idx)
|
||||
{
|
||||
// Select the next valid partition, even if that's the same one
|
||||
int fs_type = partitions.pinfo[Settings.partition].fs_type;
|
||||
int fs_type = 0;
|
||||
int ios = IOS_GetVersion();
|
||||
do
|
||||
{
|
||||
Settings.partition = (Settings.partition + 1) % partitions.num;
|
||||
fs_type = partitions.pinfo[Settings.partition].fs_type;
|
||||
Settings.partition = (Settings.partition + 1) % DeviceHandler::Instance()->GetUSBHandle()->GetPartitionCount();
|
||||
fs_type = DeviceHandler::GetUSBFilesystemType(Settings.partition);
|
||||
}
|
||||
while (!IsValidPartition(fs_type, ios));
|
||||
|
||||
if(fs_type == FS_TYPE_FAT32 && Settings.GameSplit == GAMESPLIT_NONE)
|
||||
if(fs_type == PART_FS_FAT && Settings.GameSplit == GAMESPLIT_NONE)
|
||||
Settings.GameSplit = GAMESPLIT_4GB;
|
||||
}
|
||||
|
||||
@ -303,7 +293,7 @@ int GameLoadSM::GetMenuInternal()
|
||||
{
|
||||
if (++Settings.GameSplit >= GAMESPLIT_MAX)
|
||||
{
|
||||
if(partitions.pinfo[Settings.partition].fs_type == FS_TYPE_FAT32)
|
||||
if(DeviceHandler::GetUSBFilesystemType(Settings.partition) == PART_FS_FAT)
|
||||
Settings.GameSplit = GAMESPLIT_2GB;
|
||||
else
|
||||
Settings.GameSplit = GAMESPLIT_NONE;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "mload/mload.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "settings/CSettings.h"
|
||||
#include "settings/newtitles.h"
|
||||
#include "language/gettext.h"
|
||||
@ -12,7 +13,6 @@
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "themes/CTheme.h"
|
||||
#include "audio.h"
|
||||
#include "fatmounter.h"
|
||||
#include "lstub.h"
|
||||
#include "menu.h"
|
||||
#include "video.h"
|
||||
@ -96,8 +96,7 @@ void ExitApp(void)
|
||||
{
|
||||
AppCleanUp();
|
||||
WBFS_Close();
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
DeviceHandler::DestroyInstance();
|
||||
USB_Deinitialize();
|
||||
if(Settings.PlaylogUpdate)
|
||||
Playlog_Delete(); // Don't show USB Loader GX in the Wii message board
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "IosLoader.h"
|
||||
#include "../fatmounter.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "../usbloader/usbstorage2.h"
|
||||
#include "../usbloader/disc.h"
|
||||
#include "../usbloader/wbfs.h"
|
||||
@ -52,10 +52,6 @@ s32 IosLoader::LoadAppCios()
|
||||
if((int) activeCios == Settings.cios)
|
||||
return 0;
|
||||
|
||||
// Unmount fat before reloading IOS.
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
u32 ciosLoadPriority[] = { 250, 249, 222, Settings.cios }; // Descending.
|
||||
|
||||
|
||||
@ -95,14 +91,12 @@ s32 IosLoader::LoadGameCios(s32 ios)
|
||||
// Unmount fat before reloading IOS.
|
||||
WBFS_Close();
|
||||
WDVD_Close();
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
DeviceHandler::Instance()->UnMountAll();
|
||||
|
||||
ret = ReloadIosSafe(ios);
|
||||
|
||||
// Remount devices after reloading IOS.
|
||||
SDCard_Init();
|
||||
USBDevice_Init_Loop();
|
||||
DeviceHandler::Instance()->MountAll();
|
||||
Disc_Init();
|
||||
|
||||
return ret;
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "CTheme.h"
|
||||
#include "libwiigui/gui.h"
|
||||
#include "settings/CSettings.h"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "FreeTypeGX.h"
|
||||
|
||||
@ -48,19 +49,12 @@ void Theme::SetDefault()
|
||||
{
|
||||
ShowTooltips = true;
|
||||
CleanUp();
|
||||
strcpy(Settings.theme, "");
|
||||
LoadFont("");
|
||||
}
|
||||
|
||||
bool Theme::Load(const char * theme_file_path)
|
||||
{
|
||||
char theme_path[300];
|
||||
snprintf(theme_path, sizeof(theme_path), theme_file_path);
|
||||
|
||||
char * ptr = strrchr(theme_path, '/');
|
||||
if(ptr) *ptr = '\0';
|
||||
|
||||
Theme::LoadFont(theme_path); //! support old font style
|
||||
|
||||
bool result = LoadTheme(theme_file_path);
|
||||
if(!result)
|
||||
return result;
|
||||
@ -97,6 +91,12 @@ bool Theme::Load(const char * theme_file_path)
|
||||
if(!Foldername)
|
||||
return result;
|
||||
|
||||
char theme_path[300];
|
||||
snprintf(theme_path, sizeof(theme_path), theme_file_path);
|
||||
|
||||
char * ptr = strrchr(theme_path, '/');
|
||||
if(ptr) *ptr = '\0';
|
||||
|
||||
snprintf(theme_path, sizeof(theme_path), "%s/%s", theme_path, Foldername);
|
||||
Resources::LoadFiles(theme_path);
|
||||
|
||||
|
146
source/usbloader/MountGamePartition.cpp
Normal file
146
source/usbloader/MountGamePartition.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "wad/nandtitle.h"
|
||||
#include "system/IosLoader.h"
|
||||
#include "menu/menus.h"
|
||||
#include "wpad.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "usbloader/GameList.h"
|
||||
#include "settings/GameTitles.h"
|
||||
#include "xml/WiiTDB.hpp"
|
||||
|
||||
static int FindGamePartition()
|
||||
{
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
// Loop through all WBFS partitions first to check them in case IOS249 Rev < 18
|
||||
for(int i = 0; i < usbHandle->GetPartitionCount(); ++i)
|
||||
{
|
||||
if(strncmp(usbHandle->GetFSName(i), "WBFS", 4) != 0)
|
||||
continue;
|
||||
|
||||
if (WBFS_OpenPart(i) == 0)
|
||||
{
|
||||
Settings.partition = i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, IOS_GetVersion())) < 18)
|
||||
return -1;
|
||||
|
||||
// Loop through FAT/NTFS/EXT partitions, and find the first partition with games on it (if there is one)
|
||||
for(int i = 0; i < usbHandle->GetPartitionCount(); ++i)
|
||||
{
|
||||
if(strncmp(usbHandle->GetFSName(i), "NTFS", 4) != 0 &&
|
||||
strncmp(usbHandle->GetFSName(i), "FAT", 3) != 0 &&
|
||||
strncmp(usbHandle->GetFSName(i), "LINUX", 5) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (WBFS_OpenPart(i) != 0)
|
||||
continue;
|
||||
|
||||
u32 count;
|
||||
// Get the game count...
|
||||
WBFS_GetCount(&count);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
Settings.partition = i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WBFS_Close();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int PartitionChoice()
|
||||
{
|
||||
int ret = -1;
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
|
||||
int choice = WindowPrompt(tr( "No WBFS or FAT/NTFS/EXT partition found" ),
|
||||
tr( "You need to select or format a partition" ), tr( "Select" ), tr( "Format" ), tr( "Return" ));
|
||||
|
||||
if (choice == 0)
|
||||
{
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
else if(choice == 1)
|
||||
{
|
||||
int part_num = SelectPartitionMenu();
|
||||
if(part_num >= 0)
|
||||
{
|
||||
if(IosLoader::IsWaninkokoIOS() && NandTitles.VersionOf(TITLE_ID(1, IOS_GetVersion())) < 18 &&
|
||||
(strncmp(usbHandle->GetFSName(part_num), "NTFS", 4) == 0 ||
|
||||
strncmp(usbHandle->GetFSName(part_num), "FAT", 3) == 0 ||
|
||||
strncmp(usbHandle->GetFSName(part_num), "LINUX", 5) == 0))
|
||||
{
|
||||
WindowPrompt(tr("Warning:"), tr("You are trying to select a FAT32/NTFS/EXT partition with cIOS 249 Rev < 18. This is not supported. Continue on your own risk."), tr("OK"));
|
||||
}
|
||||
|
||||
ret = WBFS_OpenPart(part_num);
|
||||
|
||||
Settings.partition = part_num;
|
||||
Settings.Save();
|
||||
}
|
||||
}
|
||||
else if(choice == 2)
|
||||
{
|
||||
while(ret < 0 || ret == -666)
|
||||
{
|
||||
int part_num = SelectPartitionMenu();
|
||||
if(part_num >= 0)
|
||||
ret = FormatingPartition(tr( "Formatting, please wait..." ), part_num);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MountGamePartition
|
||||
***************************************************************************/
|
||||
int MountGamePartition(bool ShowGUI)
|
||||
{
|
||||
gprintf("MountGamePartition()\n");
|
||||
|
||||
s32 wbfsinit = MountWBFS(ShowGUI);
|
||||
if (wbfsinit < 0)
|
||||
{
|
||||
if(ShowGUI) WindowPrompt(tr( "Error !" ), tr( "USB Device not found" ), tr( "OK" ));
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
||||
s32 ret = WBFS_OpenPart(Settings.partition);
|
||||
if(ret < 0)
|
||||
ret = FindGamePartition();
|
||||
|
||||
if (ret < 0 && ShowGUI)
|
||||
ret = PartitionChoice();
|
||||
|
||||
if(ret < 0)
|
||||
Sys_LoadMenu();
|
||||
|
||||
gprintf("\tDisc_Init\n");
|
||||
ret = Disc_Init();
|
||||
if (ret < 0)
|
||||
{
|
||||
if(ShowGUI)
|
||||
WindowPrompt(tr( "Error !" ), tr( "Could not initialize DIP module!" ), tr( "OK" ));
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
||||
gprintf("\tOpenXMLDatabase\n");
|
||||
|
||||
GameTitles.LoadTitlesFromWiiTDB(Settings.titlestxt_path);
|
||||
|
||||
return ret;
|
||||
}
|
6
source/usbloader/MountGamePartition.h
Normal file
6
source/usbloader/MountGamePartition.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef MOUNTGAMEPARTITION_H_
|
||||
#define MOUNTGAMEPARTITION_H_
|
||||
|
||||
int MountGamePartition(bool ShowGUI = true);
|
||||
|
||||
#endif
|
@ -4,7 +4,6 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "apploader.h"
|
||||
#include "wdvd.h"
|
||||
#include "fstfile.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "wbfs.h"
|
||||
#include "../settings/SettingsEnums.h"
|
||||
#include "../gecko.h"
|
||||
#include "../fatmounter.h"
|
||||
|
||||
/* Constants */
|
||||
#define PTABLE_OFFSET 0x40000
|
||||
|
@ -1,428 +0,0 @@
|
||||
// Modified by oggzee
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "partition_usbloader.h"
|
||||
#include "sdhc.h"
|
||||
#include "usbstorage2.h"
|
||||
#include "utils.h"
|
||||
#include "wbfs.h"
|
||||
#include "libs/libwbfs/libwbfs.h"
|
||||
|
||||
/* 'partition table' structure */
|
||||
typedef struct
|
||||
{
|
||||
/* Zero bytes */
|
||||
u8 padding[446];
|
||||
|
||||
/* Partition table entries */
|
||||
partitionEntry entries[MAX_PARTITIONS];
|
||||
}ATTRIBUTE_PACKED partitionTable;
|
||||
|
||||
s32 Partition_GetEntries(u32 device, partitionEntry *outbuf, u32 *outval)
|
||||
{
|
||||
static partitionTable table ATTRIBUTE_ALIGN( 32 );
|
||||
|
||||
u32 cnt, sector_size;
|
||||
s32 ret;
|
||||
|
||||
/* Read from specified device */
|
||||
switch (device)
|
||||
{
|
||||
case WBFS_DEVICE_USB:
|
||||
{
|
||||
/* Get sector size */
|
||||
ret = USBStorage2_GetCapacity(§or_size);
|
||||
if (ret == 0) return -1;
|
||||
|
||||
/* Read partition table */
|
||||
ret = USBStorage2_ReadSectors(0, 1, &table);
|
||||
if (ret < 0) return ret;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WBFS_DEVICE_SDHC:
|
||||
{
|
||||
/* SDHC sector size */
|
||||
sector_size = SDHC_SECTOR_SIZE;
|
||||
|
||||
/* Read partition table */
|
||||
ret = SDHC_ReadSectors(0, 1, &table);
|
||||
if (!ret) return -1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Swap endianess */
|
||||
for (cnt = 0; cnt < 4; cnt++)
|
||||
{
|
||||
partitionEntry *entry = &table.entries[cnt];
|
||||
|
||||
entry->sector = swap32(entry->sector);
|
||||
entry->size = swap32(entry->size);
|
||||
}
|
||||
|
||||
/* Set partition entries */
|
||||
memcpy(outbuf, table.entries, sizeof(table.entries));
|
||||
|
||||
/* Set sector size */
|
||||
*outval = sector_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Device_ReadSectors(u32 device, u32 sector, u32 count, void *buffer)
|
||||
{
|
||||
s32 ret;
|
||||
|
||||
/* Read from specified device */
|
||||
switch (device)
|
||||
{
|
||||
case WBFS_DEVICE_USB:
|
||||
ret = USBStorage2_ReadSectors(sector, count, buffer);
|
||||
if (ret < 0) return false;
|
||||
return true;
|
||||
|
||||
case WBFS_DEVICE_SDHC:
|
||||
return SDHC_ReadSectors(sector, count, buffer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Device_WriteSectors(u32 device, u32 sector, u32 count, void *buffer)
|
||||
{
|
||||
s32 ret;
|
||||
|
||||
/* Read from specified device */
|
||||
switch (device)
|
||||
{
|
||||
case WBFS_DEVICE_USB:
|
||||
ret = USBStorage2_WriteSectors(sector, count, buffer);
|
||||
if (ret < 0) return false;
|
||||
return true;
|
||||
|
||||
case WBFS_DEVICE_SDHC:
|
||||
return SDHC_WriteSectors(sector, count, buffer);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 Partition_GetEntriesEx(u32 device, partitionEntry *outbuf, u32 *psect_size, u8 *num)
|
||||
{
|
||||
static u8 Buffer[sizeof(partitionTable)] ATTRIBUTE_ALIGN( 32 );
|
||||
partitionTable *table = (partitionTable *) Buffer;
|
||||
partitionEntry *entry;
|
||||
|
||||
u32 i, sector_size;
|
||||
s32 ret;
|
||||
int maxpart = *num;
|
||||
|
||||
// Get sector size
|
||||
switch (device)
|
||||
{
|
||||
case WBFS_DEVICE_USB:
|
||||
ret = USBStorage2_GetCapacity(§or_size);
|
||||
if (ret == 0) return -1;
|
||||
break;
|
||||
case WBFS_DEVICE_SDHC:
|
||||
sector_size = SDHC_SECTOR_SIZE;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
/* Set sector size */
|
||||
*psect_size = sector_size;
|
||||
|
||||
u32 ext = 0;
|
||||
u32 next = 0;
|
||||
|
||||
// Read partition table
|
||||
ret = Device_ReadSectors(device, 0, 1, table);
|
||||
if (!ret) return -1;
|
||||
// Check if it's a RAW WBFS disc, without partition table
|
||||
if (get_fs_type((u8 *) table) == FS_TYPE_WBFS)
|
||||
{
|
||||
memset(outbuf, 0, sizeof(table->entries));
|
||||
wbfs_head_t * head = (wbfs_head_t *) Buffer;
|
||||
outbuf->size = wbfs_ntohl( head->n_hd_sec );
|
||||
*num = 1;
|
||||
return 0;
|
||||
}
|
||||
/* Swap endianess */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
entry = &table->entries[i];
|
||||
entry->sector = swap32(entry->sector);
|
||||
entry->size = swap32(entry->size);
|
||||
if (!ext && part_is_extended(entry->type))
|
||||
{
|
||||
ext = entry->sector;
|
||||
}
|
||||
}
|
||||
/* Set partition entries */
|
||||
memcpy(outbuf, table->entries, sizeof(table->entries));
|
||||
// num primary
|
||||
*num = 4;
|
||||
|
||||
if (!ext) return 0;
|
||||
|
||||
next = ext;
|
||||
// scan extended partition for logical
|
||||
for (i = 0; i < maxpart - 4; i++)
|
||||
{
|
||||
ret = Device_ReadSectors(device, next, 1, table);
|
||||
if (!ret) break;
|
||||
if (i == 0)
|
||||
{
|
||||
// handle the invalid scenario where wbfs is on an EXTENDED
|
||||
// partition instead of on the Logical inside Extended.
|
||||
if (get_fs_type((u8 *) table) == FS_TYPE_WBFS) break;
|
||||
}
|
||||
entry = &table->entries[0];
|
||||
entry->sector = swap32(entry->sector);
|
||||
entry->size = swap32(entry->size);
|
||||
if (entry->type && entry->size && entry->sector)
|
||||
{
|
||||
// rebase to abolute address
|
||||
entry->sector += next;
|
||||
// add logical
|
||||
memcpy(&outbuf[*num], entry, sizeof(*entry));
|
||||
(*num)++;
|
||||
// get next
|
||||
entry++;
|
||||
if (entry->type && entry->size && entry->sector)
|
||||
{
|
||||
next = ext + swap32(entry->sector);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool part_is_extended(int type)
|
||||
{
|
||||
if (type == 0x05) return true;
|
||||
if (type == 0x0f) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool part_is_data(int type)
|
||||
{
|
||||
if (type && !part_is_extended(type)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool part_valid_data(partitionEntry *entry)
|
||||
{
|
||||
if (entry->size && entry->type && entry->sector)
|
||||
{
|
||||
return part_is_data(entry->type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
char* part_type_data(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0x01:
|
||||
return "FAT12";
|
||||
case 0x04:
|
||||
return "FAT16";
|
||||
case 0x06:
|
||||
return "FAT16"; //+
|
||||
case 0x07:
|
||||
return "NTFS";
|
||||
case 0x0b:
|
||||
return "FAT32";
|
||||
case 0x0c:
|
||||
return "FAT32";
|
||||
case 0x0e:
|
||||
return "FAT16";
|
||||
case 0x82:
|
||||
return "LxSWP";
|
||||
case 0x83:
|
||||
return "LINUX";
|
||||
case 0x8e:
|
||||
return "LxLVM";
|
||||
case 0xa8:
|
||||
return "OSX";
|
||||
case 0xab:
|
||||
return "OSXBT";
|
||||
case 0xaf:
|
||||
return "OSXHF";
|
||||
case 0xe8:
|
||||
return "LUKS";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *part_type_name(int type)
|
||||
{
|
||||
static char unk[8];
|
||||
if (type == 0) return "UNUSED";
|
||||
if (part_is_extended(type)) return "EXTEND";
|
||||
char *p = part_type_data(type);
|
||||
if (p) return p;
|
||||
sprintf(unk, "UNK-%02x", type);
|
||||
return unk;
|
||||
}
|
||||
|
||||
int get_fs_type(u8 *buff)
|
||||
{
|
||||
// WBFS
|
||||
wbfs_head_t *head = (wbfs_head_t *) buff;
|
||||
if (head->magic == wbfs_htonl( WBFS_MAGIC )) return FS_TYPE_WBFS;
|
||||
// 55AA
|
||||
if(*((u16 *) (buff + 0x1FE)) == 0x55AA)
|
||||
{
|
||||
// FAT
|
||||
if (memcmp(buff + 0x36, "FAT", 3) == 0) return FS_TYPE_FAT16;
|
||||
if (memcmp(buff + 0x52, "FAT", 3) == 0) return FS_TYPE_FAT32;
|
||||
// NTFS
|
||||
if (memcmp(buff + 0x03, "NTFS", 4) == 0) return FS_TYPE_NTFS;
|
||||
}
|
||||
|
||||
return FS_TYPE_UNK;
|
||||
}
|
||||
|
||||
int get_part_fs(int fs_type)
|
||||
{
|
||||
switch (fs_type)
|
||||
{
|
||||
case FS_TYPE_FAT32:
|
||||
return PART_FS_FAT;
|
||||
case FS_TYPE_NTFS:
|
||||
return PART_FS_NTFS;
|
||||
case FS_TYPE_WBFS:
|
||||
return PART_FS_WBFS;
|
||||
case FS_TYPE_EXT:
|
||||
return PART_FS_EXT;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_type_fat(int type)
|
||||
{
|
||||
return (type == FS_TYPE_FAT16 || type == FS_TYPE_FAT32);
|
||||
}
|
||||
|
||||
char *get_fs_name(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case FS_TYPE_FAT16:
|
||||
return "FAT16";
|
||||
case FS_TYPE_FAT32:
|
||||
return "FAT32";
|
||||
case FS_TYPE_NTFS:
|
||||
return "NTFS";
|
||||
case FS_TYPE_EXT:
|
||||
return "EXT";
|
||||
case FS_TYPE_WBFS:
|
||||
return "WBFS";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
s32 Partition_GetList(u32 device, PartList *plist)
|
||||
{
|
||||
partitionEntry *entry = NULL;
|
||||
PartInfo *pinfo = NULL;
|
||||
int i, ret;
|
||||
|
||||
memset(plist, 0, sizeof(PartList));
|
||||
|
||||
// Get partition entries
|
||||
plist->num = MAX_PARTITIONS_EX;
|
||||
ret = Partition_GetEntriesEx(device, plist->pentry, &plist->sector_size, &plist->num);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
// check for RAW WBFS disc
|
||||
if (plist->num == 1)
|
||||
{
|
||||
pinfo = &plist->pinfo[0];
|
||||
entry = &plist->pentry[0];
|
||||
plist->wbfs_n = 1;
|
||||
pinfo->wbfs_i = pinfo->index = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char buf[plist->sector_size];
|
||||
|
||||
// scan partitions for filesystem type
|
||||
for (i = 0; i < plist->num; i++)
|
||||
{
|
||||
pinfo = &plist->pinfo[i];
|
||||
entry = &plist->pentry[i];
|
||||
if (!entry->size) continue;
|
||||
if (!entry->type) continue;
|
||||
if (!entry->sector) continue;
|
||||
// even though wrong, it's possible WBFS is on an extended part.
|
||||
//if (!part_is_data(entry->type)) continue;
|
||||
if (!Device_ReadSectors(device, entry->sector, 1, buf)) continue;
|
||||
pinfo->fs_type = get_fs_type((u8 *) buf);
|
||||
if(entry->type == 0x83 && pinfo->fs_type == FS_TYPE_UNK) pinfo->fs_type = FS_TYPE_EXT;
|
||||
if (pinfo->fs_type == FS_TYPE_WBFS)
|
||||
{
|
||||
// multiple wbfs on sdhc not supported
|
||||
if (device == WBFS_DEVICE_SDHC && (plist->wbfs_n > 1 || i > 4)) continue;
|
||||
plist->wbfs_n++;
|
||||
pinfo->wbfs_i = pinfo->index = plist->wbfs_n;
|
||||
}
|
||||
else if (is_type_fat(pinfo->fs_type))
|
||||
{
|
||||
plist->fat_n++;
|
||||
pinfo->fat_i = pinfo->index = plist->fat_n;
|
||||
}
|
||||
else if (pinfo->fs_type == FS_TYPE_NTFS)
|
||||
{
|
||||
plist->ntfs_n++;
|
||||
pinfo->ntfs_i = pinfo->index = plist->ntfs_n;
|
||||
}
|
||||
else if (pinfo->fs_type == FS_TYPE_EXT)
|
||||
{
|
||||
plist->ext_n++;
|
||||
pinfo->ext_i = pinfo->index = plist->ext_n;
|
||||
}
|
||||
pinfo->part_fs = get_part_fs(pinfo->fs_type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Partition_FixEXT(u32 device, u8 part)
|
||||
{
|
||||
static partitionTable table ATTRIBUTE_ALIGN( 32 );
|
||||
int ret;
|
||||
|
||||
if (part > 3) return -1;
|
||||
// Read partition table
|
||||
ret = Device_ReadSectors(device, 0, 1, &table);
|
||||
if (!ret) return -1;
|
||||
if (part_is_extended(table.entries[part].type))
|
||||
{
|
||||
table.entries[part].type = 0x0b; // FAT32
|
||||
ret = Device_WriteSectors(device, 0, 1, &table);
|
||||
if (!ret) return -1;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
#ifndef _PARTITION_H_
|
||||
#define _PARTITION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* 'partition entry' structure */
|
||||
typedef struct
|
||||
{
|
||||
/* Boot indicator */
|
||||
u8 boot;
|
||||
|
||||
/* Starting CHS */
|
||||
u8 start[3];
|
||||
|
||||
/* Partition type */
|
||||
u8 type;
|
||||
|
||||
/* Ending CHS */
|
||||
u8 end[3];
|
||||
|
||||
/* Partition sector */
|
||||
u32 sector;
|
||||
|
||||
/* Partition size */
|
||||
u32 size;
|
||||
}ATTRIBUTE_PACKED partitionEntry;
|
||||
|
||||
/* Constants */
|
||||
#define MAX_PARTITIONS 4
|
||||
#define MAX_PARTITIONS_EX 10
|
||||
|
||||
#define FS_TYPE_UNK 0
|
||||
#define FS_TYPE_FAT16 1
|
||||
#define FS_TYPE_FAT32 2
|
||||
#define FS_TYPE_NTFS 3
|
||||
#define FS_TYPE_WBFS 4
|
||||
#define FS_TYPE_EXT 5
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 fs_type;
|
||||
u8 part_fs;
|
||||
u8 wbfs_i; // seq wbfs part index
|
||||
u8 fat_i; // seq fat part index
|
||||
u8 ntfs_i; // seq ntfs part index
|
||||
u8 ext_i; // seq ntfs part index
|
||||
u8 index;
|
||||
} PartInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 num;
|
||||
u32 sector_size;
|
||||
partitionEntry pentry[MAX_PARTITIONS_EX];
|
||||
u8 wbfs_n;
|
||||
u8 fat_n;
|
||||
u8 ntfs_n;
|
||||
u8 ext_n;
|
||||
PartInfo pinfo[MAX_PARTITIONS_EX];
|
||||
} PartList;
|
||||
|
||||
/* Prototypes */
|
||||
s32 Partition_GetEntries(u32 device, partitionEntry *outbuf, u32 *outval);
|
||||
s32 Partition_GetEntriesEx(u32 device, partitionEntry *outbuf, u32 *outval, u8 *num);
|
||||
bool Device_ReadSectors(u32 device, u32 sector, u32 count, void *buffer);
|
||||
bool Device_WriteSectors(u32 device, u32 sector, u32 count, void *buffer);
|
||||
s32 Partition_GetList(u32 device, PartList *plist);
|
||||
int Partition_FixEXT(u32 device, u8 part);
|
||||
|
||||
bool part_is_extended(int type);
|
||||
bool part_is_data(int type);
|
||||
char* part_type_data(int type);
|
||||
char* part_type_name(int type);
|
||||
bool part_valid_data(partitionEntry *entry);
|
||||
int get_fs_type(u8 *buf);
|
||||
bool is_type_fat(int type);
|
||||
char* get_fs_name(int i);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -2,8 +2,8 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "fatmounter.h"
|
||||
#include "wbfs.h"
|
||||
#include "usbloader/wbfs/wbfs_base.h"
|
||||
#include "usbloader/wbfs/wbfs_wbfs.h"
|
||||
@ -11,22 +11,14 @@
|
||||
#include "usbloader/wbfs/wbfs_ntfs.h"
|
||||
#include "usbloader/wbfs/wbfs_ext.h"
|
||||
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
#include "usbloader/GameList.h"
|
||||
#include "menu/menus.h"
|
||||
#include "gecko.h"
|
||||
|
||||
Wbfs *current = NULL;
|
||||
//#define DEBUG_WBFS
|
||||
|
||||
static Wbfs *current = NULL;
|
||||
/* WBFS device */
|
||||
s32 wbfsDev = WBFS_MIN_DEVICE;
|
||||
|
||||
// partition
|
||||
char wbfs_fs_drive[16];
|
||||
int wbfs_part_fs = PART_FS_WBFS;
|
||||
u32 wbfs_part_idx = 0;
|
||||
u32 wbfs_part_lba = 0;
|
||||
|
||||
wbfs_disc_t* WBFS_OpenDisc(u8 *discid)
|
||||
{
|
||||
@ -48,41 +40,32 @@ s32 WBFS_Init(u32 device)
|
||||
return Wbfs::Init(device);
|
||||
}
|
||||
|
||||
s32 WBFS_Open(void)
|
||||
s32 WBFS_OpenPart(int part_num)
|
||||
{
|
||||
WBFS_Close();
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
if(part_num < 0 || part_num > usbHandle->GetPartitionCount())
|
||||
return -1;
|
||||
|
||||
current = new Wbfs_Wbfs(WBFS_DEVICE_USB, 0, 0); // Fix me!
|
||||
|
||||
wbfs_part_fs = wbfs_part_idx = wbfs_part_lba = 0;
|
||||
wbfs_part_idx = 1;
|
||||
|
||||
return current->Open();
|
||||
}
|
||||
|
||||
s32 WBFS_OpenPart(u32 part_fs, u32 part_idx, u32 part_lba, u32 part_size, char *partition)
|
||||
{
|
||||
// close
|
||||
WBFS_Close();
|
||||
|
||||
if (part_fs == PART_FS_FAT)
|
||||
gprintf("\tWBFS_OpenPart: start sector %u, sector count: %u\n", usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
|
||||
if (strncmp(usbHandle->GetFSName(part_num), "FAT", 3) == 0)
|
||||
{
|
||||
current = new Wbfs_Fat(wbfsDev, part_lba, part_size);
|
||||
strcpy(wbfs_fs_drive, "USB:");
|
||||
current = new Wbfs_Fat(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
}
|
||||
else if (part_fs == PART_FS_NTFS)
|
||||
else if (strncmp(usbHandle->GetFSName(part_num), "NTFS", 4) == 0)
|
||||
{
|
||||
current = new Wbfs_Ntfs(wbfsDev, part_lba, part_size);
|
||||
strcpy(wbfs_fs_drive, "NTFS:");
|
||||
current = new Wbfs_Ntfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
}
|
||||
else if (part_fs == PART_FS_EXT)
|
||||
else if (strncmp(usbHandle->GetFSName(part_num), "LINUX", 5) == 0)
|
||||
{
|
||||
current = new Wbfs_Ext(wbfsDev, part_lba, part_size);
|
||||
strcpy(wbfs_fs_drive, "EXT:");
|
||||
current = new Wbfs_Ext(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
}
|
||||
else
|
||||
else if (strncmp(usbHandle->GetFSName(part_num), "WBFS", 4) == 0)
|
||||
{
|
||||
current = new Wbfs_Wbfs(wbfsDev, part_lba, part_size);
|
||||
current = new Wbfs_Wbfs(wbfsDev, usbHandle->GetLBAStart(part_num), usbHandle->GetSecCount(part_num));
|
||||
}
|
||||
if (current->Open())
|
||||
{
|
||||
@ -91,126 +74,8 @@ s32 WBFS_OpenPart(u32 part_fs, u32 part_idx, u32 part_lba, u32 part_size, char *
|
||||
return -1;
|
||||
}
|
||||
|
||||
// success
|
||||
wbfs_part_fs = part_fs;
|
||||
wbfs_part_idx = part_idx;
|
||||
wbfs_part_lba = part_lba;
|
||||
wbfs_part_idx = usbHandle->GetPartitionNum(part_num);
|
||||
|
||||
const char *fs = "WBFS";
|
||||
if (wbfs_part_fs == PART_FS_FAT) fs = "FAT";
|
||||
if (wbfs_part_fs == PART_FS_NTFS) fs = "NTFS";
|
||||
if (wbfs_part_fs == PART_FS_EXT) fs = "EXT";
|
||||
sprintf(partition, "%s%d", fs, wbfs_part_idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 WBFS_OpenNamed(char *partition)
|
||||
{
|
||||
u32 i;
|
||||
u32 part_fs = PART_FS_WBFS;
|
||||
u32 part_idx = 0;
|
||||
u32 part_lba = 0;
|
||||
s32 ret = 0;
|
||||
PartList plist;
|
||||
|
||||
// close
|
||||
WBFS_Close();
|
||||
|
||||
// parse partition option
|
||||
if (strncasecmp(partition, "WBFS", 4) == 0)
|
||||
{
|
||||
i = atoi(partition + 4);
|
||||
if (i < 1 || i > 4) goto err;
|
||||
part_fs = PART_FS_WBFS;
|
||||
part_idx = i;
|
||||
}
|
||||
else if (strncasecmp(partition, "FAT", 3) == 0)
|
||||
{
|
||||
if (wbfsDev != WBFS_DEVICE_USB) goto err;
|
||||
i = atoi(partition + 3);
|
||||
if (i < 1 || i > 9) goto err;
|
||||
part_fs = PART_FS_FAT;
|
||||
part_idx = i;
|
||||
}
|
||||
else if (strncasecmp(partition, "NTFS", 4) == 0)
|
||||
{
|
||||
i = atoi(partition + 4);
|
||||
if (i < 1 || i > 9) goto err;
|
||||
part_fs = PART_FS_NTFS;
|
||||
part_idx = i;
|
||||
}
|
||||
else if (strncasecmp(partition, "EXT", 3) == 0)
|
||||
{
|
||||
i = atoi(partition + 3);
|
||||
if (i < 1 || i > 9) goto err;
|
||||
part_fs = PART_FS_EXT;
|
||||
part_idx = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
// Get partition entries
|
||||
ret = Partition_GetList(wbfsDev, &plist);
|
||||
if (ret || plist.num == 0) return -1;
|
||||
|
||||
if (part_fs == PART_FS_WBFS)
|
||||
{
|
||||
if (part_idx > plist.wbfs_n) goto err;
|
||||
for (i = 0; i < plist.num; i++)
|
||||
{
|
||||
if (plist.pinfo[i].wbfs_i == part_idx) break;
|
||||
}
|
||||
}
|
||||
else if (part_fs == PART_FS_FAT)
|
||||
{
|
||||
if (part_idx > plist.fat_n) goto err;
|
||||
for (i = 0; i < plist.num; i++)
|
||||
{
|
||||
if (plist.pinfo[i].fat_i == part_idx) break;
|
||||
}
|
||||
}
|
||||
else if (part_fs == PART_FS_NTFS)
|
||||
{
|
||||
if (part_idx > plist.ntfs_n) goto err;
|
||||
for (i = 0; i < plist.num; i++)
|
||||
{
|
||||
if (plist.pinfo[i].ntfs_i == part_idx) break;
|
||||
}
|
||||
}
|
||||
else if (part_fs == PART_FS_EXT)
|
||||
{
|
||||
if (part_idx > plist.ext_n) goto err;
|
||||
for (i = 0; i < plist.num; i++)
|
||||
{
|
||||
if (plist.pinfo[i].ext_i == part_idx) break;
|
||||
}
|
||||
}
|
||||
if (i >= plist.num) goto err;
|
||||
// set partition lba sector
|
||||
part_lba = plist.pentry[i].sector;
|
||||
|
||||
if (WBFS_OpenPart(part_fs, part_idx, part_lba, plist.pentry[i].size, partition))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
// success
|
||||
return 0;
|
||||
err: return -1;
|
||||
}
|
||||
|
||||
s32 WBFS_OpenLBA(u32 lba, u32 size)
|
||||
{
|
||||
Wbfs *part = new Wbfs_Wbfs(wbfsDev, lba, size);
|
||||
if (part->Open() != 0)
|
||||
{
|
||||
delete part;
|
||||
return -1;
|
||||
}
|
||||
|
||||
WBFS_Close();
|
||||
current = part;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -223,11 +88,6 @@ bool WBFS_Close(void)
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
wbfs_part_fs = 0;
|
||||
wbfs_part_idx = 0;
|
||||
wbfs_part_lba = 0;
|
||||
wbfs_fs_drive[0] = '\0';
|
||||
|
||||
gameList.clear();
|
||||
|
||||
return 0;
|
||||
@ -235,7 +95,7 @@ bool WBFS_Close(void)
|
||||
|
||||
bool WBFS_Mounted()
|
||||
{
|
||||
return (current != NULL && current->Mounted());
|
||||
return (current != NULL && current->IsMounted());
|
||||
}
|
||||
|
||||
s32 WBFS_Format(u32 lba, u32 size)
|
||||
@ -325,15 +185,15 @@ int MountWBFS(bool ShowGUI)
|
||||
|
||||
while (time(0) - currTime < 30)
|
||||
{
|
||||
|
||||
USBDevice_deInit();
|
||||
USBStorage2_Deinit();
|
||||
USBDevice_Init();
|
||||
ret = WBFS_Init(WBFS_DEVICE_USB);
|
||||
printf("%i...", int(time(0) - currTime));
|
||||
if (ret < 0)
|
||||
sleep(1);
|
||||
else break;
|
||||
else
|
||||
break;
|
||||
|
||||
DeviceHandler::Instance()->UnMountAllUSB();
|
||||
DeviceHandler::Instance()->MountAllUSB();
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
@ -18,15 +18,12 @@ extern "C"
|
||||
#define WBFS_MIN_DEVICE 1
|
||||
#define WBFS_MAX_DEVICE 2
|
||||
|
||||
extern s32 wbfsDev;
|
||||
extern int wbfs_part_fs;
|
||||
extern s32 wbfsDev;
|
||||
extern u32 wbfs_part_idx;
|
||||
extern u32 wbfs_part_lba;
|
||||
extern char wbfs_fs_drive[16];
|
||||
|
||||
/* Prototypes */
|
||||
s32 WBFS_Init(u32);
|
||||
s32 WBFS_Open(void);
|
||||
s32 WBFS_Format(u32, u32);
|
||||
s32 WBFS_GetCount(u32 *);
|
||||
s32 WBFS_GetHeaders(struct discHdr *, u32, u32);
|
||||
@ -48,9 +45,7 @@ extern "C"
|
||||
s32 __WBFS_WriteUSB(void *fp, u32 lba, u32 count, void *iobuf);
|
||||
*/
|
||||
|
||||
s32 WBFS_OpenPart(u32 part_fat, u32 part_idx, u32 part_lba, u32 part_size, char *partition);
|
||||
s32 WBFS_OpenNamed(char *partition);
|
||||
s32 WBFS_OpenLBA(u32 lba, u32 size);
|
||||
s32 WBFS_OpenPart(int part_num);
|
||||
wbfs_disc_t* WBFS_OpenDisc(u8 *discid);
|
||||
void WBFS_CloseDisc(wbfs_disc_t *disc);
|
||||
bool WBFS_Close();
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "usbloader/sdhc.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "fatmounter.h"
|
||||
#include "wbfs_rw.h"
|
||||
|
||||
#include "wbfs_base.h"
|
||||
@ -121,12 +120,6 @@ wbfs_t *Wbfs::GetHddInfo()
|
||||
return hdd;
|
||||
}
|
||||
|
||||
bool Wbfs::Mounted()
|
||||
{
|
||||
return hdd == NULL;
|
||||
}
|
||||
|
||||
|
||||
bool Wbfs::ShowFreeSpace(void)
|
||||
{
|
||||
return true;
|
||||
|
@ -18,7 +18,7 @@ class Wbfs
|
||||
s32 CheckGame(u8 *);
|
||||
s32 GameSize(u8 *, f32 *);
|
||||
wbfs_t *GetHddInfo(void);
|
||||
bool Mounted();
|
||||
bool IsMounted() { return hdd == 0; };
|
||||
virtual int GetFragList(u8 *id) { return 0; };
|
||||
virtual bool ShowFreeSpace(void);
|
||||
|
||||
|
@ -2,36 +2,17 @@
|
||||
#include "usbloader/usbstorage2.h"
|
||||
#include "wbfs_ext.h"
|
||||
|
||||
extern int wbfs_part_fs;
|
||||
sec_t ext_wbfs_sec = 0;
|
||||
|
||||
s32 Wbfs_Ext::Open()
|
||||
{
|
||||
Close();
|
||||
strcpy(wbfs_fs_drive, "EXT:");
|
||||
|
||||
if (Mounted)
|
||||
return 0;
|
||||
|
||||
Mounted = ext2Mount("EXT", &__io_usbstorage2, lba, CACHE_SIZE, CACHED_SECTORS, EXT2_FLAG_DEFAULT);
|
||||
if (!Mounted)
|
||||
return -2;
|
||||
|
||||
s32 ret = Wbfs_Fat::Open();
|
||||
if(ret == 0)
|
||||
{
|
||||
ext_wbfs_sec = lba;
|
||||
wbfs_part_fs = PART_FS_EXT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Wbfs_Ext::Close()
|
||||
{
|
||||
if (hdd)
|
||||
{
|
||||
wbfs_close(hdd);
|
||||
hdd = NULL;
|
||||
}
|
||||
|
||||
/* Unmount device */
|
||||
ext2Unmount("EXT:/");
|
||||
|
||||
Mounted = false;
|
||||
ext_wbfs_sec = 0;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <ext2.h>
|
||||
#include "wbfs_fat.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
class Wbfs_Ext: public Wbfs_Fat
|
||||
{
|
||||
@ -14,7 +13,6 @@ class Wbfs_Ext: public Wbfs_Fat
|
||||
}
|
||||
|
||||
virtual s32 Open();
|
||||
virtual void Close();
|
||||
bool ShowFreeSpace(void) { return true; };
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <ctype.h>
|
||||
#include <fat.h>
|
||||
|
||||
#include "Controls/DeviceHandler.hpp"
|
||||
#include "FileOperations/fileops.h"
|
||||
#include "settings/CSettings.h"
|
||||
#include "settings/GameTitles.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "language/gettext.h"
|
||||
#include "libs/libfat/fatfile_frag.h"
|
||||
#include "utils/ShowError.h"
|
||||
#include "fatmounter.h"
|
||||
#include "wbfs_fat.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
@ -33,8 +33,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern int wbfs_part_fs;
|
||||
sec_t fat_wbfs_sec = 0;
|
||||
int wbfs_part_fs;
|
||||
|
||||
char Wbfs_Fat::wbfs_fs_drive[16];
|
||||
char Wbfs_Fat::wbfs_fat_dir[16] = "/wbfs";
|
||||
@ -44,7 +43,7 @@ u32 Wbfs_Fat::fat_hdr_count = 0;
|
||||
u32 Wbfs_Fat::fat_sector_size = 512;
|
||||
|
||||
Wbfs_Fat::Wbfs_Fat(u32 device, u32 lba, u32 size) :
|
||||
Wbfs(device, lba, size), Mounted(false)
|
||||
Wbfs(device, lba, size)
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,27 +51,20 @@ s32 Wbfs_Fat::Open()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (device == WBFS_DEVICE_USB && lba == fat_usb_sec)
|
||||
PartitionHandle * usbHandle = DeviceHandler::Instance()->GetUSBHandle();
|
||||
|
||||
for(int i = 0; i < usbHandle->GetPartitionCount(); ++i)
|
||||
{
|
||||
strcpy(wbfs_fs_drive, "USB:");
|
||||
Mounted = true;
|
||||
}
|
||||
else
|
||||
if (device == WBFS_DEVICE_USB && lba == usbHandle->GetLBAStart(i))
|
||||
{
|
||||
//closing all open Files write back the cache and then shutdown em!
|
||||
fatUnmount("FAT32:/");
|
||||
|
||||
Mounted = fatMount("FAT32", &__io_usbstorage2, lba, CACHE_SIZE, CACHED_SECTORS);
|
||||
if (!Mounted)
|
||||
return -1;
|
||||
|
||||
fat_wbfs_sec = lba;
|
||||
|
||||
strcpy(wbfs_fs_drive, "FAT32:");
|
||||
}
|
||||
|
||||
sprintf(wbfs_fs_drive, "%s:", usbHandle->MountName(i));
|
||||
wbfs_part_fs = PART_FS_FAT;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Wbfs_Fat::Close()
|
||||
{
|
||||
@ -82,9 +74,8 @@ void Wbfs_Fat::Close()
|
||||
hdd = NULL;
|
||||
}
|
||||
|
||||
fatUnmount("FAT32:/");
|
||||
Mounted = false;
|
||||
fat_wbfs_sec = 0;
|
||||
wbfs_part_fs = -1;
|
||||
memset(wbfs_fs_drive, 0, sizeof(wbfs_fs_drive));
|
||||
}
|
||||
|
||||
wbfs_disc_t* Wbfs_Fat::OpenDisc(u8 *discid)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <ogcsys.h>
|
||||
|
||||
#include "usbloader/splits.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "wbfs_base.h"
|
||||
|
||||
class Wbfs_Fat: public Wbfs
|
||||
@ -35,7 +36,6 @@ class Wbfs_Fat: public Wbfs
|
||||
|
||||
protected:
|
||||
static char wbfs_fs_drive[16];
|
||||
bool Mounted;
|
||||
private:
|
||||
split_info_t split;
|
||||
|
||||
|
@ -3,42 +3,17 @@
|
||||
#include "wbfs_ntfs.h"
|
||||
#include "usbloader/usbstorage2.h"
|
||||
|
||||
extern int wbfs_part_fs;
|
||||
sec_t ntfs_wbfs_sec = 0;
|
||||
|
||||
s32 Wbfs_Ntfs::Open()
|
||||
{
|
||||
Close();
|
||||
|
||||
strcpy(wbfs_fs_drive, "NTFS:");
|
||||
|
||||
if (Mounted)
|
||||
return 0;
|
||||
|
||||
Mounted = ntfsMount("NTFS", &__io_usbstorage2, lba, CACHE_SIZE, CACHED_SECTORS, NTFS_SHOW_HIDDEN_FILES | NTFS_RECOVER);
|
||||
if (!Mounted)
|
||||
return -2;
|
||||
|
||||
// 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");
|
||||
|
||||
s32 ret = Wbfs_Fat::Open();
|
||||
if(ret == 0)
|
||||
{
|
||||
ntfs_wbfs_sec = lba;
|
||||
wbfs_part_fs = PART_FS_NTFS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Wbfs_Ntfs::Close()
|
||||
{
|
||||
if (hdd)
|
||||
{
|
||||
wbfs_close(hdd);
|
||||
hdd = NULL;
|
||||
}
|
||||
|
||||
ntfsUnmount("NTFS:/", true);
|
||||
|
||||
Mounted = false;
|
||||
ntfs_wbfs_sec = 0;
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ class Wbfs_Ntfs: public Wbfs_Fat
|
||||
}
|
||||
|
||||
virtual s32 Open();
|
||||
virtual void Close();
|
||||
|
||||
bool ShowFreeSpace(void) { return true; };
|
||||
};
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "wbfs_wbfs.h"
|
||||
#include "prompts/ProgressWindow.h"
|
||||
#include "settings/CSettings.h"
|
||||
#include "usbloader/wbfs.h"
|
||||
#include "wbfs_rw.h"
|
||||
|
||||
extern u32 sector_size;
|
||||
extern int wbfs_part_fs;
|
||||
|
||||
s32 Wbfs_Wbfs::Open()
|
||||
{
|
||||
@ -20,6 +22,8 @@ s32 Wbfs_Wbfs::Open()
|
||||
// Save the new sector size, so it will be used in read and write calls
|
||||
sector_size = 1 << hdd->head->hd_sec_sz_s;
|
||||
|
||||
wbfs_part_fs = PART_FS_WBFS;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -30,6 +34,8 @@ void Wbfs_Wbfs::Close()
|
||||
wbfs_close(hdd);
|
||||
hdd = NULL;
|
||||
}
|
||||
|
||||
wbfs_part_fs = -1;
|
||||
}
|
||||
|
||||
wbfs_disc_t* Wbfs_Wbfs::OpenDisc(u8 *discid)
|
||||
|
@ -28,9 +28,9 @@
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define le16(i) (((((u16) i) & 0xFF) << 8) | ((((u16) i) & 0xFF00) >> 8))
|
||||
#define le32(i) (((((u32) i) & 0xFF) << 24) | ((((u32) i) & 0xFF00) << 8) | \
|
||||
((((u32) i) & 0xFF0000) >> 8) | ((((u32) i) & 0xFF000000) >> 24))
|
||||
#define le16(i) ((((u16) ((i) & 0xFF)) << 8) | ((u16) (((i) & 0xFF00) >> 8)))
|
||||
#define le32(i) ((((u32)le16((i) & 0xFFFF)) << 16) | ((u32)le16(((i) & 0xFFFF0000) >> 16)))
|
||||
#define le64(i) ((((u64)le32((i) & 0xFFFFFFFFLL)) << 32) | ((u64)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -32,26 +32,6 @@ u32 frameCount = 0;
|
||||
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
|
||||
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
|
||||
|
||||
/****************************************************************************
|
||||
* StartGX
|
||||
*
|
||||
* Initialises GX and sets it up for use
|
||||
***************************************************************************/
|
||||
static void StartGX()
|
||||
{
|
||||
GXColor background = { 0, 0, 0, 0xff };
|
||||
|
||||
/*** Clear out FIFO area ***/
|
||||
memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE);
|
||||
|
||||
/*** Initialise GX ***/
|
||||
GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||
GX_SetCopyClear(background, 0x00ffffff);
|
||||
|
||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||
GX_SetCullMode(GX_CULL_NONE);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* ResetVideo_Menu
|
||||
*
|
||||
@ -132,6 +112,13 @@ void InitVideo()
|
||||
VIDEO_Init();
|
||||
vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
|
||||
|
||||
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9)
|
||||
{
|
||||
// widescreen fix
|
||||
vmode->viWidth = VI_MAX_WIDTH_PAL - 12;
|
||||
vmode->viXOrigin = ((VI_MAX_WIDTH_PAL - vmode->viWidth) / 2) + 2;
|
||||
}
|
||||
|
||||
VIDEO_Configure(vmode);
|
||||
|
||||
screenheight = 480;
|
||||
@ -146,17 +133,25 @@ void InitVideo()
|
||||
VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);
|
||||
VIDEO_SetNextFramebuffer(xfb[0]);
|
||||
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
|
||||
StartGX();
|
||||
// Initialize GX
|
||||
GXColor background = { 0, 0, 0, 0xff };
|
||||
memset (&gp_fifo, 0, DEFAULT_FIFO_SIZE);
|
||||
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||
GX_SetCopyClear (background, 0x00ffffff);
|
||||
GX_SetDispCopyGamma (GX_GM_1_0);
|
||||
GX_SetCullMode (GX_CULL_NONE);
|
||||
|
||||
ResetVideo_Menu();
|
||||
|
||||
VIDEO_SetBlack(FALSE);
|
||||
// Finally, the video is up and ready for use :)
|
||||
|
||||
// A console is always useful while debugging
|
||||
console_init(xfb[0], 80, 100, 500, 350, vmode->fbWidth * 2);
|
||||
//console_init(xfb[0], 80, 100, 500, 350, vmode->fbWidth * 2);
|
||||
}
|
||||
|
||||
void VIDEO_SetWidescreen(bool widescreen)
|
||||
|
@ -129,7 +129,7 @@ bool NandTitle::GetName(u64 tid, int language, wchar_t* name)
|
||||
{
|
||||
if (TITLE_UPPER( tid ) != 0x10001 && TITLE_UPPER( tid ) != 0x10002 && TITLE_UPPER( tid ) != 0x10004) return false;
|
||||
//gprintf("GetName( %016llx ): ", tid );
|
||||
char app[ISFS_MAXPATH];
|
||||
char app[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
IMET *imet = (IMET*) memalign(32, sizeof(IMET));
|
||||
|
||||
tmd* titleTmd = GetTMD(tid);
|
||||
@ -225,7 +225,7 @@ bool NandTitle::GetName(u64 tid, int language, wchar_t* name)
|
||||
|
||||
bool NandTitle::Exists(u64 tid)
|
||||
{
|
||||
char app[ISFS_MAXPATH];
|
||||
char app[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32);
|
||||
tmd* titleTmd = GetTMD(tid);
|
||||
if (!titleTmd) return false;
|
||||
|
||||
|
@ -45,6 +45,7 @@ EOF
|
||||
<coder>USB Loader GX Team</coder>
|
||||
<version>1.0 r$rev_new</version>
|
||||
<release_date>$rev_date</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.
|
||||
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.
|
||||
|
Loading…
Reference in New Issue
Block a user