[Scummvm-git-logs] scummvm master -> cecedb4f37327e02b4170b36a6afbce7195065c7

mduggan mgithub at guarana.org
Sat Apr 11 08:07:23 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8d50e49e32 ULTIMA8: Remove usage of readX and readXS when X is const
cecedb4f37 ULTIMA8: Refactor DataSources to inherit from Common::Streams


Commit: 8d50e49e32ec97cc9133f4810f1aa293d187df2a
    https://github.com/scummvm/scummvm/commit/8d50e49e32ec97cc9133f4810f1aa293d187df2a
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-04-11T16:35:53+09:00

Commit Message:
ULTIMA8: Remove usage of readX and readXS when X is const

Changed paths:
    engines/ultima/ultima8/graphics/anim_dat.cpp
    engines/ultima/ultima8/graphics/wpn_ovlay_dat.cpp
    engines/ultima/ultima8/usecode/uc_machine.cpp
    engines/ultima/ultima8/world/map.cpp
    engines/ultima/ultima8/world/world.cpp


diff --git a/engines/ultima/ultima8/graphics/anim_dat.cpp b/engines/ultima/ultima8/graphics/anim_dat.cpp
index 907f0af8d8..545368eaae 100644
--- a/engines/ultima/ultima8/graphics/anim_dat.cpp
+++ b/engines/ultima/ultima8/graphics/anim_dat.cpp
@@ -118,9 +118,9 @@ void AnimDat::load(IDataSource *ds) {
 						f._frame = ds->readByte(); // & 0x7FF;
 						uint8 x = ds->readByte();
 						f._frame += (x & 0x7) << 8;
-						f._deltaZ = ds->readXS(1);
+						f._deltaZ = ds->readSByte();
 						f._sfx = ds->readByte();
-						f._deltaDir = ds->readXS(1);
+						f._deltaDir = ds->readSByte();
 						f._flags = ds->readByte();
 						f._flags += (x & 0xF8) << 8;
 					} else if (GAME_IS_CRUSADER) {
@@ -132,7 +132,7 @@ void AnimDat::load(IDataSource *ds) {
 						// byte 2, 3: unknown; byte 3 might contain flags
 						ds->skip(2);
 						// byte 4: deltadir (signed)
-						f._deltaDir = ds->readXS(1);
+						f._deltaDir = ds->readSByte();
 						// byte 5: flags?
 						f._flags = ds->readByte();
 						// byte 6, 7: unknown
diff --git a/engines/ultima/ultima8/graphics/wpn_ovlay_dat.cpp b/engines/ultima/ultima8/graphics/wpn_ovlay_dat.cpp
index 7c3a7f1aaf..e76da5982f 100644
--- a/engines/ultima/ultima8/graphics/wpn_ovlay_dat.cpp
+++ b/engines/ultima/ultima8/graphics/wpn_ovlay_dat.cpp
@@ -98,8 +98,8 @@ void WpnOvlayDat::load(RawArchive *overlaydat) {
 						unsigned int offset = type * 8 * animlength
 						                      + dir * animlength + frame;
 						ds->seek(4 * offset);
-						f._xOff = ds->readXS(1);
-						f._yOff = ds->readXS(1);
+						f._xOff = ds->readSByte();
+						f._yOff = ds->readSByte();
 						f._frame = ds->readUint16LE();
 
 						awo->_overlay[type]._frames[dir][frame] = f;
diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 5282b515e9..0abe2a67ea 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -1611,7 +1611,7 @@ void UCMachine::execProcess(UCProcess *p) {
 			// yy == num bytes in string
 			// zz == type
 		{
-			si16a = cs.readXS(1);
+			si16a = cs.readSByte();
 			uint32 scriptsize = cs.readByte();
 			uint32 searchtype = cs.readByte();
 
diff --git a/engines/ultima/ultima8/world/map.cpp b/engines/ultima/ultima8/world/map.cpp
index e7385b6ab8..1f907ecd5e 100644
--- a/engines/ultima/ultima8/world/map.cpp
+++ b/engines/ultima/ultima8/world/map.cpp
@@ -211,9 +211,9 @@ void Map::loadFixedFormatObjects(Std::list<Item *> &itemlist, IDataSource *ds,
 
 	for (uint32 i = 0; i < itemcount; ++i) {
 		// These are ALL unsigned on disk
-		int32 x = static_cast<int32>(ds->readX(2));
-		int32 y = static_cast<int32>(ds->readX(2));
-		int32 z = static_cast<int32>(ds->readX(1));
+		int32 x = static_cast<int32>(ds->readUint16LE());
+		int32 y = static_cast<int32>(ds->readUint16LE());
+		int32 z = static_cast<int32>(ds->readByte());
 
 		if (GAME_IS_CRUSADER) {
 			x *= 2;
diff --git a/engines/ultima/ultima8/world/world.cpp b/engines/ultima/ultima8/world/world.cpp
index 0f7f892530..12486504bd 100644
--- a/engines/ultima/ultima8/world/world.cpp
+++ b/engines/ultima/ultima8/world/world.cpp
@@ -224,11 +224,11 @@ void World::loadItemCachNPCData(IDataSource *itemcach, IDataSource *npcdata) {
 	for (uint32 i = 1; i < 256; ++i) { // Get rid of constants?
 		// These are ALL unsigned on disk
 		itemds->seek(0x00000 + i * 2);
-		int32 x = static_cast<int32>(itemds->readX(2));
+		int32 x = static_cast<int32>(itemds->readUint16LE());
 		itemds->seek(0x04800 + i * 2);
-		int32 y = static_cast<int32>(itemds->readX(2));
+		int32 y = static_cast<int32>(itemds->readUint16LE());
 		itemds->seek(0x09000 + i * 1);
-		int32 z = static_cast<int32>(itemds->readX(1));
+		int32 z = static_cast<int32>(itemds->readByte());
 
 		itemds->seek(0x0B400 + i * 2);
 		uint32 shape = itemds->readUint16LE();


Commit: cecedb4f37327e02b4170b36a6afbce7195065c7
    https://github.com/scummvm/scummvm/commit/cecedb4f37327e02b4170b36a6afbce7195065c7
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-04-11T17:05:40+09:00

Commit Message:
ULTIMA8: Refactor DataSources to inherit from Common::Streams

Changed paths:
    engines/ultima/ultima8/filesys/idata_source.h
    engines/ultima/ultima8/filesys/odata_source.h
    test/engines/ultima/ultima8/filesys/idata_source.h
    test/engines/ultima/ultima8/filesys/odata_source.h


diff --git a/engines/ultima/ultima8/filesys/idata_source.h b/engines/ultima/ultima8/filesys/idata_source.h
index d195b76f37..0dc29009d6 100644
--- a/engines/ultima/ultima8/filesys/idata_source.h
+++ b/engines/ultima/ultima8/filesys/idata_source.h
@@ -24,30 +24,32 @@
 #define ULTIMA8_FILESYS_IDATASOURCE_H
 
 #include "common/file.h"
+#include "common/stream.h"
 #include "ultima/shared/std/misc.h"
 #include "ultima/shared/std/string.h"
 
 namespace Ultima {
 namespace Ultima8 {
 
-class IDataSource {
+class IDataSource : public Common::SeekableReadStream {
 public:
 	IDataSource() {}
 	virtual ~IDataSource() {}
 
-	virtual uint8 readByte() = 0;
-	virtual uint16 readUint16LE() = 0;
-	virtual uint16 read2high() = 0;
-	virtual uint32 read3() = 0;
-	virtual uint32 readUint32LE() = 0;
-	virtual uint32 read4high() = 0;
-	virtual int32 read(void *str, int32 num_bytes) = 0;
+	//  Read a 3-byte value, lsb first.
+	virtual uint32 readUint24LE() {
+		uint32 val = 0;
+		val |= static_cast<uint32>(readByte());
+		val |= static_cast<uint32>(readByte() << 8);
+		val |= static_cast<uint32>(readByte() << 16);
+		return val;
+	}
 
 	uint32 readX(uint32 num_bytes) {
 		assert(num_bytes > 0 && num_bytes <= 4);
 		if (num_bytes == 1) return readByte();
 		else if (num_bytes == 2) return readUint16LE();
-		else if (num_bytes == 3) return read3();
+		else if (num_bytes == 3) return readUint24LE();
 		else return readUint32LE();
 	}
 
@@ -55,7 +57,7 @@ public:
 		assert(num_bytes > 0 && num_bytes <= 4);
 		if (num_bytes == 1) return static_cast<int8>(readByte());
 		else if (num_bytes == 2) return static_cast<int16>(readUint16LE());
-		else if (num_bytes == 3) return (((static_cast<int32>(read3())) << 8) >> 8);
+		else if (num_bytes == 3) return (((static_cast<int32>(readUint24LE())) << 8) >> 8);
 		else return static_cast<int32>(readUint32LE());
 	}
 
@@ -71,12 +73,6 @@ public:
 		}
 	}
 
-	virtual void seek(uint32 pos) = 0;
-	virtual void skip(int32 delta) = 0;
-	virtual uint32 size() const = 0;
-	virtual uint32 pos() const = 0;
-	virtual bool eos() const = 0;
-
 	virtual Common::SeekableReadStream *GetRawStream() {
 		return nullptr;
 	}
@@ -95,61 +91,19 @@ public:
 		delete _in;
 	}
 
-	bool good() const {
-		return !_in->err();
-	}
-
-	//  Read a byte value
-	uint8 readByte() override {
-		return static_cast<uint8>(_in->readByte());
-	}
-
-	//  Read a 2-byte value, lsb first.
-	uint16 readUint16LE() override {
-		return _in->readUint16LE();
-	}
-
-	//  Read a 2-byte value, hsb first.
-	uint16 read2high() override {
-		return _in->readUint16BE();
-	}
-
-	//  Read a 3-byte value, lsb first.
-	uint32 read3() override {
-		uint32 val = 0;
-		val |= static_cast<uint32>(_in->readByte());
-		val |= static_cast<uint32>(_in->readByte() << 8);
-		val |= static_cast<uint32>(_in->readByte() << 16);
-		return val;
-	}
-
-	//  Read a 4-byte long value, lsb first.
-	uint32 readUint32LE() override {
-		return _in->readUint32LE();
-	}
-
-	//  Read a 4-byte long value, hsb first.
-	uint32 read4high() override {
-		return _in->readUint32BE();
-	}
-
-	int32 read(void *b, int32 len) override {
+	uint32 read(void *b, uint32 len) override {
 		return _in->read(b, len);
 	}
 
-	void seek(uint32 pos) override {
-		_in->seek(pos);
+	bool seek(int32 pos, int whence = SEEK_SET) override {
+		return _in->seek(pos, whence);
 	}
 
-	void skip(int32 pos) override {
-		_in->seek(pos, SEEK_CUR);
-	}
-
-	uint32 size() const override {
+	int32 size() const override {
 		return _in->size();
 	}
 
-	uint32 pos() const override {
+	int32 pos() const override {
 		return _in->pos();
 	}
 
@@ -198,55 +152,9 @@ public:
 		_buf = _bufPtr = nullptr;
 	}
 
-	uint8 readByte() override {
-		uint8 b0;
-		b0 = *_bufPtr++;
-		return (b0);
-	}
-
-	uint16 readUint16LE() override {
-		uint8 b0, b1;
-		b0 = *_bufPtr++;
-		b1 = *_bufPtr++;
-		return (b0 | (b1 << 8));
-	}
-
-	uint16 read2high() override {
-		uint8 b0, b1;
-		b1 = *_bufPtr++;
-		b0 = *_bufPtr++;
-		return (b0 | (b1 << 8));
-	}
-
-	uint32 read3() override {
-		uint8 b0, b1, b2;
-		b0 = *_bufPtr++;
-		b1 = *_bufPtr++;
-		b2 = *_bufPtr++;
-		return (b0 | (b1 << 8) | (b2 << 16));
-	}
-
-	uint32 readUint32LE() override {
-		uint8 b0, b1, b2, b3;
-		b0 = *_bufPtr++;
-		b1 = *_bufPtr++;
-		b2 = *_bufPtr++;
-		b3 = *_bufPtr++;
-		return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24));
-	}
-
-	uint32 read4high() override {
-		uint8 b0, b1, b2, b3;
-		b3 = *_bufPtr++;
-		b2 = *_bufPtr++;
-		b1 = *_bufPtr++;
-		b0 = *_bufPtr++;
-		return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24));
-	}
-
-	int32 read(void *str, int32 num_bytes) override {
+	uint32 read(void *str, uint32 num_bytes) override {
 		if (_bufPtr >= _buf + _size) return 0;
-		int32 count = num_bytes;
+		uint32 count = num_bytes;
 		if (_bufPtr + num_bytes > _buf + _size)
 			count = static_cast<int32>(_buf - _bufPtr + _size);
 		Std::memcpy(str, _bufPtr, count);
@@ -254,20 +162,22 @@ public:
 		return count;
 	}
 
-	void seek(uint32 pos) override {
-		_bufPtr = _buf + pos;
-	}
-
-	void skip(int32 delta) override {
-		_bufPtr += delta;
+	bool seek(int32 pos, int whence = SEEK_SET) override {
+		assert(whence == SEEK_SET || whence == SEEK_CUR);
+		if (whence == SEEK_CUR) {
+			_bufPtr += pos;
+		} else if (whence == SEEK_SET) {
+			_bufPtr = _buf + pos;
+		}
+		return true;
 	}
 
-	uint32 size() const override {
+	int32 size() const override {
 		return _size;
 	}
 
-	uint32 pos() const override {
-		return static_cast<uint32>(_bufPtr - _buf);
+	int32 pos() const override {
+		return static_cast<int32>(_bufPtr - _buf);
 	}
 
 	bool eos() const override {
diff --git a/engines/ultima/ultima8/filesys/odata_source.h b/engines/ultima/ultima8/filesys/odata_source.h
index 8b7e4b15b8..c4a2f1bc46 100644
--- a/engines/ultima/ultima8/filesys/odata_source.h
+++ b/engines/ultima/ultima8/filesys/odata_source.h
@@ -32,24 +32,22 @@
 namespace Ultima {
 namespace Ultima8 {
 
-class ODataSource {
+class ODataSource : public Common::SeekableWriteStream {
 public:
 	ODataSource() {}
 	virtual ~ODataSource() {}
 
-	virtual void writeByte(uint32) = 0;
-	virtual void writeUint16LE(uint16) = 0;
-	virtual void write2high(uint16) = 0;
-	virtual void write3(uint32) = 0;
-	virtual void writeUint32LE(uint32) = 0;
-	virtual void write4high(uint32) = 0;
-	virtual void write(const void *str, uint32 num_bytes) = 0;
+	virtual void writeUint24LE(uint32 val) {
+		writeByte(static_cast<byte>(val & 0xff));
+		writeByte(static_cast<byte>((val >> 8) & 0xff));
+		writeByte(static_cast<byte>((val >> 16) & 0xff));
+	}
 
 	void writeX(uint32 val, uint32 num_bytes) {
 		assert(num_bytes > 0 && num_bytes <= 4);
-		if (num_bytes == 1) writeByte(static_cast<uint8>(val));
+		if (num_bytes == 1) writeByte(static_cast<byte>(val));
 		else if (num_bytes == 2) writeUint16LE(static_cast<uint16>(val));
-		else if (num_bytes == 3) write3(val);
+		else if (num_bytes == 3) writeUint24LE(val);
 		else writeUint32LE(val);
 	}
 
@@ -57,10 +55,9 @@ public:
 		return nullptr;
 	}
 
-	virtual void seek(uint32 pos) = 0;
-	virtual void skip(int32 delta) = 0;
-	virtual uint32 size() const = 0;
-	virtual uint32 pos() const = 0;
+	virtual void skip(int32 delta) {
+		seek(delta, SEEK_CUR);
+	};
 };
 
 
@@ -76,61 +73,23 @@ public:
 		FORGET_OBJECT(_out);
 	}
 
-	bool good() const {
-		return !_out->err();
-	}
-
-	void writeByte(uint32 val) override {
-		_out->writeByte(val & 0xff);
-	}
-
-	void writeUint16LE(uint16 val) override {
-		_out->writeUint16LE(val);
-	}
-
-	void write2high(uint16 val) override {
-		_out->writeUint16BE(val);
-	}
-
-	void write3(uint32 val) override {
-		_out->writeByte(static_cast<byte>(val & 0xff));
-		_out->writeByte(static_cast<byte>((val >> 8) & 0xff));
-		_out->writeByte(static_cast<byte>((val >> 16) & 0xff));
-	}
-
-	void writeUint32LE(uint32 val) override {
-		_out->writeUint32LE(val);
-	}
-
-	void write4high(uint32 val) override {
-		_out->writeUint32BE(val);
+	uint32 write(const void *b, uint32 len) override {
+		return _out->write(b, len);
 	}
 
-	void write(const void *b, uint32 len) override {
-		_out->write(static_cast<const char *>(b), len);
-	}
-
-	void seek(uint32 pos) override {
+	bool seek(int32 pos, int whence = SEEK_SET) override {
 		Common::SeekableWriteStream *ws = dynamic_cast<Common::SeekableWriteStream *>(_out);
 		assert(ws);
-		ws->seek(pos);
+		return ws->seek(pos, whence);
 	}
 
-	void skip(int32 amount) override {
-		Common::SeekableWriteStream *ws = dynamic_cast<Common::SeekableWriteStream *>(_out);
-		assert(ws);
-		ws->seek(amount, SEEK_CUR);
-	}
-
-	uint32 size() const override {
+	int32 size() const override {
 		Common::SeekableWriteStream *ws = dynamic_cast<Common::SeekableWriteStream *>(_out);
 		assert(ws);
 		return ws->size();
 	}
 
-	uint32 pos() const override {
-		Common::SeekableWriteStream *ws = dynamic_cast<Common::SeekableWriteStream *>(_out);
-		assert(ws);
+	int32 pos() const override {
 		return _out->pos();
 	}
 
@@ -139,80 +98,6 @@ public:
 	}
 };
 
-class OBufferDataSource: public ODataSource {
-protected:
-	uint8 *_buf;
-	uint8 *_bufPtr;
-	uint32 _size;
-public:
-	OBufferDataSource(void *data, uint32 len) : _size(len) {
-		assert(data == 0 || len == 0);
-		_buf = _bufPtr = reinterpret_cast<uint8 *>(data);
-	};
-
-	void load(char *data, uint32 len) {
-		assert(data == 0 || len == 0);
-		_buf = _bufPtr = reinterpret_cast<uint8 *>(data);
-		_size = len;
-	};
-
-	~OBufferDataSource() override {};
-
-	void writeByte(uint32 val) override {
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void writeUint16LE(uint16 val) override {
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-	};
-
-	void write2high(uint16 val) override {
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void write3(uint32 val) override {
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-	};
-
-	void writeUint32LE(uint32 val) override {
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-		*_bufPtr++ = (val >> 24) & 0xff;
-	};
-
-	void write4high(uint32 val) override {
-		*_bufPtr++ = (val >> 24) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void write(const void *b, uint32 len) override {
-		Common::copy((const byte *)b, (const byte *)b + len, _bufPtr);
-		_bufPtr += len;
-	};
-
-	void seek(uint32 pos) override {
-		_bufPtr = const_cast<unsigned char *>(_buf) + pos;
-	};
-
-	void skip(int32 pos) override {
-		_bufPtr += pos;
-	};
-
-	uint32 size() const override {
-		return _size;
-	};
-
-	uint32 pos() const override {
-		return static_cast<uint32>(_bufPtr - _buf);
-	};
-};
 
 class OAutoBufferDataSource: public ODataSource {
 protected:
@@ -266,58 +151,21 @@ public:
 		delete [] _buf;
 	}
 
-	void writeByte(uint32 val) override {
-		checkResize(1);
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void writeUint16LE(uint16 val) override {
-		checkResize(2);
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-	};
-
-	void write2high(uint16 val) override {
-		checkResize(2);
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void write3(uint32 val) override {
-		checkResize(3);
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-	};
-
-	void writeUint32LE(uint32 val) override {
-		checkResize(4);
-		*_bufPtr++ = val & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-		*_bufPtr++ = (val >> 24) & 0xff;
-	};
-
-	void write4high(uint32 val) override {
-		checkResize(4);
-		*_bufPtr++ = (val >> 24) & 0xff;
-		*_bufPtr++ = (val >> 16) & 0xff;
-		*_bufPtr++ = (val >> 8) & 0xff;
-		*_bufPtr++ = val & 0xff;
-	};
-
-	void write(const void *b, uint32 len) override {
+	uint32 write(const void *b, uint32 len) override {
 		checkResize(len);
 		Common::copy((const byte *)b, (const byte *)b + len, _bufPtr);
 		_bufPtr += len;
+		return len;
 	};
 
-	void seek(uint32 pos) override {
+	bool seek(int32 pos, int whence = SEEK_SET) override {
+		assert(whence == SEEK_SET);
 		// No seeking past the end of the buffer
-		if (pos <= _size) _loc = pos;
+		if (pos <= static_cast<int32>(_size)) _loc = pos;
 		else _loc = _size;
 
 		_bufPtr = const_cast<unsigned char *>(_buf) + _loc;
+		return true;
 	};
 
 	void skip(int32 pos) override {
@@ -335,12 +183,12 @@ public:
 		_bufPtr = const_cast<unsigned char *>(_buf) + _loc;
 	};
 
-	uint32 size() const override {
+	int32 size() const override {
 		return _size;
 	};
 
-	uint32 pos() const override {
-		return static_cast<uint32>(_bufPtr - _buf);
+	int32 pos() const override {
+		return static_cast<int32>(_bufPtr - _buf);
 	};
 
 	// Don't actually do anything substantial
diff --git a/test/engines/ultima/ultima8/filesys/idata_source.h b/test/engines/ultima/ultima8/filesys/idata_source.h
index e05450b989..f3b2848161 100644
--- a/test/engines/ultima/ultima8/filesys/idata_source.h
+++ b/test/engines/ultima/ultima8/filesys/idata_source.h
@@ -20,7 +20,7 @@ class U8IDataSourceTestSuite : public CxxTest::TestSuite {
 	void test_ibuffer_source() {
 		uint8 buf[256];
 		for (int i = 0; i < 255; i++) {
-			buf[i] = i+1;
+			buf[i] = 0x80 + i+1;
 		}
 
 		Ultima::Ultima8::IBufferDataSource source(buf, 256, false, false);
@@ -28,18 +28,18 @@ class U8IDataSourceTestSuite : public CxxTest::TestSuite {
 		TS_ASSERT_EQUALS(source.pos(), 0);
 		TS_ASSERT(!source.eos());
 
-		TS_ASSERT_EQUALS(source.readByte(), 1);
-		TS_ASSERT_EQUALS(source.readUint16LE(), 0x0302);
-		TS_ASSERT_EQUALS(source.read3(), 0x060504);
-		TS_ASSERT_EQUALS(source.readUint32LE(), 0x0A090807);
+		TS_ASSERT_EQUALS(source.readByte(), 0x81);
+		TS_ASSERT_EQUALS(source.readUint16LE(), 0x8382);
+		TS_ASSERT_EQUALS(source.readUint24LE(), 0x868584);
+		TS_ASSERT_EQUALS(source.readUint32LE(), 0x8A898887);
 		source.skip(-2);
-		TS_ASSERT_EQUALS(source.readUint16LE(), 0x0A09);
+		TS_ASSERT_EQUALS(source.readUint16LE(), 0x8A89);
 		source.seek(16);
-		TS_ASSERT_EQUALS(source.readUint16LE(), 0x1211);
-		TS_ASSERT_EQUALS(source.readX(1), 0x13);
-		TS_ASSERT_EQUALS(source.readX(3), 0x161514);
-		TS_ASSERT_EQUALS(source.readXS(1), 0x17);
-		TS_ASSERT_EQUALS(source.readXS(3), 0x1A1918);
+		TS_ASSERT_EQUALS(source.readUint16LE(), 0x9291);
+		TS_ASSERT_EQUALS(source.readX(1), 0x93);
+		TS_ASSERT_EQUALS(source.readX(3), 0x969594);
+		TS_ASSERT_EQUALS(source.readXS(1), (int8)0x97);
+		TS_ASSERT_EQUALS(source.readXS(3), (int32)0xFF9A9998);
 		source.seek(256);
 		TS_ASSERT(source.eos());
 	}
diff --git a/test/engines/ultima/ultima8/filesys/odata_source.h b/test/engines/ultima/ultima8/filesys/odata_source.h
index 658034ab5a..a02d3b3a63 100644
--- a/test/engines/ultima/ultima8/filesys/odata_source.h
+++ b/test/engines/ultima/ultima8/filesys/odata_source.h
@@ -53,22 +53,22 @@ class U8ODataSourceTestSuite : public CxxTest::TestSuite {
 		TS_ASSERT_EQUALS(source.size(), 0);
 		TS_ASSERT_EQUALS(source.pos(), 0);
 
-		source.writeByte(0x04030201);
-		source.writeUint16LE(0x08070605);
-		source.write3(0x0C0B0A09);
-		source.writeUint32LE(0x100F0E0D);
+		source.writeByte(0x84838281);
+		source.writeUint16LE(0x88878685);
+		source.writeUint24LE(0x8C8B8A89);
+		source.writeUint32LE(0x908F8E8D);
 
 		buf = source.getData();
-		TS_ASSERT_EQUALS(buf[0], 0x01);
-		TS_ASSERT_EQUALS(buf[1], 0x05);
-		TS_ASSERT_EQUALS(buf[2], 0x06);
-		TS_ASSERT_EQUALS(buf[3], 0x09);
-		TS_ASSERT_EQUALS(buf[4], 0x0A);
-		TS_ASSERT_EQUALS(buf[5], 0x0B);
-		TS_ASSERT_EQUALS(buf[6], 0x0D);
-		TS_ASSERT_EQUALS(buf[7], 0x0E);
-		TS_ASSERT_EQUALS(buf[8], 0x0F);
-		TS_ASSERT_EQUALS(buf[9], 0x10);
+		TS_ASSERT_EQUALS(buf[0], 0x81);
+		TS_ASSERT_EQUALS(buf[1], 0x85);
+		TS_ASSERT_EQUALS(buf[2], 0x86);
+		TS_ASSERT_EQUALS(buf[3], 0x89);
+		TS_ASSERT_EQUALS(buf[4], 0x8A);
+		TS_ASSERT_EQUALS(buf[5], 0x8B);
+		TS_ASSERT_EQUALS(buf[6], 0x8D);
+		TS_ASSERT_EQUALS(buf[7], 0x8E);
+		TS_ASSERT_EQUALS(buf[8], 0x8F);
+		TS_ASSERT_EQUALS(buf[9], 0x90);
 	}
 
 };




More information about the Scummvm-git-logs mailing list