Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

1
engines/kingdom/POTFILES Normal file
View File

@@ -0,0 +1 @@
engines/kingdom/kingdom.cpp

View File

@@ -0,0 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine kingdom "Kingdom: The Far Reaches" yes "" "" ""

View File

@@ -0,0 +1,39 @@
/* 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.
*
* 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/>.
*
*/
#include "gui/debugger.h"
#include "kingdom/console.h"
#include "kingdom/kingdom.h"
namespace Kingdom {
Console::Console(Kingdom::KingdomGame *vm) : _vm(vm) {
registerCmd("showHotspots", WRAP_METHOD(Console, Cmd_showHotspots));
}
bool Console::Cmd_showHotspots(int argc, const char **argv){
_vm->_showHotspots ^= true;
return false;
}
} // End of namespace Kingdom

43
engines/kingdom/console.h Normal file
View File

@@ -0,0 +1,43 @@
/* 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.
*
* 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/>.
*
*/
#ifndef KINGDOM_CONSOLE_H
#define KINGDOM_CONSOLE_H
#include "gui/debugger.h"
namespace Kingdom {
class KingdomGame;
class Console : public GUI::Debugger {
private:
KingdomGame *_vm;
public:
explicit Console(Kingdom::KingdomGame *vm);
virtual ~Console(void) {}
bool Cmd_showHotspots(int argc, const char **argv);
};
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
begin_section("Kingdom");
add_person("Arnaud Boutonn&eacute;", "Strangerke", "");
add_person("Thomas Fach-Pedersen", "madmoose", "");
add_person("Hein-Pieter van Braam-Stewart", "TMM", "");
end_section();

View File

@@ -0,0 +1,104 @@
/* 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.
*
* 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/>.
*
*/
#include "base/plugins.h"
#include "engines/advancedDetector.h"
#include "common/file.h"
#include "kingdom/kingdom.h"
static const PlainGameDescriptor kingdomGames[] = {
{"kingdom", "Kingdom: The Far Reaches"},
{nullptr, nullptr}
};
namespace Kingdom {
static const ADGameDescription gameDescriptions[] = {
// Kingdom PC DOS Demo version, provided by Strangerke
{
"kingdom",
"Demo",
AD_ENTRY1s("KINGDEMO.EXE", "2ce478fc13086d0ddb02a2867ba307dc", 167154),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_DEMO,
GUIO0()
},
// Kingdom PC DOS version v1.26 EN, provided by Strangerke
// Also detects the GOG.COM version
{
"kingdom",
nullptr,
AD_ENTRY1s("KINGDOM.EXE", "64d3e03b963396ced402f3dc958765c0", 199693),
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
},
// Kingdom 3DO, provided by Strangerke
{
"kingdom",
nullptr,
AD_ENTRY1s("launchme", "60d2c64e3cb3e22859c4fadbc121b0db", 183452),
Common::EN_ANY,
Common::kPlatform3DO,
ADGF_UNSTABLE,
GUIO0()
},
// Kingdom PC Win version v1.0 EN, provided by Strangerke
{
"kingdom",
nullptr,
AD_ENTRY1s("REACHES.EXE", "37ba9463795c882e8ec7aef36a00152e", 207360),
Common::EN_ANY,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO0()
},
AD_TABLE_END_MARKER};
} // End of namespace Kingdom
class KingdomMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
public:
KingdomMetaEngineDetection() : AdvancedMetaEngineDetection(Kingdom::gameDescriptions, kingdomGames) {
}
const char *getName() const override {
return "kingdom";
}
const char *getEngineName() const override {
return "Kingdom: The Far Reaches' Engine";
}
const char *getOriginalCopyright() const override {
return "Kingdom: The far Reaches (C) 1995 Virtual Image Productions";
}
};
REGISTER_PLUGIN_STATIC(KINGDOM_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, KingdomMetaEngineDetection);

1708
engines/kingdom/kingdom.cpp Normal file

File diff suppressed because it is too large Load Diff

240
engines/kingdom/kingdom.h Normal file
View File

