diff options
author | Sven Hesse | 2006-01-07 22:28:54 +0000 |
---|---|---|
committer | Sven Hesse | 2006-01-07 22:28:54 +0000 |
commit | fdd5cfb635e4f37c18fc86469c1140b6b90dd901 (patch) | |
tree | 48cee91fb47786e0ab2f67afa2f3c7e3eeb6c0dd | |
parent | c5da1bb276ddbc41d788e6abcae47624a5493355 (diff) | |
download | scummvm-rg350-fdd5cfb635e4f37c18fc86469c1140b6b90dd901.tar.gz scummvm-rg350-fdd5cfb635e4f37c18fc86469c1140b6b90dd901.tar.bz2 scummvm-rg350-fdd5cfb635e4f37c18fc86469c1140b6b90dd901.zip |
Added initial support for ADL music files; continued underscoring of member variables
svn-id: r19937
-rw-r--r-- | gob/cdrom.cpp | 4 | ||||
-rw-r--r-- | gob/draw.cpp | 840 | ||||
-rw-r--r-- | gob/draw.h | 120 | ||||
-rw-r--r-- | gob/game.cpp | 918 | ||||
-rw-r--r-- | gob/game.h | 60 | ||||
-rw-r--r-- | gob/gob.cpp | 5 | ||||
-rw-r--r-- | gob/gob.h | 2 | ||||
-rw-r--r-- | gob/goblin.cpp | 1786 | ||||
-rw-r--r-- | gob/goblin.h | 166 | ||||
-rw-r--r-- | gob/init.cpp | 30 | ||||
-rw-r--r-- | gob/inter.cpp | 22 | ||||
-rw-r--r-- | gob/inter_v1.cpp | 268 | ||||
-rw-r--r-- | gob/map.cpp | 128 | ||||
-rw-r--r-- | gob/module.mk | 1 | ||||
-rw-r--r-- | gob/mult.cpp | 32 | ||||
-rw-r--r-- | gob/music.cpp | 378 | ||||
-rw-r--r-- | gob/music.h | 91 | ||||
-rw-r--r-- | gob/parse.cpp | 4 | ||||
-rw-r--r-- | gob/scenery.cpp | 138 |
19 files changed, 2734 insertions, 2259 deletions
diff --git a/gob/cdrom.cpp b/gob/cdrom.cpp index 5e34a9fed0..9bfc19cabc 100644 --- a/gob/cdrom.cpp +++ b/gob/cdrom.cpp @@ -124,7 +124,7 @@ void CDROM::playBgMusic() { }; for (int i = 0; i < ARRAYSIZE(tracks); i++) - if (!scumm_stricmp(_vm->_game->curTotFile, tracks[i][0])) { + if (!scumm_stricmp(_vm->_game->_curTotFile, tracks[i][0])) { startTrack(tracks[i][1]); break; } @@ -141,7 +141,7 @@ void CDROM::playMultMusic() { }; for (int i = 0; i < ARRAYSIZE(tracks); i++) - if (!scumm_stricmp(_vm->_game->curTotFile, tracks[i][0])) { + if (!scumm_stricmp(_vm->_game->_curTotFile, tracks[i][0])) { _cdPlaying = true; startTrack(tracks[i][_vm->_global->_language + 1]); break; diff --git a/gob/draw.cpp b/gob/draw.cpp index 7ece03efc3..18467ae51d 100644 --- a/gob/draw.cpp +++ b/gob/draw.cpp @@ -34,92 +34,92 @@ namespace Gob { Draw::Draw(GobEngine *vm) : _vm(vm) { - fontIndex = 0; - spriteLeft = 0; - spriteTop = 0; - spriteRight = 0; - spriteBottom = 0; - destSpriteX = 0; - destSpriteY = 0; - backColor = 0; - frontColor = 0; - letterToPrint = 0; - - destSurface = 0; - sourceSurface = 0; - renderFlags = 0; - backDeltaX = 0; - backDeltaY = 0; + _fontIndex = 0; + _spriteLeft = 0; + _spriteTop = 0; + _spriteRight = 0; + _spriteBottom = 0; + _destSpriteX = 0; + _destSpriteY = 0; + _backColor = 0; + _frontColor = 0; + _letterToPrint = 0; + + _destSurface = 0; + _sourceSurface = 0; + _renderFlags = 0; + _backDeltaX = 0; + _backDeltaY = 0; for (int i = 0; i < 4; i++) - fonts[i] = 0; + _fonts[i] = 0; - textToPrint = 0; - transparency = 0; + _textToPrint = 0; + _transparency = 0; for (int i = 0; i < 50; i++) - spritesArray[i] = 0; + _spritesArray[i] = 0; - invalidatedCount = 0; + _invalidatedCount = 0; for (int i = 0; i < 30; i++) { - invalidatedTops[i] = 0; - invalidatedLefts[i] = 0; - invalidatedRights[i] = 0; - invalidatedBottoms[i] = 0; + _invalidatedTops[i] = 0; + _invalidatedLefts[i] = 0; + _invalidatedRights[i] = 0; + _invalidatedBottoms[i] = 0; } - noInvalidated = 0; - applyPal = 0; - paletteCleared = 0; + _noInvalidated = 0; + _applyPal = 0; + _paletteCleared = 0; - backSurface = 0; - frontSurface = 0; + _backSurface = 0; + _frontSurface = 0; for (int i = 0; i < 18; i++) - unusedPalette1[i] = 0; + _unusedPalette1[i] = 0; for (int i = 0; i < 16; i++) - unusedPalette2[i] = 0; + _unusedPalette2[i] = 0; for (int i = 0; i < 256; i++) { - vgaPalette[i].red = 0; - vgaPalette[i].blue = 0; - vgaPalette[i].green = 0; + _vgaPalette[i].red = 0; + _vgaPalette[i].blue = 0; + _vgaPalette[i].green = 0; } for (int i = 0; i < 16; i++) { - vgaSmallPalette[i].red = 0; - vgaSmallPalette[i].blue = 0; - vgaSmallPalette[i].green = 0; + _vgaSmallPalette[i].red = 0; + _vgaSmallPalette[i].blue = 0; + _vgaSmallPalette[i].green = 0; } - cursorX = 0; - cursorY = 0; - cursorWidth = 0; - cursorHeight = 0; + _cursorX = 0; + _cursorY = 0; + _cursorWidth = 0; + _cursorHeight = 0; - cursorXDeltaVar = -1; - cursorYDeltaVar = -1; + _cursorXDeltaVar = -1; + _cursorYDeltaVar = -1; for (int i = 0; i < 40; i++) { - cursorAnimLow[i] = 0; - cursorAnimHigh[i] = 0; - cursorAnimDelays[i] = 0; + _cursorAnimLow[i] = 0; + _cursorAnimHigh[i] = 0; + _cursorAnimDelays[i] = 0; } - gcursorIndex = 0; - transparentCursor = 0; - cursorSprites = 0; - cursorBack = 0; - cursorAnim = 0; - - palLoadData1[0] = 0; - palLoadData1[1] = 17; - palLoadData1[2] = 34; - palLoadData1[3] = 51; - palLoadData2[0] = 0; - palLoadData2[1] = 68; - palLoadData2[2] = 136; - palLoadData2[3] = 204; - - cursorTimeKey = 0; + _cursorIndex = 0; + _transparentCursor = 0; + _cursorSprites = 0; + _cursorBack = 0; + _cursorAnim = 0; + + _palLoadData1[0] = 0; + _palLoadData1[1] = 17; + _palLoadData1[2] = 34; + _palLoadData1[3] = 51; + _palLoadData2[0] = 0; + _palLoadData2[1] = 68; + _palLoadData2[2] = 136; + _palLoadData2[3] = 204; + + _cursorTimeKey = 0; } void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { @@ -127,7 +127,7 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { int16 rect; int16 i; - if (renderFlags & RENDERFLAG_NOINVALIDATE) + if (_renderFlags & RENDERFLAG_NOINVALIDATE) return; if (left > right) { @@ -144,14 +144,14 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { if (left > 319 || right < 0 || top > 199 || bottom < 0) return; - noInvalidated = 0; + _noInvalidated = 0; - if (invalidatedCount >= 30) { - invalidatedLefts[0] = 0; - invalidatedTops[0] = 0; - invalidatedRights[0] = 319; - invalidatedBottoms[0] = 199; - invalidatedCount = 1; + if (_invalidatedCount >= 30) { + _invalidatedLefts[0] = 0; + _invalidatedTops[0] = 0; + _invalidatedRights[0] = 319; + _invalidatedBottoms[0] = 199; + _invalidatedCount = 1; return; } @@ -170,105 +170,105 @@ void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) { left &= 0xfff0; right |= 0x000f; - for (rect = 0; rect < invalidatedCount; rect++) { - - if (invalidatedTops[rect] > top) { - if (invalidatedTops[rect] > bottom) { - for (i = invalidatedCount; i > rect; i--) { - invalidatedLefts[i] = - invalidatedLefts[i - 1]; - invalidatedTops[i] = - invalidatedTops[i - 1]; - invalidatedRights[i] = - invalidatedRights[i - 1]; - invalidatedBottoms[i] = - invalidatedBottoms[i - 1]; + for (rect = 0; rect < _invalidatedCount; rect++) { + + if (_invalidatedTops[rect] > top) { + if (_invalidatedTops[rect] > bottom) { + for (i = _invalidatedCount; i > rect; i--) { + _invalidatedLefts[i] = + _invalidatedLefts[i - 1]; + _invalidatedTops[i] = + _invalidatedTops[i - 1]; + _invalidatedRights[i] = + _invalidatedRights[i - 1]; + _invalidatedBottoms[i] = + _invalidatedBottoms[i - 1]; } - invalidatedLefts[rect] = left; - invalidatedTops[rect] = top; - invalidatedRights[rect] = right; - invalidatedBottoms[rect] = bottom; - invalidatedCount++; + _invalidatedLefts[rect] = left; + _invalidatedTops[rect] = top; + _invalidatedRights[rect] = right; + _invalidatedBottoms[rect] = bottom; + _invalidatedCount++; return; } - if (invalidatedBottoms[rect] < bottom) - invalidatedBottoms[rect] = bottom; + if (_invalidatedBottoms[rect] < bottom) + _invalidatedBottoms[rect] = bottom; - if (invalidatedLefts[rect] > left) - invalidatedLefts[rect] = left; + if (_invalidatedLefts[rect] > left) + _invalidatedLefts[rect] = left; - if (invalidatedRights[rect] < right) - invalidatedRights[rect] = right; + if (_invalidatedRights[rect] < right) + _invalidatedRights[rect] = right; - invalidatedTops[rect] = top; + _invalidatedTops[rect] = top; return; } - if (invalidatedBottoms[rect] < top) + if (_invalidatedBottoms[rect] < top) continue; - if (invalidatedBottoms[rect] < bottom) - invalidatedBottoms[rect] = bottom; + if (_invalidatedBottoms[rect] < bottom) + _invalidatedBottoms[rect] = bottom; - if (invalidatedLefts[rect] > left) - invalidatedLefts[rect] = left; + if (_invalidatedLefts[rect] > left) + _invalidatedLefts[rect] = left; - if (invalidatedRights[rect] < right) - invalidatedRights[rect] = right; + if (_invalidatedRights[rect] < right) + _invalidatedRights[rect] = right; return; } - invalidatedLefts[invalidatedCount] = left; - invalidatedTops[invalidatedCount] = top; - invalidatedRights[invalidatedCount] = right; - invalidatedBottoms[invalidatedCount] = bottom; - invalidatedCount++; + _invalidatedLefts[_invalidatedCount] = left; + _invalidatedTops[_invalidatedCount] = top; + _invalidatedRights[_invalidatedCount] = right; + _invalidatedBottoms[_invalidatedCount] = bottom; + _invalidatedCount++; return; } void Draw::blitInvalidated(void) { int16 i; - if (gcursorIndex == 4) + if (_cursorIndex == 4) blitCursor(); if (_vm->_inter->_terminate) return; - if (noInvalidated && applyPal == 0) + if (_noInvalidated && _applyPal == 0) return; - if (noInvalidated) { + if (_noInvalidated) { setPalette(); - applyPal = 0; + _applyPal = 0; return; } - if (applyPal) { + if (_applyPal) { clearPalette(); - _vm->_video->drawSprite(backSurface, frontSurface, 0, 0, 319, + _vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0, 319, 199, 0, 0, 0); setPalette(); - invalidatedCount = 0; - noInvalidated = 1; - applyPal = 0; + _invalidatedCount = 0; + _noInvalidated = 1; + _applyPal = 0; return; } _vm->_global->_doRangeClamp = 0; - for (i = 0; i < invalidatedCount; i++) { - _vm->_video->drawSprite(backSurface, frontSurface, - invalidatedLefts[i], invalidatedTops[i], - invalidatedRights[i], invalidatedBottoms[i], - invalidatedLefts[i], invalidatedTops[i], 0); + for (i = 0; i < _invalidatedCount; i++) { + _vm->_video->drawSprite(_backSurface, _frontSurface, + _invalidatedLefts[i], _invalidatedTops[i], + _invalidatedRights[i], _invalidatedBottoms[i], + _invalidatedLefts[i], _invalidatedTops[i], 0); } _vm->_global->_doRangeClamp = 1; - invalidatedCount = 0; - noInvalidated = 1; - applyPal = 0; + _invalidatedCount = 0; + _noInvalidated = 1; + _applyPal = 0; } void Draw::setPalette(void) { @@ -276,41 +276,41 @@ void Draw::setPalette(void) { error("setPalette: Video mode 0x%x is not supported!\n", _vm->_global->_videoMode); - _vm->_global->_pPaletteDesc->unused1 = unusedPalette1; - _vm->_global->_pPaletteDesc->unused2 = unusedPalette2; - _vm->_global->_pPaletteDesc->vgaPal = vgaPalette; + _vm->_global->_pPaletteDesc->unused1 = _unusedPalette1; + _vm->_global->_pPaletteDesc->unused2 = _unusedPalette2; + _vm->_global->_pPaletteDesc->vgaPal = _vgaPalette; _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - paletteCleared = 0; + _paletteCleared = 0; } void Draw::clearPalette(void) { - if (paletteCleared == 0) { - paletteCleared = 1; + if (_paletteCleared == 0) { + _paletteCleared = 1; _vm->_util->clearPalette(); } } void Draw::blitCursor(void) { - if (gcursorIndex == -1) + if (_cursorIndex == -1) return; - gcursorIndex = -1; - if (cursorX + cursorWidth > 320) - cursorWidth = 320 - cursorX; + _cursorIndex = -1; + if (_cursorX + _cursorWidth > 320) + _cursorWidth = 320 - _cursorX; - if (cursorY + cursorHeight > 200) - cursorHeight = 200 - cursorY; + if (_cursorY + _cursorHeight > 200) + _cursorHeight = 200 - _cursorY; - if (noInvalidated) { - _vm->_video->drawSprite(backSurface, frontSurface, - cursorX, cursorY, - cursorX + cursorWidth - 1, - cursorY + cursorHeight - 1, cursorX, - cursorY, 0); + if (_noInvalidated) { + _vm->_video->drawSprite(_backSurface, _frontSurface, + _cursorX, _cursorY, + _cursorX + _cursorWidth - 1, + _cursorY + _cursorHeight - 1, _cursorX, + _cursorY, 0); } else { - invalidateRect(cursorX, cursorY, - cursorX + cursorWidth - 1, - cursorY + cursorHeight - 1); + invalidateRect(_cursorX, _cursorY, + _cursorX + _cursorWidth - 1, + _cursorY + _cursorHeight - 1); } } @@ -325,262 +325,262 @@ void Draw::spriteOperation(int16 operation) { int16 y; int16 perLine; - if (sourceSurface >= 100) - sourceSurface -= 80; + if (_sourceSurface >= 100) + _sourceSurface -= 80; - if (destSurface >= 100) - destSurface -= 80; + if (_destSurface >= 100) + _destSurface -= 80; - if (renderFlags & RENDERFLAG_USEDELTAS) { - if (sourceSurface == 21) { - spriteLeft += backDeltaX; - spriteTop += backDeltaY; + if (_renderFlags & RENDERFLAG_USEDELTAS) { + if (_sourceSurface == 21) { + _spriteLeft += _backDeltaX; + _spriteTop += _backDeltaY; } - if (destSurface == 21) { - destSpriteX += backDeltaX; - destSpriteY += backDeltaY; + if (_destSurface == 21) { + _destSpriteX += _backDeltaX; + _destSpriteY += _backDeltaY; if (operation == DRAW_DRAWLINE || (operation >= DRAW_DRAWBAR && operation <= DRAW_FILLRECTABS)) { - spriteRight += backDeltaX; - spriteBottom += backDeltaY; + _spriteRight += _backDeltaX; + _spriteBottom += _backDeltaY; } } } switch (operation) { case DRAW_BLITSURF: - _vm->_video->drawSprite(spritesArray[sourceSurface], - spritesArray[destSurface], - spriteLeft, spriteTop, - spriteLeft + spriteRight - 1, - spriteTop + spriteBottom - 1, - destSpriteX, destSpriteY, transparency); - - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX + spriteRight - 1, - destSpriteY + spriteBottom - 1); + _vm->_video->drawSprite(_spritesArray[_sourceSurface], + _spritesArray[_destSurface], + _spriteLeft, _spriteTop, + _spriteLeft + _spriteRight - 1, + _spriteTop + _spriteBottom - 1, + _destSpriteX, _destSpriteY, _transparency); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX + _spriteRight - 1, + _destSpriteY + _spriteBottom - 1); } break; case DRAW_PUTPIXEL: - _vm->_video->putPixel(destSpriteX, destSpriteY, - frontColor, spritesArray[destSurface]); - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX, destSpriteY); + _vm->_video->putPixel(_destSpriteX, _destSpriteY, + _frontColor, _spritesArray[_destSurface]); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX, _destSpriteY); } break; case DRAW_FILLRECT: - _vm->_video->fillRect(spritesArray[destSurface], - destSpriteX, destSpriteY, - destSpriteX + spriteRight - 1, - destSpriteY + spriteBottom - 1, backColor); - - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX + spriteRight - 1, - destSpriteY + spriteBottom - 1); + _vm->_video->fillRect(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _destSpriteX + _spriteRight - 1, + _destSpriteY + _spriteBottom - 1, _backColor); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX + _spriteRight - 1, + _destSpriteY + _spriteBottom - 1); } break; case DRAW_DRAWLINE: - _vm->_video->drawLine(spritesArray[destSurface], - destSpriteX, destSpriteY, - spriteRight, spriteBottom, frontColor); + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - spriteRight, spriteBottom); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); } break; case DRAW_INVALIDATE: - if (destSurface == 21) { - invalidateRect(destSpriteX - spriteRight, destSpriteY - spriteBottom, // !! - destSpriteX + spriteRight, - destSpriteY + spriteBottom); + if (_destSurface == 21) { + invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !! + _destSpriteX + _spriteRight, + _destSpriteY + _spriteBottom); } break; case DRAW_LOADSPRITE: - id = spriteLeft; + id = _spriteLeft; if (id >= 30000) { dataBuf = - _vm->_game->loadExtData(id, &spriteRight, - &spriteBottom); - _vm->_video->drawPackedSprite((byte *)dataBuf, spriteRight, - spriteBottom, destSpriteX, - destSpriteY, transparency, - spritesArray[destSurface]); - if (destSurface == 21) { - invalidateRect(destSpriteX, - destSpriteY, - destSpriteX + spriteRight - 1, - destSpriteY + spriteBottom - 1); + _vm->_game->loadExtData(id, &_spriteRight, + &_spriteBottom); + _vm->_video->drawPackedSprite((byte *)dataBuf, _spriteRight, + _spriteBottom, _destSpriteX, + _destSpriteY, _transparency, + _spritesArray[_destSurface]); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, + _destSpriteY, + _destSpriteX + _spriteRight - 1, + _destSpriteY + _spriteBottom - 1); } free(dataBuf); break; } // Load from .TOT resources - itemPtr = &_vm->_game->totResourceTable->items[id]; + itemPtr = &_vm->_game->_totResourceTable->items[id]; offset = itemPtr->offset; if (offset >= 0) { dataBuf = - ((char *)_vm->_game->totResourceTable) + + ((char *)_vm->_game->_totResourceTable) + szGame_TotResTable + szGame_TotResItem * - _vm->_game->totResourceTable->itemsCount + offset; + _vm->_game->_totResourceTable->itemsCount + offset; } else { dataBuf = - _vm->_game->imFileData + - (int32)READ_LE_UINT32(&((int32 *)_vm->_game->imFileData)[-offset - 1]); + _vm->_game->_imFileData + + (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]); } - spriteRight = itemPtr->width; - spriteBottom = itemPtr->height; + _spriteRight = itemPtr->width; + _spriteBottom = itemPtr->height; _vm->_video->drawPackedSprite((byte *)dataBuf, - spriteRight, spriteBottom, - destSpriteX, destSpriteY, - transparency, spritesArray[destSurface]); - - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX + spriteRight - 1, - destSpriteY + spriteBottom - 1); + _spriteRight, _spriteBottom, + _destSpriteX, _destSpriteY, + _transparency, _spritesArray[_destSurface]); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX + _spriteRight - 1, + _destSpriteY + _spriteBottom - 1); } break; case DRAW_PRINTTEXT: - len = strlen(textToPrint); - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX + - len * fonts[fontIndex]->itemWidth - 1, - destSpriteY + - fonts[fontIndex]->itemHeight - 1); + len = strlen(_textToPrint); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX + + len * _fonts[_fontIndex]->itemWidth - 1, + _destSpriteY + + _fonts[_fontIndex]->itemHeight - 1); } for (i = 0; i < len; i++) { - _vm->_video->drawLetter(textToPrint[i], - destSpriteX, destSpriteY, - fonts[fontIndex], - transparency, - frontColor, backColor, - spritesArray[destSurface]); - - destSpriteX += fonts[fontIndex]->itemWidth; + _vm->_video->drawLetter(_textToPrint[i], + _destSpriteX, _destSpriteY, + _fonts[_fontIndex], + _transparency, + _frontColor, _backColor, + _spritesArray[_destSurface]); + + _destSpriteX += _fonts[_fontIndex]->itemWidth; } break; case DRAW_DRAWBAR: - _vm->_video->drawLine(spritesArray[destSurface], - destSpriteX, spriteBottom, - spriteRight, spriteBottom, frontColor); + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _spriteBottom, + _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(spritesArray[destSurface], - destSpriteX, destSpriteY, - destSpriteX, spriteBottom, frontColor); + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(spritesArray[destSurface], - spriteRight, destSpriteY, - spriteRight, spriteBottom, frontColor); + _vm->_video->drawLine(_spritesArray[_destSurface], + _spriteRight, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(spritesArray[destSurface], - destSpriteX, destSpriteY, - spriteRight, destSpriteY, frontColor); + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _destSpriteY, _frontColor); - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - spriteRight, spriteBottom); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); } break; case DRAW_CLEARRECT: - if (backColor < 16) { - _vm->_video->fillRect(spritesArray[destSurface], - destSpriteX, destSpriteY, - spriteRight, spriteBottom, - backColor); + if (_backColor < 16) { + _vm->_video->fillRect(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, + _backColor); } - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - spriteRight, spriteBottom); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); } break; case DRAW_FILLRECTABS: - _vm->_video->fillRect(spritesArray[destSurface], - destSpriteX, destSpriteY, - spriteRight, spriteBottom, backColor); + _vm->_video->fillRect(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _backColor); - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - spriteRight, spriteBottom); + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); } break; case DRAW_DRAWLETTER: - if (fontToSprite[fontIndex].sprite == -1) { - if (destSurface == 21) { - invalidateRect(destSpriteX, - destSpriteY, - destSpriteX + - fonts[fontIndex]->itemWidth - 1, - destSpriteY + - fonts[fontIndex]->itemHeight - + if (_fontToSprite[_fontIndex].sprite == -1) { + if (_destSurface == 21) { + invalidateRect(_destSpriteX, + _destSpriteY, + _destSpriteX + + _fonts[_fontIndex]->itemWidth - 1, + _destSpriteY + + _fonts[_fontIndex]->itemHeight - 1); } - _vm->_video->drawLetter(letterToPrint, - destSpriteX, destSpriteY, - fonts[fontIndex], - transparency, - frontColor, backColor, - spritesArray[destSurface]); + _vm->_video->drawLetter(_letterToPrint, + _destSpriteX, _destSpriteY, + _fonts[_fontIndex], + _transparency, + _frontColor, _backColor, + _spritesArray[_destSurface]); break; } perLine = - spritesArray[(int16)fontToSprite[fontIndex]. - sprite]->width / fontToSprite[fontIndex].width; - - y = (letterToPrint - - fontToSprite[fontIndex].base) / perLine * - fontToSprite[fontIndex].height; - - x = (letterToPrint - - fontToSprite[fontIndex].base) % perLine * - fontToSprite[fontIndex].width; - - if (destSurface == 21) { - invalidateRect(destSpriteX, destSpriteY, - destSpriteX + - fontToSprite[fontIndex].width, - destSpriteY + - fontToSprite[fontIndex].height); + _spritesArray[(int16)_fontToSprite[_fontIndex]. + sprite]->width / _fontToSprite[_fontIndex].width; + + y = (_letterToPrint - + _fontToSprite[_fontIndex].base) / perLine * + _fontToSprite[_fontIndex].height; + + x = (_letterToPrint - + _fontToSprite[_fontIndex].base) % perLine * + _fontToSprite[_fontIndex].width; + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _destSpriteX + + _fontToSprite[_fontIndex].width, + _destSpriteY + + _fontToSprite[_fontIndex].height); } - _vm->_video->drawSprite(spritesArray[(int16)fontToSprite - [fontIndex].sprite], - spritesArray[destSurface], x, y, - x + fontToSprite[fontIndex].width, - y + fontToSprite[fontIndex].height, - destSpriteX, destSpriteY, transparency); + _vm->_video->drawSprite(_spritesArray[(int16)_fontToSprite + [_fontIndex].sprite], + _spritesArray[_destSurface], x, y, + x + _fontToSprite[_fontIndex].width, + y + _fontToSprite[_fontIndex].height, + _destSpriteX, _destSpriteY, _transparency); break; } - if (renderFlags & RENDERFLAG_USEDELTAS) { - if (sourceSurface == 21) { - spriteLeft -= backDeltaX; - spriteTop -= backDeltaY; + if (_renderFlags & RENDERFLAG_USEDELTAS) { + if (_sourceSurface == 21) { + _spriteLeft -= _backDeltaX; + _spriteTop -= _backDeltaY; } - if (destSurface == 21) { - destSpriteX -= backDeltaX; - destSpriteY -= backDeltaY; + if (_destSurface == 21) { + _destSpriteX -= _backDeltaX; + _destSpriteY -= _backDeltaY; } } } @@ -599,7 +599,7 @@ void Draw::animateCursor(int16 cursor) { if (cursorIndex == -1) { cursorIndex = 0; - for (ptr = _vm->_game->collisionAreas; ptr->left != -1; ptr++) { + for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) { if (ptr->flags & 0xfff0) continue; @@ -621,81 +621,81 @@ void Draw::animateCursor(int16 cursor) { cursorIndex = 3; break; } - if (cursorAnimLow[cursorIndex] == -1) + if (_cursorAnimLow[cursorIndex] == -1) cursorIndex = 1; } - if (cursorAnimLow[cursorIndex] != -1) { - if (cursorIndex == gcursorIndex) { - if (cursorAnimDelays[gcursorIndex] != 0 && - cursorAnimDelays[gcursorIndex] * 10 + - cursorTimeKey <= _vm->_util->getTimeKey()) { - cursorAnim++; - cursorTimeKey = _vm->_util->getTimeKey(); + if (_cursorAnimLow[cursorIndex] != -1) { + if (cursorIndex == _cursorIndex) { + if (_cursorAnimDelays[_cursorIndex] != 0 && + _cursorAnimDelays[_cursorIndex] * 10 + + _cursorTimeKey <= _vm->_util->getTimeKey()) { + _cursorAnim++; + _cursorTimeKey = _vm->_util->getTimeKey(); } else { -/* if (noInvalidated && - inter_mouseX == cursorX && inter_mouseY == cursorY) +/* if (_noInvalidated && + inter_mouseX == _cursorX && inter_mouseY == _cursorY) return;*/ } } else { - gcursorIndex = cursorIndex; - if (cursorAnimDelays[gcursorIndex] != 0) { - cursorAnim = - cursorAnimLow[gcursorIndex]; - cursorTimeKey = _vm->_util->getTimeKey(); + _cursorIndex = cursorIndex; + if (_cursorAnimDelays[_cursorIndex] != 0) { + _cursorAnim = + _cursorAnimLow[_cursorIndex]; + _cursorTimeKey = _vm->_util->getTimeKey(); } else { - cursorAnim = gcursorIndex; + _cursorAnim = _cursorIndex; } } - if (cursorAnimDelays[gcursorIndex] != 0 && - (cursorAnimHigh[gcursorIndex] < cursorAnim || - cursorAnimLow[gcursorIndex] > - cursorAnim)) { - cursorAnim = cursorAnimLow[gcursorIndex]; + if (_cursorAnimDelays[_cursorIndex] != 0 && + (_cursorAnimHigh[_cursorIndex] < _cursorAnim || + _cursorAnimLow[_cursorIndex] > + _cursorAnim)) { + _cursorAnim = _cursorAnimLow[_cursorIndex]; } newX = _vm->_global->_inter_mouseX; newY = _vm->_global->_inter_mouseY; - if (cursorXDeltaVar != -1) { - newX -= (uint16)VAR_OFFSET(gcursorIndex * 4 + (cursorXDeltaVar / 4) * 4); - newY -= (uint16)VAR_OFFSET(gcursorIndex * 4 + (cursorYDeltaVar / 4) * 4); + if (_cursorXDeltaVar != -1) { + newX -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorXDeltaVar / 4) * 4); + newY -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorYDeltaVar / 4) * 4); } - minX = MIN(newX, cursorX); - minY = MIN(newY, cursorY); - maxX = MAX(cursorX, newX) + cursorWidth - 1; - maxY = MAX(cursorY, newY) + cursorHeight - 1; - _vm->_video->drawSprite(backSurface, cursorBack, - newX, newY, newX + cursorWidth - 1, - newY + cursorHeight - 1, 0, 0, 0); - - _vm->_video->drawSprite(cursorSprites, backSurface, - cursorWidth * cursorAnim, 0, - cursorWidth * (cursorAnim + 1) - 1, - cursorHeight - 1, newX, newY, transparentCursor); - - if (noInvalidated == 0) { - cursorIndex = gcursorIndex; - gcursorIndex = -1; + minX = MIN(newX, _cursorX); + minY = MIN(newY, _cursorY); + maxX = MAX(_cursorX, newX) + _cursorWidth - 1; + maxY = MAX(_cursorY, newY) + _cursorHeight - 1; + _vm->_video->drawSprite(_backSurface, _cursorBack, + newX, newY, newX + _cursorWidth - 1, + newY + _cursorHeight - 1, 0, 0, 0); + + _vm->_video->drawSprite(_cursorSprites, _backSurface, + _cursorWidth * _cursorAnim, 0, + _cursorWidth * (_cursorAnim + 1) - 1, + _cursorHeight - 1, newX, newY, _transparentCursor); + + if (_noInvalidated == 0) { + cursorIndex = _cursorIndex; + _cursorIndex = -1; blitInvalidated(); - gcursorIndex = cursorIndex; + _cursorIndex = cursorIndex; } else { _vm->_video->waitRetrace(_vm->_global->_videoMode); } - _vm->_video->drawSprite(backSurface, frontSurface, + _vm->_video->drawSprite(_backSurface, _frontSurface, minX, minY, maxX, maxY, minX, minY, 0); - _vm->_video->drawSprite(cursorBack, backSurface, - 0, 0, cursorWidth - 1, cursorHeight - 1, + _vm->_video->drawSprite(_cursorBack, _backSurface, + 0, 0, _cursorWidth - 1, _cursorHeight - 1, newX, newY, 0); } else { blitCursor(); } - cursorX = newX; - cursorY = newY; + _cursorX = newX; + _cursorY = newY; } void Draw::interPalLoad(void) { @@ -706,21 +706,21 @@ void Draw::interPalLoad(void) { char *palPtr; cmd = *_vm->_global->_inter_execPtr++; - applyPal = 0; + _applyPal = 0; if (cmd & 0x80) cmd &= 0x7f; else - applyPal = 1; + _applyPal = 1; if (cmd == 49) { warning("inter_palLoad: cmd == 49 is not supported"); //var_B = 1; for (i = 0; i < 18; i++, _vm->_global->_inter_execPtr++) { if (i < 2) { - if (applyPal == 0) + if (_applyPal == 0) continue; - unusedPalette1[i] = *_vm->_global->_inter_execPtr; + _unusedPalette1[i] = *_vm->_global->_inter_execPtr; continue; } //if (*inter_execPtr != 0) @@ -729,45 +729,45 @@ void Draw::interPalLoad(void) { ind1 = *_vm->_global->_inter_execPtr >> 4; ind2 = (*_vm->_global->_inter_execPtr & 0xf); - unusedPalette1[i] = - ((palLoadData1[ind1] + palLoadData2[ind2]) << 8) + - (palLoadData2[ind1] + palLoadData1[ind2]); + _unusedPalette1[i] = + ((_palLoadData1[ind1] + _palLoadData2[ind2]) << 8) + + (_palLoadData2[ind1] + _palLoadData1[ind2]); } - _vm->_global->_pPaletteDesc->unused1 = unusedPalette1; + _vm->_global->_pPaletteDesc->unused1 = _unusedPalette1; } switch (cmd) { case 52: for (i = 0; i < 16; i++, _vm->_global->_inter_execPtr += 3) { - vgaSmallPalette[i].red = _vm->_global->_inter_execPtr[0]; - vgaSmallPalette[i].green = _vm->_global->_inter_execPtr[1]; - vgaSmallPalette[i].blue = _vm->_global->_inter_execPtr[2]; + _vgaSmallPalette[i].red = _vm->_global->_inter_execPtr[0]; + _vgaSmallPalette[i].green = _vm->_global->_inter_execPtr[1]; + _vgaSmallPalette[i].blue = _vm->_global->_inter_execPtr[2]; } break; case 50: for (i = 0; i < 16; i++, _vm->_global->_inter_execPtr++) - unusedPalette2[i] = *_vm->_global->_inter_execPtr; + _unusedPalette2[i] = *_vm->_global->_inter_execPtr; break; case 53: palPtr = _vm->_game->loadTotResource(_vm->_inter->load16()); - memcpy((char *)vgaPalette, palPtr, 768); + memcpy((char *)_vgaPalette, palPtr, 768); break; case 54: - memset((char *)vgaPalette, 0, 768); + memset((char *)_vgaPalette, 0, 768); break; } - if (!applyPal) { - _vm->_global->_pPaletteDesc->unused2 = unusedPalette2; - _vm->_global->_pPaletteDesc->unused1 = unusedPalette1; + if (!_applyPal) { + _vm->_global->_pPaletteDesc->unused2 = _unusedPalette2; + _vm->_global->_pPaletteDesc->unused1 = _unusedPalette1; if (_vm->_global->_videoMode != 0x13) - _vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)vgaSmallPalette; + _vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)_vgaSmallPalette; else - _vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)vgaPalette; + _vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)_vgaPalette; _vm->_palanim->fade((Video::PalDesc *) _vm->_global->_pPaletteDesc, 0, 0); } @@ -790,54 +790,54 @@ void Draw::printText(void) { _vm->_cdrom->playMultMusic(); - dataPtr = (char *)_vm->_game->totTextData + _vm->_game->totTextData->items[index].offset; + dataPtr = (char *)_vm->_game->_totTextData + _vm->_game->_totTextData->items[index].offset; ptr = dataPtr; - if (renderFlags & RENDERFLAG_CAPTUREPUSH) { - destSpriteX = READ_LE_UINT16(ptr); - destSpriteY = READ_LE_UINT16(ptr + 2); - spriteRight = READ_LE_UINT16(ptr + 4) - destSpriteX + 1; - spriteBottom = READ_LE_UINT16(ptr + 6) - destSpriteY + 1; - _vm->_game->capturePush(destSpriteX, destSpriteY, - spriteRight, spriteBottom); + if (_renderFlags & RENDERFLAG_CAPTUREPUSH) { + _destSpriteX = READ_LE_UINT16(ptr); + _destSpriteY = READ_LE_UINT16(ptr + 2); + _spriteRight = READ_LE_UINT16(ptr + 4) - _destSpriteX + 1; + _spriteBottom = READ_LE_UINT16(ptr + 6) - _destSpriteY + 1; + _vm->_game->capturePush(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); (*_vm->_scenery->pCaptureCounter)++; } - destSpriteX = READ_LE_UINT16(ptr); - destX = destSpriteX; + _destSpriteX = READ_LE_UINT16(ptr); + destX = _destSpriteX; - destSpriteY = READ_LE_UINT16(ptr + 2); - destY = destSpriteY; + _destSpriteY = READ_LE_UINT16(ptr + 2); + destY = _destSpriteY; - spriteRight = READ_LE_UINT16(ptr + 4); - spriteBottom = READ_LE_UINT16(ptr + 6); - destSurface = 21; + _spriteRight = READ_LE_UINT16(ptr + 4); + _spriteBottom = READ_LE_UINT16(ptr + 6); + _destSurface = 21; ptr += 8; - backColor = *ptr++; - transparency = 1; + _backColor = *ptr++; + _transparency = 1; spriteOperation(DRAW_CLEARRECT); - backColor = 0; - savedFlags = renderFlags; + _backColor = 0; + savedFlags = _renderFlags; - renderFlags &= ~RENDERFLAG_NOINVALIDATE; - for (; (destSpriteX = READ_LE_UINT16(ptr)) != -1; ptr++) { - destSpriteX += destX; - destSpriteY = READ_LE_UINT16(ptr + 2) + destY; - spriteRight = READ_LE_UINT16(ptr + 4) + destX; - spriteBottom = READ_LE_UINT16(ptr + 6) + destY; + _renderFlags &= ~RENDERFLAG_NOINVALIDATE; + for (; (_destSpriteX = READ_LE_UINT16(ptr)) != -1; ptr++) { + _destSpriteX += destX; + _destSpriteY = READ_LE_UINT16(ptr + 2) + destY; + _spriteRight = READ_LE_UINT16(ptr + 4) + destX; + _spriteBottom = READ_LE_UINT16(ptr + 6) + destY; ptr += 8; cmd = (*ptr & 0xf0) >> 4; if (cmd == 0) { - frontColor = *ptr & 0xf; + _frontColor = *ptr & 0xf; spriteOperation(DRAW_DRAWLINE); } else if (cmd == 1) { - frontColor = *ptr & 0xf; + _frontColor = *ptr & 0xf; spriteOperation(DRAW_DRAWBAR); } else if (cmd == 2) { - backColor = *ptr & 0xf; + _backColor = *ptr & 0xf; spriteOperation(DRAW_FILLRECTABS); } } @@ -857,23 +857,23 @@ void Draw::printText(void) { cmd = *ptr; if (cmd == 3) { ptr++; - fontIndex = (*ptr & 0xf0) >> 4; - frontColor = *ptr & 0xf; + _fontIndex = (*ptr & 0xf0) >> 4; + _frontColor = *ptr & 0xf; ptr++; continue; } else if (cmd == 2) { ptr++; - destSpriteX = destX + READ_LE_UINT16(ptr); - destSpriteY = destY + READ_LE_UINT16(ptr + 2); + _destSpriteX = destX + READ_LE_UINT16(ptr); + _destSpriteY = destY + READ_LE_UINT16(ptr + 2); ptr += 4; continue; } if ((byte)*ptr != 0xba) { - letterToPrint = *ptr; + _letterToPrint = *ptr; spriteOperation(DRAW_DRAWLETTER); - destSpriteX += - fonts[fontIndex]->itemWidth; + _destSpriteX += + _fonts[_fontIndex]->itemWidth; ptr++; } else { cmd = ptr2[17] & 0x7f; @@ -901,32 +901,32 @@ void Draw::printText(void) { _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]); } - textToPrint = buf; - ldestSpriteX = destSpriteX; + _textToPrint = buf; + ldestSpriteX = _destSpriteX; spriteOperation(DRAW_PRINTTEXT); if (ptr2[17] & 0x80) { if (ptr[1] == ' ') { - destSpriteX += fonts[fontIndex]->itemWidth; + _destSpriteX += _fonts[_fontIndex]->itemWidth; while (ptr[1] == ' ') ptr++; if (ptr[1] == 2) { - if (READ_LE_UINT16(ptr + 4) == destSpriteY) + if (READ_LE_UINT16(ptr + 4) == _destSpriteY) ptr += 5; } - } else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == destSpriteY) { + } else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == _destSpriteY) { ptr += 5; - destSpriteX += fonts[fontIndex]->itemWidth; + _destSpriteX += _fonts[_fontIndex]->itemWidth; } } else { - destSpriteX = ldestSpriteX + fonts[fontIndex]->itemWidth; + _destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth; } ptr2 += 23; ptr++; } } - renderFlags = savedFlags; - if (renderFlags & 4) { + _renderFlags = savedFlags; + if (_renderFlags & 4) { warning("printText: Input not supported!"); // xor ax, ax // loc_436_1391: @@ -942,7 +942,7 @@ void Draw::printText(void) { // add sp, 0Ch } - if ((renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->pCaptureCounter != 0) { + if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->pCaptureCounter != 0) { (*_vm->_scenery->pCaptureCounter)--; _vm->_game->capturePop(1); } diff --git a/gob/draw.h b/gob/draw.h index ac0c68542f..087217044e 100644 --- a/gob/draw.h +++ b/gob/draw.h @@ -41,67 +41,67 @@ public: FontToSprite() : sprite(0), base(0), width(0), height() {} } FontToSprite; - int16 fontIndex; - int16 spriteLeft; - int16 spriteTop; - int16 spriteRight; - int16 spriteBottom; - int16 destSpriteX; - int16 destSpriteY; - int16 backColor; - int16 frontColor; - char letterToPrint; - FontToSprite fontToSprite[4]; - int16 destSurface; - int16 sourceSurface; - int16 renderFlags; - int16 backDeltaX; - int16 backDeltaY; - Video::FontDesc *fonts[4]; - char *textToPrint; - int16 transparency; - Video::SurfaceDesc *spritesArray[50]; - - int16 invalidatedCount; - int16 invalidatedTops[30]; - int16 invalidatedLefts[30]; - int16 invalidatedRights[30]; - int16 invalidatedBottoms[30]; - - int8 noInvalidated; + int16 _fontIndex; + int16 _spriteLeft; + int16 _spriteTop; + int16 _spriteRight; + int16 _spriteBottom; + int16 _destSpriteX; + int16 _destSpriteY; + int16 _backColor; + int16 _frontColor; + char _letterToPrint; + FontToSprite _fontToSprite[4]; + int16 _destSurface; + int16 _sourceSurface; + int16 _renderFlags; + int16 _backDeltaX; + int16 _backDeltaY; + Video::FontDesc *_fonts[4]; + char *_textToPrint; + int16 _transparency; + Video::SurfaceDesc *_spritesArray[50]; + + int16 _invalidatedCount; + int16 _invalidatedTops[30]; + int16 _invalidatedLefts[30]; + int16 _invalidatedRights[30]; + int16 _invalidatedBottoms[30]; + + int8 _noInvalidated; // int8 doFullFlip; // Never used?!? - int8 paletteCleared; - - int16 gcursorIndex; - int16 transparentCursor; - uint32 cursorTimeKey; - - Video::SurfaceDesc *backSurface; - Video::SurfaceDesc *frontSurface; - - int16 unusedPalette1[18]; - int16 unusedPalette2[16]; - Video::Color vgaPalette[256]; - Video::Color vgaSmallPalette[16]; - - int16 cursorX; - int16 cursorY; - int16 cursorWidth; - int16 cursorHeight; - - int16 cursorXDeltaVar; - int16 cursorYDeltaVar; - - Video::SurfaceDesc *cursorSprites; - Video::SurfaceDesc *cursorBack; - int16 cursorAnim; - int8 cursorAnimLow[40]; - int8 cursorAnimHigh[40]; - int8 cursorAnimDelays[40]; - int8 applyPal; - - int16 palLoadData1[4]; - int16 palLoadData2[4]; + int8 _paletteCleared; + + int16 _cursorIndex; + int16 _transparentCursor; + uint32 _cursorTimeKey; + + Video::SurfaceDesc *_backSurface; + Video::SurfaceDesc *_frontSurface; + + int16 _unusedPalette1[18]; + int16 _unusedPalette2[16]; + Video::Color _vgaPalette[256]; + Video::Color _vgaSmallPalette[16]; + + int16 _cursorX; + int16 _cursorY; + int16 _cursorWidth; + int16 _cursorHeight; + + int16 _cursorXDeltaVar; + int16 _cursorYDeltaVar; + + Video::SurfaceDesc *_cursorSprites; + Video::SurfaceDesc *_cursorBack; + int16 _cursorAnim; + int8 _cursorAnimLow[40]; + int8 _cursorAnimHigh[40]; + int8 _cursorAnimDelays[40]; + int8 _applyPal; + + int16 _palLoadData1[4]; + int16 _palLoadData2[4]; void invalidateRect(int16 left, int16 top, int16 right, int16 bottom); void blitInvalidated(void); diff --git a/gob/game.cpp b/gob/game.cpp index b1d2c5d5d4..6718c96703 100644 --- a/gob/game.cpp +++ b/gob/game.cpp @@ -36,49 +36,49 @@ namespace Gob { -int16 Game::captureCount = 0; -Common::Rect Game::captureStack[20]; +int16 Game::_captureCount = 0; +Common::Rect Game::_captureStack[20]; Game::Game(GobEngine *vm) : _vm(vm) { - extTable = 0; - totFileData = 0; - totResourceTable = 0; - imFileData = 0; - extHandle = 0; - collisionAreas = 0; - shouldPushColls = 0; - totTextData = 0; + _extTable = 0; + _totFileData = 0; + _totResourceTable = 0; + _imFileData = 0; + _extHandle = 0; + _collisionAreas = 0; + _shouldPushColls = 0; + _totTextData = 0; // Collisions stack - collStackSize = 0; + _collStackSize = 0; for (int i = 0; i < 3; i++) { - collStack[i] = 0; - collStackElemSizes[i] = 0; + _collStack[i] = 0; + _collStackElemSizes[i] = 0; } for (int i = 0; i < 20; i++) - soundSamples[i] = 0; + _soundSamples[i] = 0; - curTotFile[0] = 0; - curExtFile[0] = 0; - totToLoad[0] = 0; + _curTotFile[0] = 0; + _curExtFile[0] = 0; + _totToLoad[0] = 0; - startTimeKey = 0; - mouseButtons = 0; + _startTimeKey = 0; + _mouseButtons = 0; - lastCollKey = 0; - lastCollAreaIndex = 0; - lastCollId = 0; + _lastCollKey = 0; + _lastCollAreaIndex = 0; + _lastCollId = 0; - activeCollResId = 0; - activeCollIndex = 0; - ghandleMouse = 0; - forceHandleMouse = 0; + _activeCollResId = 0; + _activeCollIndex = 0; + _handleMouse = 0; + _forceHandleMouse = 0; - tempStr[0] = 0; - curImaFile[0] = 0; - soundFromExt[0] = 0; - collStr[0] = 0; + _tempStr[0] = 0; + _curImaFile[0] = 0; + _soundFromExt[0] = 0; + _collStr[0] = 0; // Capture @@ -99,12 +99,12 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { char *dataPtr; itemId -= 30000; - if (extTable == 0) + if (_extTable == 0) return 0; commonHandle = -1; - itemsCount = extTable->itemsCount; - item = &extTable->items[itemId]; + itemsCount = _extTable->itemsCount; + item = &_extTable->items[itemId]; tableSize = szGame_ExtTable + szGame_ExtItem * itemsCount; offset = item->offset; @@ -127,13 +127,13 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { debug(7, "size: %d off: %d", size, offset); if (offset >= 0) { - handle = extHandle; + handle = _extHandle; } else { offset = -(offset + 1); tableSize = 0; - _vm->_dataio->closeData(extHandle); + _vm->_dataio->closeData(_extHandle); strcpy(path, "commun.ex1"); - path[strlen(path) - 1] = *(totFileData + 0x3c) + '0'; + path[strlen(path) - 1] = *(_totFileData + 0x3c) + '0'; commonHandle = _vm->_dataio->openData(path); handle = commonHandle; } @@ -155,7 +155,7 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { _vm->_dataio->readData(handle, (char *)dataPtr, size); if (commonHandle != -1) { _vm->_dataio->closeData(commonHandle); - extHandle = _vm->_dataio->openData(curExtFile); + _extHandle = _vm->_dataio->openData(_curExtFile); } if (isPacked != 0) { @@ -172,8 +172,8 @@ char *Game::loadExtData(int16 itemId, int16 *pResWidth, int16 *pResHeight) { void Game::clearCollisions() { int16 i; for (i = 0; i < 250; i++) { - collisionAreas[i].id = 0; - collisionAreas[i].left = -1; + _collisionAreas[i].id = 0; + _collisionAreas[i].left = -1; } } @@ -189,10 +189,10 @@ void Game::addNewCollision(int16 id, int16 left, int16 top, int16 right, int16 b debug(5, "funcEnter = %d, funcLeave = %d", funcEnter, funcLeave); for (i = 0; i < 250; i++) { - if (collisionAreas[i].left != -1) + if (_collisionAreas[i].left != -1) continue; - ptr = &collisionAreas[i]; + ptr = &_collisionAreas[i]; ptr->id = id; ptr->left = left; ptr->top = top; @@ -211,8 +211,8 @@ void Game::freeCollision(int16 id) { int16 i; for (i = 0; i < 250; i++) { - if (collisionAreas[i].id == id) - collisionAreas[i].left = -1; + if (_collisionAreas[i].id == id) + _collisionAreas[i].left = -1; } } @@ -222,18 +222,18 @@ void Game::pushCollisions(char all) { int16 size; debug(4, "pushCollisions"); - for (size = 0, srcPtr = collisionAreas; srcPtr->left != -1; + for (size = 0, srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) { if (all || (srcPtr->id & 0x8000)) size++; } destPtr = (Collision *)malloc(size * sizeof(Collision)); - collStack[collStackSize] = destPtr; - collStackElemSizes[collStackSize] = size; - collStackSize++; + _collStack[_collStackSize] = destPtr; + _collStackElemSizes[_collStackSize] = size; + _collStackSize++; - for (srcPtr = collisionAreas; srcPtr->left != -1; srcPtr++) { + for (srcPtr = _collisionAreas; srcPtr->left != -1; srcPtr++) { if (all || (srcPtr->id & 0x8000)) { memcpy(destPtr, srcPtr, sizeof(Collision)); srcPtr->left = -1; @@ -248,15 +248,15 @@ void Game::popCollisions(void) { debug(4, "popCollision"); - collStackSize--; - for (destPtr = collisionAreas; destPtr->left != -1; destPtr++); + _collStackSize--; + for (destPtr = _collisionAreas; destPtr->left != -1; destPtr++); - srcPtr = collStack[collStackSize]; + srcPtr = _collStack[_collStackSize]; memcpy(destPtr, srcPtr, - collStackElemSizes[collStackSize] * + _collStackElemSizes[_collStackSize] * sizeof(Collision)); - free(collStack[collStackSize]); + free(_collStack[_collStackSize]); } int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { @@ -268,7 +268,7 @@ int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { *resIndex = 0; - ptr = collisionAreas; + ptr = _collisionAreas; for (i = 0; ptr->left != -1; ptr++, i++) { if (all) { if ((ptr->flags & 0xf) > 1) @@ -295,7 +295,7 @@ int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { if ((ptr->flags & 0xf) != 1 && (ptr->flags & 0xf) != 2) continue; - if ((ptr->flags & 0xf0) >> 4 != mouseButtons - 1 + if ((ptr->flags & 0xf0) >> 4 != _mouseButtons - 1 && (ptr->flags & 0xf0) >> 4 != 2) continue; @@ -312,7 +312,7 @@ int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { } } - if (mouseButtons != 1 && all == 0) + if (_mouseButtons != 1 && all == 0) return 0x11b; return 0; @@ -321,70 +321,70 @@ int16 Game::checkMousePoint(int16 all, int16 *resId, int16 *resIndex) { void Game::capturePush(int16 left, int16 top, int16 width, int16 height) { int16 right; - if (captureCount == 20) + if (_captureCount == 20) error("capturePush: Capture stack overflow!"); - captureStack[captureCount].left = left; - captureStack[captureCount].top = top; - captureStack[captureCount].right = left + width; - captureStack[captureCount].bottom = top + height; + _captureStack[_captureCount].left = left; + _captureStack[_captureCount].top = top; + _captureStack[_captureCount].right = left + width; + _captureStack[_captureCount].bottom = top + height; - _vm->_draw->spriteTop = top; - _vm->_draw->spriteBottom = height; + _vm->_draw->_spriteTop = top; + _vm->_draw->_spriteBottom = height; right = left + width - 1; left &= 0xfff0; right |= 0xf; - _vm->_draw->spritesArray[30 + captureCount] = + _vm->_draw->_spritesArray[30 + _captureCount] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, right - left + 1, height, 0); - _vm->_draw->sourceSurface = 21; - _vm->_draw->destSurface = 30 + captureCount; + _vm->_draw->_sourceSurface = 21; + _vm->_draw->_destSurface = 30 + _captureCount; - _vm->_draw->spriteLeft = left; - _vm->_draw->spriteRight = right - left + 1; - _vm->_draw->destSpriteX = 0; - _vm->_draw->destSpriteY = 0; - _vm->_draw->transparency = 0; + _vm->_draw->_spriteLeft = left; + _vm->_draw->_spriteRight = right - left + 1; + _vm->_draw->_destSpriteX = 0; + _vm->_draw->_destSpriteY = 0; + _vm->_draw->_transparency = 0; _vm->_draw->spriteOperation(0); - captureCount++; + _captureCount++; } void Game::capturePop(char doDraw) { - if (captureCount <= 0) + if (_captureCount <= 0) return; - captureCount--; + _captureCount--; if (doDraw) { - _vm->_draw->destSpriteX = captureStack[captureCount].left; - _vm->_draw->destSpriteY = captureStack[captureCount].top; - _vm->_draw->spriteRight = - captureStack[captureCount].width(); - _vm->_draw->spriteBottom = - captureStack[captureCount].height(); - - _vm->_draw->transparency = 0; - _vm->_draw->sourceSurface = 30 + captureCount; - _vm->_draw->destSurface = 21; - _vm->_draw->spriteLeft = _vm->_draw->destSpriteX & 0xf; - _vm->_draw->spriteTop = 0; + _vm->_draw->_destSpriteX = _captureStack[_captureCount].left; + _vm->_draw->_destSpriteY = _captureStack[_captureCount].top; + _vm->_draw->_spriteRight = + _captureStack[_captureCount].width(); + _vm->_draw->_spriteBottom = + _captureStack[_captureCount].height(); + + _vm->_draw->_transparency = 0; + _vm->_draw->_sourceSurface = 30 + _captureCount; + _vm->_draw->_destSurface = 21; + _vm->_draw->_spriteLeft = _vm->_draw->_destSpriteX & 0xf; + _vm->_draw->_spriteTop = 0; _vm->_draw->spriteOperation(0); } - _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[30 + captureCount]); + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[30 + _captureCount]); } char *Game::loadTotResource(int16 id) { TotResItem *itemPtr; int32 offset; - itemPtr = &totResourceTable->items[id]; + itemPtr = &_totResourceTable->items[id]; offset = itemPtr->offset; if (offset >= 0) { - return ((char *)totResourceTable) + szGame_TotResTable + - szGame_TotResItem * totResourceTable->itemsCount + offset; + return ((char *)_totResourceTable) + szGame_TotResTable + + szGame_TotResItem * _totResourceTable->itemsCount + offset; } else { - return (char *)(imFileData + (int32)READ_LE_UINT32(&((int32 *)imFileData)[-offset - 1])); + return (char *)(_imFileData + (int32)READ_LE_UINT32(&((int32 *)_imFileData)[-offset - 1])); } } @@ -393,7 +393,7 @@ void Game::loadSound(int16 slot, char *dataPtr) { soundDesc = (Snd::SoundDesc *)malloc(sizeof(Snd::SoundDesc)); - soundSamples[slot] = soundDesc; + _soundSamples[slot] = soundDesc; soundDesc->frequency = (dataPtr[4] << 8) + dataPtr[5]; soundDesc->size = (dataPtr[1] << 16) + (dataPtr[2] << 8) + dataPtr[3]; @@ -419,10 +419,10 @@ void Game::interLoadSound(int16 slot) { if (id >= 30000) { dataPtr = loadExtData(id, 0, 0); - soundFromExt[slot] = 1; + _soundFromExt[slot] = 1; } else { dataPtr = loadTotResource(id); - soundFromExt[slot] = 0; + _soundFromExt[slot] = 0; } loadSound(slot, dataPtr); @@ -432,16 +432,16 @@ void Game::freeSoundSlot(int16 slot) { if (slot == -1) slot = _vm->_parse->parseValExpr(); - if (soundSamples[slot] == 0) + if (_soundSamples[slot] == 0) return; - if (soundFromExt[slot] == 1) { - free(soundSamples[slot]->data - 6); - soundFromExt[slot] = 0; + if (_soundFromExt[slot] == 1) { + free(_soundSamples[slot]->data - 6); + _soundFromExt[slot] = 0; } - free(soundSamples[slot]); - soundSamples[slot] = 0; + free(_soundSamples[slot]); + _soundSamples[slot] = 0; } int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY, int16 *pButtons, char handleMouse) { @@ -484,9 +484,9 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, uint32 timeKey; if (deltaTime >= -1) { - lastCollKey = 0; - lastCollAreaIndex = 0; - lastCollId = 0; + _lastCollKey = 0; + _lastCollAreaIndex = 0; + _lastCollId = 0; } if (pResId != 0) @@ -494,16 +494,16 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, resIndex = 0; - if (_vm->_draw->gcursorIndex == -1 && handleMouse != 0 - && lastCollKey == 0) { - lastCollKey = - checkMousePoint(1, &lastCollId, - &lastCollAreaIndex); + if (_vm->_draw->_cursorIndex == -1 && handleMouse != 0 + && _lastCollKey == 0) { + _lastCollKey = + checkMousePoint(1, &_lastCollId, + &_lastCollAreaIndex); - if (lastCollKey != 0 && (lastCollId & 0x8000) != 0) { + if (_lastCollKey != 0 && (_lastCollId & 0x8000) != 0) { savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcEnter; + _vm->_global->_inter_execPtr = (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcEnter; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; @@ -521,7 +521,7 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, return 0; } - if (_vm->_draw->noInvalidated == 0) { + if (_vm->_draw->_noInvalidated == 0) { if (handleMouse) _vm->_draw->animateCursor(-1); else @@ -548,9 +548,9 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, } key = checkKeys(&_vm->_global->_inter_mouseX, &_vm->_global->_inter_mouseY, - &mouseButtons, handleMouse); + &_mouseButtons, handleMouse); - if (handleMouse == 0 && mouseButtons != 0) { + if (handleMouse == 0 && _mouseButtons != 0) { _vm->_util->waitMouseRelease(0); key = 3; } @@ -566,23 +566,23 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, if (pResIndex != 0) *pResIndex = 0; - if (lastCollKey != 0 && - collisionAreas[lastCollAreaIndex].funcLeave != 0) { + if (_lastCollKey != 0 && + _collisionAreas[_lastCollAreaIndex].funcLeave != 0) { savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcLeave; + _vm->_global->_inter_execPtr = (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcLeave; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; } - lastCollKey = 0; + _lastCollKey = 0; if (key != 0) return key; } if (handleMouse != 0) { - if (mouseButtons != 0) { + if (_mouseButtons != 0) { oldIndex = 0; _vm->_draw->animateCursor(2); @@ -604,44 +604,44 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, if (key != 0 || (pResId != 0 && *pResId != 0)) { if (handleMouse == 1 && (deltaTime <= 0 - || mouseButtons == 0)) + || _mouseButtons == 0)) _vm->_draw->blitCursor(); - if (lastCollKey != 0 && - collisionAreas[lastCollAreaIndex].funcLeave != 0) { + if (_lastCollKey != 0 && + _collisionAreas[_lastCollAreaIndex].funcLeave != 0) { savedIP = _vm->_global->_inter_execPtr; _vm->_global->_inter_execPtr = - (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcLeave; + (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcLeave; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; } - lastCollKey = 0; + _lastCollKey = 0; return key; } - if (lastCollKey != 0 && - collisionAreas[lastCollAreaIndex].funcLeave != 0) { + if (_lastCollKey != 0 && + _collisionAreas[_lastCollAreaIndex].funcLeave != 0) { savedIP = _vm->_global->_inter_execPtr; _vm->_global->_inter_execPtr = - (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcLeave; + (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcLeave; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; } - lastCollKey = - checkMousePoint(1, &lastCollId, - &lastCollAreaIndex); + _lastCollKey = + checkMousePoint(1, &_lastCollId, + &_lastCollAreaIndex); - if (lastCollKey != 0 - && (lastCollId & 0x8000) != 0) { + if (_lastCollKey != 0 + && (_lastCollId & 0x8000) != 0) { savedIP = _vm->_global->_inter_execPtr; _vm->_global->_inter_execPtr = - (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcEnter; + (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcEnter; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; @@ -649,32 +649,32 @@ int16 Game::checkCollisions(char handleMouse, int16 deltaTime, int16 *pResId, } else { if (handleMouse != 0 && - (_vm->_global->_inter_mouseX != _vm->_draw->cursorX - || _vm->_global->_inter_mouseY != _vm->_draw->cursorY)) { - oldIndex = lastCollAreaIndex; - oldId = lastCollId; + (_vm->_global->_inter_mouseX != _vm->_draw->_cursorX + || _vm->_global->_inter_mouseY != _vm->_draw->_cursorY)) { + oldIndex = _lastCollAreaIndex; + oldId = _lastCollId; key = checkMousePoint(1, - &lastCollId, - &lastCollAreaIndex); + &_lastCollId, + &_lastCollAreaIndex); - if (key != lastCollKey) { - if (lastCollKey != 0 + if (key != _lastCollKey) { + if (_lastCollKey != 0 && (oldId & 0x8000) != 0) { savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + - collisionAreas[oldIndex].funcLeave; + _vm->_global->_inter_execPtr = (char *)_totFileData + + _collisionAreas[oldIndex].funcLeave; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; } - lastCollKey = key; - if (lastCollKey != 0 && (lastCollId & 0x8000) != 0) { + _lastCollKey = key; + if (_lastCollKey != 0 && (_lastCollId & 0x8000) != 0) { savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + - collisionAreas[lastCollAreaIndex].funcEnter; + _vm->_global->_inter_execPtr = (char *)_totFileData + + _collisionAreas[_lastCollAreaIndex].funcEnter; _vm->_inter->funcBlock(0); _vm->_global->_inter_execPtr = savedIP; @@ -707,115 +707,115 @@ int16 Game::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, int16 b int16 flag; int16 savedKey; - if (ghandleMouse != 0 && - (_vm->_global->_useMouse != 0 || forceHandleMouse != 0)) + if (_handleMouse != 0 && + (_vm->_global->_useMouse != 0 || _forceHandleMouse != 0)) handleMouse = 1; else handleMouse = 0; pos = strlen(str); - pFont = _vm->_draw->fonts[fontIndex]; + pFont = _vm->_draw->_fonts[fontIndex]; editSize = width / pFont->itemWidth; while (1) { - strcpy(tempStr, str); - strcat(tempStr, " "); - if (strlen(tempStr) > editSize) - strcpy(tempStr, str); - - _vm->_draw->destSpriteX = xPos; - _vm->_draw->destSpriteY = yPos; - _vm->_draw->spriteRight = editSize * pFont->itemWidth; - _vm->_draw->spriteBottom = height; - - _vm->_draw->destSurface = 21; - _vm->_draw->backColor = backColor; - _vm->_draw->frontColor = frontColor; - _vm->_draw->textToPrint = tempStr; - _vm->_draw->transparency = 1; - _vm->_draw->fontIndex = fontIndex; + strcpy(_tempStr, str); + strcat(_tempStr, " "); + if (strlen(_tempStr) > editSize) + strcpy(_tempStr, str); + + _vm->_draw->_destSpriteX = xPos; + _vm->_draw->_destSpriteY = yPos; + _vm->_draw->_spriteRight = editSize * pFont->itemWidth; + _vm->_draw->_spriteBottom = height; + + _vm->_draw->_destSurface = 21; + _vm->_draw->_backColor = backColor; + _vm->_draw->_frontColor = frontColor; + _vm->_draw->_textToPrint = _tempStr; + _vm->_draw->_transparency = 1; + _vm->_draw->_fontIndex = fontIndex; _vm->_draw->spriteOperation(DRAW_FILLRECT); - _vm->_draw->destSpriteY = yPos + (height - 8) / 2; + _vm->_draw->_destSpriteY = yPos + (height - 8) / 2; _vm->_draw->spriteOperation(DRAW_PRINTTEXT); if (pos == editSize) pos--; - curSym = tempStr[pos]; + curSym = _tempStr[pos]; flag = 1; while (1) { - tempStr[0] = curSym; - tempStr[1] = 0; - - _vm->_draw->destSpriteX = xPos + pFont->itemWidth * pos; - _vm->_draw->destSpriteY = yPos + height - 1; - _vm->_draw->spriteRight = pFont->itemWidth; - _vm->_draw->spriteBottom = 1; - _vm->_draw->destSurface = 21; - _vm->_draw->backColor = frontColor; + _tempStr[0] = curSym; + _tempStr[1] = 0; + + _vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos; + _vm->_draw->_destSpriteY = yPos + height - 1; + _vm->_draw->_spriteRight = pFont->itemWidth; + _vm->_draw->_spriteBottom = 1; + _vm->_draw->_destSurface = 21; + _vm->_draw->_backColor = frontColor; _vm->_draw->spriteOperation(DRAW_FILLRECT); if (flag != 0) { key = checkCollisions(handleMouse, -1, - &activeCollResId, - &activeCollIndex); + &_activeCollResId, + &_activeCollIndex); } flag = 0; key = checkCollisions(handleMouse, -300, - &activeCollResId, &activeCollIndex); + &_activeCollResId, &_activeCollIndex); if (*pTotTime > 0) { *pTotTime -= 300; if (*pTotTime <= 1) { key = 0; - activeCollResId = 0; + _activeCollResId = 0; break; } } - tempStr[0] = curSym; - tempStr[1] = 0; - _vm->_draw->destSpriteX = xPos + pFont->itemWidth * pos; - _vm->_draw->destSpriteY = yPos + height - 1; - _vm->_draw->spriteRight = pFont->itemWidth; - _vm->_draw->spriteBottom = 1; - _vm->_draw->destSurface = 21; - _vm->_draw->backColor = backColor; - _vm->_draw->frontColor = frontColor; - _vm->_draw->textToPrint = tempStr; - _vm->_draw->transparency = 1; + _tempStr[0] = curSym; + _tempStr[1] = 0; + _vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos; + _vm->_draw->_destSpriteY = yPos + height - 1; + _vm->_draw->_spriteRight = pFont->itemWidth; + _vm->_draw->_spriteBottom = 1; + _vm->_draw->_destSurface = 21; + _vm->_draw->_backColor = backColor; + _vm->_draw->_frontColor = frontColor; + _vm->_draw->_textToPrint = _tempStr; + _vm->_draw->_transparency = 1; _vm->_draw->spriteOperation(DRAW_FILLRECT); - _vm->_draw->destSpriteY = yPos + (height - 8) / 2; + _vm->_draw->_destSpriteY = yPos + (height - 8) / 2; _vm->_draw->spriteOperation(DRAW_PRINTTEXT); - if (key != 0 || activeCollResId != 0) + if (key != 0 || _activeCollResId != 0) break; key = checkCollisions(handleMouse, -300, - &activeCollResId, &activeCollIndex); + &_activeCollResId, &_activeCollIndex); if (*pTotTime > 0) { *pTotTime -= 300; if (*pTotTime <= 1) { key = 0; - activeCollResId = 0; + _activeCollResId = 0; break; } } - if (key != 0 || activeCollResId != 0) + if (key != 0 || _activeCollResId != 0) break; if (_vm->_inter->_terminate) return 0; } - if (key == 0 || activeCollResId != 0 || _vm->_inter->_terminate) + if (key == 0 || _activeCollResId != 0 || _vm->_inter->_terminate) return 0; switch (key) { @@ -867,10 +867,10 @@ int16 Game::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, int16 b if (_vm->_global->_useMouse != 0) continue; - forceHandleMouse = !forceHandleMouse; + _forceHandleMouse = !_forceHandleMouse; - if (ghandleMouse != 0 && - (_vm->_global->_useMouse != 0 || forceHandleMouse != 0)) + if (_handleMouse != 0 && + (_vm->_global->_useMouse != 0 || _forceHandleMouse != 0)) handleMouse = 1; else handleMouse = 0; @@ -915,10 +915,10 @@ int16 Game::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, int16 b key += ('A' - 'a'); pos++; - tempStr[0] = key; - tempStr[1] = 0; + _tempStr[0] = key; + _tempStr[1] = 0; - _vm->_util->insertStr(tempStr, str, pos - 1); + _vm->_util->insertStr(_tempStr, str, pos - 1); //strupr(str); } @@ -935,7 +935,7 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe descInd = 0; for (i = 0; i < 250; i++) { - collArea = &collisionAreas[i]; + collArea = &_collisionAreas[i]; if (collArea->left == -1) continue; @@ -949,22 +949,22 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe if ((collArea->flags & 0x0f) > 10) continue; - strcpy(tempStr, _vm->_global->_inter_variables + collArea->key); + strcpy(_tempStr, _vm->_global->_inter_variables + collArea->key); - _vm->_draw->destSpriteX = collArea->left; - _vm->_draw->destSpriteY = collArea->top; - _vm->_draw->spriteRight = collArea->right - collArea->left + 1; - _vm->_draw->spriteBottom = collArea->bottom - collArea->top + 1; + _vm->_draw->_destSpriteX = collArea->left; + _vm->_draw->_destSpriteY = collArea->top; + _vm->_draw->_spriteRight = collArea->right - collArea->left + 1; + _vm->_draw->_spriteBottom = collArea->bottom - collArea->top + 1; - _vm->_draw->destSurface = 21; + _vm->_draw->_destSurface = 21; - _vm->_draw->backColor = inpDesc[descInd].backColor; - _vm->_draw->frontColor = inpDesc[descInd].frontColor; - _vm->_draw->textToPrint = tempStr; - _vm->_draw->transparency = 1; - _vm->_draw->fontIndex = inpDesc[descInd].fontIndex; + _vm->_draw->_backColor = inpDesc[descInd].backColor; + _vm->_draw->_frontColor = inpDesc[descInd].frontColor; + _vm->_draw->_textToPrint = _tempStr; + _vm->_draw->_transparency = 1; + _vm->_draw->_fontIndex = inpDesc[descInd].fontIndex; _vm->_draw->spriteOperation(DRAW_FILLRECT); - _vm->_draw->destSpriteY += + _vm->_draw->_destSpriteY += ((collArea->bottom - collArea->top + 1) - 8) / 2; _vm->_draw->spriteOperation(DRAW_PRINTTEXT); @@ -979,7 +979,7 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe descInd = 0; for (i = 0; i < 250; i++) { - collArea = &collisionAreas[i]; + collArea = &_collisionAreas[i]; if (collArea->left == -1) continue; @@ -1003,7 +1003,7 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe assert(found != -1); - collArea = &collisionAreas[found]; + collArea = &_collisionAreas[found]; key = inputArea(collArea->left, collArea->top, collArea->right - collArea->left + 1, @@ -1017,20 +1017,20 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe switch (key) { case 0: - if (activeCollResId == 0) + if (_activeCollResId == 0) return 0; - if ((collisionAreas[activeCollIndex]. + if ((_collisionAreas[_activeCollIndex]. flags & 0x0f) < 3) return 0; - if ((collisionAreas[activeCollIndex]. + if ((_collisionAreas[_activeCollIndex]. flags & 0x0f) > 10) return 0; *pCurPos = 0; for (i = 0; i < 250; i++) { - collArea = &collisionAreas[i]; + collArea = &_collisionAreas[i]; if (collArea->left == -1) continue; @@ -1044,7 +1044,7 @@ int16 Game::multiEdit(int16 time, int16 index, int16 *pCurPos, InputDesc * inpDe if ((collArea->flags & 0x0f) > 10) continue; - if (i == activeCollIndex) + if (i == _activeCollIndex) break; pCurPos[0]++; @@ -1126,18 +1126,18 @@ void Game::collisionsBlock(void) { int16 counter; int16 var_24; int16 var_26; - int16 collStackPos; + int16 _collStackPos; Collision *collPtr; int16 timeKey; char *savedIP; - if (shouldPushColls) + if (_shouldPushColls) pushCollisions(1); collResId = -1; _vm->_global->_inter_execPtr++; count = *_vm->_global->_inter_execPtr++; - ghandleMouse = _vm->_global->_inter_execPtr[0]; + _handleMouse = _vm->_global->_inter_execPtr[0]; deltaTime = 1000 * (byte)_vm->_global->_inter_execPtr[1]; descIndex2 = (byte)_vm->_global->_inter_execPtr[2]; stackPos2 = (byte)_vm->_global->_inter_execPtr[3]; @@ -1215,10 +1215,10 @@ void Game::collisionsBlock(void) { top, left + width * - _vm->_draw->fonts[descArray[index].fontIndex]-> + _vm->_draw->_fonts[descArray[index].fontIndex]-> itemWidth - 1, top + height - 1, cmd, key, 0, - _vm->_global->_inter_execPtr - (char *)totFileData); + _vm->_global->_inter_execPtr - (char *)_totFileData); _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); @@ -1227,7 +1227,7 @@ void Game::collisionsBlock(void) { top, left + width * - _vm->_draw->fonts[descArray[index].fontIndex]-> + _vm->_draw->_fonts[descArray[index].fontIndex]-> itemWidth - 1, top + height - 1, cmd, key, 0, 0); } @@ -1243,7 +1243,7 @@ void Game::collisionsBlock(void) { left + width - 1, top + height - 1, (flags << 4) + cmdHigh + 2, key, - _vm->_global->_inter_execPtr - (char *)totFileData, 0); + _vm->_global->_inter_execPtr - (char *)_totFileData, 0); _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); @@ -1262,7 +1262,7 @@ void Game::collisionsBlock(void) { left + width - 1, top + height - 1, (flags << 4) + cmdHigh + 2, key, 0, - _vm->_global->_inter_execPtr - (char *)totFileData); + _vm->_global->_inter_execPtr - (char *)_totFileData); _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); @@ -1279,8 +1279,8 @@ void Game::collisionsBlock(void) { left + width - 1, top + height - 1, cmd + cmdHigh, key, - startIP - (char *)totFileData, - _vm->_global->_inter_execPtr - (char *)totFileData); + startIP - (char *)_totFileData, + _vm->_global->_inter_execPtr - (char *)_totFileData); _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); @@ -1301,8 +1301,8 @@ void Game::collisionsBlock(void) { left + width - 1, top + height - 1, (flags << 4) + cmd + cmdHigh, key, - startIP - (char *)totFileData, - _vm->_global->_inter_execPtr - (char *)totFileData); + startIP - (char *)_totFileData, + _vm->_global->_inter_execPtr - (char *)_totFileData); _vm->_global->_inter_execPtr += 2; _vm->_global->_inter_execPtr += READ_LE_UINT16(_vm->_global->_inter_execPtr); @@ -1310,7 +1310,7 @@ void Game::collisionsBlock(void) { } } - forceHandleMouse = 0; + _forceHandleMouse = 0; _vm->_util->waitKey(); do { @@ -1321,30 +1321,30 @@ void Game::collisionsBlock(void) { if (key == 0x1c0d) { for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; - if ((collisionAreas[i].flags & 1) != 0) + if ((_collisionAreas[i].flags & 1) != 0) continue; - if ((collisionAreas[i].flags & 0x0f) <= 2) + if ((_collisionAreas[i].flags & 0x0f) <= 2) continue; - collResId = collisionAreas[i].id; - activeCollResId = collResId; + collResId = _collisionAreas[i].id; + _activeCollResId = collResId; collResId &= 0x7fff; - activeCollIndex = i; + _activeCollIndex = i; break; } break; } } else { key = - checkCollisions(ghandleMouse, -deltaTime, - &activeCollResId, &activeCollIndex); + checkCollisions(_handleMouse, -deltaTime, + &_activeCollResId, &_activeCollIndex); } if ((key & 0xff) >= ' ' && (key & 0xff) <= 0xff && @@ -1352,44 +1352,44 @@ void Game::collisionsBlock(void) { key = '0' + (((key >> 8) - 1) % 10) + (key & 0xff00); } - if (activeCollResId == 0) { + if (_activeCollResId == 0) { if (key != 0) { for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i]. + if ((_collisionAreas[i]. id & 0x8000) == 0) continue; - if (collisionAreas[i].key == key - || collisionAreas[i].key == + if (_collisionAreas[i].key == key + || _collisionAreas[i].key == 0x7fff) { - activeCollResId = - collisionAreas[i].id; - activeCollIndex = i; + _activeCollResId = + _collisionAreas[i].id; + _activeCollIndex = i; break; } } - if (activeCollResId == 0) { + if (_activeCollResId == 0) { for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; - if ((collisionAreas[i].key & 0xff00) != 0) + if ((_collisionAreas[i].key & 0xff00) != 0) continue; - if (collisionAreas[i].key == 0) + if (_collisionAreas[i].key == 0) continue; - if (adjustKey(key & 0xff) == adjustKey(collisionAreas[i].key) || collisionAreas[i].key == 0x7fff) { - activeCollResId = collisionAreas[i].id; - activeCollIndex = i; + if (adjustKey(key & 0xff) == adjustKey(_collisionAreas[i].key) || _collisionAreas[i].key == 0x7fff) { + _activeCollResId = _collisionAreas[i].id; + _activeCollIndex = i; break; } } @@ -1398,36 +1398,36 @@ void Game::collisionsBlock(void) { if (deltaTime != 0 && VAR(16) == 0) { if (stackPos2 != 0) { - collStackPos = 0; - collPtr = collisionAreas; + _collStackPos = 0; + collPtr = _collisionAreas; - for (i = 0, collPtr = collisionAreas; collPtr->left != -1; i++, collPtr++) { + for (i = 0, collPtr = _collisionAreas; collPtr->left != -1; i++, collPtr++) { if ((collPtr->id & 0x8000) == 0) continue; - collStackPos++; - if (collStackPos != stackPos2) + _collStackPos++; + if (_collStackPos != stackPos2) continue; - activeCollResId = collPtr->id; - activeCollIndex = i; + _activeCollResId = collPtr->id; + _activeCollIndex = i; WRITE_VAR(2, _vm->_global->_inter_mouseX); WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, mouseButtons); - WRITE_VAR(16, array[(uint16)activeCollResId & ~0x8000]); + WRITE_VAR(4, _mouseButtons); + WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); if (collPtr->funcLeave != 0) { timeKey = _vm->_util->getTimeKey(); savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + collPtr->funcLeave; - shouldPushColls = 1; - savedCollStackSize = collStackSize; + _vm->_global->_inter_execPtr = (char *)_totFileData + collPtr->funcLeave; + _shouldPushColls = 1; + savedCollStackSize = _collStackSize; _vm->_inter->funcBlock(0); - if (savedCollStackSize != collStackSize) + if (savedCollStackSize != _collStackSize) popCollisions(); - shouldPushColls = 0; + _shouldPushColls = 0; _vm->_global->_inter_execPtr = savedIP; deltaTime = timeVal - (_vm->_util->getTimeKey() - timeKey); @@ -1436,37 +1436,37 @@ void Game::collisionsBlock(void) { } if (VAR(16) == 0) - activeCollResId = 0; + _activeCollResId = 0; break; } } else { if (descIndex != 0) { counter = 0; for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; counter++; if (counter != descIndex) continue; - activeCollResId = collisionAreas[i].id; - activeCollIndex = i; + _activeCollResId = _collisionAreas[i].id; + _activeCollIndex = i; break; } } else { for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; - activeCollResId = collisionAreas[i].id; - activeCollIndex = i; + _activeCollResId = _collisionAreas[i].id; + _activeCollIndex = i; break; } } @@ -1475,18 +1475,18 @@ void Game::collisionsBlock(void) { if (descIndex2 != 0) { counter = 0; for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; counter++; if (counter != descIndex2) continue; - activeCollResId = collisionAreas[i].id; - activeCollIndex = i; + _activeCollResId = _collisionAreas[i].id; + _activeCollIndex = i; break; } } @@ -1494,92 +1494,92 @@ void Game::collisionsBlock(void) { } } - if (activeCollResId == 0) + if (_activeCollResId == 0) continue; - if (collisionAreas[activeCollIndex].funcLeave != 0) + if (_collisionAreas[_activeCollIndex].funcLeave != 0) continue; WRITE_VAR(2, _vm->_global->_inter_mouseX); WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, mouseButtons); - WRITE_VAR(16, array[(uint16)activeCollResId & ~0x8000]); + WRITE_VAR(4, _mouseButtons); + WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); - if (collisionAreas[activeCollIndex].funcEnter != 0) { + if (_collisionAreas[_activeCollIndex].funcEnter != 0) { savedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)totFileData + - collisionAreas[activeCollIndex]. + _vm->_global->_inter_execPtr = (char *)_totFileData + + _collisionAreas[_activeCollIndex]. funcEnter; - shouldPushColls = 1; + _shouldPushColls = 1; - collStackPos = collStackSize; + _collStackPos = _collStackSize; _vm->_inter->funcBlock(0); - if (collStackPos != collStackSize) + if (_collStackPos != _collStackSize) popCollisions(); - shouldPushColls = 0; + _shouldPushColls = 0; _vm->_global->_inter_execPtr = savedIP; } WRITE_VAR(16, 0); - activeCollResId = 0; + _activeCollResId = 0; } - while (activeCollResId == 0 && !_vm->_inter->_terminate); + while (_activeCollResId == 0 && !_vm->_inter->_terminate); - if (((uint16)activeCollResId & ~0x8000) == collResId) { - collStackPos = 0; + if (((uint16)_activeCollResId & ~0x8000) == collResId) { + _collStackPos = 0; var_24 = 0; var_26 = 1; for (i = 0; i < 250; i++) { - if (collisionAreas[i].left == -1) + if (_collisionAreas[i].left == -1) continue; - if ((collisionAreas[i].id & 0x8000) == 0) + if ((_collisionAreas[i].id & 0x8000) == 0) continue; - if ((collisionAreas[i].flags & 0x0f) < 3) + if ((_collisionAreas[i].flags & 0x0f) < 3) continue; - if ((collisionAreas[i].flags & 0x0f) > 10) + if ((_collisionAreas[i].flags & 0x0f) > 10) continue; - if ((collisionAreas[i].flags & 0x0f) > 8) { - strcpy(tempStr, - _vm->_global->_inter_variables + collisionAreas[i].key); + if ((_collisionAreas[i].flags & 0x0f) > 8) { + strcpy(_tempStr, + _vm->_global->_inter_variables + _collisionAreas[i].key); while ((pos = - _vm->_util->strstr(" ", tempStr)) != 0) { - _vm->_util->cutFromStr(tempStr, pos - 1, 1); - pos = _vm->_util->strstr(" ", tempStr); + _vm->_util->strstr(" ", _tempStr)) != 0) { + _vm->_util->cutFromStr(_tempStr, pos - 1, 1); + pos = _vm->_util->strstr(" ", _tempStr); } - strcpy(_vm->_global->_inter_variables + collisionAreas[i].key, tempStr); + strcpy(_vm->_global->_inter_variables + _collisionAreas[i].key, _tempStr); } - if ((collisionAreas[i].flags & 0x0f) >= 5 && - (collisionAreas[i].flags & 0x0f) <= 8) { + if ((_collisionAreas[i].flags & 0x0f) >= 5 && + (_collisionAreas[i].flags & 0x0f) <= 8) { str = descArray[var_24].ptr; - strcpy(tempStr, _vm->_global->_inter_variables + collisionAreas[i].key); + strcpy(_tempStr, _vm->_global->_inter_variables + _collisionAreas[i].key); - if ((collisionAreas[i].flags & 0x0f) < 7) - _vm->_util->prepareStr(tempStr); + if ((_collisionAreas[i].flags & 0x0f) < 7) + _vm->_util->prepareStr(_tempStr); pos = 0; do { - strcpy(collStr, str); + strcpy(_collStr, str); pos += strlen(str) + 1; str += strlen(str) + 1; - if ((collisionAreas[i].flags & 0x0f) < 7) - _vm->_util->prepareStr(collStr); + if ((_collisionAreas[i].flags & 0x0f) < 7) + _vm->_util->prepareStr(_collStr); - if (strcmp(tempStr, collStr) == 0) { + if (strcmp(_tempStr, _collStr) == 0) { VAR(17)++; WRITE_VAR(17 + var_26, 1); break; } } while (READ_LE_UINT16(descArray[var_24].ptr - 2) > pos); - collStackPos++; + _collStackPos++; } else { VAR(17 + var_26) = 2; } @@ -1587,7 +1587,7 @@ void Game::collisionsBlock(void) { var_26++; } - if (collStackPos != (int16)VAR(17)) + if (_collStackPos != (int16)VAR(17)) WRITE_VAR(17, 0); else WRITE_VAR(17, 1); @@ -1595,15 +1595,15 @@ void Game::collisionsBlock(void) { savedIP = 0; if (!_vm->_inter->_terminate) { - savedIP = (char *)totFileData + - collisionAreas[activeCollIndex].funcLeave; + savedIP = (char *)_totFileData + + _collisionAreas[_activeCollIndex].funcLeave; WRITE_VAR(2, _vm->_global->_inter_mouseX); WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, mouseButtons); + WRITE_VAR(4, _mouseButtons); if (VAR(16) == 0) { - WRITE_VAR(16, array[(uint16)activeCollResId & ~0x8000]); + WRITE_VAR(16, array[(uint16)_activeCollResId & ~0x8000]); } } @@ -1618,47 +1618,47 @@ void Game::prepareStart(void) { clearCollisions(); - _vm->_global->_pPaletteDesc->unused2 = _vm->_draw->unusedPalette2; - _vm->_global->_pPaletteDesc->unused1 = _vm->_draw->unusedPalette1; - _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->vgaPalette; + _vm->_global->_pPaletteDesc->unused2 = _vm->_draw->_unusedPalette2; + _vm->_global->_pPaletteDesc->unused1 = _vm->_draw->_unusedPalette1; + _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->_vgaPalette; _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - _vm->_draw->backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); + _vm->_draw->_backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); - _vm->_video->fillRect(_vm->_draw->backSurface, 0, 0, 319, 199, 1); - _vm->_draw->frontSurface = _vm->_global->_pPrimarySurfDesc; - _vm->_video->fillRect(_vm->_draw->frontSurface, 0, 0, 319, 199, 1); + _vm->_video->fillRect(_vm->_draw->_backSurface, 0, 0, 319, 199, 1); + _vm->_draw->_frontSurface = _vm->_global->_pPrimarySurfDesc; + _vm->_video->fillRect(_vm->_draw->_frontSurface, 0, 0, 319, 199, 1); _vm->_util->setMousePos(152, 92); - _vm->_draw->cursorX = 152; + _vm->_draw->_cursorX = 152; _vm->_global->_inter_mouseX = 152; - _vm->_draw->cursorY = 92; + _vm->_draw->_cursorY = 92; _vm->_global->_inter_mouseY = 92; - _vm->_draw->invalidatedCount = 0; - _vm->_draw->noInvalidated = 1; - _vm->_draw->applyPal = 0; - _vm->_draw->paletteCleared = 0; - _vm->_draw->cursorWidth = 16; - _vm->_draw->cursorHeight = 16; - _vm->_draw->transparentCursor = 1; + _vm->_draw->_invalidatedCount = 0; + _vm->_draw->_noInvalidated = 1; + _vm->_draw->_applyPal = 0; + _vm->_draw->_paletteCleared = 0; + _vm->_draw->_cursorWidth = 16; + _vm->_draw->_cursorHeight = 16; + _vm->_draw->_transparentCursor = 1; for (i = 0; i < 40; i++) { - _vm->_draw->cursorAnimLow[i] = -1; - _vm->_draw->cursorAnimDelays[i] = 0; - _vm->_draw->cursorAnimHigh[i] = 0; + _vm->_draw->_cursorAnimLow[i] = -1; + _vm->_draw->_cursorAnimDelays[i] = 0; + _vm->_draw->_cursorAnimHigh[i] = 0; } - _vm->_draw->cursorAnimLow[1] = 0; - _vm->_draw->cursorSprites = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 32, 16, 2); - _vm->_draw->cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0); - _vm->_draw->renderFlags = 0; - _vm->_draw->backDeltaX = 0; - _vm->_draw->backDeltaY = 0; + _vm->_draw->_cursorAnimLow[1] = 0; + _vm->_draw->_cursorSprites = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 32, 16, 2); + _vm->_draw->_cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0); + _vm->_draw->_renderFlags = 0; + _vm->_draw->_backDeltaX = 0; + _vm->_draw->_backDeltaY = 0; - startTimeKey = _vm->_util->getTimeKey(); + _startTimeKey = _vm->_util->getTimeKey(); } void Game::loadTotFile(char *path) { @@ -1667,9 +1667,9 @@ void Game::loadTotFile(char *path) { handle = _vm->_dataio->openData(path); if (handle >= 0) { _vm->_dataio->closeData(handle); - totFileData = _vm->_dataio->getData(path); + _totFileData = _vm->_dataio->getData(path); } else { - totFileData = 0; + _totFileData = 0; } } @@ -1678,30 +1678,30 @@ void Game::loadExtTable(void) { // Function is correct. [sev] - extHandle = _vm->_dataio->openData(curExtFile); - if (extHandle < 0) + _extHandle = _vm->_dataio->openData(_curExtFile); + if (_extHandle < 0) return; - _vm->_dataio->readData(extHandle, (char *)&count, 2); + _vm->_dataio->readData(_extHandle, (char *)&count, 2); count = FROM_LE_16(count); - _vm->_dataio->seekData(extHandle, 0, 0); - extTable = (ExtTable *)malloc(sizeof(ExtTable) + _vm->_dataio->seekData(_extHandle, 0, 0); + _extTable = (ExtTable *)malloc(sizeof(ExtTable) + sizeof(ExtItem) * count); - _vm->_dataio->readData(extHandle, (char *)&extTable->itemsCount, 2); - extTable->itemsCount = FROM_LE_16(extTable->itemsCount); - _vm->_dataio->readData(extHandle, (char *)&extTable->unknown, 1); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->itemsCount, 2); + _extTable->itemsCount = FROM_LE_16(_extTable->itemsCount); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->unknown, 1); for (i = 0; i < count; i++) { - _vm->_dataio->readData(extHandle, (char *)&extTable->items[i].offset, 4); - extTable->items[i].offset = FROM_LE_32(extTable->items[i].offset); - _vm->_dataio->readData(extHandle, (char *)&extTable->items[i].size, 2); - extTable->items[i].size = FROM_LE_16(extTable->items[i].size); - _vm->_dataio->readData(extHandle, (char *)&extTable->items[i].width, 2); - extTable->items[i].width = FROM_LE_16(extTable->items[i].width); - _vm->_dataio->readData(extHandle, (char *)&extTable->items[i].height, 2); - extTable->items[i].height = FROM_LE_16(extTable->items[i].height); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->items[i].offset, 4); + _extTable->items[i].offset = FROM_LE_32(_extTable->items[i].offset); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->items[i].size, 2); + _extTable->items[i].size = FROM_LE_16(_extTable->items[i].size); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->items[i].width, 2); + _extTable->items[i].width = FROM_LE_16(_extTable->items[i].width); + _vm->_dataio->readData(_extHandle, (char *)&_extTable->items[i].height, 2); + _extTable->items[i].height = FROM_LE_16(_extTable->items[i].height); } } @@ -1709,19 +1709,19 @@ void Game::loadImFile(void) { char path[20]; int16 handle; - if (totFileData[0x3d] != 0 && totFileData[0x3b] == 0) + if (_totFileData[0x3d] != 0 && _totFileData[0x3b] == 0) return; strcpy(path, "commun.im1"); - if (totFileData[0x3b] != 0) - path[strlen(path) - 1] = '0' + totFileData[0x3b]; + if (_totFileData[0x3b] != 0) + path[strlen(path) - 1] = '0' + _totFileData[0x3b]; handle = _vm->_dataio->openData(path); if (handle < 0) return; _vm->_dataio->closeData(handle); - imFileData = _vm->_dataio->getData(path); + _imFileData = _vm->_dataio->getData(path); } void Game::playTot(int16 skipPlay) { @@ -1729,7 +1729,7 @@ void Game::playTot(int16 skipPlay) { int16 *oldCaptureCounter; int16 *oldBreakFrom; int16 *oldNestLevel; - int16 captureCounter; + int16 _captureCounter; int16 breakFrom; int16 nestLevel; char needTextFree; @@ -1747,16 +1747,16 @@ void Game::playTot(int16 skipPlay) { _vm->_inter->_nestLevel = &nestLevel; _vm->_inter->_breakFromLevel = &breakFrom; - _vm->_scenery->pCaptureCounter = &captureCounter; - strcpy(savedTotName, curTotFile); + _vm->_scenery->pCaptureCounter = &_captureCounter; + strcpy(savedTotName, _curTotFile); if (skipPlay == 0) { while (1) { for (i = 0; i < 4; i++) { - _vm->_draw->fontToSprite[i].sprite = -1; - _vm->_draw->fontToSprite[i].base = -1; - _vm->_draw->fontToSprite[i].width = -1; - _vm->_draw->fontToSprite[i].height = -1; + _vm->_draw->_fontToSprite[i].sprite = -1; + _vm->_draw->_fontToSprite[i].base = -1; + _vm->_draw->_fontToSprite[i].width = -1; + _vm->_draw->_fontToSprite[i].height = -1; } _vm->_cdrom->stopPlaying(); @@ -1766,80 +1766,80 @@ void Game::playTot(int16 skipPlay) { _vm->_mult->zeroMultData(); for (i = 0; i < 20; i++) - _vm->_draw->spritesArray[i] = 0; + _vm->_draw->_spritesArray[i] = 0; - _vm->_draw->spritesArray[20] = _vm->_draw->frontSurface; - _vm->_draw->spritesArray[21] = _vm->_draw->backSurface; - _vm->_draw->spritesArray[23] = _vm->_draw->cursorSprites; + _vm->_draw->_spritesArray[20] = _vm->_draw->_frontSurface; + _vm->_draw->_spritesArray[21] = _vm->_draw->_backSurface; + _vm->_draw->_spritesArray[23] = _vm->_draw->_cursorSprites; for (i = 0; i < 20; i++) - soundSamples[i] = 0; + _soundSamples[i] = 0; - totTextData = 0; - totResourceTable = 0; - imFileData = 0; - extTable = 0; - extHandle = -1; + _totTextData = 0; + _totResourceTable = 0; + _imFileData = 0; + _extTable = 0; + _extHandle = -1; needFreeResTable = 1; needTextFree = 1; - totToLoad[0] = 0; + _totToLoad[0] = 0; - if (curTotFile[0] == 0 && totFileData == 0) + if (_curTotFile[0] == 0 && _totFileData == 0) break; - loadTotFile(curTotFile); - if (totFileData == 0) { + loadTotFile(_curTotFile); + if (_totFileData == 0) { _vm->_draw->blitCursor(); break; } - strcpy(curImaFile, curTotFile); - strcpy(curExtFile, curTotFile); + strcpy(_curImaFile, _curTotFile); + strcpy(_curExtFile, _curTotFile); - curImaFile[strlen(curImaFile) - 4] = 0; - strcat(curImaFile, ".ima"); + _curImaFile[strlen(_curImaFile) - 4] = 0; + strcat(_curImaFile, ".ima"); - curExtFile[strlen(curExtFile) - 4] = 0; - strcat(curExtFile, ".ext"); + _curExtFile[strlen(_curExtFile) - 4] = 0; + strcat(_curExtFile, ".ext"); - debug(4, "IMA: %s", curImaFile); - debug(4, "EXT: %s", curExtFile); + debug(4, "IMA: %s", _curImaFile); + debug(4, "EXT: %s", _curExtFile); - filePtr = (char *)totFileData + 0x30; + filePtr = (char *)_totFileData + 0x30; if (READ_LE_UINT32(filePtr) != (uint32)-1) { - curPtr = totFileData; - totTextData = + curPtr = _totFileData; + _totTextData = (TotTextTable *) (curPtr + - READ_LE_UINT32((char *)totFileData + 0x30)); + READ_LE_UINT32((char *)_totFileData + 0x30)); - totTextData->itemsCount = (int16)READ_LE_UINT16(&totTextData->itemsCount); + _totTextData->itemsCount = (int16)READ_LE_UINT16(&_totTextData->itemsCount); - for (i = 0; i < totTextData->itemsCount; ++i) { - totTextData->items[i].offset = (int16)READ_LE_UINT16(&totTextData->items[i].offset); - totTextData->items[i].size = (int16)READ_LE_UINT16(&totTextData->items[i].size); + for (i = 0; i < _totTextData->itemsCount; ++i) { + _totTextData->items[i].offset = (int16)READ_LE_UINT16(&_totTextData->items[i].offset); + _totTextData->items[i].size = (int16)READ_LE_UINT16(&_totTextData->items[i].size); } needTextFree = 0; } - filePtr = (char *)totFileData + 0x34; + filePtr = (char *)_totFileData + 0x34; if (READ_LE_UINT32(filePtr) != (uint32)-1) { - curPtr = totFileData; + curPtr = _totFileData; - totResourceTable = + _totResourceTable = (TotResTable *)(curPtr + - READ_LE_UINT32((char *)totFileData + 0x34)); + READ_LE_UINT32((char *)_totFileData + 0x34)); - totResourceTable->itemsCount = (int16)READ_LE_UINT16(&totResourceTable->itemsCount); + _totResourceTable->itemsCount = (int16)READ_LE_UINT16(&_totResourceTable->itemsCount); - for (i = 0; i < totResourceTable->itemsCount; ++i) { - totResourceTable->items[i].offset = (int32)READ_LE_UINT32(&totResourceTable->items[i].offset); - totResourceTable->items[i].size = (int16)READ_LE_UINT16(&totResourceTable->items[i].size); - totResourceTable->items[i].width = (int16)READ_LE_UINT16(&totResourceTable->items[i].width); - totResourceTable->items[i].height = (int16)READ_LE_UINT16(&totResourceTable->items[i].height); + for (i = 0; i < _totResourceTable->itemsCount; ++i) { + _totResourceTable->items[i].offset = (int32)READ_LE_UINT32(&_totResourceTable->items[i].offset); + _totResourceTable->items[i].size = (int16)READ_LE_UINT16(&_totResourceTable->items[i].size); + _totResourceTable->items[i].width = (int16)READ_LE_UINT16(&_totResourceTable->items[i].width); + _totResourceTable->items[i].height = (int16)READ_LE_UINT16(&_totResourceTable->items[i].height); } needFreeResTable = 0; @@ -1848,16 +1848,16 @@ void Game::playTot(int16 skipPlay) { loadImFile(); loadExtTable(); - _vm->_global->_inter_animDataSize = READ_LE_UINT16((char *)totFileData + 0x38); + _vm->_global->_inter_animDataSize = READ_LE_UINT16((char *)_totFileData + 0x38); if (_vm->_global->_inter_variables == 0) { - variablesCount = READ_LE_UINT32((char *)totFileData + 0x2c); + variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c); _vm->_global->_inter_variables = (char *)malloc(variablesCount * 4); for (i = 0; i < variablesCount; i++) WRITE_VAR(i, 0); } - _vm->_global->_inter_execPtr = (char *)totFileData; - _vm->_global->_inter_execPtr += READ_LE_UINT32((char *)totFileData + 0x64); + _vm->_global->_inter_execPtr = (char *)_totFileData; + _vm->_global->_inter_execPtr += READ_LE_UINT32((char *)_totFileData + 0x64); _vm->_inter->renewTimeInVars(); @@ -1868,32 +1868,32 @@ void Game::playTot(int16 skipPlay) { _vm->_inter->callSub(2); - if (totToLoad[0] != 0) + if (_totToLoad[0] != 0) _vm->_inter->_terminate = false; - variablesCount = READ_LE_UINT32((char *)totFileData + 0x2c); + variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c); _vm->_draw->blitInvalidated(); - free(totFileData); - totFileData = 0; + free(_totFileData); + _totFileData = 0; if (needTextFree) - free(totTextData); - totTextData = 0; + free(_totTextData); + _totTextData = 0; if (needFreeResTable) - free(totResourceTable); - totResourceTable = 0; + free(_totResourceTable); + _totResourceTable = 0; - free(imFileData); - imFileData = 0; + free(_imFileData); + _imFileData = 0; - free(extTable); - extTable = 0; + free(_extTable); + _extTable = 0; - if (extHandle >= 0) - _vm->_dataio->closeData(extHandle); + if (_extHandle >= 0) + _vm->_dataio->closeData(_extHandle); - extHandle = -1; + _extHandle = -1; for (i = 0; i < *_vm->_scenery->pCaptureCounter; i++) capturePop(0); @@ -1902,23 +1902,23 @@ void Game::playTot(int16 skipPlay) { _vm->_mult->freeAll(); for (i = 0; i < 20; i++) { - if (_vm->_draw->spritesArray[i] != 0) - _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[i]); - _vm->_draw->spritesArray[i] = 0; + if (_vm->_draw->_spritesArray[i] != 0) + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[i]); + _vm->_draw->_spritesArray[i] = 0; } _vm->_snd->stopSound(0); for (i = 0; i < 20; i++) freeSoundSlot(i); - if (totToLoad[0] == 0) + if (_totToLoad[0] == 0) break; - strcpy(curTotFile, totToLoad); + strcpy(_curTotFile, _totToLoad); } } - strcpy(curTotFile, savedTotName); + strcpy(_curTotFile, savedTotName); _vm->_inter->_nestLevel = oldNestLevel; _vm->_inter->_breakFromLevel = oldBreakFrom; @@ -1927,15 +1927,15 @@ void Game::playTot(int16 skipPlay) { } void Game::start(void) { - collisionAreas = (Collision *)malloc(250 * sizeof(Collision)); + _collisionAreas = (Collision *)malloc(250 * sizeof(Collision)); prepareStart(); playTot(0); - free(collisionAreas); + free(_collisionAreas); - _vm->_video->freeSurfDesc(_vm->_draw->cursorSprites); - _vm->_video->freeSurfDesc(_vm->_draw->cursorBack); - _vm->_video->freeSurfDesc(_vm->_draw->backSurface); + _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); + _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack); + _vm->_video->freeSurfDesc(_vm->_draw->_backSurface); } } // End of namespace Gob diff --git a/gob/game.h b/gob/game.h index bc126463a1..1eb7239381 100644 --- a/gob/game.h +++ b/gob/game.h @@ -93,26 +93,26 @@ public: } GCC_PACK InputDesc; #pragma END_PACK_STRUCTS - TotResTable *totResourceTable; - Collision *collisionAreas; - Collision *collStack[3]; + TotResTable *_totResourceTable; + Collision *_collisionAreas; + Collision *_collStack[3]; - TotTextTable *totTextData; + TotTextTable *_totTextData; - char curTotFile[14]; - char curExtFile[14]; + char _curTotFile[14]; + char _curExtFile[14]; - char *imFileData; - char *totFileData; + char *_imFileData; + char *_totFileData; - int16 extHandle; + int16 _extHandle; - Snd::SoundDesc *soundSamples[20]; + Snd::SoundDesc *_soundSamples[20]; - char totToLoad[20]; + char _totToLoad[20]; - int32 startTimeKey; - int16 mouseButtons; + int32 _startTimeKey; + int16 _mouseButtons; Game(GobEngine *vm); @@ -149,32 +149,32 @@ public: protected: - int16 lastCollKey; - int16 lastCollAreaIndex; - int16 lastCollId; + int16 _lastCollKey; + int16 _lastCollAreaIndex; + int16 _lastCollId; - int16 activeCollResId; - int16 activeCollIndex; - char ghandleMouse; - char forceHandleMouse; + int16 _activeCollResId; + int16 _activeCollIndex; + char _handleMouse; + char _forceHandleMouse; - char tempStr[256]; + char _tempStr[256]; - ExtTable *extTable; - char curImaFile[18]; + ExtTable *_extTable; + char _curImaFile[18]; - int16 collStackSize; - int16 collStackElemSizes[3]; + int16 _collStackSize; + int16 _collStackElemSizes[3]; - char soundFromExt[20]; + char _soundFromExt[20]; - char shouldPushColls; + char _shouldPushColls; // Capture - static Common::Rect captureStack[20]; - static int16 captureCount; + static Common::Rect _captureStack[20]; + static int16 _captureCount; - char collStr[256]; + char _collStr[256]; GobEngine *_vm; diff --git a/gob/gob.cpp b/gob/gob.cpp index 9dd2cd7e4e..7344208e56 100644 --- a/gob/gob.cpp +++ b/gob/gob.cpp @@ -43,6 +43,7 @@ #include "gob/scenery.h" #include "gob/timer.h" #include "gob/util.h" +#include "gob/music.h" enum { // We only compute MD5 of the first megabyte of our data files. @@ -216,8 +217,8 @@ Engine *Engine_GOB_create(GameDetector * detector, OSystem *syst) { REGISTER_PLUGIN(GOB, "Gob Engine") namespace Gob { + #define MAX_TIME_DELTA 100 -//GobEngine *_vm = NULL; GobEngine::GobEngine(GameDetector *detector, OSystem * syst, uint32 features) : Engine(syst) { @@ -253,6 +254,7 @@ GobEngine::~GobEngine() { delete _gtimer; delete _util; delete _inter; + delete _music; } void GobEngine::errorString(const char *buf1, char *buf2) { @@ -288,6 +290,7 @@ int GobEngine::init(GameDetector &detector) { _scenery = new Scenery(this); _gtimer = new GTimer(); _util = new Util(this); + _music = new Music(this); if (_features & Gob::GF_GOB1) _inter = new Inter_v1(this); else if (_features & Gob::GF_GOB2) @@ -55,6 +55,7 @@ class Parse; class Scenery; class GTimer; class Util; +class Music; #define VAR_OFFSET(offs) (*(uint32 *)(_vm->_global->_inter_variables + (offs))) #define VAR(var) VAR_OFFSET((var) << 2) @@ -117,6 +118,7 @@ public: GTimer *_gtimer; Util *_util; Inter *_inter; + Music *_music; }; } // End of namespace Gob diff --git a/gob/goblin.cpp b/gob/goblin.cpp index 91597d8f13..98158dcaa8 100644 --- a/gob/goblin.cpp +++ b/gob/goblin.cpp @@ -36,130 +36,130 @@ namespace Gob { Goblin::Goblin(GobEngine *vm) : _vm(vm) { - goesAtTarget = 0; - readyToAct = 0; - gobAction = 0; - itemIndInPocket = 5; - itemIdInPocket = 2; - itemByteFlag = 0; - destItemId = -1; - destActionItem = 0; - actDestItemDesc = 0; - forceNextState[0] = -1; - forceNextState[1] = -1; - forceNextState[2] = -1; - forceNextState[3] = -1; - forceNextState[4] = -1; - forceNextState[5] = -1; - forceNextState[6] = -1; - forceNextState[7] = 0; - forceNextState[8] = 0; - forceNextState[9] = 0; - - rotStates[0][0] = 0; rotStates[0][1] = 22; rotStates[0][2] = 23; rotStates[0][3] = 24; - rotStates[1][0] = 13; rotStates[1][1] = 2; rotStates[1][2] = 12; rotStates[1][3] = 14; - rotStates[2][0] = 16; rotStates[2][1] = 15; rotStates[2][2] = 4; rotStates[2][3] = 17; - rotStates[3][0] = 27; rotStates[3][1] = 25; rotStates[3][2] = 26; rotStates[3][3] = 6; - - boreCounter = 0; - positionedGob = 5; - - noPick = 0; - objList = 0; + _goesAtTarget = 0; + _readyToAct = 0; + _gobAction = 0; + _itemIndInPocket = 5; + _itemIdInPocket = 2; + _itemByteFlag = 0; + _destItemId = -1; + _destActionItem = 0; + _actDestItemDesc = 0; + _forceNextState[0] = -1; + _forceNextState[1] = -1; + _forceNextState[2] = -1; + _forceNextState[3] = -1; + _forceNextState[4] = -1; + _forceNextState[5] = -1; + _forceNextState[6] = -1; + _forceNextState[7] = 0; + _forceNextState[8] = 0; + _forceNextState[9] = 0; + + _rotStates[0][0] = 0; _rotStates[0][1] = 22; _rotStates[0][2] = 23; _rotStates[0][3] = 24; + _rotStates[1][0] = 13; _rotStates[1][1] = 2; _rotStates[1][2] = 12; _rotStates[1][3] = 14; + _rotStates[2][0] = 16; _rotStates[2][1] = 15; _rotStates[2][2] = 4; _rotStates[2][3] = 17; + _rotStates[3][0] = 27; _rotStates[3][1] = 25; _rotStates[3][2] = 26; _rotStates[3][3] = 6; + + _boreCounter = 0; + _positionedGob = 5; + + _noPick = 0; + _objList = 0; for (int i = 0; i < 4; i++) - goblins[i] = 0; - currentGoblin = 0; + _goblins[i] = 0; + _currentGoblin = 0; for (int i = 0; i < 16; i++) - soundData[i] = 0; + _soundData[i] = 0; for (int i = 0; i < 3; i++) { - gobPositions[i].x = 0; - gobPositions[i].y = 0; + _gobPositions[i].x = 0; + _gobPositions[i].y = 0; } - gobDestX = 0; - gobDestY = 0; - pressedMapX = 0; - pressedMapY = 0; - pathExistence = 0; - - some0ValPtr = 0; - - gobRetVarPtr = 0; - curGobVarPtr = 0; - curGobXPosVarPtr = 0; - curGobYPosVarPtr = 0; - itemInPocketVarPtr = 0; - - curGobStateVarPtr = 0; - curGobFrameVarPtr = 0; - curGobMultStateVarPtr = 0; - curGobNextStateVarPtr = 0; - curGobScrXVarPtr = 0; - curGobScrYVarPtr = 0; - curGobLeftVarPtr = 0; - curGobTopVarPtr = 0; - curGobRightVarPtr = 0; - curGobBottomVarPtr = 0; - curGobDoAnimVarPtr = 0; - curGobOrderVarPtr = 0; - curGobNoTickVarPtr = 0; - curGobTypeVarPtr = 0; - curGobMaxTickVarPtr = 0; - curGobTickVarPtr = 0; - curGobActStartStateVarPtr = 0; - curGobLookDirVarPtr = 0; - curGobPickableVarPtr = 0; - curGobRelaxVarPtr = 0; - curGobMaxFrameVarPtr = 0; - - destItemStateVarPtr = 0; - destItemFrameVarPtr = 0; - destItemMultStateVarPtr = 0; - destItemNextStateVarPtr = 0; - destItemScrXVarPtr = 0; - destItemScrYVarPtr = 0; - destItemLeftVarPtr = 0; - destItemTopVarPtr = 0; - destItemRightVarPtr = 0; - destItemBottomVarPtr = 0; - destItemDoAnimVarPtr = 0; - destItemOrderVarPtr = 0; - destItemNoTickVarPtr = 0; - destItemTypeVarPtr = 0; - destItemMaxTickVarPtr = 0; - destItemTickVarPtr = 0; - destItemActStartStVarPtr = 0; - destItemLookDirVarPtr = 0; - destItemPickableVarPtr = 0; - destItemRelaxVarPtr = 0; - destItemMaxFrameVarPtr = 0; - - destItemType = 0; - destItemState = 0; + _gobDestX = 0; + _gobDestY = 0; + _pressedMapX = 0; + _pressedMapY = 0; + _pathExistence = 0; + + _some0ValPtr = 0; + + _gobRetVarPtr = 0; + _curGobVarPtr = 0; + _curGobXPosVarPtr = 0; + _curGobYPosVarPtr = 0; + _itemInPocketVarPtr = 0; + + _curGobStateVarPtr = 0; + _curGobFrameVarPtr = 0; + _curGobMultStateVarPtr = 0; + _curGobNextStateVarPtr = 0; + _curGobScrXVarPtr = 0; + _curGobScrYVarPtr = 0; + _curGobLeftVarPtr = 0; + _curGobTopVarPtr = 0; + _curGobRightVarPtr = 0; + _curGobBottomVarPtr = 0; + _curGobDoAnimVarPtr = 0; + _curGobOrderVarPtr = 0; + _curGobNoTickVarPtr = 0; + _curGobTypeVarPtr = 0; + _curGobMaxTickVarPtr = 0; + _curGobTickVarPtr = 0; + _curGobActStartStateVarPtr = 0; + _curGobLookDirVarPtr = 0; + _curGobPickableVarPtr = 0; + _curGobRelaxVarPtr = 0; + _curGobMaxFrameVarPtr = 0; + + _destItemStateVarPtr = 0; + _destItemFrameVarPtr = 0; + _destItemMultStateVarPtr = 0; + _destItemNextStateVarPtr = 0; + _destItemScrXVarPtr = 0; + _destItemScrYVarPtr = 0; + _destItemLeftVarPtr = 0; + _destItemTopVarPtr = 0; + _destItemRightVarPtr = 0; + _destItemBottomVarPtr = 0; + _destItemDoAnimVarPtr = 0; + _destItemOrderVarPtr = 0; + _destItemNoTickVarPtr = 0; + _destItemTypeVarPtr = 0; + _destItemMaxTickVarPtr = 0; + _destItemTickVarPtr = 0; + _destItemActStartStVarPtr = 0; + _destItemLookDirVarPtr = 0; + _destItemPickableVarPtr = 0; + _destItemRelaxVarPtr = 0; + _destItemMaxFrameVarPtr = 0; + + _destItemType = 0; + _destItemState = 0; for (int i = 0; i < 20; i++) { - itemToObject[i] = 0; - objects[i] = 0; + _itemToObject[i] = 0; + _objects[i] = 0; } - objCount = 0; - gobsCount = 0; + _objCount = 0; + _gobsCount = 0; } char Goblin::rotateState(int16 from, int16 to) { - return rotStates[from / 2][to / 2]; + return _rotStates[from / 2][to / 2]; } -int16 Goblin::peekGoblin(Gob_Object *curGob) { +int16 Goblin::peekGoblin(Gob_Object *_curGob) { Util::ListNode *ptr; Gob_Object *desc; int16 index; int16 i; - ptr = objList->pHead; + ptr = _objList->pHead; index = 0; while (ptr != 0) { desc = (Gob_Object *) ptr->pData; - if (desc != curGob) { + if (desc != _curGob) { for (i = 0; i < 3; i++) { - if (desc != goblins[i]) + if (desc != _goblins[i]) continue; if (_vm->_global->_inter_mouseX < desc->right && @@ -176,9 +176,9 @@ int16 Goblin::peekGoblin(Gob_Object *curGob) { } void Goblin::initList(void) { - objList = (Util::List *) malloc(sizeof(Util::List)); - objList->pHead = 0; - objList->pTail = 0; + _objList = (Util::List *) malloc(sizeof(Util::List)); + _objList->pHead = 0; + _objList->pTail = 0; } void Goblin::sortByOrder(Util::List *list) { @@ -199,7 +199,7 @@ void Goblin::sortByOrder(Util::List *list) { if (objDesc->bottom != objDesc2->bottom) continue; - if (objDesc != goblins[currentGoblin]) + if (objDesc != _goblins[_currentGoblin]) continue; } } @@ -225,8 +225,8 @@ void Goblin::drawObjects(void) { Gob_Object *gobDesc2; int16 layer; - ptr = objList->pHead; - for (ptr = objList->pHead; ptr != 0; ptr = ptr->pNext) { + ptr = _objList->pHead; + for (ptr = _objList->pHead; ptr != 0; ptr = ptr->pNext) { objDesc = (Gob_Object *) ptr->pData; if (objDesc->type == 3) @@ -235,12 +235,12 @@ void Goblin::drawObjects(void) { objDesc->toRedraw = 0; } - for (ptr = objList->pHead; ptr != 0; ptr = ptr->pNext) { + for (ptr = _objList->pHead; ptr != 0; ptr = ptr->pNext) { objDesc = (Gob_Object *) ptr->pData; if (objDesc->toRedraw == 0) continue; - _vm->_video->drawSprite(_vm->_anim->_animSurf, _vm->_draw->backSurface, + _vm->_video->drawSprite(_vm->_anim->_animSurf, _vm->_draw->_backSurface, objDesc->left, objDesc->top, objDesc->right, objDesc->bottom, objDesc->left, objDesc->top, 0); @@ -278,8 +278,8 @@ void Goblin::drawObjects(void) { objDesc->dirtyBottom = 199; } - sortByOrder(objList); - for (ptr = objList->pHead; ptr != 0; ptr = ptr->pNext) { + sortByOrder(_objList); + for (ptr = _objList->pHead; ptr != 0; ptr = ptr->pNext) { objDesc = (Gob_Object *) ptr->pData; if (objDesc->toRedraw) { layer = @@ -327,7 +327,7 @@ void Goblin::drawObjects(void) { } if (objDesc->type == 0 && objDesc->visible != 0) { - for (ptr2 = objList->pHead; ptr2 != 0; + for (ptr2 = _objList->pHead; ptr2 != 0; ptr2 = ptr2->pNext) { gobDesc2 = (Gob_Object *) ptr2->pData; @@ -364,7 +364,7 @@ void Goblin::drawObjects(void) { } } - for (ptr = objList->pHead; ptr != 0; ptr = ptr->pNext) { + for (ptr = _objList->pHead; ptr != 0; ptr = ptr->pNext) { objDesc = (Gob_Object *) ptr->pData; if (objDesc->toRedraw == 0 || objDesc->type == 1) continue; @@ -388,7 +388,7 @@ void Goblin::drawObjects(void) { if (objDesc->curFrame == sndFrame) { if (sndItem != 0xff) { - playSound(soundData[sndItem], + playSound(_soundData[sndItem], repCount, freq); } } @@ -400,7 +400,7 @@ void Goblin::drawObjects(void) { if (objDesc->curFrame == sndFrame) { if (sndItem != 0xff) { - playSound(soundData[sndItem], + playSound(_soundData[sndItem], repCount, freq); } } @@ -413,7 +413,7 @@ void Goblin::drawObjects(void) { if (objDesc->curFrame == sndFrame) { if (sndItem != -1) { - playSound(soundData[sndItem], + playSound(_soundData[sndItem], repCount, freq); } } @@ -429,7 +429,7 @@ void Goblin::animateObjects(void) { Scenery::AnimLayer *pLayer; int16 layer; - for (node = objList->pHead; node != 0; node = node->pNext) { + for (node = _objList->pHead; node != 0; node = node->pNext) { objDesc = (Gob_Object *) node->pData; if (objDesc->doAnim != 1 || objDesc->type != 0) continue; @@ -465,7 +465,7 @@ void Goblin::animateObjects(void) { if (objDesc->multState != -1) { if (objDesc->multState > 39) { - objDesc->stateMach = goblins[(int)(objDesc->multObjIndex)]->stateMach; + objDesc->stateMach = _goblins[(int)(objDesc->multObjIndex)]->stateMach; objDesc->state = objDesc->multState - 40; } else { objDesc->stateMach = objDesc->realStateMach; @@ -533,7 +533,7 @@ void Goblin::placeObject(Gob_Object *objDesc, char animated) { objDesc->dirtyTop = objDesc->yPos; objDesc->dirtyBottom = objDesc->yPos; - _vm->_util->listInsertBack(objList, objDesc); + _vm->_util->listInsertBack(_objList, objDesc); } } @@ -565,7 +565,7 @@ int16 Goblin::objIntersected(Gob_Object *obj1, Gob_Object *obj2) { } void Goblin::setMultStates(Gob_Object * gobDesc) { - gobDesc->stateMach = goblins[(int)gobDesc->multObjIndex]->stateMach; + gobDesc->stateMach = _goblins[(int)gobDesc->multObjIndex]->stateMach; } int16 Goblin::nextLayer(Gob_Object *gobDesc) { @@ -599,7 +599,7 @@ void Goblin::showBoredom(int16 gobIndex) { int16 state; int16 boreFlag; - gobDesc = goblins[gobIndex]; + gobDesc = _goblins[gobIndex]; layer = gobDesc->stateMach[gobDesc->state][0]->layer; frameCount = @@ -612,7 +612,7 @@ void Goblin::showBoredom(int16 gobIndex) { boreFlag = 1 << _vm->_util->getRandom(7); - if (gobIndex != currentGoblin && _vm->_util->getRandom(3) != 0) { + if (gobIndex != _currentGoblin && _vm->_util->getRandom(3) != 0) { if (state == 21) { if ((boreFlag & 16) || (boreFlag & 32)) { gobDesc->multState = 92 + gobIndex; @@ -648,15 +648,15 @@ void Goblin::switchGoblin(int16 index) { if (VAR(59) != 0) return; - if (goblins[currentGoblin]->state <= 39 && - goblins[currentGoblin]->curFrame != 0) + if (_goblins[_currentGoblin]->state <= 39 && + _goblins[_currentGoblin]->curFrame != 0) return; - if (index != 0 && goblins[index - 1]->type != 0) + if (index != 0 && _goblins[index - 1]->type != 0) return; if (index == 0) - next = (currentGoblin + 1) % 3; + next = (_currentGoblin + 1) % 3; else next = index - 1; @@ -664,46 +664,46 @@ void Goblin::switchGoblin(int16 index) { _vm->_map->_passMap[_vm->_map->_curGoblinY][_vm->_map->_curGoblinX] == 6) return; - if (goblins[(currentGoblin + 1) % 3]->type != 0 && - goblins[(currentGoblin + 2) % 3]->type != 0) + if (_goblins[(_currentGoblin + 1) % 3]->type != 0 && + _goblins[(_currentGoblin + 2) % 3]->type != 0) return; - gobPositions[currentGoblin].x = _vm->_map->_curGoblinX; - gobPositions[currentGoblin].y = _vm->_map->_curGoblinY; + _gobPositions[_currentGoblin].x = _vm->_map->_curGoblinX; + _gobPositions[_currentGoblin].y = _vm->_map->_curGoblinY; - goblins[currentGoblin]->doAnim = 1; - goblins[currentGoblin]->nextState = 21; + _goblins[_currentGoblin]->doAnim = 1; + _goblins[_currentGoblin]->nextState = 21; - nextLayer(goblins[currentGoblin]); + nextLayer(_goblins[_currentGoblin]); - currentGoblin = next; - if (goblins[currentGoblin]->type != 0) - currentGoblin = (currentGoblin + 1) % 3; + _currentGoblin = next; + if (_goblins[_currentGoblin]->type != 0) + _currentGoblin = (_currentGoblin + 1) % 3; - goblins[currentGoblin]->doAnim = 0; - if (goblins[currentGoblin]->curLookDir == 4) - goblins[currentGoblin]->nextState = 18; + _goblins[_currentGoblin]->doAnim = 0; + if (_goblins[_currentGoblin]->curLookDir == 4) + _goblins[_currentGoblin]->nextState = 18; else - goblins[currentGoblin]->nextState = 19; + _goblins[_currentGoblin]->nextState = 19; - goblins[currentGoblin]->toRedraw = 1; - nextLayer(goblins[currentGoblin]); + _goblins[_currentGoblin]->toRedraw = 1; + nextLayer(_goblins[_currentGoblin]); - tmp = gobPositions[currentGoblin].x; - pressedMapX = tmp; + tmp = _gobPositions[_currentGoblin].x; + _pressedMapX = tmp; _vm->_map->_destX = tmp; - gobDestX = tmp; + _gobDestX = tmp; _vm->_map->_curGoblinX = tmp; - tmp = gobPositions[currentGoblin].y; - pressedMapY = tmp; + tmp = _gobPositions[_currentGoblin].y; + _pressedMapY = tmp; _vm->_map->_destY = tmp; - gobDestY = tmp; + _gobDestY = tmp; _vm->_map->_curGoblinY = tmp; - *curGobVarPtr = currentGoblin; - pathExistence = 0; - readyToAct = 0; + *_curGobVarPtr = _currentGoblin; + _pathExistence = 0; + _readyToAct = 0; } void Goblin::adjustDest(int16 posX, int16 posY) { @@ -713,30 +713,30 @@ void Goblin::adjustDest(int16 posX, int16 posY) { int16 deltaPix; int16 i; - if (_vm->_map->_passMap[pressedMapY][pressedMapX] == 0 && - (gobAction == 0 - || _vm->_map->_itemsMap[pressedMapY][pressedMapX] == 0)) { + if (_vm->_map->_passMap[_pressedMapY][_pressedMapX] == 0 && + (_gobAction == 0 + || _vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0)) { resDelta = -1; resDeltaDir = 0; resDeltaPix = 0; for (i = 1; - i <= pressedMapX - && _vm->_map->_passMap[pressedMapY][pressedMapX - i] == 0; + i <= _pressedMapX + && _vm->_map->_passMap[_pressedMapY][_pressedMapX - i] == 0; i++); - if (i <= pressedMapX) { + if (i <= _pressedMapX) { resDeltaPix = (i - 1) * 12 + (posX % 12) + 1; resDelta = i; } for (i = 1; - (i + pressedMapX) < Map::kMapWidth - && _vm->_map->_passMap[pressedMapY][pressedMapX + i] == 0; + (i + _pressedMapX) < Map::kMapWidth + && _vm->_map->_passMap[_pressedMapY][_pressedMapX + i] == 0; i++); - if (pressedMapX + i < Map::kMapWidth) { + if (_pressedMapX + i < Map::kMapWidth) { deltaPix = (i * 12) - (posX % 12); if (resDelta == -1 || deltaPix < resDeltaPix) { resDeltaPix = deltaPix; @@ -746,11 +746,11 @@ void Goblin::adjustDest(int16 posX, int16 posY) { } for (i = 1; - (i + pressedMapY) < Map::kMapHeight - && _vm->_map->_passMap[pressedMapY + i][pressedMapX] == 0; + (i + _pressedMapY) < Map::kMapHeight + && _vm->_map->_passMap[_pressedMapY + i][_pressedMapX] == 0; i++); - if (pressedMapY + i < Map::kMapHeight) { + if (_pressedMapY + i < Map::kMapHeight) { deltaPix = (i * 6) - (posY % 6); if (resDelta == -1 || deltaPix < resDeltaPix) { resDeltaPix = deltaPix; @@ -760,11 +760,11 @@ void Goblin::adjustDest(int16 posX, int16 posY) { } for (i = 1; - i <= pressedMapY - && _vm->_map->_passMap[pressedMapY - i][pressedMapX] == 0; + i <= _pressedMapY + && _vm->_map->_passMap[_pressedMapY - i][_pressedMapX] == 0; i++); - if (i <= pressedMapY) { + if (i <= _pressedMapY) { deltaPix = (i * 6) + (posY % 6); if (resDelta == -1 || deltaPix < resDeltaPix) { resDeltaPix = deltaPix; @@ -775,19 +775,19 @@ void Goblin::adjustDest(int16 posX, int16 posY) { switch (resDeltaDir) { case 0: - pressedMapX -= resDelta; + _pressedMapX -= resDelta; break; case 1: - pressedMapX += resDelta; + _pressedMapX += resDelta; break; case 2: - pressedMapY += resDelta; + _pressedMapY += resDelta; break; case 3: - pressedMapY -= resDelta; + _pressedMapY -= resDelta; break; } @@ -795,36 +795,36 @@ void Goblin::adjustDest(int16 posX, int16 posY) { } void Goblin::adjustTarget(void) { - if (gobAction == 4 - && _vm->_map->_itemsMap[pressedMapY][pressedMapX] == 0) { + if (_gobAction == 4 + && _vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0) { - if (pressedMapY > 0 - && _vm->_map->_itemsMap[pressedMapY - 1][pressedMapX] != + if (_pressedMapY > 0 + && _vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX] != 0) { - pressedMapY--; - } else if (pressedMapX < Map::kMapWidth - 1 - && _vm->_map->_itemsMap[pressedMapY][pressedMapX + 1] != + _pressedMapY--; + } else if (_pressedMapX < Map::kMapWidth - 1 + && _vm->_map->_itemsMap[_pressedMapY][_pressedMapX + 1] != 0) { - pressedMapX++; - } else if (pressedMapX < Map::kMapWidth - 1 && pressedMapY > 0 - && _vm->_map->_itemsMap[pressedMapY - 1][pressedMapX + + _pressedMapX++; + } else if (_pressedMapX < Map::kMapWidth - 1 && _pressedMapY > 0 + && _vm->_map->_itemsMap[_pressedMapY - 1][_pressedMapX + 1] != 0) { - pressedMapY--; - pressedMapX++; + _pressedMapY--; + _pressedMapX++; } } } void Goblin::targetDummyItem(Gob_Object *gobDesc) { - if (_vm->_map->_itemsMap[pressedMapY][pressedMapX] == 0 && - _vm->_map->_passMap[pressedMapY][pressedMapX] == 1) { + if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0 && + _vm->_map->_passMap[_pressedMapY][_pressedMapX] == 1) { if (gobDesc->curLookDir == 0) { - _vm->_map->_itemPoses[0].x = pressedMapX; - _vm->_map->_itemPoses[0].y = pressedMapY; + _vm->_map->_itemPoses[0].x = _pressedMapX; + _vm->_map->_itemPoses[0].y = _pressedMapY; _vm->_map->_itemPoses[0].orient = -4; } else { - _vm->_map->_itemPoses[0].x = pressedMapX; - _vm->_map->_itemPoses[0].y = pressedMapY; + _vm->_map->_itemPoses[0].x = _pressedMapX; + _vm->_map->_itemPoses[0].y = _pressedMapY; _vm->_map->_itemPoses[0].orient = -1; } } @@ -839,106 +839,106 @@ void Goblin::targetItem(void) { int16 tmpPosY; Gob_Object *itemDesc; - if (gobAction == 3 || gobAction == 4) { - items = _vm->_map->_itemsMap[pressedMapY][pressedMapX]; - if (gobAction == 4 && (items & 0xff00) != 0 && - objects[itemToObject[(items & 0xff00) >> 8]]-> + if (_gobAction == 3 || _gobAction == 4) { + items = _vm->_map->_itemsMap[_pressedMapY][_pressedMapX]; + if (_gobAction == 4 && (items & 0xff00) != 0 && + _objects[_itemToObject[(items & 0xff00) >> 8]]-> pickable == 1) { - destItemId = (items & 0xff00) >> 8; - destActionItem = (items & 0xff00) >> 8; - itemByteFlag = 1; + _destItemId = (items & 0xff00) >> 8; + _destActionItem = (items & 0xff00) >> 8; + _itemByteFlag = 1; } else if ((items & 0xff) == 0) { - destItemId = (items & 0xff00) >> 8; - destActionItem = (items & 0xff00) >> 8; - itemByteFlag = 1; - } else if (gobAction == 3 && currentGoblin == 2 && + _destItemId = (items & 0xff00) >> 8; + _destActionItem = (items & 0xff00) >> 8; + _itemByteFlag = 1; + } else if (_gobAction == 3 && _currentGoblin == 2 && (items & 0xff00) != 0) { - destItemId = (items & 0xff00) >> 8; - destActionItem = (items & 0xff00) >> 8; - itemByteFlag = 1; + _destItemId = (items & 0xff00) >> 8; + _destActionItem = (items & 0xff00) >> 8; + _itemByteFlag = 1; } else { - destItemId = items & 0xff; - destActionItem = items & 0xff; - itemByteFlag = 0; + _destItemId = items & 0xff; + _destActionItem = items & 0xff; + _itemByteFlag = 0; } - pressedMapY = _vm->_map->_itemPoses[destItemId].y; - _vm->_map->_destY = _vm->_map->_itemPoses[destItemId].y; - gobDestY = _vm->_map->_itemPoses[destItemId].y; + _pressedMapY = _vm->_map->_itemPoses[_destItemId].y; + _vm->_map->_destY = _vm->_map->_itemPoses[_destItemId].y; + _gobDestY = _vm->_map->_itemPoses[_destItemId].y; - if (gobAction == 3 || destActionItem == 0) { - pressedMapX = _vm->_map->_itemPoses[destItemId].x; - _vm->_map->_destX = _vm->_map->_itemPoses[destItemId].x; - gobDestX = _vm->_map->_itemPoses[destItemId].x; + if (_gobAction == 3 || _destActionItem == 0) { + _pressedMapX = _vm->_map->_itemPoses[_destItemId].x; + _vm->_map->_destX = _vm->_map->_itemPoses[_destItemId].x; + _gobDestX = _vm->_map->_itemPoses[_destItemId].x; } else if ((items & 0xff00) != 0) { - if (_vm->_map->_itemPoses[destItemId].orient == 4) { - if ((_vm->_map->_itemsMap[pressedMapY] - [pressedMapX - 1] & 0xff00) == - (_vm->_map->_itemsMap[pressedMapY] - [pressedMapX] & 0xff00)) { - pressedMapX--; - _vm->_map->_destX = pressedMapX; - gobDestX = pressedMapX; + if (_vm->_map->_itemPoses[_destItemId].orient == 4) { + if ((_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX - 1] & 0xff00) == + (_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX] & 0xff00)) { + _pressedMapX--; + _vm->_map->_destX = _pressedMapX; + _gobDestX = _pressedMapX; } - } else if (_vm->_map->_itemPoses[destItemId].orient == 0) { - - if ((_vm->_map->_itemsMap[pressedMapY] - [pressedMapX + 1] & 0xff00) == - (_vm->_map->_itemsMap[pressedMapY] - [pressedMapX] & 0xff00)) { - pressedMapX++; - _vm->_map->_destX = pressedMapX; - gobDestX = pressedMapX; + } else if (_vm->_map->_itemPoses[_destItemId].orient == 0) { + + if ((_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX + 1] & 0xff00) == + (_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX] & 0xff00)) { + _pressedMapX++; + _vm->_map->_destX = _pressedMapX; + _gobDestX = _pressedMapX; } } - if ((_vm->_map->_itemsMap[pressedMapY + - 1][pressedMapX] & 0xff00) == - (_vm->_map->_itemsMap[pressedMapY][pressedMapX] & + if ((_vm->_map->_itemsMap[_pressedMapY + + 1][_pressedMapX] & 0xff00) == + (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX] & 0xff00)) { - pressedMapY++; - _vm->_map->_destY = pressedMapY; - gobDestY = pressedMapY; + _pressedMapY++; + _vm->_map->_destY = _pressedMapY; + _gobDestY = _pressedMapY; } } else { - if (_vm->_map->_itemPoses[destItemId].orient == 4) { - if ((_vm->_map->_itemsMap[pressedMapY] - [pressedMapX - 1]) == - (_vm->_map->_itemsMap[pressedMapY] - [pressedMapX])) { - pressedMapX--; - _vm->_map->_destX = pressedMapX; - gobDestX = pressedMapX; + if (_vm->_map->_itemPoses[_destItemId].orient == 4) { + if ((_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX - 1]) == + (_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX])) { + _pressedMapX--; + _vm->_map->_destX = _pressedMapX; + _gobDestX = _pressedMapX; } - } else if (_vm->_map->_itemPoses[destItemId].orient == 0) { - - if ((_vm->_map->_itemsMap[pressedMapY] - [pressedMapX + 1]) == - (_vm->_map->_itemsMap[pressedMapY] - [pressedMapX])) { - pressedMapX++; - _vm->_map->_destX = pressedMapX; - gobDestX = pressedMapX; + } else if (_vm->_map->_itemPoses[_destItemId].orient == 0) { + + if ((_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX + 1]) == + (_vm->_map->_itemsMap[_pressedMapY] + [_pressedMapX])) { + _pressedMapX++; + _vm->_map->_destX = _pressedMapX; + _gobDestX = _pressedMapX; } } - if ((_vm->_map->_itemsMap[pressedMapY + - 1][pressedMapX]) == - (_vm->_map->_itemsMap[pressedMapY][pressedMapX])) { - pressedMapY++; - _vm->_map->_destY = pressedMapY; - gobDestY = pressedMapY; + if ((_vm->_map->_itemsMap[_pressedMapY + + 1][_pressedMapX]) == + (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX])) { + _pressedMapY++; + _vm->_map->_destY = _pressedMapY; + _gobDestY = _pressedMapY; } } - if (gobAction == 4 && destActionItem != 0 && - itemToObject[destActionItem] != -1 && - objects[itemToObject[destActionItem]]-> + if (_gobAction == 4 && _destActionItem != 0 && + _itemToObject[_destActionItem] != -1 && + _objects[_itemToObject[_destActionItem]]-> pickable == 1) { itemDesc = - objects[itemToObject[destActionItem]]; + _objects[_itemToObject[_destActionItem]]; itemDesc->animation = itemDesc->stateMach[itemDesc->state][0]->animation; @@ -960,19 +960,19 @@ void Goblin::targetItem(void) { if ((tmpX % 12) < 6 && tmpPosX > 0) tmpPosX--; - if (_vm->_map->_itemPoses[destActionItem].orient == 0 || - _vm->_map->_itemPoses[destActionItem].orient == -1) { + if (_vm->_map->_itemPoses[_destActionItem].orient == 0 || + _vm->_map->_itemPoses[_destActionItem].orient == -1) { tmpPosX++; } if (_vm->_map->_passMap[tmpPosY][tmpPosX] == 1) { - pressedMapX = tmpPosX; + _pressedMapX = tmpPosX; _vm->_map->_destX = tmpPosX; - gobDestX = tmpPosX; + _gobDestX = tmpPosX; - pressedMapY = tmpPosY; + _pressedMapY = tmpPosY; _vm->_map->_destY = tmpPosY; - gobDestY = tmpPosY; + _gobDestY = tmpPosY; } } } @@ -983,14 +983,14 @@ void Goblin::initiateMove(void) { _vm->_map->findNearestToGob(); _vm->_map->optimizePoints(); - pathExistence = _vm->_map->checkDirectPath(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY, - pressedMapX, pressedMapY); + _pathExistence = _vm->_map->checkDirectPath(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY, + _pressedMapX, _pressedMapY); - if (pathExistence == 3) { + if (_pathExistence == 3) { if (_vm->_map->checkLongPath(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY, - pressedMapX, pressedMapY, + _pressedMapX, _pressedMapY, _vm->_map->_nearestWayPoint, _vm->_map->_nearestDest) == 0) { - pathExistence = 0; + _pathExistence = 0; } else { _vm->_map->_destX = _vm->_map->_wayPoints[_vm->_map->_nearestWayPoint].x; _vm->_map->_destY = _vm->_map->_wayPoints[_vm->_map->_nearestWayPoint].y; @@ -1000,80 +1000,80 @@ void Goblin::initiateMove(void) { void Goblin::moveFindItem(int16 posX, int16 posY) { int16 i; - if (gobAction == 3 || gobAction == 4) { + if (_gobAction == 3 || _gobAction == 4) { for (i = 0; i < 20; i++) { - if (objects[i] == 0) + if (_objects[i] == 0) continue; - if (objects[i]->type != 0) + if (_objects[i]->type != 0) continue; - if (objects[i]->left > posX) + if (_objects[i]->left > posX) continue; - if (objects[i]->right < posX) + if (_objects[i]->right < posX) continue; - if (objects[i]->top > posY) + if (_objects[i]->top > posY) continue; - if (objects[i]->bottom < posY) + if (_objects[i]->bottom < posY) continue; - if (objects[i]->right - objects[i]->left < 40) + if (_objects[i]->right - _objects[i]->left < 40) posX = - (objects[i]->left + - objects[i]->right) / 2; + (_objects[i]->left + + _objects[i]->right) / 2; - if (objects[i]->bottom - objects[i]->top < 40) + if (_objects[i]->bottom - _objects[i]->top < 40) posY = - (objects[i]->top + - objects[i]->bottom) / 2; + (_objects[i]->top + + _objects[i]->bottom) / 2; break; } - pressedMapX = posX / 12; - pressedMapY = posY / 6; + _pressedMapX = posX / 12; + _pressedMapY = posY / 6; - if (_vm->_map->_itemsMap[pressedMapY][pressedMapX] == 0 + if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX] == 0 && i < 20) { - if (_vm->_map->_itemsMap[pressedMapY + - 1][pressedMapX] != 0) { - pressedMapY++; - } else if (_vm->_map->_itemsMap[pressedMapY + - 1][pressedMapX + 1] != 0) { - pressedMapX++; - pressedMapY++; + if (_vm->_map->_itemsMap[_pressedMapY + + 1][_pressedMapX] != 0) { + _pressedMapY++; + } else if (_vm->_map->_itemsMap[_pressedMapY + + 1][_pressedMapX + 1] != 0) { + _pressedMapX++; + _pressedMapY++; } else - if (_vm->_map->_itemsMap[pressedMapY][pressedMapX + + if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX + 1] != 0) { - pressedMapX++; - } else if (_vm->_map->_itemsMap[pressedMapY - - 1][pressedMapX + 1] != 0) { - pressedMapX++; - pressedMapY--; - } else if (_vm->_map->_itemsMap[pressedMapY - - 1][pressedMapX] != 0) { - pressedMapY--; - } else if (_vm->_map->_itemsMap[pressedMapY - - 1][pressedMapX - 1] != 0) { - pressedMapY--; - pressedMapX--; + _pressedMapX++; + } else if (_vm->_map->_itemsMap[_pressedMapY - + 1][_pressedMapX + 1] != 0) { + _pressedMapX++; + _pressedMapY--; + } else if (_vm->_map->_itemsMap[_pressedMapY - + 1][_pressedMapX] != 0) { + _pressedMapY--; + } else if (_vm->_map->_itemsMap[_pressedMapY - + 1][_pressedMapX - 1] != 0) { + _pressedMapY--; + _pressedMapX--; } else - if (_vm->_map->_itemsMap[pressedMapY][pressedMapX - + if (_vm->_map->_itemsMap[_pressedMapY][_pressedMapX - 1] != 0) { - pressedMapX--; - } else if (_vm->_map->_itemsMap[pressedMapY + - 1][pressedMapX - 1] != 0) { - pressedMapX--; - pressedMapY++; + _pressedMapX--; + } else if (_vm->_map->_itemsMap[_pressedMapY + + 1][_pressedMapX - 1] != 0) { + _pressedMapX--; + _pressedMapY++; } } } else { - pressedMapX = posX / 12; - pressedMapY = posY / 6; + _pressedMapX = posX / 12; + _pressedMapY = posY / 6; } } @@ -1082,26 +1082,26 @@ void Goblin::moveCheckSelect(int16 framesCount, Gob_Object * gobDesc, int16 *pGo if (gobDesc->right > _vm->_global->_inter_mouseX && gobDesc->left < _vm->_global->_inter_mouseX && gobDesc->bottom > _vm->_global->_inter_mouseY && - gobDesc->bottom - 10 < _vm->_global->_inter_mouseY && gobAction == 0) { + gobDesc->bottom - 10 < _vm->_global->_inter_mouseY && _gobAction == 0) { if (gobDesc->curLookDir & 4) *nextAct = 16; else *nextAct = 23; gobDesc->curFrame = framesCount - 1; - pathExistence = 0; + _pathExistence = 0; } else { *pGobIndex = peekGoblin(gobDesc); if (*pGobIndex != 0) { - pathExistence = 0; - } else if (_vm->_map->_curGoblinX == pressedMapX && - _vm->_map->_curGoblinY == pressedMapY) { + _pathExistence = 0; + } else if (_vm->_map->_curGoblinX == _pressedMapX && + _vm->_map->_curGoblinY == _pressedMapY) { - if (gobAction != 0) - readyToAct = 1; + if (_gobAction != 0) + _readyToAct = 1; - pathExistence = 0; + _pathExistence = 0; } } } @@ -1111,18 +1111,18 @@ void Goblin::moveInitStep(int16 framesCount, int16 action, int16 cont, int16 posX; int16 posY; - if (cont != 0 && goesAtTarget == 0 && - readyToAct == 0 && VAR(59) == 0 && + if (cont != 0 && _goesAtTarget == 0 && + _readyToAct == 0 && VAR(59) == 0 && gobDesc->type != 1 && gobDesc->state != 10 && gobDesc->state != 11) { if (gobDesc->state >= 40) { gobDesc->curFrame = framesCount - 1; } - gobAction = action; - forceNextState[0] = -1; - forceNextState[1] = -1; - forceNextState[2] = -1; + _gobAction = action; + _forceNextState[0] = -1; + _forceNextState[1] = -1; + _forceNextState[2] = -1; if (action == 3) { posX = _vm->_global->_inter_mouseX + 6; @@ -1139,11 +1139,11 @@ void Goblin::moveInitStep(int16 framesCount, int16 action, int16 cont, adjustDest(posX, posY); adjustTarget(); - _vm->_map->_destX = pressedMapX; - gobDestX = pressedMapX; + _vm->_map->_destX = _pressedMapX; + _gobDestX = _pressedMapX; - _vm->_map->_destY = pressedMapY; - gobDestY = pressedMapY; + _vm->_map->_destY = _pressedMapY; + _gobDestY = _pressedMapY; targetDummyItem(gobDesc); @@ -1153,10 +1153,10 @@ void Goblin::moveInitStep(int16 framesCount, int16 action, int16 cont, moveCheckSelect(framesCount, gobDesc, pGobIndex, pNextAct); } else { - if (readyToAct != 0 && - (_vm->_map->_curGoblinX != pressedMapX || - _vm->_map->_curGoblinY != pressedMapY)) - readyToAct = 0; + if (_readyToAct != 0 && + (_vm->_map->_curGoblinX != _pressedMapX || + _vm->_map->_curGoblinY != _pressedMapY)) + _readyToAct = 0; if (gobDesc->type == 1) { *pGobIndex = peekGoblin(gobDesc); @@ -1165,19 +1165,19 @@ void Goblin::moveInitStep(int16 framesCount, int16 action, int16 cont, } void Goblin::moveTreatRopeStairs(Gob_Object *gobDesc) { - if (currentGoblin != 1) + if (_currentGoblin != 1) return; if (gobDesc->nextState == 28 && _vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX] == 6) { - forceNextState[0] = 28; - forceNextState[1] = -1; + _forceNextState[0] = 28; + _forceNextState[1] = -1; } if (gobDesc->nextState == 29 && _vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX] == 6) { - forceNextState[0] = 29; - forceNextState[1] = -1; + _forceNextState[0] = 29; + _forceNextState[1] = -1; } if ((gobDesc->nextState == 28 || gobDesc->nextState == 29 @@ -1186,27 +1186,27 @@ void Goblin::moveTreatRopeStairs(Gob_Object *gobDesc) { if ((gobDesc->curLookDir == 0 || gobDesc->curLookDir == 4 || gobDesc->curLookDir == 2) && _vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX] == 6) { - forceNextState[0] = 28; - forceNextState[1] = -1; + _forceNextState[0] = 28; + _forceNextState[1] = -1; } else if ((gobDesc->curLookDir == 0 || gobDesc->curLookDir == 4 || gobDesc->curLookDir == 6) && _vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX] == 6) { - forceNextState[0] = 29; - forceNextState[1] = -1; + _forceNextState[0] = 29; + _forceNextState[1] = -1; } } if (gobDesc->nextState == 8 && _vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX] == 3) { - forceNextState[0] = 8; - forceNextState[1] = -1; + _forceNextState[0] = 8; + _forceNextState[1] = -1; } if (gobDesc->nextState == 9 && _vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX] == 3) { - forceNextState[0] = 9; - forceNextState[1] = -1; + _forceNextState[0] = 9; + _forceNextState[1] = -1; } if (gobDesc->nextState == 20 @@ -1214,49 +1214,49 @@ void Goblin::moveTreatRopeStairs(Gob_Object *gobDesc) { if ((gobDesc->curLookDir == 0 || gobDesc->curLookDir == 4 || gobDesc->curLookDir == 2) && _vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX] == 3) { - forceNextState[0] = 8; - forceNextState[1] = -1; + _forceNextState[0] = 8; + _forceNextState[1] = -1; } else if ((gobDesc->curLookDir == 0 || gobDesc->curLookDir == 4 || gobDesc->curLookDir == 6) && _vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX] == 3) { - forceNextState[0] = 9; - forceNextState[1] = -1; + _forceNextState[0] = 9; + _forceNextState[1] = -1; } } } void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { - if (pathExistence == 1) { - _vm->_map->_curGoblinX = gobPositions[currentGoblin].x; - _vm->_map->_curGoblinY = gobPositions[currentGoblin].y; + if (_pathExistence == 1) { + _vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x; + _vm->_map->_curGoblinY = _gobPositions[_currentGoblin].y; - if (_vm->_map->_curGoblinX == pressedMapX && - _vm->_map->_curGoblinY == pressedMapY && gobAction != 0) { - readyToAct = 1; - pathExistence = 0; + if (_vm->_map->_curGoblinX == _pressedMapX && + _vm->_map->_curGoblinY == _pressedMapY && _gobAction != 0) { + _readyToAct = 1; + _pathExistence = 0; } nextAct = _vm->_map->getDirection(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY, _vm->_map->_destX, _vm->_map->_destY); if (nextAct == 0) - pathExistence = 0; - } else if (pathExistence == 3) { - _vm->_map->_curGoblinX = gobPositions[currentGoblin].x; - _vm->_map->_curGoblinY = gobPositions[currentGoblin].y; - - if (_vm->_map->_curGoblinX == gobDestX && _vm->_map->_curGoblinY == gobDestY) { - pathExistence = 1; - _vm->_map->_destX = pressedMapX; - _vm->_map->_destY = pressedMapY; + _pathExistence = 0; + } else if (_pathExistence == 3) { + _vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x; + _vm->_map->_curGoblinY = _gobPositions[_currentGoblin].y; + + if (_vm->_map->_curGoblinX == _gobDestX && _vm->_map->_curGoblinY == _gobDestY) { + _pathExistence = 1; + _vm->_map->_destX = _pressedMapX; + _vm->_map->_destY = _pressedMapY; } else { if (_vm->_map->checkDirectPath(_vm->_map->_curGoblinX, _vm->_map->_curGoblinY, - gobDestX, gobDestY) == 1) { - _vm->_map->_destX = gobDestX; - _vm->_map->_destY = gobDestY; + _gobDestX, _gobDestY) == 1) { + _vm->_map->_destX = _gobDestX; + _vm->_map->_destY = _gobDestY; } else if (_vm->_map->_curGoblinX == _vm->_map->_destX && _vm->_map->_curGoblinY == _vm->_map->_destY) { if (_vm->_map->_nearestWayPoint > _vm->_map->_nearestDest) { @@ -1285,14 +1285,14 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { _vm->_map->_nearestWayPoint++; } else { if (_vm->_map->checkDirectPath(_vm->_map->_curGoblinX, - _vm->_map->_curGoblinY, gobDestX, - gobDestY) == 3 && _vm->_map->_passMap[pressedMapY][pressedMapX] != 0) { + _vm->_map->_curGoblinY, _gobDestX, + _gobDestY) == 3 && _vm->_map->_passMap[_pressedMapY][_pressedMapX] != 0) { _vm->_map->_destX = _vm->_map->_wayPoints[_vm->_map->_nearestWayPoint].x; _vm->_map->_destY = _vm->_map->_wayPoints[_vm->_map->_nearestWayPoint].y; } else { - pathExistence = 1; - _vm->_map->_destX = pressedMapX; - _vm->_map->_destY = pressedMapY; + _pathExistence = 1; + _vm->_map->_destX = _pressedMapX; + _vm->_map->_destY = _pressedMapY; } } } @@ -1302,7 +1302,7 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { } } - if (readyToAct != 0 && (gobAction == 3 || gobAction == 4)) + if (_readyToAct != 0 && (_gobAction == 3 || _gobAction == 4)) nextAct = 0x4dc8; switch (nextAct) { @@ -1324,8 +1324,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirN: if (_vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1335,7 +1335,7 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { } if (_vm->_map->_passMap[_vm->_map->_curGoblinY][_vm->_map->_curGoblinX] == 6 && - currentGoblin == 1) { + _currentGoblin == 1) { gobDesc->nextState = 28; break; } @@ -1345,8 +1345,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirS: if (_vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1356,7 +1356,7 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { } if (_vm->_map->_passMap[_vm->_map->_curGoblinY][_vm->_map->_curGoblinX] == 6 && - currentGoblin == 1) { + _currentGoblin == 1) { gobDesc->nextState = 29; break; } @@ -1366,8 +1366,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirSE: if (_vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX + 1] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1380,8 +1380,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirSW: if (_vm->_map->_passMap[_vm->_map->_curGoblinY + 1][_vm->_map->_curGoblinX - 1] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1394,8 +1394,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirNW: if (_vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX - 1] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1408,8 +1408,8 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case Map::kDirNE: if (_vm->_map->_passMap[_vm->_map->_curGoblinY - 1][_vm->_map->_curGoblinX + 1] == 6 && - currentGoblin != 1) { - pathExistence = 0; + _currentGoblin != 1) { + _pathExistence = 0; break; } @@ -1422,45 +1422,45 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { case 0x4dc8: - if (currentGoblin == 0 && gobAction == 3 - && itemIndInPocket == -1) { - destItemId = -1; - readyToAct = 0; + if (_currentGoblin == 0 && _gobAction == 3 + && _itemIndInPocket == -1) { + _destItemId = -1; + _readyToAct = 0; break; } - if (currentGoblin == 0 && gobAction == 4 && - itemIndInPocket == -1 && destActionItem == 0) { + if (_currentGoblin == 0 && _gobAction == 4 && + _itemIndInPocket == -1 && _destActionItem == 0) { gobDesc->multState = 104; - destItemId = -1; - readyToAct = 0; + _destItemId = -1; + _readyToAct = 0; break; } - if (currentGoblin == 0 && gobAction == 4 && - itemIndInPocket == -1 && destActionItem != 0 && - itemToObject[destActionItem] != -1 && - objects[itemToObject[destActionItem]]-> + if (_currentGoblin == 0 && _gobAction == 4 && + _itemIndInPocket == -1 && _destActionItem != 0 && + _itemToObject[_destActionItem] != -1 && + _objects[_itemToObject[_destActionItem]]-> pickable == 0) { gobDesc->multState = 104; - destItemId = -1; - readyToAct = 0; + _destItemId = -1; + _readyToAct = 0; break; } - switch (_vm->_map->_itemPoses[destActionItem].orient) { + switch (_vm->_map->_itemPoses[_destActionItem].orient) { case 0: case -4: gobDesc->nextState = 10; gobDesc->curLookDir = 0; - destItemId = -1; + _destItemId = -1; break; case -1: case 4: gobDesc->nextState = 11; gobDesc->curLookDir = 4; - destItemId = -1; + _destItemId = -1; break; } break; @@ -1468,7 +1468,7 @@ void Goblin::movePathFind(Gob_Object *gobDesc, int16 nextAct) { default: if (_vm->_map->_passMap[_vm->_map->_curGoblinY][_vm->_map->_curGoblinX] == 3 || (_vm->_map->_passMap[_vm->_map->_curGoblinY][_vm->_map->_curGoblinX] == 6 - && currentGoblin == 1)) { + && _currentGoblin == 1)) { gobDesc->nextState = 20; break; } @@ -1501,7 +1501,7 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) if (gobDesc->curFrame == 1) gobDesc->actionStartState = gobDesc->state; - if (goesAtTarget == 0 + if (_goesAtTarget == 0 && gobDesc->stateMach == gobDesc->realStateMach) { switch (gobDesc->state) { case 0: @@ -1523,7 +1523,7 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) break; case 28: - if (currentGoblin != 1) + if (_currentGoblin != 1) break; gobDesc->curLookDir = 2; break; @@ -1537,7 +1537,7 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) break; case 29: - if (currentGoblin != 1) + if (_currentGoblin != 1) break; gobDesc->curLookDir = 6; @@ -1559,22 +1559,22 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) _vm->_snd->speakerOn(10 * _vm->_util->getRandom(3) + 50, 5); } - if (currentGoblin == 0 + if (_currentGoblin == 0 && gobDesc->stateMach == gobDesc->realStateMach && (gobDesc->state == 10 || gobDesc->state == 11) && gobDesc->curFrame == 9) { _vm->_snd->stopSound(0); - if (itemIndInPocket != -1) { - _vm->_snd->playSample(soundData[14], 1, 9000); + if (_itemIndInPocket != -1) { + _vm->_snd->playSample(_soundData[14], 1, 9000); } - if (itemIndInPocket == -1) { - _vm->_snd->playSample(soundData[14], 1, 5000); + if (_itemIndInPocket == -1) { + _vm->_snd->playSample(_soundData[14], 1, 5000); } } - if (boreCounter++ == 120) { - boreCounter = 0; + if (_boreCounter++ == 120) { + _boreCounter = 0; for (i = 0; i < 3; i++) showBoredom(i); } @@ -1586,13 +1586,13 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) newX = _vm->_scenery->animations[gobDesc->animation]. - layers[gobStateLayer]->animDeltaX + gobDesc->xPos; + layers[_gobStateLayer]->animDeltaX + gobDesc->xPos; newY = _vm->_scenery->animations[gobDesc->animation]. - layers[gobStateLayer]->animDeltaY + gobDesc->yPos; + layers[_gobStateLayer]->animDeltaY + gobDesc->yPos; - gobStateLayer = nextLayer(gobDesc); + _gobStateLayer = nextLayer(gobDesc); gobDesc->xPos = newX; gobDesc->yPos = newY; @@ -1600,79 +1600,79 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) if (gobDesc->curFrame == 3 && gobDesc->stateMach == gobDesc->realStateMach && (gobDesc->state < 10 || - (currentGoblin == 1 && (gobDesc->state == 28 + (_currentGoblin == 1 && (gobDesc->state == 28 || gobDesc->state == 29)) )) { flag = 0; - if (forceNextState[0] != -1) { - gobDesc->nextState = forceNextState[0]; + if (_forceNextState[0] != -1) { + gobDesc->nextState = _forceNextState[0]; for (i = 0; i < 9; i++) - forceNextState[i] = - forceNextState[i + 1]; + _forceNextState[i] = + _forceNextState[i + 1]; } - _vm->_map->_curGoblinX = gobPositions[currentGoblin].x; - _vm->_map->_curGoblinY = gobPositions[currentGoblin].y; + _vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x; + _vm->_map->_curGoblinY = _gobPositions[_currentGoblin].y; if (gobDesc->nextState != gobDesc->state) { - gobStateLayer = nextLayer(gobDesc); + _gobStateLayer = nextLayer(gobDesc); flag = 1; } switch (gobDesc->state) { case 0: - gobPositions[currentGoblin].x--; + _gobPositions[_currentGoblin].x--; break; case 2: case 8: - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].y--; break; case 4: - gobPositions[currentGoblin].x++; + _gobPositions[_currentGoblin].x++; break; case 6: case 9: - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].y++; break; case 1: - gobPositions[currentGoblin].x--; - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].x--; + _gobPositions[_currentGoblin].y--; break; case 3: - gobPositions[currentGoblin].x++; - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].x++; + _gobPositions[_currentGoblin].y--; break; case 5: - gobPositions[currentGoblin].x++; - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].x++; + _gobPositions[_currentGoblin].y++; break; case 7: - gobPositions[currentGoblin].x--; - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].x--; + _gobPositions[_currentGoblin].y++; break; case 38: - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].y++; break; } - if (currentGoblin == 1) { + if (_currentGoblin == 1) { if (gobDesc->state == 28) - gobPositions[1].y--; + _gobPositions[1].y--; if (gobDesc->state == 29) - gobPositions[1].y++; + _gobPositions[1].y++; } if (flag != 0) { - _vm->_scenery->updateAnim(gobStateLayer, 0, + _vm->_scenery->updateAnim(_gobStateLayer, 0, gobDesc->animation, 0, gobDesc->xPos, gobDesc->yPos, 0); @@ -1685,79 +1685,79 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) } if ((gobDesc->state == 10 || gobDesc->state == 11) - && currentGoblin != 0) - goesAtTarget = 1; + && _currentGoblin != 0) + _goesAtTarget = 1; } if (gobDesc->curFrame != framesCount) return; - if (forceNextState[0] != -1) { - gobDesc->nextState = forceNextState[0]; + if (_forceNextState[0] != -1) { + gobDesc->nextState = _forceNextState[0]; for (i = 0; i < 10; i++) - forceNextState[i] = - forceNextState[i + 1]; + _forceNextState[i] = + _forceNextState[i + 1]; } - _vm->_map->_curGoblinX = gobPositions[currentGoblin].x; - _vm->_map->_curGoblinY = gobPositions[currentGoblin].y; + _vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x; + _vm->_map->_curGoblinY = _gobPositions[_currentGoblin].y; - gobStateLayer = nextLayer(gobDesc); + _gobStateLayer = nextLayer(gobDesc); if (gobDesc->stateMach == gobDesc->realStateMach) { switch (gobDesc->nextState) { case 0: - gobPositions[currentGoblin].x--; + _gobPositions[_currentGoblin].x--; break; case 2: case 8: - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].y--; break; case 4: - gobPositions[currentGoblin].x++; + _gobPositions[_currentGoblin].x++; break; case 6: case 9: - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].y++; break; case 1: - gobPositions[currentGoblin].x--; - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].x--; + _gobPositions[_currentGoblin].y--; break; case 3: - gobPositions[currentGoblin].x++; - gobPositions[currentGoblin].y--; + _gobPositions[_currentGoblin].x++; + _gobPositions[_currentGoblin].y--; break; case 5: - gobPositions[currentGoblin].x++; - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].x++; + _gobPositions[_currentGoblin].y++; break; case 7: - gobPositions[currentGoblin].x--; - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].x--; + _gobPositions[_currentGoblin].y++; break; case 38: - gobPositions[currentGoblin].y++; + _gobPositions[_currentGoblin].y++; break; } - if (currentGoblin == 1) { + if (_currentGoblin == 1) { if (gobDesc->nextState == 28) - gobPositions[1].y--; + _gobPositions[1].y--; if (gobDesc->nextState == 29) - gobPositions[1].y++; + _gobPositions[1].y++; } } - _vm->_scenery->updateAnim(gobStateLayer, 0, gobDesc->animation, 0, + _vm->_scenery->updateAnim(_gobStateLayer, 0, gobDesc->animation, 0, gobDesc->xPos, gobDesc->yPos, 0); gobDesc->yPos = @@ -1767,8 +1767,8 @@ void Goblin::moveAdvance(Gob_Object *gobDesc, int16 nextAct, int16 framesCount) _vm->_map->_curGoblinX * 12 - (_vm->_scenery->toRedrawLeft - _vm->_scenery->animLeft); if ((gobDesc->state == 10 || gobDesc->state == 11) - && currentGoblin != 0) - goesAtTarget = 1; + && _currentGoblin != 0) + _goesAtTarget = 1; } return; } @@ -1791,18 +1791,18 @@ int16 Goblin::doMove(Gob_Object *gobDesc, int16 cont, int16 action) { gobDesc->order = (gobDesc->bottom) / 24 + 3; } - if (positionedGob != currentGoblin) { - _vm->_map->_curGoblinX = gobPositions[currentGoblin].x; - _vm->_map->_curGoblinY = gobPositions[currentGoblin].y; + if (_positionedGob != _currentGoblin) { + _vm->_map->_curGoblinX = _gobPositions[_currentGoblin].x; + _vm->_map->_curGoblinY = _gobPositions[_currentGoblin].y; } - positionedGob = currentGoblin; + _positionedGob = _currentGoblin; gobDesc->animation = gobDesc->stateMach[gobDesc->state][gobDesc->stateColumn]-> animation; - gobStateLayer = + _gobStateLayer = gobDesc->stateMach[gobDesc->state][gobDesc->stateColumn]->layer; moveInitStep(framesCount, action, cont, gobDesc, &gobIndex, @@ -1819,54 +1819,54 @@ void Goblin::freeObjects(void) { int16 col; for (i = 0; i < 16; i++) { - if (soundData[i] == 0) + if (_soundData[i] == 0) continue; - _vm->_snd->freeSoundData(soundData[i]); - soundData[i] = 0; + _vm->_snd->freeSoundData(_soundData[i]); + _soundData[i] = 0; } for (i = 0; i < 4; i++) { - if (goblins[i] == 0) + if (_goblins[i] == 0) continue; - goblins[i]->stateMach = goblins[i]->realStateMach; + _goblins[i]->stateMach = _goblins[i]->realStateMach; for (state = 0; state < 40; state++) { for (col = 0; col < 6; col++) { - free(goblins[i]->stateMach[state][col]); - goblins[i]->stateMach[state][col] = 0; + free(_goblins[i]->stateMach[state][col]); + _goblins[i]->stateMach[state][col] = 0; } } if (i == 3) { for (state = 40; state < 70; state++) { - free(goblins[3]->stateMach[state][0]); - goblins[3]->stateMach[state][0] = 0; + free(_goblins[3]->stateMach[state][0]); + _goblins[3]->stateMach[state][0] = 0; } } - free(goblins[i]->stateMach); - free(goblins[i]); - goblins[i] = 0; + free(_goblins[i]->stateMach); + free(_goblins[i]); + _goblins[i] = 0; } for (i = 0; i < 20; i++) { - if (objects[i] == 0) + if (_objects[i] == 0) continue; - objects[i]->stateMach = objects[i]->realStateMach; + _objects[i]->stateMach = _objects[i]->realStateMach; for (state = 0; state < 40; state++) { for (col = 0; col < 6; col++) { - free(objects[i]->stateMach[state][col]); - objects[i]->stateMach[state][col] = 0; + free(_objects[i]->stateMach[state][col]); + _objects[i]->stateMach[state][col] = 0; } } - free(objects[i]->stateMach); - free(objects[i]); - objects[i] = 0; + free(_objects[i]->stateMach); + free(_objects[i]); + _objects[i] = 0; } } @@ -1874,17 +1874,17 @@ void Goblin::zeroObjects(void) { int16 i; for (i = 0; i < 4; i++) - goblins[i] = 0; + _goblins[i] = 0; for (i = 0; i < 20; i++) - objects[i] = 0; + _objects[i] = 0; for (i = 0; i < 16; i++) - soundData[i] = 0; + _soundData[i] = 0; } void Goblin::freeAllObjects(void) { - _vm->_util->deleteList(objList); + _vm->_util->deleteList(_objList); freeObjects(); } @@ -1893,7 +1893,7 @@ void Goblin::loadObjects(char *source) { zeroObjects(); for (i = 0; i < 20; i++) - itemToObject[i] = 100; + _itemToObject[i] = 100; freeObjects(); initList(); @@ -1902,190 +1902,190 @@ void Goblin::loadObjects(char *source) { _vm->_map->_sourceFile[strlen(_vm->_map->_sourceFile) - 4] = 0; _vm->_map->loadMapObjects(source); - for (i = 0; i < gobsCount; i++) - placeObject(goblins[i], 0); + for (i = 0; i < _gobsCount; i++) + placeObject(_goblins[i], 0); - for (i = 0; i < objCount; i++) { - placeObject(objects[i], 1); + for (i = 0; i < _objCount; i++) { + placeObject(_objects[i], 1); } initVarPointers(); - actDestItemDesc = 0; + _actDestItemDesc = 0; } void Goblin::saveGobDataToVars(int16 xPos, int16 yPos, int16 someVal) { Gob_Object *obj; - *some0ValPtr = someVal; - *curGobXPosVarPtr = xPos; - *curGobYPosVarPtr = yPos; - *itemInPocketVarPtr = itemIndInPocket; - - obj = goblins[currentGoblin]; - - *curGobStateVarPtr = obj->state; - *curGobFrameVarPtr = obj->curFrame; - *curGobMultStateVarPtr = obj->multState; - *curGobNextStateVarPtr = obj->nextState; - *curGobScrXVarPtr = obj->xPos; - *curGobScrYVarPtr = obj->yPos; - *curGobLeftVarPtr = obj->left; - *curGobTopVarPtr = obj->top; - *curGobRightVarPtr = obj->right; - *curGobBottomVarPtr = obj->bottom; - *curGobDoAnimVarPtr = obj->doAnim; - *curGobOrderVarPtr = obj->order; - *curGobNoTickVarPtr = obj->noTick; - *curGobTypeVarPtr = obj->type; - *curGobMaxTickVarPtr = obj->maxTick; - *curGobTickVarPtr = obj->tick; - *curGobActStartStateVarPtr = obj->actionStartState; - *curGobLookDirVarPtr = obj->curLookDir; - *curGobPickableVarPtr = obj->pickable; - *curGobRelaxVarPtr = obj->relaxTime; - *curGobMaxFrameVarPtr = getObjMaxFrame(obj); - - if (actDestItemDesc == 0) + *_some0ValPtr = someVal; + *_curGobXPosVarPtr = xPos; + *_curGobYPosVarPtr = yPos; + *_itemInPocketVarPtr = _itemIndInPocket; + + obj = _goblins[_currentGoblin]; + + *_curGobStateVarPtr = obj->state; + *_curGobFrameVarPtr = obj->curFrame; + *_curGobMultStateVarPtr = obj->multState; + *_curGobNextStateVarPtr = obj->nextState; + *_curGobScrXVarPtr = obj->xPos; + *_curGobScrYVarPtr = obj->yPos; + *_curGobLeftVarPtr = obj->left; + *_curGobTopVarPtr = obj->top; + *_curGobRightVarPtr = obj->right; + *_curGobBottomVarPtr = obj->bottom; + *_curGobDoAnimVarPtr = obj->doAnim; + *_curGobOrderVarPtr = obj->order; + *_curGobNoTickVarPtr = obj->noTick; + *_curGobTypeVarPtr = obj->type; + *_curGobMaxTickVarPtr = obj->maxTick; + *_curGobTickVarPtr = obj->tick; + *_curGobActStartStateVarPtr = obj->actionStartState; + *_curGobLookDirVarPtr = obj->curLookDir; + *_curGobPickableVarPtr = obj->pickable; + *_curGobRelaxVarPtr = obj->relaxTime; + *_curGobMaxFrameVarPtr = getObjMaxFrame(obj); + + if (_actDestItemDesc == 0) return; - obj = actDestItemDesc; - *destItemStateVarPtr = obj->state; - *destItemFrameVarPtr = obj->curFrame; - *destItemMultStateVarPtr = obj->multState; - *destItemNextStateVarPtr = obj->nextState; - *destItemScrXVarPtr = obj->xPos; - *destItemScrYVarPtr = obj->yPos; - *destItemLeftVarPtr = obj->left; - *destItemTopVarPtr = obj->top; - *destItemRightVarPtr = obj->right; - *destItemBottomVarPtr = obj->bottom; - *destItemDoAnimVarPtr = obj->doAnim; - *destItemOrderVarPtr = obj->order; - *destItemNoTickVarPtr = obj->noTick; - *destItemTypeVarPtr = obj->type; - *destItemMaxTickVarPtr = obj->maxTick; - *destItemTickVarPtr = obj->tick; - *destItemActStartStVarPtr = obj->actionStartState; - *destItemLookDirVarPtr = obj->curLookDir; - *destItemPickableVarPtr = obj->pickable; - *destItemRelaxVarPtr = obj->relaxTime; - *destItemMaxFrameVarPtr = getObjMaxFrame(obj); - - destItemState = obj->state; - destItemType = obj->type; + obj = _actDestItemDesc; + *_destItemStateVarPtr = obj->state; + *_destItemFrameVarPtr = obj->curFrame; + *_destItemMultStateVarPtr = obj->multState; + *_destItemNextStateVarPtr = obj->nextState; + *_destItemScrXVarPtr = obj->xPos; + *_destItemScrYVarPtr = obj->yPos; + *_destItemLeftVarPtr = obj->left; + *_destItemTopVarPtr = obj->top; + *_destItemRightVarPtr = obj->right; + *_destItemBottomVarPtr = obj->bottom; + *_destItemDoAnimVarPtr = obj->doAnim; + *_destItemOrderVarPtr = obj->order; + *_destItemNoTickVarPtr = obj->noTick; + *_destItemTypeVarPtr = obj->type; + *_destItemMaxTickVarPtr = obj->maxTick; + *_destItemTickVarPtr = obj->tick; + *_destItemActStartStVarPtr = obj->actionStartState; + *_destItemLookDirVarPtr = obj->curLookDir; + *_destItemPickableVarPtr = obj->pickable; + *_destItemRelaxVarPtr = obj->relaxTime; + *_destItemMaxFrameVarPtr = getObjMaxFrame(obj); + + _destItemState = obj->state; + _destItemType = obj->type; } void Goblin::initVarPointers(void) { - gobRetVarPtr = (int32 *)VAR_ADDRESS(59); - curGobStateVarPtr = (int32 *)VAR_ADDRESS(60); - curGobFrameVarPtr = (int32 *)VAR_ADDRESS(61); - curGobMultStateVarPtr = (int32 *)VAR_ADDRESS(62); - curGobNextStateVarPtr = (int32 *)VAR_ADDRESS(63); - curGobScrXVarPtr = (int32 *)VAR_ADDRESS(64); - curGobScrYVarPtr = (int32 *)VAR_ADDRESS(65); - curGobLeftVarPtr = (int32 *)VAR_ADDRESS(66); - curGobTopVarPtr = (int32 *)VAR_ADDRESS(67); - curGobRightVarPtr = (int32 *)VAR_ADDRESS(68); - curGobBottomVarPtr = (int32 *)VAR_ADDRESS(69); - curGobDoAnimVarPtr = (int32 *)VAR_ADDRESS(70); - curGobOrderVarPtr = (int32 *)VAR_ADDRESS(71); - curGobNoTickVarPtr = (int32 *)VAR_ADDRESS(72); - curGobTypeVarPtr = (int32 *)VAR_ADDRESS(73); - curGobMaxTickVarPtr = (int32 *)VAR_ADDRESS(74); - curGobTickVarPtr = (int32 *)VAR_ADDRESS(75); - curGobActStartStateVarPtr = (int32 *)VAR_ADDRESS(76); - curGobLookDirVarPtr = (int32 *)VAR_ADDRESS(77); - curGobPickableVarPtr = (int32 *)VAR_ADDRESS(80); - curGobRelaxVarPtr = (int32 *)VAR_ADDRESS(81); - destItemStateVarPtr = (int32 *)VAR_ADDRESS(82); - destItemFrameVarPtr = (int32 *)VAR_ADDRESS(83); - destItemMultStateVarPtr = (int32 *)VAR_ADDRESS(84); - destItemNextStateVarPtr = (int32 *)VAR_ADDRESS(85); - destItemScrXVarPtr = (int32 *)VAR_ADDRESS(86); - destItemScrYVarPtr = (int32 *)VAR_ADDRESS(87); - destItemLeftVarPtr = (int32 *)VAR_ADDRESS(88); - destItemTopVarPtr = (int32 *)VAR_ADDRESS(89); - destItemRightVarPtr = (int32 *)VAR_ADDRESS(90); - destItemBottomVarPtr = (int32 *)VAR_ADDRESS(91); - destItemDoAnimVarPtr = (int32 *)VAR_ADDRESS(92); - destItemOrderVarPtr = (int32 *)VAR_ADDRESS(93); - destItemNoTickVarPtr = (int32 *)VAR_ADDRESS(94); - destItemTypeVarPtr = (int32 *)VAR_ADDRESS(95); - destItemMaxTickVarPtr = (int32 *)VAR_ADDRESS(96); - destItemTickVarPtr = (int32 *)VAR_ADDRESS(97); - destItemActStartStVarPtr = (int32 *)VAR_ADDRESS(98); - destItemLookDirVarPtr = (int32 *)VAR_ADDRESS(99); - destItemPickableVarPtr = (int32 *)VAR_ADDRESS(102); - destItemRelaxVarPtr = (int32 *)VAR_ADDRESS(103); - destItemMaxFrameVarPtr = (int32 *)VAR_ADDRESS(105); - curGobVarPtr = (int32 *)VAR_ADDRESS(106); - some0ValPtr = (int32 *)VAR_ADDRESS(107); - curGobXPosVarPtr = (int32 *)VAR_ADDRESS(108); - curGobYPosVarPtr = (int32 *)VAR_ADDRESS(109); - curGobMaxFrameVarPtr = (int32 *)VAR_ADDRESS(110); - - itemInPocketVarPtr = (int32 *)VAR_ADDRESS(114); - - *itemInPocketVarPtr = -2; + _gobRetVarPtr = (int32 *)VAR_ADDRESS(59); + _curGobStateVarPtr = (int32 *)VAR_ADDRESS(60); + _curGobFrameVarPtr = (int32 *)VAR_ADDRESS(61); + _curGobMultStateVarPtr = (int32 *)VAR_ADDRESS(62); + _curGobNextStateVarPtr = (int32 *)VAR_ADDRESS(63); + _curGobScrXVarPtr = (int32 *)VAR_ADDRESS(64); + _curGobScrYVarPtr = (int32 *)VAR_ADDRESS(65); + _curGobLeftVarPtr = (int32 *)VAR_ADDRESS(66); + _curGobTopVarPtr = (int32 *)VAR_ADDRESS(67); + _curGobRightVarPtr = (int32 *)VAR_ADDRESS(68); + _curGobBottomVarPtr = (int32 *)VAR_ADDRESS(69); + _curGobDoAnimVarPtr = (int32 *)VAR_ADDRESS(70); + _curGobOrderVarPtr = (int32 *)VAR_ADDRESS(71); + _curGobNoTickVarPtr = (int32 *)VAR_ADDRESS(72); + _curGobTypeVarPtr = (int32 *)VAR_ADDRESS(73); + _curGobMaxTickVarPtr = (int32 *)VAR_ADDRESS(74); + _curGobTickVarPtr = (int32 *)VAR_ADDRESS(75); + _curGobActStartStateVarPtr = (int32 *)VAR_ADDRESS(76); + _curGobLookDirVarPtr = (int32 *)VAR_ADDRESS(77); + _curGobPickableVarPtr = (int32 *)VAR_ADDRESS(80); + _curGobRelaxVarPtr = (int32 *)VAR_ADDRESS(81); + _destItemStateVarPtr = (int32 *)VAR_ADDRESS(82); + _destItemFrameVarPtr = (int32 *)VAR_ADDRESS(83); + _destItemMultStateVarPtr = (int32 *)VAR_ADDRESS(84); + _destItemNextStateVarPtr = (int32 *)VAR_ADDRESS(85); + _destItemScrXVarPtr = (int32 *)VAR_ADDRESS(86); + _destItemScrYVarPtr = (int32 *)VAR_ADDRESS(87); + _destItemLeftVarPtr = (int32 *)VAR_ADDRESS(88); + _destItemTopVarPtr = (int32 *)VAR_ADDRESS(89); + _destItemRightVarPtr = (int32 *)VAR_ADDRESS(90); + _destItemBottomVarPtr = (int32 *)VAR_ADDRESS(91); + _destItemDoAnimVarPtr = (int32 *)VAR_ADDRESS(92); + _destItemOrderVarPtr = (int32 *)VAR_ADDRESS(93); + _destItemNoTickVarPtr = (int32 *)VAR_ADDRESS(94); + _destItemTypeVarPtr = (int32 *)VAR_ADDRESS(95); + _destItemMaxTickVarPtr = (int32 *)VAR_ADDRESS(96); + _destItemTickVarPtr = (int32 *)VAR_ADDRESS(97); + _destItemActStartStVarPtr = (int32 *)VAR_ADDRESS(98); + _destItemLookDirVarPtr = (int32 *)VAR_ADDRESS(99); + _destItemPickableVarPtr = (int32 *)VAR_ADDRESS(102); + _destItemRelaxVarPtr = (int32 *)VAR_ADDRESS(103); + _destItemMaxFrameVarPtr = (int32 *)VAR_ADDRESS(105); + _curGobVarPtr = (int32 *)VAR_ADDRESS(106); + _some0ValPtr = (int32 *)VAR_ADDRESS(107); + _curGobXPosVarPtr = (int32 *)VAR_ADDRESS(108); + _curGobYPosVarPtr = (int32 *)VAR_ADDRESS(109); + _curGobMaxFrameVarPtr = (int32 *)VAR_ADDRESS(110); + + _itemInPocketVarPtr = (int32 *)VAR_ADDRESS(114); + + *_itemInPocketVarPtr = -2; } void Goblin::loadGobDataFromVars(void) { Gob_Object *obj; - itemIndInPocket = *itemInPocketVarPtr; - - obj = goblins[currentGoblin]; - - obj->state = *curGobStateVarPtr; - obj->curFrame = *curGobFrameVarPtr; - obj->multState = *curGobMultStateVarPtr; - obj->nextState = *curGobNextStateVarPtr; - obj->xPos = *curGobScrXVarPtr; - obj->yPos = *curGobScrYVarPtr; - obj->left = *curGobLeftVarPtr; - obj->top = *curGobTopVarPtr; - obj->right = *curGobRightVarPtr; - obj->bottom = *curGobBottomVarPtr; - obj->doAnim = *curGobDoAnimVarPtr; - obj->order = *curGobOrderVarPtr; - obj->noTick = *curGobNoTickVarPtr; - obj->type = *curGobTypeVarPtr; - obj->maxTick = *curGobMaxTickVarPtr; - obj->tick = *curGobTickVarPtr; - obj->actionStartState = *curGobActStartStateVarPtr; - obj->curLookDir = *curGobLookDirVarPtr; - obj->pickable = *curGobPickableVarPtr; - obj->relaxTime = *curGobRelaxVarPtr; - - if (actDestItemDesc == 0) + _itemIndInPocket = *_itemInPocketVarPtr; + + obj = _goblins[_currentGoblin]; + + obj->state = *_curGobStateVarPtr; + obj->curFrame = *_curGobFrameVarPtr; + obj->multState = *_curGobMultStateVarPtr; + obj->nextState = *_curGobNextStateVarPtr; + obj->xPos = *_curGobScrXVarPtr; + obj->yPos = *_curGobScrYVarPtr; + obj->left = *_curGobLeftVarPtr; + obj->top = *_curGobTopVarPtr; + obj->right = *_curGobRightVarPtr; + obj->bottom = *_curGobBottomVarPtr; + obj->doAnim = *_curGobDoAnimVarPtr; + obj->order = *_curGobOrderVarPtr; + obj->noTick = *_curGobNoTickVarPtr; + obj->type = *_curGobTypeVarPtr; + obj->maxTick = *_curGobMaxTickVarPtr; + obj->tick = *_curGobTickVarPtr; + obj->actionStartState = *_curGobActStartStateVarPtr; + obj->curLookDir = *_curGobLookDirVarPtr; + obj->pickable = *_curGobPickableVarPtr; + obj->relaxTime = *_curGobRelaxVarPtr; + + if (_actDestItemDesc == 0) return; - obj = actDestItemDesc; - - obj->state = *destItemStateVarPtr; - obj->curFrame = *destItemFrameVarPtr; - obj->multState = *destItemMultStateVarPtr; - obj->nextState = *destItemNextStateVarPtr; - obj->xPos = *destItemScrXVarPtr; - obj->yPos = *destItemScrYVarPtr; - obj->left = *destItemLeftVarPtr; - obj->top = *destItemTopVarPtr; - obj->right = *destItemRightVarPtr; - obj->bottom = *destItemBottomVarPtr; - obj->doAnim = *destItemDoAnimVarPtr; - obj->order = *destItemOrderVarPtr; - obj->noTick = *destItemNoTickVarPtr; - obj->type = *destItemTypeVarPtr; - obj->maxTick = *destItemMaxTickVarPtr; - obj->tick = *destItemTickVarPtr; - obj->actionStartState = *destItemActStartStVarPtr; - obj->curLookDir = *destItemLookDirVarPtr; - obj->pickable = *destItemPickableVarPtr; - obj->relaxTime = *destItemRelaxVarPtr; - - if (obj->type != destItemType) + obj = _actDestItemDesc; + + obj->state = *_destItemStateVarPtr; + obj->curFrame = *_destItemFrameVarPtr; + obj->multState = *_destItemMultStateVarPtr; + obj->nextState = *_destItemNextStateVarPtr; + obj->xPos = *_destItemScrXVarPtr; + obj->yPos = *_destItemScrYVarPtr; + obj->left = *_destItemLeftVarPtr; + obj->top = *_destItemTopVarPtr; + obj->right = *_destItemRightVarPtr; + obj->bottom = *_destItemBottomVarPtr; + obj->doAnim = *_destItemDoAnimVarPtr; + obj->order = *_destItemOrderVarPtr; + obj->noTick = *_destItemNoTickVarPtr; + obj->type = *_destItemTypeVarPtr; + obj->maxTick = *_destItemMaxTickVarPtr; + obj->tick = *_destItemTickVarPtr; + obj->actionStartState = *_destItemActStartStVarPtr; + obj->curLookDir = *_destItemLookDirVarPtr; + obj->pickable = *_destItemPickableVarPtr; + obj->relaxTime = *_destItemRelaxVarPtr; + + if (obj->type != _destItemType) obj->toRedraw = 1; - if (obj->state != destItemState && obj->type == 0) + if (obj->state != _destItemState && obj->type == 0) obj->toRedraw = 1; } @@ -2093,17 +2093,17 @@ void Goblin::pickItem(int16 indexToPocket, int16 idToPocket) { int16 x; int16 y; - if (objects[indexToPocket]->pickable != 1) + if (_objects[indexToPocket]->pickable != 1) return; - objects[indexToPocket]->type = 3; + _objects[indexToPocket]->type = 3; - itemIndInPocket = indexToPocket; - itemIdInPocket = idToPocket; + _itemIndInPocket = indexToPocket; + _itemIdInPocket = idToPocket; for (y = 0; y < Map::kMapHeight; y++) { for (x = 0; x < Map::kMapWidth; x++) { - if (itemByteFlag == 1) { + if (_itemByteFlag == 1) { if (((_vm->_map->_itemsMap[y][x] & 0xff00) >> 8) == idToPocket) _vm->_map->_itemsMap[y][x] &= 0xff; @@ -2115,9 +2115,9 @@ void Goblin::pickItem(int16 indexToPocket, int16 idToPocket) { } if (idToPocket >= 0 && idToPocket < 20) { - _vm->_map->_itemPoses[itemIdInPocket].x = 0; - _vm->_map->_itemPoses[itemIdInPocket].y = 0; - _vm->_map->_itemPoses[itemIdInPocket].orient = 0; + _vm->_map->_itemPoses[_itemIdInPocket].x = 0; + _vm->_map->_itemPoses[_itemIdInPocket].y = 0; + _vm->_map->_itemPoses[_itemIdInPocket].orient = 0; } } @@ -2128,20 +2128,20 @@ void Goblin::placeItem(int16 indexInPocket, int16 idInPocket) { int16 yPos; int16 layer; - itemDesc = objects[indexInPocket]; - lookDir = goblins[0]->curLookDir & 4; + itemDesc = _objects[indexInPocket]; + lookDir = _goblins[0]->curLookDir & 4; - xPos = gobPositions[0].x; - yPos = gobPositions[0].y; + xPos = _gobPositions[0].x; + yPos = _gobPositions[0].y; - itemIndInPocket = -1; - itemIdInPocket = 0; + _itemIndInPocket = -1; + _itemIdInPocket = 0; itemDesc->pickable = 1; itemDesc->type = 0; itemDesc->toRedraw = 1; itemDesc->curFrame = 0; - itemDesc->order = goblins[0]->order; + itemDesc->order = _goblins[0]->order; itemDesc->animation = itemDesc->stateMach[itemDesc->state][0]->animation; layer = @@ -2151,13 +2151,13 @@ void Goblin::placeItem(int16 indexInPocket, int16 idInPocket) { itemDesc->xPos, itemDesc->yPos, 0); itemDesc->yPos += - (gobPositions[0].y * 6) + 5 - _vm->_scenery->toRedrawBottom; + (_gobPositions[0].y * 6) + 5 - _vm->_scenery->toRedrawBottom; if (lookDir == 4) { - itemDesc->xPos += (gobPositions[0].x * 12 + 14) + itemDesc->xPos += (_gobPositions[0].x * 12 + 14) - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } else { - itemDesc->xPos += (gobPositions[0].x * 12) + itemDesc->xPos += (_gobPositions[0].x * 12) - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } @@ -2186,8 +2186,8 @@ void Goblin::placeItem(int16 indexInPocket, int16 idInPocket) { } if (idInPocket >= 0 && idInPocket < 20) { - _vm->_map->_itemPoses[idInPocket].x = gobPositions[0].x; - _vm->_map->_itemPoses[idInPocket].y = gobPositions[0].y; + _vm->_map->_itemPoses[idInPocket].x = _gobPositions[0].x; + _vm->_map->_itemPoses[idInPocket].y = _gobPositions[0].y; _vm->_map->_itemPoses[idInPocket].orient = lookDir; if (_vm->_map->_itemPoses[idInPocket].orient == 0) { // _vm->_map->_itemPoses[idInPocket].x++; @@ -2208,15 +2208,15 @@ void Goblin::swapItems(int16 indexToPick, int16 idToPick) { int16 x; int16 y; - pickObj = objects[indexToPick]; - placeObj = objects[itemIndInPocket]; + pickObj = _objects[indexToPick]; + placeObj = _objects[_itemIndInPocket]; - idToPlace = itemIdInPocket; + idToPlace = _itemIdInPocket; pickObj->type = 3; - itemIndInPocket = indexToPick; - itemIdInPocket = idToPick; + _itemIndInPocket = indexToPick; + _itemIdInPocket = idToPick; - if (itemByteFlag == 0) { + if (_itemByteFlag == 0) { for (y = 0; y < Map::kMapHeight; y++) { for (x = 0; x < Map::kMapWidth; x++) { if ((_vm->_map->_itemsMap[y][x] & 0xff) == idToPick) @@ -2240,19 +2240,19 @@ void Goblin::swapItems(int16 indexToPick, int16 idToPick) { if (idToPick >= 0 && idToPick < 20) { _vm->_map->_itemPoses[idToPlace].x = - _vm->_map->_itemPoses[itemIdInPocket].x; + _vm->_map->_itemPoses[_itemIdInPocket].x; _vm->_map->_itemPoses[idToPlace].y = - _vm->_map->_itemPoses[itemIdInPocket].y; + _vm->_map->_itemPoses[_itemIdInPocket].y; _vm->_map->_itemPoses[idToPlace].orient = - _vm->_map->_itemPoses[itemIdInPocket].orient; + _vm->_map->_itemPoses[_itemIdInPocket].orient; - _vm->_map->_itemPoses[itemIdInPocket].x = 0; - _vm->_map->_itemPoses[itemIdInPocket].y = 0; - _vm->_map->_itemPoses[itemIdInPocket].orient = 0; + _vm->_map->_itemPoses[_itemIdInPocket].x = 0; + _vm->_map->_itemPoses[_itemIdInPocket].y = 0; + _vm->_map->_itemPoses[_itemIdInPocket].orient = 0; } - itemIndInPocket = -1; - itemIdInPocket = 0; + _itemIndInPocket = -1; + _itemIdInPocket = 0; placeObj->type = 0; placeObj->nextState = -1; @@ -2260,7 +2260,7 @@ void Goblin::swapItems(int16 indexToPick, int16 idToPick) { placeObj->unk14 = 0; placeObj->toRedraw = 1; placeObj->curFrame = 0; - placeObj->order = goblins[0]->order; + placeObj->order = _goblins[0]->order; placeObj->animation = placeObj->stateMach[placeObj->state][0]->animation; @@ -2271,13 +2271,13 @@ void Goblin::swapItems(int16 indexToPick, int16 idToPick) { placeObj->yPos, 0); placeObj->yPos += - (gobPositions[0].y * 6) + 5 - _vm->_scenery->toRedrawBottom; + (_gobPositions[0].y * 6) + 5 - _vm->_scenery->toRedrawBottom; if (_vm->_map->_itemPoses[idToPlace].orient == 4) { - placeObj->xPos += (gobPositions[0].x * 12 + 14) + placeObj->xPos += (_gobPositions[0].x * 12 + 14) - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } else { - placeObj->xPos += (gobPositions[0].x * 12) + placeObj->xPos += (_gobPositions[0].x * 12) - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } } @@ -2286,7 +2286,7 @@ void Goblin::treatItemPick(int16 itemId) { int16 itemIndex; Gob_Object *gobDesc; - gobDesc = goblins[currentGoblin]; + gobDesc = _goblins[_currentGoblin]; if (gobDesc->curFrame != 9) return; @@ -2294,31 +2294,31 @@ void Goblin::treatItemPick(int16 itemId) { if (gobDesc->stateMach != gobDesc->realStateMach) return; - readyToAct = 0; - goesAtTarget = 0; + _readyToAct = 0; + _goesAtTarget = 0; - itemIndex = itemToObject[itemId]; + itemIndex = _itemToObject[itemId]; if (itemId != 0 && itemIndex != -1 - && objects[itemIndex]->pickable != 1) + && _objects[itemIndex]->pickable != 1) itemIndex = -1; - if (itemIndInPocket != -1 && itemIndInPocket == itemIndex) + if (_itemIndInPocket != -1 && _itemIndInPocket == itemIndex) itemIndex = -1; - if (itemIndInPocket != -1 && itemIndex != -1 - && objects[itemIndex]->pickable == 1) { + if (_itemIndInPocket != -1 && itemIndex != -1 + && _objects[itemIndex]->pickable == 1) { swapItems(itemIndex, itemId); - itemIndInPocket = itemIndex; - itemIdInPocket = itemId; + _itemIndInPocket = itemIndex; + _itemIdInPocket = itemId; return; } - if (itemIndInPocket != -1 && itemIndex == -1) { - placeItem(itemIndInPocket, itemIdInPocket); + if (_itemIndInPocket != -1 && itemIndex == -1) { + placeItem(_itemIndInPocket, _itemIdInPocket); return; } - if (itemIndInPocket == -1 && itemIndex != -1) { + if (_itemIndInPocket == -1 && itemIndex != -1) { pickItem(itemIndex, itemId); return; } @@ -2327,51 +2327,51 @@ void Goblin::treatItemPick(int16 itemId) { int16 Goblin::treatItem(int16 action) { int16 state; - state = goblins[currentGoblin]->state; + state = _goblins[_currentGoblin]->state; if ((state == 10 || state == 11) && - goblins[currentGoblin]->curFrame == 0) { - readyToAct = 0; + _goblins[_currentGoblin]->curFrame == 0) { + _readyToAct = 0; } - if (action == 3 && currentGoblin == 0 && - (state == 10 || state == 11) && goblins[0]->curFrame == 0) { - saveGobDataToVars(gobPositions[currentGoblin].x, - gobPositions[currentGoblin].y, 0); - goesAtTarget = 1; + if (action == 3 && _currentGoblin == 0 && + (state == 10 || state == 11) && _goblins[0]->curFrame == 0) { + saveGobDataToVars(_gobPositions[_currentGoblin].x, + _gobPositions[_currentGoblin].y, 0); + _goesAtTarget = 1; return -1; } - if (noPick == 0 && currentGoblin == 0 && + if (_noPick == 0 && _currentGoblin == 0 && (state == 10 || state == 11)) { - treatItemPick(destActionItem); + treatItemPick(_destActionItem); - saveGobDataToVars(gobPositions[currentGoblin].x, - gobPositions[currentGoblin].y, 0); + saveGobDataToVars(_gobPositions[_currentGoblin].x, + _gobPositions[_currentGoblin].y, 0); return 0; } - if (goesAtTarget == 0) { - saveGobDataToVars(gobPositions[currentGoblin].x, - gobPositions[currentGoblin].y, 0); + if (_goesAtTarget == 0) { + saveGobDataToVars(_gobPositions[_currentGoblin].x, + _gobPositions[_currentGoblin].y, 0); return 0; } else { - if (itemToObject[destActionItem] != 100 && - destActionItem != 0) { + if (_itemToObject[_destActionItem] != 100 && + _destActionItem != 0) { - if (itemToObject[destActionItem] == -1) { - actDestItemDesc = 0; + if (_itemToObject[_destActionItem] == -1) { + _actDestItemDesc = 0; } else { - actDestItemDesc = - objects[itemToObject - [destActionItem]]; + _actDestItemDesc = + _objects[_itemToObject + [_destActionItem]]; } } - goesAtTarget = 0; - saveGobDataToVars(gobPositions[currentGoblin].x, - gobPositions[currentGoblin].y, 0); - return destActionItem; + _goesAtTarget = 0; + saveGobDataToVars(_gobPositions[_currentGoblin].x, + _gobPositions[_currentGoblin].y, 0); + return _destActionItem; } } @@ -2397,14 +2397,14 @@ void Goblin::interFunc(void) { _vm->_global->_inter_execPtr += 2; if (cmd > 0 && cmd < 17) { extraData = _vm->_inter->load16(); - objDesc = objects[extraData]; + objDesc = _objects[extraData]; objDescSet = true; extraData = _vm->_inter->load16(); } if (cmd > 90 && cmd < 107) { extraData = _vm->_inter->load16(); - objDesc = goblins[extraData]; + objDesc = _goblins[extraData]; objDescSet = true; extraData = _vm->_inter->load16(); cmd -= 90; @@ -2412,12 +2412,12 @@ void Goblin::interFunc(void) { if (cmd > 110 && cmd < 128) { extraData = _vm->_inter->load16(); - objDesc = goblins[extraData]; + objDesc = _goblins[extraData]; objDescSet = true; cmd -= 90; } else if (cmd > 20 && cmd < 38) { extraData = _vm->_inter->load16(); - objDesc = objects[extraData]; + objDesc = _objects[extraData]; objDescSet = true; } @@ -2439,50 +2439,50 @@ void Goblin::interFunc(void) { case 1: objDesc->state = extraData; - if (objDesc == actDestItemDesc) - *destItemStateVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemStateVarPtr = extraData; break; case 2: objDesc->curFrame = extraData; - if (objDesc == actDestItemDesc) - *destItemFrameVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemFrameVarPtr = extraData; break; case 3: objDesc->nextState = extraData; - if (objDesc == actDestItemDesc) - *destItemNextStateVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemNextStateVarPtr = extraData; break; case 4: objDesc->multState = extraData; - if (objDesc == actDestItemDesc) - *destItemMultStateVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemMultStateVarPtr = extraData; break; case 5: objDesc->order = extraData; - if (objDesc == actDestItemDesc) - *destItemOrderVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemOrderVarPtr = extraData; break; case 6: objDesc->actionStartState = extraData; - if (objDesc == actDestItemDesc) - *destItemActStartStVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemActStartStVarPtr = extraData; break; case 7: objDesc->curLookDir = extraData; - if (objDesc == actDestItemDesc) - *destItemLookDirVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemLookDirVarPtr = extraData; break; case 8: objDesc->type = extraData; - if (objDesc == actDestItemDesc) - *destItemTypeVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemTypeVarPtr = extraData; if (extraData == 0) objDesc->toRedraw = 1; @@ -2490,44 +2490,44 @@ void Goblin::interFunc(void) { case 9: objDesc->noTick = extraData; - if (objDesc == actDestItemDesc) - *destItemNoTickVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemNoTickVarPtr = extraData; break; case 10: objDesc->pickable = extraData; - if (objDesc == actDestItemDesc) - *destItemPickableVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemPickableVarPtr = extraData; break; case 12: objDesc->xPos = extraData; - if (objDesc == actDestItemDesc) - *destItemScrXVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemScrXVarPtr = extraData; break; case 13: objDesc->yPos = extraData; - if (objDesc == actDestItemDesc) - *destItemScrYVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemScrYVarPtr = extraData; break; case 14: objDesc->doAnim = extraData; - if (objDesc == actDestItemDesc) - *destItemDoAnimVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemDoAnimVarPtr = extraData; break; case 15: objDesc->relaxTime = extraData; - if (objDesc == actDestItemDesc) - *destItemRelaxVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemRelaxVarPtr = extraData; break; case 16: objDesc->maxTick = extraData; - if (objDesc == actDestItemDesc) - *destItemMaxTickVarPtr = extraData; + if (objDesc == _actDestItemDesc) + *_destItemMaxTickVarPtr = extraData; break; case 21: @@ -2775,10 +2775,10 @@ void Goblin::interFunc(void) { xPos = _vm->_inter->load16(); yPos = _vm->_inter->load16(); - gobPositions[item].x = xPos * 2; - gobPositions[item].y = yPos * 2; + _gobPositions[item].x = xPos * 2; + _gobPositions[item].y = yPos * 2; - objDesc = goblins[item]; + objDesc = _goblins[item]; objDesc->nextState = 21; nextLayer(objDesc); @@ -2789,33 +2789,33 @@ void Goblin::interFunc(void) { objDesc->xPos, objDesc->yPos, 0); objDesc->yPos = - (gobPositions[item].y * 6 + 6) - (_vm->_scenery->toRedrawBottom - + (_gobPositions[item].y * 6 + 6) - (_vm->_scenery->toRedrawBottom - _vm->_scenery->animTop); objDesc->xPos = - gobPositions[item].x * 12 - (_vm->_scenery->toRedrawLeft - + _gobPositions[item].x * 12 - (_vm->_scenery->toRedrawLeft - _vm->_scenery->animLeft); objDesc->curFrame = 0; objDesc->state = 21; - if (currentGoblin == item) { - *curGobScrXVarPtr = objDesc->xPos; - *curGobScrYVarPtr = objDesc->yPos; + if (_currentGoblin == item) { + *_curGobScrXVarPtr = objDesc->xPos; + *_curGobScrYVarPtr = objDesc->yPos; - *curGobFrameVarPtr = 0; - *curGobStateVarPtr = 18; - pressedMapX = gobPositions[item].x; - pressedMapY = gobPositions[item].y; + *_curGobFrameVarPtr = 0; + *_curGobStateVarPtr = 18; + _pressedMapX = _gobPositions[item].x; + _pressedMapY = _gobPositions[item].y; } break; case 52: item = _vm->_inter->load16(); - *retVarPtr = gobPositions[item].x >> 1; + *retVarPtr = _gobPositions[item].x >> 1; break; case 53: item = _vm->_inter->load16(); - *retVarPtr = gobPositions[item].y >> 1; + *retVarPtr = _gobPositions[item].y >> 1; break; case 150: @@ -2823,7 +2823,7 @@ void Goblin::interFunc(void) { xPos = _vm->_inter->load16(); yPos = _vm->_inter->load16(); - objDesc = goblins[item]; + objDesc = _goblins[item]; if (yPos == 0) { objDesc->multState = xPos; objDesc->nextState = xPos; @@ -2838,15 +2838,15 @@ void Goblin::interFunc(void) { _vm->_scenery->animations[objDesc->animation].layers[layer]-> posY; - *curGobScrXVarPtr = objDesc->xPos; - *curGobScrYVarPtr = objDesc->yPos; - *curGobFrameVarPtr = 0; - *curGobStateVarPtr = objDesc->state; - *curGobNextStateVarPtr = objDesc->nextState; - *curGobMultStateVarPtr = objDesc->multState; - *curGobMaxFrameVarPtr = + *_curGobScrXVarPtr = objDesc->xPos; + *_curGobScrYVarPtr = objDesc->yPos; + *_curGobFrameVarPtr = 0; + *_curGobStateVarPtr = objDesc->state; + *_curGobNextStateVarPtr = objDesc->nextState; + *_curGobMultStateVarPtr = objDesc->multState; + *_curGobMaxFrameVarPtr = getObjMaxFrame(objDesc); - noPick = 1; + _noPick = 1; break; } @@ -2864,21 +2864,21 @@ void Goblin::interFunc(void) { objDesc->xPos = xPos * 12 - (_vm->_scenery->toRedrawLeft - _vm->_scenery->animLeft); - gobPositions[item].x = xPos; - pressedMapX = xPos; + _gobPositions[item].x = xPos; + _pressedMapX = xPos; _vm->_map->_curGoblinX = xPos; - gobPositions[item].y = yPos; - pressedMapY = yPos; + _gobPositions[item].y = yPos; + _pressedMapY = yPos; _vm->_map->_curGoblinY = yPos; - *curGobScrXVarPtr = objDesc->xPos; - *curGobScrYVarPtr = objDesc->yPos; - *curGobFrameVarPtr = 0; - *curGobStateVarPtr = 21; - *curGobNextStateVarPtr = 21; - *curGobMultStateVarPtr = -1; - noPick = 0; + *_curGobScrXVarPtr = objDesc->xPos; + *_curGobScrYVarPtr = objDesc->yPos; + *_curGobFrameVarPtr = 0; + *_curGobStateVarPtr = 21; + *_curGobNextStateVarPtr = 21; + *_curGobMultStateVarPtr = -1; + _noPick = 0; break; case 250: @@ -2886,10 +2886,10 @@ void Goblin::interFunc(void) { xPos = _vm->_inter->load16(); yPos = _vm->_inter->load16(); - gobPositions[item].x = xPos; - gobPositions[item].y = yPos; + _gobPositions[item].x = xPos; + _gobPositions[item].y = yPos; - objDesc = goblins[item]; + objDesc = _goblins[item]; objDesc->nextState = 21; nextLayer(objDesc); @@ -2906,14 +2906,14 @@ void Goblin::interFunc(void) { objDesc->curFrame = 0; objDesc->state = 21; - if (currentGoblin == item) { - *curGobScrXVarPtr = objDesc->xPos; - *curGobScrYVarPtr = objDesc->yPos; - *curGobFrameVarPtr = 0; - *curGobStateVarPtr = 18; + if (_currentGoblin == item) { + *_curGobScrXVarPtr = objDesc->xPos; + *_curGobScrYVarPtr = objDesc->yPos; + *_curGobFrameVarPtr = 0; + *_curGobStateVarPtr = 18; - pressedMapX = gobPositions[item].x; - pressedMapY = gobPositions[item].y; + _pressedMapX = _gobPositions[item].x; + _pressedMapY = _gobPositions[item].y; } break; @@ -2921,7 +2921,7 @@ void Goblin::interFunc(void) { item = _vm->_inter->load16(); state = _vm->_inter->load16(); - objDesc = goblins[item]; + objDesc = _goblins[item]; objDesc->nextState = state; nextLayer(objDesc); @@ -2932,19 +2932,19 @@ void Goblin::interFunc(void) { objDesc->yPos = _vm->_scenery->animations[objDesc->animation].layers[layer]->posY; - if (item == currentGoblin) { - *curGobScrXVarPtr = objDesc->xPos; - *curGobScrYVarPtr = objDesc->yPos; - *curGobFrameVarPtr = 0; - *curGobStateVarPtr = objDesc->state; - *curGobMultStateVarPtr = objDesc->multState; + if (item == _currentGoblin) { + *_curGobScrXVarPtr = objDesc->xPos; + *_curGobScrYVarPtr = objDesc->yPos; + *_curGobFrameVarPtr = 0; + *_curGobStateVarPtr = objDesc->state; + *_curGobMultStateVarPtr = objDesc->multState; } break; case 252: item = _vm->_inter->load16(); state = _vm->_inter->load16(); - objDesc = objects[item]; + objDesc = _objects[item]; objDesc->nextState = state; @@ -2957,38 +2957,38 @@ void Goblin::interFunc(void) { objDesc->toRedraw = 1; objDesc->type = 0; - if (objDesc == actDestItemDesc) { - *destItemScrXVarPtr = objDesc->xPos; - *destItemScrYVarPtr = objDesc->yPos; + if (objDesc == _actDestItemDesc) { + *_destItemScrXVarPtr = objDesc->xPos; + *_destItemScrYVarPtr = objDesc->yPos; - *destItemStateVarPtr = objDesc->state; - *destItemNextStateVarPtr = -1; - *destItemMultStateVarPtr = -1; - *destItemFrameVarPtr = 0; + *_destItemStateVarPtr = objDesc->state; + *_destItemNextStateVarPtr = -1; + *_destItemMultStateVarPtr = -1; + *_destItemFrameVarPtr = 0; } break; case 152: item = _vm->_inter->load16(); val = _vm->_inter->load16(); - objDesc = objects[item]; + objDesc = _objects[item]; objDesc->unk14 = val; break; case 200: - itemIdInPocket = _vm->_inter->load16(); + _itemIdInPocket = _vm->_inter->load16(); break; case 201: - itemIndInPocket = _vm->_inter->load16(); + _itemIndInPocket = _vm->_inter->load16(); break; case 202: - *retVarPtr = itemIdInPocket; + *retVarPtr = _itemIdInPocket; break; case 203: - *retVarPtr = itemIndInPocket; + *retVarPtr = _itemIndInPocket; break; case 204: @@ -3004,7 +3004,7 @@ void Goblin::interFunc(void) { case 500: extraData = _vm->_inter->load16(); - objDesc = objects[extraData]; + objDesc = _objects[extraData]; objDesc->relaxTime--; if (objDesc->relaxTime < 0 && @@ -3017,34 +3017,34 @@ void Goblin::interFunc(void) { case 502: item = _vm->_inter->load16(); - *retVarPtr = gobPositions[item].x; + *retVarPtr = _gobPositions[item].x; break; case 503: item = _vm->_inter->load16(); - *retVarPtr = gobPositions[item].y; + *retVarPtr = _gobPositions[item].y; break; case 600: - pathExistence = 0; + _pathExistence = 0; break; case 601: extraData = _vm->_inter->load16(); - goblins[extraData]->visible = 1; + _goblins[extraData]->visible = 1; break; case 602: extraData = _vm->_inter->load16(); - goblins[extraData]->visible = 0; + _goblins[extraData]->visible = 0; break; case 603: extraData = _vm->_inter->load16(); item = _vm->_inter->load16(); - objDesc = objects[extraData]; - if (objIntersected(objDesc, goblins[item]) != 0) + objDesc = _objects[extraData]; + if (objIntersected(objDesc, _goblins[item]) != 0) *retVarPtr = 1; else *retVarPtr = 0; @@ -3054,8 +3054,8 @@ void Goblin::interFunc(void) { extraData = _vm->_inter->load16(); item = _vm->_inter->load16(); - objDesc = goblins[extraData]; - if (objIntersected(objDesc, goblins[item]) != 0) + objDesc = _goblins[extraData]; + if (objIntersected(objDesc, _goblins[item]) != 0) *retVarPtr = 1; else *retVarPtr = 0; @@ -3074,11 +3074,11 @@ void Goblin::interFunc(void) { case 1000: extraData = _vm->_inter->load16(); - if (_vm->_game->extHandle >= 0) - _vm->_dataio->closeData(_vm->_game->extHandle); + if (_vm->_game->_extHandle >= 0) + _vm->_dataio->closeData(_vm->_game->_extHandle); loadObjects((char *)VAR_ADDRESS(extraData)); - _vm->_game->extHandle = _vm->_dataio->openData(_vm->_game->curExtFile); + _vm->_game->_extHandle = _vm->_dataio->openData(_vm->_game->_curExtFile); break; case 1001: @@ -3106,11 +3106,11 @@ void Goblin::interFunc(void) { if ((uint16)VAR(xPos) == 0) { item = - doMove(goblins[currentGoblin], 1, + doMove(_goblins[_currentGoblin], 1, (uint16)VAR(extraData)); } else { item = - doMove(goblins[currentGoblin], 1, 3); + doMove(_goblins[_currentGoblin], 1, 3); } if (item != 0) @@ -3139,59 +3139,59 @@ void Goblin::interFunc(void) { break; case 1010: - doMove(goblins[currentGoblin], 0, 0); + doMove(_goblins[_currentGoblin], 0, 0); break; case 1011: extraData = _vm->_inter->load16(); if (VAR(extraData) != 0) - goesAtTarget = 1; + _goesAtTarget = 1; else - goesAtTarget = 0; + _goesAtTarget = 0; break; case 1015: extraData = _vm->_inter->load16(); extraData = VAR(extraData); - objects[10]->xPos = extraData; + _objects[10]->xPos = extraData; extraData = _vm->_inter->load16(); extraData = VAR(extraData); - objects[10]->yPos = extraData; + _objects[10]->yPos = extraData; break; case 2005: - gobDesc = goblins[0]; - if (currentGoblin != 0) { - goblins[currentGoblin]->doAnim = 1; - goblins[currentGoblin]->nextState = 21; + gobDesc = _goblins[0]; + if (_currentGoblin != 0) { + _goblins[_currentGoblin]->doAnim = 1; + _goblins[_currentGoblin]->nextState = 21; - nextLayer(goblins[currentGoblin]); - currentGoblin = 0; + nextLayer(_goblins[_currentGoblin]); + _currentGoblin = 0; gobDesc->doAnim = 0; gobDesc->type = 0; gobDesc->toRedraw = 1; - pressedMapX = gobPositions[0].x; - _vm->_map->_destX = gobPositions[0].x; - gobDestX = gobPositions[0].x; + _pressedMapX = _gobPositions[0].x; + _vm->_map->_destX = _gobPositions[0].x; + _gobDestX = _gobPositions[0].x; - pressedMapY = gobPositions[0].y; - _vm->_map->_destY = gobPositions[0].y; - gobDestY = gobPositions[0].y; + _pressedMapY = _gobPositions[0].y; + _vm->_map->_destY = _gobPositions[0].y; + _gobDestY = _gobPositions[0].y; - *curGobVarPtr = 0; - pathExistence = 0; - readyToAct = 0; + *_curGobVarPtr = 0; + _pathExistence = 0; + _readyToAct = 0; } - if (gobDesc->state != 10 && itemIndInPocket != -1 && + if (gobDesc->state != 10 && _itemIndInPocket != -1 && getObjMaxFrame(gobDesc) == gobDesc->curFrame) { gobDesc->stateMach = gobDesc->realStateMach; - xPos = gobPositions[0].x; - yPos = gobPositions[0].y; + xPos = _gobPositions[0].x; + yPos = _gobPositions[0].y; gobDesc->nextState = 10; layer = nextLayer(gobDesc); @@ -3209,13 +3209,13 @@ void Goblin::interFunc(void) { if (gobDesc->state != 10) break; - if (itemIndInPocket == -1) + if (_itemIndInPocket == -1) break; if (gobDesc->curFrame != 10) break; - objDesc = objects[itemIndInPocket]; + objDesc = _objects[_itemIndInPocket]; objDesc->type = 0; objDesc->toRedraw = 1; objDesc->curFrame = 0; @@ -3230,18 +3230,18 @@ void Goblin::interFunc(void) { objDesc->xPos, objDesc->yPos, 0); objDesc->yPos += - (gobPositions[0].y * 6 + 5) - _vm->_scenery->toRedrawBottom; + (_gobPositions[0].y * 6 + 5) - _vm->_scenery->toRedrawBottom; if (gobDesc->curLookDir == 4) { - objDesc->xPos += gobPositions[0].x * 12 + 14 + objDesc->xPos += _gobPositions[0].x * 12 + 14 - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } else { - objDesc->xPos += gobPositions[0].x * 12 + objDesc->xPos += _gobPositions[0].x * 12 - (_vm->_scenery->toRedrawLeft + _vm->_scenery->toRedrawRight) / 2; } - itemIndInPocket = -1; - itemIdInPocket = -1; + _itemIndInPocket = -1; + _itemIdInPocket = -1; _vm->_util->beep(50); break; diff --git a/gob/goblin.h b/gob/goblin.h index 36c76b14f0..0de08978a6 100644 --- a/gob/goblin.h +++ b/gob/goblin.h @@ -91,91 +91,91 @@ public: } GCC_PACK Gob_Pos; #pragma END_PACK_STRUCTS - Util::List *objList; - Gob_Object *goblins[4]; - int16 currentGoblin; - Snd::SoundDesc *soundData[16]; - int16 gobStateLayer; - char goesAtTarget; - char readyToAct; - int16 gobAction; // 0 - move, 3 - do action, 4 - pick + Util::List *_objList; + Gob_Object *_goblins[4]; + int16 _currentGoblin; + Snd::SoundDesc *_soundData[16]; + int16 _gobStateLayer; + char _goesAtTarget; + char _readyToAct; + int16 _gobAction; // 0 - move, 3 - do action, 4 - pick // goblins 0 - picker, 1 - fighter, 2 - mage - Gob_Pos gobPositions[3]; - int16 gobDestX; - int16 gobDestY; - int16 pressedMapX; - int16 pressedMapY; - char pathExistence; + Gob_Pos _gobPositions[3]; + int16 _gobDestX; + int16 _gobDestY; + int16 _pressedMapX; + int16 _pressedMapY; + char _pathExistence; // Pointers to interpreter variables - int32 *some0ValPtr; - - int32 *gobRetVarPtr; - int32 *curGobVarPtr; - int32 *curGobXPosVarPtr; - int32 *curGobYPosVarPtr; - int32 *itemInPocketVarPtr; - - int32 *curGobStateVarPtr; - int32 *curGobFrameVarPtr; - int32 *curGobMultStateVarPtr; - int32 *curGobNextStateVarPtr; - int32 *curGobScrXVarPtr; - int32 *curGobScrYVarPtr; - int32 *curGobLeftVarPtr; - int32 *curGobTopVarPtr; - int32 *curGobRightVarPtr; - int32 *curGobBottomVarPtr; - int32 *curGobDoAnimVarPtr; - int32 *curGobOrderVarPtr; - int32 *curGobNoTickVarPtr; - int32 *curGobTypeVarPtr; - int32 *curGobMaxTickVarPtr; - int32 *curGobTickVarPtr; - int32 *curGobActStartStateVarPtr; - int32 *curGobLookDirVarPtr; - int32 *curGobPickableVarPtr; - int32 *curGobRelaxVarPtr; - int32 *curGobMaxFrameVarPtr; - - int32 *destItemStateVarPtr; - int32 *destItemFrameVarPtr; - int32 *destItemMultStateVarPtr; - int32 *destItemNextStateVarPtr; - int32 *destItemScrXVarPtr; - int32 *destItemScrYVarPtr; - int32 *destItemLeftVarPtr; - int32 *destItemTopVarPtr; - int32 *destItemRightVarPtr; - int32 *destItemBottomVarPtr; - int32 *destItemDoAnimVarPtr; - int32 *destItemOrderVarPtr; - int32 *destItemNoTickVarPtr; - int32 *destItemTypeVarPtr; - int32 *destItemMaxTickVarPtr; - int32 *destItemTickVarPtr; - int32 *destItemActStartStVarPtr; - int32 *destItemLookDirVarPtr; - int32 *destItemPickableVarPtr; - int32 *destItemRelaxVarPtr; - int32 *destItemMaxFrameVarPtr; - - int16 destItemType; - int16 destItemState; - int16 itemToObject[20]; - Gob_Object *objects[20]; - int16 objCount; - int16 gobsCount; - int16 itemIndInPocket; - int16 itemIdInPocket; - char itemByteFlag; - int16 destItemId; - int16 destActionItem; - Gob_Object *actDestItemDesc; - int16 forceNextState[10]; - char boreCounter; - int16 positionedGob; - char noPick; + int32 *_some0ValPtr; + + int32 *_gobRetVarPtr; + int32 *_curGobVarPtr; + int32 *_curGobXPosVarPtr; + int32 *_curGobYPosVarPtr; + int32 *_itemInPocketVarPtr; + + int32 *_curGobStateVarPtr; + int32 *_curGobFrameVarPtr; + int32 *_curGobMultStateVarPtr; + int32 *_curGobNextStateVarPtr; + int32 *_curGobScrXVarPtr; + int32 *_curGobScrYVarPtr; + int32 *_curGobLeftVarPtr; + int32 *_curGobTopVarPtr; + int32 *_curGobRightVarPtr; + int32 *_curGobBottomVarPtr; + int32 *_curGobDoAnimVarPtr; + int32 *_curGobOrderVarPtr; + int32 *_curGobNoTickVarPtr; + int32 *_curGobTypeVarPtr; + int32 *_curGobMaxTickVarPtr; + int32 *_curGobTickVarPtr; + int32 *_curGobActStartStateVarPtr; + int32 *_curGobLookDirVarPtr; + int32 *_curGobPickableVarPtr; + int32 *_curGobRelaxVarPtr; + int32 *_curGobMaxFrameVarPtr; + + int32 *_destItemStateVarPtr; + int32 *_destItemFrameVarPtr; + int32 *_destItemMultStateVarPtr; + int32 *_destItemNextStateVarPtr; + int32 *_destItemScrXVarPtr; + int32 *_destItemScrYVarPtr; + int32 *_destItemLeftVarPtr; + int32 *_destItemTopVarPtr; + int32 *_destItemRightVarPtr; + int32 *_destItemBottomVarPtr; + int32 *_destItemDoAnimVarPtr; + int32 *_destItemOrderVarPtr; + int32 *_destItemNoTickVarPtr; + int32 *_destItemTypeVarPtr; + int32 *_destItemMaxTickVarPtr; + int32 *_destItemTickVarPtr; + int32 *_destItemActStartStVarPtr; + int32 *_destItemLookDirVarPtr; + int32 *_destItemPickableVarPtr; + int32 *_destItemRelaxVarPtr; + int32 *_destItemMaxFrameVarPtr; + + int16 _destItemType; + int16 _destItemState; + int16 _itemToObject[20]; + Gob_Object *_objects[20]; + int16 _objCount; + int16 _gobsCount; + int16 _itemIndInPocket; + int16 _itemIdInPocket; + char _itemByteFlag; + int16 _destItemId; + int16 _destActionItem; + Gob_Object *_actDestItemDesc; + int16 _forceNextState[10]; + char _boreCounter; + int16 _positionedGob; + char _noPick; // Functions char rotateState(int16 from, int16 to); @@ -206,7 +206,7 @@ public: Goblin(GobEngine *vm); protected: - int16 rotStates[4][4]; + int16 _rotStates[4][4]; GobEngine *_vm; int16 peekGoblin(Gob_Object *curGob); diff --git a/gob/init.cpp b/gob/init.cpp index 9733cf67cb..11e1dd2f0f 100644 --- a/gob/init.cpp +++ b/gob/init.cpp @@ -168,22 +168,22 @@ memBlocks = word ptr -2*/ _vm->_global->_mouseXShift = 1; _vm->_global->_mouseYShift = 1; - _vm->_game->totTextData = 0; - _vm->_game->totFileData = 0; - _vm->_game->totResourceTable = 0; + _vm->_game->_totTextData = 0; + _vm->_game->_totFileData = 0; + _vm->_game->_totResourceTable = 0; _vm->_global->_inter_variables = 0; _palDesc = (Video::PalDesc *)malloc(12); if (_vm->_global->_videoMode != 0x13) error("initGame: Only 0x13 video mode is supported!"); - _palDesc->vgaPal = _vm->_draw->vgaPalette; - _palDesc->unused1 = _vm->_draw->unusedPalette1; - _palDesc->unused2 = _vm->_draw->unusedPalette2; + _palDesc->vgaPal = _vm->_draw->_vgaPalette; + _palDesc->unused1 = _vm->_draw->_unusedPalette1; + _palDesc->unused2 = _vm->_draw->_unusedPalette2; _vm->_video->setFullPalette(_palDesc); for (i = 0; i < 4; i++) - _vm->_draw->fonts[i] = 0; + _vm->_draw->_fonts[i] = 0; handle = _vm->_dataio->openData("intro.inf"); @@ -192,7 +192,7 @@ memBlocks = word ptr -2*/ handle2 = _vm->_dataio->openData(_fontNames[i]); if (handle2 >= 0) { _vm->_dataio->closeData(handle2); - _vm->_draw->fonts[i] = + _vm->_draw->_fonts[i] = _vm->_util->loadFont(_fontNames[i]); } } @@ -214,7 +214,7 @@ memBlocks = word ptr -2*/ handle2 = _vm->_dataio->openData(buffer); if (handle2 >= 0) { _vm->_dataio->closeData(handle2); - _vm->_draw->fonts[i] = _vm->_util->loadFont(buffer); + _vm->_draw->_fonts[i] = _vm->_util->loadFont(buffer); } if (infPtr == infEnd) @@ -247,7 +247,7 @@ memBlocks = word ptr -2*/ _vm->_global->_inter_variables = (char *)malloc(varsCount * 4); memset(_vm->_global->_inter_variables, 0, varsCount * 4); - strcpy(_vm->_game->curTotFile, buffer); + strcpy(_vm->_game->_curTotFile, buffer); _vm->_cdrom->testCD(1, "GOB"); _vm->_cdrom->readLIC("gob.lic"); @@ -257,14 +257,14 @@ memBlocks = word ptr -2*/ _vm->_cdrom->freeLICbuffer(); free(_vm->_global->_inter_variables); - free(_vm->_game->totFileData); - free(_vm->_game->totTextData); - free(_vm->_game->totResourceTable); + free(_vm->_game->_totFileData); + free(_vm->_game->_totTextData); + free(_vm->_game->_totResourceTable); } for (i = 0; i < 4; i++) { - if (_vm->_draw->fonts[i] != 0) - _vm->_util->freeFont(_vm->_draw->fonts[i]); + if (_vm->_draw->_fonts[i] != 0) + _vm->_util->freeFont(_vm->_draw->_fonts[i]); } free(_palDesc); diff --git a/gob/inter.cpp b/gob/inter.cpp index f80f1c2dfd..31b61697f3 100644 --- a/gob/inter.cpp +++ b/gob/inter.cpp @@ -100,21 +100,21 @@ void Inter::animPalette(void) { _vm->_video->waitRetrace(_vm->_global->_videoMode); if (_animPalDir == -1) { - col = _vm->_draw->vgaSmallPalette[_animPalLowIndex]; + col = _vm->_draw->_vgaSmallPalette[_animPalLowIndex]; for (i = _animPalLowIndex; i < _animPalHighIndex; i++) - _vm->_draw->vgaSmallPalette[i] = _vm->_draw->vgaSmallPalette[i + 1]; + _vm->_draw->_vgaSmallPalette[i] = _vm->_draw->_vgaSmallPalette[i + 1]; - _vm->_draw->vgaSmallPalette[_animPalHighIndex] = col; + _vm->_draw->_vgaSmallPalette[_animPalHighIndex] = col; } else { - col = _vm->_draw->vgaSmallPalette[_animPalHighIndex]; + col = _vm->_draw->_vgaSmallPalette[_animPalHighIndex]; for (i = _animPalHighIndex; i > _animPalLowIndex; i--) - _vm->_draw->vgaSmallPalette[i] = _vm->_draw->vgaSmallPalette[i - 1]; + _vm->_draw->_vgaSmallPalette[i] = _vm->_draw->_vgaSmallPalette[i - 1]; - _vm->_draw->vgaSmallPalette[_animPalLowIndex] = col; + _vm->_draw->_vgaSmallPalette[_animPalLowIndex] = col; } - _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->vgaSmallPalette; + _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->_vgaSmallPalette; _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); } @@ -175,11 +175,11 @@ void Inter::funcBlock(int16 retFlag) { } void Inter::storeKey(int16 key) { - WRITE_VAR(12, _vm->_util->getTimeKey() - _vm->_game->startTimeKey); + WRITE_VAR(12, _vm->_util->getTimeKey() - _vm->_game->_startTimeKey); WRITE_VAR(2, _vm->_global->_inter_mouseX); WRITE_VAR(3, _vm->_global->_inter_mouseY); - WRITE_VAR(4, _vm->_game->mouseButtons); + WRITE_VAR(4, _vm->_game->_mouseButtons); WRITE_VAR(1, _vm->_snd->_playingSound); if (key == 0x4800) @@ -257,7 +257,7 @@ void Inter::checkSwitchTable(char **ppExec) { void Inter::callSub(int16 retFlag) { int16 block; - while (_vm->_global->_inter_execPtr != 0 && (char *)_vm->_global->_inter_execPtr != _vm->_game->totFileData) { + while (_vm->_global->_inter_execPtr != 0 && (char *)_vm->_global->_inter_execPtr != _vm->_game->_totFileData) { block = *_vm->_global->_inter_execPtr; if (block == 1) { funcBlock(retFlag); @@ -266,7 +266,7 @@ void Inter::callSub(int16 retFlag) { } } - if ((char *)_vm->_global->_inter_execPtr == _vm->_game->totFileData) + if ((char *)_vm->_global->_inter_execPtr == _vm->_game->_totFileData) _terminate = true; } diff --git a/gob/inter_v1.cpp b/gob/inter_v1.cpp index 2dde0d9078..eeb8ef218c 100644 --- a/gob/inter_v1.cpp +++ b/gob/inter_v1.cpp @@ -533,19 +533,19 @@ bool Inter_v1::o1_printText(char &cmdCount, int16 &counter, int16 &retFlag) { int16 i; debug(3, "printText"); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); - - _vm->_draw->backColor = _vm->_parse->parseValExpr(); - _vm->_draw->frontColor = _vm->_parse->parseValExpr(); - _vm->_draw->fontIndex = _vm->_parse->parseValExpr(); - _vm->_draw->destSurface = 21; - _vm->_draw->textToPrint = buf; - _vm->_draw->transparency = 0; - - if (_vm->_draw->backColor >= 16) { - _vm->_draw->backColor = 0; - _vm->_draw->transparency = 1; + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); + + _vm->_draw->_backColor = _vm->_parse->parseValExpr(); + _vm->_draw->_frontColor = _vm->_parse->parseValExpr(); + _vm->_draw->_fontIndex = _vm->_parse->parseValExpr(); + _vm->_draw->_destSurface = 21; + _vm->_draw->_textToPrint = buf; + _vm->_draw->_transparency = 0; + + if (_vm->_draw->_backColor >= 16) { + _vm->_draw->_backColor = 0; + _vm->_draw->_transparency = 1; } do { @@ -610,8 +610,8 @@ void Inter_v1::o1_initCursor(void) { int16 count; int16 i; - _vm->_draw->cursorXDeltaVar = _vm->_parse->parseVarIndex(); - _vm->_draw->cursorYDeltaVar = _vm->_parse->parseVarIndex(); + _vm->_draw->_cursorXDeltaVar = _vm->_parse->parseVarIndex(); + _vm->_draw->_cursorYDeltaVar = _vm->_parse->parseVarIndex(); width = load16(); if (width < 16) @@ -625,37 +625,37 @@ void Inter_v1::o1_initCursor(void) { if (count < 2) count = 2; - if (width != _vm->_draw->cursorWidth || height != _vm->_draw->cursorHeight || - _vm->_draw->cursorSprites->width != width * count) { + if (width != _vm->_draw->_cursorWidth || height != _vm->_draw->_cursorHeight || + _vm->_draw->_cursorSprites->width != width * count) { - _vm->_video->freeSurfDesc(_vm->_draw->cursorSprites); - _vm->_video->freeSurfDesc(_vm->_draw->cursorBack); + _vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites); + _vm->_video->freeSurfDesc(_vm->_draw->_cursorBack); - _vm->_draw->cursorWidth = width; - _vm->_draw->cursorHeight = height; + _vm->_draw->_cursorWidth = width; + _vm->_draw->_cursorHeight = height; if (count < 0x80) - _vm->_draw->transparentCursor = 1; + _vm->_draw->_transparentCursor = 1; else - _vm->_draw->transparentCursor = 0; + _vm->_draw->_transparentCursor = 0; if (count > 0x80) count -= 0x80; - _vm->_draw->cursorSprites = - _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->cursorWidth * count, - _vm->_draw->cursorHeight, 2); - _vm->_draw->spritesArray[23] = _vm->_draw->cursorSprites; + _vm->_draw->_cursorSprites = + _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth * count, + _vm->_draw->_cursorHeight, 2); + _vm->_draw->_spritesArray[23] = _vm->_draw->_cursorSprites; - _vm->_draw->cursorBack = - _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->cursorWidth, - _vm->_draw->cursorHeight, 0); + _vm->_draw->_cursorBack = + _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth, + _vm->_draw->_cursorHeight, 0); for (i = 0; i < 40; i++) { - _vm->_draw->cursorAnimLow[i] = -1; - _vm->_draw->cursorAnimDelays[i] = 0; - _vm->_draw->cursorAnimHigh[i] = 0; + _vm->_draw->_cursorAnimLow[i] = -1; + _vm->_draw->_cursorAnimDelays[i] = 0; + _vm->_draw->_cursorAnimHigh[i] = 0; } - _vm->_draw->cursorAnimLow[1] = 0; + _vm->_draw->_cursorAnimLow[1] = 0; } } @@ -663,18 +663,18 @@ void Inter_v1::o1_initCursorAnim(void) { int16 ind; ind = _vm->_parse->parseValExpr(); - _vm->_draw->cursorAnimLow[ind] = load16(); - _vm->_draw->cursorAnimHigh[ind] = load16(); - _vm->_draw->cursorAnimDelays[ind] = load16(); + _vm->_draw->_cursorAnimLow[ind] = load16(); + _vm->_draw->_cursorAnimHigh[ind] = load16(); + _vm->_draw->_cursorAnimDelays[ind] = load16(); } void Inter_v1::o1_clearCursorAnim(void) { int16 ind; ind = _vm->_parse->parseValExpr(); - _vm->_draw->cursorAnimLow[ind] = -1; - _vm->_draw->cursorAnimHigh[ind] = 0; - _vm->_draw->cursorAnimDelays[ind] = 0; + _vm->_draw->_cursorAnimLow[ind] = -1; + _vm->_draw->_cursorAnimHigh[ind] = 0; + _vm->_draw->_cursorAnimDelays[ind] = 0; } bool Inter_v1::o1_drawOperations(char &cmdCount, int16 &counter, int16 &retFlag) { @@ -772,8 +772,8 @@ bool Inter_v1::o1_readData(char &cmdCount, int16 &counter, int16 &retFlag) { size = _vm->_parse->parseValExpr(); offset = _vm->_parse->parseValExpr(); - if (_vm->_game->extHandle >= 0) - _vm->_dataio->closeData(_vm->_game->extHandle); + if (_vm->_game->_extHandle >= 0) + _vm->_dataio->closeData(_vm->_game->_extHandle); WRITE_VAR(1, 1); handle = _vm->_dataio->openData(_vm->_global->_inter_resStr); @@ -791,8 +791,8 @@ bool Inter_v1::o1_readData(char &cmdCount, int16 &counter, int16 &retFlag) { WRITE_VAR(1, 0); } - if (_vm->_game->extHandle >= 0) - _vm->_game->extHandle = _vm->_dataio->openData(_vm->_game->curExtFile); + if (_vm->_game->_extHandle >= 0) + _vm->_game->_extHandle = _vm->_dataio->openData(_vm->_game->_curExtFile); return false; } @@ -803,17 +803,17 @@ bool Inter_v1::o1_loadFont(char &cmdCount, int16 &counter, int16 &retFlag) { evalExpr(0); index = load16(); - if (_vm->_draw->fonts[index] != 0) - _vm->_util->freeFont(_vm->_draw->fonts[index]); + if (_vm->_draw->_fonts[index] != 0) + _vm->_util->freeFont(_vm->_draw->_fonts[index]); _vm->_draw->animateCursor(4); - if (_vm->_game->extHandle >= 0) - _vm->_dataio->closeData(_vm->_game->extHandle); + if (_vm->_game->_extHandle >= 0) + _vm->_dataio->closeData(_vm->_game->_extHandle); - _vm->_draw->fonts[index] = _vm->_util->loadFont(_vm->_global->_inter_resStr); + _vm->_draw->_fonts[index] = _vm->_util->loadFont(_vm->_global->_inter_resStr); - if (_vm->_game->extHandle >= 0) - _vm->_game->extHandle = _vm->_dataio->openData(_vm->_game->curExtFile); + if (_vm->_game->_extHandle >= 0) + _vm->_game->_extHandle = _vm->_dataio->openData(_vm->_game->_curExtFile); return false; } @@ -821,10 +821,10 @@ bool Inter_v1::o1_freeFont(char &cmdCount, int16 &counter, int16 &retFlag) { int16 index; index = load16(); - if (_vm->_draw->fonts[index] != 0) - _vm->_util->freeFont(_vm->_draw->fonts[index]); + if (_vm->_draw->_fonts[index] != 0) + _vm->_util->freeFont(_vm->_draw->_fonts[index]); - _vm->_draw->fonts[index] = 0; + _vm->_draw->_fonts[index] = 0; return false; } @@ -907,74 +907,74 @@ bool Inter_v1::o1_strToLong(char &cmdCount, int16 &counter, int16 &retFlag) { bool Inter_v1::o1_invalidate(char &cmdCount, int16 &counter, int16 &retFlag) { warning("invalidate: 'bugged' function!"); - _vm->_draw->destSurface = load16(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->spriteRight = _vm->_parse->parseValExpr(); - _vm->_draw->frontColor = _vm->_parse->parseValExpr(); + _vm->_draw->_destSurface = load16(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteRight = _vm->_parse->parseValExpr(); + _vm->_draw->_frontColor = _vm->_parse->parseValExpr(); _vm->_draw->spriteOperation(DRAW_INVALIDATE); return false; } bool Inter_v1::o1_loadSpriteContent(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->spriteLeft = load16(); - _vm->_draw->destSurface = load16(); - _vm->_draw->transparency = load16(); - _vm->_draw->destSpriteX = 0; - _vm->_draw->destSpriteY = 0; + _vm->_draw->_spriteLeft = load16(); + _vm->_draw->_destSurface = load16(); + _vm->_draw->_transparency = load16(); + _vm->_draw->_destSpriteX = 0; + _vm->_draw->_destSpriteY = 0; _vm->_draw->spriteOperation(DRAW_LOADSPRITE); return false; } bool Inter_v1::o1_copySprite(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->sourceSurface = load16(); - _vm->_draw->destSurface = load16(); + _vm->_draw->_sourceSurface = load16(); + _vm->_draw->_destSurface = load16(); - _vm->_draw->spriteLeft = _vm->_parse->parseValExpr(); - _vm->_draw->spriteTop = _vm->_parse->parseValExpr(); - _vm->_draw->spriteRight = _vm->_parse->parseValExpr(); - _vm->_draw->spriteBottom = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteLeft = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteTop = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteRight = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->transparency = load16(); + _vm->_draw->_transparency = load16(); _vm->_draw->spriteOperation(DRAW_BLITSURF); return false; } bool Inter_v1::o1_putPixel(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->destSurface = load16(); + _vm->_draw->_destSurface = load16(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->frontColor = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_frontColor = _vm->_parse->parseValExpr(); _vm->_draw->spriteOperation(DRAW_PUTPIXEL); return false; } bool Inter_v1::o1_fillRect(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->destSurface = load16(); + _vm->_draw->_destSurface = load16(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->spriteRight = _vm->_parse->parseValExpr(); - _vm->_draw->spriteBottom = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteRight = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr(); - _vm->_draw->backColor = _vm->_parse->parseValExpr(); + _vm->_draw->_backColor = _vm->_parse->parseValExpr(); _vm->_draw->spriteOperation(DRAW_FILLRECT); return false; } bool Inter_v1::o1_drawLine(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->destSurface = load16(); + _vm->_draw->_destSurface = load16(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->spriteRight = _vm->_parse->parseValExpr(); - _vm->_draw->spriteBottom = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteRight = _vm->_parse->parseValExpr(); + _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr(); - _vm->_draw->frontColor = _vm->_parse->parseValExpr(); + _vm->_draw->_frontColor = _vm->_parse->parseValExpr(); _vm->_draw->spriteOperation(DRAW_DRAWLINE); return false; } @@ -991,11 +991,11 @@ bool Inter_v1::o1_createSprite(char &cmdCount, int16 &counter, int16 &retFlag) { flag = load16(); if (flag == 1) - _vm->_draw->spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); + _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); else - _vm->_draw->spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 0); + _vm->_draw->_spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 0); - _vm->_video->clearSurf(_vm->_draw->spritesArray[index]); + _vm->_video->clearSurf(_vm->_draw->_spritesArray[index]); return false; } @@ -1003,11 +1003,11 @@ bool Inter_v1::o1_freeSprite(char &cmdCount, int16 &counter, int16 &retFlag) { int16 index; index = load16(); - if (_vm->_draw->spritesArray[index] == 0) + if (_vm->_draw->_spritesArray[index] == 0) return false; - _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[index]); - _vm->_draw->spritesArray[index] = 0; + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[index]); + _vm->_draw->_spritesArray[index] = 0; return false; } @@ -1022,7 +1022,7 @@ bool Inter_v1::o1_playComposition(char &cmdCount, int16 &counter, int16 &retFlag for (i = 0; i < 50; i++) composition[i] = (int16)VAR_OFFSET(dataVar + i * 4); - _vm->_snd->playComposition(_vm->_game->soundSamples, composition, freqVal); + _vm->_snd->playComposition(_vm->_game->_soundSamples, composition, freqVal); return false; } @@ -1044,7 +1044,7 @@ bool Inter_v1::o1_playSound(char &cmdCount, int16 &counter, int16 &retFlag) { _vm->_snd->stopSound(0); _soundEndTimeKey = 0; - if (_vm->_game->soundSamples[index] == 0) + if (_vm->_game->_soundSamples[index] == 0) return false; if (repCount < 0) { @@ -1055,17 +1055,17 @@ bool Inter_v1::o1_playSound(char &cmdCount, int16 &counter, int16 &retFlag) { _soundEndTimeKey = _vm->_util->getTimeKey(); if (frequency == 0) { - freq2 = _vm->_game->soundSamples[index]->frequency; + freq2 = _vm->_game->_soundSamples[index]->frequency; } else { freq2 = frequency; } _soundStopVal = - (10 * (_vm->_game->soundSamples[index]->size / 2)) / freq2; + (10 * (_vm->_game->_soundSamples[index]->size / 2)) / freq2; _soundEndTimeKey += - ((_vm->_game->soundSamples[index]->size * repCount - - _vm->_game->soundSamples[index]->size / 2) * 1000) / freq2; + ((_vm->_game->_soundSamples[index]->size * repCount - + _vm->_game->_soundSamples[index]->size / 2) * 1000) / freq2; } - _vm->_snd->playSample(_vm->_game->soundSamples[index], repCount, frequency); + _vm->_snd->playSample(_vm->_game->_soundSamples[index], repCount, frequency); return false; } @@ -1080,44 +1080,44 @@ bool Inter_v1::o1_loadCursor(char &cmdCount, int16 &counter, int16 &retFlag) { id = load16(); index = *_vm->_global->_inter_execPtr++; - itemPtr = &_vm->_game->totResourceTable->items[id]; + itemPtr = &_vm->_game->_totResourceTable->items[id]; offset = itemPtr->offset; if (offset >= 0) { dataBuf = - ((char *)_vm->_game->totResourceTable) + szGame_TotResTable + - szGame_TotResItem * _vm->_game->totResourceTable->itemsCount + offset; + ((char *)_vm->_game->_totResourceTable) + szGame_TotResTable + + szGame_TotResItem * _vm->_game->_totResourceTable->itemsCount + offset; } else { - dataBuf = _vm->_game->imFileData + (int32)READ_LE_UINT32(&((int32 *)_vm->_game->imFileData)[-offset - 1]); + dataBuf = _vm->_game->_imFileData + (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]); } width = itemPtr->width; height = itemPtr->height; - _vm->_video->fillRect(_vm->_draw->cursorSprites, index * _vm->_draw->cursorWidth, 0, - index * _vm->_draw->cursorWidth + _vm->_draw->cursorWidth - 1, - _vm->_draw->cursorHeight - 1, 0); + _vm->_video->fillRect(_vm->_draw->_cursorSprites, index * _vm->_draw->_cursorWidth, 0, + index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1, + _vm->_draw->_cursorHeight - 1, 0); _vm->_video->drawPackedSprite((byte*)dataBuf, width, height, - index * _vm->_draw->cursorWidth, 0, 0, _vm->_draw->cursorSprites); - _vm->_draw->cursorAnimLow[index] = 0; + index * _vm->_draw->_cursorWidth, 0, 0, _vm->_draw->_cursorSprites); + _vm->_draw->_cursorAnimLow[index] = 0; return false; } bool Inter_v1::o1_loadSpriteToPos(char &cmdCount, int16 &counter, int16 &retFlag) { debug(4, "loadSpriteToPos"); - _vm->_draw->spriteLeft = load16(); + _vm->_draw->_spriteLeft = load16(); - _vm->_draw->destSpriteX = _vm->_parse->parseValExpr(); - _vm->_draw->destSpriteY = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); + _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); - _vm->_draw->transparency = _vm->_global->_inter_execPtr[0]; - _vm->_draw->destSurface = (_vm->_global->_inter_execPtr[0] / 2) - 1; + _vm->_draw->_transparency = _vm->_global->_inter_execPtr[0]; + _vm->_draw->_destSurface = (_vm->_global->_inter_execPtr[0] / 2) - 1; - if (_vm->_draw->destSurface < 0) - _vm->_draw->destSurface = 101; - _vm->_draw->transparency &= 1; + if (_vm->_draw->_destSurface < 0) + _vm->_draw->_destSurface = 101; + _vm->_draw->_transparency &= 1; _vm->_global->_inter_execPtr += 2; _vm->_draw->spriteOperation(DRAW_LOADSPRITE); @@ -1144,7 +1144,7 @@ bool Inter_v1::o1_loadTot(char &cmdCount, int16 &counter, int16 &retFlag) { strcat(buf, ".tot"); _terminate = true; - strcpy(_vm->_game->totToLoad, buf); + strcpy(_vm->_game->_totToLoad, buf); return false; } @@ -1217,7 +1217,7 @@ bool Inter_v1::o1_keyFunc(char &cmdCount, int16 &counter, int16 &retFlag) { _vm->_util->waitKey(); return false; } - key = _vm->_game->checkKeys(&_vm->_global->_inter_mouseX, &_vm->_global->_inter_mouseY, &_vm->_game->mouseButtons, 0); + key = _vm->_game->checkKeys(&_vm->_global->_inter_mouseX, &_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons, 0); storeKey(key); return false; @@ -1302,7 +1302,7 @@ bool Inter_v1::o1_whileDo(char &cmdCount, int16 &counter, int16 &retFlag) { } void Inter_v1::o1_setRenderFlags(void) { - _vm->_draw->renderFlags = _vm->_parse->parseValExpr(); + _vm->_draw->_renderFlags = _vm->_parse->parseValExpr(); } void Inter_v1::o1_loadAnim(void) { @@ -1385,18 +1385,18 @@ void Inter_v1::o1_stopCD(void) { void Inter_v1::o1_loadFontToSprite(void) { int16 i = load16(); - _vm->_draw->fontToSprite[i].sprite = load16(); - _vm->_draw->fontToSprite[i].base = load16(); - _vm->_draw->fontToSprite[i].width = load16(); - _vm->_draw->fontToSprite[i].height = load16(); + _vm->_draw->_fontToSprite[i].sprite = load16(); + _vm->_draw->_fontToSprite[i].base = load16(); + _vm->_draw->_fontToSprite[i].width = load16(); + _vm->_draw->_fontToSprite[i].height = load16(); } void Inter_v1::o1_freeFontToSprite(void) { int16 i = load16(); - _vm->_draw->fontToSprite[i].sprite = -1; - _vm->_draw->fontToSprite[i].base = -1; - _vm->_draw->fontToSprite[i].width = -1; - _vm->_draw->fontToSprite[i].height = -1; + _vm->_draw->_fontToSprite[i].sprite = -1; + _vm->_draw->_fontToSprite[i].base = -1; + _vm->_draw->_fontToSprite[i].width = -1; + _vm->_draw->_fontToSprite[i].height = -1; } void Inter_v1::executeDrawOpcode(byte i) { @@ -1441,7 +1441,7 @@ const char *Inter_v1::getOpcodeFuncDesc(byte i, byte j) bool Inter_v1::o1_callSub(char &cmdCount, int16 &counter, int16 &retFlag) { char *storedIP = _vm->_global->_inter_execPtr; - _vm->_global->_inter_execPtr = (char *)_vm->_game->totFileData + READ_LE_UINT16(_vm->_global->_inter_execPtr); + _vm->_global->_inter_execPtr = (char *)_vm->_game->_totFileData + READ_LE_UINT16(_vm->_global->_inter_execPtr); if (counter == cmdCount && retFlag == 2) return true; @@ -1570,8 +1570,8 @@ bool Inter_v1::o1_returnTo(char &cmdCount, int16 &counter, int16 &retFlag) { } bool Inter_v1::o1_setBackDelta(char &cmdCount, int16 &counter, int16 &retFlag) { - _vm->_draw->backDeltaX = _vm->_parse->parseValExpr(); - _vm->_draw->backDeltaY = _vm->_parse->parseValExpr(); + _vm->_draw->_backDeltaX = _vm->_parse->parseValExpr(); + _vm->_draw->_backDeltaY = _vm->_parse->parseValExpr(); return false; } @@ -1595,7 +1595,7 @@ bool Inter_v1::o1_animatePalette(char &cmdCount, int16 &counter, int16 &retFlag) _vm->_util->waitEndFrame(); animPalette(); storeKey(_vm->_game->checkKeys(&_vm->_global->_inter_mouseX, - &_vm->_global->_inter_mouseY, &_vm->_game->mouseButtons, 0)); + &_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons, 0)); return false; } diff --git a/gob/map.cpp b/gob/map.cpp index 4e5c7d823c..0ae49765be 100644 --- a/gob/map.cpp +++ b/gob/map.cpp @@ -428,7 +428,7 @@ void Map::loadItemToObject(void) { count = loadFromAvo_LE_UINT16(); for (i = 0; i < count; i++) { _avoDataPtr += 20; - _vm->_goblin->itemToObject[i] = loadFromAvo_LE_UINT16(); + _vm->_goblin->_itemToObject[i] = loadFromAvo_LE_UINT16(); _avoDataPtr += 5; } } @@ -510,41 +510,41 @@ void Map::loadMapObjects(char *avjFile) { savedPtr3 = _avoDataPtr; _avoDataPtr += count3 * 8; - _vm->_goblin->gobsCount = loadFromAvo_LE_UINT16(); - for (i = 0; i < _vm->_goblin->gobsCount; i++) { - _vm->_goblin->goblins[i] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); + _vm->_goblin->_gobsCount = loadFromAvo_LE_UINT16(); + for (i = 0; i < _vm->_goblin->_gobsCount; i++) { + _vm->_goblin->_goblins[i] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); - _vm->_goblin->goblins[i]->xPos = READ_LE_UINT16(savedPtr2); + _vm->_goblin->_goblins[i]->xPos = READ_LE_UINT16(savedPtr2); savedPtr2 += 2; - _vm->_goblin->goblins[i]->yPos = READ_LE_UINT16(savedPtr2); + _vm->_goblin->_goblins[i]->yPos = READ_LE_UINT16(savedPtr2); savedPtr2 += 2; - _vm->_goblin->goblins[i]->order = READ_LE_UINT16(savedPtr2); + _vm->_goblin->_goblins[i]->order = READ_LE_UINT16(savedPtr2); savedPtr2 += 2; - _vm->_goblin->goblins[i]->state = READ_LE_UINT16(savedPtr2); + _vm->_goblin->_goblins[i]->state = READ_LE_UINT16(savedPtr2); savedPtr2 += 2; if (i == 3) - _vm->_goblin->goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 70); + _vm->_goblin->_goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 70); else - _vm->_goblin->goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); + _vm->_goblin->_goblins[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); // FIXME: All is wrong further. We should unwind calls to loadDataFromAvo() - loadDataFromAvo((char *)_vm->_goblin->goblins[i]->stateMach, 40 * szGob_StateLine); + loadDataFromAvo((char *)_vm->_goblin->_goblins[i]->stateMach, 40 * szGob_StateLine); _avoDataPtr += 160; - _vm->_goblin->goblins[i]->multObjIndex = *_avoDataPtr; + _vm->_goblin->_goblins[i]->multObjIndex = *_avoDataPtr; _avoDataPtr += 2; - _vm->_goblin->goblins[i]->realStateMach = _vm->_goblin->goblins[i]->stateMach; + _vm->_goblin->_goblins[i]->realStateMach = _vm->_goblin->_goblins[i]->stateMach; for (state = 0; state < 40; state++) { for (col = 0; col < 6; col++) { - if (_vm->_goblin->goblins[i]->stateMach[state][col] == 0) + if (_vm->_goblin->_goblins[i]->stateMach[state][col] == 0) continue; Goblin::Gob_State *tmpState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->goblins[i]->stateMach[state][col] = tmpState; + _vm->_goblin->_goblins[i]->stateMach[state][col] = tmpState; tmpState->animation = loadFromAvo_LE_UINT16(); tmpState->layer = loadFromAvo_LE_UINT16(); @@ -568,7 +568,7 @@ void Map::loadMapObjects(char *avjFile) { } pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->goblins[0]->stateMach[39][0] = pState; + _vm->_goblin->_goblins[0]->stateMach[39][0] = pState; pState->animation = 0; pState->layer = 98; pState->unk0 = 0; @@ -576,7 +576,7 @@ void Map::loadMapObjects(char *avjFile) { pState->sndItem = -1; pState = (Goblin::Gob_State *) malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->goblins[1]->stateMach[39][0] = pState; + _vm->_goblin->_goblins[1]->stateMach[39][0] = pState; pState->animation = 0; pState->layer = 99; pState->unk0 = 0; @@ -584,25 +584,25 @@ void Map::loadMapObjects(char *avjFile) { pState->sndItem = -1; pState = (Goblin::Gob_State *) malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->goblins[2]->stateMach[39][0] = pState; + _vm->_goblin->_goblins[2]->stateMach[39][0] = pState; pState->animation = 0; pState->layer = 100; pState->unk0 = 0; pState->unk1 = 0; pState->sndItem = -1; - _vm->_goblin->goblins[2]->stateMach[10][0]->sndFrame = 13; - _vm->_goblin->goblins[2]->stateMach[11][0]->sndFrame = 13; - _vm->_goblin->goblins[2]->stateMach[28][0]->sndFrame = 13; - _vm->_goblin->goblins[2]->stateMach[29][0]->sndFrame = 13; + _vm->_goblin->_goblins[2]->stateMach[10][0]->sndFrame = 13; + _vm->_goblin->_goblins[2]->stateMach[11][0]->sndFrame = 13; + _vm->_goblin->_goblins[2]->stateMach[28][0]->sndFrame = 13; + _vm->_goblin->_goblins[2]->stateMach[29][0]->sndFrame = 13; - _vm->_goblin->goblins[1]->stateMach[10][0]->sndFrame = 13; - _vm->_goblin->goblins[1]->stateMach[11][0]->sndFrame = 13; + _vm->_goblin->_goblins[1]->stateMach[10][0]->sndFrame = 13; + _vm->_goblin->_goblins[1]->stateMach[11][0]->sndFrame = 13; for (state = 40; state < 70; state++) { pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->goblins[3]->stateMach[state][0] = pState; - _vm->_goblin->goblins[3]->stateMach[state][1] = 0; + _vm->_goblin->_goblins[3]->stateMach[state][0] = pState; + _vm->_goblin->_goblins[3]->stateMach[state][1] = 0; pState->animation = 9; pState->layer = state - 40; @@ -610,38 +610,38 @@ void Map::loadMapObjects(char *avjFile) { pState->sndFrame = 0; } - _vm->_goblin->objCount = loadFromAvo_LE_UINT16(); - for (i = 0; i < _vm->_goblin->objCount; i++) { - _vm->_goblin->objects[i] = + _vm->_goblin->_objCount = loadFromAvo_LE_UINT16(); + for (i = 0; i < _vm->_goblin->_objCount; i++) { + _vm->_goblin->_objects[i] = (Goblin::Gob_Object *) malloc(sizeof(Goblin::Gob_Object)); - _vm->_goblin->objects[i]->xPos = READ_LE_UINT16(savedPtr3); + _vm->_goblin->_objects[i]->xPos = READ_LE_UINT16(savedPtr3); savedPtr3 += 2; - _vm->_goblin->objects[i]->yPos = READ_LE_UINT16(savedPtr3); + _vm->_goblin->_objects[i]->yPos = READ_LE_UINT16(savedPtr3); savedPtr3 += 2; - _vm->_goblin->objects[i]->order = READ_LE_UINT16(savedPtr3); + _vm->_goblin->_objects[i]->order = READ_LE_UINT16(savedPtr3); savedPtr3 += 2; - _vm->_goblin->objects[i]->state = READ_LE_UINT16(savedPtr3); + _vm->_goblin->_objects[i]->state = READ_LE_UINT16(savedPtr3); savedPtr3 += 2; - _vm->_goblin->objects[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); + _vm->_goblin->_objects[i]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); - loadDataFromAvo((char *)_vm->_goblin->objects[i]->stateMach, 40 * szGob_StateLine); + loadDataFromAvo((char *)_vm->_goblin->_objects[i]->stateMach, 40 * szGob_StateLine); _avoDataPtr += 160; - _vm->_goblin->objects[i]->multObjIndex = *_avoDataPtr; + _vm->_goblin->_objects[i]->multObjIndex = *_avoDataPtr; _avoDataPtr += 2; - _vm->_goblin->objects[i]->realStateMach = _vm->_goblin->objects[i]->stateMach; + _vm->_goblin->_objects[i]->realStateMach = _vm->_goblin->_objects[i]->stateMach; for (state = 0; state < 40; state++) { for (col = 0; col < 6; col++) { - if (_vm->_goblin->objects[i]->stateMach[state][col] == 0) + if (_vm->_goblin->_objects[i]->stateMach[state][col] == 0) continue; Goblin::Gob_State *tmpState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->objects[i]->stateMach[state][col] = tmpState; + _vm->_goblin->_objects[i]->stateMach[state][col] = tmpState; tmpState->animation = loadFromAvo_LE_UINT16(); tmpState->layer = loadFromAvo_LE_UINT16(); @@ -664,14 +664,14 @@ void Map::loadMapObjects(char *avjFile) { } } - _vm->_goblin->objects[10] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); - memset(_vm->_goblin->objects[10], 0, sizeof(Goblin::Gob_Object)); + _vm->_goblin->_objects[10] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object)); + memset(_vm->_goblin->_objects[10], 0, sizeof(Goblin::Gob_Object)); - _vm->_goblin->objects[10]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); - memset(_vm->_goblin->objects[10]->stateMach, 0, szGob_StateLine * 40); + _vm->_goblin->_objects[10]->stateMach = (Goblin::Gob_StateLine *)malloc(szGob_StateLine * 40); + memset(_vm->_goblin->_objects[10]->stateMach, 0, szGob_StateLine * 40); pState = (Goblin::Gob_State *)malloc(sizeof(Goblin::Gob_State)); - _vm->_goblin->objects[10]->stateMach[0][0] = pState; + _vm->_goblin->_objects[10]->stateMach[0][0] = pState; memset(pState, 0, sizeof(Goblin::Gob_State)); pState->animation = 9; @@ -681,11 +681,11 @@ void Map::loadMapObjects(char *avjFile) { pState->sndItem = -1; pState->sndFrame = 0; - _vm->_goblin->placeObject(_vm->_goblin->objects[10], 1); + _vm->_goblin->placeObject(_vm->_goblin->_objects[10], 1); - _vm->_goblin->objects[10]->realStateMach = _vm->_goblin->objects[10]->stateMach; - _vm->_goblin->objects[10]->type = 1; - _vm->_goblin->objects[10]->unk14 = 1; + _vm->_goblin->_objects[10]->realStateMach = _vm->_goblin->_objects[10]->stateMach; + _vm->_goblin->_objects[10]->type = 1; + _vm->_goblin->_objects[10]->unk14 = 1; state = loadFromAvo_LE_UINT16(); for (i = 0; i < state; i++) { @@ -711,7 +711,7 @@ void Map::loadMapObjects(char *avjFile) { free(dataBuf); - _vm->_goblin->soundData[14] = _vm->_snd->loadSoundData("diamant1.snd"); + _vm->_goblin->_soundData[14] = _vm->_snd->loadSoundData("diamant1.snd"); for (i = 0; i < soundCount; i++) { handle = _vm->_dataio->openData(sndNames[i]); @@ -719,7 +719,7 @@ void Map::loadMapObjects(char *avjFile) { continue; _vm->_dataio->closeData(handle); - _vm->_goblin->soundData[i] = _vm->_snd->loadSoundData(sndNames[i]); + _vm->_goblin->_soundData[i] = _vm->_snd->loadSoundData(sndNames[i]); } } @@ -731,34 +731,34 @@ void Map::loadMapsInitGobs(void) { error("load: Loading .pas/.pos files is not supported!"); for (i = 0; i < 3; i++) { - _vm->_goblin->nextLayer(_vm->_goblin->goblins[i]); + _vm->_goblin->nextLayer(_vm->_goblin->_goblins[i]); } for (i = 0; i < 3; i++) { layer = - _vm->_goblin->goblins[i]->stateMach[_vm->_goblin->goblins[i]->state][0]->layer; + _vm->_goblin->_goblins[i]->stateMach[_vm->_goblin->_goblins[i]->state][0]->layer; - _vm->_scenery->updateAnim(layer, 0, _vm->_goblin->goblins[i]->animation, 0, - _vm->_goblin->goblins[i]->xPos, _vm->_goblin->goblins[i]->yPos, 0); + _vm->_scenery->updateAnim(layer, 0, _vm->_goblin->_goblins[i]->animation, 0, + _vm->_goblin->_goblins[i]->xPos, _vm->_goblin->_goblins[i]->yPos, 0); - _vm->_goblin->goblins[i]->yPos = (_vm->_goblin->gobPositions[i].y + 1) * 6 - + _vm->_goblin->_goblins[i]->yPos = (_vm->_goblin->_gobPositions[i].y + 1) * 6 - (_vm->_scenery->toRedrawBottom - _vm->_scenery->animTop); - _vm->_goblin->goblins[i]->xPos = _vm->_goblin->gobPositions[i].x * 12 - + _vm->_goblin->_goblins[i]->xPos = _vm->_goblin->_gobPositions[i].x * 12 - (_vm->_scenery->toRedrawLeft - _vm->_scenery->animLeft); - _vm->_goblin->goblins[i]->order = _vm->_scenery->toRedrawBottom / 24 + 3; + _vm->_goblin->_goblins[i]->order = _vm->_scenery->toRedrawBottom / 24 + 3; } - _vm->_goblin->currentGoblin = 0; - _vm->_goblin->pressedMapX = _vm->_goblin->gobPositions[0].x; - _vm->_goblin->pressedMapY = _vm->_goblin->gobPositions[0].y; - _vm->_goblin->pathExistence = 0; + _vm->_goblin->_currentGoblin = 0; + _vm->_goblin->_pressedMapX = _vm->_goblin->_gobPositions[0].x; + _vm->_goblin->_pressedMapY = _vm->_goblin->_gobPositions[0].y; + _vm->_goblin->_pathExistence = 0; - _vm->_goblin->goblins[0]->doAnim = 0; - _vm->_goblin->goblins[1]->doAnim = 1; - _vm->_goblin->goblins[2]->doAnim = 1; + _vm->_goblin->_goblins[0]->doAnim = 0; + _vm->_goblin->_goblins[1]->doAnim = 1; + _vm->_goblin->_goblins[2]->doAnim = 1; } } // End of namespace Gob diff --git a/gob/module.mk b/gob/module.mk index 5a9dccf71a..9eedde2cdc 100644 --- a/gob/module.mk +++ b/gob/module.mk @@ -16,6 +16,7 @@ MODULE_OBJS := \ gob/inter_v2.o \ gob/map.o \ gob/mult.o \ + gob/music.o \ gob/pack.o \ gob/palanim.o \ gob/parse.o \ diff --git a/gob/mult.cpp b/gob/mult.cpp index d9d1ae8861..41608698ee 100644 --- a/gob/mult.cpp +++ b/gob/mult.cpp @@ -254,15 +254,15 @@ void Mult::animate(void) { if (pNeedRedraw[i] == 0 || objects[i].lastLeft == -1) continue; - _vm->_draw->sourceSurface = 22; - _vm->_draw->destSurface = 21; - _vm->_draw->spriteLeft = pDirtyLefts[i] - _vm->_anim->_areaLeft; - _vm->_draw->spriteTop = pDirtyTops[i] - _vm->_anim->_areaTop; - _vm->_draw->spriteRight = pDirtyRights[i] - pDirtyLefts[i] + 1; - _vm->_draw->spriteBottom = pDirtyBottoms[i] - pDirtyTops[i] + 1; - _vm->_draw->destSpriteX = pDirtyLefts[i]; - _vm->_draw->destSpriteY = pDirtyTops[i]; - _vm->_draw->transparency = 0; + _vm->_draw->_sourceSurface = 22; + _vm->_draw->_destSurface = 21; + _vm->_draw->_spriteLeft = pDirtyLefts[i] - _vm->_anim->_areaLeft; + _vm->_draw->_spriteTop = pDirtyTops[i] - _vm->_anim->_areaTop; + _vm->_draw->_spriteRight = pDirtyRights[i] - pDirtyLefts[i] + 1; + _vm->_draw->_spriteBottom = pDirtyBottoms[i] - pDirtyTops[i] + 1; + _vm->_draw->_destSpriteX = pDirtyLefts[i]; + _vm->_draw->_destSpriteY = pDirtyTops[i]; + _vm->_draw->_transparency = 0; _vm->_draw->spriteOperation(DRAW_BLITSURF); objects[i].lastLeft = -1; } @@ -470,10 +470,10 @@ void Mult::interInitMult(void) { _vm->_anim->_animSurf = _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_anim->_areaWidth, _vm->_anim->_areaHeight, 0); - _vm->_draw->spritesArray[22] = _vm->_anim->_animSurf; + _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; } - _vm->_video->drawSprite(_vm->_draw->backSurface, _vm->_anim->_animSurf, + _vm->_video->drawSprite(_vm->_draw->_backSurface, _vm->_anim->_animSurf, _vm->_anim->_areaLeft, _vm->_anim->_areaTop, _vm->_anim->_areaLeft + _vm->_anim->_areaWidth - 1, _vm->_anim->_areaTop + _vm->_anim->_areaHeight - 1, 0, 0, 0); @@ -577,7 +577,7 @@ char Mult::drawStatics(char stop) { _vm->_scenery->curStatic = staticIndices[_vm->_scenery->curStatic]; _vm->_scenery->renderStatic(_vm->_scenery->curStatic, _vm->_scenery->curStaticLayer); - _vm->_video->drawSprite(_vm->_draw->backSurface, _vm->_anim->_animSurf, + _vm->_video->drawSprite(_vm->_draw->_backSurface, _vm->_anim->_animSurf, 0, 0, 319, 199, 0, 0, 0); } return stop; @@ -811,13 +811,13 @@ char Mult::doSoundAnim(char stop) { if (sndKey->cmd == 1) { _vm->_snd->stopSound(0); stop = 0; - playSound(_vm->_game->soundSamples[sndKey->soundIndex], sndKey->repCount, + playSound(_vm->_game->_soundSamples[sndKey->soundIndex], sndKey->repCount, sndKey->freq, sndKey->channel); } else if (sndKey->cmd == 4) { _vm->_snd->stopSound(0); stop = 0; - playSound(_vm->_game->soundSamples[sndKey->soundIndex], sndKey->repCount, + playSound(_vm->_game->_soundSamples[sndKey->soundIndex], sndKey->repCount, sndKey->freq, sndKey->channel); } } else { @@ -888,9 +888,9 @@ void Mult::playMult(int16 startFrame, int16 endFrame, char checkEscape, _vm->_anim->_animSurf = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); - _vm->_draw->spritesArray[22] = _vm->_anim->_animSurf; + _vm->_draw->_spritesArray[22] = _vm->_anim->_animSurf; - _vm->_video->drawSprite(_vm->_draw->backSurface, _vm->_anim->_animSurf, + _vm->_video->drawSprite(_vm->_draw->_backSurface, _vm->_anim->_animSurf, 0, 0, 319, 199, 0, 0, 0); animDataAllocated = 1; diff --git a/gob/music.cpp b/gob/music.cpp new file mode 100644 index 0000000000..ed1973b2ba --- /dev/null +++ b/gob/music.cpp @@ -0,0 +1,378 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2006 The ScummVM project + * Original ADL-Player source Copyright (C) 2004 by Dorian Gray + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Header$ + * + */ + +#include "gob/music.h" +#include "gob/gob.h" + +namespace Gob { + +const unsigned char Music::_operators[] = {0, 1, 2, 8, 9, 10, 16, 17, 18}; +const unsigned char Music::_volRegNums[] = { + 3, 4, 5, + 11, 12, 13, + 19, 20, 21 +}; + + +Music::Music(GobEngine *vm) : _vm(vm) { + _data = 0; + _playPos = 0; + _dataSize = 0; + _rate = _vm->_mixer->getOutputRate(); + _opl = makeAdlibOPL(_rate); + _vm->_mixer->setupPremix(this, Audio::Mixer::kMusicSoundType); + _first = true; + _ended = false; + _playing = false; + _looping = true; + _samplesTillPoll = 0; + + setFreqs(); +} + +Music::~Music(void) { + if (_data); + delete _data; + _vm->_mixer->setupPremix(0); +} + +void Music::premixerCall(int16 *buf, uint len) { + if (!_playing) { + memset(buf, 0, 2 * len * sizeof(int16)); + return; + } + else { + if (_first) { + memset(buf, 0, 2 * len * sizeof(int16)); + pollMusic(); + return; + } + else { + uint32 render; + int16 *data = buf; + uint datalen = len; + while (datalen) { + if(_samplesTillPoll) { + render = (datalen > _samplesTillPoll) ? (_samplesTillPoll) : (datalen); + datalen -= render; + _samplesTillPoll -= render; + YM3812UpdateOne(_opl, data, render); + data += render; + } else { + pollMusic(); + if(_ended) { + memset(data, 0, datalen * sizeof(int16)); + datalen = 0; + } + } + } + } + if(_ended) { + _first = true; + _ended = false; + _playPos = _data + 3 + (_data[1] + 1) * 0x38; + _samplesTillPoll = 0; + if(_looping) { + reset(); + setVoices(); + } + else + _playing = false; + } + // Convert mono data to stereo + for (int i = (len - 1); i >= 0; i--) { + buf[2 * i] = buf[2 * i + 1] = buf[i]; + } + } +} + +void Music::writeOPL(byte reg, byte val) { + debug(5, "writeOPL(%02X, %02X)", reg, val); + OPLWriteReg(_opl, reg, val); +} + +void Music::setFreqs(void) { + byte lin; + byte col; + long val; + + // Run through the 11 channels + for (lin = 0; lin < 11; lin ++) { + _notes[lin] = 0; + _notCol[lin] = 0; + _notLin[lin] = 0; + _notOn[lin] = false; + } + + // Run through the 25 lines + for (lin = 0; lin < 25; lin ++) { + // Run through the 12 columns + for (col = 0; col < 12; col ++) { + if (!col) + val = (((0x2710L + lin * 0x18) * 0xCB78 / 0x3D090) << 0xE) * 9 / 0x1B503; + _freqs[lin][col] = (short)((val + 4) >> 3); + val = val * 0x6A / 0x64; + // val = val * 392 / 370; + } + } +} + +void Music::reset() { + // Set frequencies and octave to 0; notes off + for (int i = 0; i < 9; i++) { + writeOPL(0xA0 | i, 0); + writeOPL(0xB0 | i, 0); + writeOPL(0xE0 | _operators[i] , 0); + writeOPL(0xE0 | _operators[i] + 3, 0); + } + + // Authorize the control of the waveformes + writeOPL(0x01, 0x20); +} + +void Music::setVoices() { + // Definitions of the 9 instruments + for (int i = 0; i < 9; i++) + setVoice(i, i, true); +} + +void Music::setVoice(byte voice, byte instr, bool set) { + unsigned short *strct; + byte channel; + + // i = 0 : 0 1 2 3 4 5 6 7 8 9 10 11 12 26 + // i = 1 : 13 14 15 16 17 18 19 20 21 22 23 24 25 27 + for (int i = 0; i < 2; i++) { + strct = (unsigned short*)(_data + 3 + instr * 0x38 + i * 0x1A); + channel = _operators[voice] + i * 3; + writeOPL(0xBD, 0x00); + writeOPL(0x08, 0x00); + writeOPL(0x40 | channel, ((strct[0] & 3) << 6) | (strct[8] & 0x3F)); + if (!i) + writeOPL(0xC0 | voice , ((strct[2] & 7) << 1) | (1 - (strct[12] & 1))); + writeOPL(0x60 | channel, ((strct[3] & 0xF) << 4) | (strct[6] & 0xF)); + writeOPL(0x80 | channel, ((strct[4] & 0xF) << 4) | (strct[7] & 0xF)); + writeOPL(0x20 | channel, ((strct[9] & 1) << 7) | + ((strct[10] & 1) << 6) | ((strct[5] & 1) << 5) | + ((strct[11] & 1) << 4) | (strct[1] & 0xF)); + if (!i) + writeOPL(0xE0 | channel, (strct[26] & 3)); + else + writeOPL(0xE0 | channel, (strct[14] & 3)); + if (i & set) + writeOPL(0x40 | channel, 0); + } +} + +void Music::setKey(byte voice, byte note, bool on, bool spec) { + short freq = 0; + short octa = 0; + + // Instruction AX + if (spec) { + // 0x7F donne 0x16B; + // 7F + // << 7 = 3F80 + // + E000 = 11F80 + // & FFFF = 1F80 + // * 19 = 31380 + // / 2000 = 18 => Ligne 18h, colonne 0 => freq 16B + + // 0x3A donne 0x2AF; + // 3A + // << 7 = 1D00 + // + E000 = FD00 négatif + // * 19 = xB500 + // / 2000 = -2 => Ligne 17h, colonne -1 + + // 2E + // << 7 = 1700 + // + E000 = F700 négatif + // * 19 = x1F00 + // / 2000 = + short a; + short lin; + short col; + + a = (note << 7) + 0xE000; // Volontairement tronqué + a = (short)((long)a * 25 / 0x2000); + if (a < 0) { + col = - ((24 - a) / 25); + lin = (-a % 25); + if (lin) + lin = 25 - lin; + } + else { + col = a / 25; + lin = a % 25; + } + + _notCol[voice] = col; + _notLin[voice] = lin; + note = _notes[voice]; + } + // Instructions 0X 9X 8X + else { + note -= 12; + _notOn[voice] = on; + } + + _notes[voice] = note; + note += _notCol[voice]; + note = MIN(0x5F, note); + octa = note / 12; + freq = _freqs[_notLin[voice]][note - octa * 12]; + + writeOPL(0xA0 + voice, freq & 0xff); + writeOPL(0xB0 + voice, (freq >> 8) | (octa << 2) | 0x20 * on); + + if (!freq) + warning("Voice %d, note %02X unknown\n", voice, note); +} + +void Music::setVolume(byte voice, byte volume) { + volume = 0x3F - (volume * 0x7E + 0x7F) / 0xFE; + writeOPL(0x40 + _volRegNums[voice], volume); +} + +void Music::pollMusic(void) { + unsigned char instr; + byte channel; + byte note; + byte volume; + uint16 tempo; + + if (_playPos > (_data + _dataSize)) { + _ended = true; + return; + } + + // First tempo, we'll ignore it... + if (_first) { + tempo = *(_playPos++); + // Tempo on 2 bytes + if (tempo & 0x80) + tempo = ((tempo & 3) << 8) | *(_playPos++); + } + _first = false; + + // Instruction + instr = *(_playPos++); + channel = instr & 0x0F; + + switch (instr & 0xF0) { + // Note on + Volume + case 0x00: + note = *(_playPos++); + _pollNotes[channel] = note; + setVolume(channel, *(_playPos++)); + setKey(channel, note, true, false); + break; + // Note on + case 0x90: + note = *(_playPos++); + _pollNotes[channel] = note; + setKey(channel, note, true, false); + break; + // Last note off + case 0x80: + note = _pollNotes[channel]; + setKey(channel, note, false, false); + break; + // Frequency on/off + case 0xA0: + note = *(_playPos++); + setKey(channel, note, _notOn[channel], true); + break; + // Volume + case 0xB0: + volume = *(_playPos++); + setVolume(channel, volume); + break; + // Program change + case 0xC0: + setVoice(channel, *(_playPos++), false); + break; + // Special + case 0xF0: + break; + default: + warning("Unknown command in ADL, stopping playback"); + _looping = false; + _ended = true; + break; + } + // End instruction + if (instr == 0xFF) { + _ended = true; + } + + // Temporization + tempo = *(_playPos++); + // End tempo + if (tempo == 0xFF) { + _ended = true; + return; + } + // Tempo on 2 bytes + if (tempo & 0x80) + tempo = ((tempo & 3) << 8) | *(_playPos++); + if (!tempo) + tempo ++; + + _samplesTillPoll = tempo * (_rate / 1000); +} + +void Music::startPlay(void) { + if (!_data) + return; + + _playing = true; +} + +bool Music::loadMusic(const char *filename) { + Common::File song; + + song.open(filename); + if (!song.isOpen()) + return false; + + _dataSize = song.size(); + _data = new byte[_dataSize]; + song.read(_data, _dataSize); + song.close(); + + reset(); + setVoices(); + _playPos = _data + 3 + (_data[1] + 1) * 0x38; + + return true; +} + +void Music::unloadMusic(void) { + _playing = false; + + if (_data) + delete _data; +} + +} // End of namespace Gob diff --git a/gob/music.h b/gob/music.h new file mode 100644 index 0000000000..a8aa06e782 --- /dev/null +++ b/gob/music.h @@ -0,0 +1,91 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2006 The ScummVM project + * Original ADL-Player source Copyright (C) 2004 by Dorian Gray + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Header$ + * + */ + +#ifndef GOB_MUSIC_H +#define GOB_MUSIC_H + +#include "sound/audiostream.h" +#include "sound/fmopl.h" + +#include "gob/gob.h" + +namespace Gob { + +class GobEngine; + +class Music : public AudioStream { +public: + Music(GobEngine *vm); + ~Music(); + + bool playing() { return _playing; } + bool getLooping() { return _looping; } + void setLooping(bool looping) { _looping = looping; } + void startPlay(void); + void stopPlay(void) { _playing = false; } + bool loadMusic(const char *filename); + void unloadMusic(void); + +// AudioStream API + int readBuffer(int16 *buffer, const int numSamples) { + premixerCall(buffer, numSamples / 2); + return numSamples; + } + bool isStereo() const { return true; } + bool endOfData() const { return false; } + int getRate() const { return _rate; } + +protected: + static const unsigned char _operators[]; + static const unsigned char _volRegNums []; + FM_OPL *_opl; + byte *_data; + byte *_playPos; + uint32 _dataSize; + uint32 _rate; + short _freqs[25][12]; + byte _notes[11]; + byte _notCol[11]; + byte _notLin[11]; + bool _notOn[11]; + byte _pollNotes[16]; + uint32 _samplesTillPoll; + bool _playing; + bool _first; + bool _ended; + bool _looping; + GobEngine *_vm; + + void premixerCall(int16 *buf, uint len); + void writeOPL(byte reg, byte val); + void setFreqs(void); + void reset(void); + void setVoices(); + void setVoice(byte voice, byte instr, bool set); + void setKey(byte voice, byte note, bool on, bool spec); + void setVolume(byte voice, byte volume); + void pollMusic(void); +}; + +} // End of namespace Gob + +#endif diff --git a/gob/parse.cpp b/gob/parse.cpp index ac3884510d..2ed3b02563 100644 --- a/gob/parse.cpp +++ b/gob/parse.cpp @@ -36,7 +36,7 @@ int32 Parse::encodePtr(char *ptr, int type) { switch (type) { case kExecPtr: - offset = ptr - _vm->_game->totFileData; + offset = ptr - _vm->_game->_totFileData; break; case kInterVar: offset = ptr - _vm->_global->_inter_variables; @@ -56,7 +56,7 @@ char *Parse::decodePtr(int32 n) { switch (n >> 28) { case kExecPtr: - ptr = _vm->_game->totFileData; + ptr = _vm->_game->_totFileData; break; case kInterVar: ptr = _vm->_global->_inter_variables; diff --git a/gob/scenery.cpp b/gob/scenery.cpp index b7660f1884..28f66c4af7 100644 --- a/gob/scenery.cpp +++ b/gob/scenery.cpp @@ -162,22 +162,22 @@ int16 Scenery::loadStatic(char search) { sprIndex; spriteRefs[sprIndex]++; } else { - for (sprIndex = 19; _vm->_draw->spritesArray[sprIndex] != 0; + for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex] != 0; sprIndex--); staticPictToSprite[7 * sceneryIndex + i] = sprIndex; spriteRefs[sprIndex] = 1; spriteResId[sprIndex] = sprResId; - _vm->_draw->spritesArray[sprIndex] = + _vm->_draw->_spritesArray[sprIndex] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); - _vm->_video->clearSurf(_vm->_draw->spritesArray[sprIndex]); - _vm->_draw->destSurface = sprIndex; - _vm->_draw->spriteLeft = sprResId; - _vm->_draw->transparency = 0; - _vm->_draw->destSpriteX = 0; - _vm->_draw->destSpriteY = 0; + _vm->_video->clearSurf(_vm->_draw->_spritesArray[sprIndex]); + _vm->_draw->_destSurface = sprIndex; + _vm->_draw->_spriteLeft = sprResId; + _vm->_draw->_transparency = 0; + _vm->_draw->_destSpriteX = 0; + _vm->_draw->_destSpriteY = 0; _vm->_draw->spriteOperation(DRAW_LOADSPRITE); } } @@ -201,8 +201,8 @@ void Scenery::freeStatic(int16 index) { spr = staticPictToSprite[index * 7 + i]; spriteRefs[spr]--; if (spriteRefs[spr] == 0) { - _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[spr]); - _vm->_draw->spritesArray[spr] = 0; + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[spr]); + _vm->_draw->_spritesArray[spr] = 0; spriteResId[spr] = -1; } } @@ -239,12 +239,12 @@ void Scenery::renderStatic(int16 scenery, int16 layer) { layerPtr = ptr->layers[layer]; - _vm->_draw->spriteLeft = layerPtr->backResId; - if (_vm->_draw->spriteLeft != -1) { - _vm->_draw->destSpriteX = 0; - _vm->_draw->destSpriteY = 0; - _vm->_draw->destSurface = 21; - _vm->_draw->transparency = 0; + _vm->_draw->_spriteLeft = layerPtr->backResId; + if (_vm->_draw->_spriteLeft != -1) { + _vm->_draw->_destSpriteX = 0; + _vm->_draw->_destSpriteY = 0; + _vm->_draw->_destSurface = 21; + _vm->_draw->_transparency = 0; _vm->_draw->spriteOperation(DRAW_LOADSPRITE); } @@ -258,21 +258,21 @@ void Scenery::renderStatic(int16 scenery, int16 layer) { pieceIndex = planePtr->pieceIndex; pictIndex = planePtr->pictIndex - 1; - _vm->_draw->destSpriteX = planePtr->destX; - _vm->_draw->destSpriteY = planePtr->destY; + _vm->_draw->_destSpriteX = planePtr->destX; + _vm->_draw->_destSpriteY = planePtr->destY; left = FROM_LE_16(ptr->pieces[pictIndex][pieceIndex].left); right = FROM_LE_16(ptr->pieces[pictIndex][pieceIndex].right); top = FROM_LE_16(ptr->pieces[pictIndex][pieceIndex].top); bottom = FROM_LE_16(ptr->pieces[pictIndex][pieceIndex].bottom); - _vm->_draw->sourceSurface = + _vm->_draw->_sourceSurface = staticPictToSprite[scenery * 7 + pictIndex]; - _vm->_draw->destSurface = 21; - _vm->_draw->spriteLeft = left; - _vm->_draw->spriteTop = top; - _vm->_draw->spriteRight = right - left + 1; - _vm->_draw->spriteBottom = bottom - top + 1; - _vm->_draw->transparency = planePtr->transp ? 3 : 0; + _vm->_draw->_destSurface = 21; + _vm->_draw->_spriteLeft = left; + _vm->_draw->_spriteTop = top; + _vm->_draw->_spriteRight = right - left + 1; + _vm->_draw->_spriteBottom = bottom - top + 1; + _vm->_draw->_transparency = planePtr->transp ? 3 : 0; _vm->_draw->spriteOperation(DRAW_BLITSURF); } } @@ -326,53 +326,53 @@ void Scenery::updateStatic(int16 orderFrom) { pieceIndex = planePtr->pieceIndex; pictIndex = planePtr->pictIndex - 1; - _vm->_draw->destSpriteX = planePtr->destX; - _vm->_draw->destSpriteY = planePtr->destY; + _vm->_draw->_destSpriteX = planePtr->destX; + _vm->_draw->_destSpriteY = planePtr->destY; left = FROM_LE_16(pictPtr[pictIndex][pieceIndex].left); right = FROM_LE_16(pictPtr[pictIndex][pieceIndex].right); top = FROM_LE_16(pictPtr[pictIndex][pieceIndex].top); bottom = FROM_LE_16(pictPtr[pictIndex][pieceIndex].bottom); - if (_vm->_draw->destSpriteX > toRedrawRight) + if (_vm->_draw->_destSpriteX > toRedrawRight) continue; - if (_vm->_draw->destSpriteY > toRedrawBottom) + if (_vm->_draw->_destSpriteY > toRedrawBottom) continue; - if (_vm->_draw->destSpriteX < toRedrawLeft) { - left += toRedrawLeft - _vm->_draw->destSpriteX; - _vm->_draw->destSpriteX = toRedrawLeft; + if (_vm->_draw->_destSpriteX < toRedrawLeft) { + left += toRedrawLeft - _vm->_draw->_destSpriteX; + _vm->_draw->_destSpriteX = toRedrawLeft; } - if (_vm->_draw->destSpriteY < toRedrawTop) { - top += toRedrawTop - _vm->_draw->destSpriteY; - _vm->_draw->destSpriteY = toRedrawTop; + if (_vm->_draw->_destSpriteY < toRedrawTop) { + top += toRedrawTop - _vm->_draw->_destSpriteY; + _vm->_draw->_destSpriteY = toRedrawTop; } - _vm->_draw->spriteLeft = left; - _vm->_draw->spriteTop = top; - _vm->_draw->spriteRight = right - left + 1; - _vm->_draw->spriteBottom = bottom - top + 1; + _vm->_draw->_spriteLeft = left; + _vm->_draw->_spriteTop = top; + _vm->_draw->_spriteRight = right - left + 1; + _vm->_draw->_spriteBottom = bottom - top + 1; - if (_vm->_draw->spriteRight <= 0 || _vm->_draw->spriteBottom <= 0) + if (_vm->_draw->_spriteRight <= 0 || _vm->_draw->_spriteBottom <= 0) continue; - if (_vm->_draw->destSpriteX + _vm->_draw->spriteRight - 1 > + if (_vm->_draw->_destSpriteX + _vm->_draw->_spriteRight - 1 > toRedrawRight) - _vm->_draw->spriteRight = - toRedrawRight - _vm->_draw->destSpriteX + 1; + _vm->_draw->_spriteRight = + toRedrawRight - _vm->_draw->_destSpriteX + 1; - if (_vm->_draw->destSpriteY + _vm->_draw->spriteBottom - 1 > + if (_vm->_draw->_destSpriteY + _vm->_draw->_spriteBottom - 1 > toRedrawBottom) - _vm->_draw->spriteBottom = - toRedrawBottom - _vm->_draw->destSpriteY + 1; + _vm->_draw->_spriteBottom = + toRedrawBottom - _vm->_draw->_destSpriteY + 1; - _vm->_draw->sourceSurface = + _vm->_draw->_sourceSurface = staticPictToSprite[curStatic * 7 + pictIndex]; - _vm->_draw->destSurface = 21; - _vm->_draw->transparency = planePtr->transp ? 3 : 0; + _vm->_draw->_destSurface = 21; + _vm->_draw->_transparency = planePtr->transp ? 3 : 0; _vm->_draw->spriteOperation(DRAW_BLITSURF); } } @@ -479,21 +479,21 @@ int16 Scenery::loadAnim(char search) { animPictToSprite[7 * sceneryIndex + i] = sprIndex; spriteRefs[sprIndex]++; } else { - for (sprIndex = 19; _vm->_draw->spritesArray[sprIndex] != 0; + for (sprIndex = 19; _vm->_draw->_spritesArray[sprIndex] != 0; sprIndex--); animPictToSprite[7 * sceneryIndex + i] = sprIndex; spriteRefs[sprIndex] = 1; spriteResId[sprIndex] = sprResId; - _vm->_draw->spritesArray[sprIndex] = + _vm->_draw->_spritesArray[sprIndex] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, 2); - _vm->_video->clearSurf(_vm->_draw->spritesArray[sprIndex]); - _vm->_draw->destSurface = sprIndex; - _vm->_draw->spriteLeft = sprResId; - _vm->_draw->transparency = 0; - _vm->_draw->destSpriteX = 0; - _vm->_draw->destSpriteY = 0; + _vm->_video->clearSurf(_vm->_draw->_spritesArray[sprIndex]); + _vm->_draw->_destSurface = sprIndex; + _vm->_draw->_spriteLeft = sprResId; + _vm->_draw->_transparency = 0; + _vm->_draw->_destSpriteX = 0; + _vm->_draw->_destSpriteY = 0; _vm->_draw->spriteOperation(DRAW_LOADSPRITE); } } @@ -668,17 +668,17 @@ void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, continue; if (doDraw) { - _vm->_draw->sourceSurface = + _vm->_draw->_sourceSurface = animPictToSprite[animation * 7 + pictIndex]; - _vm->_draw->destSurface = 21; - - _vm->_draw->spriteLeft = left; - _vm->_draw->spriteTop = top; - _vm->_draw->spriteRight = right - left + 1; - _vm->_draw->spriteBottom = bottom - top + 1; - _vm->_draw->destSpriteX = destX; - _vm->_draw->destSpriteY = destY; - _vm->_draw->transparency = transp; + _vm->_draw->_destSurface = 21; + + _vm->_draw->_spriteLeft = left; + _vm->_draw->_spriteTop = top; + _vm->_draw->_spriteRight = right - left + 1; + _vm->_draw->_spriteBottom = bottom - top + 1; + _vm->_draw->_destSpriteX = destX; + _vm->_draw->_destSpriteY = destY; + _vm->_draw->_transparency = transp; _vm->_draw->spriteOperation(DRAW_BLITSURF); } @@ -723,9 +723,9 @@ void Scenery::freeAnim(int16 animation) { spr = animPictToSprite[animation * 7 + i]; spriteRefs[spr]--; if (spriteRefs[spr] == 0) { - _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[spr]); + _vm->_video->freeSurfDesc(_vm->_draw->_spritesArray[spr]); - _vm->_draw->spritesArray[spr] = 0; + _vm->_draw->_spritesArray[spr] = 0; spriteResId[spr] = -1; } } |