+/*
+ * ObjectFile.h
+ *
+ * Created on: Sep 15, 2012
+ * Author: holy
+ */
+
+#ifndef LOADER_OBJECTFILE_H_
+#define LOADER_OBJECTFILE_H_
+
+#include <SDL.h>
+
+namespace loader {
+
+const int FORMAT_ID(1);
+
+struct ObjectFileHeader {
+ char ident[4];
+
+ int versionId;
+
+ int exportsBegin;
+ int exportsEnd;
+
+ int externalsBegin;
+ int externalsEnd;
+
+ int exportStringsBegin;
+ int exportStringsEnd;
+
+ int externalStringsBegin;
+ int externalStringsEnd;
+
+ int imagesBegin;
+ int imagesEnd;
+
+ int objectsBegin;
+ int objectsEnd;
+
+ ObjectFileHeader();
+};
+
+struct TypeOffset {
+ int typeId;
+ int begin;
+ int end;
+};
+
+struct Export {
+ int nameOffset;
+ int typeId;
+ int dataOffset;
+};
+
+struct External {
+ int nameOffset;
+ int referenceOffset;
+ int inlined;
+};
+
+struct ImageProperties {
+ Uint32 flags;
+ int width;
+ int height;
+ int depth;
+ int pitch;
+ Uint32 rmask;
+ Uint32 gmask;
+ Uint32 bmask;
+ Uint32 amask;
+};
+
+struct LoadedObjectFile {
+ char *allocPtr;
+ ObjectFileHeader *fileHeader;
+
+ TypeOffset *typeOffsetsBegin;
+ TypeOffset *typeOffsetsEnd;
+
+ Export *exportsBegin;
+ Export *exportsEnd;
+
+ External *externalsBegin;
+ External *externalsEnd;
+
+ char *exportStringsBegin;
+ char *exportStringsEnd;
+
+ char *externalStringsBegin;
+ char *externalStringsEnd;
+
+ char *imagesBegin;
+ char *imagesEnd;
+
+ char *objectsBegin;
+ char *objectsEnd;
+
+ SDL_Surface **surfaces;
+ int surfaceCount;
+
+ LoadedObjectFile();
+
+ char *At(int offset) { return reinterpret_cast<char *>(fileHeader) + offset; }
+};
+
+struct LoadedExport {
+ char *location;
+ int typeId;
+};
+
+}
+
+#endif /* LOADER_OBJECTFILE_H_ */