summaryrefslogtreecommitdiff
path: root/src/randtiles.h
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
committerTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
commit7d4e4c0b34a613dd3c0220475ae4e448197522c1 (patch)
tree4f5cee367de3fdef4f9a7c84af59ffe76a2bb1c3 /src/randtiles.h
downloadkamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.tar.gz
kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.zip
initial commit. now I can start playing with stuff!
Diffstat (limited to '')
-rw-r--r--src/randtiles.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/randtiles.h b/src/randtiles.h
new file mode 100644
index 0000000..ab2553d
--- /dev/null
+++ b/src/randtiles.h
@@ -0,0 +1,63 @@
+#ifndef __NEWER_RANDTILES_H
+#define __NEWER_RANDTILES_H
+
+#include <common.h>
+#include "fileload.h"
+
+#define RAND_CHECK_HORZ
+#define RAND_CHECK_VERT
+#define RAND_CHECK_BOTH
+
+struct RandTiles_Header {
+ u32 magic;
+ u32 sectionCount;
+};
+
+struct RandTiles_Section {
+ u32 nameHash;
+ u32 entryCount;
+};
+
+struct RandTiles_Entry {
+ u16 startTile;
+ u16 endTile;
+ u8 count;
+ u8 type;
+ u16 reserved;
+ u32 dataOffset;
+};
+
+inline u32 RandTiles_GetSectionCount(void *file) {
+ return ((RandTiles_Header*)file)->sectionCount;
+}
+
+inline u32 *RandTiles_GetOffsets(void *file) {
+ return (u32*)(((RandTiles_Header*)file)+1);
+}
+
+inline RandTiles_Section *RandTiles_GetSection(void *file, int id) {
+ u32 offs = RandTiles_GetOffsets(file)[id];
+ return (RandTiles_Section*)(((char*)file)+offs);
+};
+
+inline RandTiles_Entry *RandTiles_GetTiles(void *file, RandTiles_Section *section) {
+ return (RandTiles_Entry*)(section+1);
+}
+
+inline RandTiles_Entry *RandTiles_GetTiles(void *file, int sectionID) {
+ return (RandTiles_Entry*)(RandTiles_GetSection(file, sectionID)+1);
+}
+
+inline char *RandTiles_GetName(void *file, RandTiles_Section *section) {
+ return ((char*)file)+section->nameOffset;
+}
+
+inline u16 *RandTiles_GetData(void *file, RandTiles_Entry *entry) {
+ return (u16*)(((char*)file)+entry->dataOffset);
+}
+
+u32 djb2(u8 *str);
+RandTiles_Section *RandTiles_Search(void *file, u32 nameHash);
+
+
+#endif