-
Notifications
You must be signed in to change notification settings - Fork 0
/
intern.h
283 lines (244 loc) · 4.73 KB
/
intern.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/*
* REminiscence - Flashback interpreter
* Copyright (C) 2005-2019 Gregory Montoir (cyx@users.sourceforge.net)
*/
#ifndef INTERN_H__
#define INTERN_H__
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#undef ARRAYSIZE
#define ARRAYSIZE(a) (int)(sizeof(a)/sizeof(a[0]))
inline uint16_t READ_BE_UINT16(const void *ptr) {
const uint8_t *b = (const uint8_t *)ptr;
return (b[0] << 8) | b[1];
}
inline uint32_t READ_BE_UINT32(const void *ptr) {
const uint8_t *b = (const uint8_t *)ptr;
return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
}
inline uint16_t READ_LE_UINT16(const void *ptr) {
const uint8_t *b = (const uint8_t *)ptr;
return (b[1] << 8) | b[0];
}
inline uint32_t READ_LE_UINT32(const void *ptr) {
const uint8_t *b = (const uint8_t *)ptr;
return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];
}
inline int16_t ADDC_S16(int a, int b) {
a += b;
if (a < -32768) {
a = -32768;
} else if (a > 32767) {
a = 32767;
}
return a;
}
inline int16_t S8_to_S16(int a) {
if (a < -128) {
return -32768;
} else if (a > 127) {
return 32767;
} else {
const uint8_t u8 = (a ^ 0x80);
return ((u8 << 8) | u8) - 32768;
}
}
template<typename T>
inline void SWAP(T &a, T &b) {
T tmp = a;
a = b;
b = tmp;
}
template<typename T>
inline T CLIP(const T& val, const T& a, const T& b) {
if (val < a) {
return a;
} else if (val > b) {
return b;
}
return val;
}
#undef MIN
template<typename T>
inline T MIN(T v1, T v2) {
return (v1 < v2) ? v1 : v2;
}
#undef MAX
template<typename T>
inline T MAX(T v1, T v2) {
return (v1 > v2) ? v1 : v2;
}
#undef ABS
template<typename T>
inline T ABS(T t) {
return (t < 0) ? -t : t;
}
enum Language {
LANG_FR,
LANG_EN,
LANG_DE,
LANG_SP,
LANG_IT,
LANG_JP
};
enum ResourceType {
kResourceTypeAmiga,
kResourceTypeDOS
};
enum Skill {
kSkillEasy = 0,
kSkillNormal,
kSkillExpert
};
struct Options {
bool bypass_protection;
bool enable_password_menu;
bool enable_language_selection;
bool fade_out_palette;
bool use_tile_data;
bool use_text_cutscenes;
bool use_words_protection;
bool use_white_tshirt;
bool play_asc_cutscene;
bool play_caillou_cutscene;
bool play_metro_cutscene;
bool play_serrure_cutscene;
bool play_carte_cutscene;
bool play_gamesaved_sound;
};
struct Color {
uint8_t r;
uint8_t g;
uint8_t b;
};
struct Point {
int16_t x;
int16_t y;
};
struct Demo {
const char *name;
int level;
int room;
int x, y;
};
struct Level {
const char *name;
const char *name2;
const char *nameAmiga;
uint16_t cutscene_id;
uint8_t sound;
uint8_t track;
};
struct InitPGE {
uint16_t type;
int16_t pos_x;
int16_t pos_y;
uint16_t obj_node_number;
uint16_t life;
int16_t counter_values[4]; // messages
uint8_t object_type;
uint8_t init_room;
uint8_t room_location;
uint8_t init_flags;
uint8_t colliding_icon_num;
uint8_t icon_num;
uint8_t object_id;
uint8_t skill;
uint8_t mirror_x;
uint8_t flags;
uint8_t unk1C; // collidable, collision_data_len
uint16_t text_num;
};
struct LivePGE {
uint16_t obj_type;
int16_t pos_x;
int16_t pos_y;
uint8_t anim_seq;
uint8_t room_location;
int16_t life;
int16_t counter_value; // msg
uint8_t collision_slot;
uint8_t next_inventory_PGE;
uint8_t current_inventory_PGE;
uint8_t unkF; // unk_inventory_PGE
uint16_t anim_number;
uint8_t flags;
uint8_t index;
uint16_t first_obj_number;
LivePGE *next_PGE_in_room;
InitPGE *init_PGE;
};
struct GroupPGE {
GroupPGE *next_entry;
uint16_t index;
uint16_t group_id;
};
struct Object {
uint16_t type;
int8_t dx;
int8_t dy;
uint16_t init_obj_type;
uint8_t opcode2;
uint8_t opcode1;
uint8_t flags;
uint8_t opcode3;
uint16_t init_obj_number;
int16_t opcode_arg1;
int16_t opcode_arg2;
int16_t opcode_arg3;
};
struct ObjectNode {
uint16_t last_obj_number;
Object *objects;
uint16_t num_objects;
};
struct ObjectOpcodeArgs {
LivePGE *pge; // arg0
int16_t a; // arg2
int16_t b; // arg4
};
struct AnimBufferState {
int16_t x, y;
uint8_t w, h;
const uint8_t *dataPtr;
LivePGE *pge;
};
struct AnimBuffers {
AnimBufferState *_states[4];
uint8_t _curPos[4];
void addState(uint8_t stateNum, int16_t x, int16_t y, const uint8_t *dataPtr, LivePGE *pge, uint8_t w = 0, uint8_t h = 0);
};
struct CollisionSlot {
int16_t ct_pos;
CollisionSlot *prev_slot;
LivePGE *live_pge;
uint16_t index;
};
struct BankSlot {
uint16_t entryNum;
uint8_t *ptr;
};
struct CollisionSlot2 {
CollisionSlot2 *next_slot;
int8_t *unk2;
uint8_t data_size;
uint8_t data_buf[0x10]; // XXX check size
};
struct InventoryItem {
uint8_t icon_num;
InitPGE *init_pge;
LivePGE *live_pge;
};
struct SoundFx {
uint32_t offset;
uint16_t len;
uint16_t freq;
uint8_t *data;
int8_t peak;
};
extern Options g_options;
extern const char *g_caption;
#endif // INTERN_H__