diff options
| -rw-r--r-- | engines/sci/engine/kpathing.cpp | 12 | ||||
| -rw-r--r-- | engines/sci/util.cpp | 14 | ||||
| -rw-r--r-- | engines/sci/util.h | 6 | 
3 files changed, 26 insertions, 6 deletions
| diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index cb70cf91e0..c98d93c2d9 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -264,9 +264,9 @@ struct PathfindingState {  static Common::Point readPoint(SegmentRef list_r, int offset) {  	Common::Point point; -	if (list_r.isRaw) { -		point.x = (int16)READ_LE_UINT16(list_r.raw + offset * POLY_POINT_SIZE); -		point.y = (int16)READ_LE_UINT16(list_r.raw + offset * POLY_POINT_SIZE + 2); +	if (list_r.isRaw) {	// dynmem blocks are raw +		point.x = (int16)READ_SCI1ENDIAN_UINT16(list_r.raw + offset * POLY_POINT_SIZE); +		point.y = (int16)READ_SCI1ENDIAN_UINT16(list_r.raw + offset * POLY_POINT_SIZE + 2);  	} else {  		point.x = list_r.reg[offset * 2].toUint16();  		point.y = list_r.reg[offset * 2 + 1].toUint16(); @@ -275,9 +275,9 @@ static Common::Point readPoint(SegmentRef list_r, int offset) {  }  static void writePoint(SegmentRef ref, int offset, const Common::Point &point) { -	if (ref.isRaw) { -		WRITE_LE_UINT16(ref.raw + offset * POLY_POINT_SIZE, point.x); -		WRITE_LE_UINT16(ref.raw + offset * POLY_POINT_SIZE + 2, point.y); +	if (ref.isRaw) {	// dynmem blocks are raw +		WRITE_SCI1ENDIAN_UINT16(ref.raw + offset * POLY_POINT_SIZE, point.x); +		WRITE_SCI1ENDIAN_UINT16(ref.raw + offset * POLY_POINT_SIZE + 2, point.y);  	} else {  		ref.reg[offset * 2] = make_reg(0, point.x);  		ref.reg[offset * 2 + 1] = make_reg(0, point.y); diff --git a/engines/sci/util.cpp b/engines/sci/util.cpp index f6a2465682..6bc08e6b63 100644 --- a/engines/sci/util.cpp +++ b/engines/sci/util.cpp @@ -30,6 +30,20 @@  namespace Sci { +uint16 READ_SCI1ENDIAN_UINT16(const void *ptr) { +	if (g_sci->getPlatform() == Common::kPlatformAmiga && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE) +		return READ_BE_UINT16(ptr); + +	return READ_LE_UINT16(ptr); +} + +void WRITE_SCI1ENDIAN_UINT16(void *ptr, uint16 val) { +	if (g_sci->getPlatform() == Common::kPlatformAmiga && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE) +		WRITE_BE_UINT16(ptr, val); + +	WRITE_LE_UINT16(ptr, val); +} +  uint16 READ_SCI11ENDIAN_UINT16(const void *ptr) {  	if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1)  		return READ_BE_UINT16(ptr); diff --git a/engines/sci/util.h b/engines/sci/util.h index d9ced5c9f6..d1f1c2ffa9 100644 --- a/engines/sci/util.h +++ b/engines/sci/util.h @@ -30,6 +30,12 @@  namespace Sci { +// Wrappers for reading/writing integer values for SCI1 Amiga. +// Amiga versions store big endian data in dynmem blocks, as +// the game resources are in LE, but the actual system is BE. +uint16 READ_SCI1ENDIAN_UINT16(const void *ptr); +void WRITE_SCI1ENDIAN_UINT16(void *ptr, uint16 val); +  // Wrappers for reading integer values for SCI1.1+.  // Mac versions have big endian data for some fields.  uint16 READ_SCI11ENDIAN_UINT16(const void *ptr); | 
