diff options
author | Filippos Karapetis | 2010-11-28 14:57:56 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-11-28 14:57:56 +0000 |
commit | 0b5f6d4c979028b78c3b6c33f371b46b31cd0c9b (patch) | |
tree | 501a14823b049a771f9a707ac6b1366531ac3256 | |
parent | a5ffdcf6cf2c0cb7d1c4a26790ef217eb6a1e5b9 (diff) | |
download | scummvm-rg350-0b5f6d4c979028b78c3b6c33f371b46b31cd0c9b.tar.gz scummvm-rg350-0b5f6d4c979028b78c3b6c33f371b46b31cd0c9b.tar.bz2 scummvm-rg350-0b5f6d4c979028b78c3b6c33f371b46b31cd0c9b.zip |
SCI: Fixed bug #3034471 - "SCI, Castlebrain/Amiga: Invisible text in word search"
Fixed some endianness issues in Amiga versions, thanks to wjp. Amiga
versions expect a BE VM, thus we adjust accordingly in the places
where memory is accessed directly (i.e. kStrAt, kMemory and all places
that set/get characters from memory)
svn-id: r54521
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 14 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 11 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 12 |
3 files changed, 27 insertions, 10 deletions
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 90ddf4d7ea..2d611d32ef 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -289,9 +289,12 @@ reg_t kMemory(EngineState *s, int argc, reg_t *argv) { error("Attempt to peek invalid memory at %04x:%04x", PRINT_REG(argv[1])); return s->r_acc; } - if (ref.isRaw) - return make_reg(0, (int16)READ_LE_UINT16(ref.raw)); - else { + 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)); + } else { if (ref.skipByte) error("Attempt to peek memory at odd offset %04X:%04X", PRINT_REG(argv[1])); return *(ref.reg); @@ -311,7 +314,10 @@ 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; } - WRITE_LE_UINT16(ref.raw, argv[2].offset); + 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); } 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 a66dc8d91f..4a8e0f716b 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -111,7 +111,12 @@ reg_t kStrAt(EngineState *s, int argc, reg_t *argv) { offset++; reg_t &tmp = dest_r.reg[offset / 2]; - if (!(offset & 1)) { + + bool oddOffset = offset & 1; + if (g_sci->getPlatform() == Common::kPlatformAmiga) + oddOffset = !oddOffset; + + if (!oddOffset) { value = tmp.offset & 0x00ff; if (argc > 2) { /* Request to modify this char */ tmp.offset &= 0xff00; @@ -128,9 +133,7 @@ reg_t kStrAt(EngineState *s, int argc, reg_t *argv) { } } - s->r_acc = make_reg(0, value); - - return s->r_acc; + return make_reg(0, value); } diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index d509046a15..8e2a8865ff 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -600,7 +600,11 @@ static inline char getChar(const SegmentRef &ref, uint offset) { if (!((val.segment == 0xFFFF) && (offset > 1))) warning("Attempt to read character from non-raw data"); - return (offset & 1 ? val.offset >> 8 : val.offset & 0xff); + bool oddOffset = offset & 1; + if (g_sci->getPlatform() == Common::kPlatformAmiga) + oddOffset = !oddOffset; // Amiga versions are BE + + return (oddOffset ? val.offset >> 8 : val.offset & 0xff); } static inline void setChar(const SegmentRef &ref, uint offset, char value) { @@ -611,7 +615,11 @@ static inline void setChar(const SegmentRef &ref, uint offset, char value) { val->segment = 0; - if (offset & 1) + bool oddOffset = offset & 1; + if (g_sci->getPlatform() == Common::kPlatformAmiga) + oddOffset = !oddOffset; // Amiga versions are BE + + if (oddOffset) val->offset = (val->offset & 0x00ff) | (value << 8); else val->offset = (val->offset & 0xff00) | value; |