[Scummvm-cvs-logs] CVS: scummvm/common stream.h,1.13,1.14
Eugene Sandulenko
sev at users.sourceforge.net
Wed Mar 30 14:00:46 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/tools md5table.c,1.2,1.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.295,1.296 resource_v2.cpp,1.46,1.47 resource_v3.cpp,1.29,1.30 resource_v4.cpp,1.10,1.11 script_v6.cpp,1.425,1.426 script_v72he.cpp,2.226,2.227 script_v8.cpp,2.284,2.285 scumm.cpp,1.390,1.391 scumm.h,1.553,1.554 sound.cpp,1.431,1.432 util.cpp,2.4,2.5 util.h,2.3,2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13648/common
Modified Files:
stream.h
Log Message:
Support for direct reading from NES ROM:
o extend MemoryReadStream with XOR facility
o implement MemoryWriteStream
o _fileHandle now is a reference to BaseScummFile class and is created on the fly
o implement ScummNESFile class which is basically extract_mm_nes utility
o update NES MM md5's due to above changes
NOTE: to run MM NES now you need to remove *.LFL files and (probably) rename
ROM to standard conventional name 'Maniac Mansion (XXX).nes'
Index: stream.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/stream.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- stream.h 9 Jan 2005 16:07:53 -0000 1.13
+++ stream.h 30 Mar 2005 21:57:44 -0000 1.14
@@ -223,16 +223,29 @@
const byte * const _ptrOrig;
const uint32 _bufSize;
uint32 _pos;
+ byte _encbyte;
+
public:
MemoryReadStream(const byte *buf, uint32 len) : _ptr(buf), _ptrOrig(buf), _bufSize(len), _pos(0) {}
+ void setEnc(byte value) { _encbyte = value; }
+
uint32 read(void *ptr, uint32 len) {
// Read at most as many bytes as are still available...
if (len > _bufSize - _pos)
len = _bufSize - _pos;
memcpy(ptr, _ptr, len);
+
+ if (_encbyte) {
+ byte *p = (byte *)ptr;
+ byte *end = p + len;
+ while (p < end)
+ *p++ ^= _encbyte;
+ }
+
_ptr += len;
_pos += len;
+
return len;
}
@@ -243,6 +256,34 @@
void seek(int32 offs, int whence = SEEK_SET);
};
+/**
+ * Simple memory based 'stream', which implements the WriteStream interface for
+ * a plain memory block.
+ */
+class MemoryWriteStream : public WriteStream {
+private:
+ byte *_ptr;
+ const byte * const _ptrOrig;
+ const uint32 _bufSize;
+ uint32 _pos;
+public:
+ MemoryWriteStream(byte *buf, uint32 len) : _ptr(buf), _ptrOrig(buf), _bufSize(len), _pos(0) {}
+
+ uint32 write(const void *ptr, uint32 len) {
+ // Write at most as many bytes as are still available...
+ if (len > _bufSize - _pos)
+ len = _bufSize - _pos;
+ memcpy(_ptr, ptr, len);
+ _ptr += len;
+ _pos += len;
+ return len;
+ }
+
+ bool eof() const { return _pos == _bufSize; }
+ uint32 pos() const { return _pos; }
+ uint32 size() const { return _bufSize; }
+};
+
} // End of namespace Common
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/tools md5table.c,1.2,1.3
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.295,1.296 resource_v2.cpp,1.46,1.47 resource_v3.cpp,1.29,1.30 resource_v4.cpp,1.10,1.11 script_v6.cpp,1.425,1.426 script_v72he.cpp,2.226,2.227 script_v8.cpp,2.284,2.285 scumm.cpp,1.390,1.391 scumm.h,1.553,1.554 sound.cpp,1.431,1.432 util.cpp,2.4,2.5 util.h,2.3,2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list