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 (1u << 0)
68 #define VIDEO_STATE_PLAY_ON (1u << 1)
69 #define VIDEO_STATE_REC_OFF (1u << 2)
70 #define VIDEO_STATE_REC_ON (1u << 3)
71 #define VIDEO_STATE_PAUSE_OFF (1u << 4)
72 #define VIDEO_STATE_PAUSE_ON (1u << 5)
73 #define VIDEO_STATE_DATE_OFF (1u << 6)
74 #define VIDEO_STATE_DATE_ON (1u << 7)
75 #define VIDEO_STATE_TIME_OFF (1u << 8)
76 #define VIDEO_STATE_TIME_ON (1u << 9)
77 #define VIDEO_STATE_FRAME_OFF (1u << 10)
78 #define VIDEO_STATE_FRAME_ON (1u << 11)
79 #define VIDEO_STATE_FFWD_OFF (1u << 12)
80 #define VIDEO_STATE_FFWD_ON (1u << 13)
81 #define VIDEO_STATE_WARP_OFF (1u << 14)
82 #define VIDEO_STATE_WARP_ON (1u << 15)
83 #define VIDEO_STATE_WARP2_OFF (1u << 16)
84 #define VIDEO_STATE_WARP2_ON (1u << 17)
85 #define VIDEO_STATE_PBEND_OFF (1u << 18)
86 #define VIDEO_STATE_PBEND_ON (1u << 19)
87 #define VIDEO_STATE_1STEP_OFF (1u << 20)
88 #define VIDEO_STATE_1STEP_ON (1u << 21)
90 #define VIDEO_PRESS_PLAY_ON (1u << 22)
91 #define VIDEO_PRESS_PLAY_OFF (1u << 23)
92 #define VIDEO_PRESS_REC_ON (1u << 24)
93 #define VIDEO_PRESS_REC_OFF (1u << 25)
94 #define VIDEO_PRESS_PAUSE_ON (1u << 26)
95 #define VIDEO_PRESS_PAUSE_OFF (1u << 27)
96 #define VIDEO_PRESS_STOP_ON (1u << 28)
97 #define VIDEO_PRESS_STOP_OFF (1u << 29)
98 #define VIDEO_PRESS_EJECT_ON (1u << 30)
99 #define VIDEO_PRESS_EJECT_OFF (1u << 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;
214 boolean player_participates[MAX_PLAYERS];
215 int num_participating_players;
216 int centered_player_nr_next;
217 boolean set_centered_player;
219 // flags to indicate which game actions are stored in this tape
220 boolean use_key_actions;
221 boolean use_mouse_actions;
223 // bits to indicate which tape properties are stored in this tape
226 // visible playfield size when recording this tape (for team mode)
232 byte action[MAX_TAPE_ACTIONS];
236 struct TapeButtonInfo button;
237 struct TapeSymbolInfo symbol;
238 struct TapeLabelInfo label;
239 struct TapeTextInfo text;
241 boolean show_game_buttons; // show game buttons in tape viewport
243 boolean no_info_chunk; // used to identify old tape file format
244 boolean no_valid_file; // set when tape file missing or invalid
248 void DrawVideoDisplay(unsigned int, unsigned int);
249 void DrawCompleteVideoDisplay(void);
251 void TapeDeactivateDisplayOn(void);
252 void TapeDeactivateDisplayOff(boolean);
254 void TapeSetDateFromEpochSeconds(time_t);
255 void TapeSetDateFromNow(void);
257 void TapeStartRecording(int);
258 void TapeHaltRecording(void);
259 void TapeStopRecording(void);
260 boolean TapeAddAction(byte[MAX_TAPE_ACTIONS]);
261 void TapeRecordAction(byte[MAX_TAPE_ACTIONS]);
262 void TapeTogglePause(boolean);
263 void TapeStartPlaying(void);
264 void TapeStopPlaying(void);
265 byte *TapePlayAction(void);
267 void TapeStopGame(void);
268 void TapeStopTape(void);
269 void TapeErase(void);
270 unsigned int GetTapeLengthFrames(void);
271 unsigned int GetTapeLengthSeconds(void);
272 void TapeQuickSave(void);
273 void TapeQuickLoad(void);
274 void TapeRestartGame(void);
275 void TapeReplayAndPauseBeforeEnd(void);
277 boolean hasSolutionTape(void);
278 boolean InsertSolutionTape(void);
279 boolean PlaySolutionTape(void);
280 boolean PlayScoreTape(int);
283 void FixTape_ForceSinglePlayer(void);
285 int AutoPlayTapes(void);
286 int AutoPlayTapesContinue(void);
287 void PatchTapes(void);
289 void CreateTapeButtons(void);
290 void FreeTapeButtons(void);
291 void MapTapeEjectButton(void);
292 void MapTapeWarpButton(void);
293 void MapTapeButtons(void);
294 void UnmapTapeButtons(void);
295 void RedrawTapeButtons(void);
296 void RedrawOrRemapTapeButtons(void);
298 void HandleTapeButtonKeys(Key);