force VolumeDirectory to align files to 32KB (only streaming audio files really need to be aligned...)
This commit is contained in:
parent
5ceef0c513
commit
26521aa66a
|
@ -161,6 +161,7 @@ void LoadDefaultSSEState();
|
|||
float MathFloatVectorSum(const std::vector<float>&);
|
||||
|
||||
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
||||
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))
|
||||
|
||||
|
||||
// Tiny matrix/vector library.
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "Common.h" // Common
|
||||
#include "StringUtil.h"
|
||||
#include "FileUtil.h"
|
||||
#include "MathUtil.h"
|
||||
|
||||
#include "../HLE/HLE.h" // Core
|
||||
#include "../PowerPC/PowerPC.h"
|
||||
|
@ -68,7 +69,7 @@ void CBoot::Load_FST(bool _bIsWii)
|
|||
u32 fstSize = VolumeHandler::Read32(0x0428) << shift;
|
||||
u32 maxFstSize = VolumeHandler::Read32(0x042c) << shift;
|
||||
|
||||
u32 arenaHigh = 0x817FFFF4 - maxFstSize;
|
||||
u32 arenaHigh = ROUND_DOWN(0x817FFFFF - maxFstSize, 0x20);
|
||||
Memory::Write_U32(arenaHigh, 0x00000034);
|
||||
|
||||
// load FST
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "Common.h"
|
||||
#include "MathUtil.h"
|
||||
#include "CommonPaths.h"
|
||||
#include "VolumeDirectory.h"
|
||||
#include "FileBlob.h"
|
||||
|
@ -23,17 +24,6 @@
|
|||
namespace DiscIO
|
||||
{
|
||||
|
||||
static const u8 ENTRY_SIZE = 0x0c;
|
||||
static const u8 FILE_ENTRY = 0;
|
||||
static const u8 DIRECTORY_ENTRY = 1;
|
||||
static const u64 DISKHEADER_ADDRESS = 0;
|
||||
static const u64 DISKHEADERINFO_ADDRESS = 0x440;
|
||||
static const u64 APPLOADER_ADDRESS = 0x2440;
|
||||
static const u32 MAX_NAME_LENGTH = 0x3df;
|
||||
// relocatable
|
||||
static u64 FST_ADDRESS = 0x440;
|
||||
static u64 DOL_ADDRESS = 0;
|
||||
|
||||
CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii,
|
||||
const std::string& _rApploader, const std::string& _rDOL)
|
||||
: m_totalNameSize(0)
|
||||
|
@ -44,6 +34,8 @@ CVolumeDirectory::CVolumeDirectory(const std::string& _rDirectory, bool _bIsWii,
|
|||
, m_apploader(NULL)
|
||||
, m_DOLSize(0)
|
||||
, m_DOL(NULL)
|
||||
, FST_ADDRESS(0)
|
||||
, DOL_ADDRESS(0)
|
||||
{
|
||||
m_rootDirectory = ExtractDirectoryName(_rDirectory);
|
||||
|
||||
|
@ -321,7 +313,7 @@ bool CVolumeDirectory::SetApploader(const std::string& _rApploader)
|
|||
copy(data.begin(), data.end(), m_apploader);
|
||||
|
||||
// 32byte aligned (plus 0x20 padding)
|
||||
DOL_ADDRESS = (APPLOADER_ADDRESS + m_apploaderSize + 0x20 + 31) & ~31ULL;
|
||||
DOL_ADDRESS = ROUND_UP(APPLOADER_ADDRESS + m_apploaderSize + 0x20, 0x20ull);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -347,7 +339,7 @@ void CVolumeDirectory::SetDOL(const std::string& _rDOL)
|
|||
Write32((u32)(DOL_ADDRESS >> m_addressShift), 0x0420, m_diskHeader);
|
||||
|
||||
// 32byte aligned (plus 0x20 padding)
|
||||
FST_ADDRESS = (DOL_ADDRESS + m_DOLSize + 0x20 + 31) & ~31ULL;
|
||||
FST_ADDRESS = ROUND_UP(DOL_ADDRESS + m_DOLSize + 0x20, 0x20ull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,8 +359,12 @@ void CVolumeDirectory::BuildFST()
|
|||
m_fstSize = m_fstNameOffset + m_totalNameSize;
|
||||
m_FSTData = new u8[(u32)m_fstSize];
|
||||
|
||||
// if FST hasn't been assigned (ie no apploader/dol setup), set to default
|
||||
if (FST_ADDRESS == 0)
|
||||
FST_ADDRESS = APPLOADER_ADDRESS + 0x2000;
|
||||
|
||||
// 4 byte aligned start of data on disk
|
||||
m_dataStartAddress = (FST_ADDRESS + m_fstSize + 3) & ~3;
|
||||
m_dataStartAddress = ROUND_UP(FST_ADDRESS + m_fstSize, 0x8000ull);
|
||||
u64 curDataAddress = m_dataStartAddress;
|
||||
|
||||
u32 fstOffset = 0; // offset within FST data
|
||||
|
@ -490,7 +486,7 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
|
|||
m_virtualDisk.insert(make_pair(dataOffset, entry.physicalName));
|
||||
|
||||
// 4 byte aligned
|
||||
dataOffset = (dataOffset + entry.size + 3) & ~3ULL;
|
||||
dataOffset = ROUND_UP(dataOffset + entry.size, 0x8000ull);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,16 @@ private:
|
|||
|
||||
u64 m_DOLSize;
|
||||
u8* m_DOL;
|
||||
|
||||
static const u8 ENTRY_SIZE = 0x0c;
|
||||
static const u8 FILE_ENTRY = 0;
|
||||
static const u8 DIRECTORY_ENTRY = 1;
|
||||
static const u64 DISKHEADER_ADDRESS = 0;
|
||||
static const u64 DISKHEADERINFO_ADDRESS = 0x440;
|
||||
static const u64 APPLOADER_ADDRESS = 0x2440;
|
||||
static const u32 MAX_NAME_LENGTH = 0x3df;
|
||||
u64 FST_ADDRESS;
|
||||
u64 DOL_ADDRESS;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue