ScummVM API documentation
base_types.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// Hopkins-specific ACK data types and constants.
23
24#ifndef HOPKINS_BASE_TYPES_H
25#define HOPKINS_BASE_TYPES_H
26
27#include "common/array.h"
28#include "common/scummsys.h"
29
30namespace Hopkins {
31
32static const int kBaseMapWidth = 64;
33static const int kBaseMapHeight = 64;
34static const int kBaseMapCellCount = kBaseMapWidth * kBaseMapHeight;
35static const int kBaseAckGridArray = (kBaseMapWidth + 2) * (kBaseMapHeight + 2);
36static const int kBaseCellSize = 64;
37static const int kBaseCellShift = 6;
38static const int kBaseGridMask = 0xffc0;
39static const int kBaseWorldExtent = kBaseMapWidth * kBaseCellSize;
40
41static const int kBaseFixedShift = 16;
42static const int32 kBaseFixedOne = 1 << kBaseFixedShift;
43
44// Hopkins' ACK fork uses 1920 angular units per revolution, not 1800.
45static const int kBaseAngleCount = 1920;
46static const int kBaseAngleHalfFov = 160;
47static const int kBaseQuarterTurn = 480;
48static const int kBaseHalfTurn = 960;
49static const int kBaseThreeQuarterTurn = 1440;
50
51static const int kBaseFrameWidth = 320;
52static const int kBaseFrameHeight = 200;
53static const int kBaseViewWidth = 320;
54static const int kBaseViewHeight = 180;
55static const int kBaseViewHalfWidth = 160;
56static const int kBaseHorizon = 90;
57static const int kBaseMaximumDistance = 2048;
58static const int kBaseMinimumWallHeight = 8;
59static const int kBaseMaximumWallHeight = 960;
60
61static const int kBaseMaxObjects = 60;
62static const int kBaseMaxDoors = 20;
63
64static const uint16 kBaseWallTransparent = 0x0800;
65static const uint16 kBaseWallMulti = 0x0400;
66static const uint16 kBaseWallUpper = 0x0200;
67static const uint16 kBaseWallPass = 0x0100;
68
69static const uint16 kBaseDoorSecret = 0x8000;
70static const uint16 kBaseDoorLocked = 0x4000;
71static const uint16 kBaseDoorSlide = 0x2000;
72static const uint16 kBaseDoorSplit = 0x1000;
73static const uint16 kBaseDoorOpening = 0x0080;
74static const uint16 kBaseDoorClosing = 0x0040;
75static const uint16 kBaseDoorXCode = 60;
76static const uint16 kBaseDoorSideCode = 59;
77static const uint16 kBaseDoorYCode = 62;
78static const uint16 kBaseExitBitmap = 15;
79
80inline int normalizeBaseAngle(int angle) {
81 angle %= kBaseAngleCount;
82 if (angle < 0)
83 angle += kBaseAngleCount;
84 return angle;
85}
86
87inline int baseMapIndex(int x, int y) {
88 return y * kBaseMapWidth + x;
89}
90
91inline int baseWorldMapIndex(int x, int y) {
92 return (y & kBaseGridMask) + (x >> kBaseCellShift);
93}
94
95enum BaseObjectMode {
96 kBaseObjectChase = 1,
97 kBaseObjectFiring = 2,
98 kBaseObjectFlee = 3,
99 kBaseObjectDying = 4,
100 kBaseObjectDead = 5
101};
102
103enum BaseRayAxis {
104 kBaseRayNone = 0,
105 kBaseRayX = 1,
106 kBaseRayY = 2
107};
108
110 uint16 width;
111 uint16 height;
112 bool columnMajor;
113 Common::Array<byte> pixels;
114 Common::Array<byte> blankColumns;
115
116 BaseBitmap() : width(0), height(0), columnMajor(false) {}
117
118 bool valid() const {
119 return width && height && pixels.size() == (uint32)width * height;
120 }
121
122 byte sample(uint x, uint y) const {
123 if (!valid())
124 return 0;
125 x %= width;
126 y %= height;
127 return columnMajor ? pixels[x * height + y] : pixels[y * width + x];
128 }
129};
130
131struct BaseDoor {
132 int16 mPos;
133 int16 mPos1;
134 uint16 mCode;
135 uint16 mCode1;
136 int16 offset;
137 int8 speed;
138 byte type;
139 uint16 flags;
140
141 BaseDoor() : mPos(-1), mPos1(-1), mCode(0), mCode1(0), offset(0),
142 speed(0), type(0), flags(0) {}
143};
144
146 bool active;
147 bool passable;
148 int16 direction;
149 int16 x;
150 int16 y;
151 int16 mapPos;
152 byte id;
153 byte bitmap;
154 byte animationTick;
155 byte mode;
156 int16 timer;
157 int16 oldX;
158 int16 oldY;
159
160 BaseObject() : active(false), passable(false), direction(0), x(0), y(0),
161 mapPos(0), id(0), bitmap(1), animationTick(0), mode(kBaseObjectChase),
162 timer(0), oldX(0), oldY(0) {}
163};
164
166 bool hit;
167 BaseRayAxis axis;
168 uint16 code;
169 int mapPos;
170 int textureColumn;
171 int32 distance;
172 int32 rawDistance;
173 int32 worldX;
174 int32 worldY;
175
176 BaseRayHit() : hit(false), axis(kBaseRayNone), code(0), mapPos(-1),
177 textureColumn(0), distance(kBaseMaximumDistance - 1),
178 rawDistance(0x7fffffff), worldX(0), worldY(0) {}
179};
180
182 int entryId;
183 int16 playerX;
184 int16 playerY;
185 int16 playerAngle;
186 int mapIndex;
187 int returnId;
188};
189
190} // End of namespace Hopkins
191
192#endif // HOPKINS_BASE_TYPES_H
size_type size() const
Definition: array.h:316
Definition: anim.h:30
Definition: base_types.h:109
Definition: base_types.h:131
Definition: base_types.h:181
Definition: base_types.h:145
Definition: base_types.h:165