CHEWY: Only allow GMM saving/loading from main game loop

This commit is contained in:
Paul Gilbert 2021-10-23 21:50:27 -07:00
parent 264835e44a
commit c7a89d1c0a
5 changed files with 32 additions and 14 deletions

View File

@ -37,10 +37,7 @@ Graphics::Screen *g_screen;
ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc) ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc)
: Engine(syst), : Engine(syst),
_gameDescription(gameDesc), _gameDescription(gameDesc),
_rnd("chewy"), _rnd("chewy") {
_events(nullptr),
_screen(nullptr),
_sound(nullptr) {
g_engine = this; g_engine = this;
g_screen = nullptr; g_screen = nullptr;

View File

@ -49,6 +49,10 @@ class ChewyEngine : public Engine {
protected: protected:
// Engine APIs // Engine APIs
Common::Error run() override; Common::Error run() override;
/**
* Returns engine features
*/
bool hasFeature(EngineFeature f) const override; bool hasFeature(EngineFeature f) const override;
void initialize(); void initialize();
@ -58,9 +62,10 @@ public:
const ChewyGameDescription *_gameDescription; const ChewyGameDescription *_gameDescription;
Common::RandomSource _rnd; Common::RandomSource _rnd;
TempFileArchive _tempFiles; TempFileArchive _tempFiles;
EventsManager *_events; EventsManager *_events = nullptr;
Sound *_sound; Sound *_sound = nullptr;
Graphics::Screen *_screen; Graphics::Screen *_screen = nullptr;
bool _canLoadSave = false;
public: public:
ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc); ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc);
~ChewyEngine() override; ~ChewyEngine() override;
@ -68,6 +73,13 @@ public:
uint32 getFeatures() const; uint32 getFeatures() const;
Common::Language getLanguage() const; Common::Language getLanguage() const;
bool canLoadGameStateCurrently() override {
return _canLoadSave;
}
bool canSaveGameStateCurrently() override {
return _canLoadSave;
}
/** /**
* Load savegame data * Load savegame data
*/ */

View File

@ -43,9 +43,11 @@ namespace Chewy {
#define SCREEN_WIDTH 320 #define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200 #define SCREEN_HEIGHT 200
#define NO_SETUP 0 enum SetupScreenMode {
NO_SETUP = 0,
#define DO_SETUP 1 DO_SETUP = 1,
DO_MAIN_LOOP = 2
};
#define MIN_FAR_MEM 3000000 #define MIN_FAR_MEM 3000000
#define MIN_LOW_MEM 100000 #define MIN_LOW_MEM 100000

View File

@ -240,7 +240,7 @@ void free_buffers();
int16 main_loop(int16 mode); int16 main_loop(int16 mode);
void set_up_screen(int16 mode); void set_up_screen(SetupScreenMode mode);
void kb_mov(int16 mode); void kb_mov(int16 mode);

View File

@ -540,21 +540,25 @@ int16 main_loop(int16 mode) {
} }
kbinfo.scan_code = Common::KEYCODE_INVALID; kbinfo.scan_code = Common::KEYCODE_INVALID;
if (mode == DO_SETUP) if (mode == DO_SETUP)
set_up_screen(DO_SETUP); set_up_screen(DO_MAIN_LOOP);
#ifdef DEMO #ifdef DEMO
if (spieler.PersonRoomNr[P_CHEWY] > 24) if (spieler.PersonRoomNr[P_CHEWY] > 24)
ende = 1; ende = 1;
#endif #endif
return (ende); return ende;
} }
void set_up_screen(int16 mode) { void set_up_screen(SetupScreenMode mode) {
int16 nr; int16 nr;
int16 tmp; int16 tmp;
int16 i; int16 i;
int16 *ScrXy; int16 *ScrXy;
int16 txt_nr; int16 txt_nr;
bool isMainLoop = mode == DO_MAIN_LOOP;
if (isMainLoop)
mode = DO_SETUP;
if (flags.InitSound && spieler.SpeechSwitch) if (flags.InitSound && spieler.SpeechSwitch)
ailsnd->serve_db_samples(); ailsnd->serve_db_samples();
uhr->calc_timer(); uhr->calc_timer();
@ -716,7 +720,10 @@ void set_up_screen(int16 mode) {
&spieler.scrollx, &spieler.scrolly); &spieler.scrollx, &spieler.scrolly);
g_screen->update(); g_screen->update();
g_engine->_canLoadSave = isMainLoop;
g_events->update(); g_events->update();
g_engine->_canLoadSave = false;
} }
void mous_obj_action(int16 nr, int16 mode, int16 txt_mode, int16 txt_nr) { void mous_obj_action(int16 nr, int16 mode, int16 txt_mode, int16 txt_nr) {