forked from cyxx/f2bgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresource.h
130 lines (115 loc) · 3.09 KB
/
resource.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Fade To Black engine rewrite
* Copyright (C) 2006-2012 Gregory Montoir ([email protected])
*/
#ifndef RESOURCE_H__
#define RESOURCE_H__
#include "util.h"
enum {
kResType_SPR,
kResType_PAL,
kResType_MAP,
kResType_ANI,
kResType_STM,
kResType_OBJ,
kResType_SND,
kResType_F3D,
kResType_P3D,
kResTypeCount
};
enum {
kKeyPathsTableSize = 400,
kEnvAniDataSize = 38,
kIniMaxLineLength = 256,
kLevelDescriptionsCount = 13,
kSoundKeyPathsTableSize = 10,
kMusicKeyPathsTableSize = 52,
kKeyPathNameLength = 96,
kLevelMusicTableSize = 14
};
struct ResTreeNode {
int16_t childKey;
int16_t nextKey;
uint8_t *data;
uint32_t dataSize;
uint32_t dataOffset;
};
struct ResObjectIndex {
char objectName[64];
int16_t objectKey;
uint32_t dataOffs;
};
struct ResKeyPath {
char pathName[kKeyPathNameLength];
int16_t key;
};
struct ResLevelDescription {
char name[16];
char palKey[kKeyPathNameLength];
char mapKey[kKeyPathNameLength];
bool inventory;
bool map;
int16_t musicKeys[kLevelMusicTableSize];
};
struct ResMessageDescription {
const uint8_t *data;
int16_t frameSync;
int16_t duration;
int16_t xPos, yPos;
int font;
};
struct ResDemoInput {
int ticks;
uint16_t key;
bool pressed;
};
struct Resource {
ResTreeNode *_treesTable[kResTypeCount];
uint16_t _treesTableCount[kResTypeCount];
uint16_t _msgOffsetsTableCount;
uint16_t *_msgOffsetsTable;
uint8_t *_msgData;
uint32_t _cmdOffsetsTableCount;
uint32_t *_cmdOffsetsTable;
uint8_t *_cmdData;
uint32_t _objectIndexesTableCount;
ResObjectIndex *_objectIndexesTable;
uint32_t _objectTextDataSize;
uint8_t *_objectTextData;
uint16_t _keyPathsTableCount;
ResKeyPath _keyPathsTable[kKeyPathsTableSize];
uint32_t _envAniDataCount;
uint8_t *_envAniData;
ResLevelDescription _levelDescriptionsTable[kLevelDescriptionsCount];
char _soundKeyPathsTable[kSoundKeyPathsTableSize][kKeyPathNameLength];
int16_t _sndKeysTable[kSoundKeyPathsTableSize];
char _musicKeyPathsTable[kMusicKeyPathsTableSize][kKeyPathNameLength];
int _demoInputDataSize;
ResDemoInput *_demoInputData;
Resource();
~Resource();
void loadLevelData(const char *levelName, int levelNum);
void unload(int type, int16_t key);
int16_t getPrevious(int type, int16_t key);
int16_t getNext(int type, int16_t key);
int16_t getChild(int type, int16_t key);
int16_t getRoot(int type);
uint8_t *getEnvAni(int16_t key, int num);
uint8_t *getData(int type, int16_t key, const char *name);
void setObjectKey(const char *objectName, int16_t objectKey);
int getOffsetForObjectKey(int16_t objectKey);
int16_t getKeyFromPath(const char *path);
const uint8_t *getCmdData(int num);
const uint8_t *getMsgData(int num);
bool getMessageDescription(ResMessageDescription *m, uint32_t value, uint32_t offset);
void loadINI(FILE *fp, int dataSize);
void loadCMD(FILE *fp, int dataSize);
void loadMSG(FILE *fp, int dataSize);
void loadENV(FILE *fp, int dataSize);
void loadKeyPaths(FILE *fp, int dataSize);
void loadObjectIndexes(FILE *fp, int dataSize);
void loadObjectText(FILE *fp, int dataSize);
void loadTrigo();
void loadDEM(FILE *fp, int dataSize);
};
#endif // RESOURCE_H__