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