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.
|
2007-01-14 21:29:12 +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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-04-07 10:02:59 +00:00
|
|
|
#include "common/stdafx.h"
|
|
|
|
#include "common/system.h"
|
2007-01-14 21:29:12 +00:00
|
|
|
#include "common/file.h"
|
|
|
|
|
|
|
|
#include "parallaction/parallaction.h"
|
2007-05-13 14:38:05 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
namespace Parallaction {
|
2007-05-13 14:56:44 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
#define BALLOON_TAIL_WIDTH 12
|
|
|
|
#define BALLOON_TAIL_HEIGHT 10
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 15:40:12 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
byte _resBalloonTail[2][BALLOON_TAIL_WIDTH*BALLOON_TAIL_HEIGHT] = {
|
2007-01-14 21:29:12 +00:00
|
|
|
{
|
|
|
|
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
|
|
|
|
0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02,
|
|
|
|
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02,
|
|
|
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x02, 0x02
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-13 19:59:45 +00:00
|
|
|
void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) {
|
2007-03-12 20:41:25 +00:00
|
|
|
// printf("Gfx::drawBalloon(%i, %i, %i, %i, %i)...", left, top, width, height, winding);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
Common::Rect q = r;
|
|
|
|
|
2007-08-06 15:40:12 +00:00
|
|
|
// draws balloon
|
2007-03-13 23:30:36 +00:00
|
|
|
q.right += 5;
|
|
|
|
floodFill(kBitFront, q, 0);
|
2007-08-06 15:40:12 +00:00
|
|
|
q.grow(-1);
|
2007-03-13 23:30:36 +00:00
|
|
|
floodFill(kBitFront, q, 1);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 15:40:12 +00:00
|
|
|
// draws tail
|
|
|
|
// TODO: this bitmap tail should only be used for Dos games. Amiga should use a polygon fill.
|
2007-01-14 21:29:12 +00:00
|
|
|
winding = (winding == 0 ? 1 : 0);
|
2007-08-06 15:40:12 +00:00
|
|
|
byte *s = _resBalloonTail[winding];
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d = (byte*)_buffers[kBitFront]->getBasePtr(r.left + (r.width()+5)/2 - 5, r.bottom - 1);
|
2007-08-06 19:19:59 +00:00
|
|
|
uint pitch = _vm->_screenWidth - BALLOON_TAIL_WIDTH;
|
|
|
|
for (uint16 i = 0; i < BALLOON_TAIL_HEIGHT; i++) {
|
|
|
|
for (uint16 j = 0; j < BALLOON_TAIL_WIDTH; j++) {
|
|
|
|
if (*s != 2)
|
|
|
|
*d = *s;
|
2007-01-14 21:29:12 +00:00
|
|
|
d++;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
d += pitch;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// printf("done\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
void Gfx::setPalette(Palette pal, uint32 first, uint32 num) {
|
|
|
|
// printf("setPalette(%i, %i)\n", first, num);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
if (first + num > BASE_PALETTE_COLORS)
|
2007-03-28 20:12:00 +00:00
|
|
|
error("wrong parameters for setPalette()");
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
byte sysBasePal[EHB_PALETTE_COLORS*4];
|
|
|
|
byte sysExtraPal[BASE_PALETTE_COLORS*4];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
byte r, g, b;
|
|
|
|
uint32 j = 0;
|
2007-03-28 20:12:00 +00:00
|
|
|
for (uint32 i = first; i < first+num; i++) {
|
2007-04-21 12:51:40 +00:00
|
|
|
r = (pal[i*3] << 2) | (pal[i*3] >> 4);
|
|
|
|
g = (pal[i*3+1] << 2) | (pal[i*3+1] >> 4);
|
|
|
|
b = (pal[i*3+2] << 2) | (pal[i*3+2] >> 4);
|
|
|
|
|
|
|
|
sysBasePal[j*4] = r;
|
|
|
|
sysBasePal[j*4+1] = g;
|
|
|
|
sysBasePal[j*4+2] = b;
|
|
|
|
sysBasePal[j*4+3] = 0;
|
|
|
|
|
|
|
|
if (_vm->getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
sysExtraPal[j*4] = r >> 1;
|
|
|
|
sysExtraPal[j*4+1] = g >> 1;
|
|
|
|
sysExtraPal[j*4+2] = b >> 1;
|
|
|
|
sysExtraPal[j*4+3] = 0;
|
|
|
|
} else {
|
|
|
|
sysExtraPal[j*4] = 0;
|
|
|
|
sysExtraPal[j*4+1] = 0;
|
|
|
|
sysExtraPal[j*4+2] = 0;
|
|
|
|
sysExtraPal[j*4+3] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
j++;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
g_system->setPalette(sysBasePal, first, num);
|
|
|
|
|
|
|
|
if (_vm->getPlatform() == Common::kPlatformAmiga)
|
|
|
|
g_system->setPalette(sysExtraPal, first+FIRST_EHB_COLOR, num);
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
void Gfx::setBlackPalette() {
|
|
|
|
Palette pal;
|
|
|
|
memset(pal, 0, PALETTE_SIZE);
|
|
|
|
setPalette(pal);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
void Gfx::animatePalette() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
byte tmp[3];
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < 4; i++) {
|
|
|
|
|
|
|
|
if ((_palettefx[i]._flags & 1) == 0) continue; // animated palette
|
|
|
|
|
|
|
|
_palettefx[i]._timer += _palettefx[i]._step * 2; // update timer
|
|
|
|
|
|
|
|
if (_palettefx[i]._timer < 0x4000) continue; // check timeout
|
|
|
|
|
|
|
|
_palettefx[i]._timer = 0; // reset timer
|
|
|
|
|
|
|
|
if (_palettefx[i]._flags & 2) { // forward
|
|
|
|
|
|
|
|
tmp[0] = _palette[_palettefx[i]._first * 3];
|
|
|
|
tmp[1] = _palette[_palettefx[i]._first * 3 + 1];
|
|
|
|
tmp[2] = _palette[_palettefx[i]._first * 3 + 2];
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
memmove(_palette+_palettefx[i]._first*3, _palette+(_palettefx[i]._first+1)*3, (_palettefx[i]._last - _palettefx[i]._first)*3);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
_palette[_palettefx[i]._last * 3] = tmp[0];
|
|
|
|
_palette[_palettefx[i]._last * 3 + 1] = tmp[1];
|
|
|
|
_palette[_palettefx[i]._last * 3 + 2] = tmp[2];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
} else { // backward
|
|
|
|
|
|
|
|
tmp[0] = _palette[_palettefx[i]._last * 3];
|
|
|
|
tmp[1] = _palette[_palettefx[i]._last * 3 + 1];
|
|
|
|
tmp[2] = _palette[_palettefx[i]._last * 3 + 2];
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
memmove(_palette+(_palettefx[i]._first+1)*3, _palette+_palettefx[i]._first*3, (_palettefx[i]._last - _palettefx[i]._first)*3);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
_palette[_palettefx[i]._first * 3] = tmp[0];
|
|
|
|
_palette[_palettefx[i]._first * 3 + 1] = tmp[1];
|
|
|
|
_palette[_palettefx[i]._first * 3 + 2] = tmp[2];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
setPalette(_palette);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-31 19:12:44 +00:00
|
|
|
void Gfx::makeGrayscalePalette(Palette pal) {
|
2007-03-28 20:12:00 +00:00
|
|
|
|
|
|
|
for (uint16 i = 0; i < BASE_PALETTE_COLORS; i++) {
|
|
|
|
byte max;
|
|
|
|
|
|
|
|
max = MAX(_palette[i*3+1], _palette[i*3+2]);
|
|
|
|
max = MAX(max, _palette[i*3]);
|
|
|
|
|
|
|
|
pal[i*3] = max;
|
|
|
|
pal[i*3+1] = max;
|
|
|
|
pal[i*3+2] = max;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-31 19:25:07 +00:00
|
|
|
void Gfx::fadePalette(Palette pal, Palette target, uint step) {
|
|
|
|
|
|
|
|
if (step == 0)
|
|
|
|
return;
|
2007-03-28 20:12:00 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) {
|
2007-07-31 19:25:07 +00:00
|
|
|
if (pal[i] == target[i]) continue;
|
|
|
|
|
|
|
|
if (pal[i] < target[i])
|
|
|
|
pal[i] = CLIP(pal[i] + step, (uint)0, (uint)target[i]);
|
|
|
|
else
|
|
|
|
pal[i] = CLIP(pal[i] - step, (uint)target[i], (uint)255);
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
void Gfx::setHalfbriteMode(bool enable) {
|
2007-05-20 16:13:16 +00:00
|
|
|
#ifdef HALFBRITE
|
2007-04-21 12:51:40 +00:00
|
|
|
if (_vm->getPlatform() != Common::kPlatformAmiga) return;
|
|
|
|
if (enable == _halfbrite) return;
|
2007-03-28 20:12:00 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
byte *buf = _buffers[kBitBack];
|
|
|
|
for (uint32 i = 0; i < SCREEN_SIZE; i++)
|
|
|
|
*buf++ ^= 0x20;
|
2007-03-28 20:12:00 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
buf = _buffers[kBitFront];
|
|
|
|
for (uint32 i = 0; i < SCREEN_SIZE; i++)
|
|
|
|
*buf++ ^= 0x20;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
_halfbrite = !_halfbrite;
|
2007-05-20 16:13:16 +00:00
|
|
|
#endif
|
2007-04-21 12:51:40 +00:00
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::updateScreen() {
|
2007-08-06 13:22:21 +00:00
|
|
|
g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
|
2007-01-14 21:29:12 +00:00
|
|
|
g_system->updateScreen();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::swapBuffers() {
|
2007-08-06 13:22:21 +00:00
|
|
|
Graphics::Surface *temp = _buffers[kBitFront];
|
2007-01-14 21:29:12 +00:00
|
|
|
_buffers[kBitFront] = _buffers[kBitBack];
|
|
|
|
_buffers[kBitBack] = temp;
|
|
|
|
updateScreen();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// graphic primitives
|
|
|
|
//
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::clearScreen(Gfx::Buffers buffer) {
|
2007-08-06 13:22:21 +00:00
|
|
|
memset(_buffers[buffer]->pixels, 0, _vm->_screenSize);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (buffer == kBitFront) updateScreen();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) {
|
2007-08-06 13:22:21 +00:00
|
|
|
memcpy(_buffers[dstbuffer]->pixels, _buffers[srcbuffer]->pixels, _vm->_screenSize);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
void Gfx::floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d = (byte*)_buffers[buffer]->getBasePtr(r.left, r.top);
|
2007-03-13 23:30:36 +00:00
|
|
|
uint16 w = r.width() + 1;
|
|
|
|
uint16 h = r.height() + 1;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
for (uint16 i = 0; i < h; i++) {
|
|
|
|
memset(d, color, w);
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
d += _vm->_screenWidth;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
void Gfx::screenClip(Common::Rect& r, Common::Point& p) {
|
2007-03-14 21:53:34 +00:00
|
|
|
|
|
|
|
int32 x = r.left;
|
|
|
|
int32 y = r.top;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
Common::Rect screen(0, 0, _vm->_screenWidth, _vm->_screenHeight);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
r.clip(screen);
|
|
|
|
|
|
|
|
if (!r.isValidRect()) return;
|
|
|
|
|
|
|
|
p.x = r.left;
|
|
|
|
p.y = r.top;
|
|
|
|
|
|
|
|
r.translate(screen.left - x, screen.top - y);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
Common::Point dp;
|
|
|
|
Common::Rect q(r);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
screenClip(q, dp);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
byte *s = data + q.left + q.top * r.width();
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
uint sPitch = r.width() - q.width();
|
|
|
|
uint dPitch = _vm->_screenWidth - q.width();
|
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
for (uint16 i = q.top; i < q.bottom; i++) {
|
|
|
|
for (uint16 j = q.left; j < q.right; j++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
if (*s != 0) *d = *s;
|
|
|
|
s++;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
s += sPitch;
|
|
|
|
d += dPitch;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:57:07 +00:00
|
|
|
void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
Common::Point dp;
|
2007-03-14 21:09:56 +00:00
|
|
|
Common::Rect q(r);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
screenClip(q, dp);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
byte *s = data + q.left + q.top * r.width();
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
uint sPitch = r.width() - q.width();
|
|
|
|
uint dPitch = _vm->_screenWidth - q.width();
|
|
|
|
|
2007-08-06 19:13:51 +00:00
|
|
|
for (uint16 i = 0; i < q.height(); i++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:13:51 +00:00
|
|
|
for (uint16 j = 0; j < q.width(); j++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
if (*s != 0) {
|
2007-08-06 19:13:51 +00:00
|
|
|
byte v = _depthMask->getValue(dp.x + j, dp.y + i);
|
2007-01-14 21:29:12 +00:00
|
|
|
if (z >= v) *d = *s;
|
|
|
|
}
|
|
|
|
|
|
|
|
s++;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
s += sPitch;
|
|
|
|
d += dPitch;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void jobDisplayLabel(void *parm, Job *j) {
|
|
|
|
|
2007-03-17 20:51:13 +00:00
|
|
|
Label *label = (Label*)parm;
|
2007-05-13 12:41:42 +00:00
|
|
|
debugC(9, kDebugJobs, "jobDisplayLabel (%p)", (const void*) label);
|
2007-02-04 08:12:33 +00:00
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
if (label->_cnv._width == 0)
|
|
|
|
return;
|
2007-03-18 17:12:48 +00:00
|
|
|
_vm->_gfx->flatBlitCnv(&label->_cnv, _vm->_gfx->_labelPosition[0].x, _vm->_gfx->_labelPosition[0].y, Gfx::kBitBack);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void jobEraseLabel(void *parm, Job *j) {
|
2007-03-17 20:51:13 +00:00
|
|
|
Label *label = (Label*)parm;
|
2007-02-04 08:12:33 +00:00
|
|
|
|
2007-05-13 12:41:42 +00:00
|
|
|
debugC(9, kDebugJobs, "jobEraseLabel (%p)", (const void*) label);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
int16 _si, _di;
|
|
|
|
|
|
|
|
if (_vm->_activeItem._id != 0) {
|
2007-03-18 17:22:07 +00:00
|
|
|
_si = _vm->_mousePos.x + 16 - label->_cnv._width/2;
|
|
|
|
_di = _vm->_mousePos.y + 34;
|
2007-01-14 21:29:12 +00:00
|
|
|
} else {
|
2007-03-18 17:22:07 +00:00
|
|
|
_si = _vm->_mousePos.x + 8 - label->_cnv._width/2;
|
|
|
|
_di = _vm->_mousePos.y + 21;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_si < 0) _si = 0;
|
|
|
|
if (_di > 190) _di = 190;
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
if (label->_cnv._width + _si > _vm->_screenWidth)
|
|
|
|
_si = _vm->_screenWidth - label->_cnv._width;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 19:59:45 +00:00
|
|
|
Common::Rect r(label->_cnv._width, label->_cnv._height);
|
2007-03-18 17:12:48 +00:00
|
|
|
r.moveTo(_vm->_gfx->_labelPosition[1]);
|
2007-03-13 19:59:45 +00:00
|
|
|
_vm->_gfx->restoreBackground(r);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 17:12:48 +00:00
|
|
|
_vm->_gfx->_labelPosition[1] = _vm->_gfx->_labelPosition[0];
|
|
|
|
_vm->_gfx->_labelPosition[0].x = _si;
|
|
|
|
_vm->_gfx->_labelPosition[0].y = _di;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::initMouse(uint16 arg_0) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 10:30:51 +00:00
|
|
|
_mouseComposedArrow = _vm->_disk->loadPointer();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-09 19:19:56 +00:00
|
|
|
byte temp[MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT];
|
|
|
|
memcpy(temp, _mouseArrow, MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
uint16 k = 0;
|
|
|
|
for (uint16 i = 0; i < 4; i++) {
|
|
|
|
for (uint16 j = 0; j < 64; j++) _mouseArrow[k++] = temp[i + j * 4];
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-09 19:19:56 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::setMousePointer(int16 index) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (index == kCursorArrow) { // standard mouse pointer
|
|
|
|
|
2007-07-09 19:19:56 +00:00
|
|
|
g_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0);
|
2007-01-14 21:29:12 +00:00
|
|
|
g_system->showMouse(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// inventory item pointer
|
2007-03-18 10:30:51 +00:00
|
|
|
byte *v8 = _mouseComposedArrow->_data0;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-09 19:19:56 +00:00
|
|
|
// FIXME: destination offseting is not clear
|
|
|
|
byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index));
|
|
|
|
byte* d = v8 + 7 + MOUSECOMBO_WIDTH * 7;
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) {
|
|
|
|
memcpy(d, s, INVENTORYITEM_WIDTH);
|
|
|
|
|
|
|
|
s += INVENTORYITEM_PITCH;
|
|
|
|
d += MOUSECOMBO_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cnv management
|
|
|
|
//
|
2007-07-01 19:28:32 +00:00
|
|
|
void Gfx::flatBlitCnv(Cnv *cnv, uint16 frame, int16 x, int16 y, Gfx::Buffers buffer) {
|
|
|
|
|
|
|
|
StaticCnv scnv;
|
|
|
|
|
|
|
|
scnv._width = cnv->_width;
|
|
|
|
scnv._height = cnv->_height;
|
|
|
|
scnv._data0 = cnv->getFramePtr(frame);
|
2007-08-06 19:19:59 +00:00
|
|
|
scnv._data1 = NULL; // ->field_8[v60->_mood & 0xF];
|
2007-07-01 19:28:32 +00:00
|
|
|
|
|
|
|
flatBlitCnv(&scnv, x, y, buffer);
|
|
|
|
}
|
|
|
|
|
2007-03-18 09:16:12 +00:00
|
|
|
void Gfx::flatBlitCnv(StaticCnv *cnv, int16 x, int16 y, Gfx::Buffers buffer) {
|
2007-03-14 21:09:56 +00:00
|
|
|
Common::Rect r(cnv->_width, cnv->_height);
|
|
|
|
r.moveTo(x, y);
|
|
|
|
|
|
|
|
flatBlit(r, cnv->_data0, buffer);
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-14 21:57:07 +00:00
|
|
|
void Gfx::blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffer) {
|
2007-03-14 21:09:56 +00:00
|
|
|
Common::Rect r(cnv->_width, cnv->_height);
|
|
|
|
r.moveTo(x, y);
|
|
|
|
|
2007-03-14 21:57:07 +00:00
|
|
|
blit(r, z, cnv->_data0, buffer);
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *s = (byte*)_buffers[kBit2]->getBasePtr(x, y);
|
2007-03-12 19:58:10 +00:00
|
|
|
byte *d = data->_background;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 21:00:22 +00:00
|
|
|
for (uint16 i = 0; i < data->_cnv->_height ; i++) {
|
|
|
|
memcpy(d, s, data->_cnv->_width);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
s += _vm->_screenWidth;
|
2007-03-18 21:00:22 +00:00
|
|
|
d += data->_cnv->_width;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 21:15:39 +00:00
|
|
|
byte *t = data->_cnv->_data0;
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *s = (byte*)_buffers[kBitBack]->getBasePtr(x, y);
|
2007-03-12 19:58:10 +00:00
|
|
|
byte *d = data->_backup;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
uint pitch = _vm->_screenWidth - data->_cnv->_width;
|
|
|
|
|
2007-03-18 21:15:39 +00:00
|
|
|
for (uint16 i = 0; i < data->_cnv->_height ; i++) {
|
|
|
|
for (uint16 j = 0; j < data->_cnv->_width ; j++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
*d = (*t) ? *s : 0;
|
|
|
|
|
|
|
|
d++;
|
|
|
|
t++;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
s += pitch;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-04 18:58:50 +00:00
|
|
|
//
|
|
|
|
// restores background according to specified frame
|
|
|
|
//
|
|
|
|
void Gfx::restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background) {
|
|
|
|
|
|
|
|
byte *t = cnv->_data0;
|
|
|
|
byte *s = background;
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d0 = (byte*)_buffers[kBitBack]->getBasePtr(r.left, r.top);
|
|
|
|
byte *d1 = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
|
2007-08-04 18:58:50 +00:00
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
uint pitch = _vm->_screenWidth - r.width();
|
|
|
|
|
2007-08-04 18:58:50 +00:00
|
|
|
for (uint16 i = 0; i < r.height() ; i++) {
|
|
|
|
for (uint16 j = 0; j < r.width() ; j++) {
|
|
|
|
if (*t) {
|
|
|
|
*d0 = *s;
|
|
|
|
*d1 = *s;
|
|
|
|
}
|
|
|
|
|
|
|
|
d0++;
|
|
|
|
d1++;
|
|
|
|
t++;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
2007-08-06 19:19:59 +00:00
|
|
|
d0 += pitch;
|
|
|
|
d1 += pitch;
|
2007-08-04 18:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
//
|
2007-03-12 19:58:10 +00:00
|
|
|
// copies a rectangular bitmap on the background
|
2007-01-14 21:29:12 +00:00
|
|
|
//
|
2007-08-04 18:58:50 +00:00
|
|
|
void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-12 19:58:10 +00:00
|
|
|
StaticCnv cnv;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-12 19:58:10 +00:00
|
|
|
cnv._data0 = data;
|
|
|
|
cnv._data1 = NULL;
|
2007-03-13 19:59:45 +00:00
|
|
|
cnv._width = r.width();
|
|
|
|
cnv._height = r.height();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 09:16:12 +00:00
|
|
|
flatBlitCnv(&cnv, r.left, r.top, kBitBack);
|
|
|
|
flatBlitCnv(&cnv, r.left, r.top, kBit2);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) {
|
|
|
|
assert(_font == _fonts[kFontLabel]);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-23 17:22:47 +00:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
cnv->_width = _font->getStringWidth(text) + 16;
|
|
|
|
cnv->_height = 10;
|
|
|
|
cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
|
|
|
|
memset(cnv->_data0, 0, cnv->_width * cnv->_height);
|
|
|
|
|
|
|
|
_font->setColor(7);
|
|
|
|
_font->drawString(cnv->_data0 + 1, cnv->_width, text);
|
|
|
|
_font->drawString(cnv->_data0 + 1 + cnv->_width * 2, cnv->_width, text);
|
|
|
|
_font->drawString(cnv->_data0 + cnv->_width, cnv->_width, text);
|
|
|
|
_font->drawString(cnv->_data0 + 2 + cnv->_width, cnv->_width, text);
|
|
|
|
_font->setColor(1);
|
|
|
|
_font->drawString(cnv->_data0 + 1 + cnv->_width, cnv->_width, text);
|
|
|
|
} else {
|
|
|
|
cnv->_width = _font->getStringWidth(text);
|
|
|
|
cnv->_height = _font->height();
|
|
|
|
cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
|
|
|
|
memset(cnv->_data0, 0, cnv->_width * cnv->_height);
|
|
|
|
_font->drawString(cnv->_data0, cnv->_width, text);
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-02 07:32:06 +00:00
|
|
|
void Gfx::displayString(uint16 x, uint16 y, const char *text, byte color) {
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *dst = (byte*)_buffers[kBitFront]->getBasePtr(x, y);
|
2007-07-02 07:32:06 +00:00
|
|
|
_font->setColor(color);
|
2007-07-26 18:30:27 +00:00
|
|
|
_font->drawString(dst, _vm->_screenWidth, text);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 09:31:45 +00:00
|
|
|
void Gfx::displayCenteredString(uint16 y, const char *text) {
|
2007-07-26 18:30:27 +00:00
|
|
|
uint16 x = (_vm->_screenWidth - getStringWidth(text)) / 2;
|
2007-07-02 07:32:06 +00:00
|
|
|
displayString(x, y, text, 1);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
uint16 lines = 0;
|
|
|
|
bool rv = false;
|
|
|
|
uint16 linewidth = 0;
|
|
|
|
|
|
|
|
uint16 rx = x + 10;
|
|
|
|
uint16 ry = y + 4;
|
|
|
|
|
|
|
|
char token[40];
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
if (wrapwidth == -1)
|
|
|
|
wrapwidth = _vm->_screenWidth;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
while (strlen(text) > 0) {
|
|
|
|
|
2007-07-08 13:39:23 +00:00
|
|
|
text = parseNextToken(text, token, 40, " ", true);
|
2007-01-14 21:29:12 +00:00
|
|
|
linewidth += getStringWidth(token);
|
|
|
|
|
2007-07-02 07:32:06 +00:00
|
|
|
if (linewidth > wrapwidth) {
|
2007-01-14 21:29:12 +00:00
|
|
|
// wrap line
|
|
|
|
lines++;
|
|
|
|
rx = x + 10; // x
|
|
|
|
ry = y + 4 + lines*10; // y
|
|
|
|
linewidth = getStringWidth(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scumm_stricmp(token, "%s")) {
|
|
|
|
sprintf(token, "%d", _score);
|
|
|
|
}
|
|
|
|
if (!scumm_stricmp(token, "%p")) {
|
|
|
|
rv = true;
|
|
|
|
} else
|
2007-07-02 07:32:06 +00:00
|
|
|
displayString(rx, ry, token, color);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
rx += getStringWidth(token) + getStringWidth(" ");
|
|
|
|
linewidth += getStringWidth(" ");
|
|
|
|
|
2007-02-14 00:36:06 +00:00
|
|
|
text = Common::ltrim(text);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
uint16 Gfx::getStringWidth(const char *text) {
|
2007-04-16 20:16:18 +00:00
|
|
|
return _font->getStringWidth(text);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
uint16 lines = 0;
|
|
|
|
uint16 w = 0;
|
|
|
|
*width = 0;
|
|
|
|
|
|
|
|
char token[40];
|
|
|
|
|
|
|
|
while (strlen(text) != 0) {
|
|
|
|
|
2007-07-08 13:39:23 +00:00
|
|
|
text = parseNextToken(text, token, 40, " ", true);
|
2007-01-14 21:29:12 +00:00
|
|
|
w += getStringWidth(token);
|
|
|
|
|
|
|
|
if (w > maxwidth) {
|
|
|
|
w -= getStringWidth(token);
|
|
|
|
lines++;
|
|
|
|
if (w > *width)
|
|
|
|
*width = w;
|
|
|
|
|
|
|
|
w = getStringWidth(token);
|
|
|
|
}
|
|
|
|
|
|
|
|
w += getStringWidth(" ");
|
2007-02-14 00:36:06 +00:00
|
|
|
text = Common::ltrim(text);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*width < w) *width = w;
|
|
|
|
*width += 10;
|
|
|
|
|
|
|
|
*height = lines * 10 + 20;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-15 20:57:56 +00:00
|
|
|
void Gfx::setFont(Fonts name) {
|
|
|
|
assert(name < 3);
|
|
|
|
_font = _fonts[name];
|
2007-02-27 19:39:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-13 19:59:45 +00:00
|
|
|
void Gfx::restoreBackground(const Common::Rect& r) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 19:59:45 +00:00
|
|
|
int16 left = r.left;
|
|
|
|
int16 top = r.top;
|
|
|
|
int16 width = r.width();
|
|
|
|
int16 height = r.height();
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
if (left < 0) left = 0;
|
|
|
|
if (top < 0) top = 0;
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
if (left >= _vm->_screenWidth) return;
|
|
|
|
if (top >= _vm->_screenHeight) return;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
if (left+width >= _vm->_screenWidth) width = _vm->_screenWidth - left;
|
|
|
|
if (top+height >= _vm->_screenHeight) height = _vm->_screenHeight - top;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
Common::Rect q(width, height);
|
|
|
|
q.moveTo(left, top);
|
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
copyRect(kBitBack, q, (byte*)_buffers[kBit2]->getBasePtr(q.left, q.top), _vm->_screenWidth);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::freeStaticCnv(StaticCnv *cnv) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (!cnv) return;
|
|
|
|
|
|
|
|
if (!cnv || !cnv->_data0) return;
|
2007-03-04 08:58:23 +00:00
|
|
|
free(cnv->_data0);
|
2007-01-14 21:29:12 +00:00
|
|
|
cnv->_data0 = NULL;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-04 10:57:30 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::setBackground(byte *background) {
|
2007-08-06 13:22:21 +00:00
|
|
|
memcpy(_buffers[kBitBack]->pixels, background, _vm->_screenSize);
|
2007-03-04 20:12:55 +00:00
|
|
|
copyScreen(kBitBack, kBit2);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-08-06 19:39:00 +00:00
|
|
|
void Gfx::setMask(BitBuffer *buffer) {
|
|
|
|
if (_depthMask)
|
|
|
|
delete _depthMask;
|
|
|
|
|
|
|
|
_depthMask = buffer;
|
2007-03-04 10:57:30 +00:00
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *d = (byte*)_buffers[dstbuffer]->getBasePtr(r.left, r.top);
|
2007-01-14 21:29:12 +00:00
|
|
|
byte *s = src;
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
for (uint16 _si = 0; _si < r.height(); _si++) {
|
|
|
|
memcpy(d, s, r.width());
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
s += pitch;
|
2007-07-26 18:30:27 +00:00
|
|
|
d += _vm->_screenWidth;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
byte *s = (byte*)_buffers[srcbuffer]->getBasePtr(r.left, r.top);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
for (uint16 i = 0; i < r.height(); i++) {
|
|
|
|
memcpy(dst, s, r.width());
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
s += _vm->_screenWidth;
|
2007-01-14 21:29:12 +00:00
|
|
|
dst += pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
/*
|
|
|
|
the following 3 routines are hacks for Nippon Safes coming from the original code,
|
|
|
|
so they shouldn't be modified when adding support for other games
|
|
|
|
*/
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:13:51 +00:00
|
|
|
void Gfx::zeroMaskValue(uint16 x, uint16 y, byte color) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
uint16 _ax = x + y * _vm->_screenWidth;
|
2007-08-06 19:13:51 +00:00
|
|
|
_depthMask->data[_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2007-05-06 14:45:20 +00:00
|
|
|
void Gfx::fillMaskRect(const Common::Rect& r, byte color) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:43:33 +00:00
|
|
|
uint16 _di = r.left/4 + r.top * _depthMask->internalWidth;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 19:59:45 +00:00
|
|
|
for (uint16 _si = r.top; _si < r.bottom; _si++) {
|
2007-08-06 19:13:51 +00:00
|
|
|
memset(_depthMask->data + _di, color, r.width()/4+1);
|
2007-08-06 19:43:33 +00:00
|
|
|
_di += _depthMask->internalWidth;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::intGrottaHackMask() {
|
2007-08-06 19:13:51 +00:00
|
|
|
memset(_depthMask->data + 3600, 0, 3600);
|
2007-01-14 21:29:12 +00:00
|
|
|
_bgLayers[1] = 500;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
int16 Gfx::queryMask(int16 v) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
for (uint16 _si = 0; _si < 3; _si++) {
|
|
|
|
if (_bgLayers[_si+1] > v) return _si;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
Gfx::Gfx(Parallaction* vm) :
|
2007-01-14 21:29:12 +00:00
|
|
|
_vm(vm) {
|
|
|
|
|
|
|
|
g_system->beginGFXTransaction();
|
2007-07-26 18:30:27 +00:00
|
|
|
g_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
|
2007-01-14 21:29:12 +00:00
|
|
|
g_system->endGFXTransaction();
|
|
|
|
|
2007-08-06 13:22:21 +00:00
|
|
|
_buffers[kBitFront] = new Graphics::Surface;
|
|
|
|
_buffers[kBitFront]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
|
|
|
|
_buffers[kBitBack] = new Graphics::Surface;
|
|
|
|
_buffers[kBitBack]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
|
|
|
|
_buffers[kBit2] = new Graphics::Surface;
|
|
|
|
_buffers[kBit2]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
|
|
|
|
|
2007-08-06 19:39:00 +00:00
|
|
|
_depthMask = 0;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
setBlackPalette();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-15 08:32:28 +00:00
|
|
|
_bgLayers[0] = _bgLayers[1] = _bgLayers[2] = _bgLayers[3] = 0;
|
|
|
|
|
|
|
|
memset(_palette, 0, sizeof(_palette));
|
2007-04-01 14:35:33 +00:00
|
|
|
memset(_palettefx, 0, sizeof(_palettefx));
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
initMouse( 0 );
|
2007-04-16 20:16:18 +00:00
|
|
|
initFonts();
|
2007-04-15 20:57:56 +00:00
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
_halfbrite = false;
|
|
|
|
|
2007-03-18 10:38:31 +00:00
|
|
|
_font = NULL;
|
2007-02-27 19:39:33 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
Gfx::~Gfx() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-06 19:13:51 +00:00
|
|
|
_depthMask->free();
|
|
|
|
delete _depthMask;
|
2007-08-06 13:22:21 +00:00
|
|
|
|
|
|
|
_buffers[kBitFront]->free();
|
|
|
|
delete _buffers[kBitFront];
|
|
|
|
_buffers[kBitBack]->free();
|
|
|
|
delete _buffers[kBitBack];
|
|
|
|
_buffers[kBit2]->free();
|
|
|
|
delete _buffers[kBit2];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-15 20:57:56 +00:00
|
|
|
delete _fonts[kFontDialogue];
|
|
|
|
delete _fonts[kFontLabel];
|
|
|
|
delete _fonts[kFontMenu];
|
2007-02-27 19:39:33 +00:00
|
|
|
|
2007-05-21 21:06:30 +00:00
|
|
|
freeStaticCnv(_mouseComposedArrow);
|
|
|
|
delete _mouseComposedArrow;
|
2007-06-15 21:40:02 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Parallaction
|