summaryrefslogtreecommitdiff
path: root/src/randtiles.h
blob: 03005b27b87c343b4fb9878e777ba5d682c86215 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef __NEWER_RANDTILES_H
#define __NEWER_RANDTILES_H

#include <common.h>

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;
		}
	};

	u32 magic;
	u32 sectionCount;
	u32 offsets[1]; // variable size

	Section *getSection(int id) {
		return (Section*)(((char*)this) + offsets[id]);
	}

	Section *getSection(char *name);
};

u32 djb2(u8 *str);


#endif