diff options
author | Treeki <treeki@gmail.com> | 2010-10-09 01:00:16 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2010-10-09 01:00:16 +0200 |
commit | 7213ca723a65dff8ebb0c6c08669695217e60453 (patch) | |
tree | 1003cdfc9dd8fa21f2521c2e22071f391c555c78 /lyt/common.h | |
parent | c2cd2300ab03a41999b8e4e38cf0d29abb786918 (diff) | |
download | LayoutStudio-7213ca723a65dff8ebb0c6c08669695217e60453.tar.gz LayoutStudio-7213ca723a65dff8ebb0c6c08669695217e60453.zip |
material bugfixes, plus the beginning of U8 archive code, and a nice little API for handling archive filesystems
Diffstat (limited to 'lyt/common.h')
-rw-r--r-- | lyt/common.h | 97 |
1 files changed, 2 insertions, 95 deletions
diff --git a/lyt/common.h b/lyt/common.h index c75813b..9c39339 100644 --- a/lyt/common.h +++ b/lyt/common.h @@ -19,13 +19,8 @@ #define LYTCOMMON_H #include <QtGlobal> -#include <QtCore/QByteArray> -#include <QtGui/QColor> -#include <QtCore/QPointF> -#include <QtCore/QDataStream> -#include <QtCore/QStringList> -#include <QtCore/QDebug> -#include <QtCore/QVector> + +#include "../wii/common.h" union Magic { char str[4]; @@ -39,97 +34,9 @@ union Version { -inline quint32 BitExtract(quint32 value, int count, int start) { - // this function relies on heavy compiler optimisation to be efficient :p - quint32 mask = 0; - for (int i = start; i < start+count; i++) { - mask |= (0x80000000 >> i); - } - - return (value & mask) >> (32 - (start + count)); -} - -inline quint32 BitInsert(quint32 value, int newValue, int count, int start) { - quint32 mask = 0; - for (int i = start; i < start+count; i++) { - mask |= (0x80000000 >> i); - } - - value &= ~mask; - value |= (newValue << (32 - (start + count))) & mask; - return value; -} - - - - - -QByteArray PadByteArray(QByteArray original, int newLength, char padWith='\0'); - -inline quint32 ColorToRGBA(QColor col) { - return (col.red() << 24) | (col.green() << 16) | (col.blue() << 8) | (col.alpha()); -} - -inline QColor RGBAToColor(quint32 col) { - return QColor(col >> 24, (col >> 16) & 0xFF, (col >> 8) & 0xFF, col & 0xFF); -} - -inline void ReadRGBA8Color(QColor &out, QDataStream &in) { - quint32 col; - in >> (quint32&)col; - out = RGBAToColor(col); -} - -inline void WriteRGBA8Color(QColor &in, QDataStream &out) { - out << (quint32)ColorToRGBA(in); -} - -inline void ReadS10Color(QColor &out, QDataStream &in) { - quint16 r, g, b, a; - in >> (quint16&)r; - in >> (quint16&)g; - in >> (quint16&)b; - in >> (quint16&)a; - out.setRgb(r, g, b, a); -} - -inline void WriteS10Color(QColor &in, QDataStream &out) { - out << (quint16)in.red(); - out << (quint16)in.green(); - out << (quint16)in.blue(); - out << (quint16)in.alpha(); -} - - - - struct LYTTexCoords { QPointF coord[4]; }; -inline void ReadPointF(QDataStream &stream, QPointF &point) { - float x, y; - stream >> x; - stream >> y; - point.setX(x); - point.setY(y); -} - -inline void WritePointF(QDataStream &stream, const QPointF &point) { - stream << (float)point.x(); - stream << (float)point.y(); -} - -inline void InitDataStream(QDataStream &stream) { - stream.setByteOrder(QDataStream::BigEndian); - stream.setVersion(QDataStream::Qt_4_5); -} - -QStringList ReadStringList(QDataStream &in); - -QString ReadFixedLengthASCII(QDataStream &in, int length); -void WriteFixedLengthASCII(QDataStream &out, QString str, int length); - - #endif // LYTCOMMON_H |