2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2006-04-29 13:38:07 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-21 03:14:20 +00:00
|
|
|
#include "common/system.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2007-06-21 03:14:20 +00:00
|
|
|
|
|
|
|
#include "graphics/surface.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");
|
2009-09-24 17:52:53 +00:00
|
|
|
return 0; // for compilers that don't support NORETURN
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2009-02-07 01:11:51 +00:00
|
|
|
window->fillColor = fillColor;
|
|
|
|
window->textColor = textColor;
|
2006-04-29 13:38:07 +00:00
|
|
|
window->textColumn = 0;
|
|
|
|
window->textColumnOffset = 0;
|
2007-06-18 10:57:50 +00:00
|
|
|
window->textRow = 0;
|
2006-04-29 13:38:07 +00:00
|
|
|
window->scrollY = 0;
|
2006-10-13 02:22:33 +00:00
|
|
|
|
2007-06-18 10:57:50 +00:00
|
|
|
// Characters are 6 pixels
|
|
|
|
if (getGameType() == GType_ELVIRA2)
|
|
|
|
window->textMaxLength = (window->width * 8 - 4) / 6;
|
2009-03-08 08:45:21 +00:00
|
|
|
else if (getGameType() == GType_PN)
|
|
|
|
window->textMaxLength = window->width * 8 / 6 + 1;
|
2007-06-18 10:57:50 +00:00
|
|
|
else
|
|
|
|
window->textMaxLength = window->width * 8 / 6;
|
|
|
|
|
2009-03-08 08:45:21 +00:00
|
|
|
if (getGameType() == GType_PN || getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
|
2006-10-13 02:22:33 +00:00
|
|
|
clearWindow(window);
|
|
|
|
|
2009-02-07 01:11:51 +00:00
|
|
|
if (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformAmiga && window->fillColor == 225)
|
|
|
|
window->fillColor = (getFeatures() & GF_32COLOR) ? 17 : 241;
|
2008-03-24 06:48:09 +00:00
|
|
|
|
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-10-27 13:28:32 +00:00
|
|
|
justifyStart();
|
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;
|
2007-06-07 00:54:17 +00:00
|
|
|
window->textColumnOffset = (getGameType() == GType_ELVIRA2) ? 4 : 0;
|
2006-04-29 13:38:07 +00:00
|
|
|
window->textLength = 0;
|
|
|
|
window->scrollY = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-11 14:42:44 +00:00
|
|
|
#ifdef ENABLE_AGOS2
|
2007-06-07 15:42:59 +00:00
|
|
|
void AGOSEngine_Feeble::colorWindow(WindowBlock *window) {
|
2006-04-29 13:38:07 +00:00
|
|
|
byte *dst;
|
2007-06-07 15:42:59 +00:00
|
|
|
uint16 h, w;
|
2006-04-29 13:38:07 +00:00
|
|
|
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut |= 0x8000;
|
2006-04-29 13:38:07 +00:00
|
|
|
|
2009-07-06 06:21:59 +00:00
|
|
|
dst = getBackGround() + _backGroundBuf->pitch * window->y + window->x;
|
2007-06-07 15:42:59 +00:00
|
|
|
|
|
|
|
for (h = 0; h < window->height; h++) {
|
|
|
|
for (w = 0; w < window->width; w++) {
|
2009-02-07 01:11:51 +00:00
|
|
|
if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
|
|
|
|
dst[w] = window->fillColor;
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
2009-07-06 06:21:59 +00:00
|
|
|
dst += _backGroundBuf->pitch;
|
2007-06-07 15:42:59 +00:00
|
|
|
}
|
|
|
|
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut &= ~0x8000;
|
2007-06-07 15:42:59 +00:00
|
|
|
}
|
2009-08-11 14:42:44 +00:00
|
|
|
#endif
|
2007-06-07 15:42:59 +00:00
|
|
|
|
|
|
|
void AGOSEngine::colorWindow(WindowBlock *window) {
|
2007-06-08 02:18:22 +00:00
|
|
|
uint16 y, h;
|
2007-06-07 15:42:59 +00:00
|
|
|
|
|
|
|
y = window->y;
|
|
|
|
h = window->height * 8;
|
|
|
|
|
|
|
|
if (getGameType() == GType_ELVIRA2 && window->y == 146) {
|
2009-02-07 01:11:51 +00:00
|
|
|
if (window->fillColor == 1) {
|
2011-02-15 22:22:30 +00:00
|
|
|
_displayPalette[33 * 3 + 0] = 48 * 4;
|
|
|
|
_displayPalette[33 * 3 + 1] = 40 * 4;
|
|
|
|
_displayPalette[33 * 3 + 2] = 32 * 4;
|
2007-06-07 15:42:59 +00:00
|
|
|
} else {
|
2011-02-15 22:22:30 +00:00
|
|
|
_displayPalette[33 * 3 + 0] = 56 * 4;
|
|
|
|
_displayPalette[33 * 3 + 1] = 56 * 4;
|
|
|
|
_displayPalette[33 * 3 + 2] = 40 * 4;
|
2007-05-27 11:46:42 +00:00
|
|
|
}
|
2006-04-29 13:38:07 +00:00
|
|
|
|
2007-06-07 15:42:59 +00:00
|
|
|
y--;
|
|
|
|
h += 2;
|
2006-11-05 06:26:45 +00:00
|
|
|
|
2007-06-07 15:42:59 +00:00
|
|
|
_paletteFlag = 1;
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
2007-06-08 02:18:22 +00:00
|
|
|
colorBlock(window, window->x * 8, y, window->width * 8, h);
|
2007-06-07 15:42:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, uint16 h) {
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut |= 0x8000;
|
2007-06-07 15:42:59 +00:00
|
|
|
|
2007-06-21 03:14:20 +00:00
|
|
|
Graphics::Surface *screen = _system->lockScreen();
|
2013-08-02 21:12:09 +00:00
|
|
|
byte *dst = (byte *)screen->getBasePtr(x, y);
|
2007-06-07 15:42:59 +00:00
|
|
|
|
2009-02-07 01:11:51 +00:00
|
|
|
uint8 color = window->fillColor;
|
2007-06-07 15:42:59 +00:00
|
|
|
if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
|
|
|
|
color += dst[0] & 0xF0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memset(dst, color, w);
|
2009-07-06 06:21:59 +00:00
|
|
|
dst += screen->pitch;
|
2007-06-07 15:42:59 +00:00
|
|
|
} while (--h);
|
|
|
|
|
2007-06-21 03:14:20 +00:00
|
|
|
_system->unlockScreen();
|
|
|
|
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut &= ~0x8000;
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
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) {
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut |= 0x8000;
|
2006-04-29 13:38:07 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-03-08 08:45:21 +00:00
|
|
|
restoreBlock(window->x * 8, window->y, (window->x + window->width) * 8, window->y + window->height * 8);
|
2007-05-22 10:31:51 +00:00
|
|
|
} else if (getGameType() == GType_SIMON1) {
|
2009-03-08 08:45:21 +00:00
|
|
|
restoreBlock(window->x * 8, window->y, (window->x + window->width) * 8, window->y + window->height * 8 + ((window == _windowArray[2]) ? 1 : 0));
|
2007-05-22 10:31:51 +00:00
|
|
|
} else {
|
2007-06-21 06:37:00 +00:00
|
|
|
uint16 x = window->x;
|
|
|
|
uint16 w = window->width;
|
2007-06-08 01:47:29 +00:00
|
|
|
|
|
|
|
if (getGameType() == GType_ELVIRA1) {
|
|
|
|
// Adjustments to remove inventory arrows
|
|
|
|
if (x & 1) {
|
|
|
|
x--;
|
|
|
|
w++;
|
|
|
|
}
|
|
|
|
if (w & 1) {
|
|
|
|
w++;
|
|
|
|
}
|
|
|
|
}
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-03-08 08:45:21 +00:00
|
|
|
restoreBlock(x * 8, window->y, (x + w) * 8, window->y + window->height * 8);
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-08 10:08:09 +00:00
|
|
|
_videoLockOut &= ~0x8000;
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-08 08:45:21 +00:00
|
|
|
void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) {
|
2006-04-29 14:11:29 +00:00
|
|
|
byte *dst, *src;
|
|
|
|
uint i;
|
|
|
|
|
2007-06-21 03:14:20 +00:00
|
|
|
Graphics::Surface *screen = _system->lockScreen();
|
2013-08-03 00:36:55 +00:00
|
|
|
dst = (byte *)screen->getPixels();
|
2007-05-09 15:36:05 +00:00
|
|
|
src = getBackGround();
|
2006-04-29 14:11:29 +00:00
|
|
|
|
2009-07-06 06:21:59 +00:00
|
|
|
dst += y * screen->pitch;
|
|
|
|
src += y * _backGroundBuf->pitch;
|
2006-04-29 14:11:29 +00:00
|
|
|
|
2007-06-05 09:14:59 +00:00
|
|
|
uint8 paletteMod = 0;
|
|
|
|
if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && y >= 133)
|
|
|
|
paletteMod = 16;
|
2007-06-05 08:48:30 +00:00
|
|
|
|
2006-04-29 14:11:29 +00:00
|
|
|
while (y < h) {
|
|
|
|
for (i = x; i < w; i++)
|
2007-06-05 08:48:30 +00:00
|
|
|
dst[i] = src[i] + paletteMod;
|
2006-04-29 14:11:29 +00:00
|
|
|
y++;
|
2009-07-06 06:21:59 +00:00
|
|
|
dst += screen->pitch;
|
|
|
|
src += _backGroundBuf->pitch;
|
2006-04-29 14:11:29 +00:00
|
|
|
}
|
2007-06-21 03:14:20 +00:00
|
|
|
|
|
|
|
_system->unlockScreen();
|
2006-04-29 14:11:29 +00:00
|
|
|
}
|
|
|
|
|
2006-11-06 13:59:11 +00:00
|
|
|
void AGOSEngine::setTextColor(uint color) {
|
2007-02-12 11:27:11 +00:00
|
|
|
WindowBlock *window = _windowArray[_curWindow];
|
|
|
|
|
|
|
|
if ((getFeatures() & GF_32COLOR) && color != 0) {
|
2009-02-07 01:11:51 +00:00
|
|
|
if (window->fillColor == 17)
|
2007-02-12 11:27:11 +00:00
|
|
|
color = 25;
|
|
|
|
else
|
2008-03-25 08:03:32 +00:00
|
|
|
color = 220;
|
2007-02-12 11:27:11 +00:00
|
|
|
}
|
2006-11-06 13:59:11 +00:00
|
|
|
|
2009-02-07 01:11:51 +00:00
|
|
|
window->textColor = color;
|
2006-11-06 13:59:11 +00:00
|
|
|
}
|
|
|
|
|
2007-05-22 13:11:06 +00:00
|
|
|
void AGOSEngine::sendWindow(uint a) {
|
2009-03-08 08:45:21 +00:00
|
|
|
if (getGameType() == GType_PN || _textWindow != _windowArray[0]) {
|
2007-05-22 11:31:31 +00:00
|
|
|
if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
|
|
|
|
if (!(_textWindow->flags & 1)) {
|
|
|
|
haltAnimation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 13:38:07 +00:00
|
|
|
windowPutChar(_textWindow, a);
|
2007-05-22 11:31:31 +00:00
|
|
|
}
|
2006-04-29 13:38:07 +00:00
|
|
|
}
|
|
|
|
|
2006-11-15 13:11:53 +00:00
|
|
|
void AGOSEngine::waitWindow(WindowBlock *window) {
|
|
|
|
HitArea *ha;
|
|
|
|
const char *message;
|
|
|
|
|
|
|
|
window->textColumn = (window->width / 2) - 3;
|
|
|
|
window->textRow = window->height - 1;
|
|
|
|
window->textLength = 0;
|
|
|
|
|
|
|
|
message = "[ OK ]";
|
|
|
|
for (; *message; message++)
|
|
|
|
windowPutChar(window, *message);
|
|
|
|
|
|
|
|
ha = findEmptyHitArea();
|
2007-09-19 08:40:12 +00:00
|
|
|
ha->x = (window->width / 2 + window->x - 3) * 8;
|
2007-05-06 09:31:32 +00:00
|
|
|
ha->y = window->height * 8 + window->y - 8;
|
2006-11-15 13:11:53 +00:00
|
|
|
ha->width = 48;
|
|
|
|
ha->height = 8;
|
|
|
|
ha->flags = kBFBoxInUse;
|
|
|
|
ha->id = 0x7FFF;
|
|
|
|
ha->priority = 999;
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
while (!shouldQuit()) {
|
2006-11-15 13:11:53 +00:00
|
|
|
_lastHitArea = NULL;
|
|
|
|
_lastHitArea3 = NULL;
|
|
|
|
|
2008-09-30 12:27:38 +00:00
|
|
|
while (!shouldQuit()) {
|
2006-11-15 13:11:53 +00:00
|
|
|
if (_lastHitArea3 != 0)
|
|
|
|
break;
|
|
|
|
delay(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ha = _lastHitArea;
|
|
|
|
if (ha == NULL) {
|
|
|
|
} else if (ha->id == 0x7FFF) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
undefineBox(0x7FFF);
|
|
|
|
}
|
|
|
|
|
2007-05-07 01:11:10 +00:00
|
|
|
void AGOSEngine::writeChar(WindowBlock *window, int x, int y, int offs, int val) {
|
|
|
|
int chr;
|
|
|
|
|
|
|
|
// Clear background of first digit
|
|
|
|
window->textColumnOffset = offs;
|
2009-02-07 01:11:51 +00:00
|
|
|
window->textColor = 0;
|
2007-05-07 01:11:10 +00:00
|
|
|
windowDrawChar(window, x * 8, y, 129);
|
|
|
|
|
|
|
|
if (val != -1) {
|
|
|
|
// Print first digit
|
|
|
|
chr = val / 10 + 48;
|
2009-02-07 01:11:51 +00:00
|
|
|
window->textColor = 15;
|
2007-05-07 01:11:10 +00:00
|
|
|
windowDrawChar(window, x * 8, y, chr);
|
|
|
|
}
|
|
|
|
|
|
|
|
offs += 6;
|
|
|
|
if (offs >= 7) {
|
|
|
|
offs -= 8;
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear background of second digit
|
|
|
|
window->textColumnOffset = offs;
|
2009-02-07 01:11:51 +00:00
|
|
|
window->textColor = 0;
|
2007-05-07 01:11:10 +00:00
|
|
|
windowDrawChar(window, x * 8, y, 129);
|
|
|
|
|
|
|
|
if (val != -1) {
|
|
|
|
// Print second digit
|
|
|
|
chr = val % 10 + 48;
|
2009-02-07 01:11:51 +00:00
|
|
|
window->textColor = 15;
|
2007-05-07 01:11:10 +00:00
|
|
|
windowDrawChar(window, x * 8, y, chr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|