mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-01 00:55:06 +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);
|
||||
else if(dev >= USB1 && dev <= USB8)
|
||||
{
|
||||
int portPart = PartitionToPortPartition(dev-USB1);
|
||||
int portPart = dev-1;//PartitionToPortPartition(dev-USB1);
|
||||
return usb0.IsMounted(portPart);
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ bool DeviceHandler::MountUSB(int pos)
|
||||
if(pos >= GetUSBPartitionCount())
|
||||
return false;
|
||||
|
||||
int portPart = PartitionToPortPartition(pos);
|
||||
int portPart = pos;//PartitionToPortPartition(pos);
|
||||
|
||||
if(PartitionToUSBPort(pos) == 0)
|
||||
return usb0.Mount(portPart, DeviceName[USB1+pos]);
|
||||
@ -175,7 +175,7 @@ void DeviceHandler::UnMountUSB(int pos)
|
||||
if(pos >= GetUSBPartitionCount())
|
||||
return;
|
||||
|
||||
int portPart = PartitionToPortPartition(pos);
|
||||
int portPart = pos;//PartitionToPortPartition(pos);
|
||||
|
||||
if(PartitionToUSBPort(pos) == 0)
|
||||
return usb0.UnMount(portPart);
|
||||
|
@ -39,6 +39,12 @@
|
||||
#define PARTITION_TYPE_DOS33_EXTENDED 0x05 /* DOS 3.3+ 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
|
||||
extern "C"
|
||||
{
|
||||
@ -234,8 +240,6 @@ bool PartitionHandle::IsExisting(u64 lba)
|
||||
|
||||
s8 PartitionHandle::FindPartitions()
|
||||
{
|
||||
MASTER_BOOT_RECORD mbr[MAX_BYTES_PER_SECTOR] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
// Read the first sector on the device
|
||||
if(!interface->readSectors(0, 1, mbr))
|
||||
return -1;
|
||||
@ -269,9 +273,6 @@ s8 PartitionHandle::FindPartitions()
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
|
||||
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)
|
||||
continue;
|
||||
@ -378,6 +379,7 @@ void PartitionHandle::AddPartition(const char *name, u64 lba_start, u64 sec_coun
|
||||
PartitionEntry.Bootable = bootable;
|
||||
PartitionEntry.PartitionType = part_type;
|
||||
PartitionEntry.PartitionNum = part_num;
|
||||
gprintf("Found a %s Partition with the number %i\n", name, part_num);
|
||||
PartitionList.push_back(PartitionEntry);
|
||||
}
|
||||
|
||||
|
@ -898,7 +898,7 @@ private:
|
||||
void _showConfig4(void);
|
||||
void _showConfigAdv(void);
|
||||
void _showConfigSnd(void);
|
||||
void _enableNandEmu(bool fromconfig);
|
||||
void _setPartition(s8 direction = 0);
|
||||
void _showGame(void);
|
||||
void _showDownload(void);
|
||||
void _showSettings();
|
||||
|
@ -171,7 +171,7 @@ int CMenu::_config1(void)
|
||||
|
||||
if (BTN_HOME_PRESSED || BTN_B_PRESSED)
|
||||
{
|
||||
_enableNandEmu(false);
|
||||
_setPartition();
|
||||
break;
|
||||
}
|
||||
if (BTN_A_PRESSED)
|
||||
@ -189,7 +189,8 @@ int CMenu::_config1(void)
|
||||
_code();
|
||||
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();
|
||||
}
|
||||
else if (m_btnMgr.selected(m_configBtnCfg4))
|
||||
|
@ -633,26 +633,8 @@ int CMenu::main(void)
|
||||
{
|
||||
_showWaitMessage();
|
||||
_hideMain();
|
||||
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.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++;
|
||||
}
|
||||
_setPartition(1);
|
||||
partition = DeviceName[currentPartition];
|
||||
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition);
|
||||
m_cfg.setInt(_domainFromView(), "partition", currentPartition);
|
||||
}
|
||||
else
|
||||
partition = "NAND";
|
||||
@ -1060,3 +1042,37 @@ wstringEx CMenu::_getNoticeTranslation(int sorting, wstringEx 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if(m_thrdStop) return;
|
||||
|
Loading…
Reference in New Issue
Block a user