added GDash source files prepared for game engine integration into R'n'D
[rocksndiamonds.git] / src / tape.h
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // tape.h
10 // ============================================================================
11
12 #ifndef TAPE_H
13 #define TAPE_H
14
15
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)
20
21 // values for tape properties
22 #define MAX_TAPE_LEN            (10000 * FRAMES_PER_SECOND) // max.time x fps
23
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)
28
29 #define MAX_TAPE_ACTIONS        (MAX_PLAYERS + 3)
30
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
35
36 #define TAPE_ACTIONS_DEFAULT            TAPE_USE_KEY_ACTIONS_ONLY
37
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)
48
49 // values for score tape basename length (date, time, name hash, no extension)
50 #define MAX_SCORE_TAPE_BASENAME_LEN     24
51
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
65
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)
89
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)
100
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)
112
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)
118
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
125
126
127 struct TapeButtonInfo
128 {
129   struct XY eject;
130   struct XY stop;
131   struct XY pause;
132   struct XY record;
133   struct XY play;
134   struct XY insert_solution;
135   struct XY play_solution;
136 };
137
138 struct TapeSymbolInfo
139 {
140   struct XY eject;
141   struct XY stop;
142   struct XY pause;
143   struct XY record;
144   struct XY play;
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;
150 };
151
152 struct TapeLabelInfo
153 {
154   struct XY eject;
155   struct XY stop;
156   struct XY pause;
157   struct XY record;
158   struct XY play;
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;
164   struct XY date;
165   struct XY time;
166 };
167
168 struct TapeTextInfo
169 {
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;
176
177   struct TextPosInfo time;
178   struct TextPosInfo time_hh;
179   struct TextPosInfo time_mm;
180   struct TextPosInfo time_ss;
181
182   struct TextPosInfo frame;
183 };
184
185 struct TapeInfo
186 {
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
190
191   char score_tape_basename[MAX_FILENAME_LEN + 1];
192   char level_identifier[MAX_FILENAME_LEN + 1];
193   int level_nr;
194   unsigned int random_seed;
195   unsigned int date;
196   unsigned int counter;
197   unsigned int length;
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;
206   boolean auto_play;
207   boolean auto_play_level_solved;
208   boolean auto_play_level_fixed;
209   boolean auto_play_level_not_fixable;
210   boolean quick_resume;
211   boolean single_step;
212   boolean changed;
213   boolean solved;
214   boolean player_participates[MAX_PLAYERS];
215   int num_participating_players;
216   int centered_player_nr_next;
217   boolean set_centered_player;
218
219   // flags to indicate which game actions are stored in this tape
220   boolean use_key_actions;
221   boolean use_mouse_actions;
222
223   // bits to indicate which tape properties are stored in this tape
224   byte property_bits;
225
226   // special game_engine_flags;
227   boolean bd_replay;
228
229   // visible playfield size when recording this tape (for team mode)
230   int scr_fieldx;
231   int scr_fieldy;
232
233   struct
234   {
235     byte action[MAX_TAPE_ACTIONS];
236     byte delay;
237   } pos[MAX_TAPE_LEN];
238
239   struct TapeButtonInfo button;
240   struct TapeSymbolInfo symbol;
241   struct TapeLabelInfo label;
242   struct TapeTextInfo text;
243
244   boolean show_game_buttons;    // show game buttons in tape viewport
245
246   boolean no_info_chunk;        // used to identify old tape file format
247   boolean no_valid_file;        // set when tape file missing or invalid
248 };
249
250
251 void DrawVideoDisplay(unsigned int, unsigned int);
252 void DrawCompleteVideoDisplay(void);
253
254 void TapeDeactivateDisplayOn(void);
255 void TapeDeactivateDisplayOff(boolean);
256
257 void TapeSetDateFromIsoDateString(char *);
258 void TapeSetDateFromEpochSeconds(time_t);
259 void TapeSetDateFromNow(void);
260
261 void TapeStartRecording(int);
262 void TapeHaltRecording(void);
263 void TapeStopRecording(void);
264 boolean TapeAddAction(byte[MAX_TAPE_ACTIONS]);
265 void TapeRecordAction(byte[MAX_TAPE_ACTIONS]);
266 void TapeTogglePause(boolean);
267 void TapeStartPlaying(void);
268 void TapeStopPlaying(void);
269 byte *TapePlayActionExt(boolean);
270 byte *TapePlayAction_BD(void);
271 byte *TapePlayAction(void);
272 void TapeStop(void);
273 void TapeStopGame(void);
274 void TapeStopTape(void);
275 void TapeErase(void);
276 unsigned int GetTapeLengthFrames(void);
277 unsigned int GetTapeLengthSeconds(void);
278 void TapeQuickSave(void);
279 void TapeQuickLoad(void);
280 void TapeRestartGame(void);
281 void TapeReplayAndPauseBeforeEnd(void);
282 boolean TapeIsPlaying_ReplayBD(void);
283
284 boolean hasSolutionTape(void);
285 boolean InsertSolutionTape(void);
286 boolean PlaySolutionTape(void);
287 boolean PlayScoreTape(int);
288
289 void UndoTape(void);
290 void FixTape_ForceSinglePlayer(void);
291
292 int AutoPlayTapes(void);
293 int AutoPlayTapesContinue(void);
294 void PatchTapes(void);
295
296 void CreateTapeButtons(void);
297 void FreeTapeButtons(void);
298 void MapTapeEjectButton(void);
299 void MapTapeWarpButton(void);
300 void MapTapeButtons(void);
301 void UnmapTapeButtons(void);
302 void RedrawTapeButtons(void);
303 void RedrawOrRemapTapeButtons(void);
304
305 void HandleTapeButtonKeys(Key);
306
307 #endif