diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/animation.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/archive.cpp | 53 | ||||
-rw-r--r-- | engines/parallaction/defs.h | 2 | ||||
-rw-r--r-- | engines/parallaction/disk.h | 10 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 46 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/parser.h | 2 |
7 files changed, 55 insertions, 66 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index 25e2e937c0..c81a6d4d10 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -259,10 +259,10 @@ void Parallaction::loadProgram(Animation *a, char *filename) { if (!_archive.openArchivedFile(vC8)) errorFileNotFound(vC8); - uint32 size = _archive.getArchivedFileLength(); + uint32 size = _archive.size(); char* src = (char*)memAlloc(size+1); - _archive.readArchivedFile(src, size); + _archive.read(src, size); src[size] = '\0'; _archive.closeArchivedFile(); diff --git a/engines/parallaction/archive.cpp b/engines/parallaction/archive.cpp index 9d3aced9eb..e83bcecc13 100644 --- a/engines/parallaction/archive.cpp +++ b/engines/parallaction/archive.cpp @@ -89,7 +89,6 @@ bool Archive::openArchivedFile(const char *name) { _file = true; - _fileIndex = i; _fileOffset = _archiveOffsets[i]; _fileCursor = _archiveOffsets[i]; _fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i]; @@ -101,7 +100,6 @@ bool Archive::openArchivedFile(const char *name) { void Archive::resetArchivedFile() { _file = false; - _fileIndex = 0; _fileCursor = 0; _fileOffset = 0; _fileEndOffset = 0; @@ -112,44 +110,51 @@ void Archive::closeArchivedFile() { } -uint16 Archive::getArchivedFileLength() { -// printf("getArchivedFileLength(%s)\n", name); - +uint32 Archive::size() { return (_file == true ? _fileEndOffset - _fileOffset : 0); } +void Archive::seek(int32 offs, int whence) { + assert(_file == true && _fileCursor <= _fileEndOffset); + + switch (whence) { + case SEEK_CUR: + _fileCursor += offs; + break; + case SEEK_SET: + _fileCursor = _fileOffset + offs; + break; + case SEEK_END: + _fileCursor = _fileEndOffset - offs; + break; + } + assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset); -int16 Archive::readArchivedFile(void *buffer, uint16 size) { -// printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset); + _archive.seek(_fileCursor, SEEK_SET); +} + +uint32 Archive::read(void *dataPtr, uint32 dataSize) { +// printf("read(%i, %i)\n", file->_cursor, file->_endOffset); if (_file == false) - error("readArchiveFile: no archived file is currently open"); + error("Archive::read: no archived file is currently open"); - if (_fileCursor == _fileEndOffset) return -1; + if (_fileCursor >= _fileEndOffset) + error("can't read beyond end of archived file"); - if (_fileEndOffset - _fileCursor < size) - size = _fileEndOffset - _fileCursor; + if (_fileEndOffset - _fileCursor < dataSize) + dataSize = _fileEndOffset - _fileCursor; - _archive.seek(_fileCursor); - int16 read = _archive.read(buffer, size); + int32 read = _archive.read(dataPtr, dataSize); _fileCursor += read; return read; } -char *Archive::readArchivedFileText(char *buf, uint16 size) { - if (_file == false) - error("readArchiveFileText: no archived file is currently open"); - - char *t = _archive.readLine(buf, size); - - if (_archive.eof() || t == NULL) - return NULL; - - return t; +uint32 Archive::write(const void *dataPtr, uint32 dataSize) { + error("Archive files don't support writing"); } - } // namespace Parallaction diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h index e2899605ee..b475e3b170 100644 --- a/engines/parallaction/defs.h +++ b/engines/parallaction/defs.h @@ -79,8 +79,6 @@ struct Cnv { uint16 _count; // # of frames }; - -struct ArchivedFile; struct Animation; struct Zone; struct ZoneLabel; diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index 256d94b77a..033f89efcc 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -37,12 +37,11 @@ namespace Parallaction { #define DIRECTORY_OFFSET_IN_FILE 0x4000 -class Archive { +class Archive : public Common::File { protected: bool _file; - uint16 _fileIndex; uint32 _fileOffset; uint32 _fileCursor; uint32 _fileEndOffset; @@ -65,10 +64,11 @@ public: bool openArchivedFile(const char *name); void closeArchivedFile(); - uint16 getArchivedFileLength(); + uint32 size(); + void seek(int32 offs, int whence = SEEK_SET); - int16 readArchivedFile(void *buffer, uint16 size); - char *readArchivedFileText(char *buf, uint16 size); + uint32 read(void *dataPtr, uint32 dataSize); + uint32 write(const void *dataPtr, uint32 dataSize); }; diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 8ad13ccdf3..decb3a1e7a 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -1026,22 +1026,17 @@ void Graphics::loadStaticCnv(const char *filename, StaticCnv *cnv) { errorFileNotFound(path); } - cnv->_width = cnv->_height = 0; - - byte unk; - _vm->_archive.readArchivedFile(&unk, 1); - _vm->_archive.readArchivedFile(&unk, 1); - cnv->_width = unk; - _vm->_archive.readArchivedFile(&unk, 1); - cnv->_height = unk; + _vm->_archive.skip(1); + cnv->_width = _vm->_archive.readByte(); + cnv->_height = _vm->_archive.readByte(); - uint16 compressedsize = _vm->_archive.getArchivedFileLength() - 3; + uint16 compressedsize = _vm->_archive.size() - 3; byte *compressed = (byte*)memAlloc(compressedsize); uint16 size = cnv->_width*cnv->_height; cnv->_data0 = (byte*)memAlloc(size); - _vm->_archive.readArchivedFile(compressed, compressedsize); + _vm->_archive.read(compressed, compressedsize); _vm->_archive.closeArchivedFile(); decompressChunk(compressed, cnv->_data0, size); @@ -1065,25 +1060,18 @@ void Graphics::loadCnv(const char *filename, Cnv *cnv) { errorFileNotFound(path); } - cnv->_count = cnv->_width = cnv->_height = 0; - - byte unk; - - _vm->_archive.readArchivedFile(&unk, 1); - cnv->_count = unk; - _vm->_archive.readArchivedFile(&unk, 1); - cnv->_width = unk; - _vm->_archive.readArchivedFile(&unk, 1); - cnv->_height = unk; + cnv->_count = _vm->_archive.readByte(); + cnv->_width = _vm->_archive.readByte(); + cnv->_height = _vm->_archive.readByte(); uint16 framesize = cnv->_width*cnv->_height; cnv->_array = (byte**)memAlloc(cnv->_count * sizeof(byte*)); - uint32 size = _vm->_archive.getArchivedFileLength() - 3; + uint32 size = _vm->_archive.size() - 3; byte *buf = (byte*)memAlloc(size); - _vm->_archive.readArchivedFile(buf, size); + _vm->_archive.read(buf, size); byte *s = buf; @@ -1170,11 +1158,11 @@ void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) { // byte palette[PALETTE_SIZE]; byte v150[4]; - _vm->_archive.readArchivedFile(_palette, PALETTE_SIZE); - _vm->_archive.readArchivedFile(&v150, 4); + _vm->_archive.read(_palette, PALETTE_SIZE); + _vm->_archive.read(&v150, 4); byte tempfx[sizeof(PaletteFxRange)*6]; - _vm->_archive.readArchivedFile(&tempfx, sizeof(PaletteFxRange)*6); + _vm->_archive.read(&tempfx, sizeof(PaletteFxRange)*6); // setPalette(palette); @@ -1205,7 +1193,7 @@ void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) { memset(_buffers[kMask0], 0, SCREENMASK_WIDTH*SCREEN_HEIGHT); byte *v4 = (byte*)memAlloc(SCREEN_SIZE); - _vm->_archive.readArchivedFile(v4, SCREEN_SIZE); + _vm->_archive.read(v4, SCREEN_SIZE); byte v144[SCREEN_WIDTH]; @@ -1233,9 +1221,9 @@ void Graphics::loadMaskAndPath(const char *filename) { errorFileNotFound(filename); byte v4[4]; - _vm->_archive.readArchivedFile(v4, 4); - _vm->_archive.readArchivedFile(_buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT); - _vm->_archive.readArchivedFile(_buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT); + _vm->_archive.read(v4, 4); + _vm->_archive.read(_buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT); + _vm->_archive.read(_buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT); for (uint16 _si = 0; _si < 4; _si++) _bgLayers[_si] = v4[_si]; diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index 7f6a8538af..a3bb95a6dd 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -73,12 +73,12 @@ void Parallaction::parseLocation(const char *filename) { errorFileNotFound(filename); } - uint32 count = _archive.getArchivedFileLength(); + uint32 count = _archive.size(); location_src = (char*)memAlloc(0x4000); _locationScript = new Script(location_src); - _archive.readArchivedFile(location_src, count); + _archive.read(location_src, count); _archive.closeArchivedFile(); _archive.close(); diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index ea96252dab..c0d8613d3c 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -28,8 +28,6 @@ namespace Parallaction { -struct ArchivedFile; - void parseInit(char *s); char *parseNextLine(char *s, uint16 count); uint16 fillBuffers(Common::SeekableReadStream &stream, bool errorOnEOF = false); |