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