diff options
author | Strangerke | 2012-11-16 08:32:40 +0100 |
---|---|---|
committer | Strangerke | 2012-11-16 08:32:40 +0100 |
commit | 6d1db995408f3325824698b330300a0292a49931 (patch) | |
tree | 4cfca99c5e9801dc8ed48b5d2f114d8633f4d37a | |
parent | e920b06ececf39db787b3ec26be3ffe1b498ea1d (diff) | |
download | scummvm-rg350-6d1db995408f3325824698b330300a0292a49931.tar.gz scummvm-rg350-6d1db995408f3325824698b330300a0292a49931.tar.bz2 scummvm-rg350-6d1db995408f3325824698b330300a0292a49931.zip |
HOPKINS: Remove some magic values, add a safety check in Copy_Video_Vbe16
-rw-r--r-- | engines/hopkins/anim.cpp | 22 | ||||
-rw-r--r-- | engines/hopkins/files.cpp | 2 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 53 | ||||
-rw-r--r-- | engines/hopkins/graphics.h | 4 |
4 files changed, 45 insertions, 36 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 993b64e167..a5821bbcce 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -149,14 +149,14 @@ LABEL_38: _vm->_eventsManager.lItCounter = 0; _vm->_graphicsManager.DD_Lock(); if (hasScreenCopy) { - if (*v10 != (byte)-4) { + if (*v10 != kByteStop) { _vm->_graphicsManager.Copy_WinScan_Vbe3(v10, screenCopy); if (_vm->_graphicsManager.Winbpp == 2) _vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, 640, 480, 0, 0); else _vm->_graphicsManager.m_scroll2A(screenCopy, 0, 0, 640, 480, 0, 0); } - } else if (*v10 != (byte)-4) { + } else if (*v10 != kByteStop) { if (_vm->_graphicsManager.Winbpp == 1) _vm->_graphicsManager.Copy_Video_Vbe3(v10); if (_vm->_graphicsManager.Winbpp == 2) @@ -224,7 +224,7 @@ LABEL_58: v5 = -1; if (!v5) { f.read(v10, READ_LE_UINT32(ptr + 8)); - if (*v10 != (byte)-4) + if (*v10 != kByteStop) _vm->_graphicsManager.Copy_WinScan_Vbe3(v10, screenCopy); } } while (v5 != -1); @@ -440,14 +440,14 @@ LABEL_77: _vm->_eventsManager.lItCounter = 0; _vm->_graphicsManager.DD_Lock(); if (v8) { - if (*v12 != (byte)-4) { + if (*v12 != kByteStop) { _vm->_graphicsManager.Copy_WinScan_Vbe3(v12, ptr); if (_vm->_graphicsManager.Winbpp == 2) _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } - } else if (*v12 != (byte)-4) { + } else if (*v12 != kByteStop) { if (_vm->_graphicsManager.Winbpp == 1) _vm->_graphicsManager.Copy_Video_Vbe3(v12); if (_vm->_graphicsManager.Winbpp == 2) @@ -617,7 +617,7 @@ LABEL_114: if (!v6) { f.read(v12, READ_LE_UINT32(v13 + 8)); - if (*v12 != (byte)-4) + if (*v12 != kByteStop) _vm->_graphicsManager.Copy_WinScan_Vbe3(v12, ptra); } } while (v6 != -1); @@ -1107,14 +1107,14 @@ void AnimationManager::PLAY_SEQ(const Common::String &a2, uint32 a3, uint32 a4, _vm->_eventsManager.lItCounter = 0; _vm->_graphicsManager.DD_Lock(); if (v7) { - if (*v9 != (byte)-4) { + if (*v9 != kByteStop) { _vm->_graphicsManager.Copy_WinScan_Vbe(v9, ptr); if (_vm->_graphicsManager.Winbpp == 2) _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } - } else if (*v9 != (byte)-4) { + } else if (*v9 != kByteStop) { if (_vm->_graphicsManager.Winbpp == 1) _vm->_graphicsManager.Copy_Video_Vbe(v9); if (_vm->_graphicsManager.Winbpp == 2) @@ -1274,14 +1274,14 @@ LABEL_33: _vm->_eventsManager.lItCounter = 0; _vm->_graphicsManager.DD_Lock(); if (v7) { - if (*v10 != (byte)-4) { + if (*v10 != kByteStop) { _vm->_graphicsManager.Copy_WinScan_Vbe(v10, ptr); if (_vm->_graphicsManager.Winbpp == 2) _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); else _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } - } else if (*v10 != (byte)-4) { + } else if (*v10 != kByteStop) { if (_vm->_graphicsManager.Winbpp == 1) _vm->_graphicsManager.Copy_Video_Vbe(v10); if (_vm->_graphicsManager.Winbpp == 2) @@ -1343,7 +1343,7 @@ LABEL_54: v5 = true; if (!v5) { f.read(v10, READ_LE_UINT32(v11 + 8)); - if (*v10 != (byte)-4) + if (*v10 != kByteStop) _vm->_graphicsManager.Copy_WinScan_Vbe(v10, ptra); } } while (!v5); diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 79b672ca33..aafa56691f 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -99,7 +99,7 @@ void FileManager::DMESS1() { void FileManager::bload(const Common::String &file, byte *buf) { Common::File f; if (!f.open(file)) - error("Error openinig file - %s", file.c_str()); + error("Error opening file - %s", file.c_str()); int32 filesize = f.size(); _vm->_fileManager.bload_it(f, buf, filesize); f.close(); diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a455d35f40..8af5792389 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -957,17 +957,17 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) srcByte = *srcP; if (*srcP < 0xDEu) goto Video_Cont3_wVbe; - if (srcByte == (byte)-4) + if (srcByte == kByteStop) return; - if (srcByte < 0xFBu) { + if (srcByte < kSetOffset) { destOffset += (byte)(*srcP + 35); srcByte = *(srcP++ + 1); - } else if (srcByte == (byte)-3) { + } else if (srcByte == k8bVal) { destOffset += *(srcP + 1); srcByte = *(srcP + 2); srcP += 2; - } else if (srcByte == (byte)-2) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(srcP + 3); srcP += 3; @@ -1019,16 +1019,16 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) { if (*srcP < 222) goto Video_Cont3_Vbe; - if (srcByte == 252) + if (srcByte == kByteStop) return; - if (srcByte < 251) { + if (srcByte < kSetOffset) { destOffset += *srcP + 35; srcByte = *(srcP++ + 1); - } else if (srcByte == (byte)-3) { + } else if (srcByte == k8bVal) { destOffset += *(srcP + 1); srcByte = *(srcP + 2); srcP += 2; - } else if (srcByte == (byte)-2) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(srcP + 3); srcP += 3; @@ -1070,16 +1070,16 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { for (;;) { byte srcByte = *srcP; if (srcByte >= 222) { - if (srcByte == 252) + if (srcByte == kByteStop) return; - if (srcByte < 251) { + if (srcByte < kSetOffset) { destOffset += srcByte - 221; srcByte = *++srcP; - } else if (srcByte == 253) { + } else if (srcByte == k8bVal) { destOffset += *(const byte *)(srcP + 1); srcByte = *(const byte *)(srcP + 2); srcP += 2; - } else if (srcByte == 254) { + } else if (srcByte == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); srcByte = *(const byte *)(srcP + 3); srcP += 3; @@ -1090,6 +1090,11 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) { } } + if (destOffset > 640 * 480) { + warning("HACK: Stopping anim, out of bounds - 0x%x %d", srcByte, destOffset); + return; + } + if (srcByte > 210) { if (srcByte == 211) { int pixelCount = *(srcP + 1); @@ -1131,15 +1136,15 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) { srcP = srcData; for (;;) { pixelIndex = *srcP; - if (*srcP < 0xFCu) + if (*srcP < kByteStop) goto Video_Cont_Vbe16a; - if (pixelIndex == (byte)-4) + if (pixelIndex == kByteStop) return; - if (pixelIndex == (byte)-3) { + if (pixelIndex == k8bVal) { destOffset += *(srcP + 1); pixelIndex = *(srcP + 2); srcP += 2; - } else if (pixelIndex == (byte)-2) { + } else if (pixelIndex == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); pixelIndex = *(srcP + 3); srcP += 3; @@ -2295,15 +2300,15 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) { srcPtr = src; while (1) { byteVal = *srcPtr; - if (*srcPtr < 0xFCu) + if (*srcPtr < kByteStop) goto Video_Cont_wVbe; - if (byteVal == (byte)-4) + if (byteVal == kByteStop) return; - if (byteVal == (byte)-3) { + if (byteVal == k8bVal) { destOffset += *(srcPtr + 1); byteVal = *(srcPtr + 2); srcPtr += 2; - } else if (byteVal == (byte)-2) { + } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcPtr + 1); byteVal = *(srcPtr + 3); srcPtr += 3; @@ -2329,15 +2334,15 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) { srcP = src; while (1) { byteVal = *srcP; - if (*srcP < 0xFCu) + if (*srcP < kByteStop) goto Video_Cont_Vbe; - if (byteVal == (byte)-4) + if (byteVal == kByteStop) return; - if (byteVal == (byte)-3) { + if (byteVal == k8bVal) { destOffset += *(srcP + 1); byteVal = *(srcP + 2); srcP += 2; - } else if (byteVal == (byte)-2) { + } else if (byteVal == k16bVal) { destOffset += READ_LE_UINT16(srcP + 1); byteVal = *(srcP + 3); srcP += 3; diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h index 5112672848..e29ede718e 100644 --- a/engines/hopkins/graphics.h +++ b/engines/hopkins/graphics.h @@ -34,6 +34,10 @@ namespace Hopkins { #define PALETTE_SIZE 256 #define PALETTE_BLOCK_SIZE (PALETTE_SIZE * 3) #define PALETTE_EXT_BLOCK_SIZE 800 +static const byte kSetOffset = 251; +static const byte kByteStop = 252; +static const byte k8bVal = 253; +static const byte k16bVal = 254; struct RGB8 { byte r; |