ScummVM API documentation
martian_duct.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 ACCESS_MARTIAN_MARTIAN_DUCT_H
23#define ACCESS_MARTIAN_MARTIAN_DUCT_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "common/rect.h"
28#include "common/events.h"
29
30#include "access/martian/martian_resources.h" // For Point3 .. move it?
31
32namespace Access {
33
34namespace Martian {
35
36enum MoveIntent {
37 kMoveIntentNone,
38 kMoveIntentUp,
39 kMoveIntentLeft,
40 kMoveIntentDown,
41 kMoveIntentRight,
42};
43
44// Move angles - in the original these are indexes into sin/cos lookup tables.
45// Add Invalid to ensure at least 2-byte length.
46enum MoveAngle {
47 kMoveAngleNorth = 0,
48 kMoveAngleEast = 0x40,
49 kMoveAngleSouth = 0x80,
50 kMoveAngleWest = 0xC0,
51 kMoveAngleInvalid = 0xffff,
52};
53
54enum DuctFlags {
55 kDuctFlagNone = 0,
56 kDuctFlagZLessThanX = 1,
57 kDuctFlagXLessThanNegZ = 2,
58 kDuctFlagYLessThanNegZ = 4,
59 kDuctFlagZLessThanY = 8,
60 kDuctFlagZLessThan2 = 16,
61};
62
64 byte _col;
65 Common::Array<uint16> _pointIdxs;
66};
67
68class MartianEngine;
69
71public:
74
75 void duct2();
76 void duct4();
77
78private:
79 void doDuct();
80 void drawArrowSprites();
81 void drawArrowSprites2();
82 void clearWorkScreenArea();
83 void copyBufBlockToScreen();
84 void waitForMoveUpdate();
85 void storeLastValsToPrimArray(const Point3 &pt1, const Point3 &pt2);
86 void updatePlayerPos();
87 void updateMatrix();
88 void applyMatrixToMapData();
89 void updatePrimsAndDraw();
90 bool updateMapLocation();
91 void checkFinished();
92 void doMatrixMulAndAddPoint(int16 x, int16 y, int16 z);
93 bool doPrimArrayUpdates(int &tempIdx);
94 void doDraw(int counter);
95
96 void getPointValuesFromArray(int offset, Point3 &pt1, Point3 &pt2) const;
97 Common::Rect calcFinalLineSegment(const Point3 &pt1, const Point3 &pt2) const;
98
99 bool checkAndUpdatePrimArray1(int &offset);
100 bool checkAndUpdatePrimArray2(int &offset);
101 bool checkAndUpdatePrimArray3(int &offset);
102 bool checkAndUpdatePrimArray4(int &offset);
103 bool checkAndUpdatePrimArray5(int &offset);
104 bool checkAndUpdatePrimArrayForFlag(int &offset, DuctFlags flag, int divmulNum);
105
106 static Point3 divmul1(const Point3 &pt1, const Point3 &pt2);
107 static Point3 divmul2(const Point3 &pt1, const Point3 &pt2);
108 static Point3 divmul3(const Point3 &pt1, const Point3 &pt2);
109 static Point3 divmul4(const Point3 &pt1, const Point3 &pt2);
110 static Point3 divmul5(const Point3 &pt1, const Point3 &pt2);
111
112 bool checkMove0();
113 bool checkMove1();
114 bool checkMove2();
115 bool checkMove3();
116 bool checkMove4();
117 bool checkMove5();
118 bool checkMove6();
119 bool checkMove7();
120 bool checkMove8();
121 bool checkMove9();
122 bool checkMove10();
123 bool checkMove11();
124 bool checkMove12();
125 bool checkMove13_14();
126
127 void getXYandRBFlags(DuctFlags &xyflags, DuctFlags &rbflags, const Point3 &pt1, const Point3 &pt2);
128 int addPointsToMainPrimArray(int tempCount);
129 static DuctFlags getComparisonFlags(int16 x, int16 y, int16 z);
130
131 MartianEngine *_vm;
132 int16 _playerX;
133 int16 _preYOffset;
134 int16 _playerY;
135
136 int16 _nextPlayerX;
137 int16 _nextPlayerY;
138 int16 _xOffset;
139 int16 _yOffset;
140 int16 _xScale;
141 int16 _yScale;
142 uint16 _mapLoc;
143 MoveAngle _moveAngle;
144 int16 _crawlFrame;
145 bool _stopMoveLoop;
146 int16 _threshold1;
147 int16 _drawDistX;
148 int16 _drawDistY;
149 MoveIntent _moveIntent;
150
151 // NOTE: Original uses fixed point sin/cos with a lookup table.
152 float _matrix[3][3];
153
154 int16 _primArrayIdx;
155
156 Common::Array<Point3> _renderPoints;
157 Common::Array<RenderShape> _renderShapes;
158
159 Common::Array<int16> _primX1Array;
160 Common::Array<int16> _primY1Array;
161 Common::Array<int16> _primZ1Array;
162 Common::Array<int16> _primX2Array;
163 Common::Array<int16> _primY2Array;
164 Common::Array<int16> _primZ2Array;
165 Point3 _tempPoints[32];
166};
167
168}
169
170} // end namespace Access
171
172#endif // ACCESS_MARTIAN_MARTIAN_DUCT_H
Definition: martian_duct.h:70
Definition: martian_game.h:31
Definition: access.h:62
Definition: martian_resources.h:66
Definition: martian_duct.h:63
Definition: rect.h:536