42d014206a75c0d43ae58e4060c17a84f536577f
[rocksndiamonds.git] / src / game_sp / export.h
1 #ifndef GAME_SP_EXPORT_H
2 #define GAME_SP_EXPORT_H
3
4 /* ========================================================================= */
5 /* functions and definitions exported from game_sp to main program           */
6 /* ========================================================================= */
7
8 /* ------------------------------------------------------------------------- */
9 /* constant definitions                                                      */
10 /* ------------------------------------------------------------------------- */
11
12 #define SP_MAX_PLAYFIELD_WIDTH          MAX_PLAYFIELD_WIDTH
13 #define SP_MAX_PLAYFIELD_HEIGHT         MAX_PLAYFIELD_HEIGHT
14
15 #define SP_NUM_LEVELS_PER_PACKAGE       111
16
17 #define SP_STD_PLAYFIELD_WIDTH          60
18 #define SP_STD_PLAYFIELD_HEIGHT         24
19 #define SP_LEVEL_NAME_LEN               23
20 #define SP_MAX_SPECIAL_PORTS            10
21
22 #define SP_HEADER_SIZE                  96
23 #define SP_STD_PLAYFIELD_SIZE           (SP_STD_PLAYFIELD_WIDTH *       \
24                                          SP_STD_PLAYFIELD_HEIGHT)
25 #define SP_MAX_PLAYFIELD_SIZE           (SP_MAX_PLAYFIELD_WIDTH *       \
26                                          SP_MAX_PLAYFIELD_HEIGHT)
27 #define SP_STD_LEVEL_SIZE               (SP_HEADER_SIZE + SP_STD_PLAYFIELD_SIZE)
28
29 #define SP_FRAMES_PER_SECOND            35
30 #define SP_MAX_TAPE_LEN                 64010   /* (see "spfix63.doc") */
31
32
33 /* sound actions */
34
35 #define actActive                       0
36 #define actImpact                       1
37 #define actExploding                    2
38 #define actDigging                      3
39 #define actSnapping                     4
40 #define actCollecting                   5
41 #define actPassing                      6
42 #define actPushing                      7
43 #define actDropping                     8
44
45
46 /* ------------------------------------------------------------------------- */
47 /* data structure definitions                                                */
48 /* ------------------------------------------------------------------------- */
49
50 #ifndef HAS_SpecialPortType
51 typedef struct
52 {
53   short PortLocation; // = 2*(x+(y*60))         /* big endian format */
54   byte Gravity; // 1 = turn on, anything else (0) = turn off
55   byte FreezeZonks; // 2 = turn on, anything else (0) = turn off  (1=off!)
56   byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off
57   byte UnUsed;
58 } SpecialPortType;
59 #define HAS_SpecialPortType
60 #endif
61
62 #ifndef HAS_LevelInfoType
63 typedef struct
64 {
65   byte UnUsed[4];
66   byte InitialGravity; // 1=on, anything else (0) = off
67   byte Version; // SpeedFixVersion XOR &H20
68   char LevelTitle[23];
69   byte InitialFreezeZonks; // 2=on, anything else (0) = off.  (1=off too!)
70   byte InfotronsNeeded;
71
72   // Number of Infotrons needed. 0 means that Supaplex will count the total
73   // amount of Infotrons in the level, and use the low byte of that number.
74   // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!)
75   byte SpecialPortCount; // Maximum 10 allowed!
76   SpecialPortType SpecialPort[10];
77   byte SpeedByte; // = Speed XOR Highbyte(RandomSeed)
78   byte CheckSumByte; // = CheckSum XOR SpeedByte
79   short DemoRandomSeed;                         /* little endian format */
80 } LevelInfoType;
81 #define HAS_LevelInfoType
82 #endif
83
84 struct GlobalInfo_SP
85 {
86 };
87
88 struct GameInfo_SP
89 {
90   boolean LevelSolved;
91   boolean GameOver;
92
93   /* needed for updating panel */
94   int time_played;
95   int infotrons_still_needed;
96   int red_disk_count;
97   int score;
98
99   /* needed for engine snapshots */
100   char **preceding_buffer;
101   int preceding_buffer_size;
102
103   int scroll_xoffset, scroll_yoffset;
104 };
105
106 struct DemoInfo_SP
107 {
108   boolean is_available;         /* structure contains valid demo */
109
110   int level_nr;                 /* number of corresponding level */
111
112   int length;                   /* number of demo entries */
113   byte data[SP_MAX_TAPE_LEN];   /* array of demo entries */
114 };
115
116 struct LevelInfo_SP
117 {
118   LevelInfoType header;
119   byte header_raw_bytes[SP_HEADER_SIZE];
120
121   int width, height;
122
123   byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
124
125   struct DemoInfo_SP demo;
126
127   /* used for runtime values */
128   struct GameInfo_SP *game_sp;
129 };
130
131 struct GraphicInfo_SP
132 {
133   Bitmap *bitmap;
134   int src_x, src_y;
135   int src_offset_x, src_offset_y;
136   int dst_offset_x, dst_offset_y;
137   int width, height;
138
139   Bitmap *crumbled_bitmap;
140   int crumbled_src_x, crumbled_src_y;
141   int crumbled_border_size;
142
143   boolean has_crumbled_graphics;
144   boolean preserve_background;
145
146   int unique_identifier;        /* used to identify needed screen updates */
147 };
148
149 struct EngineSnapshotInfo_SP
150 {
151   struct GameInfo_SP game_sp;
152
153   int PlayField16[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
154   byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
155   byte DisPlayField[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
156
157   int AnimationPosTable[SP_MAX_PLAYFIELD_SIZE];
158   byte AnimationSubTable[SP_MAX_PLAYFIELD_SIZE];
159   byte TerminalState[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
160 };
161
162
163 /* ------------------------------------------------------------------------- */
164 /* exported functions                                                        */
165 /* ------------------------------------------------------------------------- */
166
167 extern struct GlobalInfo_SP global_sp_info;
168 extern struct GameInfo_SP game_sp;
169 extern struct LevelInfo_SP native_sp_level;
170 extern struct GraphicInfo_SP graphic_info_sp_object[TILE_MAX][8];
171 extern struct GraphicInfo_SP graphic_info_sp_player[MAX_PLAYERS][SPR_MAX][8];
172 extern struct EngineSnapshotInfo_SP engine_snapshot_sp;
173
174 extern void sp_open_all();
175 extern void sp_close_all();
176
177 extern void InitPrecedingPlayfieldMemory();
178 extern void InitGfxBuffers_SP();
179
180 extern void InitGameEngine_SP();
181 extern void GameActions_SP(byte *, boolean);
182
183 extern unsigned int InitEngineRandom_SP(int);
184
185 extern void setLevelInfoToDefaults_SP();
186 extern void copyInternalEngineVars_SP();
187 extern boolean LoadNativeLevel_SP(char *, int, boolean);
188 extern void SaveNativeLevel_SP(char *);
189
190 extern void BackToFront_SP(void);
191 extern void BlitScreenToBitmap_SP(Bitmap *);
192 extern void RedrawPlayfield_SP(boolean);
193 extern void DrawGameDoorValues_SP();
194
195 extern void LoadEngineSnapshotValues_SP();
196 extern void SaveEngineSnapshotValues_SP();
197
198 extern int map_key_RND_to_SP(int);
199 extern int map_key_SP_to_RND(int);
200
201 extern int getRedDiskReleaseFlag_SP();
202
203 #endif  /* GAME_SP_EXPORT_H */