rnd-20100309-1-src
[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 #if 0
30 #define SP_SCREEN_BUFFER_XSIZE          (SCR_FIELDX + 2)
31 #define SP_SCREEN_BUFFER_YSIZE          (SCR_FIELDY + 2)
32 #endif
33
34 #define SP_FRAMES_PER_SECOND            35
35 #define SP_MAX_TAPE_LEN                 64010   /* (see "spfix63.doc") */
36
37
38 /* ------------------------------------------------------------------------- */
39 /* data structure definitions                                                */
40 /* ------------------------------------------------------------------------- */
41
42 #ifndef HAS_SpecialPortType
43 typedef struct
44 {
45 #if 1
46   short PortLocation; // = 2*(x+(y*60))         /* big endian format */
47 #else
48   int PortLocation; // = 2*(x+(y*60))
49 #endif
50   byte Gravity; // 1 = turn on, anything else (0) = turn off
51   byte FreezeZonks; // 2 = turn on, anything else (0) = turn off  (1=off!)
52   byte FreezeEnemies; // 1 = turn on, anything else (0) = turn off
53   byte UnUsed;
54 } SpecialPortType;
55 #define HAS_SpecialPortType
56 #endif
57
58 #ifndef HAS_LevelInfoType
59 typedef struct
60 {
61   byte UnUsed[4];
62   byte InitialGravity; // 1=on, anything else (0) = off
63   byte Version; // SpeedFixVersion XOR &H20
64   char LevelTitle[23];
65   byte InitialFreezeZonks; // 2=on, anything else (0) = off.  (1=off too!)
66   byte InfotronsNeeded;
67
68   // Number of Infotrons needed. 0 means that Supaplex will count the total
69   // amount of Infotrons in the level, and use the low byte of that number.
70   // (A multiple of 256 Infotrons will then result in 0-to-eat, etc.!)
71   byte SpecialPortCount; // Maximum 10 allowed!
72   SpecialPortType SpecialPort[10];
73   byte SpeedByte; // = Speed XOR Highbyte(RandomSeed)
74   byte CheckSumByte; // = CheckSum XOR SpeedByte
75 #if 1
76   short DemoRandomSeed;                         /* little endian format */
77 #else
78   int DemoRandomSeed;
79 #endif
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   int preceding_buffer_size;
101 };
102
103 struct DemoInfo_SP
104 {
105   boolean is_available;         /* structure contains valid demo */
106
107   int level_nr;                 /* number of corresponding level */
108
109   int length;                   /* number of demo entries */
110   byte data[SP_MAX_TAPE_LEN];   /* array of demo entries */
111 };
112
113 struct LevelInfo_SP
114 {
115   LevelInfoType header;
116   byte header_raw_bytes[SP_HEADER_SIZE];
117
118   int width, height;
119
120   byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
121
122   struct DemoInfo_SP demo;
123
124   /* used for runtime values */
125   struct GameInfo_SP *game_sp;
126 };
127
128 struct GraphicInfo_SP
129 {
130   Bitmap *bitmap;
131   int src_x, src_y;
132   int src_offset_x, src_offset_y;
133   int dst_offset_x, dst_offset_y;
134   int width, height;
135
136   Bitmap *crumbled_bitmap;
137   int crumbled_src_x, crumbled_src_y;
138   int crumbled_border_size;
139
140   boolean has_crumbled_graphics;
141   boolean preserve_background;
142
143   int unique_identifier;        /* used to identify needed screen updates */
144 };
145
146 struct EngineSnapshotInfo_SP
147 {
148   struct GameInfo_SP game_sp;
149
150   int PlayField16[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
151   byte PlayField8[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
152   byte DisPlayField[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
153
154   int AnimationPosTable[SP_MAX_PLAYFIELD_SIZE];
155   byte AnimationSubTable[SP_MAX_PLAYFIELD_SIZE];
156   byte TerminalState[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
157 };
158
159
160 /* ------------------------------------------------------------------------- */
161 /* exported functions                                                        */
162 /* ------------------------------------------------------------------------- */
163
164 extern struct GlobalInfo_SP global_sp_info;
165 extern struct GameInfo_SP game_sp;
166 extern struct LevelInfo_SP native_sp_level;
167 extern struct GraphicInfo_SP graphic_info_sp_object[TILE_MAX][8];
168 extern struct GraphicInfo_SP graphic_info_sp_player[MAX_PLAYERS][SPR_MAX][8];
169 extern struct EngineSnapshotInfo_SP engine_snapshot_sp;
170
171 extern void sp_open_all();
172 extern void sp_close_all();
173
174 extern void InitGameEngine_SP();
175 extern void GameActions_SP(byte *, boolean);
176
177 extern unsigned int InitEngineRandom_SP(long);
178
179 extern void setLevelInfoToDefaults_SP();
180 extern void copyInternalEngineVars_SP();
181 extern boolean LoadNativeLevel_SP(char *, int);
182 extern void SaveNativeLevel_SP(char *);
183
184 extern void BackToFront_SP(void);
185 extern void BlitScreenToBitmap_SP(Bitmap *);
186 extern void RedrawPlayfield_SP(boolean);
187 extern void DrawGameDoorValues_SP();
188
189 extern void LoadEngineSnapshotValues_SP();
190 extern void SaveEngineSnapshotValues_SP();
191
192 extern int map_key_RND_to_SP(int);
193 extern int map_key_SP_to_RND(int);
194
195 #endif  /* GAME_SP_EXPORT_H */