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" 42 class SeekableReadStreamEndian;
51 class MacWindowManager;
69 inline uint32 packRGB(byte r, byte g, byte b) {
70 return renderColorFormat().
ARGBToColor(255, r, g, b);
74 inline 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,
105 enum 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
157 inline int robotWallPad(
int robotType) {
158 static 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
338 uint8 objWorldAng(uint8 objectAng);
339 uint8 objAngFromPlayer(uint8 playerAng);
341 static const int kBaseObject = 20;
342 static const 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];
419 Image() : width(0), height(0), align(0), rowBytes(0), bits(0), planes(0), data(
nullptr) {}
420 ~
Image() {
delete[] data; }
437 Sprite() : fg(
nullptr), mask(
nullptr), used(
false), baked(
nullptr), bakedKey(0) {}
468 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) {}
485 void pauseEngineIntern(
bool pause)
override;
486 void applyGameSettings()
override;
488 bool isSoundEnabled()
const {
return _soundOn; }
490 bool isMacRenderMode()
const {
return _renderMode == Common::kRenderMacintosh || _renderMode == Common::kRenderMacintoshBW; }
491 bool isMacColorMode()
const {
return _renderMode == Common::kRenderMacintosh && _hasMacColors; }
494 void loadMacColors();
495 void loadMap(
int mnum);
499 bool hasInteractiveWallFeature(
int cx,
int cy,
int dir)
const;
500 void clampToWalls(
Locate *p);
501 void clampToDiagonalWalls(
Locate *p);
502 int checkwallMoveTo(
int xnew,
int ynew,
int xind2,
int yind2,
Locate *pobject, uint8 trailCode);
503 int checkwallTryFeature(
int xnew,
int ynew,
int xind2,
int yind2,
Locate *pobject,
int dir);
504 int checkwall(
int xnew,
int ynew,
Locate *pobject);
505 void clearPlayerCellMarker();
506 void setPlayerCellMarker();
507 bool playerIntersectsObjectFootprint(
const Thing &obj,
int xloc,
int yloc)
const;
508 bool playerStartsInsideObject(
int rnum)
const;
509 void cCommand(
int xnew,
int ynew,
bool allowInteraction);
511 bool checkSkipRequested();
512 bool checkClickRequested();
514 bool waitForMessageInput();
516 void fallThroughHole();
517 void playTunnelEffect(
bool falling);
518 int rideTunnel(
const uint8 *map,
Locate *pobject);
521 void doText(
int entry,
int center);
522 void inform(
const char *text,
bool hold);
523 void printMessage(
const char *text[],
bool hold);
526 int runMacSaveQuery();
533 uint8 _mapData[31][31][5][5];
534 uint8 _robotArray[32][32];
535 uint8 _foodArray[32][32];
536 uint8 _dirXY[32][32];
537 bool _visited[8][32][32];
545 int _dynamicObjectBase = 0;
548 Sound *_sound =
nullptr;
553 bool _flIconsLoaded =
false;
556 int _tsin = 0, _tcos = 0;
559 int _centerX, _centerY;
561 float _mouseSensitivity;
564 bool _soundOn =
true;
567 bool _cursorShoot =
false;
598 uint8 _animDisplay[6];
606 bool _gametest =
false;
607 uint32 _blackoutColor = 0;
608 uint32 _lastClickTime = 0;
609 uint32 _displayCount = 0;
610 uint32 _lastColonyThinkTime = 0;
611 uint32 _lastHotfootTime = 0;
612 uint32 _lastAnimUpdate = 0;
613 uint32 _lastWarningChimeTime = 0;
614 uint32 _lastCollisionSoundTime = 0;
615 int _bumpedObject = 0;
616 int _action0 = 0, _action1 = 0;
618 bool _allGrow =
false;
619 bool _suppressCollisionSound =
false;
622 int _gameMode = kModeColony;
627 bool _projon =
false;
631 int _battleRound = 0;
632 Locate *_battlePwh[100] = {};
634 Locate _pyramids[4][4][15];
647 int _lastLoggedCursorMode = -1;
653 int _menuBarHeight = 0;
655 void loadMacCursorResources();
656 void handleMenuAction(
int action);
657 static void menuCommandsCallback(
int action,
Common::String &text,
void *data);
660 bool showSaveDialog();
662 int _frntxWall = 0, _frntyWall = 0;
663 int _sidexWall = 0, _sideyWall = 0;
664 int _frntx = 0, _frnty = 0;
665 int _sidex = 0, _sidey = 0;
666 int _front = 0, _side = 0;
669 float _eyeDepthPull = 0.0f;
671 int _snoopSnoutZ = 0;
673 int _snoopSniffCount = 0;
686 int _powerHeight = 0;
692 int _pictPowerID = 0;
696 uint8 wallAt(
int x,
int y)
const;
697 const uint8 *mapFeatureAt(
int x,
int y,
int direction)
const;
698 bool _visibleCell[32][32] = {};
699 void computeVisibleCells();
700 void drawStaticObjects();
705 const int (*points)[3];
707 const int (*surfaces)[8];
711 void draw3DPrism(
Thing &obj,
const PrismPartDef &def,
bool useLook,
int colorOverride = -1,
bool accumulateBounds =
false,
bool forceVisible =
false);
713 void draw3DSphere(
Thing &obj,
int pt0x,
int pt0y,
int pt0z,
714 int pt1x,
int pt1y,
int pt1z, uint32 fillColor, uint32 outlineColor,
715 bool accumulateBounds =
false,
bool dosFill =
true);
716 void drawPrismOval3D(
Thing &thing,
const PrismPartDef &def,
bool useLook,
int colorOverride,
717 bool forceVisible =
false,
bool dosFill =
true);
718 void drawEyeOverlays3D(
Thing &thing,
const PrismPartDef &irisDef,
int irisColorOverride,
719 const PrismPartDef &pupilDef,
int pupilColorOverride,
bool useLook,
bool dosFill =
true);
721 void drawBodyEye3D(
Thing &obj,
int eyeballColor,
int pupilColor,
float pull);
722 void drawEnemyEye3D(
Thing &obj,
Thing &eye,
int eyeballColor,
int irisColor,
int pupilColor);
723 void pullTowardCamera(
float *px,
float *py,
float *pz,
int count)
const;
724 float growRenderTickFraction()
const;
725 bool drawInterpolatedGrowRobot(
Thing &obj,
int eyeballColor,
int pupilColor);
727 void drawInterpolatedGrowEye(
Thing &obj,
int fromStage,
int toStage,
float progress,
int eyeballColor,
int pupilColor);
728 bool drawStaticObjectPrisms3D(
Thing &obj);
730 void renderCorridor3D();
731 void drawWallFeatures3D();
732 void drawWallFeature3D(
int cellX,
int cellY,
int direction);
733 void drawCellFeature3D(
int cellX,
int cellY);
734 void getWallFace3D(
int cellX,
int cellY,
int direction,
float corners[4][3]);
735 bool isRecessFeature(
int x,
int y,
int direction)
const;
736 bool wallSegmentIsOpenWell(
int x,
int y, uint8 bit)
const;
737 void getWallRecess3D(
const float corners[4][3],
float farC[4][3])
const;
738 void recessPoint(
const float nearC[4][3],
const float farC[4][3],
float u,
float v,
float depth,
float out[3])
const;
739 void recessLine(
const float nearC[4][3],
const float farC[4][3],
float u1,
float v1,
float d1,
740 float u2,
float v2,
float d2, uint32 color);
741 void recessQuad(
const float nearC[4][3],
const float farC[4][3],
const float *u,
const float *v,
742 const float *d,
int count, uint32 color);
743 void clipToWallFace(
const float corners[4][3]);
744 void macFillRecess(
const float nearC[4][3],
const float farC[4][3],
const float *u,
const float *v,
745 const float *d,
int count,
int macIdx,
bool macColors);
746 void getCellFace3D(
int cellX,
int cellY,
bool ceiling,
float corners[4][3]);
748 int occupiedObjectAt(
int xnew,
int ynew,
int x,
int y,
const Locate *pobject);
749 void interactWithObject(
int objNum);
755 void warpMouseLogical(
int x,
int y);
758 void setPower(
int p0,
int p1,
int p2);
760 bool isShootableRobotType(
int type)
const;
761 bool isShotBlockingObjectType(
int type)
const;
762 int findAimedObject(
const Common::Point &aim,
bool *isBlocker =
nullptr,
int *targetDist =
nullptr)
const;
763 bool hasAimedRobotTarget()
const;
764 void destroyRobot(
int num);
765 void explodeFlash(
int silentFlips);
766 void invertViewport();
767 void doShootCircles(
int cx,
int cy);
768 void doBurnHole(
int cx,
int cy,
int radius);
775 void normalizeBattlePlayerPosition();
776 void enterColonyFromBattle(
int mapNum,
int xloc,
int yloc);
777 void battleCommand(
int xnew,
int ynew);
779 void battleProjCommand(
int xcheck,
int ycheck);
781 void draw3DBattlePrism(
const PrismPartDef &def,
int worldX,
int worldY, uint8 ang,
int zShift = 0);
782 void battleBackdrop();
783 void battleDrawPyramids();
784 void battleDrawTanks();
787 void resetObjectSlot(
int slot,
int type,
int xloc,
int yloc, uint8 ang);
788 bool createObject(
int type,
int xloc,
int yloc, uint8 ang);
789 void saveLevelState();
791 void saveWall(
int x,
int y,
int direction);
793 void newPatch(
int type,
const PassPatch &from,
const PassPatch &to,
const uint8 *mapdata);
794 bool patchMapTo(
const PassPatch &to, uint8 *mapdata);
795 bool patchMapFrom(
const PassPatch &from, uint8 *mapdata);
797 void dropCarriedObject();
798 bool stepOutOfCell(uint8 angle,
bool backwards =
false);
800 void teleportPlayer();
801 bool setDoorState(
int x,
int y,
int direction,
int state);
802 int openAdjacentDoors(
int x,
int y);
803 int goToDestination(
const uint8 *map,
Locate *pobject);
804 int tryPassThroughFeature(
int fromX,
int fromY,
int direction,
Locate *pobject);
805 void playTunnelAirlockEffect();
806 void syncMacMenuChecks();
807 void updateMouseCapture(
bool recenter =
true);
809 void updateViewportLayout();
810 void drawDashboardStep1();
811 void drawDashboardMac();
812 void drawDOSBarGraph(
int x,
int y,
int height);
813 void updateDOSPowerBars();
814 static int qlog(int32 x);
815 void drawMiniMapMarker(
int x,
int y,
int halfSize, uint32 color,
bool isMac,
const Common::Rect *clip =
nullptr);
816 bool hasRobotAt(
int x,
int y)
const;
817 bool hasFoodAt(
int x,
int y)
const;
818 void drawMiniMap(uint32 lineColor);
820 void changeAutomapZoom(
bool zoomIn);
821 void drawAutomapCryoMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
822 void drawAutomapTeleportMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
823 void drawAutomapForkliftMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
824 void drawAutomapQueenMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
825 void drawAutomapSnoopMarker(
int x,
int y,
int halfSize,
int dirX,
int dirY, uint32 color,
const Common::Rect &clip);
826 void drawAutomapDroneMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
827 void drawAutomapRobotMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
828 void drawAutomapObjectMarker(
int x,
int y,
int halfSize, uint32 color,
const Common::Rect &clip);
830 void automapCellCorner(
int dx,
int dy,
int xloc,
int yloc,
int lExt,
int tsin,
int tcos,
int ccx,
int ccy,
int &sx,
int &sy);
831 void automapDrawWall(
const Common::Rect &vp,
int x1,
int y1,
int x2,
int y2, uint32 color);
832 int automapWallFeature(
int fx,
int fy,
int dir);
833 void automapDrawWallWithFeature(
const Common::Rect &vp,
int wx1,
int wy1,
int wx2,
int wy2,
int feat,
int lExt, uint32 color);
834 void drawForkliftOverlay();
835 void loadForkliftIcons();
836 void drawCrosshair();
837 bool clipLineToRect(
int &x1,
int &y1,
int &x2,
int &y2,
const Common::Rect &clip)
const;
838 void wallLine(
const float corners[4][3],
float u1,
float v1,
float u2,
float v2, uint32 color);
839 void wallPolygon(
const float corners[4][3],
const float *u,
const float *v,
int count, uint32 color);
840 void wallChar(
const float corners[4][3], uint8 cnum);
851 Image *_backgroundMask =
nullptr;
852 Image *_backgroundFG =
nullptr;
856 uint64 _backgroundBakedKey = 0;
859 bool _backgroundActive;
863 byte _bottomBG[8] = {};
871 byte _animPatternKeyTopBG[8] = {};
872 byte _animPatternKeyBottomBG[8] = {};
873 int16 _animPatternKeyDivide = -1;
874 uint32 _animPatternKeyTopColor = 0;
875 uint32 _animPatternKeyBotColor = 0;
876 int _animPatternKeyMode = -1;
877 bool _animPatternValid =
false;
880 bool _animationRunning;
881 int _animationResult;
882 bool _animExitPressed =
false;
883 bool _animExitInside =
false;
887 int _coderPick[4] = {};
888 int _coderCursor = 0;
889 int _coderPressed = -1;
890 bool _coderPressInside =
false;
891 Image *_coderTiles[4] = {};
892 Image *_coderBtnUp =
nullptr;
893 Image *_coderBtnDown =
nullptr;
894 bool _coderTilesLoaded =
false;
899 bool _liftUp =
false;
903 int _airlockDirection = -1;
904 bool _airlockTerminate =
false;
907 bool _teleportInside =
false;
908 bool _teleportDone =
false;
912 bool makeBlackHole();
915 bool drawPict(
int resID);
917 bool loadLiftAnimation(
int objectType);
918 void deleteAnimation();
921 void gameOver(
bool kill);
922 void gameOver(
bool kill,
int savedCryos);
923 int countSavedCryos()
const;
924 void playAnimation();
925 void updateAnimation();
926 void drawAnimation();
927 void drawAnimationExitButton(
int ox,
int oy);
928 void drawColonyCoder(
int animOx,
int animOy);
929 void loadCoderTiles();
931 void drawComplexSprite(
int index,
int ox,
int oy);
932 void drawAnimationImage(
Image *img,
Image *mask,
int x,
int y, uint32 fillColor,
934 uint32 resolveAnimColor(int16 bmEntry)
const;
939 void handleAnimationClick(
int item);
940 void playCollisionSound();
941 void handleDeskClick(
int item);
942 void handleVanityClick(
int item);
943 void handleSlidesClick(
int item);
944 void handleTeleshowClick(
int item);
945 void handleKeypadClick(
int item);
946 void handleSuitClick(
int item);
947 void handleDoorClick(
int item);
948 void handleAirlockClick(
int item);
949 void handleElevatorClick(
int item);
950 void handleTeleportClick(
int item);
951 void flashTeleportBooth();
952 void handleControlsClick(
int item);
953 void dolSprite(
int index);
954 void moveObject(
int index);
955 void setObjectState(
int num,
int state);
956 int objectState(
int num)
const;
957 void setObjectOnOff(
int num,
bool on);
958 void refreshAnimationDisplay();
959 void cryptArray(uint8 sarray[6],
int i,
int j,
int k,
int l);
960 void terminateGame(
bool blowup);
964 void cubeThink(
int num);
965 void pyramidThink(
int num);
966 void upyramidThink(
int num);
967 void eyeThink(
int num);
968 void queenThink(
int num);
969 void droneThink(
int num);
970 void snoopThink(
int num);
971 void eggThink(
int num);
972 int getColonyActiveRobotLimit()
const;
973 void copyOverflowObjectToSlot(
int num);
974 bool layEgg(
int type,
int xindex,
int yindex);
975 void moveThink(
int num);
976 void bigGrow(
int num);
977 void growRobot(
int num);
978 int scanForPlayer(
int num);
979 void robotShoot(
int num);
981 void respawnObject(
int num,
int type);
Definition: managed_surface.h:51
Definition: framelimiter.h:40
Definition: macresman.h:126
EngineFeature
Definition: engine.h:282
Definition: advancedDetector.h:164
RenderMode
Definition: rendermode.h:48
Definition: macwindowmanager.h:149
Definition: atari-cursor.h:35
Definition: renderer.h:41
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: movie_decoder.h:32