ScummVM API documentation
scene3110.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_PLAYABLE_SCENE3110_H
23#define HOLLYWOOD_MONSTERS_SCENES_PLAYABLE_SCENE3110_H
24
25#include "common/array.h"
26
27#include "hollywood/monsters/graphics.h"
28#include "hollywood/monsters/music.h"
29#include "hollywood/resource.h"
30#include "hollywood/monsters/scenes/presentation_scene.h"
31
32namespace Hollywood {
33
34class HollywoodEngine;
35
37public:
39 ~Scene3110() override;
40
41 bool play();
42
43private:
44 struct SpriteTrack {
45 uint chunkIndex;
46 uint descriptorCount;
47 const byte *frameMap;
48 uint frameMapSize;
49 uint firstTick;
50 bool holdLastFrame;
51 };
52
53 struct MachineRoomState {
54 byte fixedOverlayFrame;
55 byte leftMemoryActorFrame;
56 byte rightMemoryActorFrame;
57 byte leftArcFrame;
58 byte rightArcFrame;
59 byte finalOverlayFrame;
60 uint32 fixedOverlayAccumulator;
61 uint32 leftMemoryActorAccumulator;
62 uint32 rightMemoryActorAccumulator;
63 uint32 leftArcAccumulator;
64 uint32 rightArcAccumulator;
65 uint32 finalOverlayAccumulator;
66 uint32 finalCounterAccumulator;
67 uint32 paletteBandAccumulator;
68 uint32 palettePulseAccumulator;
69 uint finalCounter;
70 uint paletteBandPhase;
71 bool initialGateDirty;
72 bool finalOverlayDirty;
73 };
74
75 bool loadFramebufferAndPalette(uint framebufferChunk, uint paletteChunk, uint paletteReadSize = kPaletteSize);
76 bool prepareScene(uint framebufferChunk, uint paletteChunk, uint paletteReadSize,
77 const SpriteTrack *tracks, uint trackCount);
78 void runLongBranch();
79 void runShortBranch();
80 void runExteriorLightningSequence();
81 void runExteriorStormReturnSequence();
82 void drawExteriorFrame(byte foregroundFrameIndex, byte bladeFrame);
83 void darkenExteriorPaletteRange(const Common::Array<byte> &referencePalette,
84 uint firstColor, uint lastColor, byte threshold, bool snapLowComponentsToBlack);
85 void runMachineRoomSequence();
86 void runMonsterTableElectricSequence();
87 void runMonsterTableFinalSequence();
88 void runBlackFlashSequence();
89 void runCloseupFlashSequence();
90 void initializeMachineRoomState(MachineRoomState &state) const;
91 void composeMachineRoomFrame(const MachineRoomState &state, bool finalPhase);
92 void restoreOriginalSpriteFrameBackground(const Common::Array<byte> &resource, uint descriptorCount,
93 uint descriptorIndex, Graphics::Surface &destination) const;
94 void runMachineRoomInitialPhase(MachineRoomState &state);
95 void runMachineRoomFinalPhase(MachineRoomState &state);
96 void advanceMachineRoomState(MachineRoomState &state, uint32 elapsedMillis, bool finalPhase);
97 void advanceInitialMemoryGate(MachineRoomState &state);
98 void advanceFinalMemoryOverlay(MachineRoomState &state);
99 void advanceLeftMemoryActor(MachineRoomState &state);
100 void advanceRightMemoryActor(MachineRoomState &state);
101 void advanceLeftElectricalArc(MachineRoomState &state);
102 void advanceRightElectricalArc(MachineRoomState &state);
103 void advanceMachineRoomPalette(MachineRoomState &state, uint32 elapsedMillis);
104 void runSpriteSequence(const AnimationFrameRange &range, uint16 viewportX,
105 const SpriteTrack *tracks, uint trackCount);
106 void drawSpriteSequenceFrame(uint tick, const SpriteTrack *tracks, uint trackCount);
107 uint frameForTrack(const SpriteTrack &track, uint tick) const;
108 void initializeMemoryEffectPalette();
109 void applyMemoryPaletteBand(uint tick);
110 void processMemoryPalettePulseStep();
111 void adjustMemoryPalettePulseRanges(int delta);
112 void restoreMemoryPalettePulseRanges();
113 uint16 nextMemoryRandom15Bit();
114 void playSound(uint slot, uint16 cueId, byte volumePercent, bool loop);
115 void stopSound(uint slot);
116 void stopSounds();
117 void handleAnimationFrameEvent(const AnimationFrameEvent &event, uint frame) override;
118 void presentAnimationFrame() override;
119 void stopAudio() override;
120
121 Common::Array<byte> _exteriorStormPalette;
122 Common::Array<byte> _memoryPulseSavedPalette;
123 IndexedSurfaceBuffer _baseFramebuffer;
124 Common::Array<byte> _chunks[kResourceChunkCount];
125 SoundBank0Player _sound0;
126 SoundBank0Player _sound1;
127 SoundBank0Player _sound2;
128 const SpriteTrack *_spriteSequenceTracks;
129 uint _spriteSequenceTrackCount;
130 uint16 _spriteSequenceViewportX;
131 byte _spriteSequenceTick;
132 uint32 _memoryRandomState;
133 byte _memoryPulseLevel;
134 bool _memoryPulseActive;
135};
136
137} // End of namespace Hollywood
138
139#endif // HOLLYWOOD_MONSTERS_SCENES_PLAYABLE_SCENE3110_H
Definition: hollywood.h:47
Definition: graphics.h:74
Definition: presentation_scene.h:38
Definition: scene3110.h:36
Definition: music.h:82
Definition: surface.h:67
Definition: animation_events.h:36
Definition: animation_player.h:34