1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2024 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
15 // ============================================================================
16 // functions and definitions exported from game_sp to main program
17 // ============================================================================
19 // ----------------------------------------------------------------------------
20 // constant definitions
21 // ----------------------------------------------------------------------------
23 #define SP_MAX_PLAYFIELD_WIDTH MAX_PLAYFIELD_WIDTH
24 #define SP_MAX_PLAYFIELD_HEIGHT MAX_PLAYFIELD_HEIGHT
26 #define SP_NUM_LEVELS_PER_PACKAGE 111
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
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)
40 #define SP_FRAMES_PER_SECOND 35
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")
52 #define actExploding 2
55 #define actCollecting 5
61 // ----------------------------------------------------------------------------
62 // data structure definitions
63 // ----------------------------------------------------------------------------
65 #ifndef HAS_SpecialPortType
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
74 #define HAS_SpecialPortType
77 #ifndef HAS_LevelInfoType
81 byte InitialGravity; // 1=on, anything else (0) = off
82 byte Version; // SpeedFixVersion XOR &H20
84 byte InitialFreezeZonks; // 2=on, anything else (0) = off. (1=off too!)
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
96 #define HAS_LevelInfoType
101 boolean level_solved;
104 // needed for updating panel
106 int infotrons_still_needed;
110 // needed for engine snapshots
111 char **preceding_buffer;
112 int preceding_buffer_size;
114 int scroll_xoffset, scroll_yoffset;
119 boolean is_available; // structure contains valid demo
121 int level_nr; // number of corresponding level
123 int length; // number of demo entries
124 byte data[SP_MAX_TAPE_LEN]; // array of demo entries
129 LevelInfoType header;
130 byte header_raw_bytes[SP_HEADER_SIZE];
134 byte playfield[SP_MAX_PLAYFIELD_WIDTH][SP_MAX_PLAYFIELD_HEIGHT];
136 struct DemoInfo_SP demo;
139 struct GraphicInfo_SP
143 int src_offset_x, src_offset_y;
144 int dst_offset_x, dst_offset_y;
147 Bitmap *crumbled_bitmap;
148 int crumbled_src_x, crumbled_src_y;
149 int crumbled_border_size;
151 boolean has_crumbled_graphics;
152 boolean preserve_background;
154 int unique_identifier; // used to identify needed screen updates
157 struct EngineSnapshotInfo_SP
159 struct GameInfo_SP game_sp;
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];
165 int AnimationPosTable[SP_MAX_PLAYFIELD_SIZE];
166 byte AnimationSubTable[SP_MAX_PLAYFIELD_SIZE];
167 byte TerminalState[SP_MAX_PLAYFIELD_SIZE + SP_HEADER_SIZE];
171 // ----------------------------------------------------------------------------
172 // exported functions
173 // ----------------------------------------------------------------------------
175 extern struct GameInfo_SP game_sp;
176 extern struct LevelInfo_SP native_sp_level;
177 extern struct EngineSnapshotInfo_SP engine_snapshot_sp;
179 void sp_open_all(void);
180 void sp_close_all(void);
182 void InitPrecedingPlayfieldMemory(void);
183 void InitGfxBuffers_SP(void);
185 void InitGameEngine_SP(void);
186 void GameActions_SP(byte[MAX_PLAYERS]);
188 unsigned int InitEngineRandom_SP(int);
190 void setLevelInfoToDefaults_SP(void);
191 void copyInternalEngineVars_SP(void);
192 boolean LoadNativeLevel_SP(char *, int, boolean);
193 boolean SaveNativeLevel_SP(char *);
195 int getFieldbufferOffsetX_SP(void);
196 int getFieldbufferOffsetY_SP(void);
198 void BlitScreenToBitmap_SP(Bitmap *);
199 void RedrawPlayfield_SP(boolean);
201 void LoadEngineSnapshotValues_SP(void);
202 void SaveEngineSnapshotValues_SP(ListNode **);
204 int map_key_RND_to_SP(int);
205 int map_key_SP_to_RND(int);
207 int getRedDiskReleaseFlag_SP(void);
209 #endif // EXPORT_SP_H