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