ScummVM API documentation
sequence.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef HOLLYWOOD_RUNAWAY_SEQUENCE_H
23#define HOLLYWOOD_RUNAWAY_SEQUENCE_H
24
25#include "common/random.h"
26#include "engines/engine.h"
27#include "hollywood/resource.h"
28#include "hollywood/runaway/audio.h"
29#include "hollywood/runaway/graphics.h"
30#include "hollywood/runaway/speech.h"
31#include "hollywood/runaway/video.h"
32#include "hollywood/scene_text_store.h"
33
34namespace Hollywood {
35
36// Retail films interleave movie ranges, separately stored talking portraits,
37// and speech/effects. The scene supplies the original sequence of cues.
39public:
40 enum Operation {
41 kOpen, // Movie number; optional file suffix (defaults to .001).
42 kPlay, // First/last frame, Playback mode.
43 kStill, // Frame; second argument selects the separate GOG stills movie.
44 kImage, // A 1024x600 image from RESOURCE.000.
45 kTalk, // Cue, variation, portrait chunk + 1 (0 = movie still), offscreen speaker.
46 kSpeech, // Cue, first/last variation, global cue; continues alongside the movie.
47 kWaitSpeech, // Optional portrait and offscreen speaker, as in kTalk.
48 kWaitInput,
49 kMusic, // Cue, volume, loop.
50 kMusicVolume, // Change volume without restarting the current music.
51 kEffect, // Cue, volume, channel, loop.
52 kWaitEffect, // Maximum wait in milliseconds (channel 0); second argument blanks the screen.
53 kStopEffects, // Optional channel + 1; zero stops all effects.
54 kDelay, // Milliseconds.
55 kEnd
56 };
57 enum Playback { kOnce, kLoopDuringSpeech, kIdleDuringSpeech, kUntilSpeechEnds };
58 struct Command {
59 constexpr Command(Operation op, uint16 first = 0, uint16 second = 0, byte third = 0, byte fourth = 0) :
60 operation(op), a(first), b(second), c(third), d(fourth) {}
61 Operation operation;
62 uint16 a, b;
63 byte c, d;
64 };
65 explicit RunawaySequence(RunawayAudio &audio) : _audio(audio), _random("runawaySequence"), _speech(audio, _random) {}
66 void start(const Command *commands, const SceneTextStore &text, uint32 now, char chapter = 'B', bool keepEffects = false);
67 void setBackground(const Graphics::ManagedSurface &background, const Common::Rect &destination);
68 void update(uint32 now);
69 void skip();
70 void skipSpeech();
71 void draw(Graphics::ManagedSurface &screen);
72 bool active() const { return _commands != nullptr; }
73 bool skipped() const { return _skipFilm; }
74 const Common::U32String &subtitle() const { return _speech.subtitle(); }
75 byte speechFrame() const { return _speech.frame(_now); }
76
77private:
78 void advance();
79 void speak(uint cue, uint variation, uint lastVariation = 0, bool global = false);
80 void nextLine();
81 void finishPreparation();
82 void cacheRevisitedFrames();
83 void prefetch();
84
85 RunawayAudio &_audio;
87 RunawaySpeech _speech;
88 RunawayVideo _video, _stills;
89 bool _useStill = false;
90 RunawayFilmPortrait _portraits;
91 Graphics::ManagedSurface _background;
92 Common::Rect _destination;
93 uint _portrait = 0;
94 char _chapter = 'B';
95 const SceneTextStore *_text = nullptr;
96 const Command *_commands = nullptr;
97 uint _index = 0;
98 uint _movie = 0;
99 uint32 _now = 0, _started = 0;
100 uint32 _repeatAt = 0;
101 bool _entered = false, _showPortrait = false, _silentPortrait = false;
102 bool _skipFilm = false;
103 PauseToken _preparePause;
104 bool _skipSpeechPending = false;
105 bool _keepEffects = false;
106 int _listenerX = 512;
107 struct Line {
109 uint16 sample;
110 bool global;
111 };
112 Common::Array<Line> _lines;
113 uint _line = 0;
114};
115
116} // End of namespace Hollywood
117
118#endif // HOLLYWOOD_RUNAWAY_SEQUENCE_H
Definition: random.h:44
Definition: ustr.h:57
Definition: managed_surface.h:51
Definition: audio.h:29
Definition: sequence.h:38
Definition: scene_text_store.h:64
Definition: engine.h:111
Definition: rect.h:536
Definition: sequence.h:58