summaryrefslogtreecommitdiff
path: root/3dc/win95/iff_ILBM.hpp
diff options
context:
space:
mode:
authorRebellion Developments <rebellion@nomail>2000-03-16 11:25:00 +0100
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-19 05:45:17 +0200
commit218ca90543758a20ac326e444ca0643174ca7384 (patch)
tree16bfe3e5307f9f515489000f28728224291a0e3b /3dc/win95/iff_ILBM.hpp
Import Aliens vs Predator - Gold (Build 116)
Source code release, imported from: https://www.gamefront.com/games/aliens-vs-predator-3/file/avp-gold-complete-source-code All text files were converted to Unix format.
Diffstat (limited to '3dc/win95/iff_ILBM.hpp')
-rw-r--r--3dc/win95/iff_ILBM.hpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/3dc/win95/iff_ILBM.hpp b/3dc/win95/iff_ILBM.hpp
new file mode 100644
index 0000000..8a83b38
--- /dev/null
+++ b/3dc/win95/iff_ILBM.hpp
@@ -0,0 +1,164 @@
+#ifndef _INCLUDED_IFF_ILBM_HPP_
+#define _INCLUDED_IFF_ILBM_HPP_
+
+#include "iff.hpp"
+
+namespace IFF
+{
+ class IlbmBmhdChunk : public Chunk
+ {
+ public:
+ UINT16 width;
+ UINT16 height;
+ UINT16 xTopLeft;
+ UINT16 yTopLeft;
+ UBYTE nBitPlanes;
+ enum
+ {
+ MASK_NONE = 0,
+ MASK_HASMASK = 1,
+ MASK_TRANSPARENTCOL = 2,
+ MASK_LASSO = 3
+ };
+ UBYTE eMasking;
+ enum
+ {
+ COMPRESS_NONE = 0,
+ COMPRESS_RUNLENGTH = 1,
+ COMPRESS_S3TC =2 //will have s3tc chunk instead of body chunk
+ };
+ UBYTE eCompression;
+ UBYTE flags;
+ UINT16 iTranspCol;
+ UBYTE xAspectRatio;
+ UBYTE yAspectRatio;
+ UINT16 xMax;
+ UINT16 yMax;
+
+ IlbmBmhdChunk() { m_idCk = "BMHD"; }
+
+ protected:
+ virtual void Serialize(Archive * pArchv);
+ };
+
+ class IlbmCmapChunk : public Chunk
+ {
+ public:
+ unsigned nEntries;
+ RGBTriple * pTable;
+
+ void CreateNew(unsigned nSize);
+
+ IlbmCmapChunk() : pTable(NULL) { m_idCk = "CMAP"; }
+ virtual ~IlbmCmapChunk();
+
+ protected:
+ virtual void Serialize(Archive * pArchv);
+ };
+
+ inline void IlbmCmapChunk::CreateNew(unsigned nSize)
+ {
+ if (pTable) delete[] pTable;
+ pTable = new RGBTriple [nSize];
+ nEntries = nSize;
+ }
+
+ class IlbmBodyChunk : public Chunk
+ {
+ public:
+ IlbmBodyChunk() : pData(NULL), pDecodeDst(NULL)
+ #ifndef IFF_READ_ONLY
+ , pEncodeDst(NULL), pEncodeSrc(NULL)
+ #endif
+ { m_idCk = "BODY"; }
+ virtual ~IlbmBodyChunk();
+
+ #ifndef IFF_READ_ONLY
+ bool BeginEncode();
+ bool EncodeFirstRow(unsigned const * pRow);
+ bool EncodeNextRow(unsigned const * pRow);
+ bool EndEncode();
+
+ float GetCompressionRatio() const;
+ #endif
+
+ bool BeginDecode() const;
+ unsigned const * DecodeFirstRow() const;
+ unsigned const * DecodeNextRow() const;
+ bool EndDecode() const;
+
+ protected:
+ virtual void Serialize(Archive * pArchv);
+
+ virtual bool GetHeaderInfo() const; // fills in these three data members
+ mutable unsigned nWidth;
+ mutable unsigned eCompression;
+ mutable unsigned nBitPlanes;
+
+ private:
+ unsigned nSize;
+ UBYTE * pData;
+
+ mutable UBYTE const * pDecodeSrc;
+ mutable unsigned nRemaining;
+ mutable unsigned * pDecodeDst;
+
+ #ifndef IFF_READ_ONLY
+ DataBlock * pEncodeDst;
+ UBYTE * pEncodeSrc;
+
+ unsigned nSizeNonCprss;
+ unsigned nSizeCprss;
+ #endif
+ };
+
+ #ifndef IFF_READ_ONLY
+ inline bool IlbmBodyChunk::EncodeFirstRow(unsigned const * pRow)
+ {
+ if (BeginEncode())
+ return EncodeNextRow(pRow);
+ else
+ return false;
+ }
+
+ inline float IlbmBodyChunk::GetCompressionRatio() const
+ {
+ if (!nSizeNonCprss) return 0.0F;
+
+ return (static_cast<float>(nSizeNonCprss)-static_cast<float>(nSizeCprss))/static_cast<float>(nSizeNonCprss);
+ }
+ #endif
+
+ inline unsigned const * IlbmBodyChunk::DecodeFirstRow() const
+ {
+ if (BeginDecode())
+ return DecodeNextRow();
+ else
+ return NULL;
+ }
+
+ inline bool IlbmBodyChunk::EndDecode() const
+ {
+ if (pDecodeDst)
+ {
+ delete[] pDecodeDst;
+ pDecodeDst = NULL;
+ return true;
+ }
+ else return false;
+ }
+
+ class IlbmGrabChunk : public Chunk
+ {
+ public:
+ UINT16 xHotSpot;
+ UINT16 yHotSpot;
+
+ IlbmGrabChunk() { m_idCk = "GRAB"; }
+
+ protected:
+ virtual void Serialize(Archive * pArchv);
+ };
+}
+
+#endif // ! _INCLUDED_IFF_ILBM_HPP_