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#include "graphics/pixelformat.h"
38#include "graphics/surface.h"
43class SeekableReadStreamEndian;
52class MacWindowManager;
69inline uint32 packRGB(
byte r,
byte g,
byte b) {
70 return renderColorFormat().
ARGBToColor(255, r, g, b);
74inline uint32 packMacColor(
const uint16 rgb[3]) {
75 return packRGB((
byte)(rgb[0] >> 8), (
byte)(rgb[1] >> 8), (
byte)(rgb[2] >> 8));
90 kActionToggleMouselook,
91 kActionToggleDashboard,
92 kActionToggleWireframe,
93 kActionToggleFullscreen,
105enum WallFeatureType {
106 kWallFeatureNone = 0,
107 kWallFeatureDoor = 2,
108 kWallFeatureWindow = 3,
109 kWallFeatureShelves = 4,
110 kWallFeatureUpStairs = 5,
111 kWallFeatureDnStairs = 6,
112 kWallFeatureChar = 7,
113 kWallFeatureGlyph = 8,
114 kWallFeatureElevator = 9,
115 kWallFeatureTunnel = 10,
116 kWallFeatureAirlock = 11,
117 kWallFeatureColor = 12
157inline int robotWallPad(
int robotType) {
158 const int kMaxPad = 112;
160 case kRobEye:
return 66;
162 case kRobUPyramid:
return 85;
163 case kRobCube:
return 100;
164 case kRobQueen:
return kMaxPad;
166 case kRobSoldier:
return kMaxPad;
167 case kRobSnoop:
return kMaxPad;
218 kColorLtMagenta = 14,
231 kColorChairBase = 27,
239 kColorDeskChair = 39,
241 kColorMacScreen = 41,
243 kColorCryoGlass = 34,
254 kColorTableBase = 62,
257 kColorProjector = 65,
277 kColorBottomSnoop = 60,
291 kColorMiniEyeIris = 107,
292 kColorDroneEye = 108,
293 kColorSoldierBody = 109,
294 kColorSoldierEye = 110,
295 kColorQueenBody = 111,
296 kColorQueenEye = 112,
297 kColorQueenWingRed = 113,
304 kColonyDebugMove = 1 << 0,
305 kColonyDebugRender = 1 << 1,
306 kColonyDebugAnimation = 1 << 2,
307 kColonyDebugMap = 1 << 3,
308 kColonyDebugSound = 1 << 4,
309 kColonyDebugUI = 1 << 5,
310 kColonyDebugCombat = 1 << 6,
315 kMenuActionAbout = 1,
322 kMenuActionCrosshair,
324 kMenuActionCursorShoot
338uint8 objWorldAng(uint8 objectAng);
339uint8 objAngFromPlayer(uint8 playerAng);
341const int kBaseObject = 20;
342const int kMeNum = 101;
354 int xmx = 0, xmn = 0;
355 int zmx = 0, zmn = 0;
380 struct { uint8 level, xindex, yindex; } from;
381 struct { uint8 level, xindex, yindex;
int xloc, yloc; uint8 ang; } to;
388 uint8 level, xindex, yindex;
397 uint8
object[kBaseObject + 1];
400 uint8 location[10][3];
402 uint8 openDoors[31][31];
420 Image() : width(0), height(0), align(0), rowBytes(0), bits(0), planes(0), data(
nullptr) {}
421 ~Image() {
delete[] data; }
438 Sprite() : fg(
nullptr), mask(
nullptr), used(
false), baked(
nullptr), bakedKey(0) {}
469 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) {}
489 bool isSoundEnabled()
const {
return _soundOn; }
491 bool isMacRenderMode()
const {
return _renderMode == Common::kRenderMacintosh || _renderMode == Common::kRenderMacintoshBW; }
492 bool isMacColorMode()
const {
return _renderMode == Common::kRenderMacintosh && _hasMacColors; }
495 void loadMacColors();
496 void loadMap(
int mnum);
500 bool hasInteractiveWallFeature(
int cx,
int cy,
int dir)
const;
501 void clampToWalls(Locate *p);
502 void clampToDiagonalWalls(Locate *p);
503 int checkwallMoveTo(
int xnew,
int ynew,
int xind2,
int yind2, Locate *pobject, uint8 trailCode);
504 int checkwallTryFeature(
int xnew,
int ynew,
int xind2,
int yind2, Locate *pobject,
int dir);
505 int checkwall(
int xnew,
int ynew, Locate *pobject);
506 void clearPlayerCellMarker();
507 void setPlayerCellMarker();
508 bool playerIntersectsObjectFootprint(
const Thing &obj,
int xloc,
int yloc)
const;
509 bool playerStartsInsideObject(
int rnum)
const;
510 void cCommand(
int xnew,
int ynew,
bool allowInteraction);
512 bool checkSkipRequested();
513 bool checkClickRequested();
515 bool waitForMessageInput();
517 void fallThroughHole();
518 void playTunnelEffect(
bool falling);
519 int rideTunnel(
const uint8 *map, Locate *pobject);
522 void doText(
int entry,
int center);
523 void inform(
const char *text,
bool hold);
524 void printMessage(
const char *text[],
bool hold);
527 int runMacSaveQuery();
534 uint8 _mapData[31][31][5][5];
535 uint8 _robotArray[32][32];
536 uint8 _foodArray[32][32];
537 uint8 _dirXY[32][32];
538 bool _visited[8][32][32];
546 int _dynamicObjectBase = 0;
548 Renderer *_gfx =
nullptr;
549 Sound *_sound =
nullptr;
554 bool _flIconsLoaded =
false;
557 int _tsin = 0, _tcos = 0;
560 int _centerX, _centerY;
562 float _mouseSensitivity;
565 bool _soundOn =
true;
568 bool _cursorShoot =
false;
599 uint8 _animDisplay[6];
607 bool _gametest =
false;
608 uint32 _blackoutColor = 0;
609 uint32 _lastClickTime = 0;
610 uint32 _displayCount = 0;
611 uint32 _lastColonyThinkTime = 0;
612 uint32 _lastHotfootTime = 0;
613 uint32 _lastAnimUpdate = 0;
614 uint32 _lastWarningChimeTime = 0;
615 uint32 _lastCollisionSoundTime = 0;
616 int _bumpedObject = 0;
617 int _action0 = 0, _action1 = 0;
619 bool _allGrow =
false;
620 bool _suppressCollisionSound =
false;
623 int _gameMode = kModeColony;
628 bool _projon =
false;
632 int _battleRound = 0;
633 bool _battleSendFarX =
false;
634 Locate *_battlePwh[100] = {};
636 Locate _pyramids[4][4][15];
640 PassPatch _carryPatch[2];
643 LevelData _levelData[8];
645 MacColor _macColors[145];
649 int _lastLoggedCursorMode = -1;
655 int _menuBarHeight = 0;
656 int _pendingMenuAction = 0;
657 int _pendingLoadSlot = -1;
659 void drawMacMenuBar();
661 void processPendingMenuAction();
662 void loadMacCursorResources();
663 void handleMenuAction(
int action);
664 static void menuCommandsCallback(
int action,
Common::String &text,
void *data);
667 bool showSaveDialog();
669 int _frntxWall = 0, _frntyWall = 0;
670 int _sidexWall = 0, _sideyWall = 0;
671 int _frntx = 0, _frnty = 0;
672 int _sidex = 0, _sidey = 0;
673 int _front = 0, _side = 0;
676 float _eyeDepthPull = 0.0f;
679 int _snoopSnoutZ = 0;
681 int _snoopSniffCount = 0;
694 int _powerHeight = 0;
700 int _pictPowerID = 0;
704 uint8 wallAt(
int x,
int y)
const;
705 const uint8 *mapFeatureAt(
int x,
int y,
int direction)
const;
706 bool _visibleCell[32][32] = {};
707 void computeVisibleCells();
708 void drawStaticObjects();
713 const int (*points)[3];
715 const int (*surfaces)[8];
719 void draw3DPrism(
Thing &obj,
const PrismPartDef &def,
bool useLook,
int colorOverride = -1,
bool accumulateBounds =
false,
bool forceVisible =
false);
721 void draw3DSphere(
Thing &obj,
int pt0x,
int pt0y,
int pt0z,
722 int pt1x,
int pt1y,
int pt1z, uint32 fillColor, uint32 outlineColor,
723 bool accumulateBounds =
false,
bool dosFill =
true);
724 void drawPrismOval3D(
Thing &thing,
const PrismPartDef &def,
bool useLook,
int colorOverride,
725 bool forceVisible =
false,
bool dosFill =
true);
726 void drawEyeOverlays3D(
Thing &thing,
const PrismPartDef &irisDef,
int irisColorOverride,
727 const PrismPartDef &pupilDef,
int pupilColorOverride,
bool useLook,
bool dosFill =
true);
729 void drawBodyEye3D(
Thing &obj,
int eyeballColor,
int pupilColor,
float pull);
730 void drawEnemyEye3D(
Thing &obj,
Thing &eye,
int eyeballColor,
int irisColor,
int pupilColor);
731 void pullTowardCamera(
float *px,
float *py,
float *pz,
int count)
const;
732 float growRenderTickFraction()
const;
733 bool drawInterpolatedGrowRobot(
Thing &obj,
int eyeballColor,
int pupilColor);
735 void drawInterpolatedGrowEye(
Thing &obj,
int fromStage,
int toStage,
float progress,
int eyeballColor,
int pupilColor);
736 bool drawStaticObjectPrisms3D(
Thing &obj);
738 void renderCorridor3D();
739 void computeRenderCamera();
740 void separateRenderCameraFromWall(
int x,
int y, uint8 bit,
int separation,
bool featuresVisible);
741 void drawWallFeatures3D();
742 bool isWallFeatureFacingCamera(
int cellX,
int cellY,
int direction)
const;
743 void drawWallFeature3D(
int cellX,
int cellY,
int direction);
744 void drawCellFeature3D(
int cellX,
int cellY);
745 void getWallFace3D(
int cellX,
int cellY,
int direction,
float corners[4][3]);
746 bool isVisibleRecessFeature(
int x,
int y,
int direction)
const;
747 bool wallSegmentIsOpenWell(
int x,
int y, uint8 bit)
const;
748 bool wallSegmentIsRendered(
int x,
int y, uint8 bit)
const;
749 void getWallRecess3D(
const float corners[4][3],
float farC[4][3])
const;
750 void recessPoint(
const float nearC[4][3],
const float farC[4][3],
float u,
float v,
float depth,
float out[3])
const;
751 void recessLine(
const float nearC[4][3],
const float farC[4][3],
float u1,
float v1,
float d1,
752 float u2,
float v2,
float d2, uint32 color);
753 void recessQuad(
const float nearC[4][3],
const float farC[4][3],
const float *u,
const float *v,
754 const float *d,
int count, uint32 color);
755 void clipToWallFace(
const float corners[4][3]);
756 void macFillRecess(
const float nearC[4][3],
const float farC[4][3],
const float *u,
const float *v,
757 const float *d,
int count,
int macIdx,
bool macColors);
758 void getCellFace3D(
int cellX,
int cellY,
bool ceiling,
float corners[4][3]);
760 int occupiedObjectAt(
int xnew,
int ynew,
int x,
int y,
const Locate *pobject);
761 void interactWithObject(
int objNum);
767 void warpMouseLogical(
int x,
int y);
770 void setPower(
int p0,
int p1,
int p2);
772 bool isShootableRobotType(
int type)
const;
773 bool isShotBlockingObjectType(
int type)
const;
774 int findAimedObject(
const Common::Point &aim,
bool *isBlocker =
nullptr,
int *targetDist =
nullptr)
const;
775 bool hasAimedRobotTarget()
const;
776 void destroyRobot(
int num);
777 void explodeFlash(
int silentFlips);
778 void invertViewport();
779 void doShootCircles(
int cx,
int cy);
780 void doBurnHole(
int cx,
int cy,
int radius);
787 void normalizeBattlePlayerPosition();
788 void enterColonyFromBattle(
int mapNum,
int xloc,
int yloc);
789 void battleCommand(
int xnew,
int ynew);
791 void battleProjCommand(
int xcheck,
int ycheck);
793 void draw3DBattlePrism(
const PrismPartDef &def,
int worldX,
int worldY, uint8 ang,
int zShift = 0);
794 void battleBackdrop();
795 void battleDrawPyramids();
796 void battleDrawTanks();
799 void resetObjectSlot(
int slot,
int type,
int xloc,
int yloc, uint8 ang);
800 bool createObject(
int type,
int xloc,
int yloc, uint8 ang);
801 void saveLevelState();
802 void saveOpenDoors();
804 void saveWall(
int x,
int y,
int direction);
806 void newPatch(
int type,
const PassPatch &from,
const PassPatch &to,
const uint8 *mapdata);
807 bool patchMapTo(
const PassPatch &to, uint8 *mapdata);
808 bool patchMapFrom(
const PassPatch &from, uint8 *mapdata);
810 void dropCarriedObject();
811 bool stepOutOfCell(uint8 angle,
bool backwards =
false);
813 void teleportPlayer();
814 bool setDoorState(
int x,
int y,
int direction,
int state);
815 int openAdjacentDoors(
int x,
int y);
816 int goToDestination(
const uint8 *map,
Locate *pobject);
817 int tryPassThroughFeature(
int fromX,
int fromY,
int direction,
Locate *pobject);
818 void playTunnelAirlockEffect();
819 void syncMacMenuChecks();
820 void updateMouseCapture(
bool recenter =
true);
822 void updateViewportLayout();
823 bool updateScreenSize();
824 void drawDashboardStep1();
825 void drawDashboardMac();
826 void drawMacNoArmorPanel();
827 void drawDOSBarGraph(
int x,
int y,
int height);
828 void updateDOSPowerBars();
829 void drawMiniMapMarker(
int x,
int y,
int halfSize, uint32 color,
bool isMac,
const Common::Rect *clip =
nullptr);
830 bool hasRobotAt(
int x,
int y)
const;
831 bool hasFoodAt(
int x,
int y)
const;
832 void drawMiniMap(uint32 lineColor);
834 void changeAutomapZoom(
bool zoomIn);
835 void drawAutomapCryoMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
836 void drawAutomapTeleportMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
837 void drawAutomapForkliftMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
838 void drawAutomapQueenMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
839 void drawAutomapSnoopMarker(
int x,
int y,
int halfSize,
int dirX,
int dirY, uint32 color,
const Common::Rect &clip);
840 void drawAutomapDroneMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
841 void drawAutomapRobotMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
842 void drawAutomapObjectMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
844 void automapCellCorner(
int dx,
int dy,
int xloc,
int yloc,
int lExt,
int tsin,
int tcos,
int ccx,
int ccy,
int &sx,
int &sy);
845 void automapDrawWall(
const Common::Rect &vp,
int x1,
int y1,
int x2,
int y2, uint32 color);
846 int automapWallFeature(
int fx,
int fy,
int dir);
847 void automapDrawWallWithFeature(
const Common::Rect &vp,
int wx1,
int wy1,
int wx2,
int wy2,
int feat,
int lExt, uint32 color);
848 void drawForkliftOverlay();
849 void loadForkliftIcons();
850 void drawCrosshair();
851 bool clipLineToRect(
int &x1,
int &y1,
int &x2,
int &y2,
const Common::Rect &clip)
const;
852 void wallLine(
const float corners[4][3],
float u1,
float v1,
float u2,
float v2, uint32 color);
853 void wallPolygon(
const float corners[4][3],
const float *u,
const float *v,
int count, uint32 color);
854 void wallChar(
const float corners[4][3], uint8 cnum);
865 Image *_backgroundMask =
nullptr;
866 Image *_backgroundFG =
nullptr;
870 uint64 _backgroundBakedKey = 0;
873 bool _backgroundActive;
877 byte _bottomBG[8] = {};
885 byte _animPatternKeyTopBG[8] = {};
886 byte _animPatternKeyBottomBG[8] = {};
887 int16 _animPatternKeyDivide = -1;
888 uint32 _animPatternKeyTopColor = 0;
889 uint32 _animPatternKeyBotColor = 0;
890 int _animPatternKeyMode = -1;
891 bool _animPatternValid =
false;
894 bool _animationRunning;
895 int _animationResult;
896 bool _animExitPressed =
false;
897 bool _animExitInside =
false;
901 int _coderPick[4] = {};
902 int _coderCursor = 0;
903 int _coderPressed = -1;
904 bool _coderPressInside =
false;
905 Image *_coderTiles[4] = {};
906 Image *_coderBtnUp =
nullptr;
907 Image *_coderBtnDown =
nullptr;
908 bool _coderTilesLoaded =
false;
913 bool _liftUp =
false;
917 int _airlockDirection = -1;
918 bool _airlockTerminate =
false;
921 bool _teleportInside =
false;
922 bool _teleportDone =
false;
926 bool makeBlackHole();
929 bool explodePlanet();
931 bool drawPict(
int resID);
933 bool loadLiftAnimation(
int objectType);
934 void deleteAnimation();
937 void gameOver(
bool kill);
938 void gameOver(
bool kill,
int savedCryos);
939 int countSavedCryos()
const;
940 void playAnimation();
941 void updateAnimation();
942 void drawAnimation();
943 void drawAnimationExitButton(
int ox,
int oy);
944 void drawColonyCoder(
int animOx,
int animOy);
945 void loadCoderTiles();
947 void drawComplexSprite(
int index,
int ox,
int oy);
948 void drawAnimationImage(Image *img, Image *mask,
int x,
int y, uint32 fillColor,
950 uint32 resolveAnimColor(int16 bmEntry)
const;
955 void handleAnimationClick(
int item);
956 void playCollisionSound();
957 void handleDeskClick(
int item);
958 void handleVanityClick(
int item);
959 void handleSlidesClick(
int item);
960 void handleTeleshowClick(
int item);
961 void handleKeypadClick(
int item);
962 void handleSuitClick(
int item);
963 void handleDoorClick(
int item);
964 void handleAirlockClick(
int item);
965 void handleElevatorClick(
int item);
966 void handleTeleportClick(
int item);
967 void flashTeleportBooth();
968 void handleControlsClick(
int item);
969 void dolSprite(
int index);
970 void moveObject(
int index);
971 void setObjectState(
int num,
int state);
972 int objectState(
int num)
const;
973 void setObjectOnOff(
int num,
bool on);
974 void refreshAnimationDisplay();
975 void cryptArray(uint8 sarray[6],
int i,
int j,
int k,
int l);
976 void terminateGame(
bool blowup);
980 void cubeThink(
int num);
981 void pyramidThink(
int num);
982 void upyramidThink(
int num);
983 void eyeThink(
int num);
984 void queenThink(
int num);
985 void droneThink(
int num);
986 void snoopThink(
int num);
987 void eggThink(
int num);
988 int getColonyActiveRobotLimit()
const;
989 void copyOverflowObjectToSlot(
int num);
990 bool layEgg(
int type,
int xindex,
int yindex);
991 void moveThink(
int num);
992 void bigGrow(
int num);
993 void growRobot(
int num);
994 int scanForPlayer(
int num);
995 void robotShoot(
int num);
997 void respawnObject(
int num,
int type);
void applyGameSettings() override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
bool hasFeature(EngineFeature f) const override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
void pauseEngineIntern(bool pause) override
Common::Error run() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: macresman.h:126
EngineFeature
Definition: engine.h:293
Definition: framelimiter.h:40
Definition: macwindowmanager.h:149
Definition: managed_surface.h:51
RenderMode
Definition: rendermode.h:48
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: advancedDetector.h:164
Common::Platform platform
Definition: advancedDetector.h:199
Definition: atari-cursor.h:35