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