ACCESS: Adding file loading

This commit is contained in:
Paul Gilbert 2014-08-02 15:14:42 -04:00
parent a94bf197ef
commit a35ba4caf9
11 changed files with 305 additions and 5 deletions

View File

@ -33,15 +33,19 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc)
_gameDescription(gameDesc), Engine(syst), _randomSource("Access") {
_debugger = nullptr;
_events = nullptr;
_files = nullptr;
_graphics = nullptr;
_screen = nullptr;
_sound = nullptr;
}
AccessEngine::~AccessEngine() {
delete _debugger;
delete _events;
delete _files;
delete _graphics;
delete _screen;
delete _sound;
}
void AccessEngine::initialize() {
@ -52,8 +56,10 @@ void AccessEngine::initialize() {
_debugger = new Debugger(this);
_events = new EventsManager(this);
_files = new FileManager(this);
_graphics = new GraphicsManager(this);
_screen = new Screen(this);
_sound = new SoundManager(this);
}
Common::Error AccessEngine::run() {

View File

@ -32,8 +32,10 @@
#include "graphics/surface.h"
#include "access/debugger.h"
#include "access/events.h"
#include "access/files.h"
#include "access/graphics.h"
#include "access/screen.h"
#include "access/sound.h"
/**
* This is the namespace of the Access engine.
@ -49,6 +51,11 @@ namespace Access {
#define DEBUG_INTERMEDIATE 2
#define DEBUG_DETAILED 3
enum {
GType_Amazon = 1,
GType_MeanStreets = 2
};
enum AccessDebugChannels {
kDebugPath = 1 << 0,
kDebugScripts = 1 << 1,
@ -86,8 +93,10 @@ protected:
public:
Debugger *_debugger;
EventsManager *_events;
FileManager *_files;
GraphicsManager *_graphics;
Screen *_screen;
SoundManager *_sound;
public:
AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
virtual ~AccessEngine();

View File

@ -35,6 +35,8 @@ void AmazonEngine::doTitle() {
_screen->forceFadeOut();
_events->hideCursor();
_sound->loadSound(98, 30);
}
} // End of namespace Amazon

View File

@ -22,11 +22,6 @@
namespace Access {
enum {
GType_Amazon = 1,
GType_MeanStreets = 2
};
static const AccessGameDescription gameDescriptions[] = {
{
// Amazon Guadians of Eden - Floppy English

111
engines/access/files.cpp Normal file
View File

@ -0,0 +1,111 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software
* Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA.
*
*/
#include "access/files.h"
#include "access/resources.h"
#include "access/access.h"
namespace Access {
FileManager::FileManager(AccessEngine *vm): _vm(vm) {
switch (vm->getGameID()) {
case GType_Amazon:
_filenames = &Amazon::FILENAMES[0];
break;
default:
error("Unknown game");
}
_fileNumber = -1;
_stream = nullptr;
}
FileManager::~FileManager() {
delete _stream;
_file.close();
}
void FileManager::loadFile(int fileNum, int subfile) {
setAppended(fileNum);
gotoAppended(subfile);
handleFile();
}
void FileManager::loadFile(const Common::String &filename) {
// Open up the file
_fileNumber = -1;
_file.close();
if (_file.open(filename))
error("Could not open file - %s", filename.c_str());
// Get a stream for the entire file
delete _stream;
_stream = _file.readStream(_file.size());
handleFile();
}
void FileManager::handleFile() {
char header[3];
_stream->read(&header[0], 3);
if (!strncmp(header, "BDE", 3))
// Decompress the resource
decompressFile();
else
// Not compressed, so move back to start of data
_stream->seek(0);
}
void FileManager::decompressFile() {
// TODO
}
void FileManager::setAppended(int fileNum) {
if (_fileNumber != fileNum) {
_fileNumber = fileNum;
_file.close();
if (!_file.open(_filenames[fileNum]))
error("Could not open file %s", _filenames[fileNum]);
// Read in the file index
_fileIndex.resize(50);
for (int i = 0; i < 50; ++i) {
_fileIndex[i]._offset = _file.readUint32LE();
_fileIndex[i]._nextOffset = _file.readUint32LE();
}
}
}
void FileManager::gotoAppended(int subfile) {
uint32 offset = _fileIndex[subfile]._offset;
uint32 size = _fileIndex[subfile]._nextOffset - offset;
_file.seek(offset);
delete _stream;
_stream = _file.readStream(size);
}
} // End of namespace Access

76
engines/access/files.h Normal file
View File

@ -0,0 +1,76 @@
/* 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 ACCESS_FILES_H
#define ACCESS_FILES_H
#include "common/scummsys.h"
#include "common/file.h"
namespace Access {
class AccessEngine;
struct FileEntry {
uint32 _offset;
uint32 _nextOffset;
};
class FileManager {
private:
AccessEngine *_vm;
const char * const *_filenames;
void handleFile();
void decompressFile();
public:
int _fileNumber;
Common::File _file;
Common::SeekableReadStream *_stream;
Common::Array<FileEntry> _fileIndex;
uint32 _entryOffset;
uint32 _nextOffset;
public:
FileManager(AccessEngine *vm);
~FileManager();
void loadFile(int fileNum, int subfile);
void loadFile(const Common::String &filename);
/**
* Open up a sub-file container file
*/
void setAppended(int fileNum);
/**
* Open up a sub-file resource within an alrady opened container file.
*/
void gotoAppended(int subfile);
};
} // End of namespace Access
#endif /* ACCESS_FILES_H */

View File

@ -5,9 +5,11 @@ MODULE_OBJS := \
debugger.o \
detection.o \
events.o \
files.o \
graphics.o \
resources.o \
screen.o \
sound.o \
amazon\amazon_game.o
# This module can be built as a plugin

View File

@ -21,6 +21,7 @@
*/
#include "access/resources.h"
#include "access/access.h"
namespace Access {
@ -47,6 +48,30 @@ const byte INITIAL_PALETTE[18 * 3] = {
namespace Amazon {
const char *const FILENAMES[] = {
"S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP",
"S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP",
"S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP",
"S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP",
"S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP",
"S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP",
"S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP",
"S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP",
"C36.AP", nullptr, "S50.AP", nullptr, nullptr, "S53.AP",
"S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr,
nullptr, "S61.AP", nullptr, nullptr, "S64.AP", "C00.AP",
"C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP",
"C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP",
"C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP",
"C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP",
"C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP",
"EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP",
"NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP",
"NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP",
"NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP",
"NARATE13.AP", "NARATE14.AP"
};
const byte *CURSORS[10] = {
MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP
};

View File

@ -31,6 +31,8 @@ extern const byte INITIAL_PALETTE[18 * 3];
namespace Amazon {
extern const char *const FILENAMES[];
extern const byte MOUSE0[];
extern const byte MOUSE1[];
extern const byte MOUSE2[];

29
engines/access/sound.cpp Normal file
View File

@ -0,0 +1,29 @@
/* 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 "access/sound.h"
namespace Access {
SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {}
} // End of namespace Access

43
engines/access/sound.h Normal file
View File

@ -0,0 +1,43 @@
/* 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 ACCESS_SOUND_H
#define ACCESS_SOUND_H
namespace Access {
class AccessEngine;
class SoundManager {
private:
AccessEngine *_vm;
public:
int _soundPriority;
public:
SoundManager(AccessEngine *vm);
void loadSound(int fileNum, int subfile) {}
};
} // End of namespace Access
#endif /* ACCESS_SOUND_H*/