2010-08-17 09:28:20 +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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Hugo Trilogy source code
|
|
|
|
*
|
|
|
|
* Copyright (c) 1989-1995 David P. Gray
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Display.c - DIB related code for HUGOWIN
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/debug.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
#include "common/system.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2011-01-08 16:56:52 +00:00
|
|
|
#include "graphics/cursorman.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/palette.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
#include "hugo/hugo.h"
|
|
|
|
#include "hugo/display.h"
|
2011-01-08 16:56:52 +00:00
|
|
|
#include "hugo/inventory.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
#include "hugo/util.h"
|
2011-01-29 14:10:47 +00:00
|
|
|
#include "hugo/object.h"
|
2011-02-14 07:31:01 +00:00
|
|
|
#include "hugo/mouse.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
namespace Hugo {
|
2011-02-11 20:27:48 +00:00
|
|
|
/**
|
|
|
|
* A black and white Windows-style arrow cursor (12x20).
|
|
|
|
* 0 = Black (#000000 in 24-bit RGB).
|
|
|
|
* 1 = Transparent.
|
|
|
|
* 15 = White (#FFFFFF in 24-bit RGB).
|
|
|
|
* This cursor comes from Mohawk engine.
|
|
|
|
*/
|
|
|
|
static const byte stdMouseCursor[] = {
|
|
|
|
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 0, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 0, 1, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 0, 1, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 15, 0, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 15, 15, 0, 1, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 15, 15, 15, 0, 1, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 1,
|
|
|
|
0, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0,
|
|
|
|
0, 15, 15, 15, 0, 15, 15, 0, 1, 1, 1, 1,
|
|
|
|
0, 15, 15, 0, 0, 15, 15, 0, 1, 1, 1, 1,
|
|
|
|
0, 15, 0, 1, 0, 0, 15, 15, 0, 1, 1, 1,
|
|
|
|
0, 0, 1, 1, 1, 0, 15, 15, 0, 1, 1, 1,
|
|
|
|
0, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1,
|
|
|
|
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-02-03 18:25:38 +00:00
|
|
|
Screen::Screen(HugoEngine *vm) : _vm(vm) {
|
|
|
|
_mainPalette = 0;
|
|
|
|
_curPalette = 0;
|
2011-02-05 14:07:30 +00:00
|
|
|
_dlAddIndex = 0;
|
|
|
|
_dlRestoreIndex = 0;
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
for (int i = 0; i < kNumFonts; i++) {
|
2010-11-30 20:15:02 +00:00
|
|
|
_arrayFont[i] = 0;
|
|
|
|
fontLoadedFl[i] = false;
|
2010-11-07 00:02:48 +00:00
|
|
|
}
|
2011-02-03 18:25:38 +00:00
|
|
|
for (int i = 0; i < kBlitListSize; i++) {
|
|
|
|
_dlBlistList[i].x = 0;
|
|
|
|
_dlBlistList[i].y = 0;
|
|
|
|
_dlBlistList[i].dx = 0;
|
|
|
|
_dlBlistList[i].dy = 0;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kRectListSize; i++) {
|
|
|
|
_dlAddList[i].x = 0;
|
|
|
|
_dlAddList[i].y = 0;
|
|
|
|
_dlAddList[i].dx = 0;
|
|
|
|
_dlAddList[i].dy = 0;
|
2011-02-05 14:07:30 +00:00
|
|
|
_dlRestoreList[i].x = 0;
|
|
|
|
_dlRestoreList[i].y = 0;
|
|
|
|
_dlRestoreList[i].dx = 0;
|
|
|
|
_dlRestoreList[i].dy = 0;
|
2011-02-03 18:25:38 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-09-12 23:10:31 +00:00
|
|
|
Screen::~Screen() {
|
|
|
|
}
|
|
|
|
|
2011-02-18 21:24:32 +00:00
|
|
|
icondib_t &Screen::getIconBuffer() {
|
|
|
|
return _iconBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewdib_t &Screen::getBackBuffer() {
|
|
|
|
return _backBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewdib_t &Screen::getBackBufferBackup() {
|
|
|
|
return _backBufferBackup;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewdib_t &Screen::getFrontBuffer() {
|
|
|
|
return _frontBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewdib_t &Screen::getGUIBuffer() {
|
|
|
|
return _GUIBuffer;
|
|
|
|
}
|
|
|
|
|
2010-11-30 20:15:02 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Replace the palette by the main palette
|
|
|
|
*/
|
2010-08-17 09:28:20 +00:00
|
|
|
void Screen::createPal() {
|
|
|
|
debugC(1, kDebugDisplay, "createPal");
|
2011-02-20 10:32:00 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(_mainPalette, 0, _paletteSize / 3);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2011-01-08 16:56:52 +00:00
|
|
|
void Screen::setCursorPal() {
|
2011-02-20 10:32:00 +00:00
|
|
|
debugC(1, kDebugDisplay, "setCursorPal");
|
|
|
|
CursorMan.replaceCursorPalette(_curPalette, 0, _paletteSize / 3);
|
2011-01-08 16:56:52 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Create logical palette
|
|
|
|
*/
|
2010-08-17 09:28:20 +00:00
|
|
|
void Screen::initDisplay() {
|
|
|
|
debugC(1, kDebugDisplay, "initDisplay");
|
|
|
|
createPal();
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Move an image from source to destination
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::moveImage(image_pt srcImage, const int16 x1, const int16 y1, const int16 dx, int16 dy, const int16 width1, image_pt dstImage, const int16 x2, const int16 y2, const int16 width2) {
|
2010-10-03 08:08:42 +00:00
|
|
|
debugC(3, kDebugDisplay, "moveImage(srcImage, %d, %d, %d, %d, %d, dstImage, %d, %d, %d)", x1, y1, dx, dy, width1, x2, y2, width2);
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
int16 wrap_src = width1 - dx; // Wrap to next src row
|
|
|
|
int16 wrap_dst = width2 - dx; // Wrap to next dst row
|
|
|
|
|
|
|
|
srcImage += y1 * width1 + x1; // Offset into src image
|
|
|
|
dstImage += y2 * width2 + x2; // offset into dst image
|
|
|
|
|
|
|
|
while (dy--) { // For each row
|
2010-10-03 08:08:42 +00:00
|
|
|
for (int16 x = dx; x--;) // For each column
|
2010-08-17 09:28:20 +00:00
|
|
|
*dstImage++ = *srcImage++;
|
|
|
|
srcImage += wrap_src; // Wrap to next line
|
|
|
|
dstImage += wrap_dst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen::displayBackground() {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(1, kDebugDisplay, "displayBackground()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
g_system->copyRectToScreen(_frontBuffer, 320, 0, 0, 320, 200);
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Blit the supplied rectangle from _frontBuffer to the screen
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::displayRect(const int16 x, const int16 y, const int16 dx, const int16 dy) {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(3, kDebugDisplay, "displayRect(%d, %d, %d, %d)", x, y, dx, dy);
|
|
|
|
|
2011-01-08 17:26:39 +00:00
|
|
|
int16 xClip, yClip;
|
2011-01-29 23:05:12 +00:00
|
|
|
xClip = CLIP<int16>(x, 0, 319);
|
|
|
|
yClip = CLIP<int16>(y, 0, 199);
|
|
|
|
g_system->copyRectToScreen(&_frontBuffer[xClip + yClip * 320], 320, xClip, yClip, CLIP<int16>(dx, 0, 319 - xClip), CLIP<int16>(dy, 0, 199 - yClip));
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Change a color by remapping supplied palette index with new index in main palette.
|
|
|
|
* Alse save the new color in the current palette.
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::remapPal(const uint16 oldIndex, const uint16 newIndex) {
|
2011-02-27 10:10:09 +00:00
|
|
|
debugC(1, kDebugDisplay, "RemapPal(%d, %d)", oldIndex, newIndex);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-02-20 10:32:00 +00:00
|
|
|
_curPalette[3 * oldIndex + 0] = _mainPalette[newIndex * 3 + 0];
|
|
|
|
_curPalette[3 * oldIndex + 1] = _mainPalette[newIndex * 3 + 1];
|
|
|
|
_curPalette[3 * oldIndex + 2] = _mainPalette[newIndex * 3 + 2];
|
2010-11-06 09:59:07 +00:00
|
|
|
|
2011-02-27 10:10:09 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(_curPalette, 0, _paletteSize / 3);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-30 20:15:02 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Saves the current palette in a savegame
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::savePal(Common::WriteStream *f) const {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(1, kDebugDisplay, "savePal()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-11-19 23:49:04 +00:00
|
|
|
for (int i = 0; i < _paletteSize; i++)
|
2010-11-30 20:15:02 +00:00
|
|
|
f->writeByte(_curPalette[i]);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-30 20:15:02 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Restore the current palette from a savegame
|
|
|
|
*/
|
2011-02-18 07:11:55 +00:00
|
|
|
void Screen::restorePal(Common::ReadStream *f) {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(1, kDebugDisplay, "restorePal()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-02-24 18:59:36 +00:00
|
|
|
for (int i = 0; i < _paletteSize; i++)
|
2010-11-30 20:15:02 +00:00
|
|
|
_curPalette[i] = f->readByte();
|
2011-02-24 18:59:36 +00:00
|
|
|
|
|
|
|
g_system->getPaletteManager()->setPalette(_curPalette, 0, _paletteSize / 3);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Set the new background color.
|
|
|
|
* This implementation gives the same result than the DOS version.
|
|
|
|
* It wasn't implemented in the Win version
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::setBackgroundColor(const uint16 color) {
|
|
|
|
debugC(1, kDebugDisplay, "setBackgroundColor(%d)", color);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-12-19 16:07:03 +00:00
|
|
|
remapPal(0, color);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Merge an object frame into _frontBuffer at sx, sy and update rectangle list.
|
|
|
|
* If fore TRUE, force object above any overlay
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::displayFrame(const int sx, const int sy, seq_t *seq, const bool foreFl) {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(3, kDebugDisplay, "displayFrame(%d, %d, seq, %d)", sx, sy, (foreFl) ? 1 : 0);
|
|
|
|
|
2010-10-03 08:08:42 +00:00
|
|
|
image_pt image = seq->imagePtr; // Ptr to object image data
|
2011-01-23 00:05:52 +00:00
|
|
|
image_pt subFrontBuffer = &_frontBuffer[sy * kXPix + sx]; // Ptr to offset in _frontBuffer
|
|
|
|
int16 frontBufferwrap = kXPix - seq->x2 - 1; // Wraps dest_p after each line
|
2010-10-03 08:08:42 +00:00
|
|
|
int16 imageWrap = seq->bytesPerLine8 - seq->x2 - 1;
|
2011-02-27 00:04:49 +00:00
|
|
|
overlayState_t overlayState = (foreFl) ? kOvlForeground : kOvlUndef; // Overlay state of object
|
2010-10-03 08:08:42 +00:00
|
|
|
for (uint16 y = 0; y < seq->lines; y++) { // Each line in object
|
|
|
|
for (uint16 x = 0; x <= seq->x2; x++) {
|
2010-08-17 09:28:20 +00:00
|
|
|
if (*image) { // Non-transparent
|
2011-02-11 07:12:29 +00:00
|
|
|
byte ovlBound = _vm->_object->getFirstOverlay((uint16)(subFrontBuffer - _frontBuffer) >> 3); // Ptr into overlay bits
|
|
|
|
if (ovlBound & (0x80 >> ((uint16)(subFrontBuffer - _frontBuffer) & 7))) { // Overlay bit is set
|
|
|
|
if (overlayState == kOvlUndef) // Overlay defined yet?
|
2010-08-17 09:28:20 +00:00
|
|
|
overlayState = findOvl(seq, subFrontBuffer, y);// No, find it.
|
2011-02-27 00:04:49 +00:00
|
|
|
if (overlayState == kOvlForeground) // Object foreground
|
2010-08-17 09:28:20 +00:00
|
|
|
*subFrontBuffer = *image; // Copy pixel
|
2010-10-03 08:08:42 +00:00
|
|
|
} else { // No overlay
|
2010-08-17 09:28:20 +00:00
|
|
|
*subFrontBuffer = *image; // Copy pixel
|
2010-10-03 08:08:42 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
image++;
|
|
|
|
subFrontBuffer++;
|
|
|
|
}
|
|
|
|
image += imageWrap;
|
|
|
|
subFrontBuffer += frontBufferwrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add this rectangle to the display list
|
2011-01-23 00:05:52 +00:00
|
|
|
displayList(kDisplayAdd, sx, sy, seq->x2 + 1, seq->lines);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Merge rectangles A,B leaving result in B
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::merge(const rect_t *rectA, rect_t *rectB) {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(6, kDebugDisplay, "merge()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
int16 xa = rectA->x + rectA->dx; // Find x2,y2 for each rectangle
|
|
|
|
int16 xb = rectB->x + rectB->dx;
|
|
|
|
int16 ya = rectA->y + rectA->dy;
|
|
|
|
int16 yb = rectB->y + rectB->dy;
|
|
|
|
|
|
|
|
rectB->x = MIN(rectA->x, rectB->x); // Minimum x,y
|
|
|
|
rectB->y = MIN(rectA->y, rectB->y);
|
|
|
|
rectB->dx = MAX(xa, xb) - rectB->x; // Maximum dx,dy
|
|
|
|
rectB->dy = MAX(ya, yb) - rectB->y;
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Coalesce the rectangles in the restore/add list into one unified
|
|
|
|
* blist. len is the sizes of alist or rlist. blen is current length
|
|
|
|
* of blist. bmax is the max size of the blist. Note that blist can
|
|
|
|
* have holes, in which case dx = 0. Returns used length of blist.
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
int16 Screen::mergeLists(rect_t *list, rect_t *blist, const int16 len, int16 blen) {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(4, kDebugDisplay, "mergeLists()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
int16 coalesce[kBlitListSize]; // List of overlapping rects
|
2010-08-17 09:28:20 +00:00
|
|
|
// Process the list
|
|
|
|
for (int16 a = 0; a < len; a++, list++) {
|
|
|
|
// Compile list of overlapping rectangles in blit list
|
|
|
|
int16 c = 0;
|
|
|
|
rect_t *bp = blist;
|
2010-10-03 08:08:42 +00:00
|
|
|
for (int16 b = 0; b < blen; b++, bp++) {
|
2010-08-17 09:28:20 +00:00
|
|
|
if (bp->dx) // blist entry used
|
2011-02-07 16:39:10 +00:00
|
|
|
if (isOverlapping(list, bp))
|
2010-08-17 09:28:20 +00:00
|
|
|
coalesce[c++] = b;
|
2010-10-03 08:08:42 +00:00
|
|
|
}
|
2010-10-25 13:31:01 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
// Any overlapping blit rects?
|
2010-10-03 08:08:42 +00:00
|
|
|
if (c == 0) { // None, add a new entry
|
2010-08-17 09:28:20 +00:00
|
|
|
blist[blen++] = *list;
|
2010-10-03 08:08:42 +00:00
|
|
|
} else { // At least one overlapping
|
2010-08-17 09:28:20 +00:00
|
|
|
// Merge add-list entry with first blist entry
|
|
|
|
bp = &blist[coalesce[0]];
|
|
|
|
merge(list, bp);
|
|
|
|
|
|
|
|
// Merge any more blist entries
|
|
|
|
while (--c) {
|
|
|
|
rect_t *cp = &blist[coalesce[c]];
|
|
|
|
merge(cp, bp);
|
|
|
|
cp->dx = 0; // Delete entry
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return blen;
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Process the display list
|
|
|
|
* Trailing args are int16 x,y,dx,dy for the D_ADD operation
|
|
|
|
*/
|
2010-08-17 09:28:20 +00:00
|
|
|
void Screen::displayList(dupdate_t update, ...) {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(6, kDebugDisplay, "displayList()");
|
2010-10-03 08:08:42 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
int16 blitLength = 0; // Length of blit list
|
|
|
|
va_list marker; // Args used for D_ADD operation
|
2010-10-03 08:08:42 +00:00
|
|
|
rect_t *p; // Ptr to dlist entry
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
switch (update) {
|
2011-01-23 00:05:52 +00:00
|
|
|
case kDisplayInit: // Init lists, restore whole screen
|
2011-02-03 18:25:38 +00:00
|
|
|
_dlAddIndex = _dlRestoreIndex = 0;
|
2010-08-17 09:28:20 +00:00
|
|
|
memcpy(_frontBuffer, _backBuffer, sizeof(_frontBuffer));
|
|
|
|
break;
|
2011-01-23 00:05:52 +00:00
|
|
|
case kDisplayAdd: // Add a rectangle to list
|
2011-02-03 18:25:38 +00:00
|
|
|
if (_dlAddIndex >= kRectListSize) {
|
2010-11-01 20:40:33 +00:00
|
|
|
warning("Display list exceeded");
|
2010-08-17 09:28:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
va_start(marker, update); // Initialize variable arguments
|
2011-02-03 18:25:38 +00:00
|
|
|
p = &_dlAddList[_dlAddIndex];
|
2010-08-17 09:28:20 +00:00
|
|
|
p->x = va_arg(marker, int); // x
|
|
|
|
p->y = va_arg(marker, int); // y
|
|
|
|
p->dx = va_arg(marker, int); // dx
|
|
|
|
p->dy = va_arg(marker, int); // dy
|
|
|
|
va_end(marker); // Reset variable arguments
|
2011-02-03 18:25:38 +00:00
|
|
|
_dlAddIndex++;
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
2011-01-23 00:05:52 +00:00
|
|
|
case kDisplayDisplay: // Display whole list
|
2010-08-17 09:28:20 +00:00
|
|
|
// Don't blit if newscreen just loaded because _frontBuffer will
|
|
|
|
// get blitted via InvalidateRect() at end of this cycle
|
|
|
|
// and blitting here causes objects to appear too soon.
|
2010-10-21 17:09:57 +00:00
|
|
|
if (_vm->getGameStatus().newScreenFl) {
|
|
|
|
_vm->getGameStatus().newScreenFl = false;
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Coalesce restore-list, add-list into combined blit-list
|
2011-02-03 18:25:38 +00:00
|
|
|
blitLength = mergeLists(_dlRestoreList, _dlBlistList, _dlRestoreIndex, blitLength);
|
|
|
|
blitLength = mergeLists(_dlAddList, _dlBlistList, _dlAddIndex, blitLength);
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// Blit the combined blit-list
|
2011-02-03 18:25:38 +00:00
|
|
|
for (_dlRestoreIndex = 0, p = _dlBlistList; _dlRestoreIndex < blitLength; _dlRestoreIndex++, p++) {
|
2010-08-17 09:28:20 +00:00
|
|
|
if (p->dx) // Marks a used entry
|
|
|
|
displayRect(p->x, p->y, p->dx, p->dy);
|
2010-10-03 08:08:42 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
2011-01-23 00:05:52 +00:00
|
|
|
case kDisplayRestore: // Restore each rectangle
|
2011-02-03 18:25:38 +00:00
|
|
|
for (_dlRestoreIndex = 0, p = _dlAddList; _dlRestoreIndex < _dlAddIndex; _dlRestoreIndex++, p++) {
|
2010-08-17 09:28:20 +00:00
|
|
|
// Restoring from _backBuffer to _frontBuffer
|
2011-02-03 18:25:38 +00:00
|
|
|
_dlRestoreList[_dlRestoreIndex] = *p; // Copy add-list to restore-list
|
2011-01-23 00:05:52 +00:00
|
|
|
moveImage(_backBuffer, p->x, p->y, p->dx, p->dy, kXPix, _frontBuffer, p->x, p->y, kXPix);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
2011-02-03 18:25:38 +00:00
|
|
|
_dlAddIndex = 0; // Reset add-list
|
2010-08-17 09:28:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Write supplied character (font data) at sx,sy in supplied color
|
|
|
|
* Font data as follows:
|
|
|
|
* *(fontdata+1) = Font Height (pixels)
|
|
|
|
* *(fontdata+1) = Font Width (pixels)
|
|
|
|
* *(fontdata+x) = Font Bitmap (monochrome)
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::writeChr(const int sx, const int sy, const byte color, const char *local_fontdata){
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(2, kDebugDisplay, "writeChr(%d, %d, %d, %d)", sx, sy, color, local_fontdata[0]);
|
|
|
|
|
|
|
|
byte height = local_fontdata[0];
|
|
|
|
byte width = 8; //local_fontdata[1];
|
|
|
|
|
|
|
|
// This can probably be optimized quite a bit...
|
2010-10-03 08:08:42 +00:00
|
|
|
for (int y = 0; y < height; ++y) {
|
2010-08-17 09:28:20 +00:00
|
|
|
for (int x = 0; x < width; ++x) {
|
|
|
|
int pixel = y * width + x;
|
|
|
|
int bitpos = pixel % 8;
|
|
|
|
int offset = pixel / 8;
|
|
|
|
byte bitTest = (1 << bitpos);
|
|
|
|
if ((local_fontdata[2 + offset] & bitTest) == bitTest)
|
|
|
|
_frontBuffer[(sy + y) * 320 + sx + x] = color;
|
|
|
|
}
|
2010-10-03 08:08:42 +00:00
|
|
|
}
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Returns height of characters in current font
|
|
|
|
*/
|
2011-02-03 18:25:38 +00:00
|
|
|
int16 Screen::fontHeight() const {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(2, kDebugDisplay, "fontHeight()");
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-02-03 18:25:38 +00:00
|
|
|
static const int16 height[kNumFonts] = {5, 7, 8};
|
2011-01-23 00:05:52 +00:00
|
|
|
return height[_fnt - kFirstFont];
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Returns length of supplied string in pixels
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
int16 Screen::stringLength(const char *s) const {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(2, kDebugDisplay, "stringLength(%s)", s);
|
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
byte *const*fontArr = _font[_fnt];
|
2010-10-03 08:08:42 +00:00
|
|
|
int16 sum = 0;
|
|
|
|
for (; *s; s++)
|
2010-08-17 11:42:47 +00:00
|
|
|
sum += *(fontArr[(uint)*s] + 1) + 1;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-10-03 08:08:42 +00:00
|
|
|
return sum;
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Return x which would center supplied string
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
int16 Screen::center(const char *s) const {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(1, kDebugDisplay, "center(%s)", s);
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
return (int16)((kXPix - stringLength(s)) >> 1);
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Write string at sx,sy in supplied color in current font
|
|
|
|
* If sx == CENTER, center it
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::writeStr(int16 sx, const int16 sy, const char *s, const byte color) {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(2, kDebugDisplay, "writeStr(%d, %d, %s, %d)", sx, sy, s, color);
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
if (sx == kCenter)
|
2010-08-17 09:28:20 +00:00
|
|
|
sx = center(s);
|
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
byte *const*font = _font[_fnt];
|
2010-08-17 09:28:20 +00:00
|
|
|
for (; *s; s++) {
|
2010-08-17 11:42:47 +00:00
|
|
|
writeChr(sx, sy, color, (char *)font[(uint)*s]);
|
|
|
|
sx += *(font[(uint)*s] + 1) + 1;
|
2010-08-17 09:28:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Shadowed version of writestr
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::shadowStr(int16 sx, const int16 sy, const char *s, const byte color) {
|
2010-08-17 09:28:20 +00:00
|
|
|
debugC(1, kDebugDisplay, "shadowStr(%d, %d, %s, %d)", sx, sy, s, color);
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
if (sx == kCenter)
|
2010-08-17 09:28:20 +00:00
|
|
|
sx = center(s);
|
|
|
|
|
|
|
|
writeStr(sx + 1, sy + 1, s, _TBLACK);
|
|
|
|
writeStr(sx, sy, s, color);
|
|
|
|
}
|
|
|
|
|
2010-11-30 20:15:02 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Introduce user to the game. In the original games, it was only
|
|
|
|
* present in the DOS versions
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::userHelp() const {
|
2011-03-21 12:07:23 +00:00
|
|
|
Utils::notifyBox(
|
2010-09-14 05:32:20 +00:00
|
|
|
"F1 - Press F1 again\n"
|
|
|
|
" for instructions\n"
|
|
|
|
"F2 - Sound on/off\n"
|
|
|
|
"F3 - Recall last line\n"
|
|
|
|
"F4 - Save game\n"
|
|
|
|
"F5 - Restore game\n"
|
|
|
|
"F6 - Inventory\n"
|
|
|
|
"F8 - Turbo button\n"
|
|
|
|
"F9 - Boss button\n\n"
|
|
|
|
"ESC - Return to game");
|
|
|
|
}
|
|
|
|
|
2010-09-27 20:24:36 +00:00
|
|
|
void Screen::drawStatusText() {
|
2011-01-26 22:50:36 +00:00
|
|
|
debugC(4, kDebugDisplay, "drawStatusText()");
|
2010-09-27 20:24:36 +00:00
|
|
|
|
|
|
|
loadFont(U_FONT8);
|
2010-10-21 17:09:57 +00:00
|
|
|
uint16 sdx = stringLength(_vm->_statusLine);
|
2010-11-30 20:15:02 +00:00
|
|
|
uint16 sdy = fontHeight() + 1; // + 1 for shadow
|
2010-09-27 20:24:36 +00:00
|
|
|
uint16 posX = 0;
|
2011-01-23 00:05:52 +00:00
|
|
|
uint16 posY = kYPix - sdy;
|
2010-09-27 20:24:36 +00:00
|
|
|
|
|
|
|
// Display the string and add rect to display list
|
2010-10-21 17:09:57 +00:00
|
|
|
writeStr(posX, posY, _vm->_statusLine, _TLIGHTYELLOW);
|
2011-01-23 00:05:52 +00:00
|
|
|
displayList(kDisplayAdd, posX, posY, sdx, sdy);
|
2010-09-27 20:24:36 +00:00
|
|
|
|
2010-10-21 17:09:57 +00:00
|
|
|
sdx = stringLength(_vm->_scoreLine);
|
2010-09-27 20:24:36 +00:00
|
|
|
posY = 0;
|
2011-04-24 22:08:39 +00:00
|
|
|
|
|
|
|
//Display a black behind the score line
|
|
|
|
_vm->_screen->drawRectangle(true, 0, 0, kXPix, 8, _TBLACK);
|
2010-10-21 17:09:57 +00:00
|
|
|
writeStr(posX, posY, _vm->_scoreLine, _TCYAN);
|
2011-01-23 00:05:52 +00:00
|
|
|
displayList(kDisplayAdd, posX, posY, sdx, sdy);
|
2010-09-27 20:24:36 +00:00
|
|
|
}
|
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::drawShape(const int x, const int y, const int color1, const int color2) {
|
2011-01-23 00:05:52 +00:00
|
|
|
for (int i = 0; i < kShapeSize; i++) {
|
2010-09-26 11:32:52 +00:00
|
|
|
for (int j = 0; j < i; j++) {
|
2011-01-23 00:05:52 +00:00
|
|
|
_backBuffer[320 * (y + i) + (x + kShapeSize + j - i)] = color1;
|
|
|
|
_frontBuffer[320 * (y + i) + (x + kShapeSize + j - i)] = color1;
|
|
|
|
_backBuffer[320 * (y + i) + (x + kShapeSize + j)] = color2;
|
|
|
|
_frontBuffer[320 * (y + i) + (x + kShapeSize + j)] = color2;
|
|
|
|
_backBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j - i)] = color1;
|
|
|
|
_frontBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j - i)] = color1;
|
|
|
|
_backBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j)] = color2;
|
|
|
|
_frontBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j)] = color2;
|
2010-09-26 11:32:52 +00:00
|
|
|
}
|
2010-10-25 13:31:01 +00:00
|
|
|
}
|
2010-09-26 11:32:52 +00:00
|
|
|
}
|
2011-01-28 19:54:48 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Display rectangle (filles or empty)
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color) {
|
2010-09-26 11:32:52 +00:00
|
|
|
assert(x1 <= x2);
|
|
|
|
assert(y1 <= y2);
|
2011-01-29 23:05:12 +00:00
|
|
|
int16 x2Clip = CLIP<int16>(x2, 0, 320);
|
|
|
|
int16 y2Clip = CLIP<int16>(y2, 0, 200);
|
2010-09-26 11:32:52 +00:00
|
|
|
|
|
|
|
if (filledFl) {
|
2011-01-29 23:05:12 +00:00
|
|
|
for (int i = y1; i < y2Clip; i++) {
|
|
|
|
for (int j = x1; j < x2Clip; j++)
|
2010-09-26 11:32:52 +00:00
|
|
|
_frontBuffer[320 * i + j] = color;
|
2010-10-03 08:08:42 +00:00
|
|
|
}
|
2010-09-26 11:32:52 +00:00
|
|
|
} else {
|
2011-01-29 23:05:12 +00:00
|
|
|
for (int i = y1; i < y2Clip; i++) {
|
2011-01-28 19:54:48 +00:00
|
|
|
_frontBuffer[320 * i + x1] = color;
|
|
|
|
_frontBuffer[320 * i + x2] = color;
|
|
|
|
}
|
2011-01-29 23:05:12 +00:00
|
|
|
for (int i = x1; i < x2Clip; i++) {
|
2011-01-28 19:54:48 +00:00
|
|
|
_frontBuffer[320 * y1 + i] = color;
|
|
|
|
_frontBuffer[320 * y2 + i] = color;
|
|
|
|
}
|
2010-09-26 11:32:52 +00:00
|
|
|
}
|
2010-09-26 11:43:07 +00:00
|
|
|
}
|
2010-09-26 11:32:52 +00:00
|
|
|
|
2010-11-01 20:20:21 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Initialize screen components and display results
|
|
|
|
*/
|
2010-10-15 06:16:27 +00:00
|
|
|
void Screen::initNewScreenDisplay() {
|
2011-01-23 00:05:52 +00:00
|
|
|
displayList(kDisplayInit);
|
2010-10-15 06:16:27 +00:00
|
|
|
setBackgroundColor(_TBLACK);
|
|
|
|
displayBackground();
|
|
|
|
|
|
|
|
// Stop premature object display in Display_list(D_DISPLAY)
|
2010-10-21 17:09:57 +00:00
|
|
|
_vm->getGameStatus().newScreenFl = true;
|
2010-10-15 06:16:27 +00:00
|
|
|
}
|
2010-11-06 13:21:18 +00:00
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Load palette from Hugo.dat
|
|
|
|
*/
|
2011-02-12 16:20:57 +00:00
|
|
|
void Screen::loadPalette(Common::ReadStream &in) {
|
2010-11-06 13:21:18 +00:00
|
|
|
// Read palette
|
|
|
|
_paletteSize = in.readUint16BE();
|
2010-11-30 20:15:02 +00:00
|
|
|
_mainPalette = (byte *)malloc(sizeof(byte) * _paletteSize);
|
|
|
|
_curPalette = (byte *)malloc(sizeof(byte) * _paletteSize);
|
2010-11-06 13:21:18 +00:00
|
|
|
for (int i = 0; i < _paletteSize; i++)
|
2010-11-30 20:15:02 +00:00
|
|
|
_curPalette[i] = _mainPalette[i] = in.readByte();
|
2010-11-06 13:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-15 18:30:15 +00:00
|
|
|
* Free fonts, main and current palettes
|
2011-02-11 20:27:48 +00:00
|
|
|
*/
|
2011-02-15 18:30:15 +00:00
|
|
|
void Screen::freeScreen() {
|
2010-11-30 20:15:02 +00:00
|
|
|
free(_curPalette);
|
|
|
|
free(_mainPalette);
|
2010-11-06 13:21:18 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
for (int i = 0; i < kNumFonts; i++) {
|
2010-11-07 00:02:48 +00:00
|
|
|
if (_arrayFont[i])
|
|
|
|
free(_arrayFont[i]);
|
|
|
|
}
|
|
|
|
}
|
2011-01-08 16:56:52 +00:00
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen::selectInventoryObjId(const int16 objId) {
|
2011-01-08 16:56:52 +00:00
|
|
|
|
2011-02-08 20:52:26 +00:00
|
|
|
_vm->_inventory->setInventoryObjId(objId); // Select new object
|
2011-01-08 16:56:52 +00:00
|
|
|
|
|
|
|
// Find index of icon
|
2011-02-15 09:15:21 +00:00
|
|
|
int16 iconId = _vm->_inventory->findIconId(objId);
|
2011-01-08 16:56:52 +00:00
|
|
|
|
|
|
|
// Compute source coordinates in dib_u
|
2011-01-23 00:05:52 +00:00
|
|
|
int16 ux = (iconId + kArrowNumb) * kInvDx % kXPix;
|
|
|
|
int16 uy = (iconId + kArrowNumb) * kInvDx / kXPix * kInvDy;
|
2011-01-08 16:56:52 +00:00
|
|
|
|
|
|
|
// Copy the icon and add to display list
|
2011-01-23 00:05:52 +00:00
|
|
|
moveImage(getGUIBuffer(), ux, uy, kInvDx, kInvDy, kXPix, _iconImage, 0, 0, 32);
|
2011-01-08 16:56:52 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < stdMouseCursorHeight; i++) {
|
|
|
|
for (int j = 0; j < stdMouseCursorWidth; j++) {
|
2011-01-23 00:05:52 +00:00
|
|
|
_iconImage[(i * kInvDx) + j] = (stdMouseCursor[(i * stdMouseCursorWidth) + j] == 1) ? _iconImage[(i * kInvDx) + j] : stdMouseCursor[(i * stdMouseCursorWidth) + j];
|
2011-01-08 16:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
CursorMan.replaceCursor(_iconImage, kInvDx, kInvDy, 1, 1, 1);
|
2011-01-08 16:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Screen::resetInventoryObjId() {
|
2011-02-08 20:52:26 +00:00
|
|
|
_vm->_inventory->setInventoryObjId(-1); // Unselect object
|
2011-01-08 16:56:52 +00:00
|
|
|
CursorMan.replaceCursor(stdMouseCursor, stdMouseCursorWidth, stdMouseCursorHeight, 1, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen::showCursor() {
|
|
|
|
CursorMan.showMouse(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen::hideCursor() {
|
|
|
|
CursorMan.showMouse(false);
|
|
|
|
}
|
2011-01-20 22:50:50 +00:00
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
bool Screen::isInX(const int16 x, const rect_t *rect) const {
|
2011-01-23 22:51:12 +00:00
|
|
|
return (x >= rect->x) && (x <= rect->x + rect->dx);
|
|
|
|
}
|
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
bool Screen::isInY(const int16 y, const rect_t *rect) const {
|
2011-01-23 22:51:12 +00:00
|
|
|
return (y >= rect->y) && (y <= rect->y + rect->dy);
|
|
|
|
}
|
|
|
|
|
2011-01-28 19:54:48 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Check if two rectangles are overlapping
|
|
|
|
*/
|
2011-02-07 16:39:10 +00:00
|
|
|
bool Screen::isOverlapping(const rect_t *rectA, const rect_t *rectB) const {
|
2011-02-18 21:43:38 +00:00
|
|
|
return (isInX(rectA->x, rectB) || isInX(rectA->x + rectA->dx, rectB) || isInX(rectB->x, rectA) || isInX(rectB->x + rectB->dx, rectA)) &&
|
2011-01-23 22:51:12 +00:00
|
|
|
(isInY(rectA->y, rectB) || isInY(rectA->y + rectA->dy, rectB) || isInY(rectB->y, rectA) || isInY(rectB->y + rectB->dy, rectA));
|
|
|
|
}
|
|
|
|
|
2011-01-28 19:54:48 +00:00
|
|
|
/**
|
2011-02-14 07:31:01 +00:00
|
|
|
* Display active boundaries in God Mode ('PPG')
|
2011-02-11 20:27:48 +00:00
|
|
|
* Light Red = Exit hotspots
|
|
|
|
* Light Green = Visible objects
|
|
|
|
* White = Fixed objects, parts of background
|
|
|
|
*/
|
2011-02-14 07:31:01 +00:00
|
|
|
void Screen::drawBoundaries() {
|
2011-01-28 19:54:48 +00:00
|
|
|
if (!_vm->getGameStatus().godModeFl)
|
|
|
|
return;
|
|
|
|
|
2011-02-14 07:31:01 +00:00
|
|
|
_vm->_mouse->drawHotspots();
|
2011-01-29 14:10:47 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < _vm->_object->_numObj; i++) {
|
|
|
|
object_t *obj = &_vm->_object->_objects[i]; // Get pointer to object
|
|
|
|
if (obj->screenIndex == *_vm->_screen_p) {
|
|
|
|
if ((obj->currImagePtr != 0) && (obj->cycling != kCycleInvisible))
|
2011-02-18 21:43:38 +00:00
|
|
|
drawRectangle(false, obj->x + obj->currImagePtr->x1, obj->y + obj->currImagePtr->y1,
|
2011-01-29 14:10:47 +00:00
|
|
|
obj->x + obj->currImagePtr->x2, obj->y + obj->currImagePtr->y2, _TLIGHTGREEN);
|
|
|
|
else if ((obj->currImagePtr == 0) && (obj->vxPath != 0) && !obj->carriedFl)
|
|
|
|
drawRectangle(false, obj->oldx, obj->oldy, obj->oldx + obj->vxPath, obj->oldy + obj->vyPath, _TBRIGHTWHITE);
|
|
|
|
}
|
|
|
|
}
|
2011-01-28 19:54:48 +00:00
|
|
|
g_system->copyRectToScreen(_frontBuffer, 320, 0, 0, 320, 200);
|
|
|
|
}
|
|
|
|
|
2011-01-20 22:50:50 +00:00
|
|
|
Screen_v1d::Screen_v1d(HugoEngine *vm) : Screen(vm) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Screen_v1d::~Screen_v1d() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Load font file, construct font ptrs and reverse data bytes
|
|
|
|
* TODO: This uses hardcoded fonts in hugo.dat, it should be replaced
|
|
|
|
* by a proper implementation of .FON files
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen_v1d::loadFont(const int16 fontId) {
|
2011-01-20 22:50:50 +00:00
|
|
|
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
assert(fontId < kNumFonts);
|
2011-01-20 22:50:50 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
_fnt = fontId - kFirstFont; // Set current font number
|
2011-01-20 22:50:50 +00:00
|
|
|
|
|
|
|
if (fontLoadedFl[_fnt]) // If already loaded, return
|
|
|
|
return;
|
|
|
|
|
|
|
|
fontLoadedFl[_fnt] = true;
|
|
|
|
|
|
|
|
memcpy(_fontdata[_fnt], _arrayFont[_fnt], _arrayFontSize[_fnt]);
|
|
|
|
_font[_fnt][0] = _fontdata[_fnt]; // Store height,width of fonts
|
|
|
|
|
|
|
|
int16 offset = 2; // Start at fontdata[2] ([0],[1] used for height,width)
|
|
|
|
|
|
|
|
// Setup the font array (127 characters)
|
|
|
|
for (int i = 1; i < 128; i++) {
|
|
|
|
_font[_fnt][i] = _fontdata[_fnt] + offset;
|
|
|
|
byte height = *(_fontdata[_fnt] + offset);
|
|
|
|
byte width = *(_fontdata[_fnt] + offset + 1);
|
|
|
|
|
|
|
|
int16 size = height * ((width + 7) >> 3);
|
|
|
|
for (int j = 0; j < size; j++)
|
|
|
|
Utils::reverseByte(&_fontdata[_fnt][offset + 2 + j]);
|
|
|
|
|
|
|
|
offset += 2 + size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Load fonts from Hugo.dat
|
|
|
|
* These fonts are a workaround to avoid handling TTF fonts used by DOS versions
|
|
|
|
* TODO: Get rid of this function when the win1 fonts are supported
|
|
|
|
*/
|
2011-02-12 16:20:57 +00:00
|
|
|
void Screen_v1d::loadFontArr(Common::ReadStream &in) {
|
2011-01-23 00:05:52 +00:00
|
|
|
for (int i = 0; i < kNumFonts; i++) {
|
2011-01-20 22:50:50 +00:00
|
|
|
_arrayFontSize[i] = in.readUint16BE();
|
|
|
|
_arrayFont[i] = (byte *)malloc(sizeof(byte) * _arrayFontSize[i]);
|
|
|
|
for (int j = 0; j < _arrayFontSize[i]; j++) {
|
|
|
|
_arrayFont[i][j] = in.readByte();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-26 13:06:30 +00:00
|
|
|
/**
|
|
|
|
* Return the overlay state (Foreground/Background) of the currently
|
|
|
|
* processed object by looking down the current column for an overlay
|
|
|
|
* base byte set (in which case the object is foreground).
|
|
|
|
*/
|
|
|
|
overlayState_t Screen_v1d::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) {
|
|
|
|
debugC(4, kDebugDisplay, "findOvl()");
|
|
|
|
|
2011-02-27 00:04:49 +00:00
|
|
|
uint16 index = (uint16)(dst_p - _frontBuffer) >> 3;
|
|
|
|
|
|
|
|
for (int i = 0; i < seq_p->lines-y; i++) { // Each line in object
|
|
|
|
if (_vm->_object->getBaseBoundary(index)) // If any overlay base byte is non-zero then the object is foreground, else back.
|
2011-02-26 13:06:30 +00:00
|
|
|
return kOvlForeground;
|
2011-02-27 00:04:49 +00:00
|
|
|
index += kCompLineSize;
|
2011-02-26 13:06:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return kOvlBackground; // No bits set, must be background
|
|
|
|
}
|
|
|
|
|
2011-01-20 22:50:50 +00:00
|
|
|
Screen_v1w::Screen_v1w(HugoEngine *vm) : Screen(vm) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Screen_v1w::~Screen_v1w() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Load font file, construct font ptrs and reverse data bytes
|
|
|
|
*/
|
2011-02-02 21:12:51 +00:00
|
|
|
void Screen_v1w::loadFont(const int16 fontId) {
|
2011-01-20 22:50:50 +00:00
|
|
|
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
_fnt = fontId - kFirstFont; // Set current font number
|
2011-01-20 22:50:50 +00:00
|
|
|
|
|
|
|
if (fontLoadedFl[_fnt]) // If already loaded, return
|
|
|
|
return;
|
|
|
|
|
|
|
|
fontLoadedFl[_fnt] = true;
|
|
|
|
_vm->_file->readUIFItem(fontId, _fontdata[_fnt]);
|
|
|
|
|
|
|
|
// Compile font ptrs. Note: First ptr points to height,width of font
|
|
|
|
_font[_fnt][0] = _fontdata[_fnt]; // Store height,width of fonts
|
|
|
|
|
|
|
|
int16 offset = 2; // Start at fontdata[2] ([0],[1] used for height,width)
|
|
|
|
|
|
|
|
// Setup the font array (127 characters)
|
|
|
|
for (int i = 1; i < 128; i++) {
|
|
|
|
_font[_fnt][i] = _fontdata[_fnt] + offset;
|
|
|
|
byte height = *(_fontdata[_fnt] + offset);
|
|
|
|
byte width = *(_fontdata[_fnt] + offset + 1);
|
|
|
|
|
|
|
|
int16 size = height * ((width + 7) >> 3);
|
|
|
|
for (int j = 0; j < size; j++)
|
|
|
|
Utils::reverseByte(&_fontdata[_fnt][offset + 2 + j]);
|
|
|
|
|
|
|
|
offset += 2 + size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Skips the fonts used by the DOS versions
|
|
|
|
*/
|
2011-02-12 16:20:57 +00:00
|
|
|
void Screen_v1w::loadFontArr(Common::ReadStream &in) {
|
2011-01-23 00:05:52 +00:00
|
|
|
for (int i = 0; i < kNumFonts; i++) {
|
2011-01-20 22:50:50 +00:00
|
|
|
uint16 numElem = in.readUint16BE();
|
|
|
|
for (int j = 0; j < numElem; j++)
|
|
|
|
in.readByte();
|
|
|
|
}
|
|
|
|
}
|
2011-01-23 22:51:12 +00:00
|
|
|
|
2011-02-26 13:06:30 +00:00
|
|
|
/**
|
|
|
|
* Return the overlay state (Foreground/Background) of the currently
|
|
|
|
* processed object by looking down the current column for an overlay
|
|
|
|
* base bit set (in which case the object is foreground).
|
|
|
|
*/
|
|
|
|
overlayState_t Screen_v1w::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) {
|
|
|
|
debugC(4, kDebugDisplay, "findOvl()");
|
|
|
|
|
|
|
|
for (; y < seq_p->lines; y++) { // Each line in object
|
|
|
|
byte ovb = _vm->_object->getBaseBoundary((uint16)(dst_p - _frontBuffer) >> 3); // Ptr into overlay bits
|
|
|
|
if (ovb & (0x80 >> ((uint16)(dst_p - _frontBuffer) & 7))) // Overlay bit is set
|
|
|
|
return kOvlForeground; // Found a bit - must be foreground
|
|
|
|
dst_p += kXPix;
|
|
|
|
}
|
|
|
|
|
|
|
|
return kOvlBackground; // No bits set, must be background
|
|
|
|
}
|
|
|
|
|
2010-08-27 09:48:53 +00:00
|
|
|
} // End of namespace Hugo
|
2010-09-12 22:59:32 +00:00
|
|
|
|