@@ -0,0 +1,240 @@
/* 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.
*
* 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/>.
*
*/
#ifndef KINGDOM_KINGDOM_H
#define KINGDOM_KINGDOM_H
#include "common/system.h"
#include "common/scummsys.h"
#include "common/random.h"
#include "engines/advancedDetector.h"
#include "common/error.h"
#include "engines/engine.h"
#include "audio/mixer.h"
#include "common/file.h"
#include "graphics/screen.h"
#include "graphics/surface.h"
#include "common/serializer.h"
#include "kingdom/console.h"
#include "kingdom/logic.h"
namespace Kingdom {
struct KingArtEntry {
uint8 _width;
uint8 _height;
byte* _data;
};
struct HotSpot {
uint16 x1, y1, x2, y2;
int16 _mouseValue;
bool contains(const Common::Point &p) const {
return (x1 <= p.x) && (p.x < x2) && (y1 <= p.y) && (p.y < y2);
}
bool dummy() const {
return !(x1 || x2 || y1 || y2);
}
};
extern const byte _finalFrameTable[];
extern const char * const _rezNames[];
extern const uint16 _mapExit[];
extern const uint8 _emlTable[];
extern const uint8 _zoomTable[81][9][2];
extern const uint8 _iconActTable[82][7];
extern const uint8 _cursorTable[96];
extern const uint8 _teaSeq[6][2];
extern const uint8 _hgaSeq[4][2];
extern const HotSpot _mouseMapMSFull[51];
extern const HotSpot _mouseMapMSDemo[51];
extern const HotSpot _mouseMapASFull[128][16];
extern const HotSpot _mouseMapASDemo[128][16];
struct KingdomSavegameHeader {
uint32 _signature;
uint8 _version;
Common::String _saveName;
Graphics::Surface *_thumbnail;
int _year, _month, _day;
int _hour, _minute;
};
class KingdomGame : public Engine {
public:
KingdomGame(OSystem *syst, const ADGameDescription *gameDesc);
~KingdomGame() override;
bool hasFeature(EngineFeature f) const override;
Common::Error run() override;
// Detection related functions
const ADGameDescription *_gameDescription;
const char *getGameId() const;
Common::Platform getPlatform() const;
static bool readSavegameHeader(Common::InSaveFile *in, KingdomSavegameHeader &header);
bool isDemo() const;
private:
Logic *_logic;
KingArtEntry *_kingartEntries;
uint32 _kingartCount;
void displayDebugHotSpots();
public:
Common::RandomSource *_rnd;
bool _showHotspots;
bool _loopFlag;
int _gameMode;
bool _fstFwd;
bool _noIFScreen;
bool _sound;
bool _lastSound;
bool _fullScreen;
int _frameStop;
int _daelonCntr;
bool _itemInhibit;
bool _asMode;
bool _aTimerFlag;
bool _bTimerFlag;
bool _cTimerFlag;
bool _skylarTimerFlag;
int _aTimer;
int _bTimer;
int _cTimer;
int _skylarTimer;
bool _mapEx;
int _healthTmr;
int _treeEyeTimer;
int _treeEyePic;
int _treeEyeSta;
int _treeHGTimer;
int _treeHGPic;
int _treeHGUPic;
int _treeLeftPic;
int _treeRightPic;
int _treeRightSta;
int _treeHGSta;
bool _tsIconOnly;
bool _noMusic; // TODO: Synchronize this flag with the launcher
byte *_asPtr;
int _asMap;
int _oldTLS;
int _oldTRS;
int _treeLeftSta;
bool _iconsClosed;
bool _oldIconsClosed;
int _pMovie;
bool _demoMovieSkipped;
bool _keyActive;
bool _iconRedraw;
bool _quit;
bool _cursorDrawn; // CHECKME: Useless
bool _wizard;
int _zoom;
int _mouseValue;
int _cursorDef; // TODO: Could be removed by using the return value of CursorTypeExit()
int _oldCursorDef; // CHECKME: Unused in our implementation?
Common::Point _cursorPos;
Common::Point _oldCursorPos; // CHECKME: Unused in out implementation?
int _iconSel;
int _iconSelect;
bool _mouseDebound;
int _soundNumber;
bool _palStepFlag;
Audio::SoundHandle _soundHandle;
int _tickCount;
uint32 _oldTime;
int _iconPic[7];
uint16 _userInput;
uint16 _mouseButton;
void drawScreen();
void setupPics();
void initTools();
void titlePage();
void initPlay();
void initHelp();
void fadeToBlack1();
void fadeToBlack2();
Common::SeekableReadStream *loadAResource(int reznum);
void showPic(int reznum);
void fShowPic(int reznum);
void initCursor();
void initMouse();
void setMouse();
void readMouse();
void initMPlayer();
void playMovie(int movieNum);
void saveAS(); // TODO: Rename later as saveVideoBackground
void restoreAS(); // TODO: Rename later as restoreVideoBackground
void drawHelpScreen();
void drawRect(uint minX, uint minY, uint maxX, uint maxY, int color);
void drawHotSpot(const HotSpot &hs, int color);
void drawInventory();
void playSound(int idx);
void eraseCursor();
void getUserInput();
void eraseCursorAsm();
void drawLocation();
void processMap(int mapNum, int zoom);
void processMapInput(int mapNum);
void drawPic(int reznum);
void displayIcon(int reznum);
void setATimer();
void refreshSound();
void checkMainScreen();
void switchAtoM();
void switchMtoA();
void drawIcon(int x, int y, int index);
int waitKey();
void drawCursor();
void cursorType();
void loadKingArt();
void unloadKingArt();
void setCursor(int cursor);
int getAKey();
int checkMouseMapAS();
void cursorTypeExit();
void saveGame();
void restoreGame();
Common::Error loadGameState(int slot) override;
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
Common::String getSavegameFilename(int slot);
void writeSavegameHeader(Common::OutSaveFile *out, KingdomSavegameHeader &header);
void synchronize(Common::Serializer &s);
void refreshScreen();
void checkTimers();
void initVariables();
};
} // End of namespace Kingdom
#endif

623
engines/kingdom/logic.cpp Normal file
View File

