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