ScummVM API documentation
graphics.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_GRAPHICS_H
23#define HOLLYWOOD_RUNAWAY_GRAPHICS_H
24
25#include "common/array.h"
26#include "common/path.h"
27#include "common/rect.h"
28#include "graphics/managed_surface.h"
29
30namespace Hollywood {
31
32class ChunkArchive;
33
34bool readRunawayFile(const Common::Path &path, Common::Array<byte> &data);
35// RESOURCE.000 has a ten-byte (demo) or twenty-byte (retail) prefix,
36// followed by two 500-entry tables.
37bool readRunawayGlobalChunk(uint chunk, Common::Array<byte> &data);
38bool loadRunawaySurface(uint chunk, int width, int height, Graphics::ManagedSurface &surface);
39bool loadRunawaySurface(const Common::Path &path, int width, int height, Graphics::ManagedSurface &surface);
40bool loadRunawaySurface(ChunkArchive &archive, uint chunk, int width, int height, Graphics::ManagedSurface &surface);
41bool loadRunawayMask(ChunkArchive &archive, int width, int height, Common::Array<byte> &mask, Common::Array<byte> &maps, uint chunk = 1);
42byte findRunawayLight(Common::Point position, int width, const Common::Array<byte> &mask, const Common::Array<byte> &maps);
43bool applyRunawayPatch(const Common::Array<byte> &patch, Graphics::ManagedSurface &surface, int yOffset = 0, int xOffset = 0);
44
45enum {
46 kRunawayScreenWidth = 1024,
47 kRunawayScreenHeight = 768,
48 kRunawayViewportHeight = 600,
49 kRunawayViewportTop = (kRunawayScreenHeight - kRunawayViewportHeight) / 2
50};
51
52// Runaway's room animations retain Hollywood's 14-byte descriptors, but use
53// RGB565 spans. Coordinates are absolute room coordinates, including shadows.
55public:
56 bool load(ChunkArchive &archive, uint chunk, uint frames);
57 bool load(const Common::Array<byte> &data, uint frames);
58 void draw(Graphics::ManagedSurface &surface, uint frame, int cameraX, int roomTop) const;
59 uint frameCount() const { return _frames; }
60
61private:
62 bool validate(uint frames);
64 uint _frames = 0;
65};
66
67// Brian's walking and head banks are indexed RGB565 with separate opacity and
68// shadow planes. This differs from the room animation spans.
70public:
71 enum Model {
72 kCabin, kMuseumInterior, kMuseumHall,
73 kChapters12, kChapters12Alternate, kCabinAlternate, kChapters456, kChapters456Alternate
74 };
75
76 struct RenderParams {
77 Common::Point position, camera;
78 int roomWidth = 0;
79 float height = 455;
80 // A depth layer hides the actor until his feet pass its Y threshold.
81 int16 depthY[10] = {0, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767, 32767};
82 byte light[3] = {100, 100, 100};
83 bool antialias = true;
84 };
85 bool load(Model model = kCabin);
86 bool loadChapter(byte chapter, bool alternate);
87 bool setFrame(uint facing, uint frame, int headFrame = -1);
88 bool loadAction(uint chunk, uint frames);
89 bool setActionFrame(uint frame);
90 static float perspectiveHeight(Common::Point position);
91 void draw(Graphics::ManagedSurface &surface, Common::Point position, int cameraX,
92 int roomTop, const Common::Array<byte> &mask, const Common::Array<byte> &maps,
93 bool sunlit = false, bool antialias = true) const;
94 void draw(Graphics::ManagedSurface &surface, const RenderParams &params,
95 const Common::Array<byte> &mask, const Common::Array<byte> &maps) const;
96
97private:
98 enum { kHeadHeight = 148, kFacings = 8, kFrames = 19,
99 kHeadFacings = 6, kHeadFrames = 40 };
100 uint _width = 345, _height = 518;
101 int _anchorX = 168, _anchorY = 434;
102 bool _museum = false;
103 bool decodeBodyFrame(const Common::Array<byte> &bank, const byte *descriptor, uint end);
104 bool decodeFrame(const Common::Array<byte> &bank, const byte *descriptor, uint end, bool head);
105 Common::Array<byte> _descriptors, _headDescriptors;
106 Common::Array<byte> _actionDescriptors, _actionBank;
107 Common::Array<byte> _banks[kFacings];
108 Common::Array<byte> _headBanks[kHeadFacings];
109 Common::Array<byte> _pixels, _opacity, _shadow;
110 uint16 _palette[256];
111 Common::Rect _bounds;
112 int _loadedModel = -1;
113 int _facing = -1;
114 int _frame = -1;
115 int _headFrame = -1;
116};
117
118} // End of namespace Hollywood
119
120#endif
Definition: path.h:52
Definition: managed_surface.h:51
Definition: resource.h:59
Definition: graphics.h:69
Definition: graphics.h:54
Definition: rect.h:144
Definition: rect.h:536
Definition: graphics.h:76