ScummVM API documentation
scene9100.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_MONSTERS_SCENES_INTRO_SCENE9100_H
23#define HOLLYWOOD_MONSTERS_SCENES_INTRO_SCENE9100_H
24
25#include "common/array.h"
26#include "common/random.h"
27#include "common/str.h"
28
29#include "hollywood/monsters/gameplay/actor_renderer.h"
30#include "hollywood/monsters/music.h"
31#include "hollywood/monsters/scenes/presentation_scene.h"
32#include "hollywood/scene_text_store.h"
33
34namespace Hollywood {
35
36class HollywoodEngine;
37
39public:
41
42 bool play();
43 bool playDialogueBranch();
44
46 uint16 centerX;
47 uint16 topY;
48 byte colorIndex;
49 byte red;
50 byte green;
51 byte blue;
52 bool updatePalette;
53 };
54
55private:
56 enum TalkingOverlayBase {
57 kTalkingOverlayNone = -1,
58 kTalkingOverlayBase0 = 0,
59 kTalkingOverlayBase320000 = 320000,
60 kTalkingOverlayBase640000 = 640000
61 };
62
63 struct CinematicStep {
64 byte backgroundMode;
65 uint16 textBankIndex;
66 byte descriptorIndex;
67 TalkingOverlayBase talkingOverlayBase;
68 byte talkingOverlayVariant;
69 bool copyFrameToSavedBefore;
70 bool animateForegroundActor;
71 SpeechTextStyle speechTextStyle;
72 };
73
74 bool load(bool dialogueBranch);
75 bool loadActorResources();
76 bool loadI10ActorBank(uint runStreamChunkIndex, uint descriptorChunkIndex, ActorSpriteBank &bank);
77
78 void applyActorHighlightColor(byte highlightRed, byte highlightGreen, byte highlightBlue);
79 void runRonEntryConversation();
80 void drawRonEntryPathFrame(uint32 pathElapsedMillis, uint32 pathDurationMillis,
81 bool playFootstep = false);
82 void runSueEntrySequence();
83 void runSueEntryPath();
84 void drawSueEntryPathFrame(uint32 pathElapsedMillis, uint32 pathDurationMillis,
85 bool playFootstep = false);
86 void drawActorFrame(const ActorSpriteBank &bank, byte facing, byte cel, int worldX, int worldY);
87 void playActorFootstepIfDue(int worldX, int worldY, byte cel);
88 void runForegroundIdleBeat();
89 void runOpeningPrelude();
90 void runCinematicSequence();
91 void initializeDialogueBranchOfficeState();
92 void runDialogueBranchSequence();
93 void prepareDialogueBranchOfficePatch();
94 void runForegroundPoseToDialogueState();
95 void runForegroundPoseBackToDeskIdle();
96 void prepareSceneFadeFrameWithScratchActor(byte talkingOverlayVariant);
97 void prepareChunkDFrameWithOptionalActorOverlay(bool actorOverlayEnabled);
98 void runEndingWipe();
99 void runConversationStep(uint16 textBankIndex, byte descriptorIndex, TalkingOverlayBase talkingOverlayBase, byte talkingOverlayVariant, bool animateForegroundActor, bool animateClock, const SpeechTextStyle &speechTextStyle, bool animateInsetActor = false, byte insetTalkBaseFrame = 0);
100 void waitForSpeechOrDelay(uint32 fallbackMillis, TalkingOverlayBase talkingOverlayBase, byte talkingOverlayVariant, bool animateForegroundActor, bool animateClock, bool animateInsetActor = false, byte insetTalkBaseFrame = 0);
101 void beginSubtitle(const SceneSpeechCue &popup, uint segmentIndex, const SpeechTextStyle &speechTextStyle);
102
103 void drawInitialForegroundFrame();
104 void drawForegroundActorFrame(byte frameIndex);
105 void restoreForegroundActorLayer();
106 void drawForegroundActorLayer();
107 void drawDeskActorLayer(uint32 baseOffset, uint16 descriptorCount, byte frameIndex, bool restoreBackground);
108 void drawDeskPrimaryStaticFrame(byte frameIndex, bool restoreBackground = true);
109 void drawDeskSecondaryStaticFrame(byte frameIndex, bool restoreBackground = true);
110 void drawDeskPrimaryStaticLayer(bool restoreBackground);
111 void drawDeskSecondaryStaticLayer(bool restoreBackground);
112 void drawPersistentDeskActors();
113 void drawOfficeCompositeLayers();
114 void syncOfficeRestoreBaseFromSaved();
115 void animateForegroundFrames(byte firstFrame, byte lastFrame);
116 void animateDeskPrimaryStaticFrames(byte firstFrame, byte lastFrame);
117 void animateDeskSecondaryStaticFrames(byte firstFrame, byte lastFrame);
118 void advanceClockFrame();
119 void restoreClockAreaBackground();
120 void drawClockLayers();
121 void drawTalkingOverlay(TalkingOverlayBase talkingOverlayBase, byte frameIndex, byte talkingOverlayVariant);
122 void drawStripSpriteFrame(const Common::Array<byte> &resource, uint32 baseOffset, uint32 descriptorTableOffset, uint16 descriptorCount, uint16 descriptorIndex);
123 void restoreSpriteBackground(const Common::Array<byte> &resource, uint32 baseOffset, uint32 descriptorTableOffset, uint16 descriptorCount, uint16 descriptorIndex);
124 void applyResourceSpanPatchToFrameDecodeBuffer(uint32 baseOffset);
125 void drawResourceBlockListToSceneFramebuffer(uint32 baseOffset);
126 void restoreResourceBlockListFromCleanOfficeBase(uint32 baseOffset, IndexedSurfaceBuffer &destination);
127 void removeInitialOfficeTitlePatch(IndexedSurfaceBuffer &destination);
128 void expandFillRunsToSavedFramebuffer();
129 void restoreOfficeFrameAndPresent();
130 void applyBackgroundMode(const CinematicStep &step);
131 void copyPaletteSegment(byte segmentIndex);
132 void copyDefaultPalette();
133 bool advanceClockTimer(uint32 millis);
134 bool advanceTalkingTimer(uint32 millis);
135 bool delayFrame(uint32 millis, TalkingOverlayBase talkingOverlayBase, byte talkingOverlayVariant, bool animateForegroundActor, bool animateClock, bool animateInsetActor = false, byte insetTalkBaseFrame = 0);
136 void stopAudio() override;
137
138 byte nextTalkingFrameVariant();
139 uint32 getSegmentOffset(byte segmentIndex) const;
140 uint16 readUint16(const Common::Array<byte> &source, uint offset) const;
141 int16 readSint16(const Common::Array<byte> &source, uint offset) const;
142 uint32 readUint32(const Common::Array<byte> &source, uint offset) const;
143
144 enum {
145 kI10ForegroundDescriptorCount = 0x24,
146 kI10DeskPrimaryStaticDescriptorCount = 3,
147 kI10DeskSecondaryStaticDescriptorCount = 6,
148 kI10ClockDescriptorCount = 0x3c,
149 kI10TalkingOverlayDescriptorCount = 10,
150 kSecondaryScratchBufferSize = 96000,
151 kDeskPrimaryStaticBase = 0,
152 kDeskSecondaryStaticBase = 48000,
153 kScratchChunk21Base = 0x4e200,
154 kScratchPrimaryPayloadBase = 640000
155 };
156
157 MusicPlayer _music;
158 SpeechPlayer _speech;
159 SceneTextStore _text;
160 SoundBank0Player _effectSound;
161 SoundBank0Player _clockSound;
162 SoundBank0Player _ambientSound;
163 ResidentSoundEffectPlayer _residentSoundEffects;
164 Common::RandomSource _random;
165 Common::Array<byte> _paletteDefault;
166 Common::Array<byte> _scenePaletteMask;
167 Common::Array<byte> _sceneFillRuns;
168 Common::Array<byte> _resourceScratchArena;
169 Common::Array<byte> _secondaryScratchBuffer;
170 Common::Array<byte> _presentationPaletteRemapTable;
171 IndexedSurfaceBuffer _frameDecodeBuffer;
172 IndexedSurfaceBuffer _cleanOfficeBaseFramebuffer;
173 ActorSpriteBank _actorBankI10Ron;
174 ActorSpriteBank _actorBankI10Sue;
175 uint32 _clockFrameAccumulator;
176 uint32 _talkingFrameAccumulator;
177 byte _foregroundActorFrame;
178 byte _foregroundTalkBaseFrame;
179 byte _clockChunk7Frame;
180 byte _clockChunk8Frame;
181 byte _clockChunk9Frame;
182 byte _clockChunk7CarryGate;
183 byte _talkingFrame;
184 byte _lastTalkingFrameVariant;
185 byte _deskPrimaryActorFrame;
186 byte _deskSecondaryActorFrame;
187 bool _clockVisible;
188 bool _deskPrimaryActorVisible;
189 bool _deskSecondaryActorVisible;
190 bool _dialogueBranch;
191};
192
193} // End of namespace Hollywood
194
195#endif // HOLLYWOOD_MONSTERS_SCENES_INTRO_SCENE9100_H
Definition: random.h:44
Definition: hollywood.h:47
Definition: presentation_scene.h:38
Definition: scene9100.h:38
Definition: scene9100.h:45