re-enabled storing selection from "last played level set" menu
[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
42 // some positions in the video tape control window
43 #define VIDEO_DISPLAY1_XPOS     5
44 #define VIDEO_DISPLAY1_YPOS     5
45 #define VIDEO_DISPLAY2_XPOS     5
46 #define VIDEO_DISPLAY2_YPOS     41
47 #define VIDEO_DISPLAY_XSIZE     90
48 #define VIDEO_DISPLAY_YSIZE     31
49 #define VIDEO_BUTTON_XSIZE      18
50 #define VIDEO_BUTTON_YSIZE      18
51 #define VIDEO_CONTROL_XPOS      5
52 #define VIDEO_CONTROL_YPOS      77
53 #define VIDEO_CONTROL_XSIZE     VIDEO_DISPLAY_XSIZE
54 #define VIDEO_CONTROL_YSIZE     VIDEO_BUTTON_YSIZE
55
56 // values for video tape control
57 #define VIDEO_STATE_PLAY_OFF    (1 << 0)
58 #define VIDEO_STATE_PLAY_ON     (1 << 1)
59 #define VIDEO_STATE_REC_OFF     (1 << 2)
60 #define VIDEO_STATE_REC_ON      (1 << 3)
61 #define VIDEO_STATE_PAUSE_OFF   (1 << 4)
62 #define VIDEO_STATE_PAUSE_ON    (1 << 5)
63 #define VIDEO_STATE_DATE_OFF    (1 << 6)
64 #define VIDEO_STATE_DATE_ON     (1 << 7)
65 #define VIDEO_STATE_TIME_OFF    (1 << 8)
66 #define VIDEO_STATE_TIME_ON     (1 << 9)
67 #define VIDEO_STATE_FRAME_OFF   (1 << 10)
68 #define VIDEO_STATE_FRAME_ON    (1 << 11)
69 #define VIDEO_STATE_FFWD_OFF    (1 << 12)
70 #define VIDEO_STATE_FFWD_ON     (1 << 13)
71 #define VIDEO_STATE_WARP_OFF    (1 << 14)
72 #define VIDEO_STATE_WARP_ON     (1 << 15)
73 #define VIDEO_STATE_WARP2_OFF   (1 << 16)
74 #define VIDEO_STATE_WARP2_ON    (1 << 17)
75 #define VIDEO_STATE_PBEND_OFF   (1 << 18)
76 #define VIDEO_STATE_PBEND_ON    (1 << 19)
77 #define VIDEO_STATE_1STEP_OFF   (1 << 20)
78 #define VIDEO_STATE_1STEP_ON    (1 << 21)
79
80 #define VIDEO_PRESS_PLAY_ON     (1 << 22)
81 #define VIDEO_PRESS_PLAY_OFF    (1 << 23)
82 #define VIDEO_PRESS_REC_ON      (1 << 24)
83 #define VIDEO_PRESS_REC_OFF     (1 << 25)
84 #define VIDEO_PRESS_PAUSE_ON    (1 << 26)
85 #define VIDEO_PRESS_PAUSE_OFF   (1 << 27)
86 #define VIDEO_PRESS_STOP_ON     (1 << 28)
87 #define VIDEO_PRESS_STOP_OFF    (1 << 29)
88 #define VIDEO_PRESS_EJECT_ON    (1 << 30)
89 #define VIDEO_PRESS_EJECT_OFF   (1 << 31)
90
91 #define VIDEO_STATE_PLAY(x)  ((x) ? VIDEO_STATE_PLAY_ON : VIDEO_STATE_PLAY_OFF)
92 #define VIDEO_STATE_REC(x)   ((x) ? VIDEO_STATE_REC_ON  : VIDEO_STATE_REC_OFF)
93 #define VIDEO_STATE_PAUSE(x) ((x) ? VIDEO_STATE_PAUSE_ON: VIDEO_STATE_PAUSE_OFF)
94 #define VIDEO_STATE_DATE(x)  ((x) ? VIDEO_STATE_DATE_ON : VIDEO_STATE_DATE_OFF)
95 #define VIDEO_STATE_TIME(x)  ((x) ? VIDEO_STATE_TIME_ON : VIDEO_STATE_TIME_OFF)
96 #define VIDEO_STATE_FRAME(x) ((x) ? VIDEO_STATE_FRAME_ON: VIDEO_STATE_FRAME_OFF)
97 #define VIDEO_STATE_FFWD(x)  ((x) ? VIDEO_STATE_FFWD_ON : VIDEO_STATE_FFWD_OFF)
98 #define VIDEO_STATE_WARP(x)  ((x) ? VIDEO_STATE_WARP_ON : VIDEO_STATE_WARP_OFF)
99 #define VIDEO_STATE_WARP2(x) ((x) ? VIDEO_STATE_WARP2_ON: VIDEO_STATE_WARP2_OFF)
100 #define VIDEO_STATE_PBEND(x) ((x) ? VIDEO_STATE_PBEND_ON: VIDEO_STATE_PBEND_OFF)
101 #define VIDEO_STATE_1STEP(x) ((x) ? VIDEO_STATE_1STEP_ON: VIDEO_STATE_1STEP_OFF)
102
103 #define VIDEO_PRESS_PLAY(x)  ((x) ? VIDEO_PRESS_PLAY_ON : VIDEO_PRESS_PLAY_OFF)
104 #define VIDEO_PRESS_REC(x)   ((x) ? VIDEO_PRESS_REC_ON  : VIDEO_PRESS_REC_OFF)
105 #define VIDEO_PRESS_PAUSE(x) ((x) ? VIDEO_PRESS_PAUSE_ON: VIDEO_PRESS_PAUSE_OFF)
106 #define VIDEO_PRESS_STOP(x)  ((x) ? VIDEO_PRESS_STOP_ON : VIDEO_PRESS_STOP_OFF)
107 #define VIDEO_PRESS_EJECT(x) ((x) ? VIDEO_PRESS_EJECT_ON: VIDEO_PRESS_EJECT_OFF)
108
109 // tags to draw video display labels or symbols only
110 // (negative values to prevent misinterpretation in DrawVideoDisplay(), where
111 // the variable "value" is also used for tape length -- better fix this)
112 #define VIDEO_DISPLAY_DEFAULT           0
113 #define VIDEO_DISPLAY_LABEL_ONLY        -1
114 #define VIDEO_DISPLAY_SYMBOL_ONLY       -2
115
116
117 struct TapeButtonInfo
118 {
119   struct XY eject;
120   struct XY stop;
121   struct XY pause;
122   struct XY record;
123   struct XY play;
124   struct XY insert_solution;
125   struct XY play_solution;
126 };
127
128 struct TapeSymbolInfo
129 {
130   struct XY eject;
131   struct XY stop;
132   struct XY pause;
133   struct XY record;
134   struct XY play;
135   struct XY fast_forward;
136   struct XY warp_forward;
137   struct XY warp_forward_blind;
138   struct XY pause_before_end;
139   struct XY single_step;
140 };
141
142 struct TapeLabelInfo
143 {
144   struct XY eject;
145   struct XY stop;
146   struct XY pause;
147   struct XY record;
148   struct XY play;
149   struct XY fast_forward;
150   struct XY warp_forward;
151   struct XY warp_forward_blind;
152   struct XY pause_before_end;
153   struct XY single_step;
154   struct XY date;
155   struct XY time;
156 };
157
158 struct TapeTextInfo
159 {
160   struct TextPosInfo date;
161   struct TextPosInfo date_yyyy;
162   struct TextPosInfo date_yy;
163   struct TextPosInfo date_mon;
164   struct TextPosInfo date_mm;
165   struct TextPosInfo date_dd;
166
167   struct TextPosInfo time;
168   struct TextPosInfo time_hh;
169   struct TextPosInfo time_mm;
170   struct TextPosInfo time_ss;
171
172   struct TextPosInfo frame;
173 };
174
175 struct TapeInfo
176 {
177   int file_version;     // file format version the tape is stored with
178   int game_version;     // game release version the tape was created with
179   int engine_version;   // game engine version the tape was recorded with
180
181   char level_identifier[MAX_FILENAME_LEN + 1];
182   int level_nr;
183   unsigned int random_seed;
184   unsigned int date;
185   unsigned int counter;
186   unsigned int length;
187   unsigned int length_frames;
188   unsigned int length_seconds;
189   unsigned int delay_played;
190   boolean pause_before_end;
191   boolean recording, playing, pausing;
192   boolean fast_forward;
193   boolean warp_forward;
194   boolean deactivate_display;
195   boolean auto_play;
196   boolean auto_play_level_solved;
197   boolean auto_play_level_fixed;
198   boolean auto_play_level_not_fixable;
199   boolean quick_resume;
200   boolean single_step;
201   boolean changed;
202   boolean player_participates[MAX_PLAYERS];
203   int num_participating_players;
204   int centered_player_nr_next;
205   boolean set_centered_player;
206
207   // flags to indicate which game actions are stored in this tape
208   boolean use_key_actions;
209   boolean use_mouse_actions;
210
211   // bits to indicate which tape properties are stored in this tape
212   byte property_bits;
213
214   // visible playfield size when recording this tape (for team mode)
215   int scr_fieldx;
216   int scr_fieldy;
217
218   struct
219   {
220     byte action[MAX_TAPE_ACTIONS];
221     byte delay;
222   } pos[MAX_TAPE_LEN];
223
224   struct TapeButtonInfo button;
225   struct TapeSymbolInfo symbol;
226   struct TapeLabelInfo label;
227   struct TapeTextInfo text;
228
229   boolean show_game_buttons;    // show game buttons in tape viewport
230
231   boolean no_valid_file;        // set when tape file missing or invalid
232 };
233
234
235 void DrawVideoDisplay(unsigned int, unsigned int);
236 void DrawCompleteVideoDisplay(void);
237
238 void TapeDeactivateDisplayOn(void);
239 void TapeDeactivateDisplayOff(boolean);
240
241 void TapeSetDateFromEpochSeconds(time_t);
242 void TapeSetDateFromNow(void);
243
244 void TapeStartRecording(int);
245 void TapeHaltRecording(void);
246 void TapeStopRecording(void);
247 boolean TapeAddAction(byte *);
248 void TapeRecordAction(byte *);
249 void TapeTogglePause(boolean);
250 void TapeStartPlaying(void);
251 void TapeStopPlaying(void);
252 byte *TapePlayAction(void);
253 void TapeStop(void);
254 void TapeErase(void);
255 unsigned int GetTapeLengthFrames(void);
256 unsigned int GetTapeLengthSeconds(void);
257 void TapeQuickSave(void);
258 void TapeQuickLoad(void);
259
260 boolean hasSolutionTape(void);
261 boolean InsertSolutionTape(void);
262 boolean PlaySolutionTape(void);
263
264 void UndoTape(void);
265 void FixTape_ForceSinglePlayer(void);
266
267 void AutoPlayTapes(void);
268 void PatchTapes(void);
269
270 void CreateTapeButtons(void);
271 void FreeTapeButtons(void);
272 void MapTapeEjectButton(void);
273 void MapTapeWarpButton(void);
274 void MapTapeButtons(void);
275 void UnmapTapeButtons(void);
276 void RedrawTapeButtons(void);
277 void RedrawOrRemapTapeButtons(void);
278
279 void HandleTapeButtonKeys(Key);
280
281 #endif