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