scummvm/engines/director/director.h

356 lines
9.3 KiB
C
Raw Normal View History

2012-11-13 20:23:11 -05:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2016-09-03 12:46:38 +02:00
*
2012-11-13 20:23:11 -05:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2016-09-03 12:46:38 +02:00
*
2012-11-13 20:23:11 -05:00
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2012-11-13 20:23:11 -05:00
*
*/
#ifndef DIRECTOR_DIRECTOR_H
#define DIRECTOR_DIRECTOR_H
2020-08-05 11:00:42 -04:00
#include "common/file.h"
#include "common/hashmap.h"
#include "common/hash-ptr.h"
#include "common/hash-str.h"
#include "common/rect.h"
#include "common/str-array.h"
#include "engines/engine.h"
#include "graphics/pixelformat.h"
#include "graphics/macgui/macwindowmanager.h"
#include "director/types.h"
#include "director/util.h"
#include "director/debugger.h"
#include "director/detection.h"
2012-11-13 20:23:11 -05:00
namespace Common {
class MacResManager;
class SeekableReadStream;
class SeekableReadStreamEndian;
}
namespace Graphics {
class MacWindowManager;
struct MacPlotData;
struct WinCursorGroup;
typedef Common::Array<byte *> MacPatterns;
2020-07-01 17:18:11 +02:00
class ManagedSurface;
}
2012-11-13 20:23:11 -05:00
namespace Director {
2012-11-14 11:16:35 -05:00
class Archive;
class MacArchive;
class Cast;
2016-08-23 13:30:00 +02:00
class DirectorSound;
class Lingo;
class Movie;
class Window;
class Score;
class Channel;
class CastMember;
class Stxt;
2012-11-13 20:23:11 -05:00
2016-08-21 10:39:30 +02:00
enum {
kDebugLingoExec = 1 << 0,
kDebugCompile = 1 << 1,
kDebugLoading = 1 << 2,
kDebugImages = 1 << 3,
kDebugText = 1 << 4,
kDebugEvents = 1 << 5,
kDebugParse = 1 << 6,
kDebugCompileOnly = 1 << 7,
kDebugSlow = 1 << 8,
kDebugFast = 1 << 9,
kDebugNoLoop = 1 << 10,
kDebugNoBytecode = 1 << 11,
kDebugFewFramesOnly = 1 << 12,
kDebugPreprocess = 1 << 13,
2020-07-03 11:02:10 -04:00
kDebugScreenshot = 1 << 14,
kDebugDesktop = 1 << 15,
kDebug32bpp = 1 << 16,
kDebugEndVideo = 1 << 17,
kDebugLingoStrict = 1 << 18,
kDebugSound = 1 << 19,
2022-10-09 21:13:07 +08:00
kDebugConsole = 1 << 20,
kDebugXObj = 1 << 21,
2016-08-21 10:39:30 +02:00
};
struct MovieReference {
Common::String movie;
Common::String frameS;
int frameI;
MovieReference() { frameI = -1; }
};
struct StartMovie {
Common::String startMovie;
int16 startFrame;
};
struct StartOptions {
StartMovie startMovie;
Common::String startupPath;
};
struct PaletteV4 {
CastMemberID id;
byte *palette;
int length;
PaletteV4(CastMemberID i, byte *p, int l) : id(i), palette(p), length(l) {}
PaletteV4() : id(), palette(nullptr), length(0) {}
};
2016-08-21 10:39:30 +02:00
struct MacShape {
InkType ink;
byte spriteType;
2020-08-16 00:20:28 +02:00
uint32 foreColor;
uint32 backColor;
int lineSize;
uint pattern;
Picture *tile;
const Common::Rect *tileRect;
Graphics::MacPlotData *pd;
};
struct PatternTile {
Picture *img = nullptr;
Common::Rect rect;
2022-08-28 21:34:41 +08:00
~PatternTile();
};
const int SCALE_THRESHOLD = 0x100;
2012-11-13 20:23:11 -05:00
class DirectorEngine : public ::Engine {
public:
DirectorEngine(OSystem *syst, const DirectorGameDescription *gameDesc);
2020-02-09 12:05:28 +01:00
~DirectorEngine() override;
2012-11-13 20:23:11 -05:00
// Detection related functions
DirectorGameGID getGameGID() const;
const char *getGameId() const;
uint16 getDescriptionVersion() const;
uint16 getVersion() const { return _version; }
void setVersion(uint16 version);
2012-11-13 20:23:11 -05:00
Common::Platform getPlatform() const;
Common::Language getLanguage() const;
Common::String getTargetName() { return _targetName; }
const char *getExtra();
2012-11-14 11:16:35 -05:00
Common::String getEXEName() const;
StartMovie getStartMovie() const;
void parseOptions();
Graphics::MacWindowManager *getMacWindowManager() const { return _wm; }
Archive *getMainArchive() const;
Lingo *getLingo() const { return _lingo; }
Window *getStage() const { return _stage; }
Window *getCurrentWindow() const { return _currentWindow; }
void setCurrentWindow(Window *window) { _currentWindow = window; };
Window *getCursorWindow() const { return _cursorWindow; }
void setCursorWindow(Window *window) { _cursorWindow = window; }
Movie *getCurrentMovie() const;
2020-07-23 18:49:21 -04:00
void setCurrentMovie(Movie *movie);
Common::String getCurrentPath() const;
Common::String getCurrentAbsolutePath();
Common::String getStartupPath() const;
// graphics.cpp
bool hasFeature(EngineFeature f) const override;
void addPalette(CastMemberID &id, byte *palette, int length);
bool setPalette(const CastMemberID &id);
void setPalette(byte *palette, uint16 count);
2022-08-29 00:52:29 +08:00
void shiftPalette(int startIndex, int endIndex, bool reverse);
void clearPalettes();
PaletteV4 *getPalette(const CastMemberID &id);
void loadDefaultPalettes();
const Common::HashMap<CastMemberID, PaletteV4> &getLoadedPalettes() { return _loadedPalettes; }
const Common::HashMap<CastMemberID, PaletteV4> &getLoaded16Palettes() { return _loaded16Palettes; }
const PaletteV4 &getLoaded4Palette() { return _loaded4Palette; }
2020-08-05 11:00:42 -04:00
const Common::FSNode *getGameDataDir() const { return &_gameDataDir; }
const byte *getPalette() const { return _currentPalette; }
uint16 getPaletteColorCount() const { return _currentPaletteLength; }
void loadPatterns();
Picture *getTile(int num);
const Common::Rect &getTileRect(int num);
uint32 transformColor(uint32 color);
Graphics::MacPatterns &getPatterns();
void setCursor(DirectorCursor type);
void draw();
Graphics::MacDrawPixPtr getInkDrawPixel();
2020-06-16 22:43:12 -04:00
void loadKeyCodes();
void setMachineType(int machineType);
Common::CodePage getPlatformEncoding();
2016-08-29 18:06:41 +02:00
Archive *createArchive();
2022-07-03 10:56:30 -07:00
bool desktopEnabled();
// events.cpp
bool processEvents(bool captureClick = false);
void processEventQUIT();
uint32 getMacTicks();
// game-quirks.cpp
void gameQuirks(const char *target, Common::Platform platform);
void delayMillis(uint32 delay);
public:
RandomState _rnd;
Graphics::MacWindowManager *_wm;
Graphics::PixelFormat _pixelformat;
2016-06-27 21:11:26 +03:00
uint32 _debugDraw = 0;
public:
int _colorDepth;
Common::HashMap<int, int> _KeyCodes;
int _machineType;
bool _playbackPaused;
bool _skipFrameAdvance;
2020-08-06 12:36:38 -04:00
bool _centerStage;
char _dirSeparator;
bool _fixStageSize;
Common::Rect _fixStageRect;
Common::List<Common::String> _extraSearchPath;
Common::HashMap<Common::String, Archive *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _allOpenResFiles;
// Opened Resource Files that were opened by OpenResFile
Common::HashMap<Common::String, MacArchive *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _openResFiles;
Common::Array<Graphics::WinCursorGroup *> _winCursor;
2012-11-13 20:23:11 -05:00
protected:
2020-02-09 12:05:28 +01:00
Common::Error run() override;
2012-11-13 20:23:11 -05:00
public:
2012-11-13 20:23:11 -05:00
const DirectorGameDescription *_gameDescription;
2020-08-05 11:00:42 -04:00
Common::FSNode _gameDataDir;
CastMemberID *_clipBoard;
uint32 _wmMode;
uint16 _wmWidth;
uint16 _wmHeight;
byte _fpsLimit;
2012-11-14 11:16:35 -05:00
private:
byte _currentPalette[768];
uint16 _currentPaletteLength;
Lingo *_lingo;
uint16 _version;
2016-09-01 10:52:11 +02:00
Window *_stage;
2020-07-08 14:06:37 -04:00
Datum *_windowList; // Lingo list
Window *_currentWindow;
Window *_cursorWindow;
Graphics::MacPatterns _director3Patterns;
Graphics::MacPatterns _director3QuickDrawPatterns;
PatternTile _builtinTiles[kNumBuiltinTiles];
Common::HashMap<CastMemberID, PaletteV4> _loadedPalettes;
Common::HashMap<CastMemberID, PaletteV4> _loaded16Palettes;
PaletteV4 _loaded4Palette;
Graphics::ManagedSurface *_surface;
StartOptions _options;
public:
int _tickBaseline;
Common::String _traceLogFile;
uint16 _framesRan = 0; // used by kDebugFewFramesOnly
2012-11-13 20:23:11 -05:00
};
2022-06-12 15:52:29 +02:00
// An extension of MacPlotData for interfacing with inks and patterns without
// needing extra surfaces.
struct DirectorPlotData {
DirectorEngine *d = nullptr;
Graphics::ManagedSurface *dst = nullptr;
2022-06-12 15:52:29 +02:00
Common::Rect destRect;
Common::Point srcPoint;
Graphics::ManagedSurface *srf = nullptr;
MacShape *ms = nullptr;
2022-06-12 15:52:29 +02:00
SpriteType sprite = kInactiveSprite;
bool oneBitImage = false;
InkType ink = kInkTypeCopy;
2022-06-12 15:52:29 +02:00
uint32 colorWhite;
uint32 colorBlack;
int alpha = 0;
2022-06-12 15:52:29 +02:00
uint32 backColor;
uint32 foreColor;
bool applyColor = false;
2022-06-12 15:52:29 +02:00
// graphics.cpp
void setApplyColor();
uint32 preprocessColor(uint32 src);
void inkBlitShape(Common::Rect &srcRect);
void inkBlitSurface(Common::Rect &srcRect, const Graphics::Surface *mask);
void inkBlitStretchSurface(Common::Rect &srcRect, const Graphics::Surface *mask);
DirectorPlotData(DirectorEngine *d_, SpriteType s, InkType i, int a, uint32 b, uint32 f) : d(d_), sprite(s), ink(i), alpha(a), backColor(b), foreColor(f) {
colorWhite = d->_wm->_colorWhite;
colorBlack = d->_wm->_colorBlack;
}
DirectorPlotData(const DirectorPlotData &old) : d(old.d), sprite(old.sprite),
ink(old.ink), alpha(old.alpha),
backColor(old.backColor), foreColor(old.foreColor),
srf(old.srf), dst(old.dst),
destRect(old.destRect), srcPoint(old.srcPoint),
colorWhite(old.colorWhite), colorBlack(old.colorBlack),
applyColor(old.applyColor) {
if (old.ms) {
ms = new MacShape(*old.ms);
} else {
ms = nullptr;
}
}
DirectorPlotData &operator=(const DirectorPlotData &);
~DirectorPlotData() {
delete ms;
}
};
2017-01-08 09:32:32 +01:00
extern DirectorEngine *g_director;
extern Debugger *g_debugger;
2017-01-08 09:32:32 +01:00
2012-11-13 20:23:11 -05:00
} // End of namespace Director
#endif