HOPKINS: Created new SaveFileManager class to handle save file related code
This commit is contained in:
parent
9827c4023c
commit
38b5cf1efe
11 changed files with 129 additions and 43 deletions
|
@ -273,9 +273,9 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint
|
||||||
memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u);
|
memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u);
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
||||||
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
|
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)
|
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)
|
if (!_vm->_graphicsManager.nbrligne)
|
||||||
_vm->_graphicsManager.ofscroll = 0;
|
_vm->_graphicsManager.ofscroll = 0;
|
||||||
v12 = _vm->_graphicsManager.VESA_SCREEN;
|
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->_eventsManager.VBL();
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
||||||
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
|
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))
|
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)
|
if (!_vm->_graphicsManager.nbrligne)
|
||||||
_vm->_graphicsManager.ofscroll = 0;
|
_vm->_graphicsManager.ofscroll = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,32 +38,6 @@ void FileManager::setParent(HopkinsEngine *vm) {
|
||||||
_vm = 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
|
// Load INI File
|
||||||
void FileManager::Chage_Inifile(Common::StringMap &iniParams) {
|
void FileManager::Chage_Inifile(Common::StringMap &iniParams) {
|
||||||
// TODO: Review whether we can do something cleaner with ScummVM initialisation than
|
// 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
|
// Build Linux
|
||||||
Common::String FileManager::CONSTRUIT_LINUX(const Common::String &file) {
|
Common::String FileManager::CONSTRUIT_LINUX(const Common::String &file) {
|
||||||
|
_vm->_globals.NFICHIER = file;
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,6 @@ public:
|
||||||
FileManager();
|
FileManager();
|
||||||
void setParent(HopkinsEngine *vm);
|
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);
|
void Chage_Inifile(Common::StringMap &iniParams);
|
||||||
byte *CHARGE_FICHIER(const Common::String &file);
|
byte *CHARGE_FICHIER(const Common::String &file);
|
||||||
void CHARGE_FICHIER2(const Common::String &file, byte *a2);
|
void CHARGE_FICHIER2(const Common::String &file, byte *a2);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "hopkins/graphics.h"
|
#include "hopkins/graphics.h"
|
||||||
#include "hopkins/hopkins.h"
|
#include "hopkins/hopkins.h"
|
||||||
#include "hopkins/files.h"
|
#include "hopkins/files.h"
|
||||||
|
#include "hopkins/saveload.h"
|
||||||
#include "hopkins/sound.h"
|
#include "hopkins/sound.h"
|
||||||
#include "hopkins/talk.h"
|
#include "hopkins/talk.h"
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ HopkinsEngine::HopkinsEngine(OSystem *syst, const HopkinsGameDescription *gameDe
|
||||||
_linesManager.setParent(this);
|
_linesManager.setParent(this);
|
||||||
_menuManager.setParent(this);
|
_menuManager.setParent(this);
|
||||||
_objectsManager.setParent(this);
|
_objectsManager.setParent(this);
|
||||||
|
_saveLoadManager.setParent(this);
|
||||||
_scriptManager.setParent(this);
|
_scriptManager.setParent(this);
|
||||||
_soundManager.setParent(this);
|
_soundManager.setParent(this);
|
||||||
_talkManager.setParent(this);
|
_talkManager.setParent(this);
|
||||||
|
@ -58,7 +60,7 @@ HopkinsEngine::~HopkinsEngine() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error HopkinsEngine::run() {
|
Common::Error HopkinsEngine::run() {
|
||||||
_fileManager.initSaves();
|
_saveLoadManager.initSaves();
|
||||||
|
|
||||||
Common::StringMap iniParams;
|
Common::StringMap iniParams;
|
||||||
_fileManager.Chage_Inifile(iniParams);
|
_fileManager.Chage_Inifile(iniParams);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "hopkins/lines.h"
|
#include "hopkins/lines.h"
|
||||||
#include "hopkins/menu.h"
|
#include "hopkins/menu.h"
|
||||||
#include "hopkins/objects.h"
|
#include "hopkins/objects.h"
|
||||||
|
#include "hopkins/saveload.h"
|
||||||
#include "hopkins/script.h"
|
#include "hopkins/script.h"
|
||||||
#include "hopkins/sound.h"
|
#include "hopkins/sound.h"
|
||||||
#include "hopkins/talk.h"
|
#include "hopkins/talk.h"
|
||||||
|
@ -107,6 +108,7 @@ public:
|
||||||
LinesManager _linesManager;
|
LinesManager _linesManager;
|
||||||
MenuManager _menuManager;
|
MenuManager _menuManager;
|
||||||
ObjectsManager _objectsManager;
|
ObjectsManager _objectsManager;
|
||||||
|
SaveLoadManager _saveLoadManager;
|
||||||
ScriptManager _scriptManager;
|
ScriptManager _scriptManager;
|
||||||
SoundManager _soundManager;
|
SoundManager _soundManager;
|
||||||
TalkManager _talkManager;
|
TalkManager _talkManager;
|
||||||
|
|
|
@ -353,14 +353,14 @@ void MenuManager::SAUVE_PARTIE() {
|
||||||
} while (v4 <= 34);
|
} while (v4 <= 34);
|
||||||
|
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX(v7);
|
_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;
|
v12 = 46;
|
||||||
v13 = 69;
|
v13 = 69;
|
||||||
v14 = 67;
|
v14 = 67;
|
||||||
v15 = 82;
|
v15 = 82;
|
||||||
v16 = 0;
|
v16 = 0;
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX(v7);
|
_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);
|
_vm->_globals.dos_free2(v1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ MODULE_OBJS := \
|
||||||
lines.o \
|
lines.o \
|
||||||
menu.o \
|
menu.o \
|
||||||
objects.o \
|
objects.o \
|
||||||
|
saveload.o \
|
||||||
script.o \
|
script.o \
|
||||||
sound.o \
|
sound.o \
|
||||||
talk.o
|
talk.o
|
||||||
|
|
|
@ -4301,7 +4301,7 @@ void ObjectsManager::SPECIAL_JEU() {
|
||||||
v1 = _vm->_globals.dos_malloc2(0x3E8u);
|
v1 = _vm->_globals.dos_malloc2(0x3E8u);
|
||||||
memcpy(v1, _vm->_graphicsManager.Palette, 0x301u);
|
memcpy(v1, _vm->_graphicsManager.Palette, 0x301u);
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX("TEMP1.SCR");
|
_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)
|
if (!_vm->_graphicsManager.nbrligne)
|
||||||
_vm->_graphicsManager.ofscroll = 0;
|
_vm->_graphicsManager.ofscroll = 0;
|
||||||
_vm->_graphicsManager.NB_SCREEN();
|
_vm->_graphicsManager.NB_SCREEN();
|
||||||
|
|
61
engines/hopkins/saveload.cpp
Normal file
61
engines/hopkins/saveload.cpp
Normal file
|
@ -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
|
46
engines/hopkins/saveload.h
Normal file
46
engines/hopkins/saveload.h
Normal file
|
@ -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 */
|
|
@ -91,11 +91,13 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) {
|
||||||
}
|
}
|
||||||
PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
|
PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
|
||||||
_vm->_globals.CAT_FLAG = 0;
|
_vm->_globals.CAT_FLAG = 0;
|
||||||
|
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
||||||
if (_vm->_graphicsManager.nbrligne == 640)
|
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)
|
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)
|
if (!_vm->_graphicsManager.nbrligne)
|
||||||
_vm->_graphicsManager.ofscroll = 0;
|
_vm->_graphicsManager.ofscroll = 0;
|
||||||
_vm->_graphicsManager.NB_SCREEN();
|
_vm->_graphicsManager.NB_SCREEN();
|
||||||
|
@ -1214,9 +1216,9 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) {
|
||||||
_vm->_globals.CAT_FLAG = 0;
|
_vm->_globals.CAT_FLAG = 0;
|
||||||
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
_vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
|
||||||
if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
|
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))
|
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)
|
if (!_vm->_graphicsManager.nbrligne)
|
||||||
_vm->_graphicsManager.ofscroll = 0;
|
_vm->_graphicsManager.ofscroll = 0;
|
||||||
_vm->_graphicsManager.NB_SCREEN();
|
_vm->_graphicsManager.NB_SCREEN();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue