From c5ab591b791d96783d9fdb7796a162cbe246b08b Mon Sep 17 00:00:00 2001 From: Vladimir Menshakov Date: Sun, 12 Jun 2011 17:39:15 +0400 Subject: DREAMWEB: unstabbed save --- engines/dreamweb/dreamweb.cpp | 27 +++++++++++++++++++++++---- engines/dreamweb/dreamweb.h | 5 +++++ 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 2c03e369e1..817496d73b 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -29,7 +29,6 @@ #include "common/EventRecorder.h" #include "common/file.h" #include "common/func.h" -#include "common/savefile.h" #include "common/system.h" #include "common/timer.h" #include "common/util.h" @@ -196,7 +195,22 @@ uint32 DreamWebEngine::readFromFile(uint8 *dst, unsigned size) { void DreamWebEngine::closeFile() { processEvents(); - _file.close(); + if (_file.isOpen()) + _file.close(); + delete _saveFile; + _saveFile = 0; +} + +void DreamWebEngine::openSaveFile(const Common::String &name) { + processEvents(); + _saveFile = _system->getSavefileManager()->openForSaving(name); +} + +uint DreamWebEngine::writeToSaveFile(const uint8 *data, uint size) { + processEvents(); + if (!_saveFile) + error("save file was not opened"); + return _saveFile->write(data, size); } void DreamWebEngine::keyPressed(uint16 ascii) { @@ -408,7 +422,9 @@ void closefile(Context &context) { } void openforsave(Context &context) { - ::error("openforsave"); + const char *name = (const char *)context.ds.ptr(context.dx, 13); + debug(1, "openforsave(%s)", name); + engine()->openSaveFile(name); } void openfilenocheck(Context &context) { @@ -581,10 +597,13 @@ void scanfornames(Context &context) { } void saveseg(Context &context) { - ::error("saveseg"); + context.cx = context.es.word(context.di); + context._add(context.di, 2); + savefilewrite(context); } void savefilewrite(Context &context) { + engine()->writeToSaveFile(context.ds.ptr(context.dx, context.cx), context.cx); } void savefileread(Context &context) { diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h index 633d5075e0..7e99bf5e78 100644 --- a/engines/dreamweb/dreamweb.h +++ b/engines/dreamweb/dreamweb.h @@ -30,6 +30,7 @@ #include "common/file.h" #include "common/random.h" #include "common/rect.h" +#include "common/savefile.h" #include "common/scummsys.h" #include "engines/engine.h" @@ -89,6 +90,9 @@ public: void getPalette(uint8 *data, uint start, uint count); void setPalette(const uint8 *data, uint start, uint count); + + void openSaveFile(const Common::String &name); + uint writeToSaveFile(const uint8 *data, uint size); private: @@ -100,6 +104,7 @@ private: unsigned _mouseState; Common::File _file; + Common::OutSaveFile *_saveFile; dreamgen::Context _context; }; -- cgit v1.2.3