aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/hopkins/anim.cpp8
-rw-r--r--engines/hopkins/files.cpp27
-rw-r--r--engines/hopkins/files.h3
-rw-r--r--engines/hopkins/hopkins.cpp4
-rw-r--r--engines/hopkins/hopkins.h2
-rw-r--r--engines/hopkins/menu.cpp4
-rw-r--r--engines/hopkins/module.mk1
-rw-r--r--engines/hopkins/objects.cpp2
-rw-r--r--engines/hopkins/saveload.cpp61
-rw-r--r--engines/hopkins/saveload.h46
-rw-r--r--engines/hopkins/talk.cpp14
11 files changed, 129 insertions, 43 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp
index afaf37253c..7622302fc3 100644
--- a/engines/hopkins/anim.cpp
+++ b/engines/hopkins/anim.cpp
@@ -273,9 +273,9 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint
memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u);
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
if (_vm->_graphicsManager.nbrligne == 1280)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
if (!_vm->_graphicsManager.nbrligne)
_vm->_graphicsManager.ofscroll = 0;
v12 = _vm->_graphicsManager.VESA_SCREEN;
@@ -972,9 +972,9 @@ void AnimationManager::PLAY_SEQ(int a1, const Common::String &a2, uint32 a3, uin
_vm->_eventsManager.VBL();
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
if (!_vm->_graphicsManager.nbrligne)
_vm->_graphicsManager.ofscroll = 0;
}
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
index 151a9a84f8..79b672ca33 100644
--- a/engines/hopkins/files.cpp
+++ b/engines/hopkins/files.cpp
@@ -38,32 +38,6 @@ void FileManager::setParent(HopkinsEngine *vm) {
_vm = vm;
}
-void FileManager::initSaves() {
- Common::String dataFilename = "HISCORE.DAT";
- byte data[100];
- Common::fill(&data[0], &data[100], 0);
-
- SAUVE_FICHIER(dataFilename, data, 100);
-}
-
-// Save File
-bool FileManager::SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n) {
- return bsave(file, buf, n);
-}
-
-bool FileManager::bsave(const Common::String &file, const void *buf, size_t n) {
- Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(file);
-
- if (f) {
- size_t bytesWritten = f->write(buf, n);
- f->finalize();
- delete f;
-
- return bytesWritten == n;
- } else
- return false;
-}
-
// Load INI File
void FileManager::Chage_Inifile(Common::StringMap &iniParams) {
// TODO: Review whether we can do something cleaner with ScummVM initialisation than
@@ -342,6 +316,7 @@ uint32 FileManager::FLONG(const Common::String &filename) {
// Build Linux
Common::String FileManager::CONSTRUIT_LINUX(const Common::String &file) {
+ _vm->_globals.NFICHIER = file;
return file;
}
diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h
index 9aece5fba3..d9df4341ca 100644
--- a/engines/hopkins/files.h
+++ b/engines/hopkins/files.h
@@ -39,9 +39,6 @@ public:
FileManager();
void setParent(HopkinsEngine *vm);
- void initSaves();
- bool SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n);
- bool bsave(const Common::String &file, const void *buf, size_t n);
void Chage_Inifile(Common::StringMap &iniParams);
byte *CHARGE_FICHIER(const Common::String &file);
void CHARGE_FICHIER2(const Common::String &file, byte *a2);
diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp
index 08f4b9f874..97271313f6 100644
--- a/engines/hopkins/hopkins.cpp
+++ b/engines/hopkins/hopkins.cpp
@@ -28,6 +28,7 @@
#include "hopkins/graphics.h"
#include "hopkins/hopkins.h"
#include "hopkins/files.h"
+#include "hopkins/saveload.h"
#include "hopkins/sound.h"
#include "hopkins/talk.h"
@@ -49,6 +50,7 @@ HopkinsEngine::HopkinsEngine(OSystem *syst, const HopkinsGameDescription *gameDe
_linesManager.setParent(this);
_menuManager.setParent(this);
_objectsManager.setParent(this);
+ _saveLoadManager.setParent(this);
_scriptManager.setParent(this);
_soundManager.setParent(this);
_talkManager.setParent(this);
@@ -58,7 +60,7 @@ HopkinsEngine::~HopkinsEngine() {
}
Common::Error HopkinsEngine::run() {
- _fileManager.initSaves();
+ _saveLoadManager.initSaves();
Common::StringMap iniParams;
_fileManager.Chage_Inifile(iniParams);
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
index 0b6818d8cd..6a0eb2e5cd 100644
--- a/engines/hopkins/hopkins.h
+++ b/engines/hopkins/hopkins.h
@@ -42,6 +42,7 @@
#include "hopkins/lines.h"
#include "hopkins/menu.h"
#include "hopkins/objects.h"
+#include "hopkins/saveload.h"
#include "hopkins/script.h"
#include "hopkins/sound.h"
#include "hopkins/talk.h"
@@ -107,6 +108,7 @@ public:
LinesManager _linesManager;
MenuManager _menuManager;
ObjectsManager _objectsManager;
+ SaveLoadManager _saveLoadManager;
ScriptManager _scriptManager;
SoundManager _soundManager;
TalkManager _talkManager;
diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp
index 58616e59d8..1de66a103c 100644
--- a/engines/hopkins/menu.cpp
+++ b/engines/hopkins/menu.cpp
@@ -353,14 +353,14 @@ void MenuManager::SAUVE_PARTIE() {
} while (v4 <= 34);
_vm->_fileManager.CONSTRUIT_LINUX(v7);
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0], 0x7D0u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, &_vm->_globals.SAUVEGARDE->data[0], 0x7D0u);
v12 = 46;
v13 = 69;
v14 = 67;
v15 = 82;
v16 = 0;
_vm->_fileManager.CONSTRUIT_LINUX(v7);
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, v1, 0x2B80u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, v1, 0x2B80u);
}
_vm->_globals.dos_free2(v1);
}
diff --git a/engines/hopkins/module.mk b/engines/hopkins/module.mk
index dbed88c668..109104f229 100644
--- a/engines/hopkins/module.mk
+++ b/engines/hopkins/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
lines.o \
menu.o \
objects.o \
+ saveload.o \
script.o \
sound.o \
talk.o
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index c94544f5ae..e60d72ba68 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -4301,7 +4301,7 @@ void ObjectsManager::SPECIAL_JEU() {
v1 = _vm->_globals.dos_malloc2(0x3E8u);
memcpy(v1, _vm->_graphicsManager.Palette, 0x301u);
_vm->_fileManager.CONSTRUIT_LINUX("TEMP1.SCR");
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
if (!_vm->_graphicsManager.nbrligne)
_vm->_graphicsManager.ofscroll = 0;
_vm->_graphicsManager.NB_SCREEN();
diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp
new file mode 100644
index 0000000000..ed4e3f1596
--- /dev/null
+++ b/engines/hopkins/saveload.cpp
@@ -0,0 +1,61 @@
+/* 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 "common/system.h"
+#include "common/savefile.h"
+#include "hopkins/saveload.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+
+namespace Hopkins {
+
+void SaveLoadManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+bool SaveLoadManager::bsave(const Common::String &file, const void *buf, size_t n) {
+ Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(file);
+
+ if (f) {
+ size_t bytesWritten = f->write(buf, n);
+ f->finalize();
+ delete f;
+
+ return bytesWritten == n;
+ } else
+ return false;
+}
+
+// Save File
+bool SaveLoadManager::SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n) {
+ return bsave(file, buf, n);
+}
+
+void SaveLoadManager::initSaves() {
+ Common::String dataFilename = "HISCORE.DAT";
+ byte data[100];
+ Common::fill(&data[0], &data[100], 0);
+
+ SAUVE_FICHIER(dataFilename, data, 100);
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/saveload.h b/engines/hopkins/saveload.h
new file mode 100644
index 0000000000..d35d529749
--- /dev/null
+++ b/engines/hopkins/saveload.h
@@ -0,0 +1,46 @@
+/* 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.
+ *
+ */
+
+#ifndef HOPKINS_SAVELOAD_H
+#define HOPKINS_SAVELOAD_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class SaveLoadManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ void setParent(HopkinsEngine *vm);
+
+ void initSaves();
+ bool bsave(const Common::String &file, const void *buf, size_t n);
+ bool SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_SAVELOAD_H */
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index b010afd6eb..1630ce6013 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -91,11 +91,13 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) {
}
PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
_vm->_globals.CAT_FLAG = 0;
+
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
- if (_vm->_graphicsManager.nbrligne == 640)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
- if (_vm->_graphicsManager.nbrligne == 1280)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+
if (!_vm->_graphicsManager.nbrligne)
_vm->_graphicsManager.ofscroll = 0;
_vm->_graphicsManager.NB_SCREEN();
@@ -1214,9 +1216,9 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) {
_vm->_globals.CAT_FLAG = 0;
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
- _vm->_fileManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
if (!_vm->_graphicsManager.nbrligne)
_vm->_graphicsManager.ofscroll = 0;
_vm->_graphicsManager.NB_SCREEN();