diff options
| -rw-r--r-- | engines/glk/magnetic/glk.cpp | 10 | ||||
| -rw-r--r-- | engines/glk/magnetic/magnetic.cpp | 22 | ||||
| -rw-r--r-- | engines/glk/magnetic/magnetic.h | 17 | ||||
| -rw-r--r-- | engines/glk/magnetic/main.cpp | 75 | ||||
| -rw-r--r-- | engines/glk/module.mk | 3 | 
5 files changed, 45 insertions, 82 deletions
diff --git a/engines/glk/magnetic/glk.cpp b/engines/glk/magnetic/glk.cpp index 67fed7632b..1ef0d83052 100644 --- a/engines/glk/magnetic/glk.cpp +++ b/engines/glk/magnetic/glk.cpp @@ -3979,5 +3979,15 @@ void Magnetic::writeChar(char c) {  	glk_put_char(c);  } +void Magnetic::script_write(type8 c) { +	if (log_on == 2) +		log1->writeByte(c); +} + +void Magnetic::transcript_write(type8 c) { +	if (log2) +		log2->writeByte(c); +} +  } // End of namespace Magnetic  } // End of namespace Glk diff --git a/engines/glk/magnetic/magnetic.cpp b/engines/glk/magnetic/magnetic.cpp index e768deed41..588b66ee6f 100644 --- a/engines/glk/magnetic/magnetic.cpp +++ b/engines/glk/magnetic/magnetic.cpp @@ -66,7 +66,7 @@ Magnetic::Magnetic(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(s  		, hints(nullptr), hint_contents(nullptr), xpos(0), bufpos(0), log_on(0),  		ms_gfx_enabled(0), log1(nullptr), log2(nullptr), GMS_LUMINANCE_WEIGHTS(299, 587, 114),  		linear_gamma(nullptr), pic_current_crc(0), hints_current_crc(0), -		hints_crc_initialized(false) { +		hints_crc_initialized(false), _saveData(nullptr), _saveSize(0) {  	Common::fill(&gms_graphics_palette[0], &gms_graphics_palette[GMS_PALETTE_SIZE], 0);  	Common::fill(&gms_status_buffer[0], &gms_status_buffer[GMS_STATBUFFER_LENGTH], '\0'); @@ -157,14 +157,26 @@ void Magnetic::initializeLinearGamma() {  	}  } +type8 Magnetic::ms_load_file(const char *name, type8 *ptr, type16 size) { +	_saveData = ptr; +	_saveSize = size; + +	return loadGame().getCode() == Common::kNoError ? 0 : 1; +} +  Common::Error Magnetic::readSaveData(Common::SeekableReadStream *rs) { -	// TODO -	return Common::kReadingFailed; +	return rs->read(_saveData, _saveSize) == _saveSize ? Common::kNoError : Common::kReadingFailed; +} + +type8 Magnetic::ms_save_file(const char *name, type8 *ptr, type16 size) { +	_saveData = ptr; +	_saveSize = size; + +	return saveGame().getCode() == Common::kNoError ? 0 : 1;  }  Common::Error Magnetic::writeGameData(Common::WriteStream *ws) { -	// TODO -	return Common::kWritingFailed; +	return ws->write(_saveData, _saveSize) == _saveSize ? Common::kNoError : Common::kWritingFailed;  }  } // End of namespace Magnetic diff --git a/engines/glk/magnetic/magnetic.h b/engines/glk/magnetic/magnetic.h index 6f81df41a1..bb6e935c73 100644 --- a/engines/glk/magnetic/magnetic.h +++ b/engines/glk/magnetic/magnetic.h @@ -254,6 +254,9 @@ private:  	 * subjective results.  	 */  	const gms_rgb_t GMS_LUMINANCE_WEIGHTS; + +	type8 *_saveData; +	size_t _saveSize;  private:  	type8 buffer[80], xpos, bufpos, log_on, ms_gfx_enabled, filename[256];  	Common::DumpFile *log1, *log2; @@ -1381,6 +1384,20 @@ public:  	}  	/** +	 * The Magnetic engine currently doesn't support loading savegames from the GMM +	 */ +	virtual bool canLoadGameStateCurrently() override { +		return false; +	} + +	/** +	 * The Magnetic engine currently doesn't support saving games from the GMM +	 */ +	virtual bool canSaveGameStateCurrently() override { +		return false; +	} + +	/**  	 * Load a savegame from the passed Quetzal file chunk stream  	 */  	virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override; diff --git a/engines/glk/magnetic/main.cpp b/engines/glk/magnetic/main.cpp deleted file mode 100644 index 444aa0a930..0000000000 --- a/engines/glk/magnetic/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "glk/magnetic/magnetic.h" -#include "common/file.h" -#include "common/savefile.h" -#include "common/system.h" - -namespace Glk { -namespace Magnetic { - -#define WIDTH 78 - -type8 Magnetic::ms_load_file(const char *name, type8 *ptr, type16 size) { -	assert(name); -	Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(name); -	if (!file) -		return 1; - -	if (file->read(ptr, size) != size) { -		delete file; -		return 1; -	} - -	delete file; -	return 0; -} - -type8 Magnetic::ms_save_file(const char *name, type8 *ptr, type16 size) { -	assert(name); -	Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(name); -	if (!file) -		return 1; - -	if (file->write(ptr, size) != size) { -		delete file; -		return 1; -	} - -	file->finalize(); -	delete file; -	return 0; -} - -void Magnetic::script_write(type8 c) { -	if (log_on == 2) -		log1->writeByte(c); -} - -void Magnetic::transcript_write(type8 c) { -	if (log2) -		log2->writeByte(c); -} - -} // End of namespace Magnetic -} // End of namespace Glk diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 7c6308fd06..74d3321872 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -263,8 +263,7 @@ MODULE_OBJS += \  	magnetic/detection.o \  	magnetic/emu.o \  	magnetic/glk.o \ -	magnetic/magnetic.o \ -	magnetic/main.o +	magnetic/magnetic.o  endif  ifdef ENABLE_GLK_QUEST  | 
