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