From f96e93047a6407eeb5c9e59825e55648f74c6a3d Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Fri, 4 Mar 2011 21:07:52 +0100 Subject: SCI: Use BE string handling for Mac games. --- engines/sci/engine/kmisc.cpp | 10 ++-------- engines/sci/engine/kstring.cpp | 2 +- engines/sci/engine/seg_manager.cpp | 8 ++++---- engines/sci/sci.cpp | 10 ++++++++++ engines/sci/sci.h | 1 + engines/sci/util.cpp | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 6d7c4580e6..5b0d93a249 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -299,10 +299,7 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } if (ref.isRaw) { - if (g_sci->getPlatform() == Common::kPlatformAmiga) - return make_reg(0, (int16)READ_BE_UINT16(ref.raw)); // Amiga versions are BE - else - return make_reg(0, (int16)READ_LE_UINT16(ref.raw)); + return make_reg(0, (int16)READ_SCI1ENDIAN_UINT16(ref.raw)); } else { if (ref.skipByte) error("Attempt to peek memory at odd offset %04X:%04X", PRINT_REG(argv[1])); @@ -323,10 +320,7 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { error("Attempt to poke memory reference %04x:%04x to %04x:%04x", PRINT_REG(argv[2]), PRINT_REG(argv[1])); return s->r_acc; } - if (g_sci->getPlatform() == Common::kPlatformAmiga) - WRITE_BE_UINT16(ref.raw, argv[2].offset); // Amiga versions are BE - else - WRITE_LE_UINT16(ref.raw, argv[2].offset); + WRITE_SCI1ENDIAN_UINT16(ref.raw, argv[2].offset); // Amiga versions are BE } else { if (ref.skipByte) error("Attempt to poke memory at odd offset %04X:%04X", PRINT_REG(argv[1])); diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index df77b8e933..730f7af9b8 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -113,7 +113,7 @@ reg_t kStrAt(EngineState *s, int argc, reg_t *argv) { reg_t &tmp = dest_r.reg[offset / 2]; bool oddOffset = offset & 1; - if (g_sci->getPlatform() == Common::kPlatformAmiga) + if (g_sci->isBE()) oddOffset = !oddOffset; if (!oddOffset) { diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index f30f3ceb2c..c75ceab280 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -602,8 +602,8 @@ static inline char getChar(const SegmentRef &ref, uint offset) { warning("Attempt to read character from non-raw data"); bool oddOffset = offset & 1; - if (g_sci->getPlatform() == Common::kPlatformAmiga) - oddOffset = !oddOffset; // Amiga versions are BE + if (g_sci->isBE()) + oddOffset = !oddOffset; return (oddOffset ? val.offset >> 8 : val.offset & 0xff); } @@ -617,8 +617,8 @@ static inline void setChar(const SegmentRef &ref, uint offset, byte value) { val->segment = 0; bool oddOffset = offset & 1; - if (g_sci->getPlatform() == Common::kPlatformAmiga) - oddOffset = !oddOffset; // Amiga versions are BE + if (g_sci->isBE()) + oddOffset = !oddOffset; if (oddOffset) val->offset = (val->offset & 0x00ff) | (value << 8); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 89a81dc441..3dfa5e0a97 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -777,6 +777,16 @@ bool SciEngine::isCD() const { return _gameDescription->flags & ADGF_CD; } +bool SciEngine::isBE() const{ + switch(_gameDescription->platform) { + case Common::kPlatformAmiga: + case Common::kPlatformMacintosh: + return true; + default: + return false; + } +} + bool SciEngine::hasMacIconBar() const { return _resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1 && (getGameId() == GID_KQ6 || getGameId() == GID_FREDDYPHARKAS); diff --git a/engines/sci/sci.h b/engines/sci/sci.h index aea5712ace..9155db04c8 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -238,6 +238,7 @@ public: Common::Platform getPlatform() const; bool isDemo() const; bool isCD() const; + bool isBE() const; bool hasMacIconBar() const; inline ResourceManager *getResMan() const { return _resMan; } diff --git a/engines/sci/util.cpp b/engines/sci/util.cpp index 8f6576cd38..408fd9d818 100644 --- a/engines/sci/util.cpp +++ b/engines/sci/util.cpp @@ -31,14 +31,14 @@ 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) + if (g_sci->isBE() && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE) return READ_BE_UINT16(ptr); else 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) + if (g_sci->isBE() && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE) WRITE_BE_UINT16(ptr, val); else WRITE_LE_UINT16(ptr, val); -- cgit v1.2.3