diff options
author | Paul Gilbert | 2019-06-08 21:39:52 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-06-09 15:00:46 -0700 |
commit | a9324c3c9e0eea017f899faf7b2a53039b659ae5 (patch) | |
tree | c86b8a90ccbc1983df38239b615f0afaeffce40b /engines/glk | |
parent | da434f29522d7ee36f33c1b0bd95d9cc03cc5093 (diff) | |
download | scummvm-rg350-a9324c3c9e0eea017f899faf7b2a53039b659ae5.tar.gz scummvm-rg350-a9324c3c9e0eea017f899faf7b2a53039b659ae5.tar.bz2 scummvm-rg350-a9324c3c9e0eea017f899faf7b2a53039b659ae5.zip |
GLK: ADVSYS: Main game loop
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/advsys/advsys.cpp | 39 | ||||
-rw-r--r-- | engines/glk/advsys/game.cpp | 7 | ||||
-rw-r--r-- | engines/glk/advsys/game.h | 11 |
3 files changed, 53 insertions, 4 deletions
diff --git a/engines/glk/advsys/advsys.cpp b/engines/glk/advsys/advsys.cpp index 5d0f20b1bb..c1d1f9e38e 100644 --- a/engines/glk/advsys/advsys.cpp +++ b/engines/glk/advsys/advsys.cpp @@ -26,14 +26,49 @@ namespace Glk { namespace AdvSys { +void execute(int offset) { + // TODO: Stub +} + +bool getInput() { + // TODO: Stub + return false; +} + +bool singleAction() { + // TODO: Stub + return false; +} + +bool nextAction() { + // TODO: STub + return false; +} + void AdvSys::runGame() { if (!initialize()) { GUIErrorMessage(_("Could not start AdvSys game")); return; } - // TODO: play game - print("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n"); + // Outer play loop - this loop re-iterates if a game is restarted + while (!shouldQuit()) { + // Run game startup + execute(_initCodeOffset); + + // Gameplay loop + while (!shouldQuit() && !shouldRestart()) { + // Run update code + execute(_updateCodeOffset); + + // Get and parse a single line + if (getInput()) { + if (singleAction()) { + while (!shouldQuit() && nextAction() && singleAction()) {} + } + } + } + } deinitialize(); } diff --git a/engines/glk/advsys/game.cpp b/engines/glk/advsys/game.cpp index 938c85fe51..a20178d9e2 100644 --- a/engines/glk/advsys/game.cpp +++ b/engines/glk/advsys/game.cpp @@ -142,6 +142,13 @@ void Game::restart(Common::SeekableReadStream& s) { decrypt(_saveArea, _saveSize); setVariable(V_OCOUNT, _objectCount); + _restartFlag = true; +} + +bool Game::shouldRestart() { + bool result = _restartFlag; + _restartFlag = false; + return result; } void Game::saveGameData(Common::WriteStream& ws) { diff --git a/engines/glk/advsys/game.h b/engines/glk/advsys/game.h index bd125f2373..d74245b67c 100644 --- a/engines/glk/advsys/game.h +++ b/engines/glk/advsys/game.h @@ -131,6 +131,8 @@ public: */ class Game : public Header { private: + bool _restartFlag; +private: /** * Find an object property field */ @@ -183,8 +185,8 @@ public: /** * Constructor */ - Game() : Header(), _residentOffset(0), _wordCount(0), _objectCount(0), _actionCount(0), - _variableCount(0), _residentBase(nullptr), _wordTable(nullptr), + Game() : Header(), _restartFlag(false), _residentOffset(0), _wordCount(0), _objectCount(0), + _actionCount(0), _variableCount(0), _residentBase(nullptr), _wordTable(nullptr), _wordTypeTable(nullptr), _objectTable(nullptr), _actionTable(nullptr), _variableTable(nullptr), _saveArea(nullptr) {} @@ -199,6 +201,11 @@ public: void restart(Common::SeekableReadStream& s); /** + * Returns true if the game is restarting, and resets the flag + */ + bool shouldRestart(); + + /** * Save the game data to a savegame */ void saveGameData(Common::WriteStream& ws); |