2005-04-05 15:53:16 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2004 Ivan Dubrov
|
|
|
|
* Copyright (C) 2004-2005 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
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 15:53:16 +00:00
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/draw.h"
|
|
|
|
#include "gob/global.h"
|
|
|
|
#include "gob/video.h"
|
|
|
|
#include "gob/game.h"
|
|
|
|
#include "gob/util.h"
|
2005-04-09 19:32:29 +00:00
|
|
|
#include "gob/scenery.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/inter.h"
|
|
|
|
#include "gob/video.h"
|
|
|
|
#include "gob/palanim.h"
|
2005-04-13 18:27:29 +00:00
|
|
|
#include "gob/cdrom.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Draw::Draw(GobEngine *vm) : _vm(vm) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_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;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_fonts[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_textToPrint = 0;
|
|
|
|
_transparency = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 50; i++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_spritesArray[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedCount = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
for (int i = 0; i < 30; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedTops[i] = 0;
|
|
|
|
_invalidatedLefts[i] = 0;
|
|
|
|
_invalidatedRights[i] = 0;
|
|
|
|
_invalidatedBottoms[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_noInvalidated = 0;
|
|
|
|
_applyPal = 0;
|
|
|
|
_paletteCleared = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_backSurface = 0;
|
|
|
|
_frontSurface = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 18; i++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_unusedPalette1[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
for (int i = 0; i < 16; i++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_unusedPalette2[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
for (int i = 0; i < 256; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_vgaPalette[i].red = 0;
|
|
|
|
_vgaPalette[i].blue = 0;
|
|
|
|
_vgaPalette[i].green = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < 16; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_vgaSmallPalette[i].red = 0;
|
|
|
|
_vgaSmallPalette[i].blue = 0;
|
|
|
|
_vgaSmallPalette[i].green = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorX = 0;
|
|
|
|
_cursorY = 0;
|
|
|
|
_cursorWidth = 0;
|
|
|
|
_cursorHeight = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorXDeltaVar = -1;
|
|
|
|
_cursorYDeltaVar = -1;
|
2006-01-03 23:14:39 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 40; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorAnimLow[i] = 0;
|
|
|
|
_cursorAnimHigh[i] = 0;
|
|
|
|
_cursorAnimDelays[i] = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_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;
|
2006-01-03 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 temp;
|
|
|
|
int16 rect;
|
|
|
|
int16 i;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_renderFlags & RENDERFLAG_NOINVALIDATE)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (left > right) {
|
|
|
|
temp = left;
|
|
|
|
left = right;
|
|
|
|
right = temp;
|
|
|
|
}
|
|
|
|
if (top > bottom) {
|
|
|
|
temp = top;
|
|
|
|
top = bottom;
|
|
|
|
bottom = temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left > 319 || right < 0 || top > 199 || bottom < 0)
|
|
|
|
return;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_noInvalidated = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedCount >= 30) {
|
|
|
|
_invalidatedLefts[0] = 0;
|
|
|
|
_invalidatedTops[0] = 0;
|
|
|
|
_invalidatedRights[0] = 319;
|
|
|
|
_invalidatedBottoms[0] = 199;
|
|
|
|
_invalidatedCount = 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (left < 0)
|
|
|
|
left = 0;
|
|
|
|
|
|
|
|
if (right > 319)
|
|
|
|
right = 319;
|
|
|
|
|
|
|
|
if (top < 0)
|
|
|
|
top = 0;
|
|
|
|
|
|
|
|
if (bottom > 199)
|
|
|
|
bottom = 199;
|
|
|
|
|
|
|
|
left &= 0xfff0;
|
|
|
|
right |= 0x000f;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
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];
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedLefts[rect] = left;
|
|
|
|
_invalidatedTops[rect] = top;
|
|
|
|
_invalidatedRights[rect] = right;
|
|
|
|
_invalidatedBottoms[rect] = bottom;
|
|
|
|
_invalidatedCount++;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedBottoms[rect] < bottom)
|
|
|
|
_invalidatedBottoms[rect] = bottom;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedLefts[rect] > left)
|
|
|
|
_invalidatedLefts[rect] = left;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedRights[rect] < right)
|
|
|
|
_invalidatedRights[rect] = right;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedTops[rect] = top;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedBottoms[rect] < top)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedBottoms[rect] < bottom)
|
|
|
|
_invalidatedBottoms[rect] = bottom;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedLefts[rect] > left)
|
|
|
|
_invalidatedLefts[rect] = left;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_invalidatedRights[rect] < right)
|
|
|
|
_invalidatedRights[rect] = right;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedLefts[_invalidatedCount] = left;
|
|
|
|
_invalidatedTops[_invalidatedCount] = top;
|
|
|
|
_invalidatedRights[_invalidatedCount] = right;
|
|
|
|
_invalidatedBottoms[_invalidatedCount] = bottom;
|
|
|
|
_invalidatedCount++;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::blitInvalidated(void) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 i;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorIndex == 4)
|
2006-01-03 23:14:39 +00:00
|
|
|
blitCursor();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:23:20 +00:00
|
|
|
if (_vm->_inter->_terminate)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_noInvalidated && _applyPal == 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_noInvalidated) {
|
2006-01-03 23:14:39 +00:00
|
|
|
setPalette();
|
2006-01-07 22:28:54 +00:00
|
|
|
_applyPal = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_applyPal) {
|
2006-01-03 23:14:39 +00:00
|
|
|
clearPalette();
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0, 319,
|
2005-04-05 15:07:40 +00:00
|
|
|
199, 0, 0, 0);
|
2006-01-03 23:14:39 +00:00
|
|
|
setPalette();
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedCount = 0;
|
|
|
|
_noInvalidated = 1;
|
|
|
|
_applyPal = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_global->_doRangeClamp = 0;
|
2006-01-07 22:28:54 +00:00
|
|
|
for (i = 0; i < _invalidatedCount; i++) {
|
|
|
|
_vm->_video->drawSprite(_backSurface, _frontSurface,
|
|
|
|
_invalidatedLefts[i], _invalidatedTops[i],
|
|
|
|
_invalidatedRights[i], _invalidatedBottoms[i],
|
|
|
|
_invalidatedLefts[i], _invalidatedTops[i], 0);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_global->_doRangeClamp = 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_invalidatedCount = 0;
|
|
|
|
_noInvalidated = 1;
|
|
|
|
_applyPal = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::setPalette(void) {
|
2006-01-04 01:48:15 +00:00
|
|
|
if (_vm->_global->_videoMode != 0x13)
|
2006-01-03 23:14:39 +00:00
|
|
|
error("setPalette: Video mode 0x%x is not supported!\n",
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_global->_videoMode);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_global->_pPaletteDesc->unused1 = _unusedPalette1;
|
|
|
|
_vm->_global->_pPaletteDesc->unused2 = _unusedPalette2;
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = _vgaPalette;
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
|
2006-01-07 22:28:54 +00:00
|
|
|
_paletteCleared = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::clearPalette(void) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_paletteCleared == 0) {
|
|
|
|
_paletteCleared = 1;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_util->clearPalette();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::blitCursor(void) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorIndex == -1)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorIndex = -1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_noInvalidated) {
|
|
|
|
_vm->_video->drawSprite(_backSurface, _frontSurface,
|
|
|
|
_cursorX, _cursorY,
|
|
|
|
_cursorX + _cursorWidth - 1,
|
|
|
|
_cursorY + _cursorHeight - 1, _cursorX,
|
|
|
|
_cursorY, 0);
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2006-01-07 22:28:54 +00:00
|
|
|
invalidateRect(_cursorX, _cursorY,
|
|
|
|
_cursorX + _cursorWidth - 1,
|
|
|
|
_cursorY + _cursorHeight - 1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::spriteOperation(int16 operation) {
|
2005-04-05 15:07:40 +00:00
|
|
|
uint16 id;
|
|
|
|
char *dataBuf;
|
2006-01-03 23:14:39 +00:00
|
|
|
Game::TotResItem *itemPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int32 offset;
|
|
|
|
int16 len;
|
|
|
|
int16 i;
|
|
|
|
int16 x;
|
|
|
|
int16 y;
|
|
|
|
int16 perLine;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_sourceSurface >= 100)
|
|
|
|
_sourceSurface -= 80;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface >= 100)
|
|
|
|
_destSurface -= 80;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_renderFlags & RENDERFLAG_USEDELTAS) {
|
|
|
|
if (_sourceSurface == 21) {
|
|
|
|
_spriteLeft += _backDeltaX;
|
|
|
|
_spriteTop += _backDeltaY;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
_destSpriteX += _backDeltaX;
|
|
|
|
_destSpriteY += _backDeltaY;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (operation == DRAW_DRAWLINE ||
|
|
|
|
(operation >= DRAW_DRAWBAR
|
|
|
|
&& operation <= DRAW_FILLRECTABS)) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_spriteRight += _backDeltaX;
|
|
|
|
_spriteBottom += _backDeltaY;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (operation) {
|
|
|
|
case DRAW_BLITSURF:
|
2006-01-07 22:28:54 +00:00
|
|
|
_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);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PUTPIXEL:
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->putPixel(_destSpriteX, _destSpriteY,
|
|
|
|
_frontColor, _spritesArray[_destSurface]);
|
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_destSpriteX, _destSpriteY);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_FILLRECT:
|
2006-01-07 22:28:54 +00:00
|
|
|
_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);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_DRAWLINE:
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLine(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom, _frontColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_INVALIDATE:
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !!
|
|
|
|
_destSpriteX + _spriteRight,
|
|
|
|
_destSpriteY + _spriteBottom);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_LOADSPRITE:
|
2006-01-07 22:28:54 +00:00
|
|
|
id = _spriteLeft;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (id >= 30000) {
|
|
|
|
dataBuf =
|
2006-01-07 22:28:54 +00:00
|
|
|
_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);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
free(dataBuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Load from .TOT resources
|
2006-01-07 22:28:54 +00:00
|
|
|
itemPtr = &_vm->_game->_totResourceTable->items[id];
|
2005-04-05 15:07:40 +00:00
|
|
|
offset = itemPtr->offset;
|
|
|
|
if (offset >= 0) {
|
|
|
|
dataBuf =
|
2006-01-07 22:28:54 +00:00
|
|
|
((char *)_vm->_game->_totResourceTable) +
|
2005-04-05 15:07:40 +00:00
|
|
|
szGame_TotResTable + szGame_TotResItem *
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_game->_totResourceTable->itemsCount + offset;
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2005-07-30 21:11:48 +00:00
|
|
|
dataBuf =
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_game->_imFileData +
|
|
|
|
(int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_spriteRight = itemPtr->width;
|
|
|
|
_spriteBottom = itemPtr->height;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_video->drawPackedSprite((byte *)dataBuf,
|
2006-01-07 22:28:54 +00:00
|
|
|
_spriteRight, _spriteBottom,
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_transparency, _spritesArray[_destSurface]);
|
|
|
|
|
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_destSpriteX + _spriteRight - 1,
|
|
|
|
_destSpriteY + _spriteBottom - 1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_PRINTTEXT:
|
2006-01-07 22:28:54 +00:00
|
|
|
len = strlen(_textToPrint);
|
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_destSpriteX +
|
|
|
|
len * _fonts[_fontIndex]->itemWidth - 1,
|
|
|
|
_destSpriteY +
|
|
|
|
_fonts[_fontIndex]->itemHeight - 1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLetter(_textToPrint[i],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_fonts[_fontIndex],
|
|
|
|
_transparency,
|
|
|
|
_frontColor, _backColor,
|
|
|
|
_spritesArray[_destSurface]);
|
|
|
|
|
|
|
|
_destSpriteX += _fonts[_fontIndex]->itemWidth;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_DRAWBAR:
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLine(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _spriteBottom,
|
|
|
|
_spriteRight, _spriteBottom, _frontColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLine(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_destSpriteX, _spriteBottom, _frontColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLine(_spritesArray[_destSurface],
|
|
|
|
_spriteRight, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom, _frontColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLine(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _destSpriteY, _frontColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_CLEARRECT:
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_backColor < 16) {
|
|
|
|
_vm->_video->fillRect(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom,
|
|
|
|
_backColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_FILLRECTABS:
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->fillRect(_spritesArray[_destSurface],
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom, _backColor);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX, _destSpriteY,
|
|
|
|
_spriteRight, _spriteBottom);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_DRAWLETTER:
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_fontToSprite[_fontIndex].sprite == -1) {
|
|
|
|
if (_destSurface == 21) {
|
|
|
|
invalidateRect(_destSpriteX,
|
|
|
|
_destSpriteY,
|
|
|
|
_destSpriteX +
|
|
|
|
_fonts[_fontIndex]->itemWidth - 1,
|
|
|
|
_destSpriteY +
|
|
|
|
_fonts[_fontIndex]->itemHeight -
|
2005-04-05 15:07:40 +00:00
|
|
|
1);
|
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawLetter(_letterToPrint,
|
|
|
|
_destSpriteX, _destSpriteY,
|
|
|
|
_fonts[_fontIndex],
|
|
|
|
_transparency,
|
|
|
|
_frontColor, _backColor,
|
|
|
|
_spritesArray[_destSurface]);
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
perLine =
|
2006-01-07 22:28:54 +00:00
|
|
|
_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);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawSprite(_spritesArray[(int16)_fontToSprite
|
|
|
|
[_fontIndex].sprite],
|
|
|
|
_spritesArray[_destSurface], x, y,
|
|
|
|
x + _fontToSprite[_fontIndex].width,
|
|
|
|
y + _fontToSprite[_fontIndex].height,
|
|
|
|
_destSpriteX, _destSpriteY, _transparency);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_renderFlags & RENDERFLAG_USEDELTAS) {
|
|
|
|
if (_sourceSurface == 21) {
|
|
|
|
_spriteLeft -= _backDeltaX;
|
|
|
|
_spriteTop -= _backDeltaY;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_destSurface == 21) {
|
|
|
|
_destSpriteX -= _backDeltaX;
|
|
|
|
_destSpriteY -= _backDeltaY;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::animateCursor(int16 cursor) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 newX = 0;
|
|
|
|
int16 newY = 0;
|
2006-01-03 23:14:39 +00:00
|
|
|
Game::Collision *ptr;
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 minX;
|
|
|
|
int16 minY;
|
|
|
|
int16 maxX;
|
|
|
|
int16 maxY;
|
|
|
|
int16 cursorIndex;
|
|
|
|
|
|
|
|
cursorIndex = cursor;
|
|
|
|
|
|
|
|
if (cursorIndex == -1) {
|
|
|
|
cursorIndex = 0;
|
2006-01-07 22:28:54 +00:00
|
|
|
for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) {
|
2005-04-05 15:07:40 +00:00
|
|
|
if (ptr->flags & 0xfff0)
|
|
|
|
continue;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
if (ptr->left > _vm->_global->_inter_mouseX)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
if (ptr->right < _vm->_global->_inter_mouseX)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
if (ptr->top > _vm->_global->_inter_mouseY)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
if (ptr->bottom < _vm->_global->_inter_mouseY)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((ptr->flags & 0xf) < 3)
|
|
|
|
cursorIndex = 1;
|
|
|
|
else
|
|
|
|
cursorIndex = 3;
|
|
|
|
break;
|
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorAnimLow[cursorIndex] == -1)
|
2005-04-05 15:07:40 +00:00
|
|
|
cursorIndex = 1;
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorAnimLow[cursorIndex] != -1) {
|
|
|
|
if (cursorIndex == _cursorIndex) {
|
|
|
|
if (_cursorAnimDelays[_cursorIndex] != 0 &&
|
|
|
|
_cursorAnimDelays[_cursorIndex] * 10 +
|
|
|
|
_cursorTimeKey <= _vm->_util->getTimeKey()) {
|
|
|
|
_cursorAnim++;
|
|
|
|
_cursorTimeKey = _vm->_util->getTimeKey();
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2006-01-07 22:28:54 +00:00
|
|
|
/* if (_noInvalidated &&
|
|
|
|
inter_mouseX == _cursorX && inter_mouseY == _cursorY)
|
2005-04-05 15:07:40 +00:00
|
|
|
return;*/
|
|
|
|
}
|
|
|
|
} else {
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorIndex = cursorIndex;
|
|
|
|
if (_cursorAnimDelays[_cursorIndex] != 0) {
|
|
|
|
_cursorAnim =
|
|
|
|
_cursorAnimLow[_cursorIndex];
|
|
|
|
_cursorTimeKey = _vm->_util->getTimeKey();
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorAnim = _cursorIndex;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorAnimDelays[_cursorIndex] != 0 &&
|
|
|
|
(_cursorAnimHigh[_cursorIndex] < _cursorAnim ||
|
|
|
|
_cursorAnimLow[_cursorIndex] >
|
|
|
|
_cursorAnim)) {
|
|
|
|
_cursorAnim = _cursorAnimLow[_cursorIndex];
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
newX = _vm->_global->_inter_mouseX;
|
|
|
|
newY = _vm->_global->_inter_mouseY;
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_cursorXDeltaVar != -1) {
|
|
|
|
newX -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorXDeltaVar / 4) * 4);
|
|
|
|
newY -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorYDeltaVar / 4) * 4);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
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;
|
2006-01-03 23:14:39 +00:00
|
|
|
blitInvalidated();
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorIndex = cursorIndex;
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_video->waitRetrace(_vm->_global->_videoMode);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawSprite(_backSurface, _frontSurface,
|
2005-04-05 15:07:40 +00:00
|
|
|
minX, minY, maxX, maxY, minX, minY, 0);
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_video->drawSprite(_cursorBack, _backSurface,
|
|
|
|
0, 0, _cursorWidth - 1, _cursorHeight - 1,
|
2005-04-05 15:07:40 +00:00
|
|
|
newX, newY, 0);
|
|
|
|
} else {
|
2006-01-03 23:14:39 +00:00
|
|
|
blitCursor();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_cursorX = newX;
|
|
|
|
_cursorY = newY;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::interPalLoad(void) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 i;
|
|
|
|
int16 ind1;
|
|
|
|
int16 ind2;
|
|
|
|
byte cmd;
|
|
|
|
char *palPtr;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
cmd = *_vm->_global->_inter_execPtr++;
|
2006-01-07 22:28:54 +00:00
|
|
|
_applyPal = 0;
|
2005-04-05 15:07:40 +00:00
|
|
|
if (cmd & 0x80)
|
|
|
|
cmd &= 0x7f;
|
|
|
|
else
|
2006-01-07 22:28:54 +00:00
|
|
|
_applyPal = 1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
if (cmd == 49) {
|
|
|
|
warning("inter_palLoad: cmd == 49 is not supported");
|
|
|
|
//var_B = 1;
|
2006-01-04 01:48:15 +00:00
|
|
|
for (i = 0; i < 18; i++, _vm->_global->_inter_execPtr++) {
|
2005-04-05 15:07:40 +00:00
|
|
|
if (i < 2) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (_applyPal == 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_unusedPalette1[i] = *_vm->_global->_inter_execPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-05-08 21:49:52 +00:00
|
|
|
//if (*inter_execPtr != 0)
|
2005-04-05 15:07:40 +00:00
|
|
|
// var_B = 0;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
ind1 = *_vm->_global->_inter_execPtr >> 4;
|
|
|
|
ind2 = (*_vm->_global->_inter_execPtr & 0xf);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_unusedPalette1[i] =
|
|
|
|
((_palLoadData1[ind1] + _palLoadData2[ind2]) << 8) +
|
|
|
|
(_palLoadData2[ind1] + _palLoadData1[ind2]);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_global->_pPaletteDesc->unused1 = _unusedPalette1;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case 52:
|
2006-01-04 01:48:15 +00:00
|
|
|
for (i = 0; i < 16; i++, _vm->_global->_inter_execPtr += 3) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_vgaSmallPalette[i].red = _vm->_global->_inter_execPtr[0];
|
|
|
|
_vgaSmallPalette[i].green = _vm->_global->_inter_execPtr[1];
|
|
|
|
_vgaSmallPalette[i].blue = _vm->_global->_inter_execPtr[2];
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 50:
|
2006-01-04 01:48:15 +00:00
|
|
|
for (i = 0; i < 16; i++, _vm->_global->_inter_execPtr++)
|
2006-01-07 22:28:54 +00:00
|
|
|
_unusedPalette2[i] = *_vm->_global->_inter_execPtr;
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 53:
|
2006-01-03 23:14:39 +00:00
|
|
|
palPtr = _vm->_game->loadTotResource(_vm->_inter->load16());
|
2006-01-07 22:28:54 +00:00
|
|
|
memcpy((char *)_vgaPalette, palPtr, 768);
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 54:
|
2006-01-07 22:28:54 +00:00
|
|
|
memset((char *)_vgaPalette, 0, 768);
|
2005-04-05 15:07:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
if (!_applyPal) {
|
|
|
|
_vm->_global->_pPaletteDesc->unused2 = _unusedPalette2;
|
|
|
|
_vm->_global->_pPaletteDesc->unused1 = _unusedPalette1;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
if (_vm->_global->_videoMode != 0x13)
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)_vgaSmallPalette;
|
2005-04-05 15:07:40 +00:00
|
|
|
else
|
2006-01-07 22:28:54 +00:00
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = (Video::Color *)_vgaPalette;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_palanim->fade((Video::PalDesc *) _vm->_global->_pPaletteDesc, 0, 0);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Draw::printText(void) {
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 savedFlags;
|
2006-01-03 23:14:39 +00:00
|
|
|
int16 ldestSpriteX;
|
2005-04-05 15:07:40 +00:00
|
|
|
char *dataPtr;
|
|
|
|
char *ptr;
|
|
|
|
char *ptr2;
|
|
|
|
int16 index;
|
|
|
|
int16 destX;
|
|
|
|
int16 destY;
|
|
|
|
char cmd;
|
|
|
|
int16 val;
|
|
|
|
char buf[20];
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
index = _vm->_inter->load16();
|
2005-04-13 18:27:29 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_cdrom->playMultMusic();
|
2005-04-13 18:27:29 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
dataPtr = (char *)_vm->_game->_totTextData + _vm->_game->_totTextData->items[index].offset;
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr = dataPtr;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
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);
|
2006-01-09 16:10:22 +00:00
|
|
|
(*_vm->_scenery->_pCaptureCounter)++;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX = READ_LE_UINT16(ptr);
|
|
|
|
destX = _destSpriteX;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteY = READ_LE_UINT16(ptr + 2);
|
|
|
|
destY = _destSpriteY;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_spriteRight = READ_LE_UINT16(ptr + 4);
|
|
|
|
_spriteBottom = READ_LE_UINT16(ptr + 6);
|
|
|
|
_destSurface = 21;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
ptr += 8;
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_backColor = *ptr++;
|
|
|
|
_transparency = 1;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_CLEARRECT);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_backColor = 0;
|
|
|
|
savedFlags = _renderFlags;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_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;
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr += 8;
|
|
|
|
|
|
|
|
cmd = (*ptr & 0xf0) >> 4;
|
|
|
|
if (cmd == 0) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_frontColor = *ptr & 0xf;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_DRAWLINE);
|
2005-04-05 15:07:40 +00:00
|
|
|
} else if (cmd == 1) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_frontColor = *ptr & 0xf;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_DRAWBAR);
|
2005-04-05 15:07:40 +00:00
|
|
|
} else if (cmd == 2) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_backColor = *ptr & 0xf;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_FILLRECTABS);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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++;
|
2006-01-07 22:28:54 +00:00
|
|
|
_fontIndex = (*ptr & 0xf0) >> 4;
|
|
|
|
_frontColor = *ptr & 0xf;
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr++;
|
|
|
|
continue;
|
|
|
|
} else if (cmd == 2) {
|
|
|
|
ptr++;
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX = destX + READ_LE_UINT16(ptr);
|
|
|
|
_destSpriteY = destY + READ_LE_UINT16(ptr + 2);
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr += 4;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((byte)*ptr != 0xba) {
|
2006-01-07 22:28:54 +00:00
|
|
|
_letterToPrint = *ptr;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_DRAWLETTER);
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX +=
|
|
|
|
_fonts[_fontIndex]->itemWidth;
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr++;
|
|
|
|
} else {
|
|
|
|
cmd = ptr2[17] & 0x7f;
|
|
|
|
if (cmd == 0) {
|
|
|
|
val = READ_LE_UINT16(ptr2 + 18) * 4;
|
2005-04-10 17:13:17 +00:00
|
|
|
sprintf(buf, "%d", VAR_OFFSET(val));
|
2005-04-05 15:07:40 +00:00
|
|
|
} else if (cmd == 1) {
|
|
|
|
val = READ_LE_UINT16(ptr2 + 18) * 4;
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
strcpy(buf, _vm->_global->_inter_variables + val);
|
2005-04-05 15:07:40 +00:00
|
|
|
} else {
|
|
|
|
val = READ_LE_UINT16(ptr2 + 18) * 4;
|
|
|
|
|
2005-04-10 17:13:17 +00:00
|
|
|
sprintf(buf, "%d", VAR_OFFSET(val));
|
2005-04-05 15:07:40 +00:00
|
|
|
if (buf[0] == '-') {
|
|
|
|
while (strlen(buf) - 1 < (uint32)ptr2[17]) {
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_util->insertStr("0", buf, 1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (strlen(buf) - 1 < (uint32)ptr2[17]) {
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_util->insertStr("0", buf, 0);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_textToPrint = buf;
|
|
|
|
ldestSpriteX = _destSpriteX;
|
2006-01-03 23:14:39 +00:00
|
|
|
spriteOperation(DRAW_PRINTTEXT);
|
2005-04-05 15:07:40 +00:00
|
|
|
if (ptr2[17] & 0x80) {
|
|
|
|
if (ptr[1] == ' ') {
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX += _fonts[_fontIndex]->itemWidth;
|
2005-04-05 15:07:40 +00:00
|
|
|
while (ptr[1] == ' ')
|
|
|
|
ptr++;
|
|
|
|
if (ptr[1] == 2) {
|
2006-01-07 22:28:54 +00:00
|
|
|
if (READ_LE_UINT16(ptr + 4) == _destSpriteY)
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr += 5;
|
|
|
|
}
|
2006-01-07 22:28:54 +00:00
|
|
|
} else if (ptr[1] == 2 && READ_LE_UINT16(ptr + 4) == _destSpriteY) {
|
2005-04-05 15:07:40 +00:00
|
|
|
ptr += 5;
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX += _fonts[_fontIndex]->itemWidth;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-01-07 22:28:54 +00:00
|
|
|
_destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
ptr2 += 23;
|
|
|
|
ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-07 22:28:54 +00:00
|
|
|
_renderFlags = savedFlags;
|
|
|
|
if (_renderFlags & 4) {
|
2006-01-03 23:14:39 +00:00
|
|
|
warning("printText: Input not supported!");
|
2005-04-05 15:07:40 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2006-01-09 16:10:22 +00:00
|
|
|
if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) {
|
|
|
|
(*_vm->_scenery->_pCaptureCounter)--;
|
2006-01-03 23:14:39 +00:00
|
|
|
_vm->_game->capturePop(1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Gob
|