aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2012-09-08 09:09:09 +1000
committerPaul Gilbert2012-09-08 09:09:09 +1000
commitc10f87f9c88b7ffd0a0652727fa91fd76929786f (patch)
treef8c9875677b3a2646b27c4aa9fa1c765fd01a65b
parentf2012c6ad9e48673270ec0c0acda363eb69cc275 (diff)
downloadscummvm-rg350-c10f87f9c88b7ffd0a0652727fa91fd76929786f.tar.gz
scummvm-rg350-c10f87f9c88b7ffd0a0652727fa91fd76929786f.tar.bz2
scummvm-rg350-c10f87f9c88b7ffd0a0652727fa91fd76929786f.zip
HOPKINS: Beginnings of file manager code
-rw-r--r--engines/hopkins/files.cpp127
-rw-r--r--engines/hopkins/globals.h16
-rw-r--r--engines/hopkins/hopkins.cpp8
-rw-r--r--engines/hopkins/hopkins.h2
4 files changed, 144 insertions, 9 deletions
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
new file mode 100644
index 0000000000..1f3434517e
--- /dev/null
+++ b/engines/hopkins/files.cpp
@@ -0,0 +1,127 @@
+/* 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 "hopkins/files.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/globals.h"
+#include "common/system.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/str.h"
+#include "common/savefile.h"
+
+namespace Hopkins {
+
+void FileManager::initSaves() {
+ Common::String dataFilename = "HISCORE.DAT";
+ byte data[100];
+ Common::fill(&data[0], &data[100], 0);
+
+ SAUVE_FICHIER(dataFilename, data, 100);
+}
+
+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;
+}
+
+void FileManager::Chage_Inifile(Common::StringMap &iniParams) {
+ char *iniData = (char *)CHARGE_FICHIER("config.ini");
+ char *ptr = iniData;
+
+ bool endOfFile = false;
+ while (!endOfFile) {
+ if (*ptr == '%') {
+ if (*(ptr + 1) == '%') {
+ endOfFile = true;
+ } else {
+ ++ptr;
+
+ // Get the parameter name
+ Common::String paramName;
+ while (*ptr == ' ')
+ ++ptr;
+ while (*ptr != '=') {
+ paramName += toupper(*ptr++);
+ }
+ while (paramName.lastChar() == ' ')
+ paramName.deleteLastChar();
+
+ // Get the parameter value
+ Common::String paramValue;
+ while (*++ptr == ' ')
+ ;
+ while (*ptr != ';') {
+ paramValue += toupper(*ptr++);
+ }
+ while (paramValue.lastChar() == ' ')
+ paramValue.deleteLastChar();
+
+ iniParams[paramName] = paramValue;
+ }
+ }
+
+ ++ptr;
+ }
+
+ free(iniData);
+}
+
+void *FileManager::CHARGE_FICHIER(const Common::String &file) {
+ DMESS1();
+
+ Common::File f;
+ if (!f.open(file))
+ error("Error opening %s", file.c_str());
+
+ // Allocate space for the file contents
+ size_t filesize = f.size();
+ void *data = malloc(filesize);
+ if (!data)
+ error("Error allocating space for file being loaded - %s", file.c_str());
+
+ bload_it(f, data, filesize);
+ f.close();
+
+ return data;
+}
+
+void FileManager::DMESS1() {
+}
+
+int FileManager::bload_it(Common::ReadStream &stream, void *buf, size_t nbytes) {
+ return stream.read(buf, nbytes);
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
index bb6a3935dd..ec980a975d 100644
--- a/engines/hopkins/globals.h
+++ b/engines/hopkins/globals.h
@@ -24,7 +24,6 @@
#define HOPKINS_GLOBALS_H
#include "common/scummsys.h"
-#include "common/hash-str.h"
namespace Hopkins {
@@ -33,14 +32,13 @@ namespace Hopkins {
*/
class Globals {
public:
- int FADESPD;
- int FR;
- int SVGA;
- int MANU_SCROLL;
- int SPEED_SCROLL;
- int internet;
- int PUBEXIT;
- Common::StringMap _iniParams;
+ int FADESPD;
+ int FR;
+ int SVGA;
+ int MANU_SCROLL;
+ int SPEED_SCROLL;
+ int internet;
+ int PUBEXIT;
Globals();
};
diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp
index f29a4237e7..16e75784d5 100644
--- a/engines/hopkins/hopkins.cpp
+++ b/engines/hopkins/hopkins.cpp
@@ -46,6 +46,10 @@ Common::Error HopkinsEngine::run() {
FileManager::initSaves();
+ Common::StringMap iniParams;
+ FileManager::Chage_Inifile(iniParams);
+ processIniParams(iniParams);
+
/*
Chage_Inifile();
LOAD_CONFIG();
@@ -525,4 +529,8 @@ int HopkinsEngine::getRandomNumber(int maxNumber) {
return _randomSource.getRandomNumber(maxNumber);
}
+void HopkinsEngine::processIniParams(Common::StringMap &iniParams) {
+
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
index f84463ab3e..c4f8415543 100644
--- a/engines/hopkins/hopkins.h
+++ b/engines/hopkins/hopkins.h
@@ -27,6 +27,7 @@
#include "common/system.h"
#include "common/error.h"
#include "common/random.h"
+#include "common/hash-str.h"
#include "common/util.h"
#include "engines/engine.h"
#include "hopkins/globals.h"
@@ -60,6 +61,7 @@ private:
const HopkinsGameDescription *_gameDescription;
Common::RandomSource _randomSource;
+ void processIniParams(Common::StringMap &iniParams);
protected:
// Engine APIs
virtual Common::Error run();