Initial image building

This commit is contained in:
Jack Andersen 2016-01-19 17:17:24 -10:00
parent 151b2cf24a
commit 3a41af8a91
7 changed files with 62 additions and 28 deletions

View File

@ -20,22 +20,42 @@ public:
virtual ~DiscBase() {} virtual ~DiscBase() {}
struct Header struct Header
{ {
char gameID[6]; char m_gameID[6];
char discNum; char m_discNum;
char discVersion; char m_discVersion;
char audioStreaming; char m_audioStreaming;
char streamBufSz; char m_streamBufSz;
char unk[14]; char m_unk[14];
uint32_t wiiMagic; uint32_t m_wiiMagic;
uint32_t gcnMagic; uint32_t m_gcnMagic;
char gameTitle[64]; char m_gameTitle[64];
Header(IDiscIO& dio) Header(IDiscIO& dio)
{ {
std::unique_ptr<IDiscIO::IReadStream> s = dio.beginReadStream(0); std::unique_ptr<IDiscIO::IReadStream> s = dio.beginReadStream(0);
s->read(this, sizeof(*this)); s->read(this, sizeof(*this));
wiiMagic = SBig(wiiMagic); m_wiiMagic = SBig(m_wiiMagic);
gcnMagic = SBig(gcnMagic); m_gcnMagic = SBig(m_gcnMagic);
}
Header(const char gameID[6], const char* gameTitle, char discNum=0, char discVersion=0,
char audioStreaming=1, char streamBufSz=0)
{
memset(this, 0, sizeof(*this));
memcpy(m_gameID, gameID, 6);
strncpy(m_gameTitle, gameTitle, 64);
m_discNum = discNum;
m_discVersion = discVersion;
m_audioStreaming = audioStreaming;
m_streamBufSz = streamBufSz;
m_gcnMagic = 0xC2339F3D;
}
void write(IDiscIO::IWriteStream& ws) const
{
Header hs(*this);
hs.m_gcnMagic = SBig(hs.m_gcnMagic);
ws.write(&hs, sizeof(hs));
} }
}; };
@ -45,6 +65,14 @@ public:
uint32_t offset; uint32_t offset;
uint32_t length; uint32_t length;
public: public:
FSTNode(bool isDir, uint32_t nameOff, uint32_t off, uint32_t len)
{
typeAndNameOffset = nameOff & 0xffffff;
typeAndNameOffset |= isDir << 24;
typeAndNameOffset = SBig(typeAndNameOffset);
offset = SBig(off);
length = SBig(len);
}
inline bool isDir() const {return ((SBig(typeAndNameOffset) >> 24) != 0);} inline bool isDir() const {return ((SBig(typeAndNameOffset) >> 24) != 0);}
inline uint32_t getNameOffset() const {return SBig(typeAndNameOffset) & 0xffffff;} inline uint32_t getNameOffset() const {return SBig(typeAndNameOffset) & 0xffffff;}
inline uint32_t getOffset() const {return SBig(offset);} inline uint32_t getOffset() const {return SBig(offset);}
@ -229,7 +257,6 @@ public:
DiscBase(std::unique_ptr<IDiscIO>&& dio) DiscBase(std::unique_ptr<IDiscIO>&& dio)
: m_discIO(std::move(dio)), m_header(*m_discIO) {} : m_discIO(std::move(dio)), m_header(*m_discIO) {}
virtual bool commit()=0;
inline const Header& getHeader() const {return m_header;} inline const Header& getHeader() const {return m_header;}
inline const IDiscIO& getDiscIO() const {return *m_discIO;} inline const IDiscIO& getDiscIO() const {return *m_discIO;}
inline IPartition* getDataPartition() inline IPartition* getDataPartition()
@ -251,6 +278,8 @@ public:
for (std::unique_ptr<IPartition>& part : m_partitions) for (std::unique_ptr<IPartition>& part : m_partitions)
part->extractToDirectory(path, ctx); part->extractToDirectory(path, ctx);
} }
virtual bool packFromDirectory(const SystemChar* dataPath, const SystemChar* updatePath,
const SystemChar* outPath, const char gameID[6], const char* gameTitle, bool korean=false)=0;
}; };
using Partition = DiscBase::IPartition; using Partition = DiscBase::IPartition;

View File

@ -10,7 +10,9 @@ class DiscGCN : public DiscBase
{ {
public: public:
DiscGCN(std::unique_ptr<IDiscIO>&& dio); DiscGCN(std::unique_ptr<IDiscIO>&& dio);
bool commit(); bool packFromDirectory(const SystemChar* dataPath, const SystemChar* updatePath,
const SystemChar* outPath, const char gameID[6], const char* gameTitle,
bool korean=false);
}; };
} }

View File

@ -10,7 +10,9 @@ class DiscWii : public DiscBase
{ {
public: public:
DiscWii(std::unique_ptr<IDiscIO>&& dio); DiscWii(std::unique_ptr<IDiscIO>&& dio);
bool commit(); bool packFromDirectory(const SystemChar* dataPath, const SystemChar* updatePath,
const SystemChar* outPath, const char gameID[6], const char* gameTitle,
bool korean=false);
}; };
} }

View File

@ -9,7 +9,6 @@ add_library(NOD
DiscIOWBFS.cpp DiscIOWBFS.cpp
DiscWii.cpp DiscWii.cpp
FileIOFILE.cpp FileIOFILE.cpp
FileIOMEM.cpp
NOD.cpp NOD.cpp
${NOD_HEADERS}) ${NOD_HEADERS})
if(NOT WIN32) if(NOT WIN32)

View File

@ -109,8 +109,16 @@ DiscGCN::DiscGCN(std::unique_ptr<IDiscIO>&& dio)
m_partitions.emplace_back(new PartitionGCN(*this, IPartition::Kind::Data, 0)); m_partitions.emplace_back(new PartitionGCN(*this, IPartition::Kind::Data, 0));
} }
bool DiscGCN::commit() bool DiscGCN::packFromDirectory(const SystemChar* dataPath, const SystemChar* updatePath,
const SystemChar* outPath, const char gameID[6], const char* gameTitle,
bool korean)
{ {
std::unique_ptr<IDiscIO::IWriteStream> ws = m_discIO->beginWriteStream(0);
Header header(gameID, gameTitle);
header.write(*ws);
ws = m_discIO->beginWriteStream(0x420);
return false; return false;
} }

View File

@ -6,7 +6,6 @@
namespace NOD namespace NOD
{ {
/* Not much of a secret anymore I suppose */
static const uint8_t COMMON_KEYS[2][16] = static const uint8_t COMMON_KEYS[2][16] =
{ {
/* Normal */ /* Normal */
@ -391,8 +390,13 @@ DiscWii::DiscWii(std::unique_ptr<IDiscIO>&& dio)
} }
} }
bool DiscWii::commit() bool DiscWii::packFromDirectory(const SystemChar* dataPath, const SystemChar* updatePath,
const SystemChar* outPath, const char gameID[6], const char* gameTitle,
bool korean)
{ {
std::unique_ptr<IDiscIO::IWriteStream> s = m_discIO->beginWriteStream(0x420);
return false; return false;
} }

View File

@ -1,10 +0,0 @@
#include "NOD/IFileIO.hpp"
namespace NOD
{
class FileIOMEM : public IFileIO
{
};
}