mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-29 14:42:26 +00:00
- Implemented cmd_restart (for the restart functionality in Return to Zork)
svn-id: r35378
This commit is contained in:
parent
c76f0bdb10
commit
2ce4a32fb6
@ -254,6 +254,9 @@ GameDatabase::~GameDatabase() {
|
||||
|
||||
void GameDatabase::open(const char *filename) {
|
||||
debug(1, "GameDatabase::open() Loading from %s", filename);
|
||||
_isRedSource = false;
|
||||
_filename = filename;
|
||||
_redFilename = "";
|
||||
Common::File fd;
|
||||
if (!fd.open(filename))
|
||||
error("GameDatabase::open() Could not open %s", filename);
|
||||
@ -263,6 +266,9 @@ void GameDatabase::open(const char *filename) {
|
||||
|
||||
void GameDatabase::openFromRed(const char *redFilename, const char *filename) {
|
||||
debug(1, "GameDatabase::openFromRed() Loading from %s->%s", redFilename, filename);
|
||||
_isRedSource = true;
|
||||
_filename = filename;
|
||||
_redFilename = redFilename;
|
||||
Common::MemoryReadStream *fileS = RedReader::loadFromRed(redFilename, filename);
|
||||
if (!fileS)
|
||||
error("GameDatabase::openFromRed() Could not load %s from %s", filename, redFilename);
|
||||
@ -270,6 +276,21 @@ void GameDatabase::openFromRed(const char *redFilename, const char *filename) {
|
||||
delete fileS;
|
||||
}
|
||||
|
||||
void GameDatabase::reload() {
|
||||
if (!_isRedSource) {
|
||||
Common::File fd;
|
||||
if (!fd.open(_filename.c_str()))
|
||||
error("GameDatabase::reload() Could not open %s", _filename.c_str());
|
||||
reloadFromStream(fd);
|
||||
} else {
|
||||
Common::MemoryReadStream *fileS = RedReader::loadFromRed(_redFilename.c_str(), _filename.c_str());
|
||||
if (!fileS)
|
||||
error("GameDatabase::openFromRed() Could not load %s from %s", _filename.c_str(), _redFilename.c_str());
|
||||
reloadFromStream(*fileS);
|
||||
delete fileS;
|
||||
}
|
||||
}
|
||||
|
||||
int16 GameDatabase::getVar(int16 index) {
|
||||
return (int16)READ_LE_UINT16(_gameState + index * 2);
|
||||
}
|
||||
@ -391,6 +412,10 @@ void GameDatabaseV2::load(Common::SeekableReadStream &sourceS) {
|
||||
|
||||
}
|
||||
|
||||
void GameDatabaseV2::reloadFromStream(Common::SeekableReadStream &sourceS) {
|
||||
// Not used in version 2 games
|
||||
}
|
||||
|
||||
bool GameDatabaseV2::getSavegameDescription(const char *filename, Common::String &description) {
|
||||
// Not used in version 2 games
|
||||
return false;
|
||||
@ -509,16 +534,16 @@ void GameDatabaseV3::load(Common::SeekableReadStream &sourceS) {
|
||||
|
||||
uint32 objectIndexOffs = sourceS.readUint32LE();
|
||||
uint16 objectCount = sourceS.readUint16LE();
|
||||
uint32 gameStateOffs = sourceS.readUint32LE();
|
||||
_gameStateOffs = sourceS.readUint32LE();
|
||||
_gameStateSize = sourceS.readUint32LE();
|
||||
uint32 objectsOffs = sourceS.readUint32LE();
|
||||
uint32 objectsSize = sourceS.readUint32LE();
|
||||
_mainCodeObjectIndex = sourceS.readUint16LE();
|
||||
|
||||
debug(2, "objectIndexOffs = %08X; objectCount = %d; gameStateOffs = %08X; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d\n", objectIndexOffs, objectCount, gameStateOffs, _gameStateSize, objectsOffs, objectsSize);
|
||||
debug(2, "objectIndexOffs = %08X; objectCount = %d; gameStateOffs = %08X; gameStateSize = %d; objectsOffs = %08X; objectsSize = %d\n", objectIndexOffs, objectCount, _gameStateOffs, _gameStateSize, objectsOffs, objectsSize);
|
||||
|
||||
_gameState = new byte[_gameStateSize];
|
||||
sourceS.seek(gameStateOffs);
|
||||
sourceS.seek(_gameStateOffs);
|
||||
sourceS.read(_gameState, _gameStateSize);
|
||||
|
||||
Common::Array<uint32> objectOffsets;
|
||||
@ -544,6 +569,11 @@ void GameDatabaseV3::load(Common::SeekableReadStream &sourceS) {
|
||||
|
||||
}
|
||||
|
||||
void GameDatabaseV3::reloadFromStream(Common::SeekableReadStream &sourceS) {
|
||||
sourceS.seek(_gameStateOffs);
|
||||
sourceS.read(_gameState, _gameStateSize);
|
||||
}
|
||||
|
||||
bool GameDatabaseV3::getSavegameDescription(const char *filename, Common::String &description) {
|
||||
Common::InSaveFile *in;
|
||||
char desc[64];
|
||||
|
@ -116,6 +116,8 @@ public:
|
||||
void open(const char *filename);
|
||||
void openFromRed(const char *redFilename, const char *filename);
|
||||
|
||||
void reload();
|
||||
|
||||
Object *getObject(int16 index) const {
|
||||
if (index >= 1)
|
||||
return _objects[index - 1];
|
||||
@ -150,7 +152,10 @@ protected:
|
||||
byte *_gameState;
|
||||
uint32 _gameStateSize;
|
||||
int16 _mainCodeObjectIndex;
|
||||
bool _isRedSource;
|
||||
Common::String _filename, _redFilename;
|
||||
virtual void load(Common::SeekableReadStream &sourceS) = 0;
|
||||
virtual void reloadFromStream(Common::SeekableReadStream &sourceS) = 0;
|
||||
};
|
||||
|
||||
class GameDatabaseV2 : public GameDatabase {
|
||||
@ -165,6 +170,7 @@ public:
|
||||
protected:
|
||||
char *_gameText;
|
||||
void load(Common::SeekableReadStream &sourceS);
|
||||
void reloadFromStream(Common::SeekableReadStream &sourceS);
|
||||
};
|
||||
|
||||
class GameDatabaseV3 : public GameDatabase {
|
||||
@ -177,7 +183,9 @@ public:
|
||||
int16 loadgame(const char *filename, int16 version);
|
||||
protected:
|
||||
char *_gameText;
|
||||
uint32 _gameStateOffs;
|
||||
void load(Common::SeekableReadStream &sourceS);
|
||||
void reloadFromStream(Common::SeekableReadStream &sourceS);
|
||||
};
|
||||
|
||||
} // End of namespace Made
|
||||
|
@ -179,6 +179,11 @@ void MadeEngine::freeTimer(int16 timerNum) {
|
||||
_timers[timerNum - 1] = -1;
|
||||
}
|
||||
|
||||
void MadeEngine::resetAllTimers() {
|
||||
for (int i = 0; i < ARRAYSIZE(_timers); i++)
|
||||
_timers[i] = -1;
|
||||
}
|
||||
|
||||
Common::String MadeEngine::getSavegameFilename(int16 saveNum) {
|
||||
char filename[256];
|
||||
snprintf(filename, 256, "%s.%03d", getTargetName().c_str(), saveNum);
|
||||
@ -237,8 +242,7 @@ void MadeEngine::handleEvents() {
|
||||
|
||||
Common::Error MadeEngine::go() {
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(_timers); i++)
|
||||
_timers[i] = -1;
|
||||
resetAllTimers();
|
||||
|
||||
if (getGameID() == GID_RTZ) {
|
||||
_engineVersion = 3;
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
void resetTimer(int16 timerNum);
|
||||
int16 allocTimer();
|
||||
void freeTimer(int16 timerNum);
|
||||
void resetAllTimers();
|
||||
|
||||
const Common::String getTargetName() { return _targetName; }
|
||||
Common::String getSavegameFilename(int16 saveNum);
|
||||
|
@ -554,8 +554,10 @@ void ScriptInterpreter::cmd_vectorp() {
|
||||
}
|
||||
|
||||
void ScriptInterpreter::cmd_restart() {
|
||||
// TODO: Used in RTZ
|
||||
warning("Unimplemented command: cmd_restart");
|
||||
_vm->_dat->reload();
|
||||
_vm->_screen->clearChannels();
|
||||
_vm->resetAllTimers();
|
||||
_stack.setTop(0);
|
||||
}
|
||||
|
||||
void ScriptInterpreter::cmd_rand() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user