@@ -0,0 +1,623 @@
/* 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.
*
* 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/>.
*
*/
#include "kingdom/kingdom.h"
#include "kingdom/logic.h"
namespace Kingdom {
Logic::Logic(KingdomGame* vm) : _vm(vm) {
initVariables();
}
void Logic::initVariables() {
_healthOld = 0;
_health = 0;
_tideCntl = false;
_statPlay = 0;
_spell3 = false;
_spell2 = false;
_spell1 = false;
_robberyNode = 0;
_rtnNode = 0;
_replay = false;
_resurrect = false;
_pouch = false;
_oldPouch = false;
_oldHelp = false;
_oldEye = false;
_oldStatPlay = 0;
_oldNode = 0;
_nodeNum = 0;
_nextNode = 0;
_mapStat = 0;
_lastObs = false;
_lastObstacle = 0;
_help = false;
_eye = false;
_fstFwd = false;
for (int i = 0; i < 99; i++)
_nodes[i] = 0;
_currMap = 0;
}
void Logic::initPlay() {
for (int i = 0; i != 19; ++i)
_inventory[i] = -1;
for (int i = 0; i < 99; i++)
_nodes[i] = 0;
_statPlay = 10;
_spell1 = false;
_spell2 = false;
_spell3 = false;
_tideCntl = false;
_health = 12;
_healthOld = 1;
_lastObs = false;
enableUIButtons();
_pouch = true;
initOpcodes();
}
void Logic::initOpcodes() {
_opCodes[10] = &Logic::GPL1_10;
_opCodes[11] = &Logic::GPL1_11;
_opCodes[20] = &Logic::GPL1_20;
_opCodes[30] = &Logic::GPL1_30;
_opCodes[31] = &Logic::GPL1_31;
_opCodes[32] = &Logic::GPL1_32;
_opCodes[40] = &Logic::GPL1_40;
_opCodes[41] = &Logic::GPL1_41;
_opCodes[42] = &Logic::GPL1_42;
_opCodes[50] = &Logic::GPL1_50;
_opCodes[51] = &Logic::GPL1_51;
_opCodes[52] = &Logic::GPL1_52;
_opCodes[53] = &Logic::GPL1_53;
_opCodes[60] = &Logic::GPL1_60;
_opCodes[70] = &Logic::GPL1_70;
_opCodes[71] = &Logic::GPL1_71;
_opCodes[72] = &Logic::GPL1_72;
_opCodes[80] = &Logic::GPL1_80;
_opCodes[81] = &Logic::GPL1_81;
_opCodes[82] = &Logic::GPL1_82;
_opCodes[90] = &Logic::GPL1_90;
_opCodes[91] = &Logic::GPL1_91;
_opCodes[92] = &Logic::GPL1_92;
_opCodes[100] = &Logic::GPL1_100;
_opCodes[101] = &Logic::GPL1_101;
_opCodes[102] = &Logic::GPL1_102;
_opCodes[110] = &Logic::GPL1_110;
_opCodes[111] = &Logic::GPL1_111;
_opCodes[112] = &Logic::GPL1_112;
_opCodes[120] = &Logic::GPL1_120;
_opCodes[121] = &Logic::GPL1_121;
_opCodes[130] = &Logic::GPL1_130;
_opCodes[140] = &Logic::GPL1_140;
_opCodes[141] = &Logic::GPL1_141;
_opCodes[142] = &Logic::GPL1_142;
_opCodes[150] = &Logic::GPL1_150;
_opCodes[151] = &Logic::GPL1_151;
_opCodes[160] = &Logic::GPL1_160;
_opCodes[161] = &Logic::GPL1_161;
_opCodes[162] = &Logic::GPL1_162;
_opCodes[170] = &Logic::GPL1_170;
_opCodes[171] = &Logic::GPL1_171;
_opCodes[172] = &Logic::GPL1_172;
_opCodes[180] = &Logic::GPL1_180;
_opCodes[181] = &Logic::GPL1_181;
_opCodes[182] = &Logic::GPL1_182;
_opCodes[190] = &Logic::GPL1_190;
_opCodes[200] = &Logic::GPL1_200;
_opCodes[201] = &Logic::GPL1_201;
_opCodes[202] = &Logic::GPL1_202;
_opCodes[210] = &Logic::GPL1_210;
_opCodes[211] = &Logic::GPL1_211;
_opCodes[212] = &Logic::GPL1_212;
_opCodes[220] = &Logic::GPL1_220;
_opCodes[221] = &Logic::GPL1_221;
_opCodes[222] = &Logic::GPL1_222;
_opCodes[230] = &Logic::GPL1_230;
_opCodes[240] = &Logic::GPL1_240;
_opCodes[241] = &Logic::GPL1_241;
_opCodes[242] = &Logic::GPL1_242;
_opCodes[250] = &Logic::GPL2_250;
_opCodes[251] = &Logic::GPL2_251;
_opCodes[252] = &Logic::GPL2_252;
_opCodes[900] = &Logic::GPL4_900;
_opCodes[901] = &Logic::GPL4_901;
_opCodes[991] = &Logic::GPL4_991;
_opCodes[994] = &Logic::GPL4_994;
if (_vm->isDemo())
initOpcodesDemo();
else
initOpcodesFull();
}
void Logic::initOpcodesDemo() {
_opCodes[992] = &Logic::GPL4_992_demo;
_opCodes[993] = &Logic::GPL4_993_demo;
}
void Logic::initOpcodesFull() {
_opCodes[260] = &Logic::GPL2_260;
_opCodes[261] = &Logic::GPL2_261;
_opCodes[270] = &Logic::GPL2_270;
_opCodes[271] = &Logic::GPL2_271;
_opCodes[272] = &Logic::GPL2_272;
_opCodes[280] = &Logic::GPL2_280;
_opCodes[290] = &Logic::GPL2_290;
_opCodes[291] = &Logic::GPL2_291;
_opCodes[292] = &Logic::GPL2_292;
_opCodes[300] = &Logic::GPL2_300;
_opCodes[301] = &Logic::GPL2_301;
_opCodes[302] = &Logic::GPL2_302;
_opCodes[310] = &Logic::GPL2_310;
_opCodes[311] = &Logic::GPL2_311;
_opCodes[312] = &Logic::GPL2_312;
_opCodes[320] = &Logic::GPL2_320;
_opCodes[321] = &Logic::GPL2_321;
_opCodes[322] = &Logic::GPL2_322;
_opCodes[330] = &Logic::GPL2_330;
_opCodes[331] = &Logic::GPL2_331;
_opCodes[332] = &Logic::GPL2_332;
_opCodes[340] = &Logic::GPL2_340;
_opCodes[341] = &Logic::GPL2_341;
_opCodes[342] = &Logic::GPL2_342;
_opCodes[350] = &Logic::GPL2_350;
_opCodes[351] = &Logic::GPL2_351;
_opCodes[360] = &Logic::GPL2_360;
_opCodes[361] = &Logic::GPL2_361;
_opCodes[362] = &Logic::GPL2_362;
_opCodes[370] = &Logic::GPL2_370;
_opCodes[371] = &Logic::GPL2_371;
_opCodes[372] = &Logic::GPL2_372;
_opCodes[380] = &Logic::GPL2_380;
_opCodes[381] = &Logic::GPL2_381;
_opCodes[382] = &Logic::GPL2_382;
_opCodes[390] = &Logic::GPL2_390;
_opCodes[400] = &Logic::GPL2_400;
_opCodes[401] = &Logic::GPL2_401;
_opCodes[402] = &Logic::GPL2_402;
_opCodes[410] = &Logic::GPL2_410;
_opCodes[411] = &Logic::GPL2_411;
_opCodes[420] = &Logic::GPL2_420;
_opCodes[421] = &Logic::GPL2_421;
_opCodes[422] = &Logic::GPL2_422;
_opCodes[430] = &Logic::GPL2_430;
_opCodes[431] = &Logic::GPL2_431;
_opCodes[440] = &Logic::GPL2_440;
_opCodes[441] = &Logic::GPL2_441;
_opCodes[442] = &Logic::GPL2_442;
_opCodes[450] = &Logic::GPL2_450;
_opCodes[451] = &Logic::GPL2_451;
_opCodes[460] = &Logic::GPL2_460;
_opCodes[461] = &Logic::GPL2_461;
_opCodes[462] = &Logic::GPL2_462;
_opCodes[480] = &Logic::GPL2_480;
_opCodes[481] = &Logic::GPL2_481;
_opCodes[482] = &Logic::GPL2_482;
_opCodes[490] = &Logic::GPL2_490;
_opCodes[491] = &Logic::GPL2_491;
_opCodes[500] = &Logic::GPL3_500;
_opCodes[501] = &Logic::GPL3_501;
_opCodes[502] = &Logic::GPL3_502;
_opCodes[510] = &Logic::GPL3_510;
_opCodes[511] = &Logic::GPL3_511;
_opCodes[512] = &Logic::GPL3_512;
_opCodes[520] = &Logic::GPL3_520;
_opCodes[521] = &Logic::GPL3_521;
_opCodes[522] = &Logic::GPL3_522;
_opCodes[530] = &Logic::GPL3_530;
_opCodes[531] = &Logic::GPL3_531;
_opCodes[540] = &Logic::GPL3_540;
_opCodes[541] = &Logic::GPL3_541;
_opCodes[542] = &Logic::GPL3_542;
_opCodes[550] = &Logic::GPL3_550;
_opCodes[551] = &Logic::GPL3_551;
_opCodes[552] = &Logic::GPL3_552;
_opCodes[560] = &Logic::GPL3_560;
_opCodes[561] = &Logic::GPL3_561;
_opCodes[562] = &Logic::GPL3_562;
_opCodes[570] = &Logic::GPL3_570;
_opCodes[571] = &Logic::GPL3_571;
_opCodes[572] = &Logic::GPL3_572;
_opCodes[580] = &Logic::GPL3_580;
_opCodes[581] = &Logic::GPL3_581;
_opCodes[582] = &Logic::GPL3_582;
_opCodes[590] = &Logic::GPL3_590;
_opCodes[591] = &Logic::GPL3_591;
_opCodes[592] = &Logic::GPL3_592;
_opCodes[600] = &Logic::GPL3_600;
_opCodes[610] = &Logic::GPL3_610;
_opCodes[611] = &Logic::GPL3_611;
_opCodes[620] = &Logic::GPL3_620;
_opCodes[621] = &Logic::GPL3_621;
_opCodes[630] = &Logic::GPL3_630;
_opCodes[631] = &Logic::GPL3_631;
_opCodes[640] = &Logic::GPL3_640;
_opCodes[641] = &Logic::GPL3_641;
_opCodes[642] = &Logic::GPL3_642;
_opCodes[650] = &Logic::GPL3_650;
_opCodes[651] = &Logic::GPL3_651;
_opCodes[660] = &Logic::GPL3_660;
_opCodes[661] = &Logic::GPL3_661;
_opCodes[670] = &Logic::GPL3_670;
_opCodes[671] = &Logic::GPL3_671;
_opCodes[680] = &Logic::GPL3_680;
_opCodes[690] = &Logic::GPL3_690;
_opCodes[691] = &Logic::GPL3_691;
_opCodes[692] = &Logic::GPL3_692;
_opCodes[700] = &Logic::GPL3_700;
_opCodes[701] = &Logic::GPL3_701;
_opCodes[710] = &Logic::GPL3_710;
_opCodes[711] = &Logic::GPL3_711;
_opCodes[712] = &Logic::GPL3_712;
_opCodes[720] = &Logic::GPL3_720;
_opCodes[721] = &Logic::GPL3_721;
_opCodes[730] = &Logic::GPL3_730;
_opCodes[731] = &Logic::GPL3_731;
_opCodes[740] = &Logic::GPL3_740;
_opCodes[741] = &Logic::GPL3_741;
_opCodes[760] = &Logic::GPL3_760;
_opCodes[761] = &Logic::GPL3_761;
_opCodes[780] = &Logic::GPL3_780;
_opCodes[781] = &Logic::GPL3_781;
_opCodes[790] = &Logic::GPL3_790;
_opCodes[791] = &Logic::GPL3_791;
_opCodes[992] = &Logic::GPL4_992;
_opCodes[993] = &Logic::GPL4_993;
}
void Logic::enableUIButtons() {
_help = true;
_eye = true;
_replay = true;
_pouch = true;
_fstFwd = true;
}
void Logic::disableUIButtons() {
_help = false;
_eye = false;
_replay = false;
_pouch = false;
_fstFwd = false;
}
void Logic::inventoryDel(int item) {
if (_inventory[item] > 0)
_inventory[item]--;
}
void Logic::inventoryAdd(int item) {
if (item >= 4)
_inventory[item] = 1;
else
_inventory[item] = 3;
}
bool Logic::wound() {
bool retval = false;
if (_health == 12 || _health == 8 || _health == 4) {
_health -= 2;
retval = true;
}
return retval;
}
bool Logic::chkDesertObstacles() {
if (!_vm->_wizard)
return false;
_nextNode = _nodeNum;
if (_lastObs) {
_lastObs = false;
return false;
}
if (_nodes[28] || _vm->_rnd->getRandomNumber(6) == 0) {
if (!_nodes[48] || _robberyNode != _nodeNum) {
if (_lastObstacle != _nodeNum) {
if (_vm->_rnd->getRandomNumber(5) == 0) {
_statPlay = 250;
_lastObstacle = _nodeNum;
_lastObs = true;
_vm->_loopFlag = true;
return true;
} else {
return false;
}
} else {
return false;
}
} else {
_statPlay = 490;
_vm->_loopFlag = true;
return true;
}
} else {
_statPlay = 280;
_robberyNode = _nodeNum;
_lastObstacle = _nodeNum;
_lastObs = true;
_vm->_loopFlag = true;
return true;
}
}
void Logic::increaseHealth() {
if (_health <= 3)
_health = 4;
else if (_health <= 7)
_health = 8;
else
_health = 12;
}
void Logic::endCredits() {
_nodeNum = 0;
_vm->_bTimer = 190;
_vm->readMouse();
while(_vm->_bTimer != 0 && _vm->_mouseButton == 0) {
_vm->checkTimers();
_vm->refreshSound();
_vm->checkMainScreen();
_vm->readMouse();
}
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->playSound(0);
disableUIButtons();
_vm->_iconsClosed = true;
_vm->playMovie(199);
disableUIButtons();
_vm->playMovie(205);
disableUIButtons();
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->playMovie(201);
_vm->fShowPic(125);
characterDeath();
}
void Logic::gameHelp_Sub43C() {
_vm->fadeToBlack1();
_currMap = _vm->_asMap;
_vm->drawRect(4, 17, 228, 161, 0);
_vm->restoreAS();
_vm->_userInput = 0;
_vm->_gameMode = 0;
_vm->_iconsClosed = false;
_vm->_treeLeftSta = _vm->_oldTLS;
_eye = _oldEye;
_help = _oldHelp;
_pouch = _oldPouch;
}
void Logic::gameHelp() {
if (!_vm->_gameMode) {
if (_vm->_userInput == 0x43C) {
_vm->saveAS();
_vm->_asMap = _currMap;
_currMap = 0;
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->drawHelpScreen();
_vm->_gameMode = 1;
_vm->_oldTLS = _vm->_treeLeftSta;
_vm->_treeLeftSta = 0;
_vm->_iconsClosed = true;
_oldEye = _eye;
_eye = false;
_oldHelp = _help;
_oldPouch = _pouch;
_pouch = false;
_vm->_userInput = 0;
}
if (_vm->_userInput == 0x44F) {
_vm->saveAS();
_vm->_asMap = _currMap;
_vm->_gameMode = 2;
_vm->_oldTLS = _vm->_treeLeftSta;
_vm->_treeLeftSta = 0;
_vm->_iconsClosed = true;
_oldEye = _eye;
_eye = false;
_oldHelp = _help;
_help = false;
_oldPouch = _pouch;
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->drawInventory();
if (_nodes[67] == 1 || _nodes[28] == 1 || _vm->_itemInhibit)
_currMap = 10;
else
_currMap = 11;
_vm->_userInput = 0;
}
}
if (_vm->_gameMode == 0)
return;
switch(_vm->_userInput) {
case 0x240:
// New game
_vm->fadeToBlack2();
//TODO: Set _quitFlag to 1
break;
case 0x241:
case 0x43B:
case 0x43C:
case 0x44F:
// Resume game
gameHelp_Sub43C();
return;
break;
case 0x242:
// Music On/Off
if (_vm->_noMusic) {
_vm->_noMusic = false;
_vm->playSound(1);
} else {
_vm->_noMusic = true;
_vm->playSound(0);
}
_vm->drawHelpScreen();
break;
case 0x243: {
// Show Demo
_vm->fadeToBlack2();
_vm->_keyActive = false;
_vm->_noIFScreen = true;
_vm->playSound(0);
// The demo isn't saving pMovie.
// It's obviously a bug and this behavior wasn't kept in ScummVM
int oldPMovie = _vm->_pMovie;
_vm->_demoMovieSkipped = false;
while(!_vm->_keyActive && !_vm->shouldQuit() && !_vm->_demoMovieSkipped) {
_vm->playMovie(54);
_vm->fadeToBlack2();
}
_vm->_demoMovieSkipped = false;
_vm->_pMovie = oldPMovie;
_vm->_noIFScreen = false;
_vm->showPic(106);
_vm->drawHelpScreen();
_vm->_iconRedraw = true;
_vm->playSound(1);
}
break;
case 0x244:
// Quit
//TODO: Set _quitFlag to 2
_vm->_quit = true;
break;
case 0x245: {
// Show Credits
_vm->fadeToBlack1();
// The demo isn't saving pMovie.
// It's obviously a bug and this behavior wasn't kept in ScummVM
int oldPMovie = _vm->_pMovie;
_vm->drawRect(4, 17, 228, 161, 0);
_vm->playMovie(205);
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->playMovie(199);
_vm->fadeToBlack1();
_vm->drawRect(4, 17, 228, 161, 0);
_vm->drawHelpScreen();
_vm->_pMovie = oldPMovie;
}
break;
case 0x246:
_vm->saveGame();
break;
default:
break;
}
if (_vm->_userInput > 0x427 && _vm->_userInput < 0x43A)
_vm->fShowPic(130 + _vm->_userInput - 0x428);
if (_vm->_userInput == 0x260) {
_vm->drawInventory();
if (_nodes[67] == 1 || _nodes[28] == 1)
_currMap = 10;
else
_currMap = 11;
_vm->_userInput = 0;
}
}
void Logic::switchAS() {
_vm->_asMode = false;
_currMap = _vm->_asMap;
_vm->_treeLeftSta = _vm->_oldTLS;
_vm->_treeRightSta = _vm->_oldTRS;
_pouch = _oldPouch;
_help = _oldHelp;
_vm->_iconsClosed = _vm->_oldIconsClosed;
}
void Logic::characterDeath() {
_currMap = 3;
disableUIButtons();
_pouch = false;
for (int i = 0; i != 19; ++i) {
_inventory[i] = -1;
}
_statPlay = 994;
_vm->_loopFlag = true;
}
void Logic::executeOpcode() {
if (_opCodes.contains(_statPlay)) {
Opcode op = _opCodes[_statPlay];
(this->*op)();
} else
warning("Unknown opcode: %d", _statPlay);
}
void Logic::synchronize(Common::Serializer &s) {
s.syncAsSint16LE(_statPlay);
s.syncAsSint16LE(_health);
s.syncAsSint16LE(_healthOld);
s.syncAsSint16LE(_lastObstacle);
s.syncAsSint16LE(_nextNode);
s.syncAsSint16LE(_nodeNum);
s.syncAsSint16LE(_rtnNode);
s.syncAsSint16LE(_robberyNode);
for (int i = 0; i < 18; i++)
s.syncAsSint16LE(_inventory[i]);
for (int i = 0; i < 99; i++)
s.syncAsSint16LE(_nodes[i]);
s.syncAsByte(_oldEye);
s.syncAsByte(_fstFwd);
s.syncAsByte(_help);
s.syncAsByte(_lastObs);
s.syncAsByte(_oldPouch);
s.syncAsByte(_replay);
s.syncAsByte(_spell1);
s.syncAsByte(_spell2);
s.syncAsByte(_spell3);
s.syncAsByte(_tideCntl);
}
} // NameSpace

