summaryrefslogtreecommitdiff
path: root/lyt
diff options
context:
space:
mode:
Diffstat (limited to 'lyt')
-rw-r--r--lyt/binaryfile.cpp5
-rw-r--r--lyt/binaryfilesection.cpp7
-rw-r--r--lyt/common.h6
-rw-r--r--lyt/directorypackage.cpp5
-rw-r--r--lyt/directorypackage.h1
-rw-r--r--lyt/materials/material.cpp10
-rw-r--r--lyt/materials/material.h6
7 files changed, 27 insertions, 13 deletions
diff --git a/lyt/binaryfile.cpp b/lyt/binaryfile.cpp
index 26ca8a0..b040bb6 100644
--- a/lyt/binaryfile.cpp
+++ b/lyt/binaryfile.cpp
@@ -28,14 +28,15 @@ LYTBinaryFile::LYTBinaryFile(QByteArray data) : magic(0), version(0) {
QDataStream reader(data);
InitDataStream(reader);
- quint16 endian, firstSectionOffset, sectionCount;
+ quint16 endian, firstSectionOffset;
+ quint32 sectionCount;
quint32 fileSize;
reader >> this->magic.value;
reader >> endian;
+ reader >> firstSectionOffset;
reader >> this->version.value;
reader >> fileSize;
- reader >> firstSectionOffset;
reader >> sectionCount;
LYTBinaryFileSection section;
diff --git a/lyt/binaryfilesection.cpp b/lyt/binaryfilesection.cpp
index 5115cda..98286cd 100644
--- a/lyt/binaryfilesection.cpp
+++ b/lyt/binaryfilesection.cpp
@@ -39,7 +39,12 @@ void LYTBinaryFileSection::writeToDataStream(QDataStream &out) const {
void LYTBinaryFileSection::readFromDataStream(QDataStream &in) {
quint32 length;
- in >> (quint32&)magic.value;
+ char a[4];
+ in.readRawData(a, 4);
+ magic.str[0] = a[3];
+ magic.str[1] = a[2];
+ magic.str[2] = a[1];
+ magic.str[3] = a[0];
in >> (quint32&)length;
char *raw = new char[length - 8];
diff --git a/lyt/common.h b/lyt/common.h
index a343c32..a79409a 100644
--- a/lyt/common.h
+++ b/lyt/common.h
@@ -30,10 +30,10 @@ union Magic {
};
union Version {
- char str[2];
- quint16 value;
+ char str[4];
+ quint32 value;
- Version(quint16 v) : value(v) { }
+ Version(quint32 v) : value(v) { }
};
diff --git a/lyt/directorypackage.cpp b/lyt/directorypackage.cpp
index 803cb80..2d1cb59 100644
--- a/lyt/directorypackage.cpp
+++ b/lyt/directorypackage.cpp
@@ -74,6 +74,11 @@ bool LYTDirectoryPackage::write(ItemType type, const QString &name, const QByteA
return false;
}
+bool LYTDirectoryPackage::rename(ItemType type, const QString &from, const QString &to) {
+ // Not implemented
+ return false;
+}
+
bool LYTDirectoryPackage::remove(ItemType type, const QString &name) {
QDir search(m_path);
diff --git a/lyt/directorypackage.h b/lyt/directorypackage.h
index 0d6ea19..3573cd6 100644
--- a/lyt/directorypackage.h
+++ b/lyt/directorypackage.h
@@ -34,6 +34,7 @@ public:
QStringList list(ItemType type) const;
QByteArray get(ItemType type, const QString &name) const;
bool write(ItemType type, const QString &name, const QByteArray &data);
+ bool rename(ItemType type, const QString &from, const QString &to);
bool remove(ItemType type, const QString &name);
bool needsExplicitSave() const { return false; }
diff --git a/lyt/materials/material.cpp b/lyt/materials/material.cpp
index a775553..877338d 100644
--- a/lyt/materials/material.cpp
+++ b/lyt/materials/material.cpp
@@ -94,7 +94,7 @@ void LYTMaterial::writeToDataStream(QDataStream &out) const {
WriteFixedLengthASCII(out, name, 0x14);
for (int i = 0; i < 3; i++)
- WriteS10Color(this->colours[i], out);
+ WriteRGBA8Color(this->colours[i], out);
for (int i = 0; i < 4; i++)
WriteRGBA8Color(this->tevKColour[i], out);
@@ -176,7 +176,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) {
name = ReadFixedLengthASCII(in, 0x14);
for (int i = 0; i < 3; i++)
- ReadS10Color(this->colours[i], in);
+ ReadRGBA8Color(this->colours[i], in);
for (int i = 0; i < 4; i++)
ReadRGBA8Color(this->tevKColour[i], in);
@@ -186,6 +186,8 @@ void LYTMaterial::readFromDataStream(QDataStream &in) {
in >> (quint32&)resNumValue;
LYTMaterialResourceNum resourceNum(resNumValue);
+ qDebug() << "[[ resNum : " << resNumValue << "]]";
+
// this is really complicated -_-
// first off: TexMap
texMaps.clear();
@@ -208,7 +210,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) {
this->readTexCoordGen(in);
}
- // ChanCtrl
+ /*// ChanCtrl
if (resourceNum.hasChanCtrl()) {
this->hasChanCtrl = true;
this->chanCtrl.readFromDataStream(in);
@@ -267,7 +269,7 @@ void LYTMaterial::readFromDataStream(QDataStream &in) {
this->blendMode.readFromDataStream(in);
} else {
this->hasBlendMode = false;
- }
+ }*/
}
diff --git a/lyt/materials/material.h b/lyt/materials/material.h
index a42a9d8..025b304 100644
--- a/lyt/materials/material.h
+++ b/lyt/materials/material.h
@@ -45,9 +45,9 @@ public:
quint32 value() const { return m_value; }
- int getTexMapNum() const { return BitExtract(m_value, 4, 28); }
- int getTexSRTNum() const { return BitExtract(m_value, 4, 24); }
- int getTexCoordGenNum() const { return BitExtract(m_value, 4, 20); }
+ int getTexMapNum() const { return BitExtract(m_value, 2, 30); }
+ int getTexSRTNum() const { return BitExtract(m_value, 2, 28); }
+ int getTexCoordGenNum() const { return BitExtract(m_value, 2, 26); }
bool hasChanCtrl() const { return BitExtract(m_value, 1, 6); }
bool hasMatCol() const { return BitExtract(m_value, 1, 4); }
bool hasTevSwapTable() const { return BitExtract(m_value, 1, 19); }