fixed bug with closing doors when exiting from level editor
[rocksndiamonds.git] / src / game_em / export.h
1 #ifndef EXPORT_H
2 #define EXPORT_H
3
4 // ============================================================================
5 // functions and definitions exported from game_em to main program
6 // ============================================================================
7
8 #include "emerald.h"
9 #include "cave.h"
10
11
12 // ----------------------------------------------------------------------------
13 // constant definitions
14 // ----------------------------------------------------------------------------
15
16 #define EM_MAX_CAVE_WIDTH               CAVE_WIDTH
17 #define EM_MAX_CAVE_HEIGHT              CAVE_HEIGHT
18
19
20 // ----------------------------------------------------------------------------
21 // exported structures
22 // ----------------------------------------------------------------------------
23
24 struct GlobalInfo_EM
25 {
26   Bitmap *screenbuffer;
27 };
28
29 struct GameInfo_EM
30 {
31   unsigned int random;
32
33   boolean level_solved;
34   boolean game_over;
35
36   boolean any_player_moving;
37   boolean any_player_snapping;
38
39   int last_moving_player;
40   int last_player_direction[MAX_PLAYERS];
41
42   struct LOGIC *lev;
43   struct PLAYER *ply[MAX_PLAYERS];
44
45   // flags to handle bugs in and changes between different engine versions
46   boolean use_single_button;
47   boolean use_snap_key_bug;
48   boolean use_random_bug;
49   boolean use_old_explosions;
50   boolean use_old_android;
51   boolean use_old_push_elements;
52   boolean use_old_push_into_acid;
53   boolean use_wrap_around;
54   boolean use_push_delay;
55 };
56
57 struct LevelInfo_EM
58 {
59   int file_version;
60
61   struct CAVE *cav;
62 };
63
64 struct GraphicInfo_EM
65 {
66   Bitmap *bitmap;
67   int src_x, src_y;
68   int src_offset_x, src_offset_y;
69   int dst_offset_x, dst_offset_y;
70   int width, height;
71
72   Bitmap *crumbled_bitmap;
73   int crumbled_src_x, crumbled_src_y;
74   int crumbled_border_size;
75   int crumbled_tile_size;
76
77   boolean has_crumbled_graphics;
78   boolean preserve_background;
79
80   int unique_identifier;        /* used to identify needed screen updates */
81 };
82
83 struct EngineSnapshotInfo_EM
84 {
85   struct GameInfo_EM game_em;
86   struct LOGIC lev;
87   struct PLAYER ply[MAX_PLAYERS];
88
89   int frame;
90   int screen_x;
91   int screen_y;
92 };
93
94
95 // ----------------------------------------------------------------------------
96 // exported functions
97 // ----------------------------------------------------------------------------
98
99 extern struct GlobalInfo_EM global_em_info;
100 extern struct GameInfo_EM game_em;
101 extern struct LevelInfo_EM native_em_level;
102 extern struct GraphicInfo_EM graphic_info_em_object[GAME_TILE_MAX][8];
103 extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][PLY_MAX][8];
104 extern struct EngineSnapshotInfo_EM engine_snapshot_em;
105
106 void em_open_all(void);
107 void em_close_all(void);
108
109 void InitGfxBuffers_EM(void);
110
111 void InitGameEngine_EM(void);
112 void GameActions_EM(byte[MAX_PLAYERS]);
113
114 unsigned int InitEngineRandom_EM(int);
115
116 void setLevelInfoToDefaults_EM(void);
117 boolean LoadNativeLevel_EM(char *, boolean);
118
119 int getFieldbufferOffsetX_EM(void);
120 int getFieldbufferOffsetY_EM(void);
121
122 void BlitScreenToBitmap_EM(Bitmap *);
123 void RedrawPlayfield_EM(boolean);
124
125 void LoadEngineSnapshotValues_EM(void);
126 void SaveEngineSnapshotValues_EM(void);
127
128 boolean checkIfAllPlayersFitToScreen(void);
129
130 int map_em_element_C_to_X(int);
131 int map_em_element_X_to_C(int);
132
133 #endif  // EXPORT_H