ScummVM API documentation
colony.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  * Based on the original sources
21  * https://github.com/Croquetx/thecolony
22  * Copyright (C) 1988, David A. Smith
23  *
24  * Distributed under Apache Version 2.0 License
25  *
26  */
27 
28 #ifndef COLONY_H
29 #define COLONY_H
30 
31 #include "common/array.h"
32 #include "common/random.h"
33 #include "common/rect.h"
34 #include "common/rendermode.h"
35 #include "engines/advancedDetector.h"
36 #include "engines/engine.h"
37 
38 namespace Common {
39 class MacResManager;
40 class SeekableReadStreamEndian;
41 }
42 
43 namespace Graphics {
44 class Cursor;
45 class Font;
46 class FrameLimiter;
47 class MacMenu;
48 class MacWindowManager;
49 class ManagedSurface;
50 struct Surface;
51 }
52 
53 namespace Colony {
54 
55 class Renderer;
56 class Sound;
57 
58 enum ColonyAction {
59  kActionNone,
60  kActionMoveForward,
61  kActionMoveBackward,
62  kActionStrafeLeft,
63  kActionStrafeRight,
64  kActionRotateLeft,
65  kActionRotateRight,
66  kActionLookLeft,
67  kActionLookRight,
68  kActionLookBehind,
69  kActionToggleMouselook,
70  kActionToggleDashboard,
71  kActionToggleWireframe,
72  kActionToggleFullscreen,
73  kActionSkipIntro,
74  kActionEscape,
75  kActionFire
76 };
77 
78 enum GameMode {
79  kModeColony = 2,
80  kModeBattle = 1
81 };
82 
83 enum WallFeatureType {
84  kWallFeatureNone = 0,
85  kWallFeatureDoor = 2,
86  kWallFeatureWindow = 3,
87  kWallFeatureShelves = 4,
88  kWallFeatureUpStairs = 5,
89  kWallFeatureDnStairs = 6,
90  kWallFeatureChar = 7,
91  kWallFeatureGlyph = 8,
92  kWallFeatureElevator = 9,
93  kWallFeatureTunnel = 10,
94  kWallFeatureAirlock = 11,
95  kWallFeatureColor = 12
96 };
97 
98 enum MapDirection {
99  kDirNorth = 0,
100  kDirEast = 1,
101  kDirWest = 2,
102  kDirSouth = 3,
103  kDirCenter = 4
104 };
105 
106 enum RobotType {
107  kRobEye = 1,
108  kRobPyramid = 2,
109  kRobCube = 3,
110  kRobUPyramid = 4,
111  kRobFEye = 5,
112  kRobFPyramid = 6,
113  kRobFCube = 7,
114  kRobFUPyramid = 8,
115  kRobSEye = 9,
116  kRobSPyramid = 10,
117  kRobSCube = 11,
118  kRobSUPyramid = 12,
119  kRobMEye = 13,
120  kRobMPyramid = 14,
121  kRobMCube = 15,
122  kRobMUPyramid = 16,
123  kRobQueen = 17,
124  kRobDrone = 18,
125  kRobSoldier = 19,
126  kRobSnoop = 20
127 };
128 
129 // 3D bounding radius (max XY extent from center) for each robot type.
130 // Used by clampToWalls to keep robot geometry from intersecting wall polygons.
131 // The original 2D wireframe renderer drew walls over robots (painter's algorithm);
132 // in OpenGL 3D both exist as real geometry, so padding is needed.
133 // Capped at 112 so the robot keeps at least 32 units of movement freedom
134 // within a 256-unit cell (256 - 2*112 = 32).
135 inline int robotWallPad(int robotType) {
136  static const int kMaxPad = 112;
137  switch (robotType) {
138  case kRobEye: return 66;
139  case kRobPyramid:
140  case kRobUPyramid: return 85;
141  case kRobCube: return 100;
142  case kRobQueen: return kMaxPad; // actual 120
143  case kRobDrone:
144  case kRobSoldier: return kMaxPad; // actual 130
145  case kRobSnoop: return kMaxPad; // actual 180
146  default: return 40; // eggs and other small types
147  }
148 }
149 
150 enum ObjectType {
151  kObjDesk = 21,
152  kObjPlant = 22,
153  kObjCChair = 23,
154  kObjBed = 24,
155  kObjTable = 25,
156  kObjCouch = 26,
157  kObjChair = 27,
158  kObjTV = 28,
159  kObjScreen = 29,
160  kObjConsole = 30,
161  kObjPowerSuit = 31,
162  kObjForkLift = 32,
163  kObjCryo = 33,
164  kObjBox1 = 34,
165  kObjBox2 = 35,
166  kObjTeleport = 36,
167  kObjDrawer = 37,
168  kObjTub = 38,
169  kObjSink = 39,
170  kObjToilet = 40,
171  kObjBench = 41,
172  kObjPToilet = 43,
173  kObjCBench = 44,
174  kObjProjector = 45,
175  kObjReactor = 46,
176  kObjFWall = 48,
177  kObjCWall = 49,
178  kObjBBed = 42
179 };
180 
181 enum ObjColor {
182  kColorClear = 0,
183  kColorBlack = 1,
184  kColorDkGray = 9,
185  kColorLtGreen = 11,
186  kColorBath = 17,
187  kColorWater = 18,
188  kColorSilver = 19,
189  kColorReactor = 20,
190  kColorBlanket = 21,
191  kColorSheet = 22,
192  kColorBed = 23,
193  kColorBox = 24,
194  kColorBench = 25,
195  kColorChair = 26,
196  kColorChairBase = 27,
197  kColorCouch = 28,
198  kColorConsole = 29,
199  kColorTV = 30,
200  kColorTVScreen = 31,
201  kColorDrawer = 32,
202  kColorDesk = 37,
203  kColorDeskTop = 38,
204  kColorDeskChair = 39,
205  kColorMac = 40,
206  kColorMacScreen = 41,
207  kColorCryo = 33,
208  kColorCryoGlass = 34,
209  kColorCryoBase = 35,
210  kColorForklift = 49,
211  kColorTread1 = 50,
212  kColorTread2 = 51,
213  kColorPot = 52,
214  kColorPlant = 53,
215  kColorPower = 54,
216  kColorPBase = 55,
217  kColorPSource = 56,
218  kColorTable = 61,
219  kColorTableBase = 62,
220  kColorPStand = 63,
221  kColorPLens = 64,
222  kColorProjector = 65,
223  kColorTele = 66,
224  kColorTeleDoor = 67,
225  kColorWall = 77,
226  kColorRainbow1 = 80,
227  kColorRainbow2 = 81,
228  kColorRainbow3 = 82,
229  kColorRainbow4 = 83,
230  // Robot colors
231  kColorCube = 36,
232  kColorDrone = 42,
233  kColorClaw1 = 43,
234  kColorClaw2 = 44,
235  kColorEyes = 45,
236  kColorEye = 46,
237  kColorIris = 47,
238  kColorPupil = 48,
239  kColorPyramid = 57,
240  kColorQueen = 58,
241  kColorTopSnoop = 59,
242  kColorBottomSnoop = 60,
243  kColorUPyramid = 68,
244  kColorShadow = 74,
245  // Animated reactor/power suit colors (Mac: c_hcore1..c_hcore4, c_ccore, c_color0..c_color3)
246  kColorHCore1 = 100,
247  kColorHCore2 = 101,
248  kColorHCore3 = 102,
249  kColorHCore4 = 103,
250  kColorCCore = 104,
251  // Semantic robot colors that need platform- or level-specific mapping.
252  kColorEyeball = 105,
253  kColorEyeIris = 106,
254  kColorMiniEyeIris = 107,
255  kColorDroneEye = 108,
256  kColorSoldierBody = 109,
257  kColorSoldierEye = 110,
258  kColorQueenBody = 111,
259  kColorQueenEye = 112,
260  kColorQueenWingRed = 113
261 };
262 
263 enum {
264  kColonyDebugMove = 1 << 0,
265  kColonyDebugRender = 1 << 1,
266  kColonyDebugAnimation = 1 << 2,
267  kColonyDebugMap = 1 << 3,
268  kColonyDebugSound = 1 << 4,
269  kColonyDebugUI = 1 << 5,
270  kColonyDebugCombat = 1 << 6,
271 };
272 
273 // Mac menu action IDs (matching original Mac Colony menu structure)
274 enum MenuAction {
275  kMenuActionAbout = 1,
276  kMenuActionNew,
277  kMenuActionOpen,
278  kMenuActionSave,
279  kMenuActionSaveAs,
280  kMenuActionQuit,
281  kMenuActionSound,
282  kMenuActionCrosshair,
283  kMenuActionPolyFill,
284  kMenuActionCursorShoot
285 };
286 
287 static const int kBaseObject = 20;
288 static const int kMeNum = 101;
289 
290 struct Locate {
291  uint8 ang = 0;
292  uint8 look = 0;
293  int8 lookY = 0;
294  int lookx = 0;
295  int delta = 0;
296  int xloc = 0;
297  int yloc = 0;
298  int xindex = 0;
299  int yindex = 0;
300  int xmx = 0, xmn = 0;
301  int zmx = 0, zmn = 0;
302  int32 power[3] = {};
303  int type = 0;
304  int dx = 0, dy = 0;
305  int dist = 0;
306  int wallPad = 0; // 3D bounding radius for wall clamping (0 = use default kWallPad)
307 };
308 
309 struct Thing {
310  int type = 0;
311  int visible = 0;
312  int alive = 0;
313  Common::Rect clip;
314  int count = 0;
315  Locate where;
316  int opcode = 0;
317  int counter = 0;
318  int time = 0;
319  int grow = 0;
320  // void (*make)(); // To be implemented as virtual functions or member function pointers
321  // void (*think)();
322 };
323 
324 // PATCH.C: Tracks object relocations across levels (forklift carry/drop).
325 struct PatchEntry {
326  struct { uint8 level, xindex, yindex; } from;
327  struct { uint8 level, xindex, yindex; int xloc, yloc; uint8 ang; } to;
328  uint8 type;
329  uint8 mapdata[5];
330 };
331 
332 // Temporary location reference for carrying objects.
333 struct PassPatch {
334  uint8 level, xindex, yindex;
335  int xloc, yloc;
336  uint8 ang;
337 };
338 
339 // Per-level persistence: wall state changes (airlock locks) and visit flags.
340 struct LevelData {
341  uint8 visit;
342  uint8 queen;
343  uint8 object[kBaseObject + 1];
344  uint8 count; // airlock open count (termination check)
345  uint8 size; // number of saved wall changes (max 10)
346  uint8 location[10][3]; // [x, y, direction] of each changed wall
347  uint8 data[10][5]; // saved wall feature bytes (5 per location)
348 };
349 
350 struct MacColor {
351  uint16 fg[3];
352  uint16 bg[3];
353  uint16 pattern;
354 };
355 
356 struct Image {
357  int16 width;
358  int16 height;
359  int16 align;
360  int16 rowBytes;
361  int8 bits;
362  int8 planes;
363  byte *data;
364 
365  Image() : width(0), height(0), align(0), rowBytes(0), bits(0), planes(0), data(nullptr) {}
366  ~Image() { delete[] data; }
367 };
368 
369 struct Sprite {
370  Image *fg;
371  Image *mask;
372  Common::Rect clip;
373  Common::Rect locate;
374  bool used;
375 
376  Sprite() : fg(nullptr), mask(nullptr), used(false) {}
377  ~Sprite() { delete fg; delete mask; }
378 };
379 
381  struct SubObject {
382  int16 spritenum;
383  int16 xloc, yloc;
384  };
385  Common::Array<SubObject> objects;
386  Common::Rect bounds;
387  bool visible;
388  int16 current;
389  int16 xloc, yloc;
390  int16 acurrent;
391  int16 axloc, ayloc;
392  uint8 type;
393  uint8 frozen;
394  uint8 locked;
395  int16 link;
396  int16 key;
397  int16 lock;
398  bool onoff;
399 
400  ComplexSprite() : visible(false), current(0), xloc(0), yloc(0), acurrent(0), axloc(0), ayloc(0), type(0), frozen(0), locked(0), link(0), key(0), lock(0), onoff(true) {}
401 };
402 
403 class Debugger;
404 
405 class ColonyEngine : public Engine {
406  friend class Debugger;
407 public:
408  ColonyEngine(OSystem *syst, const ADGameDescription *gd);
409  virtual ~ColonyEngine();
410 
411  Common::Error run() override;
412  bool hasFeature(EngineFeature f) const override;
413  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
414  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
415  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
416  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
417  void pauseEngineIntern(bool pause) override;
418  Common::Platform getPlatform() const { return _gameDescription->platform; }
419  bool isSoundEnabled() const { return _soundOn; }
420  const Graphics::Surface *getSavedScreen() const { return _savedScreen; }
421 
422  void initTrig();
423  void loadMacColors();
424  void loadMap(int mnum);
425  void startNewGame();
426  void corridor();
427  void quadrant();
428  bool hasInteractiveWallFeature(int cx, int cy, int dir) const;
429  void clampToWalls(Locate *p);
430  void clampToDiagonalWalls(Locate *p);
431  int checkwallMoveTo(int xnew, int ynew, int xind2, int yind2, Locate *pobject, uint8 trailCode);
432  int checkwallTryFeature(int xnew, int ynew, int xind2, int yind2, Locate *pobject, int dir);
433  int checkwall(int xnew, int ynew, Locate *pobject);
434  void cCommand(int xnew, int ynew, bool allowInteraction);
435  bool scrollInfo(const Graphics::Font *macFont = nullptr);
436  bool checkSkipRequested();
437  bool waitForInput();
438  void checkCenter();
439  void fallThroughHole();
440  void playTunnelEffect(bool falling);
441 
442  void doText(int entry, int center);
443  void inform(const char *text, bool hold);
444  void printMessage(const char *text[], bool hold);
445  void makeMessageRect(Common::Rect &r);
446  int runMacEndgameDialog(const Common::String &message);
447 
448 private:
449  const ADGameDescription *_gameDescription;
450 
451  uint8 _wall[32][32];
452  uint8 _mapData[31][31][5][5];
453  uint8 _robotArray[32][32];
454  uint8 _foodArray[32][32];
455  uint8 _dirXY[32][32];
456  bool _visited[8][32][32]; // per-level fog-of-war: _visited[level-1][x][y]
457  bool _showAutomap;
458 
459  Locate _me;
460  Common::Array<Thing> _objects;
461  int _level;
462  int _robotNum;
463  int _dynamicObjectBase = 0;
464 
465  Renderer *_gfx = nullptr;
466  Sound *_sound = nullptr;
467  Graphics::FrameLimiter *_frameLimiter = nullptr;
468  Common::RenderMode _renderMode;
469  Graphics::Surface *_savedScreen = nullptr;
470 
471 
472  int _tsin = 0, _tcos = 0;
473  int _sint[256];
474  int _cost[256];
475  int _centerX, _centerY;
476  int _width, _height;
477  int _mouseSensitivity;
478  bool _mouseLocked;
479  bool _soundOn = true;
480  bool _showDashBoard;
481  bool _crosshair;
482  bool _cursorShoot = false;
483  bool _insight;
484  bool _hasKeycard;
485  bool _unlocked;
486  int _weapons;
487  bool _wireframe;
488  bool _widescreen;
489  bool _fullscreen;
490  int _speedShift; // 1-5, movement speed = 1 << (_speedShift - 1)
491 
492  // Continuous movement flags (set/cleared by keymapper action events)
493  bool _moveForward;
494  bool _moveBackward;
495  bool _strafeLeft;
496  bool _strafeRight;
497  bool _rotateLeft;
498  bool _rotateRight;
499  bool _sprint;
500 
501  Common::RandomSource _randomSource;
502  Common::Point _mousePos;
503  uint8 _decode1[4];
504  uint8 _decode2[4];
505  uint8 _decode3[4];
506  uint8 _animDisplay[6];
507  int _coreState[2];
508  int _coreHeight[2];
509  int _corePower[3];
510  int _epower[3]; // log2 display levels for power bars (from qlog)
511  int _coreIndex;
512  int _orbit = 0;
513  int _armor = 0;
514  bool _gametest = false;
515  uint32 _blackoutColor = 0;
516  uint32 _lastClickTime = 0;
517  uint32 _displayCount = 0; // Frame counter for COLOR wall animation (Mac: count)
518  uint32 _lastHotfootTime = 0; // Time-gate for HOTFOOT damage (~8fps)
519  uint32 _lastAnimUpdate = 0;
520  uint32 _lastWarningChimeTime = 0;
521  int _action0 = 0, _action1 = 0;
522  int _creature = 0;
523  bool _allGrow = false;
524  bool _suppressCollisionSound = false;
525 
526  // Battle state (battle.c)
527  int _gameMode = kModeColony;
528  Locate _bfight[16]; // 16 battle enemies
529  Locate _battleEnter; // entrance structure
530  Locate _battleShip; // shuttle
531  Locate _battleProj; // enemy projectile
532  bool _projon = false; // projectile active
533  int _pcount = 0; // projectile countdown
534  int _mountains[256]; // mountain height profile
535  int _battledx = 0; // mountain parallax divisor (Width/59)
536  int _battleRound = 0; // AI round-robin counter
537  Locate *_battlePwh[100] = {}; // visible object pointers (for hit detection)
538  int _battleMaxP = 0; // count of visible objects
539  Locate _pyramids[4][4][15]; // pyramid obstacles: 4x4 quadrants, 15 each
540 
541  // PATCH.C: object relocation + wall state persistence
542  Common::Array<PatchEntry> _patches;
543  PassPatch _carryPatch[2]; // [0]=forklift, [1]=carried object
544  int _carryType; // type of object being carried
545  int _fl; // 0=not in forklift, 1=in forklift empty, 2=carrying object
546  LevelData _levelData[8]; // per-level wall state persistence
547 
548  MacColor _macColors[145];
549  bool _hasMacColors;
550  Graphics::Cursor *_macCrossCursor = nullptr;
551  Graphics::Cursor *_macArrowCursor = nullptr;
552  int _lastLoggedCursorMode = -1;
553 
554  // Mac menu bar (MacWindowManager overlay)
555  Graphics::MacWindowManager *_wm = nullptr;
556  Graphics::MacMenu *_macMenu = nullptr;
557  Graphics::ManagedSurface *_menuSurface = nullptr;
558  int _menuBarHeight = 0;
559  void initMacMenus();
560  void loadMacCursorResources();
561  void handleMenuAction(int action);
562  static void menuCommandsCallback(int action, Common::String &text, void *data);
563 
564  int _frntxWall = 0, _frntyWall = 0;
565  int _sidexWall = 0, _sideyWall = 0;
566  int _frntx = 0, _frnty = 0;
567  int _sidex = 0, _sidey = 0;
568  int _front = 0, _side = 0;
569  int _direction = 0;
570 
571  Common::Rect _clip;
572  Common::Rect _screenR;
573  Common::Rect _dashBoardRect;
574  Common::Rect _compassRect; // DOS: compOval (after shrink); Mac: moveWindow
575  Common::Rect _headsUpRect; // DOS: floorRect; Mac: minimap inside moveWindow
576  Common::Rect _powerRect; // DOS: powerRect; Mac: infoWindow
577 
578  // DOS dashboard layout (from original MetaWINDOW pix_per_Qinch values)
579  int _pQx = 0; // pixels per quarter-inch X (24 for EGA 640x350)
580  int _pQy = 0; // pixels per quarter-inch Y (18 for EGA 640x350)
581  int _powerWidth = 0; // width of each of the 3 power bar columns
582  int _powerHeight = 0; // pixel height per power bar unit (max 5)
583 
584  // Cached decoded PICT surfaces for dashboard panels (Mac color mode)
585  Graphics::Surface *_pictPower = nullptr; // PICT -32755 (normal) or -32760 (trouble)
586  Graphics::Surface *_pictPowerNoArmor = nullptr; // PICT -32761 (no armor, color)
587  Graphics::Surface *_pictCompass = nullptr; // PICT -32757
588  int _pictPowerID = 0; // Track which PICT is cached
589  Graphics::Surface *loadPictSurface(int resID);
590  void drawPictAt(Graphics::Surface *surf, int destX, int destY);
591 
592  uint8 wallAt(int x, int y) const;
593  const uint8 *mapFeatureAt(int x, int y, int direction) const;
594  bool _visibleCell[32][32] = {};
595  void computeVisibleCells();
596  void drawStaticObjects();
597 
598 public:
599  struct PrismPartDef {
600  int pointCount;
601  const int (*points)[3];
602  int surfaceCount;
603  const int (*surfaces)[8];
604  };
605 
606 private:
607  void draw3DPrism(Thing &obj, const PrismPartDef &def, bool useLook, int colorOverride = -1, bool accumulateBounds = false, bool forceVisible = false);
608  void draw3DLeaf(const Thing &obj, const PrismPartDef &def);
609  void draw3DSphere(Thing &obj, int pt0x, int pt0y, int pt0z,
610  int pt1x, int pt1y, int pt1z, uint32 fillColor, uint32 outlineColor, bool accumulateBounds = false);
611  void drawPrismOval3D(Thing &thing, const PrismPartDef &def, bool useLook, int colorOverride, bool forceVisible = false);
612  void drawEyeOverlays3D(Thing &thing, const PrismPartDef &irisDef, int irisColorOverride,
613  const PrismPartDef &pupilDef, int pupilColorOverride, bool useLook);
614  bool drawStaticObjectPrisms3D(Thing &obj);
615  void initRobots();
616  void renderCorridor3D();
617  void drawWallFeatures3D();
618  void drawWallFeature3D(int cellX, int cellY, int direction);
619  void drawCellFeature3D(int cellX, int cellY);
620  void getWallFace3D(int cellX, int cellY, int direction, float corners[4][3]);
621  void getCellFace3D(int cellX, int cellY, bool ceiling, float corners[4][3]);
622 
623  int occupiedObjectAt(int x, int y, const Locate *pobject);
624  void interactWithObject(int objNum);
625 
626  // shoot.c: shooting and power management
627  void setPower(int p0, int p1, int p2);
628  void cShoot();
629  void destroyRobot(int num);
630  void doShootCircles(int cx, int cy);
631  void doBurnHole(int cx, int cy, int radius);
632  void meGetShot();
633 
634  // battle.c: outdoor battle system (OpenGL 3D)
635  void battleInit();
636  void battleSet();
637  void battleThink();
638  void enterColonyFromBattle(int mapNum, int xloc, int yloc);
639  void battleCommand(int xnew, int ynew);
640  void battleShoot();
641  void battleProjCommand(int xcheck, int ycheck);
642  void renderBattle();
643  void draw3DBattlePrism(const PrismPartDef &def, int worldX, int worldY, uint8 ang, int zShift = 0);
644  void battleBackdrop();
645  void battleDrawPyramids();
646  void battleDrawTanks();
647 
648  // PATCH.C: object relocation + wall state persistence
649  void resetObjectSlot(int slot, int type, int xloc, int yloc, uint8 ang);
650  bool createObject(int type, int xloc, int yloc, uint8 ang);
651  void saveLevelState();
652  void doPatch();
653  void saveWall(int x, int y, int direction);
654  void getWall();
655  void newPatch(int type, const PassPatch &from, const PassPatch &to, const uint8 *mapdata);
656  bool patchMapTo(const PassPatch &to, uint8 *mapdata);
657  bool patchMapFrom(const PassPatch &from, uint8 *mapdata);
658  void exitForklift();
659  void dropCarriedObject();
660  bool setDoorState(int x, int y, int direction, int state);
661  int openAdjacentDoors(int x, int y);
662  int goToDestination(const uint8 *map, Locate *pobject);
663  int tryPassThroughFeature(int fromX, int fromY, int direction, Locate *pobject);
664  void playTunnelAirlockEffect();
665  void syncMacMenuChecks();
666  void updateMouseCapture(bool recenter = true);
667  Common::Point getAimPoint() const;
668  void updateViewportLayout();
669  void drawDashboardStep1();
670  void drawDashboardMac();
671  void drawDOSBarGraph(int x, int y, int height);
672  void updateDOSPowerBars();
673  static int qlog(int32 x);
674  void drawMiniMapMarker(int x, int y, int halfSize, uint32 color, bool isMac, const Common::Rect *clip = nullptr);
675  bool hasRobotAt(int x, int y) const;
676  bool hasFoodAt(int x, int y) const;
677  void drawMiniMap(uint32 lineColor);
678  void drawAutomap();
679  void markVisited();
680  void automapCellCorner(int dx, int dy, int xloc, int yloc, int lExt, int tsin, int tcos, int ccx, int ccy, int &sx, int &sy);
681  void automapDrawWall(const Common::Rect &vp, int x1, int y1, int x2, int y2, uint32 color);
682  int automapWallFeature(int fx, int fy, int dir);
683  void automapDrawWallWithFeature(const Common::Rect &vp, int wx1, int wy1, int wx2, int wy2, int feat, int lExt, uint32 color);
684  void drawForkliftOverlay();
685  void drawCrosshair();
686  bool clipLineToRect(int &x1, int &y1, int &x2, int &y2, const Common::Rect &clip) const;
687  void wallLine(const float corners[4][3], float u1, float v1, float u2, float v2, uint32 color);
688  void wallPolygon(const float corners[4][3], const float *u, const float *v, int count, uint32 color);
689  void wallChar(const float corners[4][3], uint8 cnum);
690 
691  struct TextIndex {
692  uint32 offset;
693  uint16 ch;
694  uint16 lines;
695  };
696 
697  // Animation system
698  Common::Array<Sprite *> _cSprites;
700  Image *_backgroundMask = nullptr;
701  Image *_backgroundFG = nullptr;
702  Common::Rect _backgroundClip;
703  Common::Rect _backgroundLocate;
704  bool _backgroundActive;
705  Common::MacResManager *_resMan = nullptr;
706  Common::MacResManager *_colorResMan = nullptr;
707  byte _topBG[8] = {};
708  byte _bottomBG[8] = {};
709  int16 _divideBG;
710  Common::String _animationName;
711  Common::Array<int16> _animBMColors;
712  bool _animationRunning;
713  int _animationResult;
714  bool _doorOpen;
715  int _liftObject = 0; // sprite index for the carried object in lift animation
716  bool _liftUp = false; // current lift state: true=raised, false=lowered
717  int _elevatorFloor;
718  int _airlockX = -1;
719  int _airlockY = -1;
720  int _airlockDirection = -1;
721  bool _airlockTerminate = false;
722 
723  void playIntro();
724  bool makeStars(const Common::Rect &r, int btn);
725  bool makeBlackHole();
726  bool makePlanet();
727  bool timeSquare(const Common::String &str, const Graphics::Font *macFont = nullptr);
728  bool drawPict(int resID);
729  bool loadAnimation(const Common::String &name);
730  void deleteAnimation();
731  void takeOff();
732  void gameOver(bool kill);
733  int countSavedCryos() const;
734  void playAnimation();
735  void updateAnimation();
736  void drawAnimation();
737  void drawComplexSprite(int index, int ox, int oy);
738  void drawAnimationImage(Image *img, Image *mask, int x, int y, uint32 fillColor = 0xFFFFFFFF);
739  uint32 resolveAnimColor(int16 bmEntry) const;
740  Image *loadImage(Common::SeekableReadStreamEndian &file);
741  void unpackBytes(Common::SeekableReadStreamEndian &file, byte *dst, uint32 len);
743  int whichSprite(const Common::Point &p);
744  void handleAnimationClick(int item);
745  void handleDeskClick(int item);
746  void handleVanityClick(int item);
747  void handleSlidesClick(int item);
748  void handleTeleshowClick(int item);
749  void handleKeypadClick(int item);
750  void handleSuitClick(int item);
751  void handleDoorClick(int item);
752  void handleAirlockClick(int item);
753  void handleElevatorClick(int item);
754  void handleControlsClick(int item);
755  void dolSprite(int index);
756  void moveObject(int index);
757  void setObjectState(int num, int state);
758  int objectState(int num) const;
759  void setObjectOnOff(int num, bool on);
760  void refreshAnimationDisplay();
761  void cryptArray(uint8 sarray[6], int i, int j, int k, int l);
762  void terminateGame(bool blowup);
763 
764  // think.c / shoot.c: colony robot AI, egg growth, and egg eating
765  void cThink();
766  void cubeThink(int num);
767  void pyramidThink(int num);
768  void upyramidThink(int num);
769  void eyeThink(int num);
770  void queenThink(int num);
771  void droneThink(int num);
772  void snoopThink(int num);
773  void eggThink(int num);
774  int getColonyActiveRobotLimit() const;
775  void copyOverflowObjectToSlot(int num);
776  bool layEgg(int type, int xindex, int yindex);
777  void moveThink(int num);
778  void bigGrow(int num);
779  void growRobot(int num);
780  int scanForPlayer(int num);
781  void robotShoot(int num);
782  void meEat();
783  void respawnObject(int num, int type);
784 };
785 
786 } // End of namespace Colony
787 
788 #endif // COLONY_H
Definition: managed_surface.h:51
Definition: framelimiter.h:40
Definition: macresman.h:126
Definition: str.h:59
Definition: font.h:83
Definition: surface.h:67
EngineFeature
Definition: engine.h:258
Definition: stream.h:77
Definition: error.h:81
Definition: array.h:52
Definition: advancedDetector.h:164
Definition: colony.h:325
Definition: random.h:44
RenderMode
Definition: rendermode.h:48
Definition: rect.h:524
Definition: colony.h:599
Definition: stream.h:745
Definition: macwindowmanager.h:148
Definition: colony.h:53
Definition: colony.h:333
Definition: colony.h:309
Definition: ustr.h:57
Definition: atari-cursor.h:35
Definition: colony.h:340
Definition: renderer.h:38
Definition: colony.h:381
Definition: cursor.h:42
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: colony.h:405
Definition: sound.h:40
Definition: macmenu.h:94
Definition: stream.h:944
Definition: console.h:37
Definition: colony.h:290
Definition: system.h:164
Definition: colony.h:369
Definition: movie_decoder.h:32
Definition: engine.h:144
Definition: colony.h:380
Platform
Definition: platform.h:93
Definition: colony.h:350