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;
50 class MacWindowManager;
68 inline uint32 packRGB(byte r, byte g, byte b) {
69 return renderColorFormat().
ARGBToColor(255, r, g, b);
73 inline uint32 packMacColor(
const uint16 rgb[3]) {
74 return packRGB((byte)(rgb[0] >> 8), (byte)(rgb[1] >> 8), (byte)(rgb[2] >> 8));
89 kActionToggleMouselook,
90 kActionToggleDashboard,
91 kActionToggleWireframe,
92 kActionToggleFullscreen,
102 enum WallFeatureType {
103 kWallFeatureNone = 0,
104 kWallFeatureDoor = 2,
105 kWallFeatureWindow = 3,
106 kWallFeatureShelves = 4,
107 kWallFeatureUpStairs = 5,
108 kWallFeatureDnStairs = 6,
109 kWallFeatureChar = 7,
110 kWallFeatureGlyph = 8,
111 kWallFeatureElevator = 9,
112 kWallFeatureTunnel = 10,
113 kWallFeatureAirlock = 11,
114 kWallFeatureColor = 12
154 inline int robotWallPad(
int robotType) {
155 static const int kMaxPad = 112;
157 case kRobEye:
return 66;
159 case kRobUPyramid:
return 85;
160 case kRobCube:
return 100;
161 case kRobQueen:
return kMaxPad;
163 case kRobSoldier:
return kMaxPad;
164 case kRobSnoop:
return kMaxPad;
215 kColorChairBase = 27,
223 kColorDeskChair = 39,
225 kColorMacScreen = 41,
227 kColorCryoGlass = 34,
238 kColorTableBase = 62,
241 kColorProjector = 65,
261 kColorBottomSnoop = 60,
273 kColorMiniEyeIris = 107,
274 kColorDroneEye = 108,
275 kColorSoldierBody = 109,
276 kColorSoldierEye = 110,
277 kColorQueenBody = 111,
278 kColorQueenEye = 112,
279 kColorQueenWingRed = 113
283 kColonyDebugMove = 1 << 0,
284 kColonyDebugRender = 1 << 1,
285 kColonyDebugAnimation = 1 << 2,
286 kColonyDebugMap = 1 << 3,
287 kColonyDebugSound = 1 << 4,
288 kColonyDebugUI = 1 << 5,
289 kColonyDebugCombat = 1 << 6,
294 kMenuActionAbout = 1,
301 kMenuActionCrosshair,
303 kMenuActionCursorShoot
306 static const int kBaseObject = 20;
307 static const int kMeNum = 101;
319 int xmx = 0, xmn = 0;
320 int zmx = 0, zmn = 0;
345 struct { uint8 level, xindex, yindex; } from;
346 struct { uint8 level, xindex, yindex;
int xloc, yloc; uint8 ang; } to;
353 uint8 level, xindex, yindex;
362 uint8
object[kBaseObject + 1];
365 uint8 location[10][3];
384 Image() : width(0), height(0), align(0), rowBytes(0), bits(0), planes(0), data(
nullptr) {}
385 ~
Image() {
delete[] data; }
402 Sprite() : fg(
nullptr), mask(
nullptr), used(
false), baked(
nullptr), bakedKey(0) {}
433 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) {}
450 void pauseEngineIntern(
bool pause)
override;
452 bool isSoundEnabled()
const {
return _soundOn; }
454 bool isMacRenderMode()
const {
return _renderMode == Common::kRenderMacintosh || _renderMode == Common::kRenderMacintoshBW; }
455 bool isMacColorMode()
const {
return _renderMode == Common::kRenderMacintosh && _hasMacColors; }
458 void loadMacColors();
459 void loadMap(
int mnum);
463 bool hasInteractiveWallFeature(
int cx,
int cy,
int dir)
const;
464 void clampToWalls(
Locate *p);
465 void clampToDiagonalWalls(
Locate *p);
466 int checkwallMoveTo(
int xnew,
int ynew,
int xind2,
int yind2,
Locate *pobject, uint8 trailCode);
467 int checkwallTryFeature(
int xnew,
int ynew,
int xind2,
int yind2,
Locate *pobject,
int dir);
468 int checkwall(
int xnew,
int ynew,
Locate *pobject);
469 void clearPlayerCellMarker();
470 void setPlayerCellMarker();
471 bool playerIntersectsObjectFootprint(
const Thing &obj,
int xloc,
int yloc)
const;
472 void cCommand(
int xnew,
int ynew,
bool allowInteraction);
474 bool checkSkipRequested();
477 void fallThroughHole();
478 void playTunnelEffect(
bool falling);
480 void doText(
int entry,
int center);
481 void inform(
const char *text,
bool hold);
482 void printMessage(
const char *text[],
bool hold);
490 uint8 _mapData[31][31][5][5];
491 uint8 _robotArray[32][32];
492 uint8 _foodArray[32][32];
493 uint8 _dirXY[32][32];
494 bool _visited[8][32][32];
501 int _dynamicObjectBase = 0;
504 Sound *_sound =
nullptr;
510 int _tsin = 0, _tcos = 0;
513 int _centerX, _centerY;
515 float _mouseSensitivity;
517 bool _soundOn =
true;
520 bool _cursorShoot =
false;
551 uint8 _animDisplay[6];
559 bool _gametest =
false;
560 uint32 _blackoutColor = 0;
561 uint32 _lastClickTime = 0;
562 uint32 _displayCount = 0;
563 uint32 _lastColonyThinkTime = 0;
564 uint32 _lastHotfootTime = 0;
565 uint32 _lastAnimUpdate = 0;
566 uint32 _lastWarningChimeTime = 0;
567 uint32 _lastCollisionSoundTime = 0;
568 int _action0 = 0, _action1 = 0;
570 bool _allGrow =
false;
571 bool _suppressCollisionSound =
false;
574 int _gameMode = kModeColony;
579 bool _projon =
false;
583 int _battleRound = 0;
584 Locate *_battlePwh[100] = {};
586 Locate _pyramids[4][4][15];
599 int _lastLoggedCursorMode = -1;
605 int _menuBarHeight = 0;
607 void loadMacCursorResources();
608 void handleMenuAction(
int action);
609 static void menuCommandsCallback(
int action,
Common::String &text,
void *data);
611 int _frntxWall = 0, _frntyWall = 0;
612 int _sidexWall = 0, _sideyWall = 0;
613 int _frntx = 0, _frnty = 0;
614 int _sidex = 0, _sidey = 0;
615 int _front = 0, _side = 0;
629 int _powerHeight = 0;
635 int _pictPowerID = 0;
639 uint8 wallAt(
int x,
int y)
const;
640 const uint8 *mapFeatureAt(
int x,
int y,
int direction)
const;
641 bool _visibleCell[32][32] = {};
642 void computeVisibleCells();
643 void drawStaticObjects();
648 const int (*points)[3];
650 const int (*surfaces)[8];
654 void draw3DPrism(
Thing &obj,
const PrismPartDef &def,
bool useLook,
int colorOverride = -1,
bool accumulateBounds =
false,
bool forceVisible =
false);
656 void draw3DSphere(
Thing &obj,
int pt0x,
int pt0y,
int pt0z,
657 int pt1x,
int pt1y,
int pt1z, uint32 fillColor, uint32 outlineColor,
bool accumulateBounds =
false);
658 void drawPrismOval3D(
Thing &thing,
const PrismPartDef &def,
bool useLook,
int colorOverride,
bool forceVisible =
false);
659 void drawEyeOverlays3D(
Thing &thing,
const PrismPartDef &irisDef,
int irisColorOverride,
660 const PrismPartDef &pupilDef,
int pupilColorOverride,
bool useLook);
661 float growRenderTickFraction()
const;
662 bool drawInterpolatedGrowRobot(
Thing &obj,
int eyeballColor,
int pupilColor);
664 void drawInterpolatedGrowEye(
Thing &obj,
int fromStage,
int toStage,
float progress,
int eyeballColor,
int pupilColor);
665 bool drawStaticObjectPrisms3D(
Thing &obj);
667 void renderCorridor3D();
668 void drawWallFeatures3D();
669 void drawWallFeature3D(
int cellX,
int cellY,
int direction);
670 void drawCellFeature3D(
int cellX,
int cellY);
671 void getWallFace3D(
int cellX,
int cellY,
int direction,
float corners[4][3]);
672 void getCellFace3D(
int cellX,
int cellY,
bool ceiling,
float corners[4][3]);
674 int occupiedObjectAt(
int xnew,
int ynew,
int x,
int y,
const Locate *pobject);
675 void interactWithObject(
int objNum);
690 void warpMouseLogical(
int x,
int y);
693 void setPower(
int p0,
int p1,
int p2);
695 bool isShootableRobotType(
int type)
const;
696 bool isShotBlockingObjectType(
int type)
const;
697 int findAimedObject(
const Common::Point &aim,
bool *isBlocker =
nullptr,
int *targetDist =
nullptr)
const;
698 bool hasAimedRobotTarget()
const;
699 void destroyRobot(
int num);
700 void doShootCircles(
int cx,
int cy);
701 void doBurnHole(
int cx,
int cy,
int radius);
708 void normalizeBattlePlayerPosition();
709 void enterColonyFromBattle(
int mapNum,
int xloc,
int yloc);
710 void battleCommand(
int xnew,
int ynew);
712 void battleProjCommand(
int xcheck,
int ycheck);
714 void draw3DBattlePrism(
const PrismPartDef &def,
int worldX,
int worldY, uint8 ang,
int zShift = 0);
715 void battleBackdrop();
716 void battleDrawPyramids();
717 void battleDrawTanks();
720 void resetObjectSlot(
int slot,
int type,
int xloc,
int yloc, uint8 ang);
721 bool createObject(
int type,
int xloc,
int yloc, uint8 ang);
722 void saveLevelState();
724 void saveWall(
int x,
int y,
int direction);
726 void newPatch(
int type,
const PassPatch &from,
const PassPatch &to,
const uint8 *mapdata);
727 bool patchMapTo(
const PassPatch &to, uint8 *mapdata);
728 bool patchMapFrom(
const PassPatch &from, uint8 *mapdata);
730 void dropCarriedObject();
731 bool setDoorState(
int x,
int y,
int direction,
int state);
732 int openAdjacentDoors(
int x,
int y);
733 int goToDestination(
const uint8 *map,
Locate *pobject);
734 int tryPassThroughFeature(
int fromX,
int fromY,
int direction,
Locate *pobject);
735 void playTunnelAirlockEffect();
736 void syncMacMenuChecks();
737 void updateMouseCapture(
bool recenter =
true);
739 void updateViewportLayout();
740 void drawDashboardStep1();
741 void drawDashboardMac();
742 void drawDOSBarGraph(
int x,
int y,
int height);
743 void updateDOSPowerBars();
744 static int qlog(int32 x);
745 void drawMiniMapMarker(
int x,
int y,
int halfSize, uint32 color,
bool isMac,
const Common::Rect *clip =
nullptr);
746 bool hasRobotAt(
int x,
int y)
const;
747 bool hasFoodAt(
int x,
int y)
const;
748 void drawMiniMap(uint32 lineColor);
751 void automapCellCorner(
int dx,
int dy,
int xloc,
int yloc,
int lExt,
int tsin,
int tcos,
int ccx,
int ccy,
int &sx,
int &sy);
752 void automapDrawWall(
const Common::Rect &vp,
int x1,
int y1,
int x2,
int y2, uint32 color);
753 int automapWallFeature(
int fx,
int fy,
int dir);
754 void automapDrawWallWithFeature(
const Common::Rect &vp,
int wx1,
int wy1,
int wx2,
int wy2,
int feat,
int lExt, uint32 color);
755 void drawForkliftOverlay();
756 void drawCrosshair();
757 bool clipLineToRect(
int &x1,
int &y1,
int &x2,
int &y2,
const Common::Rect &clip)
const;
758 void wallLine(
const float corners[4][3],
float u1,
float v1,
float u2,
float v2, uint32 color);
759 void wallPolygon(
const float corners[4][3],
const float *u,
const float *v,
int count, uint32 color);
760 void wallChar(
const float corners[4][3], uint8 cnum);
771 Image *_backgroundMask =
nullptr;
772 Image *_backgroundFG =
nullptr;
776 uint64 _backgroundBakedKey = 0;
779 bool _backgroundActive;
783 byte _bottomBG[8] = {};
791 byte _animPatternKeyTopBG[8] = {};
792 byte _animPatternKeyBottomBG[8] = {};
793 int16 _animPatternKeyDivide = -1;
794 uint32 _animPatternKeyTopColor = 0;
795 uint32 _animPatternKeyBotColor = 0;
796 int _animPatternKeyMode = -1;
797 bool _animPatternValid =
false;
800 bool _animationRunning;
801 int _animationResult;
804 bool _liftUp =
false;
808 int _airlockDirection = -1;
809 bool _airlockTerminate =
false;
813 bool makeBlackHole();
816 bool drawPict(
int resID);
818 void deleteAnimation();
820 void gameOver(
bool kill);
821 int countSavedCryos()
const;
822 void playAnimation();
823 void updateAnimation();
824 void drawAnimation();
825 void drawComplexSprite(
int index,
int ox,
int oy);
826 void drawAnimationImage(
Image *img,
Image *mask,
int x,
int y, uint32 fillColor,
828 uint32 resolveAnimColor(int16 bmEntry)
const;
833 void handleAnimationClick(
int item);
834 void playCollisionSound();
835 void handleDeskClick(
int item);
836 void handleVanityClick(
int item);
837 void handleSlidesClick(
int item);
838 void handleTeleshowClick(
int item);
839 void handleKeypadClick(
int item);
840 void handleSuitClick(
int item);
841 void handleDoorClick(
int item);
842 void handleAirlockClick(
int item);
843 void handleElevatorClick(
int item);
844 void handleControlsClick(
int item);
845 void dolSprite(
int index);
846 void moveObject(
int index);
847 void setObjectState(
int num,
int state);
848 int objectState(
int num)
const;
849 void setObjectOnOff(
int num,
bool on);
850 void refreshAnimationDisplay();
851 void cryptArray(uint8 sarray[6],
int i,
int j,
int k,
int l);
852 void terminateGame(
bool blowup);
856 void cubeThink(
int num);
857 void pyramidThink(
int num);
858 void upyramidThink(
int num);
859 void eyeThink(
int num);
860 void queenThink(
int num);
861 void droneThink(
int num);
862 void snoopThink(
int num);
863 void eggThink(
int num);
864 int getColonyActiveRobotLimit()
const;
865 void copyOverflowObjectToSlot(
int num);
866 bool layEgg(
int type,
int xindex,
int yindex);
867 void moveThink(
int num);
868 void bigGrow(
int num);
869 void growRobot(
int num);
870 int scanForPlayer(
int num);
871 void robotShoot(
int num);
873 void respawnObject(
int num,
int type);
Definition: managed_surface.h:51
Definition: framelimiter.h:40
Definition: macresman.h:126
EngineFeature
Definition: engine.h:258
Definition: advancedDetector.h:164
RenderMode
Definition: rendermode.h:48
Definition: macwindowmanager.h:147
Definition: atari-cursor.h:35
Definition: renderer.h:38
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: movie_decoder.h:32