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)
42 // values for score tape basename length (date, time, name hash, no extension)
43 #define MAX_SCORE_TAPE_BASENAME_LEN 24
45 // some positions in the video tape control window
46 #define VIDEO_DISPLAY1_XPOS 5
47 #define VIDEO_DISPLAY1_YPOS 5
48 #define VIDEO_DISPLAY2_XPOS 5
49 #define VIDEO_DISPLAY2_YPOS 41
50 #define VIDEO_DISPLAY_XSIZE 90
51 #define VIDEO_DISPLAY_YSIZE 31
52 #define VIDEO_BUTTON_XSIZE 18
53 #define VIDEO_BUTTON_YSIZE 18
54 #define VIDEO_CONTROL_XPOS 5
55 #define VIDEO_CONTROL_YPOS 77
56 #define VIDEO_CONTROL_XSIZE VIDEO_DISPLAY_XSIZE
57 #define VIDEO_CONTROL_YSIZE VIDEO_BUTTON_YSIZE
59 // values for video tape control
60 #define VIDEO_STATE_PLAY_OFF (1 << 0)
61 #define VIDEO_STATE_PLAY_ON (1 << 1)
62 #define VIDEO_STATE_REC_OFF (1 << 2)
63 #define VIDEO_STATE_REC_ON (1 << 3)
64 #define VIDEO_STATE_PAUSE_OFF (1 << 4)
65 #define VIDEO_STATE_PAUSE_ON (1 << 5)
66 #define VIDEO_STATE_DATE_OFF (1 << 6)
67 #define VIDEO_STATE_DATE_ON (1 << 7)
68 #define VIDEO_STATE_TIME_OFF (1 << 8)
69 #define VIDEO_STATE_TIME_ON (1 << 9)
70 #define VIDEO_STATE_FRAME_OFF (1 << 10)
71 #define VIDEO_STATE_FRAME_ON (1 << 11)
72 #define VIDEO_STATE_FFWD_OFF (1 << 12)
73 #define VIDEO_STATE_FFWD_ON (1 << 13)
74 #define VIDEO_STATE_WARP_OFF (1 << 14)
75 #define VIDEO_STATE_WARP_ON (1 << 15)
76 #define VIDEO_STATE_WARP2_OFF (1 << 16)
77 #define VIDEO_STATE_WARP2_ON (1 << 17)
78 #define VIDEO_STATE_PBEND_OFF (1 << 18)
79 #define VIDEO_STATE_PBEND_ON (1 << 19)
80 #define VIDEO_STATE_1STEP_OFF (1 << 20)
81 #define VIDEO_STATE_1STEP_ON (1 << 21)
83 #define VIDEO_PRESS_PLAY_ON (1 << 22)
84 #define VIDEO_PRESS_PLAY_OFF (1 << 23)
85 #define VIDEO_PRESS_REC_ON (1 << 24)
86 #define VIDEO_PRESS_REC_OFF (1 << 25)
87 #define VIDEO_PRESS_PAUSE_ON (1 << 26)
88 #define VIDEO_PRESS_PAUSE_OFF (1 << 27)
89 #define VIDEO_PRESS_STOP_ON (1 << 28)
90 #define VIDEO_PRESS_STOP_OFF (1 << 29)
91 #define VIDEO_PRESS_EJECT_ON (1 << 30)
92 #define VIDEO_PRESS_EJECT_OFF (1 << 31)
94 #define VIDEO_STATE_PLAY(x) ((x) ? VIDEO_STATE_PLAY_ON : VIDEO_STATE_PLAY_OFF)
95 #define VIDEO_STATE_REC(x) ((x) ? VIDEO_STATE_REC_ON : VIDEO_STATE_REC_OFF)
96 #define VIDEO_STATE_PAUSE(x) ((x) ? VIDEO_STATE_PAUSE_ON: VIDEO_STATE_PAUSE_OFF)
97 #define VIDEO_STATE_DATE(x) ((x) ? VIDEO_STATE_DATE_ON : VIDEO_STATE_DATE_OFF)
98 #define VIDEO_STATE_TIME(x) ((x) ? VIDEO_STATE_TIME_ON : VIDEO_STATE_TIME_OFF)
99 #define VIDEO_STATE_FRAME(x) ((x) ? VIDEO_STATE_FRAME_ON: VIDEO_STATE_FRAME_OFF)
100 #define VIDEO_STATE_FFWD(x) ((x) ? VIDEO_STATE_FFWD_ON : VIDEO_STATE_FFWD_OFF)
101 #define VIDEO_STATE_WARP(x) ((x) ? VIDEO_STATE_WARP_ON : VIDEO_STATE_WARP_OFF)
102 #define VIDEO_STATE_WARP2(x) ((x) ? VIDEO_STATE_WARP2_ON: VIDEO_STATE_WARP2_OFF)
103 #define VIDEO_STATE_PBEND(x) ((x) ? VIDEO_STATE_PBEND_ON: VIDEO_STATE_PBEND_OFF)
104 #define VIDEO_STATE_1STEP(x) ((x) ? VIDEO_STATE_1STEP_ON: VIDEO_STATE_1STEP_OFF)
106 #define VIDEO_PRESS_PLAY(x) ((x) ? VIDEO_PRESS_PLAY_ON : VIDEO_PRESS_PLAY_OFF)
107 #define VIDEO_PRESS_REC(x) ((x) ? VIDEO_PRESS_REC_ON : VIDEO_PRESS_REC_OFF)
108 #define VIDEO_PRESS_PAUSE(x) ((x) ? VIDEO_PRESS_PAUSE_ON: VIDEO_PRESS_PAUSE_OFF)
109 #define VIDEO_PRESS_STOP(x) ((x) ? VIDEO_PRESS_STOP_ON : VIDEO_PRESS_STOP_OFF)
110 #define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF)
112 // tags to draw video display labels or symbols only
113 // (negative values to prevent misinterpretation in DrawVideoDisplay(), where
114 // the variable "value" is also used for tape length -- better fix this)
115 #define VIDEO_DISPLAY_DEFAULT 0
116 #define VIDEO_DISPLAY_LABEL_ONLY -1
117 #define VIDEO_DISPLAY_SYMBOL_ONLY -2
120 struct TapeButtonInfo
127 struct XY insert_solution;
128 struct XY play_solution;
131 struct TapeSymbolInfo
138 struct XY fast_forward;
139 struct XY warp_forward;
140 struct XY warp_forward_blind;
141 struct XY pause_before_end;
142 struct XY single_step;
152 struct XY fast_forward;
153 struct XY warp_forward;
154 struct XY warp_forward_blind;
155 struct XY pause_before_end;
156 struct XY single_step;
163 struct TextPosInfo date;
164 struct TextPosInfo date_yyyy;
165 struct TextPosInfo date_yy;
166 struct TextPosInfo date_mon;
167 struct TextPosInfo date_mm;
168 struct TextPosInfo date_dd;
170 struct TextPosInfo time;
171 struct TextPosInfo time_hh;
172 struct TextPosInfo time_mm;
173 struct TextPosInfo time_ss;
175 struct TextPosInfo frame;
180 int file_version; // file format version the tape is stored with
181 int game_version; // game release version the tape was created with
182 int engine_version; // game engine version the tape was recorded with
184 char score_tape_basename[MAX_FILENAME_LEN + 1];
185 char level_identifier[MAX_FILENAME_LEN + 1];
187 unsigned int random_seed;
189 unsigned int counter;
191 unsigned int length_frames;
192 unsigned int length_seconds;
193 unsigned int delay_played;
194 boolean pause_before_end;
195 boolean recording, playing, pausing;
196 boolean fast_forward;
197 boolean warp_forward;
198 boolean deactivate_display;
200 boolean auto_play_level_solved;
201 boolean auto_play_level_fixed;
202 boolean auto_play_level_not_fixable;
203 boolean quick_resume;
206 boolean player_participates[MAX_PLAYERS];
207 int num_participating_players;
208 int centered_player_nr_next;
209 boolean set_centered_player;
211 // flags to indicate which game actions are stored in this tape
212 boolean use_key_actions;
213 boolean use_mouse_actions;
215 // bits to indicate which tape properties are stored in this tape
218 // visible playfield size when recording this tape (for team mode)
224 byte action[MAX_TAPE_ACTIONS];
228 struct TapeButtonInfo button;
229 struct TapeSymbolInfo symbol;
230 struct TapeLabelInfo label;
231 struct TapeTextInfo text;
233 boolean show_game_buttons; // show game buttons in tape viewport
235 boolean no_valid_file; // set when tape file missing or invalid
239 void DrawVideoDisplay(unsigned int, unsigned int);
240 void DrawCompleteVideoDisplay(void);
242 void TapeDeactivateDisplayOn(void);
243 void TapeDeactivateDisplayOff(boolean);
245 void TapeSetDateFromEpochSeconds(time_t);
246 void TapeSetDateFromNow(void);
248 void TapeStartRecording(int);
249 void TapeHaltRecording(void);
250 void TapeStopRecording(void);
251 boolean TapeAddAction(byte *);
252 void TapeRecordAction(byte *);
253 void TapeTogglePause(boolean);
254 void TapeStartPlaying(void);
255 void TapeStopPlaying(void);
256 byte *TapePlayAction(void);
258 void TapeErase(void);
259 unsigned int GetTapeLengthFrames(void);
260 unsigned int GetTapeLengthSeconds(void);
261 void TapeQuickSave(void);
262 void TapeQuickLoad(void);
264 boolean hasSolutionTape(void);
265 boolean InsertSolutionTape(void);
266 boolean PlaySolutionTape(void);
269 void FixTape_ForceSinglePlayer(void);
271 void AutoPlayTapes(void);
272 void PatchTapes(void);
274 void CreateTapeButtons(void);
275 void FreeTapeButtons(void);
276 void MapTapeEjectButton(void);
277 void MapTapeWarpButton(void);
278 void MapTapeButtons(void);
279 void UnmapTapeButtons(void);
280 void RedrawTapeButtons(void);
281 void RedrawOrRemapTapeButtons(void);
283 void HandleTapeButtonKeys(Key);