1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
16 // values for TapeTogglePause()
17 #define TAPE_TOGGLE_AUTOMATIC 0
18 #define TAPE_TOGGLE_MANUAL (1 << 0)
19 #define TAPE_TOGGLE_PLAY_PAUSE (1 << 1)
21 // values for tape properties
22 #define MAX_TAPE_LEN (10000 * FRAMES_PER_SECOND) // max.time x fps
24 // values for tape action array positions
25 #define TAPE_ACTION_LX (MAX_PLAYERS + 0)
26 #define TAPE_ACTION_LY (MAX_PLAYERS + 1)
27 #define TAPE_ACTION_BUTTON (MAX_PLAYERS + 2)
29 #define MAX_TAPE_ACTIONS (MAX_PLAYERS + 3)
31 // values for tape actions stored in tape file
32 #define TAPE_USE_KEY_ACTIONS_ONLY 0
33 #define TAPE_USE_MOUSE_ACTIONS_ONLY 1
34 #define TAPE_USE_KEY_AND_MOUSE_ACTIONS 2
36 #define TAPE_ACTIONS_DEFAULT TAPE_USE_KEY_ACTIONS_ONLY
38 // values for tape properties stored in tape file
39 #define TAPE_PROPERTY_NONE 0
40 #define TAPE_PROPERTY_EM_RANDOM_BUG (1 << 0)
41 #define TAPE_PROPERTY_GAME_SPEED (1 << 1)
42 #define TAPE_PROPERTY_PAUSE_MODE (1 << 2)
43 #define TAPE_PROPERTY_SINGLE_STEP (1 << 3)
44 #define TAPE_PROPERTY_SNAPSHOT (1 << 4)
45 #define TAPE_PROPERTY_REPLAYED (1 << 5)
46 #define TAPE_PROPERTY_TAS_KEYS (1 << 6)
47 #define TAPE_PROPERTY_SMALL_GRAPHICS (1 << 7)
49 // values for score tape basename length (date, time, name hash, no extension)
50 #define MAX_SCORE_TAPE_BASENAME_LEN 24
52 // some positions in the video tape control window
53 #define VIDEO_DISPLAY1_XPOS 5
54 #define VIDEO_DISPLAY1_YPOS 5
55 #define VIDEO_DISPLAY2_XPOS 5
56 #define VIDEO_DISPLAY2_YPOS 41
57 #define VIDEO_DISPLAY_XSIZE 90
58 #define VIDEO_DISPLAY_YSIZE 31
59 #define VIDEO_BUTTON_XSIZE 18
60 #define VIDEO_BUTTON_YSIZE 18
61 #define VIDEO_CONTROL_XPOS 5
62 #define VIDEO_CONTROL_YPOS 77
63 #define VIDEO_CONTROL_XSIZE VIDEO_DISPLAY_XSIZE
64 #define VIDEO_CONTROL_YSIZE VIDEO_BUTTON_YSIZE
66 // values for video tape control
67 #define VIDEO_STATE_PLAY_OFF (1 << 0)
68 #define VIDEO_STATE_PLAY_ON (1 << 1)
69 #define VIDEO_STATE_REC_OFF (1 << 2)
70 #define VIDEO_STATE_REC_ON (1 << 3)
71 #define VIDEO_STATE_PAUSE_OFF (1 << 4)
72 #define VIDEO_STATE_PAUSE_ON (1 << 5)
73 #define VIDEO_STATE_DATE_OFF (1 << 6)
74 #define VIDEO_STATE_DATE_ON (1 << 7)
75 #define VIDEO_STATE_TIME_OFF (1 << 8)
76 #define VIDEO_STATE_TIME_ON (1 << 9)
77 #define VIDEO_STATE_FRAME_OFF (1 << 10)
78 #define VIDEO_STATE_FRAME_ON (1 << 11)
79 #define VIDEO_STATE_FFWD_OFF (1 << 12)
80 #define VIDEO_STATE_FFWD_ON (1 << 13)
81 #define VIDEO_STATE_WARP_OFF (1 << 14)
82 #define VIDEO_STATE_WARP_ON (1 << 15)
83 #define VIDEO_STATE_WARP2_OFF (1 << 16)
84 #define VIDEO_STATE_WARP2_ON (1 << 17)
85 #define VIDEO_STATE_PBEND_OFF (1 << 18)
86 #define VIDEO_STATE_PBEND_ON (1 << 19)
87 #define VIDEO_STATE_1STEP_OFF (1 << 20)
88 #define VIDEO_STATE_1STEP_ON (1 << 21)
90 #define VIDEO_PRESS_PLAY_ON (1 << 22)
91 #define VIDEO_PRESS_PLAY_OFF (1 << 23)
92 #define VIDEO_PRESS_REC_ON (1 << 24)
93 #define VIDEO_PRESS_REC_OFF (1 << 25)
94 #define VIDEO_PRESS_PAUSE_ON (1 << 26)
95 #define VIDEO_PRESS_PAUSE_OFF (1 << 27)
96 #define VIDEO_PRESS_STOP_ON (1 << 28)
97 #define VIDEO_PRESS_STOP_OFF (1 << 29)
98 #define VIDEO_PRESS_EJECT_ON (1 << 30)
99 #define VIDEO_PRESS_EJECT_OFF (1 << 31)
101 #define VIDEO_STATE_PLAY(x) ((x) ? VIDEO_STATE_PLAY_ON : VIDEO_STATE_PLAY_OFF)
102 #define VIDEO_STATE_REC(x) ((x) ? VIDEO_STATE_REC_ON : VIDEO_STATE_REC_OFF)
103 #define VIDEO_STATE_PAUSE(x) ((x) ? VIDEO_STATE_PAUSE_ON: VIDEO_STATE_PAUSE_OFF)
104 #define VIDEO_STATE_DATE(x) ((x) ? VIDEO_STATE_DATE_ON : VIDEO_STATE_DATE_OFF)
105 #define VIDEO_STATE_TIME(x) ((x) ? VIDEO_STATE_TIME_ON : VIDEO_STATE_TIME_OFF)
106 #define VIDEO_STATE_FRAME(x) ((x) ? VIDEO_STATE_FRAME_ON: VIDEO_STATE_FRAME_OFF)
107 #define VIDEO_STATE_FFWD(x) ((x) ? VIDEO_STATE_FFWD_ON : VIDEO_STATE_FFWD_OFF)
108 #define VIDEO_STATE_WARP(x) ((x) ? VIDEO_STATE_WARP_ON : VIDEO_STATE_WARP_OFF)
109 #define VIDEO_STATE_WARP2(x) ((x) ? VIDEO_STATE_WARP2_ON: VIDEO_STATE_WARP2_OFF)
110 #define VIDEO_STATE_PBEND(x) ((x) ? VIDEO_STATE_PBEND_ON: VIDEO_STATE_PBEND_OFF)
111 #define VIDEO_STATE_1STEP(x) ((x) ? VIDEO_STATE_1STEP_ON: VIDEO_STATE_1STEP_OFF)
113 #define VIDEO_PRESS_PLAY(x) ((x) ? VIDEO_PRESS_PLAY_ON : VIDEO_PRESS_PLAY_OFF)
114 #define VIDEO_PRESS_REC(x) ((x) ? VIDEO_PRESS_REC_ON : VIDEO_PRESS_REC_OFF)
115 #define VIDEO_PRESS_PAUSE(x) ((x) ? VIDEO_PRESS_PAUSE_ON: VIDEO_PRESS_PAUSE_OFF)
116 #define VIDEO_PRESS_STOP(x) ((x) ? VIDEO_PRESS_STOP_ON : VIDEO_PRESS_STOP_OFF)
117 #define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF)
119 // tags to draw video display labels or symbols only
120 // (negative values to prevent misinterpretation in DrawVideoDisplay(), where
121 // the variable "value" is also used for tape length -- better fix this)
122 #define VIDEO_DISPLAY_DEFAULT 0
123 #define VIDEO_DISPLAY_LABEL_ONLY -1
124 #define VIDEO_DISPLAY_SYMBOL_ONLY -2
127 struct TapeButtonInfo
134 struct XY insert_solution;
135 struct XY play_solution;
138 struct TapeSymbolInfo
145 struct XY fast_forward;
146 struct XY warp_forward;
147 struct XY warp_forward_blind;
148 struct XY pause_before_end;
149 struct XY single_step;
159 struct XY fast_forward;
160 struct XY warp_forward;
161 struct XY warp_forward_blind;
162 struct XY pause_before_end;
163 struct XY single_step;
170 struct TextPosInfo date;
171 struct TextPosInfo date_yyyy;
172 struct TextPosInfo date_yy;
173 struct TextPosInfo date_mon;
174 struct TextPosInfo date_mm;
175 struct TextPosInfo date_dd;
177 struct TextPosInfo time;
178 struct TextPosInfo time_hh;
179 struct TextPosInfo time_mm;
180 struct TextPosInfo time_ss;
182 struct TextPosInfo frame;
187 int file_version; // file format version the tape is stored with
188 int game_version; // game release version the tape was created with
189 int engine_version; // game engine version the tape was recorded with
191 char score_tape_basename[MAX_FILENAME_LEN + 1];
192 char level_identifier[MAX_FILENAME_LEN + 1];
194 unsigned int random_seed;
196 unsigned int counter;
198 unsigned int length_frames;
199 unsigned int length_seconds;
200 unsigned int delay_played;
201 boolean pause_before_end;
202 boolean recording, playing, pausing;
203 boolean fast_forward;
204 boolean warp_forward;
205 boolean deactivate_display;
207 boolean auto_play_level_solved;
208 boolean auto_play_level_fixed;
209 boolean auto_play_level_not_fixable;
210 boolean quick_resume;
213 boolean player_participates[MAX_PLAYERS];
214 int num_participating_players;
215 int centered_player_nr_next;
216 boolean set_centered_player;
218 // flags to indicate which game actions are stored in this tape
219 boolean use_key_actions;
220 boolean use_mouse_actions;
222 // bits to indicate which tape properties are stored in this tape
225 // visible playfield size when recording this tape (for team mode)
231 byte action[MAX_TAPE_ACTIONS];
235 struct TapeButtonInfo button;
236 struct TapeSymbolInfo symbol;
237 struct TapeLabelInfo label;
238 struct TapeTextInfo text;
240 boolean show_game_buttons; // show game buttons in tape viewport
242 boolean no_info_chunk; // used to identify old tape file format
243 boolean no_valid_file; // set when tape file missing or invalid
247 void DrawVideoDisplay(unsigned int, unsigned int);
248 void DrawCompleteVideoDisplay(void);
250 void TapeDeactivateDisplayOn(void);
251 void TapeDeactivateDisplayOff(boolean);
253 void TapeSetDateFromEpochSeconds(time_t);
254 void TapeSetDateFromNow(void);
256 void TapeStartRecording(int);
257 void TapeHaltRecording(void);
258 void TapeStopRecording(void);
259 boolean TapeAddAction(byte *);
260 void TapeRecordAction(byte *);
261 void TapeTogglePause(boolean);
262 void TapeStartPlaying(void);
263 void TapeStopPlaying(void);
264 byte *TapePlayAction(void);
266 void TapeStopGame(void);
267 void TapeStopTape(void);
268 void TapeErase(void);
269 unsigned int GetTapeLengthFrames(void);
270 unsigned int GetTapeLengthSeconds(void);
271 void TapeQuickSave(void);
272 void TapeQuickLoad(void);
273 void TapeRestartGame(void);
274 void TapeReplayAndPauseBeforeEnd(void);
276 boolean hasSolutionTape(void);
277 boolean InsertSolutionTape(void);
278 boolean PlaySolutionTape(void);
279 boolean PlayScoreTape(int);
282 void FixTape_ForceSinglePlayer(void);
284 int AutoPlayTapes(void);
285 int AutoPlayTapesContinue(void);
286 void PatchTapes(void);
288 void CreateTapeButtons(void);
289 void FreeTapeButtons(void);
290 void MapTapeEjectButton(void);
291 void MapTapeWarpButton(void);
292 void MapTapeButtons(void);
293 void UnmapTapeButtons(void);
294 void RedrawTapeButtons(void);
295 void RedrawOrRemapTapeButtons(void);
297 void HandleTapeButtonKeys(Key);