mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 11:21:55 +01:00
-general code cleanup
This commit is contained in:
parent
6cee8ba139
commit
3420882624
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Copyright (C) 2010
|
* Copyright (C) 2010 by Dimok
|
||||||
* by Dimok
|
* (C) 2012 by FIX94
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any
|
* warranty. In no event will the authors be held liable for any
|
||||||
@ -20,8 +20,6 @@
|
|||||||
*
|
*
|
||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
|
||||||
* for WiiXplorer 2010
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -40,25 +38,17 @@
|
|||||||
#include "loader/sys.h"
|
#include "loader/sys.h"
|
||||||
#include "loader/wbfs.h"
|
#include "loader/wbfs.h"
|
||||||
|
|
||||||
DeviceHandler * DeviceHandler::instance = NULL;
|
DeviceHandler DeviceHandle;
|
||||||
|
|
||||||
DeviceHandler::~DeviceHandler()
|
void DeviceHandler::Init()
|
||||||
{
|
{
|
||||||
UnMountAll();
|
sd = NULL;
|
||||||
}
|
gca = NULL;
|
||||||
|
gcb = NULL;
|
||||||
DeviceHandler * DeviceHandler::Instance()
|
usb0 = NULL;
|
||||||
{
|
usb1 = NULL;
|
||||||
if(instance == NULL)
|
OGC_Device = NULL;
|
||||||
instance = new DeviceHandler();
|
DolphinSD = false;
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceHandler::DestroyInstance()
|
|
||||||
{
|
|
||||||
if(instance)
|
|
||||||
delete instance;
|
|
||||||
instance = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandler::MountAll()
|
void DeviceHandler::MountAll()
|
||||||
@ -121,7 +111,7 @@ bool DeviceHandler::IsInserted(int dev)
|
|||||||
else if(dev >= USB1 && dev <= USB8)
|
else if(dev >= USB1 && dev <= USB8)
|
||||||
{
|
{
|
||||||
int portPart = PartitionToPortPartition(dev-USB1);
|
int portPart = PartitionToPortPartition(dev-USB1);
|
||||||
PartitionHandle *usb = instance->GetUSBHandleFromPartition(dev-USB1);
|
PartitionHandle *usb = GetUSBHandleFromPartition(dev-USB1);
|
||||||
if(usb)
|
if(usb)
|
||||||
return usb->IsMounted(portPart);
|
return usb->IsMounted(portPart);
|
||||||
}
|
}
|
||||||
@ -211,35 +201,6 @@ bool DeviceHandler::MountAllUSB()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
bool DeviceHandler::MountUSBPort1()
|
|
||||||
{
|
|
||||||
if(!usb1)// && (Settings.USBPort == 1 || Settings.USBPort == 2))
|
|
||||||
usb1 = new PartitionHandle(GetUSB1Interface());
|
|
||||||
|
|
||||||
if(usb1 && usb1->GetPartitionCount() < 1)
|
|
||||||
{
|
|
||||||
delete usb1;
|
|
||||||
usb1 = NULL;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result = false;
|
|
||||||
int partCount = GetUSBPartitionCount();
|
|
||||||
int partCount0 = 0;
|
|
||||||
if(usb0)
|
|
||||||
partCount0 = usb0->GetPartitionCount();
|
|
||||||
|
|
||||||
for(int i = partCount0; i < partCount; i++)
|
|
||||||
{
|
|
||||||
if(MountUSB(i))
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void DeviceHandler::UnMountUSB(int pos)
|
void DeviceHandler::UnMountUSB(int pos)
|
||||||
{
|
{
|
||||||
if(pos >= GetUSBPartitionCount())
|
if(pos >= GetUSBPartitionCount())
|
||||||
@ -266,7 +227,7 @@ void DeviceHandler::UnMountAllUSB()
|
|||||||
usb1 = NULL;
|
usb1 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeviceHandler::PathToDriveType(const char * path)
|
int DeviceHandler::PathToDriveType(const char *path)
|
||||||
{
|
{
|
||||||
if(!path)
|
if(!path)
|
||||||
return -1;
|
return -1;
|
||||||
@ -280,25 +241,23 @@ int DeviceHandler::PathToDriveType(const char * path)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * DeviceHandler::GetFSName(int dev)
|
const char *DeviceHandler::GetFSName(int dev)
|
||||||
{
|
{
|
||||||
if(dev == SD && DeviceHandler::instance->sd)
|
if(dev == SD && sd)
|
||||||
{
|
return sd->GetFSName(0);
|
||||||
return DeviceHandler::instance->sd->GetFSName(0);
|
|
||||||
}
|
|
||||||
else if(dev >= USB1 && dev <= USB8)
|
else if(dev >= USB1 && dev <= USB8)
|
||||||
{
|
{
|
||||||
int partCount0 = 0;
|
int partCount0 = 0;
|
||||||
int partCount1 = 0;
|
int partCount1 = 0;
|
||||||
if(DeviceHandler::instance->usb0)
|
if(usb0)
|
||||||
partCount0 += DeviceHandler::instance->usb0->GetPartitionCount();
|
partCount0 += usb0->GetPartitionCount();
|
||||||
if(DeviceHandler::instance->usb1)
|
if(usb1)
|
||||||
partCount1 += DeviceHandler::instance->usb1->GetPartitionCount();
|
partCount1 += usb1->GetPartitionCount();
|
||||||
|
|
||||||
if(dev-USB1 < partCount0 && DeviceHandler::instance->usb0)
|
if(dev-USB1 < partCount0 && usb0)
|
||||||
return DeviceHandler::instance->usb0->GetFSName(dev-USB1);
|
return usb0->GetFSName(dev-USB1);
|
||||||
else if(DeviceHandler::instance->usb1)
|
else if(usb1)
|
||||||
return DeviceHandler::instance->usb1->GetFSName(dev-USB1-partCount0);
|
return usb1->GetFSName(dev-USB1-partCount0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@ -306,9 +265,6 @@ const char * DeviceHandler::GetFSName(int dev)
|
|||||||
|
|
||||||
int DeviceHandler::GetFSType(int dev)
|
int DeviceHandler::GetFSType(int dev)
|
||||||
{
|
{
|
||||||
if(!instance)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
const char *FSName = GetFSName(dev);
|
const char *FSName = GetFSName(dev);
|
||||||
if(!FSName) return -1;
|
if(!FSName) return -1;
|
||||||
|
|
||||||
@ -326,43 +282,39 @@ int DeviceHandler::GetFSType(int dev)
|
|||||||
|
|
||||||
u16 DeviceHandler::GetUSBPartitionCount()
|
u16 DeviceHandler::GetUSBPartitionCount()
|
||||||
{
|
{
|
||||||
if(!instance)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
u16 partCount0 = 0;
|
u16 partCount0 = 0;
|
||||||
u16 partCount1 = 0;
|
u16 partCount1 = 0;
|
||||||
if(instance->usb0)
|
if(usb0)
|
||||||
partCount0 = instance->usb0->GetPartitionCount();
|
partCount0 = usb0->GetPartitionCount();
|
||||||
if(instance->usb1)
|
if(usb1)
|
||||||
partCount1 = instance->usb1->GetPartitionCount();
|
partCount1 = usb1->GetPartitionCount();
|
||||||
|
|
||||||
return partCount0+partCount1;
|
return partCount0+partCount1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wbfs_t * DeviceHandler::GetWbfsHandle(int dev)
|
wbfs_t * DeviceHandler::GetWbfsHandle(int dev)
|
||||||
{
|
{
|
||||||
if(dev == SD && DeviceHandler::instance->sd)
|
if(dev == SD && sd)
|
||||||
return DeviceHandler::instance->sd->GetWbfsHandle(0);
|
return sd->GetWbfsHandle(0);
|
||||||
else if(dev >= USB1 && dev <= USB8 && DeviceHandler::instance->usb0)
|
else if(dev >= USB1 && dev <= USB8 && usb0)
|
||||||
return DeviceHandler::instance->usb0->GetWbfsHandle(dev-USB1);
|
return usb0->GetWbfsHandle(dev-USB1);
|
||||||
else if(dev >= USB1 && dev <= USB8 && DeviceHandler::instance->usb1)
|
else if(dev >= USB1 && dev <= USB8 && usb1)
|
||||||
return DeviceHandler::instance->usb1->GetWbfsHandle(dev-USB1);
|
return usb1->GetWbfsHandle(dev-USB1);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 DeviceHandler::Open_WBFS(int dev)
|
s32 DeviceHandler::OpenWBFS(int dev)
|
||||||
{
|
{
|
||||||
u32 part_lba, part_idx = 1;
|
u32 part_lba, part_idx = 1;
|
||||||
u32 part_fs = GetFSType(dev);
|
u32 part_fs = GetFSType(dev);
|
||||||
char *partition = (char *)DeviceName[dev];
|
char *partition = (char *)DeviceName[dev];
|
||||||
|
|
||||||
if(dev == SD && IsInserted(dev))
|
if(dev == SD && IsInserted(dev))
|
||||||
part_lba = Instance()->sd->GetLBAStart(dev);
|
part_lba = sd->GetLBAStart(dev);
|
||||||
else if(dev >= USB1 && dev <= USB8 && IsInserted(dev))
|
else if(dev >= USB1 && dev <= USB8 && IsInserted(dev))
|
||||||
{
|
{
|
||||||
part_idx = dev;
|
part_idx = dev;
|
||||||
part_lba = Instance()->usb0->GetLBAStart(dev - USB1);
|
part_lba = usb0->GetLBAStart(dev - USB1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
@ -372,14 +324,11 @@ s32 DeviceHandler::Open_WBFS(int dev)
|
|||||||
|
|
||||||
int DeviceHandler::PartitionToUSBPort(int part)
|
int DeviceHandler::PartitionToUSBPort(int part)
|
||||||
{
|
{
|
||||||
if(!DeviceHandler::instance)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
u16 partCount0 = 0;
|
u16 partCount0 = 0;
|
||||||
if(DeviceHandler::instance->usb0)
|
if(usb0)
|
||||||
partCount0 = instance->usb0->GetPartitionCount();
|
partCount0 = usb0->GetPartitionCount();
|
||||||
|
|
||||||
if(!instance->usb0 || part >= partCount0)
|
if(!usb0 || part >= partCount0)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@ -387,20 +336,17 @@ int DeviceHandler::PartitionToUSBPort(int part)
|
|||||||
|
|
||||||
int DeviceHandler::PartitionToPortPartition(int part)
|
int DeviceHandler::PartitionToPortPartition(int part)
|
||||||
{
|
{
|
||||||
if(!DeviceHandler::instance)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
u16 partCount0 = 0;
|
u16 partCount0 = 0;
|
||||||
if(instance->usb0)
|
if(usb0)
|
||||||
partCount0 = instance->usb0->GetPartitionCount();
|
partCount0 = usb0->GetPartitionCount();
|
||||||
|
|
||||||
if(!instance->usb0 || part >= partCount0)
|
if(!usb0 || part >= partCount0)
|
||||||
return part-partCount0;
|
return part-partCount0;
|
||||||
else
|
else
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionHandle *DeviceHandler::GetUSBHandleFromPartition(int part) const
|
PartitionHandle *DeviceHandler::GetUSBHandleFromPartition(int part)
|
||||||
{
|
{
|
||||||
if(PartitionToUSBPort(part) == 0)
|
if(PartitionToUSBPort(part) == 0)
|
||||||
return usb0;
|
return usb0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Copyright (C) 2010
|
* Copyright (C) 2010 by Dimok
|
||||||
* by Dimok
|
* (C) 2012 by FIX94
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any
|
* warranty. In no event will the authors be held liable for any
|
||||||
@ -20,8 +20,6 @@
|
|||||||
*
|
*
|
||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
|
||||||
* for WiiXplorer 2010
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef DEVICE_HANDLER_HPP_
|
#ifndef DEVICE_HANDLER_HPP_
|
||||||
#define DEVICE_HANDLER_HPP_
|
#define DEVICE_HANDLER_HPP_
|
||||||
@ -66,11 +64,8 @@ const char DeviceName[MAXDEVICES][8] =
|
|||||||
class DeviceHandler
|
class DeviceHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DeviceHandler * Instance();
|
void Init();
|
||||||
static void DestroyInstance();
|
|
||||||
|
|
||||||
void SetModes();
|
void SetModes();
|
||||||
|
|
||||||
void MountAll();
|
void MountAll();
|
||||||
void UnMountAll();
|
void UnMountAll();
|
||||||
bool Mount(int dev);
|
bool Mount(int dev);
|
||||||
@ -97,40 +92,37 @@ public:
|
|||||||
PartitionHandle * GetUSB0Handle() const { return usb0; }
|
PartitionHandle * GetUSB0Handle() const { return usb0; }
|
||||||
PartitionHandle * GetUSB1Handle() const { return usb1; }
|
PartitionHandle * GetUSB1Handle() const { return usb1; }
|
||||||
|
|
||||||
PartitionHandle * GetUSBHandleFromPartition(int part) const;
|
PartitionHandle * GetUSBHandleFromPartition(int part);
|
||||||
static const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; }
|
const DISC_INTERFACE *GetUSB0Interface() { return &__io_usbstorage2_port0; }
|
||||||
static const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; }
|
const DISC_INTERFACE *GetUSB1Interface() { return &__io_usbstorage2_port1; }
|
||||||
|
|
||||||
static int PathToDriveType(const char * path);
|
int PathToDriveType(const char *path);
|
||||||
static const char * GetFSName(int dev);
|
const char * GetFSName(int dev);
|
||||||
static int GetFSType(int dev);
|
int GetFSType(int dev);
|
||||||
static u16 GetUSBPartitionCount();
|
u16 GetUSBPartitionCount();
|
||||||
static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); }
|
const char *PathToFSName(const char *path) { return GetFSName(PathToDriveType(path)); }
|
||||||
static wbfs_t *GetWbfsHandle(int dev);
|
wbfs_t *GetWbfsHandle(int dev);
|
||||||
s32 Open_WBFS(int dev);
|
s32 OpenWBFS(int dev);
|
||||||
static int PartitionToUSBPort(int part);
|
int PartitionToUSBPort(int part);
|
||||||
static int PartitionToPortPartition(int part);
|
int PartitionToPortPartition(int part);
|
||||||
|
|
||||||
/* Special Devolution Stuff */
|
/* Special Devolution Stuff */
|
||||||
bool MountDevolution(int CurrentPartition);
|
bool MountDevolution(int CurrentPartition);
|
||||||
void UnMountDevolution(int CurrentPartition);
|
void UnMountDevolution(int CurrentPartition);
|
||||||
private:
|
private:
|
||||||
DeviceHandler() : sd(0), gca(0), gcb(0), usb0(0), usb1(0), OGC_Device(0), DolphinSD(false) { }
|
|
||||||
~DeviceHandler();
|
|
||||||
bool MountUSB(int part);
|
bool MountUSB(int part);
|
||||||
|
|
||||||
static DeviceHandler *instance;
|
PartitionHandle *sd;
|
||||||
|
PartitionHandle *gca;
|
||||||
PartitionHandle * sd;
|
PartitionHandle *gcb;
|
||||||
PartitionHandle * gca;
|
PartitionHandle *usb0;
|
||||||
PartitionHandle * gcb;
|
PartitionHandle *usb1;
|
||||||
PartitionHandle * usb0;
|
|
||||||
PartitionHandle * usb1;
|
|
||||||
|
|
||||||
/* Special Devolution Stuff */
|
/* Special Devolution Stuff */
|
||||||
PartitionHandle *OGC_Device;
|
PartitionHandle *OGC_Device;
|
||||||
/* Dolphin Stuff */
|
/* Dolphin Stuff */
|
||||||
bool DolphinSD;
|
bool DolphinSD;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern DeviceHandler DeviceHandle;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Copyright (C) 2010
|
* Copyright (C) 2010 by Dimok
|
||||||
* by Dimok
|
* (C) 2012 by FIX94
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any
|
* warranty. In no event will the authors be held liable for any
|
||||||
@ -20,8 +20,6 @@
|
|||||||
*
|
*
|
||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
|
||||||
* for WiiXplorer 2010
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -265,8 +263,7 @@ int PartitionHandle::FindPartitions()
|
|||||||
if(le32(partition->block_count) > 0 && !IsExisting(le32(partition->lba_start)))
|
if(le32(partition->block_count) > 0 && !IsExisting(le32(partition->lba_start)))
|
||||||
{
|
{
|
||||||
AddPartition(PartFromType(partition->type), le32(partition->lba_start),
|
AddPartition(PartFromType(partition->type), le32(partition->lba_start),
|
||||||
le32(partition->block_count), (partition->status == PARTITION_BOOTABLE),
|
le32(partition->block_count), (partition->status == PARTITION_BOOTABLE), partition->type, i);
|
||||||
partition->type, i);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +296,7 @@ void PartitionHandle::CheckEBR(u8 PartNum, sec_t ebr_lba)
|
|||||||
if(le32(ebr->partition.block_count) > 0 && !IsExisting(ebr_lba + next_erb_lba + le32(ebr->partition.lba_start)))
|
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),
|
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),
|
le32(ebr->partition.block_count), (ebr->partition.status == PARTITION_BOOTABLE), ebr->partition.type, PartNum);
|
||||||
ebr->partition.type, PartNum);
|
|
||||||
}
|
}
|
||||||
// Get the start sector of the current partition
|
// Get the start sector of the current partition
|
||||||
// and the next extended boot record in the chain
|
// and the next extended boot record in the chain
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Copyright (C) 2010
|
* Copyright (C) 2010 by Dimok
|
||||||
* by Dimok
|
* (C) 2012 by FIX94
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any
|
* warranty. In no event will the authors be held liable for any
|
||||||
@ -20,8 +20,6 @@
|
|||||||
*
|
*
|
||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*
|
|
||||||
* for WiiXplorer 2010
|
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#ifndef PARTITION_HANDLE_H
|
#ifndef PARTITION_HANDLE_H
|
||||||
#define PARTITION_HANDLE_H
|
#define PARTITION_HANDLE_H
|
||||||
@ -106,7 +104,7 @@ typedef struct _GPT_HEADER
|
|||||||
} __attribute__((__packed__)) GPT_HEADER;
|
} __attribute__((__packed__)) GPT_HEADER;
|
||||||
|
|
||||||
typedef struct _PartitionFS {
|
typedef struct _PartitionFS {
|
||||||
const char * FSName;
|
const char *FSName;
|
||||||
u64 LBA_Start;
|
u64 LBA_Start;
|
||||||
u64 SecCount;
|
u64 SecCount;
|
||||||
bool Bootable;
|
bool Bootable;
|
||||||
|
@ -211,7 +211,7 @@ void DEVO_GetLoader(const char *loader)
|
|||||||
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID, bool memcard_emu)
|
void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *gameID, bool memcard_emu)
|
||||||
{
|
{
|
||||||
// re-mount device we need
|
// re-mount device we need
|
||||||
DeviceHandler::Instance()->MountDevolution(CurrentPartition);
|
DeviceHandle.MountDevolution(CurrentPartition);
|
||||||
|
|
||||||
//start writing cfg to mem
|
//start writing cfg to mem
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -298,7 +298,7 @@ void DEVO_SetOptions(const char *isopath, int CurrentPartition, const char *game
|
|||||||
// flush disc ID and Devolution config out to memory
|
// flush disc ID and Devolution config out to memory
|
||||||
DCFlushRange((void*)0x80000000, 64);
|
DCFlushRange((void*)0x80000000, 64);
|
||||||
|
|
||||||
DeviceHandler::Instance()->UnMountDevolution(CurrentPartition);
|
DeviceHandle.UnMountDevolution(CurrentPartition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEVO_Boot()
|
void DEVO_Boot()
|
||||||
|
@ -7,7 +7,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, Con
|
|||||||
m_loaded = false;
|
m_loaded = false;
|
||||||
m_database = sfmt("%s/%s.db", m_cacheDir.c_str(), (make_db_name(path)).c_str());
|
m_database = sfmt("%s/%s.db", m_cacheDir.c_str(), (make_db_name(path)).c_str());
|
||||||
|
|
||||||
m_wbfsFS = strncasecmp(DeviceHandler::Instance()->PathToFSName(path.c_str()), "WBFS", 4) == 0;
|
m_wbfsFS = strncasecmp(DeviceHandle.PathToFSName(path.c_str()), "WBFS", 4) == 0;
|
||||||
|
|
||||||
bool update_games = false;
|
bool update_games = false;
|
||||||
bool update_homebrew = false;
|
bool update_homebrew = false;
|
||||||
@ -23,7 +23,7 @@ void CachedList::Load(string path, string containing, string m_lastLanguage, Con
|
|||||||
update_homebrew = strcasestr(path.c_str(), "apps") != NULL && force_update[COVERFLOW_HOMEBREW];
|
update_homebrew = strcasestr(path.c_str(), "apps") != NULL && force_update[COVERFLOW_HOMEBREW];
|
||||||
update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU];
|
update_emu = strcasestr(path.c_str(), m_plugin.getString("PLUGIN","romDir","").c_str()) != NULL && force_update[COVERFLOW_EMU];
|
||||||
|
|
||||||
const char* partition = DeviceName[DeviceHandler::Instance()->PathToDriveType(path.c_str())];
|
const char* partition = DeviceName[DeviceHandle.PathToDriveType(path.c_str())];
|
||||||
update_dml = strcasestr(path.c_str(), fmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition)) != NULL && force_update[COVERFLOW_DML];
|
update_dml = strcasestr(path.c_str(), fmt(strncmp(partition, "sd", 2) != 0 ? m_DMLgameDir.c_str() : "%s:/games", partition)) != NULL && force_update[COVERFLOW_DML];
|
||||||
|
|
||||||
gprintf("update_games=%d update_homebrew=%d update_dml=%d, update_emu=%d\n", update_games, update_homebrew, update_dml, update_emu);
|
gprintf("update_games=%d update_homebrew=%d update_dml=%d, update_emu=%d\n", update_games, update_homebrew, update_dml, update_emu);
|
||||||
|
@ -87,8 +87,8 @@ void CList<T>::GetPaths(vector<string> &pathlist, string containing, string dire
|
|||||||
if(strcasestr(containing.c_str(), ".dol") != 0)
|
if(strcasestr(containing.c_str(), ".dol") != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int partition = DeviceHandler::Instance()->PathToDriveType(directory.c_str());
|
int partition = DeviceHandle.PathToDriveType(directory.c_str());
|
||||||
wbfs_t* handle = DeviceHandler::Instance()->GetWbfsHandle(partition);
|
wbfs_t* handle = DeviceHandle.GetWbfsHandle(partition);
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
|
|||||||
|| (*itr).rfind(".bin") != string::npos || (*itr).rfind(".BIN") != string::npos)
|
|| (*itr).rfind(".bin") != string::npos || (*itr).rfind(".BIN") != string::npos)
|
||||||
{
|
{
|
||||||
char* filename = &(*itr)[(*itr).find_last_of('/')+1];
|
char* filename = &(*itr)[(*itr).find_last_of('/')+1];
|
||||||
const char* dml_partition = DeviceName[DeviceHandler::Instance()->PathToDriveType((*itr).c_str())];
|
const char* dml_partition = DeviceName[DeviceHandle.PathToDriveType((*itr).c_str())];
|
||||||
if(strcasecmp(filename, "game.iso") == 0 || strcasecmp(filename, "gam1.iso") == 0 || strcasecmp(filename, "boot.bin") == 0)
|
if(strcasecmp(filename, "game.iso") == 0 || strcasecmp(filename, "gam1.iso") == 0 || strcasecmp(filename, "boot.bin") == 0)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen((*itr).c_str(), "rb");
|
FILE *fp = fopen((*itr).c_str(), "rb");
|
||||||
@ -312,10 +312,10 @@ void CList<dir_discHdr>::GetHeaders(vector<string> pathlist, vector<dir_discHdr>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(strncasecmp(DeviceHandler::Instance()->PathToFSName((*itr).c_str()), "WBFS", 4) == 0)
|
else if(strncasecmp(DeviceHandle.PathToFSName((*itr).c_str()), "WBFS", 4) == 0)
|
||||||
{
|
{
|
||||||
u8 partition = DeviceHandler::Instance()->PathToDriveType((*itr).c_str());
|
u8 partition = DeviceHandle.PathToDriveType((*itr).c_str());
|
||||||
wbfs_t* handle = DeviceHandler::Instance()->GetWbfsHandle(partition);
|
wbfs_t* handle = DeviceHandle.GetWbfsHandle(partition);
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "gecko/gecko.h"
|
#include "gecko/gecko.h"
|
||||||
#include "memory/mem2.hpp"
|
#include "memory/mem2.hpp"
|
||||||
#include "memory/memory.h"
|
#include "memory/memory.h"
|
||||||
#include "music/musicplayer.h"
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
// mload from uloader by Hermes
|
// mload from uloader by Hermes
|
||||||
@ -90,7 +89,6 @@ bool loadIOS(int ios, bool MountDevices)
|
|||||||
{
|
{
|
||||||
WDVD_Close();
|
WDVD_Close();
|
||||||
Close_Inputs();
|
Close_Inputs();
|
||||||
m_music.StopAndSetPos();
|
|
||||||
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
|
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
|
||||||
ShutdownBeforeExit();
|
ShutdownBeforeExit();
|
||||||
ret = IOS_ReloadIOS(ios) == 0;
|
ret = IOS_ReloadIOS(ios) == 0;
|
||||||
@ -104,9 +102,9 @@ bool loadIOS(int ios, bool MountDevices)
|
|||||||
load_ehc_module_ex();
|
load_ehc_module_ex();
|
||||||
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
|
else if(CurrentIOS.Type == IOS_TYPE_WANIN && CurrentIOS.Revision >= 18)
|
||||||
load_dip_249();
|
load_dip_249();
|
||||||
DeviceHandler::Instance()->SetModes();
|
DeviceHandle.SetModes();
|
||||||
if(MountDevices && ios != CurIOS)
|
if(MountDevices && ios != CurIOS)
|
||||||
DeviceHandler::Instance()->MountAll();
|
DeviceHandle.MountAll();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ void ExternalBooter_ChannelSetup(u64 title)
|
|||||||
|
|
||||||
void ShutdownBeforeExit(bool KeepPatches)
|
void ShutdownBeforeExit(bool KeepPatches)
|
||||||
{
|
{
|
||||||
DeviceHandler::Instance()->UnMountAll();
|
DeviceHandle.UnMountAll();
|
||||||
Nand::Instance()->DeInit_ISFS(KeepPatches);
|
Nand::Instance()->DeInit_ISFS(KeepPatches);
|
||||||
WDVD_Close();
|
WDVD_Close();
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ bool WBFS_Close()
|
|||||||
wbfs_part_fs = 0;
|
wbfs_part_fs = 0;
|
||||||
wbfs_part_lba = 0;
|
wbfs_part_lba = 0;
|
||||||
wbfs_part_idx = 0;
|
wbfs_part_idx = 0;
|
||||||
strcpy(wbfs_fs_drive, "");
|
memset(wbfs_fs_drive, 0, sizeof(wbfs_fs_drive));
|
||||||
wbfs_mounted = 0;
|
wbfs_mounted = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -34,6 +34,7 @@ int main(int argc, char **argv)
|
|||||||
CVideo vid;
|
CVideo vid;
|
||||||
vid.init();
|
vid.init();
|
||||||
|
|
||||||
|
DeviceHandle.Init();
|
||||||
Nand::Instance()->Init_ISFS();
|
Nand::Instance()->Init_ISFS();
|
||||||
MEM_init(); //Inits both mem1lo and mem2
|
MEM_init(); //Inits both mem1lo and mem2
|
||||||
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
||||||
@ -73,7 +74,7 @@ int main(int argc, char **argv)
|
|||||||
CurrentIOS.Base = 254;
|
CurrentIOS.Base = 254;
|
||||||
CurrentIOS.Revision = 999;
|
CurrentIOS.Revision = 999;
|
||||||
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
|
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
|
||||||
DeviceHandler::Instance()->SetModes();
|
DeviceHandle.SetModes();
|
||||||
}
|
}
|
||||||
else if(AHBRPOT_Patched() && IOS_GetVersion() == 58)
|
else if(AHBRPOT_Patched() && IOS_GetVersion() == 58)
|
||||||
{
|
{
|
||||||
@ -89,7 +90,7 @@ int main(int argc, char **argv)
|
|||||||
Sys_Init();
|
Sys_Init();
|
||||||
Sys_ExitTo(EXIT_TO_HBC);
|
Sys_ExitTo(EXIT_TO_HBC);
|
||||||
|
|
||||||
DeviceHandler::Instance()->MountAll();
|
DeviceHandle.MountAll();
|
||||||
vid.waitMessage(0.15f);
|
vid.waitMessage(0.15f);
|
||||||
|
|
||||||
mainMenu = new CMenu(vid);
|
mainMenu = new CMenu(vid);
|
||||||
@ -97,7 +98,7 @@ int main(int argc, char **argv)
|
|||||||
mainMenu->init();
|
mainMenu->init();
|
||||||
if(CurrentIOS.Version != mainIOS && !neek2o() && !Sys_DolphinMode())
|
if(CurrentIOS.Version != mainIOS && !neek2o() && !Sys_DolphinMode())
|
||||||
{
|
{
|
||||||
if(useMainIOS || !DeviceHandler::Instance()->UsablePartitionMounted())
|
if(useMainIOS || !DeviceHandle.UsablePartitionMounted())
|
||||||
{
|
{
|
||||||
iosOK = loadIOS(mainIOS, true) && CustomIOS(CurrentIOS.Type);
|
iosOK = loadIOS(mainIOS, true) && CustomIOS(CurrentIOS.Type);
|
||||||
Open_Inputs();
|
Open_Inputs();
|
||||||
@ -109,7 +110,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if(!iosOK)
|
if(!iosOK)
|
||||||
mainMenu->terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
|
mainMenu->terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
|
||||||
else if(!DeviceHandler::Instance()->UsablePartitionMounted())
|
else if(!DeviceHandle.UsablePartitionMounted())
|
||||||
mainMenu->terror("errboot2", L"Could not find a device to save configuration files on!");
|
mainMenu->terror("errboot2", L"Could not find a device to save configuration files on!");
|
||||||
else if(WDVD_Init() < 0)
|
else if(WDVD_Init() < 0)
|
||||||
mainMenu->terror("errboot3", L"Could not initialize the DIP module!");
|
mainMenu->terror("errboot3", L"Could not initialize the DIP module!");
|
||||||
|
@ -158,7 +158,7 @@ void CMenu::init(void)
|
|||||||
Playlog_Delete();
|
Playlog_Delete();
|
||||||
|
|
||||||
for(int i = SD; i <= USB8; i++) //Find the first partition with a wiiflow.ini
|
for(int i = SD; i <= USB8; i++) //Find the first partition with a wiiflow.ini
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/" CFG_FILENAME, DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/" CFG_FILENAME, DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
@ -166,7 +166,7 @@ void CMenu::init(void)
|
|||||||
|
|
||||||
if(drive == check) //No wiiflow.ini found
|
if(drive == check) //No wiiflow.ini found
|
||||||
for(int i = SD; i <= USB8; i++) //Find the first partition with a boot.dol
|
for(int i = SD; i <= USB8; i++) //Find the first partition with a boot.dol
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/boot.dol", DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s/boot.dol", DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
@ -174,7 +174,7 @@ void CMenu::init(void)
|
|||||||
|
|
||||||
if(drive == check) //No boot.dol found
|
if(drive == check) //No boot.dol found
|
||||||
for(int i = SD; i <= USB8; i++) //Find the first partition with apps/wiiflow folder
|
for(int i = SD; i <= USB8; i++) //Find the first partition with apps/wiiflow folder
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR2), &dummy) == 0)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
@ -182,7 +182,7 @@ void CMenu::init(void)
|
|||||||
|
|
||||||
if(drive == check) //No apps/wiiflow folder found
|
if(drive == check) //No apps/wiiflow folder found
|
||||||
for(int i = SD; i <= USB8; i++) // Find the first writable partition
|
for(int i = SD; i <= USB8; i++) // Find the first writable partition
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
fsop_MakeFolder((char *)fmt("%s:/%s", DeviceName[i], APPDATA_DIR2)); //Make the apps dir, so saving wiiflow.ini does not fail.
|
fsop_MakeFolder((char *)fmt("%s:/%s", DeviceName[i], APPDATA_DIR2)); //Make the apps dir, so saving wiiflow.ini does not fail.
|
||||||
@ -221,17 +221,17 @@ void CMenu::init(void)
|
|||||||
if (onUSB)
|
if (onUSB)
|
||||||
{
|
{
|
||||||
for(int i = USB1; i <= USB8; i++) //Look for first partition with a wiiflow folder in root
|
for(int i = USB1; i <= USB8; i++) //Look for first partition with a wiiflow folder in root
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR), &dummy) == 0)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt("%s:/%s", DeviceName[i], APPDATA_DIR), &dummy) == 0)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(DeviceHandler::Instance()->IsInserted(SD)) drive = DeviceName[SD];
|
else if(DeviceHandle.IsInserted(SD)) drive = DeviceName[SD];
|
||||||
|
|
||||||
if(drive == check && onUSB) //No wiiflow folder found in root of any usb partition, and data_on_usb=yes
|
if(drive == check && onUSB) //No wiiflow folder found in root of any usb partition, and data_on_usb=yes
|
||||||
for(int i = USB1; i <= USB8; i++) // Try first USB partition with wbfs folder.
|
for(int i = USB1; i <= USB8; i++) // Try first USB partition with wbfs folder.
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS && stat(fmt(GAMES_DIR, DeviceName[i]), &dummy) == 0)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS && stat(fmt(GAMES_DIR, DeviceName[i]), &dummy) == 0)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
@ -239,7 +239,7 @@ void CMenu::init(void)
|
|||||||
|
|
||||||
if(drive == check && onUSB) // No wbfs folder found and data_on_usb=yes
|
if(drive == check && onUSB) // No wbfs folder found and data_on_usb=yes
|
||||||
for(int i = USB1; i <= USB8; i++) // Try first available USB partition.
|
for(int i = USB1; i <= USB8; i++) // Try first available USB partition.
|
||||||
if (DeviceHandler::Instance()->IsInserted(i) && DeviceHandler::Instance()->GetFSType(i) != PART_FS_WBFS)
|
if (DeviceHandle.IsInserted(i) && DeviceHandle.GetFSType(i) != PART_FS_WBFS)
|
||||||
{
|
{
|
||||||
drive = DeviceName[i];
|
drive = DeviceName[i];
|
||||||
break;
|
break;
|
||||||
@ -248,7 +248,7 @@ void CMenu::init(void)
|
|||||||
if(drive == check)
|
if(drive == check)
|
||||||
{
|
{
|
||||||
_buildMenus();
|
_buildMenus();
|
||||||
if(DeviceHandler::Instance()->IsInserted(SD))
|
if(DeviceHandle.IsInserted(SD))
|
||||||
{
|
{
|
||||||
error(_fmt("errboot5", L"data_on_usb=yes and No available usb partitions for data!\nUsing SD."));
|
error(_fmt("errboot5", L"data_on_usb=yes and No available usb partitions for data!\nUsing SD."));
|
||||||
drive = DeviceName[SD];
|
drive = DeviceName[SD];
|
||||||
@ -320,7 +320,7 @@ void CMenu::init(void)
|
|||||||
const char *checkDir = m_current_view == COVERFLOW_HOMEBREW ? HOMEBREW_DIR : GAMES_DIR;
|
const char *checkDir = m_current_view == COVERFLOW_HOMEBREW ? HOMEBREW_DIR : GAMES_DIR;
|
||||||
|
|
||||||
u8 partition = m_cfg.getInt(domain, "partition", 0); //Auto find a valid partition and fix old ini partition settings.
|
u8 partition = m_cfg.getInt(domain, "partition", 0); //Auto find a valid partition and fix old ini partition settings.
|
||||||
if(m_current_view != COVERFLOW_CHANNEL && (partition > USB8 || !DeviceHandler::Instance()->IsInserted(partition)))
|
if(m_current_view != COVERFLOW_CHANNEL && (partition > USB8 || !DeviceHandle.IsInserted(partition)))
|
||||||
{
|
{
|
||||||
m_cfg.remove(domain, "partition");
|
m_cfg.remove(domain, "partition");
|
||||||
for(int i = SD; i <= USB8+1; i++) // Find a usb partition with the wbfs folder or wbfs file system, else leave it blank (defaults to 1 later)
|
for(int i = SD; i <= USB8+1; i++) // Find a usb partition with the wbfs folder or wbfs file system, else leave it blank (defaults to 1 later)
|
||||||
@ -330,8 +330,8 @@ void CMenu::init(void)
|
|||||||
m_current_view = COVERFLOW_CHANNEL;
|
m_current_view = COVERFLOW_CHANNEL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DeviceHandler::Instance()->IsInserted(i)
|
if (DeviceHandle.IsInserted(i)
|
||||||
&& ((m_current_view == COVERFLOW_USB && DeviceHandler::Instance()->GetFSType(i) == PART_FS_WBFS)
|
&& ((m_current_view == COVERFLOW_USB && DeviceHandle.GetFSType(i) == PART_FS_WBFS)
|
||||||
|| stat(fmt(checkDir, DeviceName[i]), &dummy) == 0))
|
|| stat(fmt(checkDir, DeviceName[i]), &dummy) == 0))
|
||||||
{
|
{
|
||||||
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition);
|
gprintf("Setting Emu NAND to Partition: %i\n",currentPartition);
|
||||||
@ -437,7 +437,7 @@ void CMenu::init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_btnMgr.init(m_vid);
|
m_btnMgr.init(m_vid);
|
||||||
m_music.Init(m_cfg, m_musicDir, sfmt("%s/music", m_themeDataDir.c_str()));
|
MusicPlayer.Init(m_cfg, m_musicDir, sfmt("%s/music", m_themeDataDir.c_str()));
|
||||||
|
|
||||||
_buildMenus();
|
_buildMenus();
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ void CMenu::init(void)
|
|||||||
m_btnMgr.setRumble(m_cfg.getBool("GENERAL", "rumble", true));
|
m_btnMgr.setRumble(m_cfg.getBool("GENERAL", "rumble", true));
|
||||||
|
|
||||||
int exit_to = m_cfg.getInt("GENERAL", "exit_to", 0);
|
int exit_to = m_cfg.getInt("GENERAL", "exit_to", 0);
|
||||||
if(exit_to == EXIT_TO_BOOTMII && (!DeviceHandler::Instance()->IsInserted(SD) ||
|
if(exit_to == EXIT_TO_BOOTMII && (!DeviceHandle.IsInserted(SD) ||
|
||||||
stat(fmt("%s:/bootmii/armboot.bin",DeviceName[SD]), &dummy) != 0 ||
|
stat(fmt("%s:/bootmii/armboot.bin",DeviceName[SD]), &dummy) != 0 ||
|
||||||
stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) != 0))
|
stat(fmt("%s:/bootmii/ppcboot.elf", DeviceName[SD]), &dummy) != 0))
|
||||||
exit_to = EXIT_TO_HBC;
|
exit_to = EXIT_TO_HBC;
|
||||||
@ -496,7 +496,7 @@ void CMenu::cleanup()
|
|||||||
m_plugin.Cleanup();
|
m_plugin.Cleanup();
|
||||||
|
|
||||||
_stopSounds();
|
_stopSounds();
|
||||||
m_music.cleanup();
|
MusicPlayer.Cleanup();
|
||||||
m_cameraSound.release();
|
m_cameraSound.release();
|
||||||
ClearGameSoundThreadStack();
|
ClearGameSoundThreadStack();
|
||||||
SoundHandler::DestroyInstance();
|
SoundHandler::DestroyInstance();
|
||||||
@ -1894,7 +1894,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
|
|||||||
if(Sys_Exiting())
|
if(Sys_Exiting())
|
||||||
exitHandler(BUTTON_CALLBACK);
|
exitHandler(BUTTON_CALLBACK);
|
||||||
|
|
||||||
if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && m_music.GetVolume() == 0)
|
if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && MusicPlayer.GetVolume() == 0)
|
||||||
{
|
{
|
||||||
CheckGameSoundThread();
|
CheckGameSoundThread();
|
||||||
m_gameSound.Play(m_bnrSndVol);
|
m_gameSound.Play(m_bnrSndVol);
|
||||||
@ -1903,18 +1903,18 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
|
|||||||
else if(!m_gameSelected)
|
else if(!m_gameSelected)
|
||||||
m_gameSound.Stop();
|
m_gameSound.Stop();
|
||||||
|
|
||||||
m_music.Tick(m_video_playing || (m_gameSelected &&
|
MusicPlayer.Tick(m_video_playing || (m_gameSelected &&
|
||||||
m_gameSound.IsLoaded()) || m_gameSound.IsPlaying());
|
m_gameSound.IsLoaded()) || m_gameSound.IsPlaying());
|
||||||
|
|
||||||
if(m_music.SongChanged())
|
if(MusicPlayer.SongChanged())
|
||||||
{
|
{
|
||||||
m_btnMgr.setText(m_mainLblCurMusic, m_music.GetFileName(), true);
|
m_btnMgr.setText(m_mainLblCurMusic, MusicPlayer.GetFileName(), true);
|
||||||
m_btnMgr.show(m_mainLblCurMusic);
|
m_btnMgr.show(m_mainLblCurMusic);
|
||||||
m_music.DisplayTime = time(NULL);
|
MusicPlayer.DisplayTime = time(NULL);
|
||||||
}
|
}
|
||||||
else if(m_music.DisplayTime > 0 && time(NULL) - m_music.DisplayTime > 3)
|
else if(MusicPlayer.DisplayTime > 0 && time(NULL) - MusicPlayer.DisplayTime > 3)
|
||||||
{
|
{
|
||||||
m_music.DisplayTime = 0;
|
MusicPlayer.DisplayTime = 0;
|
||||||
m_btnMgr.hide(m_mainLblCurMusic);
|
m_btnMgr.hide(m_mainLblCurMusic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2153,14 +2153,12 @@ bool CMenu::_loadChannelList(void)
|
|||||||
Nand::Instance()->Disable_Emu();
|
Nand::Instance()->Disable_Emu();
|
||||||
if(!disable_emu)
|
if(!disable_emu)
|
||||||
{
|
{
|
||||||
if(useMainIOS)
|
MusicPlayer.Stop();
|
||||||
m_music.StopAndSetPos();
|
|
||||||
else
|
|
||||||
_TempLoadIOS();
|
_TempLoadIOS();
|
||||||
if(!DeviceHandler::Instance()->IsInserted(lastPartition))
|
if(!DeviceHandle.IsInserted(lastPartition))
|
||||||
DeviceHandler::Instance()->Mount(lastPartition);
|
DeviceHandle.Mount(lastPartition);
|
||||||
|
|
||||||
DeviceHandler::Instance()->UnMount(currentPartition);
|
DeviceHandle.UnMount(currentPartition);
|
||||||
|
|
||||||
Nand::Instance()->Init(emuPath.c_str(), currentPartition, disable_emu);
|
Nand::Instance()->Init(emuPath.c_str(), currentPartition, disable_emu);
|
||||||
if(Nand::Instance()->Enable_Emu() < 0)
|
if(Nand::Instance()->Enable_Emu() < 0)
|
||||||
@ -2169,8 +2167,8 @@ bool CMenu::_loadChannelList(void)
|
|||||||
gprintf("Using path: \"%s\" for NAND emulation\n", nandpath.c_str());
|
gprintf("Using path: \"%s\" for NAND emulation\n", nandpath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
DeviceHandler::Instance()->Mount(currentPartition);
|
DeviceHandle.Mount(currentPartition);
|
||||||
|
|
||||||
if(Nand::Instance()->EmulationEnabled() || disable_emu)
|
if(Nand::Instance()->EmulationEnabled() || disable_emu)
|
||||||
{
|
{
|
||||||
@ -2189,14 +2187,15 @@ bool CMenu::_loadList(void)
|
|||||||
{
|
{
|
||||||
m_cf.clear();
|
m_cf.clear();
|
||||||
m_gameList.clear();
|
m_gameList.clear();
|
||||||
if((m_current_view == COVERFLOW_CHANNEL && m_cfg.getBool("NAND", "disable", true)) || m_current_view != COVERFLOW_CHANNEL)
|
if((m_current_view == COVERFLOW_CHANNEL && m_cfg.getBool("NAND", "disable", true))
|
||||||
|
|| (m_current_view != COVERFLOW_CHANNEL && Nand::Instance()->EmulationEnabled()))
|
||||||
|
{
|
||||||
|
MusicPlayer.Stop();
|
||||||
Nand::Instance()->Disable_Emu();
|
Nand::Instance()->Disable_Emu();
|
||||||
|
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
|
||||||
|
}
|
||||||
if(m_cfg.getBool(_domainFromView(), "update_cache"))
|
if(m_cfg.getBool(_domainFromView(), "update_cache"))
|
||||||
m_gameList.Update(m_current_view);
|
m_gameList.Update(m_current_view);
|
||||||
|
|
||||||
/* Make sure if coming from Emu NAND the IOS is set back */
|
|
||||||
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
|
|
||||||
gprintf("Loading items of ");
|
gprintf("Loading items of ");
|
||||||
|
|
||||||
bool retval;
|
bool retval;
|
||||||
@ -2232,22 +2231,23 @@ bool CMenu::_loadList(void)
|
|||||||
bool CMenu::_loadGameList(void)
|
bool CMenu::_loadGameList(void)
|
||||||
{
|
{
|
||||||
currentPartition = m_cfg.getInt("GAMES", "partition", 1);
|
currentPartition = m_cfg.getInt("GAMES", "partition", 1);
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Config tmpcfg;
|
Config tmpcfg;
|
||||||
gprintf("%s\n", DeviceName[currentPartition]);
|
gprintf("%s\n", DeviceName[currentPartition]);
|
||||||
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
DeviceHandle.OpenWBFS(currentPartition);
|
||||||
m_gameList.Load(sfmt(GAMES_DIR, DeviceName[currentPartition]), ".wbfs|.iso", m_cfg.getString("GAMES", "lastlanguage", "EN").c_str(), tmpcfg);
|
m_gameList.Load(sfmt(GAMES_DIR, DeviceName[currentPartition]), ".wbfs|.iso", m_cfg.getString("GAMES", "lastlanguage", "EN").c_str(), tmpcfg);
|
||||||
m_cfg.setString("GAMES", "lastlanguage", m_loc.getString(m_curLanguage, "gametdb_code", "EN"));
|
m_cfg.setString("GAMES", "lastlanguage", m_loc.getString(m_curLanguage, "gametdb_code", "EN"));
|
||||||
m_cfg.save();
|
m_cfg.save();
|
||||||
|
WBFS_Close();
|
||||||
return m_gameList.size() > 0 ? true : false;
|
return m_gameList.size() > 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMenu::_loadHomebrewList()
|
bool CMenu::_loadHomebrewList()
|
||||||
{
|
{
|
||||||
currentPartition = m_cfg.getInt("HOMEBREW", "partition", DeviceHandler::Instance()->PathToDriveType(m_appDir.c_str()));
|
currentPartition = m_cfg.getInt("HOMEBREW", "partition", DeviceHandle.PathToDriveType(m_appDir.c_str()));
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Config tmpcfg;
|
Config tmpcfg;
|
||||||
@ -2261,7 +2261,7 @@ bool CMenu::_loadHomebrewList()
|
|||||||
bool CMenu::_loadDmlList()
|
bool CMenu::_loadDmlList()
|
||||||
{
|
{
|
||||||
currentPartition = m_cfg.getInt("DML", "partition", 0);
|
currentPartition = m_cfg.getInt("DML", "partition", 0);
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Config tmpcfg;
|
Config tmpcfg;
|
||||||
@ -2278,7 +2278,7 @@ bool CMenu::_loadDmlList()
|
|||||||
bool CMenu::_loadEmuList()
|
bool CMenu::_loadEmuList()
|
||||||
{
|
{
|
||||||
currentPartition = m_cfg.getInt("EMULATOR", "partition", 0);
|
currentPartition = m_cfg.getInt("EMULATOR", "partition", 0);
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
gprintf("%s\n", DeviceName[currentPartition]);
|
gprintf("%s\n", DeviceName[currentPartition]);
|
||||||
@ -2340,11 +2340,11 @@ void CMenu::_stopSounds(void)
|
|||||||
// Fade out sounds
|
// Fade out sounds
|
||||||
int fade_rate = m_cfg.getInt("GENERAL", "music_fade_rate", 8);
|
int fade_rate = m_cfg.getInt("GENERAL", "music_fade_rate", 8);
|
||||||
|
|
||||||
if(!m_music.IsStopped())
|
if(!MusicPlayer.IsStopped())
|
||||||
{
|
{
|
||||||
while(m_music.GetVolume() > 0 || m_gameSound.GetVolume() > 0)
|
while(MusicPlayer.GetVolume() > 0 || m_gameSound.GetVolume() > 0)
|
||||||
{
|
{
|
||||||
m_music.Tick(true);
|
MusicPlayer.Tick(true);
|
||||||
if(m_gameSound.GetVolume() > 0)
|
if(m_gameSound.GetVolume() > 0)
|
||||||
m_gameSound.SetVolume(m_gameSound.GetVolume() < fade_rate ? 0 : m_gameSound.GetVolume() - fade_rate);
|
m_gameSound.SetVolume(m_gameSound.GetVolume() < fade_rate ? 0 : m_gameSound.GetVolume() - fade_rate);
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
@ -2653,7 +2653,6 @@ void CMenu::RemoveCover( char * id )
|
|||||||
|
|
||||||
void CMenu::_TempLoadIOS(int IOS)
|
void CMenu::_TempLoadIOS(int IOS)
|
||||||
{
|
{
|
||||||
#ifndef DOLPHIN
|
|
||||||
/* Only temp reload in IOS58 mode */
|
/* Only temp reload in IOS58 mode */
|
||||||
if(useMainIOS || neek2o() || Sys_DolphinMode())
|
if(useMainIOS || neek2o() || Sys_DolphinMode())
|
||||||
return;
|
return;
|
||||||
@ -2670,5 +2669,4 @@ void CMenu::_TempLoadIOS(int IOS)
|
|||||||
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
|
for(int chan = WPAD_MAX_WIIMOTES-2; chan >= 0; chan--)
|
||||||
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
|
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "loader/gc_disc_dump.hpp"
|
#include "loader/gc_disc_dump.hpp"
|
||||||
#include "loader/wbfs.h"
|
#include "loader/wbfs.h"
|
||||||
#include "music/gui_sound.h"
|
#include "music/gui_sound.h"
|
||||||
#include "music/musicplayer.h"
|
#include "music/MusicPlayer.hpp"
|
||||||
#include "plugin/plugin.hpp"
|
#include "plugin/plugin.hpp"
|
||||||
#include "wiiuse/wpad.h"
|
#include "wiiuse/wpad.h"
|
||||||
|
|
||||||
|
@ -101,14 +101,14 @@ int CMenu::_configSnd(void)
|
|||||||
int musicVol = min(m_cfg.getInt("GENERAL", "sound_volume_music", 255) + step, 255);
|
int musicVol = min(m_cfg.getInt("GENERAL", "sound_volume_music", 255) + step, 255);
|
||||||
m_cfg.setInt("GENERAL", "sound_volume_music", musicVol);
|
m_cfg.setInt("GENERAL", "sound_volume_music", musicVol);
|
||||||
_showConfigSnd();
|
_showConfigSnd();
|
||||||
m_music.SetMaxVolume(musicVol);
|
MusicPlayer.SetMaxVolume(musicVol);
|
||||||
}
|
}
|
||||||
else if (m_btnMgr.selected(m_configSndBtnMusicVolM))
|
else if (m_btnMgr.selected(m_configSndBtnMusicVolM))
|
||||||
{
|
{
|
||||||
int musicVol = max(m_cfg.getInt("GENERAL", "sound_volume_music", 255) - step, 0);
|
int musicVol = max(m_cfg.getInt("GENERAL", "sound_volume_music", 255) - step, 0);
|
||||||
m_cfg.setInt("GENERAL", "sound_volume_music", musicVol);
|
m_cfg.setInt("GENERAL", "sound_volume_music", musicVol);
|
||||||
_showConfigSnd();
|
_showConfigSnd();
|
||||||
m_music.SetMaxVolume(musicVol);
|
MusicPlayer.SetMaxVolume(musicVol);
|
||||||
}
|
}
|
||||||
else if (m_btnMgr.selected(m_configSndBtnCFVolP))
|
else if (m_btnMgr.selected(m_configSndBtnCFVolP))
|
||||||
{
|
{
|
||||||
|
@ -265,6 +265,7 @@ static Banner *_extractBnr(dir_discHdr *hdr)
|
|||||||
{
|
{
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
Banner *banner = NULL;
|
Banner *banner = NULL;
|
||||||
|
DeviceHandle.OpenWBFS(currentPartition);
|
||||||
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->id, (char *) hdr->path);
|
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) &hdr->id, (char *) hdr->path);
|
||||||
if (disc != NULL)
|
if (disc != NULL)
|
||||||
{
|
{
|
||||||
@ -274,6 +275,7 @@ static Banner *_extractBnr(dir_discHdr *hdr)
|
|||||||
banner = new Banner((u8 *)bnr, size);
|
banner = new Banner((u8 *)bnr, size);
|
||||||
WBFS_CloseDisc(disc);
|
WBFS_CloseDisc(disc);
|
||||||
}
|
}
|
||||||
|
WBFS_Close();
|
||||||
return banner;
|
return banner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,7 +451,7 @@ void CMenu::_game(bool launch)
|
|||||||
FILE *file = fopen(videoPath.c_str(), "rb");
|
FILE *file = fopen(videoPath.c_str(), "rb");
|
||||||
if(file)
|
if(file)
|
||||||
{
|
{
|
||||||
m_music.StopAndSetPos();
|
MusicPlayer.Stop();
|
||||||
m_gameSound.Stop();
|
m_gameSound.Stop();
|
||||||
m_banner->SetShowBanner(false);
|
m_banner->SetShowBanner(false);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@ -544,6 +546,7 @@ void CMenu::_game(bool launch)
|
|||||||
else if(launch || m_btnMgr.selected(m_gameBtnPlay) || m_btnMgr.selected(m_gameBtnPlayFull) || !ShowPointer())
|
else if(launch || m_btnMgr.selected(m_gameBtnPlay) || m_btnMgr.selected(m_gameBtnPlayFull) || !ShowPointer())
|
||||||
{
|
{
|
||||||
_hideGame();
|
_hideGame();
|
||||||
|
MusicPlayer.Stop();
|
||||||
m_gameSound.FreeMemory();
|
m_gameSound.FreeMemory();
|
||||||
CheckGameSoundThread();
|
CheckGameSoundThread();
|
||||||
ClearGameSoundThreadStack();
|
ClearGameSoundThreadStack();
|
||||||
@ -738,15 +741,13 @@ void CMenu::directlaunch(const string &id)
|
|||||||
|
|
||||||
for (int i = USB1; i < USB8; i++)
|
for (int i = USB1; i < USB8; i++)
|
||||||
{
|
{
|
||||||
if(!DeviceHandler::Instance()->IsInserted(i)) continue;
|
if(!DeviceHandle.IsInserted(i)) continue;
|
||||||
|
|
||||||
DeviceHandler::Instance()->Open_WBFS(i);
|
DeviceHandle.OpenWBFS(i);
|
||||||
CList<dir_discHdr> list;
|
CList<dir_discHdr> list;
|
||||||
string path = sfmt(GAMES_DIR, DeviceName[i]);
|
string path = sfmt(GAMES_DIR, DeviceName[i]);
|
||||||
vector<string> pathlist;
|
vector<string> pathlist;
|
||||||
list.GetPaths(pathlist, id.c_str(), path,
|
list.GetPaths(pathlist, id.c_str(), path, strncasecmp(DeviceHandle.PathToFSName(path.c_str()), "WBFS", 4) == 0);
|
||||||
strncasecmp(DeviceHandler::Instance()->PathToFSName(path.c_str()), "WBFS", 4) == 0);
|
|
||||||
|
|
||||||
m_gameList.clear();
|
m_gameList.clear();
|
||||||
Config nullCfg;
|
Config nullCfg;
|
||||||
list.GetHeaders(pathlist, m_gameList, m_settingsDir, m_curLanguage, m_DMLgameDir, nullCfg);
|
list.GetHeaders(pathlist, m_gameList, m_settingsDir, m_curLanguage, m_DMLgameDir, nullCfg);
|
||||||
@ -755,6 +756,7 @@ void CMenu::directlaunch(const string &id)
|
|||||||
gprintf("Game found on partition #%i\n", i);
|
gprintf("Game found on partition #%i\n", i);
|
||||||
_launch(&m_gameList[0]); // Launch will exit wiiflow
|
_launch(&m_gameList[0]); // Launch will exit wiiflow
|
||||||
}
|
}
|
||||||
|
WBFS_Close();
|
||||||
}
|
}
|
||||||
error(sfmt("errgame1", L"Cannot find the game with ID: %s", id.c_str()));
|
error(sfmt("errgame1", L"Cannot find the game with ID: %s", id.c_str()));
|
||||||
}
|
}
|
||||||
@ -1109,7 +1111,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
|
|||||||
{
|
{
|
||||||
if(!emu_disabled)
|
if(!emu_disabled)
|
||||||
{
|
{
|
||||||
DeviceHandler::Instance()->UnMount(emuPartition);
|
DeviceHandle.UnMount(emuPartition);
|
||||||
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
|
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
|
||||||
Nand::Instance()->Enable_Emu();
|
Nand::Instance()->Enable_Emu();
|
||||||
}
|
}
|
||||||
@ -1360,10 +1362,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
|
if(_loadIOS(gameIOS, userIOS, id) == LOAD_IOS_FAILED)
|
||||||
Sys_Exit();
|
Sys_Exit();
|
||||||
}
|
}
|
||||||
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
|
||||||
bool wbfs_partition = (DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS);
|
|
||||||
if(!dvd && !wbfs_partition && get_frag_list((u8 *)id.c_str(), (char*)path.c_str(), currentPartition == 0 ? 0x200 : USBStorage2_GetSectorSize()) < 0)
|
|
||||||
Sys_Exit();
|
|
||||||
if(CurrentIOS.Type == IOS_TYPE_D2X)
|
if(CurrentIOS.Type == IOS_TYPE_D2X)
|
||||||
{
|
{
|
||||||
/* Open ES Module */
|
/* Open ES Module */
|
||||||
@ -1395,7 +1393,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
if(emulate_mode && !neek2o())
|
if(emulate_mode && !neek2o())
|
||||||
{
|
{
|
||||||
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
|
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
|
||||||
DeviceHandler::Instance()->UnMount(emuPartition);
|
DeviceHandle.UnMount(emuPartition);
|
||||||
|
|
||||||
if(emulate_mode == 3)
|
if(emulate_mode == 3)
|
||||||
Nand::Instance()->Set_RCMode(true);
|
Nand::Instance()->Set_RCMode(true);
|
||||||
@ -1409,12 +1407,16 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
error(_t("errgame6", L"Enabling emu after reload failed!"));
|
error(_t("errgame6", L"Enabling emu after reload failed!"));
|
||||||
Sys_Exit();
|
Sys_Exit();
|
||||||
}
|
}
|
||||||
if(!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if(!DeviceHandle.IsInserted(currentPartition))
|
||||||
DeviceHandler::Instance()->Mount(currentPartition);
|
DeviceHandle.Mount(currentPartition);
|
||||||
DeviceHandler::Instance()->Mount(emuPartition);
|
DeviceHandle.Mount(emuPartition);
|
||||||
}
|
}
|
||||||
if(!dvd)
|
if(!dvd)
|
||||||
{
|
{
|
||||||
|
DeviceHandle.OpenWBFS(currentPartition);
|
||||||
|
bool wbfs_partition = (DeviceHandle.GetFSType(currentPartition) == PART_FS_WBFS);
|
||||||
|
if(!wbfs_partition && get_frag_list((u8 *)id.c_str(), (char*)path.c_str(), currentPartition == 0 ? 0x200 : USBStorage2_GetSectorSize()) < 0)
|
||||||
|
Sys_Exit();
|
||||||
s32 ret = Disc_SetUSB((u8*)id.c_str(), !wbfs_partition);
|
s32 ret = Disc_SetUSB((u8*)id.c_str(), !wbfs_partition);
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
{
|
{
|
||||||
@ -1427,6 +1429,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
|
|||||||
error(_t("wbfsoperr2", L"Disc_Open failed"));
|
error(_t("wbfsoperr2", L"Disc_Open failed"));
|
||||||
Sys_Exit();
|
Sys_Exit();
|
||||||
}
|
}
|
||||||
|
WBFS_Close();
|
||||||
}
|
}
|
||||||
if(gameconfig.get() != NULL)
|
if(gameconfig.get() != NULL)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ void CMenu::_showMain(void)
|
|||||||
if(!m_cfg.getBool("NAND", "disable", true))
|
if(!m_cfg.getBool("NAND", "disable", true))
|
||||||
{
|
{
|
||||||
Nand::Instance()->Disable_Emu();
|
Nand::Instance()->Disable_Emu();
|
||||||
DeviceHandler::Instance()->MountAll();
|
DeviceHandle.MountAll();
|
||||||
_hideMain();
|
_hideMain();
|
||||||
if(!_AutoCreateNand())
|
if(!_AutoCreateNand())
|
||||||
m_cfg.setBool("NAND", "disable", true);
|
m_cfg.setBool("NAND", "disable", true);
|
||||||
@ -217,7 +217,7 @@ void CMenu::exitHandler(int ExitTo)
|
|||||||
if(ExitTo == EXIT_TO_BOOTMII) //Bootmii, check that the files are there, or ios will hang.
|
if(ExitTo == EXIT_TO_BOOTMII) //Bootmii, check that the files are there, or ios will hang.
|
||||||
{
|
{
|
||||||
struct stat dummy;
|
struct stat dummy;
|
||||||
if(!DeviceHandler::Instance()->IsInserted(SD) ||
|
if(!DeviceHandle.IsInserted(SD) ||
|
||||||
stat("sd:/bootmii/armboot.bin", &dummy) != 0 ||
|
stat("sd:/bootmii/armboot.bin", &dummy) != 0 ||
|
||||||
stat("sd:/bootmii/ppcboot.elf", &dummy) != 0)
|
stat("sd:/bootmii/ppcboot.elf", &dummy) != 0)
|
||||||
ExitTo = EXIT_TO_HBC;
|
ExitTo = EXIT_TO_HBC;
|
||||||
@ -545,14 +545,14 @@ int CMenu::main(void)
|
|||||||
else if(BTN_MINUS_PRESSED)
|
else if(BTN_MINUS_PRESSED)
|
||||||
{
|
{
|
||||||
if(b_lr_mode)
|
if(b_lr_mode)
|
||||||
m_music.Previous();
|
MusicPlayer.Previous();
|
||||||
else
|
else
|
||||||
m_cf.pageUp();
|
m_cf.pageUp();
|
||||||
}
|
}
|
||||||
else if(BTN_PLUS_PRESSED)
|
else if(BTN_PLUS_PRESSED)
|
||||||
{
|
{
|
||||||
if(b_lr_mode)
|
if(b_lr_mode)
|
||||||
m_music.Next();
|
MusicPlayer.Next();
|
||||||
else
|
else
|
||||||
m_cf.pageDown();
|
m_cf.pageDown();
|
||||||
}
|
}
|
||||||
@ -596,7 +596,7 @@ int CMenu::main(void)
|
|||||||
if(b_lr_mode)
|
if(b_lr_mode)
|
||||||
m_cf.pageUp();
|
m_cf.pageUp();
|
||||||
else
|
else
|
||||||
m_music.Previous();
|
MusicPlayer.Previous();
|
||||||
}
|
}
|
||||||
else if(BTN_RIGHT_PRESSED)
|
else if(BTN_RIGHT_PRESSED)
|
||||||
{
|
{
|
||||||
@ -604,7 +604,7 @@ int CMenu::main(void)
|
|||||||
if(b_lr_mode)
|
if(b_lr_mode)
|
||||||
m_cf.pageDown();
|
m_cf.pageDown();
|
||||||
else
|
else
|
||||||
m_music.Next();
|
MusicPlayer.Next();
|
||||||
}
|
}
|
||||||
else if(BTN_PLUS_PRESSED && !m_locked)
|
else if(BTN_PLUS_PRESSED && !m_locked)
|
||||||
{
|
{
|
||||||
@ -650,11 +650,11 @@ int CMenu::main(void)
|
|||||||
Nand::Instance()->Enable_Emu();
|
Nand::Instance()->Enable_Emu();
|
||||||
u8 limiter = 0;
|
u8 limiter = 0;
|
||||||
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
||||||
while(!DeviceHandler::Instance()->IsInserted(currentPartition) ||
|
while(!DeviceHandle.IsInserted(currentPartition) ||
|
||||||
((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_EMU) && (DeviceHandler::Instance()->GetFSType(currentPartition) != PART_FS_FAT ||
|
((m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_EMU) && (DeviceHandle.GetFSType(currentPartition) != PART_FS_FAT ||
|
||||||
(!isD2XnewerThanV6 && DeviceHandler::Instance()->PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
||||||
(!isD2XnewerThanV6 && DeviceHandler::Instance()->PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
||||||
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS))
|
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandle.GetFSType(currentPartition) == PART_FS_WBFS))
|
||||||
{
|
{
|
||||||
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
||||||
if(limiter > 10) break;
|
if(limiter > 10) break;
|
||||||
|
@ -118,10 +118,10 @@ int CMenu::_FindEmuPart(string *emuPath, int part, bool searchvalid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!DeviceHandler::Instance()->IsInserted(emuPartition))
|
if(!DeviceHandle.IsInserted(emuPartition))
|
||||||
DeviceHandler::Instance()->Mount(emuPartition);
|
DeviceHandle.Mount(emuPartition);
|
||||||
|
|
||||||
if(_TestEmuNand(emuPartition, tmpPath.c_str(), true) && DeviceHandler::Instance()->PartitionUsableForNandEmu(emuPartition))
|
if(_TestEmuNand(emuPartition, tmpPath.c_str(), true) && DeviceHandle.PartitionUsableForNandEmu(emuPartition))
|
||||||
{
|
{
|
||||||
*emuPath = tmpPath;
|
*emuPath = tmpPath;
|
||||||
return emuPartition;
|
return emuPartition;
|
||||||
@ -131,10 +131,10 @@ int CMenu::_FindEmuPart(string *emuPath, int part, bool searchvalid)
|
|||||||
bool fllscn = emuPartition == -1;
|
bool fllscn = emuPartition == -1;
|
||||||
for(u8 i = part; i <= USB8; ++i)
|
for(u8 i = part; i <= USB8; ++i)
|
||||||
{
|
{
|
||||||
if(!DeviceHandler::Instance()->IsInserted(i))
|
if(!DeviceHandle.IsInserted(i))
|
||||||
DeviceHandler::Instance()->Mount(i);
|
DeviceHandle.Mount(i);
|
||||||
|
|
||||||
if(!DeviceHandler::Instance()->PartitionUsableForNandEmu(i))
|
if(!DeviceHandle.PartitionUsableForNandEmu(i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(_TestEmuNand(i, tmpPath.c_str(), true) || searchvalid)
|
if(_TestEmuNand(i, tmpPath.c_str(), true) || searchvalid)
|
||||||
@ -203,11 +203,11 @@ void CMenu::_enableNandEmu(bool fromconfig)
|
|||||||
if (!fromconfig)
|
if (!fromconfig)
|
||||||
direction = 0;
|
direction = 0;
|
||||||
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
||||||
while(!DeviceHandler::Instance()->IsInserted(currentPartition) ||
|
while(!DeviceHandle.IsInserted(currentPartition) ||
|
||||||
(m_current_view == COVERFLOW_CHANNEL && (DeviceHandler::Instance()->GetFSType(currentPartition) != PART_FS_FAT ||
|
(m_current_view == COVERFLOW_CHANNEL && (DeviceHandle.GetFSType(currentPartition) != PART_FS_FAT ||
|
||||||
(!isD2XnewerThanV6 && DeviceHandler::Instance()->PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_appDir.c_str()) == currentPartition) ||
|
||||||
(!isD2XnewerThanV6 && DeviceHandler::Instance()->PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
(!isD2XnewerThanV6 && DeviceHandle.PathToDriveType(m_dataDir.c_str()) == currentPartition))) ||
|
||||||
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandler::Instance()->GetFSType(currentPartition) == PART_FS_WBFS))
|
((m_current_view == COVERFLOW_HOMEBREW || m_current_view == COVERFLOW_DML) && DeviceHandle.GetFSType(currentPartition) == PART_FS_WBFS))
|
||||||
{
|
{
|
||||||
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
currentPartition = loopNum(currentPartition + direction, (int)USB8);
|
||||||
if (limiter > 10) break;
|
if (limiter > 10) break;
|
||||||
|
@ -115,18 +115,16 @@ int CMenu::_gameInstaller(void *obj)
|
|||||||
CMenu &m = *(CMenu *)obj;
|
CMenu &m = *(CMenu *)obj;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DeviceHandler::Instance()->Open_WBFS(currentPartition);
|
DeviceHandle.OpenWBFS(currentPartition);
|
||||||
if(!WBFS_Mounted())
|
if(!WBFS_Mounted())
|
||||||
{
|
{
|
||||||
m.m_thrdWorking = false;
|
m.m_thrdWorking = false;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 comp_size = 0, real_size = 0;
|
u64 comp_size = 0, real_size = 0;
|
||||||
f32 free, used;
|
f32 free, used;
|
||||||
WBFS_DiskSpace(&used, &free);
|
WBFS_DiskSpace(&used, &free);
|
||||||
WBFS_DVD_Size(&comp_size, &real_size);
|
WBFS_DVD_Size(&comp_size, &real_size);
|
||||||
|
|
||||||
if((f32)comp_size + (f32)128*1024 >= free * GB_SIZE)
|
if((f32)comp_size + (f32)128*1024 >= free * GB_SIZE)
|
||||||
{
|
{
|
||||||
LWP_MutexLock(m.m_mutex);
|
LWP_MutexLock(m.m_mutex);
|
||||||
@ -149,6 +147,7 @@ int CMenu::_gameInstaller(void *obj)
|
|||||||
LWP_MutexUnlock(m.m_mutex);
|
LWP_MutexUnlock(m.m_mutex);
|
||||||
slotLight(true);
|
slotLight(true);
|
||||||
}
|
}
|
||||||
|
WBFS_Close();
|
||||||
m.m_thrdWorking = false;
|
m.m_thrdWorking = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -173,7 +172,7 @@ int CMenu::_GCgameInstaller(void *obj)
|
|||||||
int ret;
|
int ret;
|
||||||
m.m_progress = 0.f;
|
m.m_progress = 0.f;
|
||||||
|
|
||||||
if (!DeviceHandler::Instance()->IsInserted(currentPartition))
|
if (!DeviceHandle.IsInserted(currentPartition))
|
||||||
{
|
{
|
||||||
m.m_thrdWorking = false;
|
m.m_thrdWorking = false;
|
||||||
return -1;
|
return -1;
|
||||||
@ -307,6 +306,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
|||||||
switch(op)
|
switch(op)
|
||||||
{
|
{
|
||||||
case CMenu::WO_ADD_GAME:
|
case CMenu::WO_ADD_GAME:
|
||||||
|
MusicPlayer.Stop();
|
||||||
_TempLoadIOS();
|
_TempLoadIOS();
|
||||||
m_btnMgr.show(m_wbfsPBar);
|
m_btnMgr.show(m_wbfsPBar);
|
||||||
m_btnMgr.setProgress(m_wbfsPBar, 0.f);
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f);
|
||||||
@ -436,7 +436,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
|||||||
m_thrdMessageAdded = false;
|
m_thrdMessageAdded = false;
|
||||||
m_cf.stopCoverLoader();
|
m_cf.stopCoverLoader();
|
||||||
_stopSounds();
|
_stopSounds();
|
||||||
m_music.cleanup();
|
MusicPlayer.Cleanup();
|
||||||
SoundHandler::DestroyInstance();
|
SoundHandler::DestroyInstance();
|
||||||
soundDeinit();
|
soundDeinit();
|
||||||
Nand::Instance()->Disable_Emu();
|
Nand::Instance()->Disable_Emu();
|
||||||
@ -461,6 +461,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
|||||||
if(op == CMenu::WO_ADD_GAME)
|
if(op == CMenu::WO_ADD_GAME)
|
||||||
{
|
{
|
||||||
WDVD_StopMotor();
|
WDVD_StopMotor();
|
||||||
|
MusicPlayer.Stop();
|
||||||
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
|
_TempLoadIOS(IOS_TYPE_NORMAL_IOS);
|
||||||
}
|
}
|
||||||
m_btnMgr.show(m_wbfsBtnBack);
|
m_btnMgr.show(m_wbfsBtnBack);
|
||||||
|
171
source/music/MusicPlayer.cpp
Normal file
171
source/music/MusicPlayer.cpp
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2012 FIX94
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include "MusicPlayer.hpp"
|
||||||
|
#include "SoundHandler.hpp"
|
||||||
|
#include "fileOps/fileOps.h"
|
||||||
|
#include "gui/text.hpp"
|
||||||
|
#include "gecko/gecko.h"
|
||||||
|
|
||||||
|
Musicplayer MusicPlayer;
|
||||||
|
|
||||||
|
void Musicplayer::Cleanup()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
DisplayTime = 0;
|
||||||
|
CurrentPosition = 0;
|
||||||
|
MusicChanged = false;
|
||||||
|
MusicStopped = true;
|
||||||
|
FileNames.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::Init(Config &cfg, string musicDir, string themeMusicDir)
|
||||||
|
{
|
||||||
|
Cleanup();
|
||||||
|
FadeRate = cfg.getInt("GENERAL", "music_fade_rate", 8);
|
||||||
|
Volume = cfg.getInt("GENERAL", "sound_volume_music", 255);
|
||||||
|
|
||||||
|
SetVolume(0);
|
||||||
|
MusicFile.SetVoice(0);
|
||||||
|
|
||||||
|
ScanDirectories(themeMusicDir.c_str());
|
||||||
|
ScanDirectories(musicDir.c_str());
|
||||||
|
if(cfg.getBool("GENERAL", "randomize_music", true) && FileNames.size() > 0)
|
||||||
|
{
|
||||||
|
srand(unsigned(time(NULL)));
|
||||||
|
random_shuffle(FileNames.begin(), FileNames.end());
|
||||||
|
}
|
||||||
|
CurrentFileName = FileNames.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::ScanDirectories(const char *directory)
|
||||||
|
{
|
||||||
|
struct dirent *pent = NULL;
|
||||||
|
DIR *pdir = opendir(directory);
|
||||||
|
while((pent = readdir(pdir)) != NULL)
|
||||||
|
{
|
||||||
|
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
|
||||||
|
continue;
|
||||||
|
string CurrentItem = sfmt("%s/%s", directory, pent->d_name);
|
||||||
|
if(fsop_DirExist(CurrentItem.c_str()))
|
||||||
|
ScanDirectories(CurrentItem.c_str());
|
||||||
|
else if(strcasestr(pent->d_name, ".mp3") != NULL || strcasestr(pent->d_name, ".ogg") != NULL)
|
||||||
|
FileNames.push_back(CurrentItem);
|
||||||
|
}
|
||||||
|
closedir(pdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::SetMaxVolume(u8 volume)
|
||||||
|
{
|
||||||
|
Volume = volume;
|
||||||
|
SetVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::SetVolume(u8 volume)
|
||||||
|
{
|
||||||
|
CurrentVolume = volume;
|
||||||
|
MusicFile.SetVolume(CurrentVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::Previous()
|
||||||
|
{
|
||||||
|
if(FileNames.empty() || PosFromPrevFile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(CurrentFileName == FileNames.begin())
|
||||||
|
CurrentFileName = FileNames.end();
|
||||||
|
CurrentFileName--;
|
||||||
|
LoadCurrentFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::Next()
|
||||||
|
{
|
||||||
|
if(FileNames.empty() || PosFromPrevFile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CurrentFileName++;
|
||||||
|
if(CurrentFileName == FileNames.end())
|
||||||
|
CurrentFileName = FileNames.begin();
|
||||||
|
LoadCurrentFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Musicplayer::PosFromPrevFile()
|
||||||
|
{
|
||||||
|
if(!CurrentPosition)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MusicFile.Load((*CurrentFileName).c_str());
|
||||||
|
SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Seek(CurrentPosition);
|
||||||
|
SetVolume(CurrentVolume);
|
||||||
|
MusicFile.Play();
|
||||||
|
CurrentPosition = 0;
|
||||||
|
MusicStopped = false;
|
||||||
|
MusicChanged = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::Stop()
|
||||||
|
{
|
||||||
|
if(!MusicFile.IsPlaying())
|
||||||
|
return;
|
||||||
|
MusicFile.Pause();
|
||||||
|
CurrentPosition = SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Tell();
|
||||||
|
MusicFile.FreeMemory();
|
||||||
|
MusicStopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::Tick(bool attenuate)
|
||||||
|
{
|
||||||
|
if(FileNames.empty())
|
||||||
|
return;
|
||||||
|
if(!attenuate && CurrentVolume < Volume)
|
||||||
|
SetVolume(CurrentVolume + FadeRate > Volume ? Volume : CurrentVolume + FadeRate);
|
||||||
|
else if(attenuate && CurrentVolume > 0)
|
||||||
|
SetVolume(CurrentVolume - FadeRate < 0 ? 0 : CurrentVolume - FadeRate);
|
||||||
|
if(!attenuate && !MusicFile.IsPlaying())
|
||||||
|
Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Musicplayer::LoadCurrentFile()
|
||||||
|
{
|
||||||
|
MusicFile.Load((*CurrentFileName).c_str());
|
||||||
|
SetVolume(CurrentVolume);
|
||||||
|
MusicFile.Play();
|
||||||
|
CurrentPosition = 0;
|
||||||
|
MusicStopped = false;
|
||||||
|
MusicChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For our GUI */
|
||||||
|
wstringEx Musicplayer::GetFileName()
|
||||||
|
{
|
||||||
|
wstringEx CurrentFile;
|
||||||
|
string CurrentFileStr((*CurrentFileName).begin()+(*CurrentFileName).find_last_of('/')+1,
|
||||||
|
(*CurrentFileName).begin()+(*CurrentFileName).find_last_of('.'));
|
||||||
|
CurrentFile.fromUTF8(CurrentFileStr.c_str());
|
||||||
|
return CurrentFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Musicplayer::SongChanged()
|
||||||
|
{
|
||||||
|
if(!MusicChanged)
|
||||||
|
return false;
|
||||||
|
MusicChanged = false;
|
||||||
|
return true;
|
||||||
|
}
|
68
source/music/MusicPlayer.hpp
Normal file
68
source/music/MusicPlayer.hpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* Copyright (C) 2012 FIX94
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef _MUSICPLAYER_HPP_
|
||||||
|
#define _MUSICPLAYER_HPP_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "gui_sound.h"
|
||||||
|
#include "config/config.hpp"
|
||||||
|
#include "wstringEx/wstringEx.hpp"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class Musicplayer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Cleanup();
|
||||||
|
void Init(Config &cfg, string musicDir, string themeMusicDir);
|
||||||
|
void Tick(bool attenuate);
|
||||||
|
|
||||||
|
void SetVolume(u8 volume);
|
||||||
|
void SetMaxVolume(u8 volume);
|
||||||
|
u8 GetVolume() { return CurrentVolume; };
|
||||||
|
u8 GetMaxVolume() { return Volume; };
|
||||||
|
|
||||||
|
void Previous();
|
||||||
|
void Next();
|
||||||
|
void Stop();
|
||||||
|
|
||||||
|
bool IsStopped() { return MusicStopped; };
|
||||||
|
|
||||||
|
/* For our GUI */
|
||||||
|
wstringEx GetFileName();
|
||||||
|
bool SongChanged();
|
||||||
|
time_t DisplayTime;
|
||||||
|
protected:
|
||||||
|
bool PosFromPrevFile();
|
||||||
|
void LoadCurrentFile();
|
||||||
|
void ScanDirectories(const char *directory);
|
||||||
|
|
||||||
|
u8 Volume;
|
||||||
|
u8 CurrentVolume;
|
||||||
|
u8 FadeRate;
|
||||||
|
int CurrentPosition;
|
||||||
|
bool MusicStopped;
|
||||||
|
bool MusicChanged;
|
||||||
|
|
||||||
|
GuiSound MusicFile;
|
||||||
|
vector<string> FileNames;
|
||||||
|
vector<string>::iterator CurrentFileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Musicplayer MusicPlayer;
|
||||||
|
|
||||||
|
#endif /* _MUSICPLAYER_HPP_ */
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "gui_sound.h"
|
#include "gui_sound.h"
|
||||||
#include "SoundHandler.hpp"
|
#include "SoundHandler.hpp"
|
||||||
#include "musicplayer.h"
|
#include "MusicPlayer.hpp"
|
||||||
#include "WavDecoder.hpp"
|
#include "WavDecoder.hpp"
|
||||||
#include "loader/sys.h"
|
#include "loader/sys.h"
|
||||||
#include "banner/AnimatedBanner.h"
|
#include "banner/AnimatedBanner.h"
|
||||||
|
@ -1,179 +0,0 @@
|
|||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#include "musicplayer.h"
|
|
||||||
#include "SoundHandler.hpp"
|
|
||||||
#include "fileOps/fileOps.h"
|
|
||||||
#include "gui/text.hpp"
|
|
||||||
|
|
||||||
MusicPlayer m_music;
|
|
||||||
|
|
||||||
void MusicPlayer::cleanup()
|
|
||||||
{
|
|
||||||
if(m_music_files.empty())
|
|
||||||
return;
|
|
||||||
MusicFile.Pause();
|
|
||||||
MusicFile.Stop();
|
|
||||||
MusicFile.FreeMemory();
|
|
||||||
m_music_files.clear();
|
|
||||||
DisplayTime = 0;
|
|
||||||
m_changed = false;
|
|
||||||
m_stopped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir)
|
|
||||||
{
|
|
||||||
DisplayTime = 0;
|
|
||||||
m_changed = false;
|
|
||||||
m_stopped = true;
|
|
||||||
CurrentPosition = 0;
|
|
||||||
m_fade_rate = cfg.getInt("GENERAL", "music_fade_rate", 8);
|
|
||||||
m_music_volume = cfg.getInt("GENERAL", "sound_volume_music", 255);
|
|
||||||
|
|
||||||
SetVolume(0);
|
|
||||||
MusicFile.SetVoice(0);
|
|
||||||
m_music_files.clear();
|
|
||||||
ScanDirectories(themeMusicDir.c_str());
|
|
||||||
ScanDirectories(musicDir.c_str());
|
|
||||||
|
|
||||||
if(cfg.getBool("GENERAL", "randomize_music", true) && m_music_files.size() > 0)
|
|
||||||
{
|
|
||||||
srand(unsigned(time(NULL)));
|
|
||||||
random_shuffle(m_music_files.begin(), m_music_files.end());
|
|
||||||
}
|
|
||||||
m_current_music = m_music_files.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::ScanDirectories(const char *directory)
|
|
||||||
{
|
|
||||||
struct dirent *pent = NULL;
|
|
||||||
DIR *pdir = opendir(directory);
|
|
||||||
while((pent = readdir(pdir)) != NULL)
|
|
||||||
{
|
|
||||||
if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0)
|
|
||||||
continue;
|
|
||||||
string CurrentItem = sfmt("%s/%s", directory, pent->d_name);
|
|
||||||
if(fsop_DirExist(CurrentItem.c_str()))
|
|
||||||
ScanDirectories(CurrentItem.c_str());
|
|
||||||
else if(strcasestr(pent->d_name, ".mp3") != NULL || strcasestr(pent->d_name, ".ogg") != NULL)
|
|
||||||
m_music_files.push_back(CurrentItem);
|
|
||||||
}
|
|
||||||
closedir(pdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::SetMaxVolume(u8 volume)
|
|
||||||
{
|
|
||||||
m_music_volume = volume;
|
|
||||||
SetVolume(volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::SetVolume(u8 volume)
|
|
||||||
{
|
|
||||||
m_music_current_volume = volume;
|
|
||||||
MusicFile.SetVolume(m_music_current_volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Previous()
|
|
||||||
{
|
|
||||||
if(m_music_files.empty())
|
|
||||||
return;
|
|
||||||
if(PosFromPrevFile())
|
|
||||||
return;
|
|
||||||
if(m_current_music == m_music_files.begin())
|
|
||||||
m_current_music = m_music_files.end();
|
|
||||||
|
|
||||||
m_current_music--;
|
|
||||||
|
|
||||||
LoadCurrentFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Next()
|
|
||||||
{
|
|
||||||
if(m_music_files.empty())
|
|
||||||
return;
|
|
||||||
if(PosFromPrevFile())
|
|
||||||
return;
|
|
||||||
m_current_music++;
|
|
||||||
if (m_current_music == m_music_files.end())
|
|
||||||
m_current_music = m_music_files.begin();
|
|
||||||
|
|
||||||
LoadCurrentFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::StopAndSetPos()
|
|
||||||
{
|
|
||||||
if(m_music_files.empty())
|
|
||||||
return;
|
|
||||||
CurrentPosition = SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Tell();
|
|
||||||
Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MusicPlayer::PosFromPrevFile()
|
|
||||||
{
|
|
||||||
if(!CurrentPosition)
|
|
||||||
return false;
|
|
||||||
LoadCurrentFile();
|
|
||||||
MusicFile.Pause();
|
|
||||||
SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Seek(CurrentPosition);
|
|
||||||
CurrentPosition = 0;
|
|
||||||
MusicFile.Resume();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Play()
|
|
||||||
{
|
|
||||||
SetVolume(m_music_current_volume);
|
|
||||||
MusicFile.Play();
|
|
||||||
m_stopped = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Stop()
|
|
||||||
{
|
|
||||||
MusicFile.Pause();
|
|
||||||
MusicFile.Stop();
|
|
||||||
m_stopped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::Tick(bool attenuate)
|
|
||||||
{
|
|
||||||
if(m_music_files.empty())
|
|
||||||
return;
|
|
||||||
if(!attenuate && m_music_current_volume < m_music_volume)
|
|
||||||
{
|
|
||||||
SetVolume(m_music_current_volume + m_fade_rate > m_music_volume ? m_music_volume
|
|
||||||
: m_music_current_volume + m_fade_rate);
|
|
||||||
}
|
|
||||||
else if(attenuate && m_music_current_volume > 0)
|
|
||||||
{
|
|
||||||
SetVolume(m_music_current_volume - m_fade_rate < 0 ? 0
|
|
||||||
: m_music_current_volume - m_fade_rate);
|
|
||||||
}
|
|
||||||
if(!attenuate && !MusicFile.IsPlaying())
|
|
||||||
Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MusicPlayer::LoadCurrentFile()
|
|
||||||
{
|
|
||||||
m_changed = true;
|
|
||||||
MusicFile.Load((*m_current_music).c_str());
|
|
||||||
Play();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For our GUI */
|
|
||||||
wstringEx MusicPlayer::GetFileName()
|
|
||||||
{
|
|
||||||
wstringEx CurrentFile;
|
|
||||||
string CurrentFileStr((*m_current_music).begin()+(*m_current_music).find_last_of('/')+1,
|
|
||||||
(*m_current_music).begin()+(*m_current_music).find_last_of('.'));
|
|
||||||
CurrentFile.fromUTF8(CurrentFileStr.c_str());
|
|
||||||
return CurrentFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MusicPlayer::SongChanged()
|
|
||||||
{
|
|
||||||
if(!m_changed)
|
|
||||||
return false;
|
|
||||||
m_changed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
#ifndef _MUSICPLAYER_H
|
|
||||||
#define _MUSICPLAYER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "gui_sound.h"
|
|
||||||
#include "config/config.hpp"
|
|
||||||
#include "wstringEx/wstringEx.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MusicPlayer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void cleanup();
|
|
||||||
void Init(Config &cfg, string musicDir, string themeMusicDir);
|
|
||||||
void Tick(bool attenuate);
|
|
||||||
|
|
||||||
void SetVolume(u8 volume);
|
|
||||||
void SetMaxVolume(u8 volume);
|
|
||||||
u8 GetVolume() { return m_music_current_volume; };
|
|
||||||
u8 GetMaxVolume() { return m_music_volume; };
|
|
||||||
|
|
||||||
void Previous();
|
|
||||||
void Next();
|
|
||||||
void StopAndSetPos();
|
|
||||||
|
|
||||||
bool IsStopped() { return m_stopped; };
|
|
||||||
|
|
||||||
/* For our GUI */
|
|
||||||
wstringEx GetFileName();
|
|
||||||
bool SongChanged();
|
|
||||||
time_t DisplayTime;
|
|
||||||
protected:
|
|
||||||
void Play();
|
|
||||||
void Stop();
|
|
||||||
bool PosFromPrevFile();
|
|
||||||
void LoadCurrentFile();
|
|
||||||
void ScanDirectories(const char *directory);
|
|
||||||
|
|
||||||
u8 m_music_volume;
|
|
||||||
u8 m_music_current_volume;
|
|
||||||
u8 m_fade_rate;
|
|
||||||
int CurrentPosition;
|
|
||||||
bool m_stopped;
|
|
||||||
bool m_changed;
|
|
||||||
|
|
||||||
GuiSound MusicFile;
|
|
||||||
vector<string> m_music_files;
|
|
||||||
vector<string>::iterator m_current_music;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern MusicPlayer m_music;
|
|
||||||
|
|
||||||
#endif
|
|
@ -261,7 +261,7 @@ vector<string> Plugin::CreateMplayerCEArguments(const char *filepath)
|
|||||||
while(ptr[0] != '/' || ptr[1] == '/')
|
while(ptr[0] != '/' || ptr[1] == '/')
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
if(strncmp(DeviceHandler::PathToFSName(filepath), "NTF", 3) == 0)
|
if(strncmp(DeviceHandle.PathToFSName(filepath), "NTF", 3) == 0)
|
||||||
{
|
{
|
||||||
sprintf(dst, "ntfs:%s", ptr);
|
sprintf(dst, "ntfs:%s", ptr);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
<pd><ViewState><e p="Wiiflow" x="true"></e><e p="Wiiflow\resources" x="false"></e><e p="Wiiflow\data" x="false"></e><e p="Wiiflow\scripts" x="false"></e><e p="Wiiflow\source" x="true"></e><e p="Wiiflow\source\network" x="false"></e><e p="Wiiflow\source\channel" x="false"></e><e p="Wiiflow\source\menu" x="true"></e><e p="Wiiflow\docs" x="false"></e><e p="Wiiflow\portlibs" x="false"></e><e p="Wiiflow\source\banner" x="false"></e><e p="Wiiflow\source\cheats" x="false"></e><e p="Wiiflow\source\config" x="false"></e><e p="Wiiflow\source\devicemounter" x="false"></e><e p="Wiiflow\source\fileOps" x="false"></e><e p="Wiiflow\source\gc" x="false"></e><e p="Wiiflow\source\gecko" x="false"></e><e p="Wiiflow\source\gui" x="false"></e><e p="Wiiflow\source\homebrew" x="false"></e><e p="Wiiflow\source\libwbfs" x="false"></e><e p="Wiiflow\source\list" x="true"></e><e p="Wiiflow\source\loader" x="true"></e><e p="Wiiflow\source\memory" x="false"></e><e p="Wiiflow\source\music" x="false"></e><e p="Wiiflow\source\plugin" x="false"></e><e p="Wiiflow\source\unzip" x="false"></e><e p="Wiiflow\source\wstringEx" x="false"></e><e p="Wiiflow\wii" x="false"></e></ViewState></pd>
|
<pd><ViewState><e p="Wiiflow" x="true"></e><e p="Wiiflow\resources" x="false"></e><e p="Wiiflow\data" x="false"></e><e p="Wiiflow\scripts" x="false"></e><e p="Wiiflow\source" x="false"></e><e p="Wiiflow\wii" x="false"></e><e p="Wiiflow\docs" x="false"></e><e p="Wiiflow\portlibs" x="false"></e></ViewState></pd>
|
Loading…
Reference in New Issue
Block a user