diff options
Diffstat (limited to 'gob/scenery.cpp')
-rw-r--r-- | gob/scenery.cpp | 620 |
1 files changed, 312 insertions, 308 deletions
diff --git a/gob/scenery.cpp b/gob/scenery.cpp index b373e2178c..0cd6971c25 100644 --- a/gob/scenery.cpp +++ b/gob/scenery.cpp @@ -33,35 +33,39 @@ namespace Gob { -int16 scen_spriteResId[20]; -char scen_spriteRefs[20]; - -Scen_Static scen_statics[10]; -int16 scen_staticPictCount[10]; -char scen_staticFromExt[10]; -int16 scen_staticResId[10]; -char scen_staticPictToSprite[70]; - -Scen_Animation scen_animations[10]; -int16 scen_animPictCount[10]; -char scen_animFromExt[10]; -int16 scen_animResId[10]; -char scen_animPictToSprite[70]; +Scenery::Scenery(GobEngine *vm) : _vm(vm) { + for (int i = 0; i < 20; i++) { + spriteRefs[i] = 0; + spriteResId[i] = 0; + } + for (int i = 0; i < 70; i++ ) { + staticPictToSprite[i] = 0; + animPictToSprite[i] = 0; + } + for (int i = 0; i < 10; i++) { + staticPictCount[i] = 0; + staticFromExt[i] = 0; + staticResId[i] = 0; + animPictCount[i] = 0; + animFromExt[i] = 0; + animResId[i] = 0; + } -int16 scen_curStatic; -int16 scen_curStaticLayer; + curStatic = 0; + curStaticLayer = 0; -int16 scen_toRedrawLeft; -int16 scen_toRedrawRight; -int16 scen_toRedrawTop; -int16 scen_toRedrawBottom; + toRedrawLeft = 0; + toRedrawRight = 0; + toRedrawTop = 0; + toRedrawBottom = 0; -int16 scen_animTop; -int16 scen_animLeft; + animTop = 0; + animLeft = 0; -int16 *scen_pCaptureCounter; + pCaptureCounter = 0; +} -int16 scen_loadStatic(char search) { +int16 Scenery::loadStatic(char search) { int16 tmp; int16 *backsPtr; int16 picsCount; @@ -69,7 +73,7 @@ int16 scen_loadStatic(char search) { int16 i; int16 sceneryIndex; char *dataPtr; - Scen_Static *ptr; + Static *ptr; int16 offset; int16 pictDescId; int16 width; @@ -77,48 +81,48 @@ int16 scen_loadStatic(char search) { int16 sprResId; int16 sprIndex; - inter_evalExpr(&sceneryIndex); - tmp = inter_load16(); - backsPtr = (int16 *)inter_execPtr; - inter_execPtr += tmp * 2; - picsCount = inter_load16(); - resId = inter_load16(); + _vm->_inter->evalExpr(&sceneryIndex); + tmp = _vm->_inter->load16(); + backsPtr = (int16 *)_vm->_global->inter_execPtr; + _vm->_global->inter_execPtr += tmp * 2; + picsCount = _vm->_inter->load16(); + resId = _vm->_inter->load16(); if (search) { for (i = 0; i < 10; i++) { - if (scen_staticPictCount[i] != -1 && scen_staticResId[i] == resId) { - inter_execPtr += 8 * scen_staticPictCount[i]; + if (staticPictCount[i] != -1 && staticResId[i] == resId) { + _vm->_global->inter_execPtr += 8 * staticPictCount[i]; return i; } - if (scen_staticPictCount[i] == -1 && i < sceneryIndex) + if (staticPictCount[i] == -1 && i < sceneryIndex) sceneryIndex = i; } } - scen_staticPictCount[sceneryIndex] = picsCount; - scen_staticResId[sceneryIndex] = resId; + staticPictCount[sceneryIndex] = picsCount; + staticResId[sceneryIndex] = resId; if (resId >= 30000) { - scen_staticFromExt[sceneryIndex] = 1; - dataPtr = game_loadExtData(resId, 0, 0); + staticFromExt[sceneryIndex] = 1; + dataPtr = _vm->_game->loadExtData(resId, 0, 0); } else { - scen_staticFromExt[sceneryIndex] = 0; - dataPtr = game_loadTotResource(resId); + staticFromExt[sceneryIndex] = 0; + dataPtr = _vm->_game->loadTotResource(resId); } - ptr = &scen_statics[sceneryIndex]; + ptr = &statics[sceneryIndex]; ptr->dataPtr = dataPtr; ptr->layersCount = (int16)READ_LE_UINT16(dataPtr); dataPtr += 2; - ptr->layers = (Scen_StaticLayer **)malloc(sizeof(Scen_StaticLayer *) * ptr->layersCount); - ptr->pieces = (Scen_PieceDesc **)malloc(sizeof(Scen_PieceDesc *) * picsCount); + ptr->layers = (StaticLayer **)malloc(sizeof(StaticLayer *) * ptr->layersCount); + ptr->pieces = (PieceDesc **)malloc(sizeof(PieceDesc *) * picsCount); ptr->piecesFromExt = (int8 *)malloc(picsCount); for (i = 0; i < ptr->layersCount; i++) { offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]); - ptr->layers[i] = (Scen_StaticLayer *)(dataPtr + offset - 2); + ptr->layers[i] = (StaticLayer *)(dataPtr + offset - 2); ptr->layers[i]->planeCount = (int16)READ_LE_UINT16(&ptr->layers[i]->planeCount); @@ -132,91 +136,91 @@ int16 scen_loadStatic(char search) { } for (i = 0; i < picsCount; i++) { - pictDescId = inter_load16(); + pictDescId = _vm->_inter->load16(); if (pictDescId >= 30000) { ptr->pieces[i] = - (Scen_PieceDesc *) game_loadExtData(pictDescId, 0, + (PieceDesc *) _vm->_game->loadExtData(pictDescId, 0, 0); ptr->piecesFromExt[i] = 1; } else { ptr->pieces[i] = - (Scen_PieceDesc *) - game_loadTotResource(pictDescId); + (PieceDesc *) + _vm->_game->loadTotResource(pictDescId); ptr->piecesFromExt[i] = 0; } - width = inter_load16(); - height = inter_load16(); - sprResId = inter_load16(); + width = _vm->_inter->load16(); + height = _vm->_inter->load16(); + sprResId = _vm->_inter->load16(); for (sprIndex = 0; sprIndex < 20; sprIndex++) { - if (scen_spriteResId[sprIndex] == sprResId) + if (spriteResId[sprIndex] == sprResId) break; } if (sprIndex < 20) { - scen_staticPictToSprite[7 * sceneryIndex + i] = + staticPictToSprite[7 * sceneryIndex + i] = sprIndex; - scen_spriteRefs[sprIndex]++; + spriteRefs[sprIndex]++; } else { - for (sprIndex = 19; draw_spritesArray[sprIndex] != 0; + for (sprIndex = 19; _vm->_draw->spritesArray[sprIndex] != 0; sprIndex--); - scen_staticPictToSprite[7 * sceneryIndex + i] = + staticPictToSprite[7 * sceneryIndex + i] = sprIndex; - scen_spriteRefs[sprIndex] = 1; - scen_spriteResId[sprIndex] = sprResId; - draw_spritesArray[sprIndex] = - vid_initSurfDesc(videoMode, width, height, 2); - - vid_clearSurf(draw_spritesArray[sprIndex]); - draw_destSurface = sprIndex; - draw_spriteLeft = sprResId; - draw_transparency = 0; - draw_destSpriteX = 0; - draw_destSpriteY = 0; - draw_spriteOperation(DRAW_LOADSPRITE); + spriteRefs[sprIndex] = 1; + spriteResId[sprIndex] = sprResId; + _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->_draw->spriteOperation(DRAW_LOADSPRITE); } } return sceneryIndex + 100; } -void scen_freeStatic(int16 index) { +void Scenery::freeStatic(int16 index) { int16 i; int16 spr; if (index == -1) - inter_evalExpr(&index); + _vm->_inter->evalExpr(&index); - if (scen_staticPictCount[index] == -1) + if (staticPictCount[index] == -1) return; - for (i = 0; i < scen_staticPictCount[index]; i++) { - if (scen_statics[index].piecesFromExt[i] == 1) - free(scen_statics[index].pieces[i]); + for (i = 0; i < staticPictCount[index]; i++) { + if (statics[index].piecesFromExt[i] == 1) + free(statics[index].pieces[i]); - spr = scen_staticPictToSprite[index * 7 + i]; - scen_spriteRefs[spr]--; - if (scen_spriteRefs[spr] == 0) { - vid_freeSurfDesc(draw_spritesArray[spr]); - draw_spritesArray[spr] = 0; - scen_spriteResId[spr] = -1; + spr = staticPictToSprite[index * 7 + i]; + spriteRefs[spr]--; + if (spriteRefs[spr] == 0) { + _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[spr]); + _vm->_draw->spritesArray[spr] = 0; + spriteResId[spr] = -1; } } - free(scen_statics[index].layers); - free(scen_statics[index].pieces); - free(scen_statics[index].piecesFromExt); - if (scen_staticFromExt[index] == 1) - free(scen_statics[index].dataPtr); + free(statics[index].layers); + free(statics[index].pieces); + free(statics[index].piecesFromExt); + if (staticFromExt[index] == 1) + free(statics[index].dataPtr); - scen_staticFromExt[index] = 0; - scen_staticPictCount[index] = -1; + staticFromExt[index] = 0; + staticPictCount[index] = -1; } -void scen_renderStatic(int16 scenery, int16 layer) { - Scen_Static *ptr; - Scen_StaticLayer *layerPtr; - Scen_StaticPlane *planePtr; +void Scenery::renderStatic(int16 scenery, int16 layer) { + Static *ptr; + StaticLayer *layerPtr; + StaticPlane *planePtr; int16 planeCount; int16 order; int16 plane; @@ -229,19 +233,19 @@ void scen_renderStatic(int16 scenery, int16 layer) { int16 top; int16 bottom; - ptr = &scen_statics[scenery]; + ptr = &statics[scenery]; if (layer >= ptr->layersCount) return; layerPtr = ptr->layers[layer]; - draw_spriteLeft = layerPtr->backResId; - if (draw_spriteLeft != -1) { - draw_destSpriteX = 0; - draw_destSpriteY = 0; - draw_destSurface = 21; - draw_transparency = 0; - draw_spriteOperation(DRAW_LOADSPRITE); + _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); } planeCount = layerPtr->planeCount; @@ -254,44 +258,44 @@ void scen_renderStatic(int16 scenery, int16 layer) { pieceIndex = planePtr->pieceIndex; pictIndex = planePtr->pictIndex - 1; - draw_destSpriteX = planePtr->destX; - 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); - draw_sourceSurface = - scen_staticPictToSprite[scenery * 7 + pictIndex]; - draw_destSurface = 21; - draw_spriteLeft = left; - draw_spriteTop = top; - draw_spriteRight = right - left + 1; - draw_spriteBottom = bottom - top + 1; - draw_transparency = planePtr->transp ? 3 : 0; - draw_spriteOperation(DRAW_BLITSURF); + _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->spriteOperation(DRAW_BLITSURF); } } } -void scen_interRenderStatic(void) { +void Scenery::interRenderStatic(void) { int16 layer; int16 index; - inter_evalExpr(&index); - inter_evalExpr(&layer); - scen_renderStatic(index, layer); + _vm->_inter->evalExpr(&index); + _vm->_inter->evalExpr(&layer); + renderStatic(index, layer); } -void scen_interLoadCurLayer(void) { - inter_evalExpr(&scen_curStatic); - inter_evalExpr(&scen_curStaticLayer); +void Scenery::interLoadCurLayer(void) { + _vm->_inter->evalExpr(&curStatic); + _vm->_inter->evalExpr(&curStaticLayer); } -void scen_updateStatic(int16 orderFrom) { - Scen_StaticLayer *layerPtr; - Scen_PieceDesc **pictPtr; - Scen_StaticPlane *planePtr; +void Scenery::updateStatic(int16 orderFrom) { + StaticLayer *layerPtr; + PieceDesc **pictPtr; + StaticPlane *planePtr; int16 planeCount; int16 order; int16 plane; @@ -303,14 +307,14 @@ void scen_updateStatic(int16 orderFrom) { int16 top; int16 bottom; - if (scen_curStatic == -1) + if (curStatic == -1) return; - if (scen_curStaticLayer >= scen_statics[scen_curStatic].layersCount) + if (curStaticLayer >= statics[curStatic].layersCount) return; - layerPtr = scen_statics[scen_curStatic].layers[scen_curStaticLayer]; - pictPtr = scen_statics[scen_curStatic].pieces; + layerPtr = statics[curStatic].layers[curStaticLayer]; + pictPtr = statics[curStatic].pieces; planeCount = layerPtr->planeCount; @@ -322,65 +326,65 @@ void scen_updateStatic(int16 orderFrom) { pieceIndex = planePtr->pieceIndex; pictIndex = planePtr->pictIndex - 1; - draw_destSpriteX = planePtr->destX; - 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 (draw_destSpriteX > scen_toRedrawRight) + if (_vm->_draw->destSpriteX > toRedrawRight) continue; - if (draw_destSpriteY > scen_toRedrawBottom) + if (_vm->_draw->destSpriteY > toRedrawBottom) continue; - if (draw_destSpriteX < scen_toRedrawLeft) { - left += scen_toRedrawLeft - draw_destSpriteX; - draw_destSpriteX = scen_toRedrawLeft; + if (_vm->_draw->destSpriteX < toRedrawLeft) { + left += toRedrawLeft - _vm->_draw->destSpriteX; + _vm->_draw->destSpriteX = toRedrawLeft; } - if (draw_destSpriteY < scen_toRedrawTop) { - top += scen_toRedrawTop - draw_destSpriteY; - draw_destSpriteY = scen_toRedrawTop; + if (_vm->_draw->destSpriteY < toRedrawTop) { + top += toRedrawTop - _vm->_draw->destSpriteY; + _vm->_draw->destSpriteY = toRedrawTop; } - draw_spriteLeft = left; - draw_spriteTop = top; - draw_spriteRight = right - left + 1; - 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 (draw_spriteRight <= 0 || draw_spriteBottom <= 0) + if (_vm->_draw->spriteRight <= 0 || _vm->_draw->spriteBottom <= 0) continue; - if (draw_destSpriteX + draw_spriteRight - 1 > - scen_toRedrawRight) - draw_spriteRight = - scen_toRedrawRight - draw_destSpriteX + 1; + if (_vm->_draw->destSpriteX + _vm->_draw->spriteRight - 1 > + toRedrawRight) + _vm->_draw->spriteRight = + toRedrawRight - _vm->_draw->destSpriteX + 1; - if (draw_destSpriteY + draw_spriteBottom - 1 > - scen_toRedrawBottom) - draw_spriteBottom = - scen_toRedrawBottom - draw_destSpriteY + 1; + if (_vm->_draw->destSpriteY + _vm->_draw->spriteBottom - 1 > + toRedrawBottom) + _vm->_draw->spriteBottom = + toRedrawBottom - _vm->_draw->destSpriteY + 1; - draw_sourceSurface = - scen_staticPictToSprite[scen_curStatic * 7 + + _vm->_draw->sourceSurface = + staticPictToSprite[curStatic * 7 + pictIndex]; - draw_destSurface = 21; - draw_transparency = planePtr->transp ? 3 : 0; - draw_spriteOperation(DRAW_BLITSURF); + _vm->_draw->destSurface = 21; + _vm->_draw->transparency = planePtr->transp ? 3 : 0; + _vm->_draw->spriteOperation(DRAW_BLITSURF); } } } -int16 scen_loadAnim(char search) { +int16 Scenery::loadAnim(char search) { int16 picsCount; int16 resId; int16 i; int16 sceneryIndex; char *dataPtr; - Scen_Animation *ptr; + Animation *ptr; int16 offset; int16 pictDescId; int16 width; @@ -388,58 +392,58 @@ int16 scen_loadAnim(char search) { int16 sprResId; int16 sprIndex; - if (cd_globFlag) { - while (cd_getTrackPos() != -1) - util_longDelay(50); + if (_vm->_cdrom->_cdPlaying) { + while (_vm->_cdrom->getTrackPos() != -1) + _vm->_util->longDelay(50); - cd_globFlag = false; + _vm->_cdrom->_cdPlaying = false; } - inter_evalExpr(&sceneryIndex); - picsCount = inter_load16(); - resId = inter_load16(); + _vm->_inter->evalExpr(&sceneryIndex); + picsCount = _vm->_inter->load16(); + resId = _vm->_inter->load16(); if (search) { for (i = 0; i < 10; i++) { - if (scen_animPictCount[i] != 0 - && scen_animResId[i] == resId) { - inter_execPtr += 8 * scen_animPictCount[i]; + if (animPictCount[i] != 0 + && animResId[i] == resId) { + _vm->_global->inter_execPtr += 8 * animPictCount[i]; return i; } - if (scen_animPictCount[i] == 0 && i < sceneryIndex) + if (animPictCount[i] == 0 && i < sceneryIndex) sceneryIndex = i; } } - scen_animPictCount[sceneryIndex] = picsCount; - scen_animResId[sceneryIndex] = resId; + animPictCount[sceneryIndex] = picsCount; + animResId[sceneryIndex] = resId; if (resId >= 30000) { - scen_animFromExt[sceneryIndex] = 1; - dataPtr = game_loadExtData(resId, 0, 0); + animFromExt[sceneryIndex] = 1; + dataPtr = _vm->_game->loadExtData(resId, 0, 0); } else { - scen_animFromExt[sceneryIndex] = 0; - dataPtr = game_loadTotResource(resId); + animFromExt[sceneryIndex] = 0; + dataPtr = _vm->_game->loadTotResource(resId); } - ptr = &scen_animations[sceneryIndex]; + ptr = &animations[sceneryIndex]; ptr->dataPtr = dataPtr; ptr->layersCount = READ_LE_UINT16(dataPtr); dataPtr += 2; ptr->layers = - (Scen_AnimLayer **) malloc(sizeof(Scen_AnimLayer *) * + (AnimLayer **) malloc(sizeof(AnimLayer *) * ptr->layersCount); ptr->pieces = - (Scen_PieceDesc **) malloc(sizeof(Scen_PieceDesc *) * + (PieceDesc **) malloc(sizeof(PieceDesc *) * picsCount); ptr->piecesFromExt = (int8 *) malloc(picsCount); for (i = 0; i < ptr->layersCount; i++) { offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]); - ptr->layers[i] = (Scen_AnimLayer *) (dataPtr + offset - 2); + ptr->layers[i] = (AnimLayer *) (dataPtr + offset - 2); ptr->layers[i]->unknown0 = (int16)READ_LE_UINT16(&ptr->layers[i]->unknown0); ptr->layers[i]->posX = (int16)READ_LE_UINT16(&ptr->layers[i]->posX); @@ -450,47 +454,47 @@ int16 scen_loadAnim(char search) { } for (i = 0; i < picsCount; i++) { - pictDescId = inter_load16(); + pictDescId = _vm->_inter->load16(); if (pictDescId >= 30000) { ptr->pieces[i] = - (Scen_PieceDesc *) game_loadExtData(pictDescId, 0, + (PieceDesc *) _vm->_game->loadExtData(pictDescId, 0, 0); ptr->piecesFromExt[i] = 1; } else { ptr->pieces[i] = - (Scen_PieceDesc *) - game_loadTotResource(pictDescId); + (PieceDesc *) + _vm->_game->loadTotResource(pictDescId); ptr->piecesFromExt[i] = 0; } - width = inter_load16(); - height = inter_load16(); - sprResId = inter_load16(); + width = _vm->_inter->load16(); + height = _vm->_inter->load16(); + sprResId = _vm->_inter->load16(); for (sprIndex = 0; sprIndex < 20; sprIndex++) { - if (scen_spriteResId[sprIndex] == sprResId) + if (spriteResId[sprIndex] == sprResId) break; } if (sprIndex < 20) { - scen_animPictToSprite[7 * sceneryIndex + i] = sprIndex; - scen_spriteRefs[sprIndex]++; + animPictToSprite[7 * sceneryIndex + i] = sprIndex; + spriteRefs[sprIndex]++; } else { - for (sprIndex = 19; draw_spritesArray[sprIndex] != 0; + for (sprIndex = 19; _vm->_draw->spritesArray[sprIndex] != 0; sprIndex--); - scen_animPictToSprite[7 * sceneryIndex + i] = sprIndex; - scen_spriteRefs[sprIndex] = 1; - scen_spriteResId[sprIndex] = sprResId; - draw_spritesArray[sprIndex] = - vid_initSurfDesc(videoMode, width, height, 2); - - vid_clearSurf(draw_spritesArray[sprIndex]); - draw_destSurface = sprIndex; - draw_spriteLeft = sprResId; - draw_transparency = 0; - draw_destSpriteX = 0; - draw_destSpriteY = 0; - draw_spriteOperation(DRAW_LOADSPRITE); + animPictToSprite[7 * sceneryIndex + i] = sprIndex; + spriteRefs[sprIndex] = 1; + spriteResId[sprIndex] = sprResId; + _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->_draw->spriteOperation(DRAW_LOADSPRITE); } } return sceneryIndex + 100; @@ -500,11 +504,11 @@ int16 scen_loadAnim(char search) { // flags & 4 == 0 - calculate animation final size // flags & 2 != 0 - don't check with "toRedraw"'s // flags & 4 != 0 - checkk view toRedraw -void scen_updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, +void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, int16 drawDeltaX, int16 drawDeltaY, char doDraw) { - Scen_AnimLayer *layerPtr; - Scen_PieceDesc **pictPtr; - Scen_AnimFramePiece *framePtr; + AnimLayer *layerPtr; + PieceDesc **pictPtr; + AnimFramePiece *framePtr; uint16 pieceIndex; uint16 pictIndex; @@ -523,29 +527,29 @@ void scen_updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, int16 destX; int16 destY; - if (layer >= scen_animations[animation].layersCount) + if (layer >= animations[animation].layersCount) return; - layerPtr = scen_animations[animation].layers[layer]; + layerPtr = animations[animation].layers[layer]; if (frame >= layerPtr->framesCount) return; if (flags & 1) // Do capture { - scen_updateAnim(layer, frame, animation, 0, drawDeltaX, + updateAnim(layer, frame, animation, 0, drawDeltaX, drawDeltaY, 0); - if (scen_toRedrawLeft == -12345) // Some magic number? + if (toRedrawLeft == -12345) // Some magic number? return; - game_capturePush(scen_toRedrawLeft, scen_toRedrawTop, - scen_toRedrawRight - scen_toRedrawLeft + 1, - scen_toRedrawBottom - scen_toRedrawTop + 1); + _vm->_game->capturePush(toRedrawLeft, toRedrawTop, + toRedrawRight - toRedrawLeft + 1, + toRedrawBottom - toRedrawTop + 1); - *scen_pCaptureCounter = *scen_pCaptureCounter + 1; + *pCaptureCounter = *pCaptureCounter + 1; } - pictPtr = scen_animations[animation].pieces; + pictPtr = animations[animation].pieces; framePtr = layerPtr->frames; for (i = 0; i < frame; i++, framePtr++) { @@ -554,18 +558,18 @@ void scen_updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, } if ((flags & 4) == 0) { - scen_toRedrawLeft = -12345; + toRedrawLeft = -12345; } else { - scen_toRedrawLeft = - MAX(scen_toRedrawLeft, anim_animAreaLeft); - scen_toRedrawTop = - MAX(scen_toRedrawTop, anim_animAreaTop); - scen_toRedrawRight = - MIN(scen_toRedrawRight, - (int16)(anim_animAreaLeft + anim_animAreaWidth - 1)); - scen_toRedrawBottom = - MIN(scen_toRedrawBottom, - (int16)(anim_animAreaTop + anim_animAreaHeight - 1)); + toRedrawLeft = + MAX(toRedrawLeft, _vm->_anim->_areaLeft); + toRedrawTop = + MAX(toRedrawTop, _vm->_anim->_areaTop); + toRedrawRight = + MIN(toRedrawRight, + (int16)(_vm->_anim->_areaLeft + _vm->_anim->_areaWidth - 1)); + toRedrawBottom = + MIN(toRedrawBottom, + (int16)(_vm->_anim->_areaTop + _vm->_anim->_areaHeight - 1)); } transp = layerPtr->transp ? 3 : 0; @@ -612,131 +616,131 @@ void scen_updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, bottom = FROM_LE_16(pictPtr[pictIndex][pieceIndex].bottom); if (flags & 2) { - if (destX < anim_animAreaLeft) { - left += anim_animAreaLeft - destX; - destX = anim_animAreaLeft; + if (destX < _vm->_anim->_areaLeft) { + left += _vm->_anim->_areaLeft - destX; + destX = _vm->_anim->_areaLeft; } if (left <= right && destX + right - left >= - anim_animAreaLeft + anim_animAreaWidth) + _vm->_anim->_areaLeft + _vm->_anim->_areaWidth) right -= (destX + right - left) - - (anim_animAreaLeft + anim_animAreaWidth) + + (_vm->_anim->_areaLeft + _vm->_anim->_areaWidth) + 1; - if (destY < anim_animAreaTop) { - top += anim_animAreaTop - destY; - destY = anim_animAreaTop; + if (destY < _vm->_anim->_areaTop) { + top += _vm->_anim->_areaTop - destY; + destY = _vm->_anim->_areaTop; } if (top <= bottom && destY + bottom - top >= - anim_animAreaTop + anim_animAreaHeight) + _vm->_anim->_areaTop + _vm->_anim->_areaHeight) bottom -= (destY + bottom - top) - - (anim_animAreaTop + anim_animAreaHeight) + + (_vm->_anim->_areaTop + _vm->_anim->_areaHeight) + 1; } else if (flags & 4) { - if (destX < scen_toRedrawLeft) { - left += scen_toRedrawLeft - destX; - destX = scen_toRedrawLeft; + if (destX < toRedrawLeft) { + left += toRedrawLeft - destX; + destX = toRedrawLeft; } if (left <= right - && destX + right - left > scen_toRedrawRight) + && destX + right - left > toRedrawRight) right -= - destX + right - left - scen_toRedrawRight; + destX + right - left - toRedrawRight; - if (destY < scen_toRedrawTop) { - top += scen_toRedrawTop - destY; - destY = scen_toRedrawTop; + if (destY < toRedrawTop) { + top += toRedrawTop - destY; + destY = toRedrawTop; } if (top <= bottom - && destY + bottom - top > scen_toRedrawBottom) + && destY + bottom - top > toRedrawBottom) bottom -= - destY + bottom - top - scen_toRedrawBottom; + destY + bottom - top - toRedrawBottom; } if (left > right || top > bottom) continue; if (doDraw) { - draw_sourceSurface = - scen_animPictToSprite[animation * 7 + pictIndex]; - draw_destSurface = 21; - - draw_spriteLeft = left; - draw_spriteTop = top; - draw_spriteRight = right - left + 1; - draw_spriteBottom = bottom - top + 1; - draw_destSpriteX = destX; - draw_destSpriteY = destY; - draw_transparency = transp; - draw_spriteOperation(DRAW_BLITSURF); + _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->spriteOperation(DRAW_BLITSURF); } if ((flags & 4) == 0) { - if (scen_toRedrawLeft == -12345) { - scen_toRedrawLeft = destX; - scen_animLeft = destX; - scen_toRedrawTop = destY; - scen_animTop = destY; - scen_toRedrawRight = destX + right - left; - scen_toRedrawBottom = destY + bottom - top; + if (toRedrawLeft == -12345) { + toRedrawLeft = destX; + animLeft = destX; + toRedrawTop = destY; + animTop = destY; + toRedrawRight = destX + right - left; + toRedrawBottom = destY + bottom - top; } else { - scen_toRedrawLeft = - MIN(scen_toRedrawLeft, destX); - scen_toRedrawTop = - MIN(scen_toRedrawTop, destY); - scen_toRedrawRight = - MAX(scen_toRedrawRight, + toRedrawLeft = + MIN(toRedrawLeft, destX); + toRedrawTop = + MIN(toRedrawTop, destY); + toRedrawRight = + MAX(toRedrawRight, (int16)(destX + right - left)); - scen_toRedrawBottom = - MAX(scen_toRedrawBottom, + toRedrawBottom = + MAX(toRedrawBottom, (int16)(destY + bottom - top)); } } } while (framePtr->notFinal == 1); } -void scen_freeAnim(int16 animation) { +void Scenery::freeAnim(int16 animation) { int16 i; int16 spr; if (animation == -1) - inter_evalExpr(&animation); + _vm->_inter->evalExpr(&animation); - if (scen_animPictCount[animation] == 0) + if (animPictCount[animation] == 0) return; - for (i = 0; i < scen_animPictCount[animation]; i++) { - if (scen_animations[animation].piecesFromExt[i] == 1) - free(scen_animations[animation].pieces[i]); + for (i = 0; i < animPictCount[animation]; i++) { + if (animations[animation].piecesFromExt[i] == 1) + free(animations[animation].pieces[i]); - spr = scen_animPictToSprite[animation * 7 + i]; - scen_spriteRefs[spr]--; - if (scen_spriteRefs[spr] == 0) { - vid_freeSurfDesc(draw_spritesArray[spr]); + spr = animPictToSprite[animation * 7 + i]; + spriteRefs[spr]--; + if (spriteRefs[spr] == 0) { + _vm->_video->freeSurfDesc(_vm->_draw->spritesArray[spr]); - draw_spritesArray[spr] = 0; - scen_spriteResId[spr] = -1; + _vm->_draw->spritesArray[spr] = 0; + spriteResId[spr] = -1; } } - free(scen_animations[animation].layers); - free(scen_animations[animation].pieces); - free(scen_animations[animation].piecesFromExt); - if (scen_animFromExt[animation] == 1) - free(scen_animations[animation].dataPtr); + free(animations[animation].layers); + free(animations[animation].pieces); + free(animations[animation].piecesFromExt); + if (animFromExt[animation] == 1) + free(animations[animation].dataPtr); - scen_animFromExt[animation] = 0; - scen_animPictCount[animation] = 0; + animFromExt[animation] = 0; + animPictCount[animation] = 0; } -void scen_interUpdateAnim(void) { +void Scenery::interUpdateAnim(void) { int16 deltaX; int16 deltaY; int16 flags; @@ -744,37 +748,37 @@ void scen_interUpdateAnim(void) { int16 layer; int16 animation; - inter_evalExpr(&deltaX); - inter_evalExpr(&deltaY); - inter_evalExpr(&animation); - inter_evalExpr(&layer); - inter_evalExpr(&frame); - flags = inter_load16(); - scen_updateAnim(layer, frame, animation, flags, deltaX, deltaY, 1); + _vm->_inter->evalExpr(&deltaX); + _vm->_inter->evalExpr(&deltaY); + _vm->_inter->evalExpr(&animation); + _vm->_inter->evalExpr(&layer); + _vm->_inter->evalExpr(&frame); + flags = _vm->_inter->load16(); + updateAnim(layer, frame, animation, flags, deltaX, deltaY, 1); } -void scen_interStoreParams(void) { - Scen_AnimLayer *layerPtr; +void Scenery::interStoreParams(void) { + AnimLayer *layerPtr; int16 animation; int16 layer; int16 var; - warning("scen_interStoreParams: Storing..."); + warning("interStoreParams: Storing..."); - inter_evalExpr(&animation); - inter_evalExpr(&layer); - layerPtr = scen_animations[animation].layers[layer]; + _vm->_inter->evalExpr(&animation); + _vm->_inter->evalExpr(&layer); + layerPtr = animations[animation].layers[layer]; - var = parse_parseVarIndex(); + var = _vm->_parse->parseVarIndex(); WRITE_VAR_OFFSET(var, layerPtr->animDeltaX); - var = parse_parseVarIndex(); + var = _vm->_parse->parseVarIndex(); WRITE_VAR_OFFSET(var, layerPtr->animDeltaY); - var = parse_parseVarIndex(); + var = _vm->_parse->parseVarIndex(); WRITE_VAR_OFFSET(var, layerPtr->unknown0); - var = parse_parseVarIndex(); + var = _vm->_parse->parseVarIndex(); WRITE_VAR_OFFSET(var, layerPtr->framesCount); } |