[Scummvm-git-logs] scummvm master -> fe24a937a2dec093ccfbe7e1bd09b9ee3ba57d34
athrxx
noreply at scummvm.org
Wed Oct 26 19:45:30 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fe24a937a2 SCUMM: (FM-TOWNS) - fix mouse cursor color endianness glitch
Commit: fe24a937a2dec093ccfbe7e1bd09b9ee3ba57d34
https://github.com/scummvm/scummvm/commit/fe24a937a2dec093ccfbe7e1bd09b9ee3ba57d34
Author: athrxx (athrxx at scummvm.org)
Date: 2022-10-26T21:44:27+02:00
Commit Message:
SCUMM: (FM-TOWNS) - fix mouse cursor color endianness glitch
(which would occur when loading a savegame created on a machine
with a different endianness)
Changed paths:
engines/scumm/saveload.cpp
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index c12407b8f2e..20d2cd49cd6 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -68,7 +68,7 @@ struct SaveInfoSection {
#define SaveInfoSectionSize (4+4+4 + 4+4 + 4+2)
-#define CURRENT_VER 106
+#define CURRENT_VER 107
#define INFOSECTION_VERSION 2
#pragma mark -
@@ -1349,9 +1349,38 @@ void ScummEngine::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsByte(_cursor.state, VER(8));
s.skip(1, VER(8), VER(20)); // _gdi->_cursorActive
s.syncAsByte(_currentCursor, VER(8));
- // TODO: This seems wrong, _grabbedCursor is >8192 bytes and sometimes holds
- // 16-bit values
- s.syncBytes(_grabbedCursor, 8192, VER(20));
+
+ if (_outputPixelFormat.bytesPerPixel == 2) {
+ if (s.getVersion() >= VER(107)) {
+ uint16 *pos = (uint16*)_grabbedCursor;
+ for (i = 0; i < 4096; ++i)
+ s.syncAsUint16LE(*pos++, VER(20));
+ } else {
+ s.syncBytes(_grabbedCursor, 8192, VER(20));
+ // Patch older savegames if they were saved on a system with a
+ // different endianness than the current system's endianness
+ // which is now used for loading. We just check the format of
+ // the transparency color and then swap bytes if needed.
+ // We read the transparent color from far back inside the buffer
+ // where actual cursor data would never get stored (at least not
+ // for the games concerned).
+ uint16 transCol = (_game.heversion >= 80) ? 5 : 255;
+#ifdef SCUMM_LITTLE_ENDIAN
+ if (READ_BE_UINT16(&_grabbedCursor[2046]) == transCol) {
+#else
+ if (READ_LE_UINT16(&_grabbedCursor[2046]) == transCol) {
+#endif
+ uint16 *pos = (uint16*)_grabbedCursor;
+ for (i = 0; i < 4096; ++i) {
+ *pos = SWAP_BYTES_16(*pos);
+ pos++;
+ }
+ }
+ }
+ } else {
+ s.syncBytes(_grabbedCursor, 8192, VER(20));
+ }
+
s.syncAsSint16LE(_cursor.width, VER(20));
s.syncAsSint16LE(_cursor.height, VER(20));
s.syncAsSint16LE(_cursor.hotspotX, VER(20));
More information about the Scummvm-git-logs
mailing list