ScummVM API documentation
dungeon_view.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 ULTIMA3_GFX_DUNGEON_VIEW_H
23#define ULTIMA3_GFX_DUNGEON_VIEW_H
24
25#include "common/array.h"
26#include "ultima/ultima3/data/dungeon.h"
27
28namespace Ultima {
29namespace Ultima3 {
30namespace Gfx {
31
40private:
41 // The picture is built a pixel at a time at the position it has on the
42 // screen, which leaves the view with a margin on all sides
43 static const int WIDTH = 256;
44 static const int HEIGHT = 200;
45 static const int OFFSET = 0x20;
46
47 // The pictures are layers the size of the view, and 0 in them is clear
48 static const int PICTURE_SIZE = 0x80;
49 static const int FACES = 64;
50 static const int PLACES = 21;
51
52 struct Picture {
53 bool _present;
54 byte _pixels[PICTURE_SIZE * PICTURE_SIZE];
55 };
56
57 // Something that is drawn once all the walls have been, so that it's over them
58 struct Thing {
59 bool _chest;
60 bool _down;
61 int _place;
62 };
63
64 static Picture _faces[FACES];
65 static Picture _ladders[PLACES];
66 static Picture _chests[PLACES];
67 static bool _loaded;
68 static bool _enabled;
69
70 byte _pixels[WIDTH * HEIGHT];
71 int _facing = 0;
73 bool _usePictures = false;
74
75 static bool loadPicture(Picture &picture, const Common::String &name);
76
81 static void resetPictures();
82
83 void drawPicture(const Picture &picture, bool flip, bool erase);
84
88 void drawPlaces(const Data::Dungeon &dungeon, int level, int x, int y);
89
90 enum Sight {
91 OPEN,
92 WALL,
93 DOOR
94 };
95
96 void plot(int x, int y);
97 void line(int x0, int y0, int x1, int y1);
98 void column(int x, int top, int bottom, bool erase, byte color);
99 void drawWall(int face);
100 void drawLadder(bool down, int place);
101 void drawChest(int place);
102
106 Sight look(const Data::Dungeon &dungeon, int level, int x, int y, int place);
107
112 void lookAlong(const Data::Dungeon &dungeon, int level, int x, int y, const byte *places, int count);
113
114public:
115 DungeonView() {
116 memset(_pixels, 0, sizeof(_pixels));
117 resetPictures();
118 }
119
123 static void loadPictures();
124
128 static void setPicturesEnabled(bool enabled) {
129 _enabled = enabled;
130 }
131
135 static bool usesPictures();
136
140 void draw(const Data::Dungeon &dungeon, int level, int x, int y, int facing);
141
146 byte color(int x, int y) const {
147 return _pixels[y * WIDTH + x];
148 }
149};
150
151} // namespace Gfx
152} // namespace Ultima3
153} // namespace Ultima
154
155#endif
Definition: str.h:59
Definition: dungeon.h:54
Definition: dungeon_view.h:39
void draw(const Data::Dungeon &dungeon, int level, int x, int y, int facing)
static void setPicturesEnabled(bool enabled)
Definition: dungeon_view.h:128
byte color(int x, int y) const
Definition: dungeon_view.h:146