Skip to content

Commit

Permalink
HOPKINS: Added explicit int16 cast to all READ_LE_UINT16 accesses.
Browse files Browse the repository at this point in the history
I've already previously fixed two initialisatoin errors for data reading that expected int's to be 16 bits and signed, so adding the explicit cast everywhere will likely fix other similiar issues.
  • Loading branch information
dreammaster committed Oct 11, 2012
1 parent d8dd041 commit 721b619
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 354 deletions.
30 changes: 15 additions & 15 deletions engines/hopkins/anim.cpp
Expand Up @@ -859,10 +859,10 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam

if (_vm->_globals.Bank[idx].field1A > 0) {
for (int v14 = 0; v14 < _vm->_globals.Bank[idx].field1A; ++v14) {
v16 = READ_LE_UINT16(v13);
v17 = READ_LE_UINT16(v13 + 2);
v21 = READ_LE_UINT16(v13 + 4);
v20 = READ_LE_UINT16(v13 + 6);
v16 = (int16)READ_LE_UINT16(v13);
v17 = (int16)READ_LE_UINT16(v13 + 2);
v21 = (int16)READ_LE_UINT16(v13 + 4);
v20 = (int16)READ_LE_UINT16(v13 + 6);
v13 += 8;

_vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, v14, v16, v17, 0);
Expand Down Expand Up @@ -953,11 +953,11 @@ void AnimationManager::RECHERCHE_ANIM(const byte *data, int idx, int nbytes) {

v9 = dataP + 20;
v23 = v21 + data + 25;
v10 = READ_LE_UINT16(v21 + data + 25);
v11 = READ_LE_UINT16(v21 + data + 27);
v22 = READ_LE_UINT16(v21 + data + 29);
v12 = READ_LE_UINT16(v21 + data + 31);
v13 = READ_LE_UINT16(v21 + data + 33);
v10 = (int16)READ_LE_UINT16(v21 + data + 25);
v11 = (int16)READ_LE_UINT16(v21 + data + 27);
v22 = (int16)READ_LE_UINT16(v21 + data + 29);
v12 = (int16)READ_LE_UINT16(v21 + data + 31);
v13 = (int16)READ_LE_UINT16(v21 + data + 33);
*(dataP + 29) = *(v21 + data + 34);
WRITE_LE_UINT16(dataP + 20, v10);
WRITE_LE_UINT16(dataP + 22, v11);
Expand All @@ -972,11 +972,11 @@ void AnimationManager::RECHERCHE_ANIM(const byte *data, int idx, int nbytes) {
if (!v22)
break;

v24 = READ_LE_UINT16(v23);
v15 = READ_LE_UINT16(v23 + 2);
v22 = READ_LE_UINT16(v23 + 4);
v16 = READ_LE_UINT16(v23 + 6);
v17 = READ_LE_UINT16(v23 + 8);
v24 = (int16)READ_LE_UINT16(v23);
v15 = (int16)READ_LE_UINT16(v23 + 2);
v22 = (int16)READ_LE_UINT16(v23 + 4);
v16 = (int16)READ_LE_UINT16(v23 + 6);
v17 = (int16)READ_LE_UINT16(v23 + 8);
*(v9 + 9) = *(v23 + 9);
WRITE_LE_UINT16(v9, v24);
WRITE_LE_UINT16(v9 + 2, v15);
Expand Down Expand Up @@ -1102,7 +1102,7 @@ void AnimationManager::PLAY_SEQ(int a1, const Common::String &a2, uint32 a3, uin
if (strncmp((const char *)v10, "IMAGE=", 7))
v5 = -1;
if (!v5) {
f.read(v9, READ_LE_UINT16(v10 + 8));
f.read(v9, (int16)READ_LE_UINT16(v10 + 8));
if (_vm->_globals.iRegul == 1) {
do {
if (_vm->_eventsManager.ESC_KEY == 1) {
Expand Down
2 changes: 1 addition & 1 deletion engines/hopkins/font.cpp
Expand Up @@ -253,7 +253,7 @@ void FontManager::BOITE(int idx, int fileIndex, const Common::String &filename,
v10 = _vm->_globals.BUF_ZONE + Index[fileIndex];
memcpy(v9, v10, 0x60u);
v11 = 0;
WRITE_LE_UINT16((uint16 *)v9 + 48, READ_LE_UINT16(v10 + 96));
WRITE_LE_UINT16((uint16 *)v9 + 48, (int16)READ_LE_UINT16(v10 + 96));
}
v59 = texte_tmp;
v63 = 0;
Expand Down
8 changes: 4 additions & 4 deletions engines/hopkins/globals.cpp
Expand Up @@ -883,11 +883,11 @@ void Globals::CHARGE_CACHE(const Common::String &file) {
v15 = 60;
v14 = 0;
do {
v11 = READ_LE_UINT16((uint16 *)ptr + v15);
v4 = READ_LE_UINT16((uint16 *)ptr + v15 + 1);
v5 = READ_LE_UINT16((uint16 *)ptr + v15 + 2);
v11 = (int16)READ_LE_UINT16((uint16 *)ptr + v15);
v4 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 1);
v5 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 2);
v6 = v14;
Cache[v6].field14 = READ_LE_UINT16((uint16 *)ptr + v15 + 4);
Cache[v6].field14 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 4);
Cache[v6].field2 = v11;
Cache[v6].field0 = v4;
Cache[v6].field4 = v5;
Expand Down
38 changes: 19 additions & 19 deletions engines/hopkins/graphics.cpp
Expand Up @@ -372,9 +372,9 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by
v7 = _vm->_globals.CAT_TAILLE - 896;
v8 = f.read(HEADER_PCX, 128);

v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1;
v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1;
if ((READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) {
v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
if (((int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) {
DOUBLE_ECRAN = false;
} else {
v6 = SCREEN_WIDTH * 2;
Expand All @@ -396,8 +396,8 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by
if (bytesRead < 128)
error("Erreur en cours de lecture.");

v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1;
v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1;
v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
if (v6 <= SCREEN_WIDTH) {
DOUBLE_ECRAN = false;
} else {
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSur
v6 = *(v5 + 2);
v5 += 2;
} else if (v6 == 254) {
v3 += READ_LE_UINT16(v5 + 1);
v3 += (int16)READ_LE_UINT16(v5 + 1);
v6 = *(v5 + 3);
v5 += 3;
} else {
Expand Down Expand Up @@ -1162,7 +1162,7 @@ void GraphicsManager::Copy_Video_Vbe3(const byte *surface) {
v5 = *(v4 + 2);
v4 += 2;
} else if (v5 == (byte)-2) {
v2 += READ_LE_UINT16(v4 + 1);
v2 += (int16)READ_LE_UINT16(v4 + 1);
v5 = *(v4 + 3);
v4 += 3;
} else {
Expand Down Expand Up @@ -1217,7 +1217,7 @@ void GraphicsManager::Copy_Video_Vbe16(const byte *surface) {
srcByte = *(const byte *)(srcP + 2);
srcP += 2;
} else if (srcByte == 254) {
destOffset += READ_LE_UINT16(srcP + 1);
destOffset += (int16)READ_LE_UINT16(srcP + 1);
srcByte = *(const byte *)(srcP + 3);
srcP += 3;
} else {
Expand Down Expand Up @@ -1277,7 +1277,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) {
v4 = *(v3 + 2);
v3 += 2;
} else if (v4 == -2) {
v2 += READ_LE_UINT16(v3 + 1);
v2 += (int16)READ_LE_UINT16(v3 + 1);
v4 = *(v3 + 3);
v3 += 3;
} else {
Expand All @@ -1286,7 +1286,7 @@ void GraphicsManager::Copy_Video_Vbe16a(const byte *surface) {
v3 += 5;
}
Video_Cont_Vbe16a:
WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4));
WRITE_LE_UINT16(v2 + v2 + VideoPtr, (int16)READ_LE_UINT16(PAL_PIXELS + 2 * v4));
++v3;
++v2;
}
Expand Down Expand Up @@ -1336,9 +1336,9 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp,
clip_flag = false;

spriteP += 4;
int width = READ_LE_UINT16(spriteP);
int width = (int16)READ_LE_UINT16(spriteP);
spriteP += 2;
int height = READ_LE_UINT16(spriteP);
int height = (int16)READ_LE_UINT16(spriteP);

// Clip X
clip_x1 = width;
Expand Down Expand Up @@ -1386,7 +1386,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp,

// Set up source
spriteP += 6;
int srcOffset = READ_LE_UINT16(spriteP);
int srcOffset = (int16)READ_LE_UINT16(spriteP);
spriteP += 4;
const byte *srcP = spriteP;
spriteP += srcOffset;
Expand All @@ -1404,7 +1404,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp,

while ((byteVal = *srcP) != 253) {
++srcP;
width = READ_LE_UINT16(srcP);
width = (int16)READ_LE_UINT16(srcP);
srcP += 2;

if (byteVal == 254) {
Expand Down Expand Up @@ -1432,7 +1432,7 @@ void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp,

while ((byteVal = *srcP) != 253) {
++srcP;
width = READ_LE_UINT16(srcP);
width = (int16)READ_LE_UINT16(srcP);
srcP += 2;

if (byteVal == 254) {
Expand Down Expand Up @@ -2294,9 +2294,9 @@ void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int x
v9 = 0;
v10 = 0;
v8 = v6 + 4;
v9 = READ_LE_UINT16(v8);
v9 = (int16)READ_LE_UINT16(v8);
v8 += 2;
v10 = READ_LE_UINT16(v8);
v10 = (int16)READ_LE_UINT16(v8);
v11 = v8 + 10;
destP = surface + xp + nbrligne2 * yp;
Largeur = v9;
Expand Down Expand Up @@ -2465,7 +2465,7 @@ void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) {
byteVal = *(srcPtr + 2);
srcPtr += 2;
} else if (byteVal == (byte)-2) {
destOffset += READ_LE_UINT16(srcPtr + 1);
destOffset += (int16)READ_LE_UINT16(srcPtr + 1);
byteVal = *(srcPtr + 3);
srcPtr += 3;
} else {
Expand Down Expand Up @@ -2499,7 +2499,7 @@ void GraphicsManager::Copy_Video_Vbe(const byte *src) {
byteVal = *(srcP + 2);
srcP += 2;
} else if (byteVal == -2) {
destOffset += READ_LE_UINT16(srcP + 1);
destOffset += (int16)READ_LE_UINT16(srcP + 1);
byteVal = *(srcP + 3);
srcP += 3;
} else {
Expand Down

0 comments on commit 721b619

Please sign in to comment.