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