2006-04-29 13:38:07 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-05-05 00:42:37 +00:00
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-04-29 13:38:07 +00:00
|
|
|
* Copyright (C) 2001-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.
|
|
|
|
*
|
2006-04-29 14:11:29 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2006-04-29 13:38:07 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/stdafx.h"
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
#include "agos/agos.h"
|
|
|
|
#include "agos/intern.h"
|
2006-04-29 13:38:07 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2006-04-29 13:38:07 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
uint AGOSEngine::getWindowNum(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
uint i;
|
|
|
|
|
|
|
|
for (i = 0; i != ARRAYSIZE(_windowArray); i++)
|
|
|
|
if (_windowArray[i] == window)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
error("getWindowNum: not found");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-11 14:03:40 +00:00
|
|
|
WindowBlock *AGOSEngine::openWindow(uint x, uint y, uint w, uint h, uint flags, uint fillColor, uint textColor) {
|
2006-04-29 13:38:07 +00:00
|
|
|
WindowBlock *window;
|
|
|
|
|
|
|
|
window = _windowList;
|
|
|
|
while (window->mode != 0)
|
|
|
|
window++;
|
|
|
|
|
2006-10-17 01:04:14 +00:00
|
|
|
if (getGameType() == GType_ELVIRA1 && y >= 133)
|
|
|
|
textColor += 16;
|
|
|
|
|
2006-04-29 13:38:07 +00:00
|
|
|
window->mode = 2;
|
|
|
|
window->x = x;
|
|
|
|
window->y = y;
|
|
|
|
window->width = w;
|
|
|
|
window->height = h;
|
|
|
|
window->flags = flags;
|
2006-10-11 14:03:40 +00:00
|
|
|
window->fill_color = fillColor;
|
|
|
|
window->text_color = textColor;
|
2006-04-29 13:38:07 +00:00
|
|
|
window->textColumn = 0;
|
|
|
|
window->textRow = 0;
|
|
|
|
window->textColumnOffset = 0;
|
|
|
|
window->textMaxLength = window->width * 8 / 6; // characters are 6 pixels
|
|
|
|
window->scrollY = 0;
|
2006-10-13 02:22:33 +00:00
|
|
|
|
2006-10-17 01:04:14 +00:00
|
|
|
if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
|
2006-10-13 02:22:33 +00:00
|
|
|
clearWindow(window);
|
|
|
|
|
2006-04-29 13:38:07 +00:00
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::changeWindow(uint a) {
|
2006-04-29 13:38:07 +00:00
|
|
|
a &= 7;
|
|
|
|
|
|
|
|
if (_windowArray[a] == NULL || _curWindow == a)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_curWindow = a;
|
2006-10-21 01:51:59 +00:00
|
|
|
justifyOutPut(0);
|
2006-04-29 13:38:07 +00:00
|
|
|
_textWindow = _windowArray[a];
|
|
|
|
|
2006-09-29 03:25:08 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP)
|
2006-10-21 01:51:59 +00:00
|
|
|
justifyStart(_textWindow->textColumn, _textWindow->width);
|
2006-04-29 13:38:07 +00:00
|
|
|
else
|
2006-10-21 01:51:59 +00:00
|
|
|
justifyStart(_textWindow->textLength, _textWindow->textMaxLength);
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::closeWindow(uint a) {
|
2006-04-29 13:38:07 +00:00
|
|
|
if (_windowArray[a] == NULL)
|
|
|
|
return;
|
|
|
|
removeIconArray(a);
|
|
|
|
resetWindow(_windowArray[a]);
|
|
|
|
_windowArray[a] = NULL;
|
|
|
|
if (_curWindow == a) {
|
|
|
|
_textWindow = NULL;
|
|
|
|
changeWindow(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::clearWindow(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
if (window->flags & 0x10)
|
|
|
|
restoreWindow(window);
|
|
|
|
else
|
|
|
|
colorWindow(window);
|
|
|
|
|
|
|
|
window->textColumn = 0;
|
|
|
|
window->textRow = 0;
|
|
|
|
window->textColumnOffset = 0;
|
|
|
|
window->textLength = 0;
|
|
|
|
window->scrollY = 0;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::colorWindow(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
byte *dst;
|
|
|
|
uint h, w;
|
|
|
|
|
|
|
|
_lockWord |= 0x8000;
|
|
|
|
|
2006-09-29 03:25:08 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
2006-04-29 13:38:07 +00:00
|
|
|
dst = getFrontBuf() + _dxSurfacePitch * window->y + window->x;
|
|
|
|
|
|
|
|
for (h = 0; h < window->height; h++) {
|
|
|
|
for (w = 0; w < window->width; w++) {
|
|
|
|
if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
|
|
|
|
dst[w] = window->fill_color;
|
|
|
|
}
|
|
|
|
dst += _screenWidth;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dst = getFrontBuf() + _dxSurfacePitch * window->y + window->x * 8;
|
|
|
|
h = window->height * 8;
|
|
|
|
w = window->width * 8;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memset(dst, window->fill_color, w);
|
|
|
|
dst += _dxSurfacePitch;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
|
|
|
|
_lockWord &= ~0x8000;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::resetWindow(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
if (window->flags & 8)
|
|
|
|
restoreWindow(window);
|
|
|
|
window->mode = 0;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::restoreWindow(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
_lockWord |= 0x8000;
|
|
|
|
|
2006-09-29 03:25:08 +00:00
|
|
|
if (getGameType() == GType_FF || getGameType() == GType_PP) {
|
2006-04-29 13:38:07 +00:00
|
|
|
restoreBlock(window->y + window->height, window->x + window->width, window->y, window->x);
|
|
|
|
} else if (getGameType() == GType_SIMON2) {
|
|
|
|
if (_restoreWindow6 && _windowArray[2] == window) {
|
|
|
|
window = _windowArray[6];
|
|
|
|
_restoreWindow6 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
restoreBlock(window->y + window->height * 8, (window->x + window->width) * 8, window->y, window->x * 8);
|
|
|
|
} else {
|
|
|
|
restoreBlock(window->y + window->height * 8 + ((window == _windowArray[2]) ? 1 : 0), (window->x + window->width) * 8, window->y, window->x * 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
_lockWord &= ~0x8000;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::restoreBlock(uint h, uint w, uint y, uint x) {
|
2006-04-29 14:11:29 +00:00
|
|
|
byte *dst, *src;
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
dst = getFrontBuf();
|
|
|
|
src = _backGroundBuf;
|
|
|
|
|
|
|
|
dst += y * _dxSurfacePitch;
|
|
|
|
src += y * _dxSurfacePitch;
|
|
|
|
|
|
|
|
while (y < h) {
|
|
|
|
for (i = x; i < w; i++)
|
|
|
|
dst[i] = src[i];
|
|
|
|
y++;
|
|
|
|
dst += _dxSurfacePitch;
|
|
|
|
src += _dxSurfacePitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
void AGOSEngine::windowPutChar(uint a) {
|
2006-04-29 13:38:07 +00:00
|
|
|
if (_textWindow != _windowArray[0])
|
|
|
|
windowPutChar(_textWindow, a);
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|