299
engines/kingdom/logic.h Normal file
View File

@@ -0,0 +1,299 @@
/* 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.
*
* 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/>.
*
*/
#ifndef KINGDOM_LOGIC_H
#define KINGDOM_LOGIC_H
namespace Kingdom {
class KingdomGame;
class Logic {
typedef void (Kingdom::Logic::*Opcode)(void);
private:
KingdomGame *_vm;
Common::HashMap<int, Opcode> _opCodes;
void initOpcodes();
void initOpcodesDemo();
void initOpcodesFull();
void GPL1_10();
void GPL1_11();
void GPL1_20();
void GPL1_30();
void GPL1_31();
void GPL1_32();
void GPL1_40();
void GPL1_41();
void GPL1_42();
void GPL1_50();
void GPL1_51();
void GPL1_52();
void GPL1_53();
void GPL1_60();
void GPL1_70();
void GPL1_71();
void GPL1_72();
void GPL1_80();
void GPL1_81();
void GPL1_82();
void GPL1_90();
void GPL1_91();
void GPL1_92();
void GPL1_100();
void GPL1_101();
void GPL1_102();
void GPL1_110();
void GPL1_111();
void GPL1_112();
void GPL1_120();
void GPL1_121();
void GPL1_130();
void GPL1_140();
void GPL1_141();
void GPL1_142();
void GPL1_150();
void GPL1_151();
void GPL1_160();
void GPL1_161();
void GPL1_162();
void GPL1_170();
void GPL1_171();
void GPL1_172();
void GPL1_180();
void GPL1_181();
void GPL1_182();
void GPL1_190();
void GPL1_200();
void GPL1_201();
void GPL1_202();
void GPL1_210();
void GPL1_211();
void GPL1_212();
void GPL1_220();
void GPL1_221();
void GPL1_222();
void GPL1_230();
void GPL1_240();
void GPL1_241();
void GPL1_242();
void GPL2_250();
void GPL2_251();
void GPL2_252();
void GPL2_260();
void GPL2_261();
void GPL2_270();
void GPL2_271();
void GPL2_272();
void GPL2_280();
void GPL2_290();
void GPL2_291();
void GPL2_292();
void GPL2_300();
void GPL2_301();
void GPL2_302();
void GPL2_310();
void GPL2_311();
void GPL2_312();
void GPL2_320();
void GPL2_321();
void GPL2_322();
void GPL2_330();
void GPL2_331();
void GPL2_332();
void GPL2_340();
void GPL2_341();
void GPL2_342();
void GPL2_350();
void GPL2_351();
void GPL2_360();
void GPL2_361();
void GPL2_362();
void GPL2_370();
void GPL2_371();
void GPL2_372();
void GPL2_380();
void GPL2_381();
void GPL2_382();
void GPL2_390();
void GPL2_400();
void GPL2_401();
void GPL2_402();
void GPL2_410();
void GPL2_411();
void GPL2_420();
void GPL2_421();
void GPL2_422();
void GPL2_430();
void GPL2_431();
void GPL2_440();
void GPL2_441();
void GPL2_442();
void GPL2_450();
void GPL2_451();
void GPL2_460();
void GPL2_461();
void GPL2_462();
void GPL2_480();
void GPL2_481();
void GPL2_482();
void GPL2_490();
void GPL2_491();
void GPL3_500();
void GPL3_501();
void GPL3_502();
void GPL3_510();
void GPL3_511();
void GPL3_512();
void GPL3_520();
void GPL3_521();
void GPL3_522();
void GPL3_530();
void GPL3_531();
void GPL3_540();
void GPL3_541();
void GPL3_542();
void GPL3_550();
void GPL3_551();
void GPL3_552();
void GPL3_560();
void GPL3_561();
void GPL3_562();
void GPL3_570();
void GPL3_571();
void GPL3_572();
void GPL3_580();
void GPL3_581();
void GPL3_582();
void GPL3_590();
void GPL3_591();
void GPL3_592();
void GPL3_600();
void GPL3_610();
void GPL3_611();
void GPL3_620();
void GPL3_621();
void GPL3_630();
void GPL3_631();
void GPL3_640();
void GPL3_641();
void GPL3_642();
void GPL3_650();
void GPL3_651();
void GPL3_660();
void GPL3_661();
void GPL3_670();
void GPL3_671();
void GPL3_680();
void GPL3_690();
void GPL3_691();
void GPL3_692();
void GPL3_700();
void GPL3_701();
void GPL3_710();
void GPL3_711();
void GPL3_712();
void GPL3_720();
void GPL3_721();
void GPL3_730();
void GPL3_731();
void GPL3_740();
void GPL3_741();
void GPL3_760();
void GPL3_761();
void GPL3_780();
void GPL3_781();
void GPL3_790();
void GPL3_791();
void GPL4_900();
void GPL4_901();
void GPL4_991();
void GPL4_992();
void GPL4_992_demo();
void GPL4_993();
void GPL4_993_demo();
void GPL4_994();
public:
int _statPlay;
int _oldStatPlay;
int _nodeNum;
int _oldNode; // CHECKME: Useless? If so, to be removed
int _nextNode;
int _robberyNode;
int16 _nodes[99];
int _currMap;
bool _oldEye;
bool _eye;
bool _oldHelp;
bool _help;
int _lastObstacle;
bool _lastObs;
int _inventory[19];
bool _replay;
bool _pouch;
bool _oldPouch;
bool _resurrect;
bool _tideCntl;
int _rtnNode;
int _health;
int _healthOld;
bool _fstFwd;
bool _spell1;
bool _spell2;
bool _spell3;
int _mapStat; // CHECKME: Useless? If so, to be removed
void enableUIButtons();
void disableUIButtons();
bool wound();
void GPLogic1_SubSP10();
void GPLogic1_SubSP121();
void GPLogic2_SubSP361();
bool chkDesertObstacles();
void increaseHealth();
void endCredits();
void gameHelp_Sub43C();
void initVariables();
public:
explicit Logic(Kingdom::KingdomGame *vm);
virtual ~Logic(void) {}
void gameHelp();
void inventoryDel(int item);
void inventoryAdd(int item);
void executeOpcode();
void initPlay();
void switchAS();
void characterDeath();
void synchronize(Common::Serializer &s);
};
}
#endif

