mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 03:11:58 +01:00
-fixed a possible bug in partition mounting
-cleaned up the coverflow dependant partition select code
This commit is contained in:
parent
8263bd09a7
commit
8473b54bb0
@ -86,7 +86,7 @@ bool DeviceHandler::IsInserted(int dev)
|
|||||||
return SD_Inserted() && sd.IsMounted(0);
|
return SD_Inserted() && sd.IsMounted(0);
|
||||||
else if(dev >= USB1 && dev <= USB8)
|
else if(dev >= USB1 && dev <= USB8)
|
||||||
{
|
{
|
||||||
int portPart = PartitionToPortPartition(dev-USB1);
|
int portPart = dev-1;//PartitionToPortPartition(dev-USB1);
|
||||||
return usb0.IsMounted(portPart);
|
return usb0.IsMounted(portPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ bool DeviceHandler::MountUSB(int pos)
|
|||||||
if(pos >= GetUSBPartitionCount())
|
if(pos >= GetUSBPartitionCount())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int portPart = PartitionToPortPartition(pos);
|
int portPart = pos;//PartitionToPortPartition(pos);
|
||||||
|
|
||||||
if(PartitionToUSBPort(pos) == 0)
|
if(PartitionToUSBPort(pos) == 0)
|
||||||
return usb0.Mount(portPart, DeviceName[USB1+pos]);
|
return usb0.Mount(portPart, DeviceName[USB1+pos]);
|
||||||
@ -175,7 +175,7 @@ void DeviceHandler::UnMountUSB(int pos)
|
|||||||
if(pos >= GetUSBPartitionCount())
|
if(pos >= GetUSBPartitionCount())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int portPart = PartitionToPortPartition(pos);
|
int portPart = pos;//PartitionToPortPartition(pos);
|
||||||
|
|
||||||
if(PartitionToUSBPort(pos) == 0)
|
if(PartitionToUSBPort(pos) == 0)
|
||||||
return usb0.UnMount(portPart);
|
return usb0.UnMount(portPart);
|
||||||
|
@ -39,6 +39,12 @@
|
|||||||
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ extended partition */
|
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ extended partition */
|
||||||
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
#define PARTITION_TYPE_WIN95_EXTENDED 0x0F /* Windows 95 extended partition */
|
||||||
|
|
||||||
|
/* Predefined Buffers */
|
||||||
|
GUID_PART_ENTRY gpt_entry[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
||||||
|
MASTER_BOOT_RECORD mbr[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
||||||
|
u8 HeaderBuffer[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
||||||
|
u8 AddingBuffer[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
||||||
|
|
||||||
//! libfat stuff
|
//! libfat stuff
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -234,8 +240,6 @@ bool PartitionHandle::IsExisting(u64 lba)
|
|||||||
|
|
||||||
s8 PartitionHandle::FindPartitions()
|
s8 PartitionHandle::FindPartitions()
|
||||||
{
|
{
|
||||||
MASTER_BOOT_RECORD mbr[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
|
||||||
|
|
||||||
// Read the first sector on the device
|
// Read the first sector on the device
|
||||||
if(!interface->readSectors(0, 1, mbr))
|
if(!interface->readSectors(0, 1, mbr))
|
||||||
return -1;
|
return -1;
|
||||||
@ -269,9 +273,6 @@ s8 PartitionHandle::FindPartitions()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 HeaderBuffer[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
|
||||||
static u8 AddingBuffer[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
|
||||||
|
|
||||||
void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
||||||
{
|
{
|
||||||
EXTENDED_BOOT_RECORD *ebr = (EXTENDED_BOOT_RECORD *)HeaderBuffer;
|
EXTENDED_BOOT_RECORD *ebr = (EXTENDED_BOOT_RECORD *)HeaderBuffer;
|
||||||
@ -319,12 +320,12 @@ s8 PartitionHandle::CheckGPT(u8 PartNum)
|
|||||||
u64 next_lba = gpt_header->part_table_lba;
|
u64 next_lba = gpt_header->part_table_lba;
|
||||||
for(u32 i = 0; i < gpt_header->part_entries; ++i)
|
for(u32 i = 0; i < gpt_header->part_entries; ++i)
|
||||||
{
|
{
|
||||||
if(!interface->readSectors(next_lba, 1, AddingBuffer))
|
if(!interface->readSectors(next_lba, 1, gpt_entry))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for(u32 n = 0; n < BYTES_PER_SECTOR/gpt_header->part_entry_size; ++n, ++i)
|
for(u32 n = 0; n < BYTES_PER_SECTOR/gpt_header->part_entry_size; ++n, ++i)
|
||||||
{
|
{
|
||||||
GUID_PART_ENTRY * part_entry = (GUID_PART_ENTRY *) (AddingBuffer + gpt_header->part_entry_size*n);
|
GUID_PART_ENTRY *part_entry = (gpt_entry + gpt_header->part_entry_size * n);
|
||||||
|
|
||||||
if(memcmp(part_entry->part_type_guid, TYPE_UNUSED, 16) == 0)
|
if(memcmp(part_entry->part_type_guid, TYPE_UNUSED, 16) == 0)
|
||||||
continue;
|
continue;
|
||||||
@ -378,6 +379,7 @@ void PartitionHandle::AddPartition(const char *name, u64 lba_start, u64 sec_coun
|
|||||||
PartitionEntry.Bootable = bootable;
|
PartitionEntry.Bootable = bootable;
|
||||||
PartitionEntry.PartitionType = part_type;
|
PartitionEntry.PartitionType = part_type;
|
||||||
PartitionEntry.PartitionNum = part_num;
|
PartitionEntry.PartitionNum = part_num;
|
||||||
|
gprintf("Found a %s Partition with the number %i\n", name, part_num);
|
||||||
PartitionList.push_back(PartitionEntry);
|
PartitionList.push_back(PartitionEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,7 +898,7 @@ private:
|
|||||||
void _showConfig4(void);
|
void _showConfig4(void);
|
||||||
void _showConfigAdv(void);
|
void _showConfigAdv(void);
|
||||||
void _showConfigSnd(void);
|
void _showConfigSnd(void);
|
||||||
void _enableNandEmu(bool fromconfig);
|
void _setPartition(s8 direction = 0);
|
||||||
void _showGame(void);
|
void _showGame(void);
|
||||||
void _showDownload(void);
|
void _showDownload(void);
|
||||||
void _showSettings();
|
void _showSettings();
|
||||||
|
@ -171,7 +171,7 @@ int CMenu::_config1(void)
|
|||||||
|
|
||||||
if (BTN_HOME_PRESSED || BTN_B_PRESSED)
|
if (BTN_HOME_PRESSED || BTN_B_PRESSED)
|
||||||
{
|
{
|
||||||
_enableNandEmu(false);
|
_setPartition();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (BTN_A_PRESSED)
|
if (BTN_A_PRESSED)
|
||||||
@ -189,7 +189,8 @@ int CMenu::_config1(void)
|
|||||||
_code();
|
_code();
|
||||||
else if ((m_btnMgr.selected(m_configBtnPartitionP) || m_btnMgr.selected(m_configBtnPartitionM)))
|
else if ((m_btnMgr.selected(m_configBtnPartitionP) || m_btnMgr.selected(m_configBtnPartitionM)))
|
||||||
{
|
{
|
||||||
_enableNandEmu(true);
|
s8 direction = m_btnMgr.selected(m_configBtnPartitionP) ? 1 : -1;
|
||||||
|
_setPartition(direction);
|
||||||
_showConfig();
|
_showConfig();
|
||||||
}
|
}
|
||||||
else if (m_btnMgr.selected(m_configBtnCfg4))
|
else if (m_btnMgr.selected(m_configBtnCfg4))
|
||||||
|
@ -633,26 +633,8 @@ int CMenu::main(void)
|
|||||||
{
|
{
|
||||||
_showWaitMessage();
|
_showWaitMessage();
|
||||||
_hideMain();
|
_hideMain();
|
||||||
bool isD2XnewerThanV6 = (CurrentIOS.Type == IOS_TYPE_NEEK2O);
|
_setPartition(1);
|
||||||
if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
|
|
||||||
isD2XnewerThanV6 = true;
|
|
||||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt(CHANNEL_DOMAIN, "emulation", 0))
|
|
||||||
NandHandle.Enable_Emu();
|
|
||||||
u8 limiter = 0;
|
|
||||||
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
|
||||||
while(!DeviceHandle.IsInserted(currentPartition) ||
|
|
||||||
((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_PLUGIN) && (DeviceHandle.GetFSType(currentPartition) != PART_FS_FAT ||
|
|
||||||
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
|
||||||
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
|
||||||
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandle.GetFSType(currentPartition) == PART_FS_WBFS))
|
|
||||||
{
|
|
||||||
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
|
||||||
if(limiter > 10) break;
|
|
||||||
limiter++;
|
|
||||||
}
|
|
||||||
partition = DeviceName[currentPartition];
|
partition = DeviceName[currentPartition];
|
||||||
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition);
|
|
||||||
m_cfg.setInt(_domainFromView(), "partition", currentPartition);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
partition = "NAND";
|
partition = "NAND";
|
||||||
@ -1060,3 +1042,37 @@ wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx curLetter)
|
|||||||
|
|
||||||
return curLetter;
|
return curLetter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMenu::_setPartition(s8 direction)
|
||||||
|
{
|
||||||
|
_cfNeedsUpdate();
|
||||||
|
bool disable = m_current_view == COVERFLOW_CHANNEL && !m_tempView &&
|
||||||
|
(m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) || neek2o());
|
||||||
|
if(disable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(m_current_view == COVERFLOW_CHANNEL)
|
||||||
|
NandHandle.Enable_Emu();
|
||||||
|
|
||||||
|
if(direction != 0)
|
||||||
|
{
|
||||||
|
u8 limiter = 0;
|
||||||
|
bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_DML;
|
||||||
|
currentPartition = loopNum(currentPartition + direction, 8);
|
||||||
|
int FS_Type = DeviceHandle.GetFSType(currentPartition);
|
||||||
|
while(!DeviceHandle.IsInserted(currentPartition) ||
|
||||||
|
(m_current_view != COVERFLOW_USB && FS_Type == PART_FS_WBFS) ||
|
||||||
|
(NeedFAT && FS_Type != PART_FS_FAT))
|
||||||
|
{
|
||||||
|
currentPartition = loopNum(currentPartition + direction, 8);
|
||||||
|
FS_Type = DeviceHandle.GetFSType(currentPartition);
|
||||||
|
if(limiter > 10)
|
||||||
|
break;
|
||||||
|
limiter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(m_tempView)
|
||||||
|
m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition);
|
||||||
|
else
|
||||||
|
m_cfg.setInt(_domainFromView(), "partition", currentPartition);
|
||||||
|
}
|
||||||
|
@ -187,41 +187,6 @@ bool CMenu::_checkSave(string id, bool nand)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenu::_enableNandEmu(bool fromconfig)
|
|
||||||
{
|
|
||||||
_cfNeedsUpdate();
|
|
||||||
bool disable = (m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) || neek2o()) && m_current_view == COVERFLOW_CHANNEL && !m_tempView;
|
|
||||||
|
|
||||||
if(!disable)
|
|
||||||
{
|
|
||||||
bool isD2XnewerThanV6 = (CurrentIOS.Type == IOS_TYPE_NEEK2O);
|
|
||||||
if(CurrentIOS.Revision > 6 && CurrentIOS.Type == IOS_TYPE_D2X)
|
|
||||||
isD2XnewerThanV6 = true;
|
|
||||||
if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool(CHANNEL_DOMAIN, "disable", true) && !neek2o() && !m_tempView)
|
|
||||||
NandHandle.Enable_Emu();
|
|
||||||
u8 limiter = 0;
|
|
||||||
s8 direction = m_btnMgr.selected(m_configBtnPartitionP) ? 1 : -1;
|
|
||||||
if (!fromconfig)
|
|
||||||
direction = 0;
|
|
||||||
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
|
||||||
while(!DeviceHandle.IsInserted(currentPartition) ||
|
|
||||||
(m_current_view == COVERFLOW_CHANNEL && (DeviceHandle.GetFSType(currentPartition) != PART_FS_FAT ||
|
|
||||||
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
|
||||||
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
|
||||||
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandle.GetFSType(currentPartition) == PART_FS_WBFS))
|
|
||||||
{
|
|
||||||
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
|
||||||
if (limiter > 10) break;
|
|
||||||
limiter++;
|
|
||||||
}
|
|
||||||
gprintf("Next item: %s\n", DeviceName[currentPartition]);
|
|
||||||
if(m_tempView)
|
|
||||||
m_cfg.setInt(WII_DOMAIN, "savepartition", currentPartition);
|
|
||||||
else
|
|
||||||
m_cfg.setInt(_domainFromView(), "partition", currentPartition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMenu::_setDumpMsg(const wstringEx &msg, float totprog, float fileprog)
|
void CMenu::_setDumpMsg(const wstringEx &msg, float totprog, float fileprog)
|
||||||
{
|
{
|
||||||
if(m_thrdStop) return;
|
if(m_thrdStop) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user