[Scummvm-cvs-logs] SF.net SVN: scummvm: [25868] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Feb 25 22:40:16 CET 2007
Revision: 25868
http://scummvm.svn.sourceforge.net/scummvm/?rev=25868&view=rev
Author: peres001
Date: 2007-02-25 13:40:15 -0800 (Sun, 25 Feb 2007)
Log Message:
-----------
made Archive inherit from Common::File, added some methods to comply to interface, changed callers to exploit readByte capabilities
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/animation.cpp
scummvm/trunk/engines/parallaction/archive.cpp
scummvm/trunk/engines/parallaction/defs.h
scummvm/trunk/engines/parallaction/disk.h
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/parser.h
Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/animation.cpp 2007-02-25 21:40:15 UTC (rev 25868)
@@ -259,10 +259,10 @@
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();
Modified: scummvm/trunk/engines/parallaction/archive.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/archive.cpp 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/archive.cpp 2007-02-25 21:40:15 UTC (rev 25868)
@@ -89,7 +89,6 @@
_file = true;
- _fileIndex = i;
_fileOffset = _archiveOffsets[i];
_fileCursor = _archiveOffsets[i];
_fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i];
@@ -101,7 +100,6 @@
void Archive::resetArchivedFile() {
_file = false;
- _fileIndex = 0;
_fileCursor = 0;
_fileOffset = 0;
_fileEndOffset = 0;
@@ -112,44 +110,51 @@
}
-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);
-int16 Archive::readArchivedFile(void *buffer, uint16 size) {
-// printf("readArchivedFile(%i, %i)\n", file->_cursor, file->_endOffset);
+ 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);
+
+ _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
Modified: scummvm/trunk/engines/parallaction/defs.h
===================================================================
--- scummvm/trunk/engines/parallaction/defs.h 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/defs.h 2007-02-25 21:40:15 UTC (rev 25868)
@@ -79,8 +79,6 @@
uint16 _count; // # of frames
};
-
-struct ArchivedFile;
struct Animation;
struct Zone;
struct ZoneLabel;
Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/disk.h 2007-02-25 21:40:15 UTC (rev 25868)
@@ -37,12 +37,11 @@
#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 @@
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);
};
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-02-25 21:40:15 UTC (rev 25868)
@@ -1026,22 +1026,17 @@
errorFileNotFound(path);
}
- cnv->_width = cnv->_height = 0;
+ _vm->_archive.skip(1);
+ cnv->_width = _vm->_archive.readByte();
+ cnv->_height = _vm->_archive.readByte();
- byte unk;
- _vm->_archive.readArchivedFile(&unk, 1);
- _vm->_archive.readArchivedFile(&unk, 1);
- cnv->_width = unk;
- _vm->_archive.readArchivedFile(&unk, 1);
- cnv->_height = unk;
-
- 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 @@
errorFileNotFound(path);
}
- cnv->_count = cnv->_width = cnv->_height = 0;
+ cnv->_count = _vm->_archive.readByte();
+ cnv->_width = _vm->_archive.readByte();
+ cnv->_height = _vm->_archive.readByte();
- 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;
-
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 @@
// 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 @@
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 @@
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];
Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/location.cpp 2007-02-25 21:40:15 UTC (rev 25868)
@@ -73,12 +73,12 @@
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();
Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h 2007-02-25 21:04:51 UTC (rev 25867)
+++ scummvm/trunk/engines/parallaction/parser.h 2007-02-25 21:40:15 UTC (rev 25868)
@@ -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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list