summaryrefslogtreecommitdiff
path: root/src/randtiles.h
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-07-25 03:16:21 +0200
committerTreeki <treeki@gmail.com>2011-07-25 03:16:21 +0200
commit4f6633db18e2213a151782d995486491c8db3ff7 (patch)
tree5b56f33b7214916b6988fb93dfa6cd000c7bf786 /src/randtiles.h
parent92a54fbb0c075d36da846b5d1b99b67cafc533eb (diff)
downloadkamek-4f6633db18e2213a151782d995486491c8db3ff7.tar.gz
kamek-4f6633db18e2213a151782d995486491c8db3ff7.zip
Random tiles added. Untested.
Diffstat (limited to '')
-rw-r--r--src/randtiles.h80
1 files changed, 33 insertions, 47 deletions
diff --git a/src/randtiles.h b/src/randtiles.h
index ab2553d..03005b2 100644
--- a/src/randtiles.h
+++ b/src/randtiles.h
@@ -2,62 +2,48 @@
#define __NEWER_RANDTILES_H
#include <common.h>
-#include "fileload.h"
-#define RAND_CHECK_HORZ
-#define RAND_CHECK_VERT
-#define RAND_CHECK_BOTH
+class RandomTileData {
+ enum Type {
+ CHECK_NONE = 0,
+ CHECK_HORZ = 1,
+ CHECK_VERT = 2,
+ CHECK_BOTH = 3
+ };
+
+ class Entry {
+ u8 startTile, endTile;
+ u8 count, type;
+ u32 dataOffset;
+
+ u8 *getData() {
+ return ((u8*)this) + dataOffset;
+ }
+ };
+
+ class Section {
+ u32 nameHash;
+ u32 nameOffset;
+ u32 entryCount;
+ Entry entries[1]; // variable size
+
+ const char *getName() {
+ return ((char*)this) + nameOffset;
+ }
+ };
-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;
-};
+ u32 offsets[1]; // variable size
-inline u32 RandTiles_GetSectionCount(void *file) {
- return ((RandTiles_Header*)file)->sectionCount;
-}
+ Section *getSection(int id) {
+ return (Section*)(((char*)this) + offsets[id]);
+ }
-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);
+ Section *getSection(char *name);
};
-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