1504
engines/kingdom/logic1.cpp Normal file

File diff suppressed because it is too large Load Diff

1385
engines/kingdom/logic2.cpp Normal file

File diff suppressed because it is too large Load Diff

1748
engines/kingdom/logic3.cpp Normal file

File diff suppressed because it is too large Load Diff

355
engines/kingdom/logic4.cpp Normal file
View File

@@ -0,0 +1,355 @@
/* 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.
*
* 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/>.
*
*/
#include "kingdom/kingdom.h"
#include "kingdom/logic.h"
namespace Kingdom {
void Logic::GPL4_900() {
if (_vm->_aTimer > 0) {
_vm->playSound(0);
_vm->_aTimer = 133;
}
if (_vm->_asMode) {
_vm->switchMtoA();
_mapStat = 0;
_oldStatPlay--;
_vm->_asMode = false;
}
_vm->saveAS();
_vm->fadeToBlack2();
if (_health == 10 || _health == 6 || _health == 2) {
_vm->showPic(121);
_vm->_bTimer = 38;
_vm->readMouse();
while (_vm->_bTimer && !_vm->_mouseButton) {
_vm->checkTimers();
_vm->refreshSound();
_vm->readMouse();
}
if (_vm->_aTimer > 0)
_vm->setATimer();
_vm->_userInput = 0;
GPL4_901();
} else {
if (_vm->_aTimer > 0) {
_vm->setATimer();
_vm->_aTimer = 133;
}
_vm->showPic(120);
_statPlay = 901;
}
}
void Logic::GPL4_901() {
_vm->setMouse();
_vm->eraseCursor();
_vm->fadeToBlack2();
_vm->showPic(106);
_vm->drawIcon(4, 0, 12 - _healthOld);
if (_tideCntl)
_vm->drawPic(178);
else
_vm->drawPic(179);
_vm->_iconRedraw = true;
if (_vm->_userInput == 0x2F1) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
_vm->_loopFlag = true;
} else {
if (_health == 10 || _health == 6 || _health == 2 || _vm->_userInput < 0x400 || _vm->_userInput > 0x427) {
_vm->_asMode = false;
_vm->restoreAS();
_statPlay = _oldStatPlay;
} else {
_statPlay = _mapExit[_vm->_userInput - 0x400];
_vm->_userInput = 0;
wound();
_vm->playMovie(10);
inventoryDel(3);
_vm->_tsIconOnly = false;
enableUIButtons();
switchAS();
_mapStat = 0;
}
_vm->_userInput = 0;
_vm->_loopFlag = true;
}
}
void Logic::GPL4_991() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
characterDeath();
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[28] == 1) {
_nodes[28] = 0;
_nodes[48] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enableUIButtons();
_vm->_mapEx = true;
_nodeNum = 5;
_vm->drawLocation();
_vm->playSound(0);
if (_nodes[5] > 0) {
_vm->playMovie(197);
_resurrect = true;
}
inventoryDel(12);
_statPlay = 50;
}
}
void Logic::GPL4_992() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
characterDeath();
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[28] == 1) {
_nodes[28] = 0;
_nodes[48] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enableUIButtons();
_vm->_mapEx = true;
_nodeNum = 27;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(195);
inventoryDel(12);
_statPlay = 270;
}
}
void Logic::GPL4_992_demo() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
characterDeath();
} else {
_vm->_bTimer = 36;
while(_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[28] == 1) {
_nodes[28] = 0;
_nodes[48] = 0;
}
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enableUIButtons();
_nodeNum = 27;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(195);
inventoryDel(12);
_statPlay = 270;
}
}
void Logic::GPL4_993() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
characterDeath();
} else {
_vm->_bTimer = 36;
while (_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[28] == 1) {
_nodes[28] = 0;
_nodes[48] = 0;
}
if (_nodes[67] == 1)
_nodes[67] = 0;
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enableUIButtons();
_vm->_mapEx = true;
_nodeNum = 52;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(196);
inventoryDel(12);
_statPlay = 520;
}
}
void Logic::GPL4_993_demo() {
_currMap = 10;
_vm->_userInput = 0;
_vm->playSound(0);
if (_health == 10 || _health == 6 || _health == 2)
_health -= 2;
else
_health -= 4;
if (_health == 0) {
_vm->playMovie(194);
_vm->_noIFScreen = true;
_vm->fShowPic(107);
characterDeath();
} else {
_vm->_bTimer = 36;
while (_vm->_bTimer != 0) {
_vm->checkTimers();
_vm->refreshSound();
}
_vm->_loopFlag = true;
if (_nodes[28] == 1) {
_nodes[28] = 0;
_nodes[48] = 0;
}
if (_nodes[67] == 1)
_nodes[67] = 0;
_vm->_itemInhibit = false;
_tideCntl = false;
_vm->drawPic(179);
_vm->_skylarTimer = 0;
_vm->_skylarTimerFlag = false;
enableUIButtons();
_nodeNum = 52;
_vm->drawLocation();
_resurrect = true;
_vm->playSound(0);
_vm->playMovie(196);
inventoryDel(12);
_statPlay = 520;
}
}
void Logic::GPL4_994() {
switch(_vm->_userInput) {
case 0x190:
_vm->initPlay();
// TODO _QuitFlag = 1;
_vm->_quit = true;
break;
case 0x191:
// TODO _QuitFlag = 2;
_vm->_quit = true;
break;
default:
if (_vm->_userInput)
warning("Skipped UserInput %d(0x%04X) for _StatPlay %d", _vm->_userInput, _vm->_userInput, _statPlay);
break;
}
}
} // Namespace

