diff options
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/draw.cpp | 446 | ||||
-rw-r--r-- | engines/gob/draw.h | 24 | ||||
-rw-r--r-- | engines/gob/draw_v1.cpp | 487 | ||||
-rw-r--r-- | engines/gob/draw_v2.cpp | 491 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 3 | ||||
-rw-r--r-- | engines/gob/inter.h | 1 | ||||
-rw-r--r-- | engines/gob/inter_v1.cpp | 8 | ||||
-rw-r--r-- | engines/gob/inter_v2.cpp | 27 | ||||
-rw-r--r-- | engines/gob/module.mk | 2 | ||||
-rw-r--r-- | engines/gob/mult.cpp | 70 | ||||
-rw-r--r-- | engines/gob/mult.h | 12 | ||||
-rw-r--r-- | engines/gob/mult_v1.cpp | 70 | ||||
-rw-r--r-- | engines/gob/mult_v2.cpp | 79 |
13 files changed, 1196 insertions, 524 deletions
diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 6e1e2a1da3..e43a76f614 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -321,277 +321,6 @@ void Draw::blitCursor(void) { } } -void Draw::spriteOperation(int16 operation) { - uint16 id; - char *dataBuf; - Game::TotResItem *itemPtr; - int32 offset; - int16 len; - int16 i; - int16 x; - int16 y; - int16 perLine; - - if (_sourceSurface >= 100) - _sourceSurface -= 80; - - if (_destSurface >= 100) - _destSurface -= 80; - - if (_renderFlags & RENDERFLAG_USEDELTAS) { - if (_sourceSurface == 21) { - _spriteLeft += _backDeltaX; - _spriteTop += _backDeltaY; - } - - if (_destSurface == 21) { - _destSpriteX += _backDeltaX; - _destSpriteY += _backDeltaY; - if (operation == DRAW_DRAWLINE || - (operation >= DRAW_DRAWBAR - && operation <= DRAW_FILLRECTABS)) { - _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); - } - break; - - case DRAW_PUTPIXEL: - _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); - } - break; - - case DRAW_DRAWLINE: - _vm->_video->drawLine(_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom, _frontColor); - - if (_destSurface == 21) { - invalidateRect(_destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom); - } - break; - - case DRAW_INVALIDATE: - if (_destSurface == 21) { - invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !! - _destSpriteX + _spriteRight, - _destSpriteY + _spriteBottom); - } - break; - - case DRAW_LOADSPRITE: - 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); - } - delete[] dataBuf; - break; - } - // Load from .TOT resources - 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; - } else { - dataBuf = - _vm->_game->_imFileData + - (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]); - } - - _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); - } - break; - - case DRAW_PRINTTEXT: - 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; - } - break; - - case DRAW_DRAWBAR: - _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], - _spriteRight, _destSpriteY, - _spriteRight, _spriteBottom, _frontColor); - - _vm->_video->drawLine(_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, - _spriteRight, _destSpriteY, _frontColor); - - 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 (_destSurface == 21) { - invalidateRect(_destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom); - } - break; - - case DRAW_FILLRECTABS: - _vm->_video->fillRect(_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom, _backColor); - - 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 - - 1); - } - _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); - } - - _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 (_destSurface == 21) { - _destSpriteX -= _backDeltaX; - _destSpriteY -= _backDeltaY; - } - } -} - void Draw::animateCursor(int16 cursor) { int16 newX = 0; int16 newY = 0; @@ -705,181 +434,6 @@ void Draw::animateCursor(int16 cursor) { _cursorY = newY; } -void Draw::printText(void) { - int16 savedFlags; - int16 ldestSpriteX; - char *dataPtr; - char *ptr; - char *ptr2; - int16 index; - int16 destX; - int16 destY; - char cmd; - int16 val; - char buf[20]; - - index = _vm->_inter->load16(); - - _vm->_cdrom->playMultMusic(); - - 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); - (*_vm->_scenery->_pCaptureCounter)++; - } - _destSpriteX = READ_LE_UINT16(ptr); - destX = _destSpriteX; - - _destSpriteY = READ_LE_UINT16(ptr + 2); - destY = _destSpriteY; - - _spriteRight = READ_LE_UINT16(ptr + 4); - _spriteBottom = READ_LE_UINT16(ptr + 6); - _destSurface = 21; - - ptr += 8; - - _backColor = *ptr++; - _transparency = 1; - spriteOperation(DRAW_CLEARRECT); - - _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; - ptr += 8; - - cmd = (*ptr & 0xf0) >> 4; - if (cmd == 0) { - _frontColor = *ptr & 0xf; - spriteOperation(DRAW_DRAWLINE); - } else if (cmd == 1) { - _frontColor = *ptr & 0xf; - spriteOperation(DRAW_DRAWBAR); - } else if (cmd == 2) { - _backColor = *ptr & 0xf; - spriteOperation(DRAW_FILLRECTABS); - } - } - ptr += 2; - - for (ptr2 = ptr; *ptr2 != 1; ptr2++) { - if (*ptr2 == 3) - ptr2++; - - if (*ptr2 == 2) - ptr2 += 4; - } - - ptr2++; - - while (*ptr != 1) { - cmd = *ptr; - if (cmd == 3) { - ptr++; - _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); - ptr += 4; - continue; - } - - if ((byte)*ptr != 0xba) { - _letterToPrint = *ptr; - spriteOperation(DRAW_DRAWLETTER); - _destSpriteX += - _fonts[_fontIndex]->itemWidth; - ptr++; - } else { - cmd = ptr2[17] & 0x7f; - if (cmd == 0) { - val = READ_LE_UINT16(ptr2 + 18) * 4; - sprintf(buf, "%d", VAR_OFFSET(val)); - } else if (cmd == 1) { - val = READ_LE_UINT16(ptr2 + 18) * 4; - - strcpy(buf, _vm->_global->_inter_variables + val); - } else { - val = READ_LE_UINT16(ptr2 + 18) * 4; - - sprintf(buf, "%d", VAR_OFFSET(val)); - if (buf[0] == '-') { - while (strlen(buf) - 1 < (uint32)ptr2[17]) { - _vm->_util->insertStr("0", buf, 1); - } - } else { - while (strlen(buf) - 1 < (uint32)ptr2[17]) { - _vm->_util->insertStr("0", buf, 0); - } - } - - _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]); - } - - _textToPrint = buf; - ldestSpriteX = _destSpriteX; - spriteOperation(DRAW_PRINTTEXT); - if (ptr2[17] & 0x80) { - if (ptr[1] == ' ') { - _destSpriteX += _fonts[_fontIndex]->itemWidth; - while (ptr[1] == ' ') - ptr++; - if (ptr[1] == 2) { - if (READ_LE_UINT16(ptr + 4) == _destSpriteY) - ptr += 5; - } - } else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == _destSpriteY) { - ptr += 5; - _destSpriteX += _fonts[_fontIndex]->itemWidth; - } - } else { - _destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth; - } - ptr2 += 23; - ptr++; - } - } - - _renderFlags = savedFlags; - if (_renderFlags & 4) { - warning("printText: Input not supported"); -// xor ax, ax -// loc_436_1391: -// xor dx, dx -// push ax -// push dx -// push ax -// push dx -// push ax -// mov al, 0 -// push ax -// call sub_9FF_1E71 -// add sp, 0Ch - } - - if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) { - (*_vm->_scenery->_pCaptureCounter)--; - _vm->_game->capturePop(1); - } -} - void Draw::freeSprite(int16 index) { // .-- sub_CD84 --- if (_spritesArray[index] == 0) diff --git a/engines/gob/draw.h b/engines/gob/draw.h index 1364c90a07..bf9bf3f212 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -114,20 +114,40 @@ public: void clearPalette(void); void blitCursor(void); - void spriteOperation(int16 operation); void animateCursor(int16 cursor); - void printText(void); void freeSprite(int16 index); void adjustCoords(int16 *coord1, int16 *coord2, char adjust); void initBigSprite(int16 index, int16 height, int16 width, int16 flags); + virtual void printText(void) = 0; + virtual void spriteOperation(int16 operation) = 0; + Draw(GobEngine *vm); + virtual ~Draw() {}; protected: GobEngine *_vm; }; +class Draw_v1 : public Draw { +public: + virtual void printText(void); + virtual void spriteOperation(int16 operation); + + Draw_v1(GobEngine *vm); + virtual ~Draw_v1() {}; +}; + +class Draw_v2 : public Draw_v1 { +public: + virtual void printText(void); + virtual void spriteOperation(int16 operation); + + Draw_v2(GobEngine *vm); + virtual ~Draw_v2() {}; +}; + // Draw operations #define DRAW_BLITSURF 0 diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp new file mode 100644 index 0000000000..2c0725dd9b --- /dev/null +++ b/engines/gob/draw_v1.cpp @@ -0,0 +1,487 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004 Ivan Dubrov + * Copyright (C) 2004-2006 The ScummVM project + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" + +#include "gob/gob.h" +#include "gob/draw.h" +#include "gob/global.h" +#include "gob/game.h" +#include "gob/util.h" +#include "gob/scenery.h" +#include "gob/inter.h" +#include "gob/cdrom.h" + +namespace Gob { + +Draw_v1::Draw_v1(GobEngine *vm) : Draw(vm) { +} + +void Draw_v1::printText(void) { + int16 savedFlags; + int16 ldestSpriteX; + char *dataPtr; + char *ptr; + char *ptr2; + int16 index; + int16 destX; + int16 destY; + char cmd; + int16 val; + char buf[20]; + + index = _vm->_inter->load16(); + + _vm->_cdrom->playMultMusic(); + + 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); + (*_vm->_scenery->_pCaptureCounter)++; + } + _destSpriteX = READ_LE_UINT16(ptr); + destX = _destSpriteX; + + _destSpriteY = READ_LE_UINT16(ptr + 2); + destY = _destSpriteY; + + _spriteRight = READ_LE_UINT16(ptr + 4); + _spriteBottom = READ_LE_UINT16(ptr + 6); + _destSurface = 21; + + ptr += 8; + + _backColor = *ptr++; + _transparency = 1; + spriteOperation(DRAW_CLEARRECT); + + _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; + ptr += 8; + + cmd = (*ptr & 0xf0) >> 4; + if (cmd == 0) { + _frontColor = *ptr & 0xf; + spriteOperation(DRAW_DRAWLINE); + } else if (cmd == 1) { + _frontColor = *ptr & 0xf; + spriteOperation(DRAW_DRAWBAR); + } else if (cmd == 2) { + _backColor = *ptr & 0xf; + spriteOperation(DRAW_FILLRECTABS); + } + } + ptr += 2; + + for (ptr2 = ptr; *ptr2 != 1; ptr2++) { + if (*ptr2 == 3) + ptr2++; + + if (*ptr2 == 2) + ptr2 += 4; + } + + ptr2++; + + while (*ptr != 1) { + cmd = *ptr; + if (cmd == 3) { + ptr++; + _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); + ptr += 4; + continue; + } + + if ((byte)*ptr != 0xba) { + _letterToPrint = *ptr; + spriteOperation(DRAW_DRAWLETTER); + _destSpriteX += + _fonts[_fontIndex]->itemWidth; + ptr++; + } else { + cmd = ptr2[17] & 0x7f; + if (cmd == 0) { + val = READ_LE_UINT16(ptr2 + 18) * 4; + sprintf(buf, "%d", VAR_OFFSET(val)); + } else if (cmd == 1) { + val = READ_LE_UINT16(ptr2 + 18) * 4; + + strcpy(buf, _vm->_global->_inter_variables + val); + } else { + val = READ_LE_UINT16(ptr2 + 18) * 4; + + sprintf(buf, "%d", VAR_OFFSET(val)); + if (buf[0] == '-') { + while (strlen(buf) - 1 < (uint32)ptr2[17]) { + _vm->_util->insertStr("0", buf, 1); + } + } else { + while (strlen(buf) - 1 < (uint32)ptr2[17]) { + _vm->_util->insertStr("0", buf, 0); + } + } + + _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]); + } + + _textToPrint = buf; + ldestSpriteX = _destSpriteX; + spriteOperation(DRAW_PRINTTEXT); + if (ptr2[17] & 0x80) { + if (ptr[1] == ' ') { + _destSpriteX += _fonts[_fontIndex]->itemWidth; + while (ptr[1] == ' ') + ptr++; + if (ptr[1] == 2) { + if (READ_LE_UINT16(ptr + 4) == _destSpriteY) + ptr += 5; + } + } else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == _destSpriteY) { + ptr += 5; + _destSpriteX += _fonts[_fontIndex]->itemWidth; + } + } else { + _destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth; + } + ptr2 += 23; + ptr++; + } + } + + _renderFlags = savedFlags; + if (_renderFlags & 4) { + warning("printText: Input not supported"); +// xor ax, ax +// loc_436_1391: +// xor dx, dx +// push ax +// push dx +// push ax +// push dx +// push ax +// mov al, 0 +// push ax +// call sub_9FF_1E71 +// add sp, 0Ch + } + + if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) { + (*_vm->_scenery->_pCaptureCounter)--; + _vm->_game->capturePop(1); + } +} + +void Draw_v1::spriteOperation(int16 operation) { + uint16 id; + char *dataBuf; + Game::TotResItem *itemPtr; + int32 offset; + int16 len; + int16 i; + int16 x; + int16 y; + int16 perLine; + + if (_sourceSurface >= 100) + _sourceSurface -= 80; + + if (_destSurface >= 100) + _destSurface -= 80; + + if (_renderFlags & RENDERFLAG_USEDELTAS) { + if (_sourceSurface == 21) { + _spriteLeft += _backDeltaX; + _spriteTop += _backDeltaY; + } + + if (_destSurface == 21) { + _destSpriteX += _backDeltaX; + _destSpriteY += _backDeltaY; + if (operation == DRAW_DRAWLINE || + (operation >= DRAW_DRAWBAR + && operation <= DRAW_FILLRECTABS)) { + _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); + } + break; + + case DRAW_PUTPIXEL: + _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); + } + break; + + case DRAW_DRAWLINE: + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); + } + break; + + case DRAW_INVALIDATE: + if (_destSurface == 21) { + invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !! + _destSpriteX + _spriteRight, + _destSpriteY + _spriteBottom); + } + break; + + case DRAW_LOADSPRITE: + 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); + } + delete[] dataBuf; + break; + } + // Load from .TOT resources + 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; + } else { + dataBuf = + _vm->_game->_imFileData + + (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]); + } + + _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); + } + break; + + case DRAW_PRINTTEXT: + 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; + } + break; + + case DRAW_DRAWBAR: + _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], + _spriteRight, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); + + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _destSpriteY, _frontColor); + + 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 (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); + } + break; + + case DRAW_FILLRECTABS: + _vm->_video->fillRect(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _backColor); + + 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 - + 1); + } + _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); + } + + _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 (_destSurface == 21) { + _destSpriteX -= _backDeltaX; + _destSpriteY -= _backDeltaY; + } + } +} + +} // End of namespace Gob diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp new file mode 100644 index 0000000000..72d10e2989 --- /dev/null +++ b/engines/gob/draw_v2.cpp @@ -0,0 +1,491 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004 Ivan Dubrov + * Copyright (C) 2004-2006 The ScummVM project + * + * 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. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" + +#include "gob/gob.h" +#include "gob/draw.h" +#include "gob/global.h" +#include "gob/game.h" +#include "gob/util.h" +#include "gob/scenery.h" +#include "gob/inter.h" +#include "gob/cdrom.h" + +namespace Gob { + +Draw_v2::Draw_v2(GobEngine *vm) : Draw_v1(vm) { +} + +void Draw_v2::printText(void) { + int16 savedFlags; + int16 ldestSpriteX; + char *dataPtr; + char *ptr; + char *ptr2; + int16 index; + int16 destX; + int16 destY; + char cmd; + int16 val; + char buf[20]; + + warning("GOB2 Stub! Draw_v2::printText()"); + + index = _vm->_inter->load16(); + + _vm->_cdrom->playMultMusic(); + + 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); + (*_vm->_scenery->_pCaptureCounter)++; + } + _destSpriteX = READ_LE_UINT16(ptr); + destX = _destSpriteX; + + _destSpriteY = READ_LE_UINT16(ptr + 2); + destY = _destSpriteY; + + _spriteRight = READ_LE_UINT16(ptr + 4); + _spriteBottom = READ_LE_UINT16(ptr + 6); + _destSurface = 21; + + ptr += 8; + + _backColor = *ptr++; + _transparency = 1; + spriteOperation(DRAW_CLEARRECT); + + _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; + ptr += 8; + + cmd = (*ptr & 0xf0) >> 4; + if (cmd == 0) { + _frontColor = *ptr & 0xf; + spriteOperation(DRAW_DRAWLINE); + } else if (cmd == 1) { + _frontColor = *ptr & 0xf; + spriteOperation(DRAW_DRAWBAR); + } else if (cmd == 2) { + _backColor = *ptr & 0xf; + spriteOperation(DRAW_FILLRECTABS); + } + } + ptr += 2; + + for (ptr2 = ptr; *ptr2 != 1; ptr2++) { + if (*ptr2 == 3) + ptr2++; + + if (*ptr2 == 2) + ptr2 += 4; + } + + ptr2++; + + while (*ptr != 1) { + cmd = *ptr; + if (cmd == 3) { + ptr++; + _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); + ptr += 4; + continue; + } + + if ((byte)*ptr != 0xba) { + _letterToPrint = *ptr; +// spriteOperation(DRAW_DRAWLETTER); +// _destSpriteX += +// _fonts[_fontIndex]->itemWidth; + ptr++; + } else { + cmd = ptr2[17] & 0x7f; + if (cmd == 0) { + val = READ_LE_UINT16(ptr2 + 18) * 4; + sprintf(buf, "%d", VAR_OFFSET(val)); + } else if (cmd == 1) { + val = READ_LE_UINT16(ptr2 + 18) * 4; + + strcpy(buf, _vm->_global->_inter_variables + val); + } else { + val = READ_LE_UINT16(ptr2 + 18) * 4; + + sprintf(buf, "%d", VAR_OFFSET(val)); + if (buf[0] == '-') { + while (strlen(buf) - 1 < (uint32)ptr2[17]) { + _vm->_util->insertStr("0", buf, 1); + } + } else { + while (strlen(buf) - 1 < (uint32)ptr2[17]) { + _vm->_util->insertStr("0", buf, 0); + } + } + + _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]); + } + + _textToPrint = buf; + ldestSpriteX = _destSpriteX; +// spriteOperation(DRAW_PRINTTEXT); + if (ptr2[17] & 0x80) { + if (ptr[1] == ' ') { +// _destSpriteX += _fonts[_fontIndex]->itemWidth; + while (ptr[1] == ' ') + ptr++; + if (ptr[1] == 2) { + if (READ_LE_UINT16(ptr + 4) == _destSpriteY) + ptr += 5; + } + } else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == _destSpriteY) { + ptr += 5; +// _destSpriteX += _fonts[_fontIndex]->itemWidth; + } +// } else { +// _destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth; + } + ptr2 += 23; + ptr++; + } + } + + _renderFlags = savedFlags; + if (_renderFlags & 4) { + warning("printText: Input not supported"); +// xor ax, ax +// loc_436_1391: +// xor dx, dx +// push ax +// push dx +// push ax +// push dx +// push ax +// mov al, 0 +// push ax +// call sub_9FF_1E71 +// add sp, 0Ch + } + + if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) { + (*_vm->_scenery->_pCaptureCounter)--; + _vm->_game->capturePop(1); + } +} + +void Draw_v2::spriteOperation(int16 operation) { + uint16 id; + char *dataBuf; + Game::TotResItem *itemPtr; + int32 offset; + int16 len; + int16 i; + int16 x; + int16 y; + int16 perLine; + + if (_sourceSurface >= 100) + _sourceSurface -= 80; + + if (_destSurface >= 100) + _destSurface -= 80; + + if (_renderFlags & RENDERFLAG_USEDELTAS) { + if (_sourceSurface == 21) { + _spriteLeft += _backDeltaX; + _spriteTop += _backDeltaY; + } + + if (_destSurface == 21) { + _destSpriteX += _backDeltaX; + _destSpriteY += _backDeltaY; + if (operation == DRAW_DRAWLINE || + (operation >= DRAW_DRAWBAR + && operation <= DRAW_FILLRECTABS)) { + _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); + } + break; + + case DRAW_PUTPIXEL: + _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); + } + break; + + case DRAW_DRAWLINE: + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); + } + break; + + case DRAW_INVALIDATE: + if (_destSurface == 21) { + invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !! + _destSpriteX + _spriteRight, + _destSpriteY + _spriteBottom); + } + break; + + case DRAW_LOADSPRITE: + 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); + } + delete[] dataBuf; + break; + } + // Load from .TOT resources + 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; + } else { + dataBuf = + _vm->_game->_imFileData + + (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]); + } + + _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); + } + break; + + case DRAW_PRINTTEXT: + break; + 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; + } + break; + + case DRAW_DRAWBAR: + _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], + _spriteRight, _destSpriteY, + _spriteRight, _spriteBottom, _frontColor); + + _vm->_video->drawLine(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _destSpriteY, _frontColor); + + 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 (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); + } + break; + + case DRAW_FILLRECTABS: + _vm->_video->fillRect(_spritesArray[_destSurface], + _destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom, _backColor); + + if (_destSurface == 21) { + invalidateRect(_destSpriteX, _destSpriteY, + _spriteRight, _spriteBottom); + } + break; + + case DRAW_DRAWLETTER: + break; + 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]); + 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); + } + + _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 (_destSurface == 21) { + _destSpriteX -= _backDeltaX; + _destSpriteY -= _backDeltaY; + } + } +} + +} // End of namespace Gob diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index afd4dbfe50..3538e01b65 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -194,7 +194,6 @@ int GobEngine::init(GameDetector &detector) { _snd = new Snd(this); _video = new Video(this); _global = new Global(this); - _draw = new Draw(this); _anim = new Anim(); _cdrom = new CDROM(this); _dataio = new DataIO(this); @@ -210,11 +209,13 @@ int GobEngine::init(GameDetector &detector) { _inter = new Inter_v1(this); _parse = new Parse_v1(this); _mult = new Mult_v1(this); + _draw = new Draw_v1(this); } else if (_features & Gob::GF_GOB2) { _inter = new Inter_v2(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); + _draw = new Draw_v2(this); } else error("GobEngine::init(): Unknown version of game engine"); diff --git a/engines/gob/inter.h b/engines/gob/inter.h index bdb6c900c8..46730f140d 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -303,6 +303,7 @@ protected: virtual const char *getOpcodeGoblinDesc(int i); void o2_drawStub(void) { warning("Gob2 stub"); } + void o2_stub0x40(void); void o2_stub0x80(void); bool o2_evaluateStore(char &cmdCount, int16 &counter, int16 &retFlag); bool o2_palLoad(char &cmdCount, int16 &counter, int16 &retFlag); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 71e6b5ba63..047de35350 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1720,6 +1720,14 @@ bool Inter_v1::o1_callSub(char &cmdCount, int16 &counter, int16 &retFlag) { _vm->_global->_inter_execPtr += 2; return false; } + // Skipping the copy protection screen in Gobliins 2 + if (!_vm->_copyProtection && (_vm->_features & GF_GOB2) && (offset == 1746) + && !scumm_stricmp(_vm->_game->_curTotFile, "intro0.tot")) { + warning("=> Skipping copy protection screen"); + debugC(2, DEBUG_GAMEFLOW, "Skipping copy protection screen"); + _vm->_global->_inter_execPtr += 2; + return false; + } _vm->_global->_inter_execPtr = (char *)_vm->_game->_totFileData + offset; diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index b3e5ac4478..2f5a084f22 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -199,7 +199,7 @@ void Inter_v2::setupOpcodes(void) { {NULL, ""}, {NULL, ""}, /* 40 */ - OPCODE(o2_drawStub), + OPCODE(o2_stub0x40), OPCODE(o2_drawStub), OPCODE(o2_drawStub), OPCODE(o2_drawStub), @@ -706,6 +706,31 @@ const char *Inter_v2::getOpcodeGoblinDesc(int i) { return ""; } +void Inter_v2::o2_stub0x40(void) { + char str[18]; + int i; + int length; + + warning("STUB: Gob2 drawOperation 0x40"); + + length = *_vm->_global->_inter_execPtr++; + if (length > 17) + error("Length in o2_stub0x40 is greater than 17 (%d)", length); + if (length & 0x80) { + evalExpr(0); + strcpy(str, _vm->_global->_inter_resStr); + } else { // loc_E8CE + for (i = 0; i < length; i++) // loc_E8E3 + str[i] = *_vm->_global->_inter_execPtr++; + str[i] = 0; + } + + // loc_E910 + + _vm->_global->_inter_execPtr++; + warning("GOB2 Stub! sub_A6EB(%d, \"%s\");", *_vm->_global->_inter_execPtr, str); +} + void Inter_v2::o2_stub0x80(void) { _vm->_global->_inter_execPtr += 2; diff --git a/engines/gob/module.mk b/engines/gob/module.mk index aeea7a8309..69bdc1ba17 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -5,6 +5,8 @@ MODULE_OBJS := \ cdrom.o \ dataio.o \ draw.o \ + draw_v1.o \ + draw_v2.o \ driver_vga.o \ game.o \ global.o \ diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp index 396a0964c4..4f856377c0 100644 --- a/engines/gob/mult.cpp +++ b/engines/gob/mult.cpp @@ -209,80 +209,10 @@ void Mult::initAll(void) { _vm->_scenery->_curStatic = -1; } -void Mult::playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq, - int16 channel) { - _vm->_snd->playSample(soundDesc, repCount, freq); -} - void Mult::zeroMultData(void) { _multData = 0; } -void Mult::freeMultKeys(void) { - int i; - char animCount; - char staticCount; - - _dataPtr = _multData; - staticCount = _dataPtr[0]; - animCount = _dataPtr[1]; - - delete[] _dataPtr; - - staticCount++; - animCount++; - for (i = 0; i < staticCount; i++) { - - if (_staticLoaded[i] != 0) - _vm->_scenery->freeStatic(_staticIndices[i]); - } - - for (i = 0; i < animCount; i++) { - if (_animLoaded[i] != 0) - _vm->_scenery->freeAnim(_animIndices[i]); - } - - delete[] _staticKeys; - - for (i = 0; i < 4; i++) - delete[] _animKeys[i]; - - delete[] _palFadeKeys; - delete[] _palKeys; - delete[] _textKeys; - - for (i = 0; i < _sndSlotsCount; i++) { - _vm->_game->freeSoundSlot(19 - i); - } - - delete[] _sndKeys; - - _multData = 0; - - if (_animDataAllocated != 0) { - delete[] _objects; - _objects = 0; - - delete[] _renderData; - _renderData = 0; - - delete[] _animArrayX; - _animArrayX = 0; - - delete[] _animArrayY; - _animArrayY = 0; - - delete[] _animArrayData; - _animArrayData = 0; - - if (_vm->_anim->_animSurf) - _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); - _vm->_anim->_animSurf = 0; - - _animDataAllocated = 0; - } -} - void Mult::checkFreeMult(void) { if (_multData != 0) freeMultKeys(); diff --git a/engines/gob/mult.h b/engines/gob/mult.h index 415675865a..d073248ce0 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -187,21 +187,21 @@ public: int8 *_orderArray; void zeroMultData(void); - void freeMultKeys(void); void checkFreeMult(void); void interGetObjAnimSize(void); void freeMult(void); void interLoadMult(void); void freeAll(void); void initAll(void); - void playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq, - int16 channel); virtual void setMultData(uint16 multindex) = 0; virtual void loadMult(int16 resId) = 0; virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape, char handleMouse) = 0; virtual void animate(void) = 0; + virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount, + int16 freq, int16 channel) = 0; + virtual void freeMultKeys(void) = 0; Mult(GobEngine *vm); virtual ~Mult() {}; @@ -229,6 +229,9 @@ public: virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape, char handleMouse); virtual void animate(void); + virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount, + int16 freq, int16 channel); + virtual void freeMultKeys(void); protected: virtual char drawStatics(char stop); @@ -307,6 +310,9 @@ public: virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape, char handleMouse); virtual void animate(void); + virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount, + int16 freq, int16 channel); + virtual void freeMultKeys(void); protected: virtual char drawStatics(char stop); diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp index a3d1c82b66..2d1669afa5 100644 --- a/engines/gob/mult_v1.cpp +++ b/engines/gob/mult_v1.cpp @@ -905,4 +905,74 @@ void Mult_v1::animate(void) { } } +void Mult_v1::playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq, + int16 channel) { + _vm->_snd->playSample(soundDesc, repCount, freq); +} + +void Mult_v1::freeMultKeys(void) { + int i; + char animCount; + char staticCount; + + _dataPtr = _multData; + staticCount = _dataPtr[0]; + animCount = _dataPtr[1]; + + delete[] _dataPtr; + + staticCount++; + animCount++; + for (i = 0; i < staticCount; i++) { + + if (_staticLoaded[i] != 0) + _vm->_scenery->freeStatic(_staticIndices[i]); + } + + for (i = 0; i < animCount; i++) { + if (_animLoaded[i] != 0) + _vm->_scenery->freeAnim(_animIndices[i]); + } + + delete[] _staticKeys; + + for (i = 0; i < 4; i++) + delete[] _animKeys[i]; + + delete[] _palFadeKeys; + delete[] _palKeys; + delete[] _textKeys; + + for (i = 0; i < _sndSlotsCount; i++) { + _vm->_game->freeSoundSlot(19 - i); + } + + delete[] _sndKeys; + + _multData = 0; + + if (_animDataAllocated != 0) { + delete[] _objects; + _objects = 0; + + delete[] _renderData; + _renderData = 0; + + delete[] _animArrayX; + _animArrayX = 0; + + delete[] _animArrayY; + _animArrayY = 0; + + delete[] _animArrayData; + _animArrayData = 0; + + if (_vm->_anim->_animSurf) + _vm->_video->freeSurfDesc(_vm->_anim->_animSurf); + _vm->_anim->_animSurf = 0; + + _animDataAllocated = 0; + } +} + } // End of namespace Gob diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index 000d7d02ce..921ba59451 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -1,4 +1,4 @@ - /* ScummVM - Scumm Interpreter +/* ScummVM - Scumm Interpreter * Copyright (C) 2004 Ivan Dubrov * Copyright (C) 2004-2006 The ScummVM project * @@ -1141,4 +1141,81 @@ void Mult_v2::animate(void) { } } +void Mult_v2::playSound(Snd::SoundDesc * soundDesc, int16 repCount, int16 freq, + int16 channel) { + warning("GOB2 Stub! Mult_v2::playSound()"); +// _vm->_snd->playSample(soundDesc, repCount, freq); +} + +void Mult_v2::freeMultKeys(void) { + int i; + char animCount; + char staticCount; + + warning("GOB2 Stub! Mult_v2::freeMultKeys()"); + + if (_multData2 == 0) + return; + + return; + + // loc_7323 + + staticCount = (_multData2->staticCount + 1) && 0x7F; + animCount = _multData2->animCount + 1; + + for (i = 0; i < staticCount; i++) { // loc_7345 + if (_multData2->staticLoaded[i] != 0) + _vm->_scenery->freeStatic(_multData2->staticIndices[i]); + } + + for (i = 0; i < animCount; i++) { // loc_7377 + if (_multData2->animLoaded[i] != 0) + _vm->_scenery->freeAnim(_multData2->animIndices[i]); + } + + delete[] _multData2->staticKeys; + + for (i = 0; i < 4; i++) { // loc_73BA + delete[] _multData2->animKeys[i]; + if (_multData2->somepointer05[i] != 0) + delete[] _multData2->somepointer05[i]; + } + + delete[] _multData2->palFadeKeys; + delete[] _multData2->palKeys; + delete[] _multData2->textKeys; + + for (i = 0; i < _multData2->sndSlotsCount; i++) { // loc_7448 + if ((_multData2->sndSlot[i] & 0x8000) == 0) + _vm->_game->freeSoundSlot(_multData2->sndSlot[i]); + } + + delete[] _multData2->sndKeys; + delete[] _multData2->fadePal; + + if (_multData2->somepointer09 != 0) + delete[] _multData2->somepointer09; + if (_multData2->somepointer10 != 0) + delete[] _multData2->somepointer10; + + if (_animDataAllocated != 0) { + freeMult(); + + delete[] _animArrayX; + _animArrayX = 0; + + delete[] _animArrayY; + _animArrayY = 0; + + delete[] _animArrayData; + _animArrayData = 0; + + _animDataAllocated = 0; + } + + delete _multData2; + _multData2 = 0; +} + } // End of namespace Gob |