scummvm/engines/chewy/chewy.cpp

148 lines
3.8 KiB
C++
Raw Normal View History

2016-03-16 17:36:48 +00: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-03-16 17:36:48 +00: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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2016-03-16 17:36:48 +00:00
*
*/
#include "common/config-manager.h"
#include "common/fs.h"
2019-11-04 21:24:37 +00:00
#include "common/system.h"
2016-03-16 17:36:48 +00:00
#include "engines/util.h"
#include "chewy/chewy.h"
2021-09-19 04:24:36 +00:00
#include "chewy/events.h"
2021-11-15 00:02:05 +00:00
#include "chewy/global.h"
2019-11-04 21:24:37 +00:00
#include "chewy/main.h"
#include "chewy/resource.h"
#include "chewy/sound.h"
2016-03-16 17:36:48 +00:00
namespace Chewy {
ChewyEngine *g_engine;
Graphics::Screen *g_screen;
2016-03-16 17:36:48 +00:00
ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc)
: Engine(syst),
_gameDescription(gameDesc),
_rnd("chewy") {
g_engine = this;
g_screen = nullptr;
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "back");
SearchMan.addSubDirectoryMatching(gameDataDir, "cut");
SearchMan.addSubDirectoryMatching(gameDataDir, "err");
SearchMan.addSubDirectoryMatching(gameDataDir, "misc");
SearchMan.addSubDirectoryMatching(gameDataDir, "room");
SearchMan.addSubDirectoryMatching(gameDataDir, "sound");
SearchMan.addSubDirectoryMatching(gameDataDir, "txt");
2016-03-16 17:36:48 +00:00
}
ChewyEngine::~ChewyEngine() {
2021-09-19 04:24:36 +00:00
delete _events;
2021-11-15 00:02:05 +00:00
delete _globals;
delete _screen;
2019-11-04 21:24:37 +00:00
delete _sound;
g_engine = nullptr;
g_screen = nullptr;
}
void ChewyEngine::initialize() {
g_screen = _screen = new Graphics::Screen();
_events = new EventsManager(_screen);
2021-11-15 00:02:05 +00:00
_globals = new Globals();
2019-11-04 21:24:37 +00:00
_sound = new Sound(_mixer);
_tempFiles.add(ADSH_TMP);
SearchMan.add("temp", &_tempFiles, 99, false);
2016-03-16 17:36:48 +00:00
}
Common::Error ChewyEngine::run() {
// Initialize backend
//initGraphics(640, 480);
initGraphics(320, 200);
2016-03-16 17:36:48 +00:00
initialize();
2019-11-04 21:24:37 +00:00
game_main();
2016-03-16 17:36:48 +00:00
return Common::kNoError;
}
Common::Error ChewyEngine::loadGameStream(Common::SeekableReadStream *stream) {
exit_room(-1);
Common::Serializer s(stream, nullptr);
if (!spieler.synchronize(s)) {
fcode = READFEHLER;
modul = DATEI;
2021-10-24 17:49:17 +00:00
return Common::kReadingFailed;
} else {
flags.LoadGame = true;
ERROR
2021-10-24 17:49:17 +00:00
if (spieler.inv_cur == true && spieler.AkInvent != -1) {
menu_item = CUR_USE;
}
if (spieler.AkInvent != -1)
spieler.room_m_obj[spieler.AkInvent].RoomNr = -1;
room->load_room(&room_blk, spieler.PersonRoomNr[P_CHEWY], &spieler);
ERROR
2021-10-24 17:49:17 +00:00
load_chewy_taf(spieler.ChewyAni);
2021-10-27 05:26:06 +00:00
fx_blend = BLEND1;
room->calc_invent(&room_blk, &spieler);
if (spieler.AkInvent != -1)
spieler.room_m_obj[spieler.AkInvent].RoomNr = 255;
obj->sort();
set_speed();
for (int i = 0; i < MAX_PERSON; i++) {
set_person_pos(spieler.X[i], spieler.Y[i], i, spieler.Phase[i]);
}
2021-11-15 00:02:05 +00:00
_G(auto_obj) = 0;
enter_room(-1);
flags.LoadGame = false;
2021-10-24 17:49:17 +00:00
return Common::kNoError;
}
}
Common::Error ChewyEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
Common::Serializer s(nullptr, stream);
int16 spr_nr;
int16 i;
spr_nr = chewy_ph[spieler_vector[P_CHEWY].Phase * 8 + spieler_vector[P_CHEWY].PhNr];
for (i = 0; i < MAX_PERSON; i++) {
spieler.X[i] = spieler_vector[i].Xypos[0];
spieler.Y[i] = spieler_vector[i].Xypos[1];
spieler.Phase[i] = person_end_phase[i];
}
2021-10-24 17:49:17 +00:00
return spieler.synchronize(s) ? Common::kNoError :
Common::kWritingFailed;
}
2016-03-16 17:36:48 +00:00
} // End of namespace Chewy