View File

@@ -0,0 +1,139 @@
/* 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.
*
* 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/>.
*
*/
#include "base/plugins.h"
#include "common/savefile.h"
#include "engines/advancedDetector.h"
#include "common/file.h"
#include "kingdom/kingdom.h"
#define MAX_SAVES 99
namespace Kingdom {
const char *KingdomGame::getGameId() const { return _gameDescription->gameId; }
Common::Platform KingdomGame::getPlatform() const { return _gameDescription->platform; }
} // End of namespace Kingdom
class KingdomMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
public:
const char *getName() const override {
return "kingdom";
}
bool hasFeature(MetaEngineFeature f) const override;
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
int getMaximumSaveSlot() const override;
SaveStateList listSaves(const char *target) const override;
bool removeSaveState(const char *target, int slot) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
};
bool KingdomMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSimpleSavesNames) ||
(f == kSavesSupportCreationDate);
}
Common::Error KingdomMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
*engine = new Kingdom::KingdomGame(syst, desc);
return Common::kNoError;
}
int KingdomMetaEngine::getMaximumSaveSlot() const {
return MAX_SAVES;
}
SaveStateList KingdomMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.0##", target);
Common::StringArray filenames = saveFileMan->listSavefiles(pattern);
Kingdom::KingdomSavegameHeader header;
SaveStateList saveList;
for (const auto &filename : filenames) {
const char *ext = strrchr(filename.c_str(), '.');
int slot = ext ? atoi(ext + 1) : -1;
if (slot >= 0 && slot < MAX_SAVES) {
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
if (in) {
if (Kingdom::KingdomGame::readSavegameHeader(in, header)) {
saveList.push_back(SaveStateDescriptor(this, slot, header._saveName));
header._thumbnail->free();
delete header._thumbnail;
}
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
bool KingdomMetaEngine::removeSaveState(const char *target, int slot) const {
Common::String filename = Common::String::format("%s.%03d", target, slot);
return g_system->getSavefileManager()->removeSavefile(filename);
}
SaveStateDescriptor KingdomMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String filename = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
if (f) {
Kingdom::KingdomSavegameHeader header;
Kingdom::KingdomGame::readSavegameHeader(f, header);
delete f;
// Create the return descriptor
SaveStateDescriptor desc(this, slot, header._saveName);
desc.setThumbnail(header._thumbnail);
desc.setSaveDate(header._year, header._month, header._day);
desc.setSaveTime(header._hour, header._minute);
return desc;
}
return SaveStateDescriptor();
}
#if PLUGIN_ENABLED_DYNAMIC(KINGDOM)
REGISTER_PLUGIN_DYNAMIC(KINGDOM, PLUGIN_TYPE_ENGINE, KingdomMetaEngine);
#else
REGISTER_PLUGIN_STATIC(KINGDOM, PLUGIN_TYPE_ENGINE, KingdomMetaEngine);
#endif

23
engines/kingdom/module.mk Normal file
View File

@@ -0,0 +1,23 @@
MODULE := engines/kingdom
MODULE_OBJS = \
kingdom.o \
constants.o \
console.o \
logic1.o \
logic2.o \
logic3.o \
logic4.o \
logic.o \
metaengine.o
# This module can be built as a plugin
ifeq ($(ENABLE_KINGDOM), DYNAMIC_PLUGIN)
PLUGIN := 1
endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection.o