123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- #ifndef IFF_H
- #define IFF_H
- #include "System.h"
- #ifdef PATHS_IN_INCLUDES
- #include "ORANGE/File/file.h"
- #include "ORANGE/CDT/stack.h"
- #else
- #include "file.h"
- #include "stack.h"
- #endif // PATHS_IN_INCLUDES
- #define MAKE_IFF_FCC(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
- #define MAKE_RIFF_FCC(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a))
- #define MAX_FORMS 50
- typedef U32 FCC;
- class RIff : public RFile
- {
- public:
-
- RIff(void);
-
- ~RIff(void);
- public:
- typedef struct
- {
- FCC fccChunk;
- FCC fccForm;
- ULONG ulSize;
- long lDataPos;
- long lSizePos;
-
- } CHUNK, *PCHUNK;
- public:
-
-
-
-
-
-
-
- short Close(void);
-
- short GetChunk( // Returns 0 on success.
- char* pszFCC)
- {
-
- if (m_endian == LittleEndian)
- RiffFCC2Str(m_chunk.fccChunk, pszFCC);
- else
- IffFCC2Str(m_chunk.fccChunk, pszFCC);
- return (m_chunk.fccChunk == 0) ? 1 : 0;
- }
- ULONG GetChunk(void)
- { return m_chunk.fccChunk; }
-
- short GetForm( // Returns non-zero if no form.
- char* pszFCC)
- {
-
- if (m_endian == LittleEndian)
- RiffFCC2Str(m_chunk.fccForm, pszFCC);
- else
- IffFCC2Str(m_chunk.fccForm, pszFCC);
- return (m_chunk.fccForm == 0) ? 1 : 0;
- }
- ULONG GetForm(void)
- { return m_chunk.fccForm; }
- ULONG GetSize(void)
- { return m_chunk.ulSize; }
-
- long GetNextChunkPos( // Returns the position of the next to the
- // chunk specified below.
- CHUNK* pchunk)
- {
-
- if (pchunk->lSizePos == 0)
- return Tell();
- else
- return pchunk->lSizePos
- + sizeof(pchunk->ulSize)
- + pchunk->ulSize
- + ((pchunk->ulSize % 2) ? 1 : 0);
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- short Find(char* pszPath);
-
-
-
-
-
- short Next(void);
-
-
-
-
-
-
- short Descend(void);
-
-
-
-
- short Ascend(void);
-
-
-
-
-
-
-
-
-
- short CreateChunk(FCC fccChunk, FCC fccForm = 0);
-
-
-
- short EndChunk(FCC fccChunk = 0, FCC fccForm = 0);
- public:
-
-
- static ULONG IffStr2FCC(char* pszFCC)
- { return (pszFCC[0] << 24) | (pszFCC[1] << 16) | (pszFCC[2] << 8) | (pszFCC[3]); }
-
-
-
- static ULONG RiffStr2FCC(char* pszFCC)
- { return (pszFCC[3] << 24) | (pszFCC[2] << 16) | (pszFCC[1] << 8) | (pszFCC[0]); }
-
-
- static void IffFCC2Str( ULONG ulFCC, // FCC to convert.
- char* pszFCC)
- {
- pszFCC[0] = (char)(ulFCC >> 24);
- pszFCC[1] = (char)(ulFCC >> 16);
- pszFCC[2] = (char)(ulFCC >> 8);
- pszFCC[3] = (char)(ulFCC);
- pszFCC[4] = '\0';
- }
-
-
-
- static void RiffFCC2Str(ULONG ulFCC, // FCC to convert.
- char* pszFCC)
- {
- pszFCC[3] = (char)(ulFCC >> 24);
- pszFCC[2] = (char)(ulFCC >> 16);
- pszFCC[1] = (char)(ulFCC >> 8);
- pszFCC[0] = (char)(ulFCC);
- pszFCC[4] = '\0';
- }
-
- public:
- protected:
-
-
-
-
- short RelSeek(long lPos);
-
- void Init(void);
-
- short ReadChunkHeader(void);
-
- short IsForm( // Returns TRUE if fcc is a form; FALSE otherwise.
- FCC fcc);
- public:
- protected:
- RStack <PCHUNK> m_stack;
- CHUNK m_chunk;
- static FCC ms_afccIffForms[MAX_FORMS];
-
-
- static FCC ms_afccRiffForms[MAX_FORMS];
-
-
- };
- #endif // IFF_H
|