2014-07-29 21:02:28 -04: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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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.
|
2014-12-17 18:27:47 +01:00
|
|
|
*
|
2014-07-29 21:02:28 -04: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.
|
2014-12-17 18:27:47 +01:00
|
|
|
*
|
2014-07-29 21:02:28 -04:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-07-29 21:02:28 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ACCESS_ACCESS_H
|
|
|
|
#define ACCESS_ACCESS_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/random.h"
|
2014-08-30 08:45:42 -04:00
|
|
|
#include "common/savefile.h"
|
2014-08-29 21:03:11 -04:00
|
|
|
#include "common/serializer.h"
|
2014-07-29 21:02:28 -04:00
|
|
|
#include "common/util.h"
|
2020-08-04 22:31:39 +05:30
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
#include "engines/engine.h"
|
2020-08-04 22:31:39 +05:30
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
#include "graphics/surface.h"
|
2020-08-04 22:31:39 +05:30
|
|
|
|
2014-08-13 22:45:15 -04:00
|
|
|
#include "access/animation.h"
|
2014-08-17 11:14:30 -04:00
|
|
|
#include "access/bubble_box.h"
|
2014-08-23 12:09:27 -04:00
|
|
|
#include "access/char.h"
|
2014-08-05 20:59:44 -04:00
|
|
|
#include "access/data.h"
|
2014-07-29 22:49:45 -04:00
|
|
|
#include "access/events.h"
|
2014-08-02 15:14:42 -04:00
|
|
|
#include "access/files.h"
|
2014-08-24 23:59:37 -04:00
|
|
|
#include "access/font.h"
|
2014-08-09 17:57:34 -04:00
|
|
|
#include "access/inventory.h"
|
2014-08-05 22:17:30 -04:00
|
|
|
#include "access/player.h"
|
2015-11-27 12:12:32 -05:00
|
|
|
#include "access/resources.h"
|
2014-08-05 22:17:30 -04:00
|
|
|
#include "access/room.h"
|
2014-08-02 10:07:54 -04:00
|
|
|
#include "access/screen.h"
|
2014-08-05 23:23:49 -04:00
|
|
|
#include "access/scripts.h"
|
2014-08-02 15:14:42 -04:00
|
|
|
#include "access/sound.h"
|
2014-08-23 14:13:26 -04:00
|
|
|
#include "access/video.h"
|
2020-08-26 16:41:04 +05:30
|
|
|
#include "access/detection.h"
|
2014-07-29 21:02:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the namespace of the Access engine.
|
|
|
|
*
|
|
|
|
* Status of this engine: In Development
|
|
|
|
*
|
|
|
|
* Games using this engine:
|
|
|
|
* - Amazon: Guardians of Eden
|
|
|
|
*/
|
|
|
|
namespace Access {
|
|
|
|
|
|
|
|
enum AccessDebugChannels {
|
|
|
|
kDebugPath = 1 << 0,
|
|
|
|
kDebugScripts = 1 << 1,
|
2014-12-07 22:28:03 +01:00
|
|
|
kDebugGraphics = 1 << 2,
|
|
|
|
kDebugSound = 1 << 3
|
2014-07-29 21:02:28 -04:00
|
|
|
};
|
|
|
|
|
2014-08-23 23:49:08 +02:00
|
|
|
extern const char *const _estTable[];
|
|
|
|
|
2014-08-30 08:45:42 -04:00
|
|
|
#define ACCESS_SAVEGAME_VERSION 1
|
|
|
|
|
|
|
|
struct AccessSavegameHeader {
|
|
|
|
uint8 _version;
|
|
|
|
Common::String _saveName;
|
|
|
|
Graphics::Surface *_thumbnail;
|
|
|
|
int _year, _month, _day;
|
|
|
|
int _hour, _minute;
|
|
|
|
int _totalFrames;
|
|
|
|
};
|
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
class AccessEngine : public Engine {
|
|
|
|
private:
|
2014-08-20 01:46:46 +02:00
|
|
|
uint32 _lastTime, _curTime;
|
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
/**
|
2014-08-25 23:44:55 +02:00
|
|
|
* Handles basic initialization
|
2014-07-29 21:02:28 -04:00
|
|
|
*/
|
|
|
|
void initialize();
|
2014-08-01 16:20:24 -04:00
|
|
|
|
2014-08-01 21:32:05 -04:00
|
|
|
/**
|
|
|
|
* Set VGA mode
|
|
|
|
*/
|
|
|
|
void setVGA();
|
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
protected:
|
2014-08-01 21:32:05 -04:00
|
|
|
const AccessGameDescription *_gameDescription;
|
|
|
|
Common::RandomSource _randomSource;
|
2014-08-30 10:57:45 -04:00
|
|
|
int _loadSaveSlot;
|
2014-08-01 21:32:05 -04:00
|
|
|
|
2014-08-05 20:59:44 -04:00
|
|
|
/**
|
|
|
|
* Main handler for showing game rooms
|
|
|
|
*/
|
|
|
|
void doRoom();
|
|
|
|
|
2014-10-31 23:01:47 -04:00
|
|
|
/**
|
|
|
|
* Play back an entire video
|
|
|
|
*/
|
2014-11-01 16:07:52 -04:00
|
|
|
void playVideo(int videoNum, const Common::Point &pt);
|
2014-10-31 23:01:47 -04:00
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
// Engine APIs
|
2020-02-09 12:05:26 +01:00
|
|
|
Common::Error run() override;
|
|
|
|
bool hasFeature(EngineFeature f) const override;
|
2014-08-02 10:07:54 -04:00
|
|
|
protected:
|
|
|
|
/**
|
2014-08-04 21:35:49 -04:00
|
|
|
* Play the game
|
2014-08-02 10:07:54 -04:00
|
|
|
*/
|
2014-08-04 21:35:49 -04:00
|
|
|
virtual void playGame() = 0;
|
2014-08-29 21:03:11 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronize savegame data
|
|
|
|
*/
|
|
|
|
virtual void synchronize(Common::Serializer &s);
|
2014-07-29 21:02:28 -04:00
|
|
|
public:
|
2014-08-09 15:54:35 -04:00
|
|
|
AnimationManager *_animation;
|
2014-08-17 11:14:30 -04:00
|
|
|
BubbleBox *_bubbleBox;
|
2015-01-09 08:20:59 +01:00
|
|
|
BubbleBox *_helpBox;
|
|
|
|
BubbleBox *_travelBox;
|
|
|
|
BubbleBox *_invBox;
|
|
|
|
BubbleBox *_aboutBox;
|
2014-08-23 12:09:27 -04:00
|
|
|
CharManager *_char;
|
2014-07-29 22:49:45 -04:00
|
|
|
EventsManager *_events;
|
2014-08-02 15:14:42 -04:00
|
|
|
FileManager *_files;
|
2014-08-09 17:57:34 -04:00
|
|
|
InventoryManager *_inventory;
|
2014-08-05 22:17:30 -04:00
|
|
|
Player *_player;
|
2015-11-27 12:12:32 -05:00
|
|
|
Resources *_res;
|
2014-08-05 22:17:30 -04:00
|
|
|
Room *_room;
|
2014-08-02 10:07:54 -04:00
|
|
|
Screen *_screen;
|
2014-08-05 23:23:49 -04:00
|
|
|
Scripts *_scripts;
|
2014-08-02 15:14:42 -04:00
|
|
|
SoundManager *_sound;
|
2014-12-01 07:49:26 +01:00
|
|
|
MusicManager *_midi;
|
2014-08-23 14:13:26 -04:00
|
|
|
VideoPlayer *_video;
|
2014-08-04 09:21:39 -04:00
|
|
|
|
2016-05-26 21:21:03 -04:00
|
|
|
BaseSurface *_destIn;
|
|
|
|
BaseSurface *_current;
|
2014-08-06 22:43:40 -04:00
|
|
|
ASurface _buffer1;
|
|
|
|
ASurface _buffer2;
|
2014-11-23 22:21:48 +01:00
|
|
|
ASurface _vidBuf;
|
|
|
|
int _vidX, _vidY;
|
2014-08-23 12:09:27 -04:00
|
|
|
Common::Array<CharEntry *> _charTable;
|
2014-08-10 11:56:14 -04:00
|
|
|
SpriteResource *_objectsTable[100];
|
2014-08-23 13:13:56 -04:00
|
|
|
bool _establishTable[100];
|
2014-08-06 22:43:40 -04:00
|
|
|
bool _establishFlag;
|
|
|
|
int _establishMode;
|
|
|
|
int _establishGroup;
|
2014-08-23 23:49:08 +02:00
|
|
|
int _establishCtrlTblOfs;
|
2014-08-05 22:17:30 -04:00
|
|
|
int _numAnimTimers;
|
2014-08-16 10:33:03 -04:00
|
|
|
TimerList _timers;
|
2014-08-30 17:17:19 -04:00
|
|
|
DeathList _deaths;
|
2014-08-16 22:18:53 -04:00
|
|
|
FontManager _fonts;
|
2014-08-12 08:38:12 -04:00
|
|
|
Common::Array<Common::Rect> _newRects;
|
|
|
|
Common::Array<Common::Rect> _oldRects;
|
2014-08-06 22:43:40 -04:00
|
|
|
Common::Array<ExtraCell> _extraCells;
|
2014-08-14 22:02:47 -04:00
|
|
|
ImageEntryList _images;
|
2014-08-05 20:59:44 -04:00
|
|
|
int _mouseMode;
|
2014-08-04 09:21:39 -04:00
|
|
|
|
2014-12-29 07:22:51 +01:00
|
|
|
int _playerDataCount;
|
2014-08-04 22:38:50 -04:00
|
|
|
int _currentManOld;
|
|
|
|
int _converseMode;
|
2014-08-05 23:23:49 -04:00
|
|
|
bool _currentCharFlag;
|
|
|
|
bool _boxSelect;
|
2014-08-07 09:23:31 -04:00
|
|
|
int _scale;
|
2014-08-06 22:43:40 -04:00
|
|
|
int _scaleH1, _scaleH2;
|
|
|
|
int _scaleN1;
|
|
|
|
int _scaleT1;
|
|
|
|
int _scaleMaxY;
|
|
|
|
int _scaleI;
|
2014-12-18 21:45:55 -05:00
|
|
|
int _scrollX, _scrollY;
|
|
|
|
int _scrollCol, _scrollRow;
|
2014-11-22 22:17:39 -05:00
|
|
|
bool _imgUnscaled;
|
2014-08-30 09:57:51 -04:00
|
|
|
bool _canSaveLoad;
|
2014-08-04 22:38:50 -04:00
|
|
|
|
2014-12-01 07:59:42 +01:00
|
|
|
Resource *_establish;
|
2014-08-21 00:32:11 +02:00
|
|
|
int _printEnd;
|
|
|
|
int _txtPages;
|
2014-08-23 23:49:08 +02:00
|
|
|
int _narateFile;
|
|
|
|
int _sndSubFile;
|
|
|
|
int _countTbl[6];
|
2014-08-21 00:32:11 +02:00
|
|
|
|
2014-08-05 20:04:41 -04:00
|
|
|
// Fields that are included in savegames
|
|
|
|
int _conversation;
|
|
|
|
int _currentMan;
|
|
|
|
uint32 _newTime;
|
|
|
|
uint32 _newDate;
|
2014-08-09 18:28:33 -04:00
|
|
|
int _flags[256];
|
|
|
|
|
2015-01-12 00:04:38 +01:00
|
|
|
// Fields used by MM
|
|
|
|
// TODO: Refactor
|
2015-07-24 23:03:22 +03:00
|
|
|
int _travel[60];
|
|
|
|
int _ask[40];
|
|
|
|
int _startTravelItem;
|
|
|
|
int _startTravelBox;
|
2015-01-05 22:43:21 +01:00
|
|
|
int _startAboutItem;
|
2015-01-12 00:04:38 +01:00
|
|
|
int _startAboutBox;
|
2015-07-24 23:03:22 +03:00
|
|
|
int _boxDataStart;
|
|
|
|
bool _boxDataEnd;
|
|
|
|
int _boxSelectY;
|
|
|
|
int _boxSelectYOld;
|
|
|
|
int _numLines;
|
2015-01-12 00:23:28 +01:00
|
|
|
byte _byte26CB5;
|
2015-07-24 23:03:22 +03:00
|
|
|
int _bcnt;
|
|
|
|
byte *_tempList;
|
2015-02-04 22:22:50 +01:00
|
|
|
int _pictureTaken;
|
2015-01-12 00:04:38 +01:00
|
|
|
//
|
2015-01-06 00:40:13 +01:00
|
|
|
|
2015-01-05 22:43:21 +01:00
|
|
|
bool _vidEnd;
|
2014-08-26 23:55:17 +02:00
|
|
|
bool _clearSummaryFlag;
|
2014-12-07 19:53:19 +01:00
|
|
|
bool _cheatFl;
|
2014-12-10 23:25:18 +01:00
|
|
|
bool _restartFl;
|
2014-08-09 18:28:33 -04:00
|
|
|
// Fields mapped into the flags array
|
|
|
|
int &_useItem;
|
|
|
|
int &_startup;
|
|
|
|
int &_manScaleOff;
|
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
public:
|
|
|
|
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
|
2020-02-09 12:05:26 +01:00
|
|
|
~AccessEngine() override;
|
2014-07-29 21:02:28 -04:00
|
|
|
|
2014-11-28 21:02:12 -05:00
|
|
|
virtual void dead(int deathId) = 0;
|
|
|
|
|
2014-07-29 21:02:28 -04:00
|
|
|
uint32 getFeatures() const;
|
2014-08-09 12:12:39 -04:00
|
|
|
bool isCD() const;
|
2014-12-02 16:29:42 +01:00
|
|
|
bool isDemo() const;
|
2014-07-29 21:02:28 -04:00
|
|
|
Common::Language getLanguage() const;
|
|
|
|
Common::Platform getPlatform() const;
|
|
|
|
uint16 getVersion() const;
|
|
|
|
uint32 getGameID() const;
|
|
|
|
uint32 getGameFeatures() const;
|
2014-12-10 23:25:18 +01:00
|
|
|
bool shouldQuitOrRestart();
|
2014-07-29 21:02:28 -04:00
|
|
|
|
|
|
|
int getRandomNumber(int maxNumber);
|
2014-08-06 08:28:20 -04:00
|
|
|
|
2014-08-23 12:09:27 -04:00
|
|
|
void loadCells(Common::Array<CellIdent> &cells);
|
2014-08-06 22:43:40 -04:00
|
|
|
|
2014-08-06 08:28:20 -04:00
|
|
|
/**
|
2014-08-13 22:45:15 -04:00
|
|
|
* Free the sprites list
|
2014-08-06 08:28:20 -04:00
|
|
|
*/
|
|
|
|
void freeCells();
|
|
|
|
|
2014-08-26 23:55:17 +02:00
|
|
|
virtual void establish(int esatabIndex, int sub) = 0;
|
2014-08-11 23:12:53 -04:00
|
|
|
|
|
|
|
void plotList();
|
|
|
|
void plotList1();
|
2014-08-12 08:38:12 -04:00
|
|
|
|
|
|
|
void copyBlocks();
|
2014-08-12 21:40:14 -04:00
|
|
|
|
|
|
|
void copyRects();
|
2014-08-12 23:34:23 -04:00
|
|
|
|
|
|
|
void copyBF1BF2();
|
|
|
|
|
|
|
|
void copyBF2Vid();
|
2014-08-16 09:35:38 -04:00
|
|
|
|
2014-08-19 20:43:32 -04:00
|
|
|
void freeChar();
|
2014-08-30 08:45:42 -04:00
|
|
|
|
2014-08-31 02:18:02 +02:00
|
|
|
/**
|
|
|
|
* Draw a string on a given surface and update text positioning
|
|
|
|
*/
|
2016-05-26 21:21:03 -04:00
|
|
|
void printText(BaseSurface *s, const Common::String &msg);
|
|
|
|
void speakText(BaseSurface *s, const Common::String &msg);
|
2014-08-31 02:18:02 +02:00
|
|
|
|
2014-08-30 09:57:51 -04:00
|
|
|
/**
|
|
|
|
* Load a savegame
|
|
|
|
*/
|
2020-02-09 12:05:26 +01:00
|
|
|
Common::Error loadGameState(int slot) override;
|
2014-08-30 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the game
|
|
|
|
*/
|
2020-02-04 22:13:33 -08:00
|
|
|
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
|
2014-08-30 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if a savegame can currently be loaded
|
|
|
|
*/
|
2020-02-05 14:34:33 +01:00
|
|
|
bool canLoadGameStateCurrently() override;
|
2014-08-30 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the game can currently be saved
|
|
|
|
*/
|
2020-02-05 14:34:33 +01:00
|
|
|
bool canSaveGameStateCurrently() override;
|
2014-08-30 09:57:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read in a savegame header
|
|
|
|
*/
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
|
2014-08-30 08:45:42 -04:00
|
|
|
|
2014-08-30 09:57:51 -04:00
|
|
|
/**
|
|
|
|
* Write out a savegame header
|
|
|
|
*/
|
2014-08-30 08:45:42 -04:00
|
|
|
void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
|
2015-02-06 08:25:22 +01:00
|
|
|
|
|
|
|
void SPRINTCHR(char c, int fontNum);
|
|
|
|
void PRINTCHR(Common::String msg, int fontNum);
|
2015-11-24 15:42:17 +01:00
|
|
|
|
|
|
|
bool playMovie(const Common::String &filename, const Common::Point &pos);
|
2014-07-29 21:02:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Access
|
|
|
|
|
|
|
|
#endif /* ACCESS_ACCESS_H */
|