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
|
|
|
|
|
|
|
|
|
|
|
extern OSystem *g_system;
|
|
|
|
|
|
|
|
namespace Parallaction {
|
2007-05-13 14:56:44 +00:00
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
byte * Gfx::_buffers[];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
#define BALLOON_WIDTH 12
|
|
|
|
#define BALLOON_HEIGHT 10
|
|
|
|
|
|
|
|
byte _resBalloon[2][BALLOON_WIDTH*BALLOON_HEIGHT] = {
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
q.right += 5;
|
|
|
|
floodFill(kBitFront, q, 0);
|
|
|
|
|
|
|
|
q.left++;
|
|
|
|
q.top+=2;
|
|
|
|
q.right--;
|
|
|
|
q.bottom--;
|
|
|
|
floodFill(kBitFront, q, 1);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
winding = (winding == 0 ? 1 : 0);
|
|
|
|
byte *s = _resBalloon[winding];
|
2007-03-13 19:59:45 +00:00
|
|
|
byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * SCREEN_WIDTH;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
for (uint16 i = 0; i < BALLOON_HEIGHT; i++) {
|
|
|
|
for (uint16 j = 0; j < BALLOON_WIDTH; j++) {
|
|
|
|
if (*s != 2) *d = *s;
|
|
|
|
d++;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
|
|
|
d += (SCREEN_WIDTH - BALLOON_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
g_system->updateScreen();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// palette Animation
|
|
|
|
//
|
|
|
|
// FIXME: the effect is different from the original
|
|
|
|
//
|
2007-03-28 20:12:00 +00:00
|
|
|
void Gfx::animatePalette() {
|
2007-04-01 14:35:33 +00:00
|
|
|
// printf("Gfx::animatePalette()\n");
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gfx::fadePalette(Palette pal) {
|
2007-04-21 12:51:40 +00:00
|
|
|
for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
|
2007-03-28 20:12:00 +00:00
|
|
|
if (pal[i] < _palette[i]) pal[i]++;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-28 20:12:00 +00:00
|
|
|
void Gfx::buildBWPalette(Palette pal) {
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gfx::quickFadePalette(Palette pal) {
|
|
|
|
|
2007-04-21 12:51:40 +00:00
|
|
|
for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) {
|
2007-03-28 20:12:00 +00:00
|
|
|
if (pal[i] == _palette[i]) continue;
|
|
|
|
pal[i] += (pal[i] < _palette[i] ? 4 : -4);
|
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
|
|
|
// printf("Gfx::updateScreen()\n");
|
2007-01-14 21:29:12 +00:00
|
|
|
g_system->copyRectToScreen(_buffers[kBitFront], SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
g_system->updateScreen();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::swapBuffers() {
|
2007-01-14 21:29:12 +00:00
|
|
|
byte *temp = _buffers[kBitFront];
|
|
|
|
_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-01-14 21:29:12 +00:00
|
|
|
memset(_buffers[buffer], 0, SCREEN_WIDTH*SCREEN_HEIGHT);
|
|
|
|
|
|
|
|
if (buffer == kBitFront) updateScreen();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) {
|
2007-01-14 21:29:12 +00:00
|
|
|
memcpy(_buffers[dstbuffer], _buffers[srcbuffer], SCREEN_WIDTH*SCREEN_HEIGHT);
|
|
|
|
|
|
|
|
if (dstbuffer == kBitFront) updateScreen();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
void Gfx::floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color) {
|
2007-03-12 20:41:25 +00:00
|
|
|
// printf("Gfx::floodFill(%i, %i, %i, %i, %i)\n", color, left, top, right, bottom);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
byte *d = _buffers[buffer] + (r.left + r.top * SCREEN_WIDTH);
|
|
|
|
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);
|
|
|
|
|
|
|
|
d += SCREEN_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:53:34 +00:00
|
|
|
void screenClip(Common::Rect& r, Common::Point& p) {
|
|
|
|
|
|
|
|
int32 x = r.left;
|
|
|
|
int32 y = r.top;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
Common::Rect screen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
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();
|
|
|
|
byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
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-03-14 21:09:56 +00:00
|
|
|
s += (r.width() - q.width());
|
|
|
|
d += (SCREEN_WIDTH - q.width());
|
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();
|
|
|
|
byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
for (uint16 i = q.top; i < q.bottom; i++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
uint16 n = dp.x % 4;
|
2007-03-14 21:57:07 +00:00
|
|
|
byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*SCREENMASK_WIDTH;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
for (uint16 j = q.left; j < q.right; j++) {
|
2007-01-14 21:29:12 +00:00
|
|
|
if (*s != 0) {
|
2007-03-14 21:09:56 +00:00
|
|
|
uint16 v = ((3 << (n << 1)) & *m) >> (n << 1);
|
2007-01-14 21:29:12 +00:00
|
|
|
if (z >= v) *d = *s;
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
n++;
|
|
|
|
if (n==4) m++;
|
|
|
|
n &= 0x3;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
s++;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:09:56 +00:00
|
|
|
s += (r.width() - q.right + q.left);
|
|
|
|
d += (SCREEN_WIDTH - q.right + q.left);
|
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-02-04 08:12:33 +00:00
|
|
|
if (label->_cnv._width + _si > SCREEN_WIDTH)
|
2007-02-17 21:19:55 +00:00
|
|
|
_si = SCREEN_WIDTH - 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
|
|
|
|
|
|
|
byte temp[16*16];
|
|
|
|
memcpy(temp, _mouseArrow, 16*16);
|
|
|
|
|
|
|
|
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-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
|
|
|
|
|
|
|
|
g_system->setMouseCursor(_mouseArrow, 16, 16, 0, 0, 0);
|
|
|
|
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-03-18 10:30:51 +00:00
|
|
|
// FIXME: target offseting is not clear
|
2007-01-14 21:29:12 +00:00
|
|
|
extractInventoryGraphics(index, v8 + 7 + 32 * 7);
|
|
|
|
g_system->setMouseCursor(v8, 32, 32, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Cnv management
|
|
|
|
//
|
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
|
|
|
|
|
|
|
byte *s = _buffers[kBit2] + x + y * SCREEN_WIDTH;
|
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
|
|
|
|
|
|
|
s += SCREEN_WIDTH;
|
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-01-14 21:29:12 +00:00
|
|
|
byte *s = _buffers[kBitBack] + x + y * SCREEN_WIDTH;
|
2007-03-12 19:58:10 +00:00
|
|
|
byte *d = data->_backup;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
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-03-18 21:15:39 +00:00
|
|
|
s += (SCREEN_WIDTH - data->_cnv->_width);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2007-03-12 19:58:10 +00:00
|
|
|
// copies a rectangular bitmap on the background
|
2007-01-14 21:29:12 +00:00
|
|
|
//
|
2007-03-13 19:59:45 +00:00
|
|
|
void Gfx::restoreZoneBackground(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-04-16 20:16:18 +00:00
|
|
|
void Gfx::displayString(uint16 x, uint16 y, const char *text) {
|
|
|
|
assert(_font == _fonts[kFontMenu]);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
|
2007-04-23 17:22:47 +00:00
|
|
|
_font->setColor(1);
|
2007-04-16 20:16:18 +00:00
|
|
|
_font->drawString(dst, SCREEN_WIDTH, 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) {
|
|
|
|
uint16 x = (SCREEN_WIDTH - getStringWidth(text)) / 2;
|
|
|
|
displayString(x, y, text);
|
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::displayBalloonString(uint16 x, uint16 y, const char *text, byte color) {
|
2007-04-16 20:16:18 +00:00
|
|
|
assert(_font == _fonts[kFontDialogue]);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-16 20:16:18 +00:00
|
|
|
_font->setColor(color);
|
|
|
|
_font->drawString(dst, SCREEN_WIDTH, text);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth, byte color) {
|
|
|
|
// printf("Gfx::displayWrappedString(%s, %i, %i, %i, %i)...", text, x, y, maxwidth, color);
|
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];
|
|
|
|
|
|
|
|
while (strlen(text) > 0) {
|
|
|
|
|
|
|
|
text = parseNextToken(text, token, 40, " ");
|
|
|
|
linewidth += getStringWidth(token);
|
|
|
|
|
|
|
|
if (linewidth > maxwidth) {
|
|
|
|
// 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
|
|
|
|
displayBalloonString(rx, ry, token, color);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// printf("done\n");
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
text = parseNextToken(text, token, 40, " ");
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (left >= SCREEN_WIDTH) return;
|
|
|
|
if (top >= SCREEN_HEIGHT) return;
|
|
|
|
|
|
|
|
if (left+width >= SCREEN_WIDTH) width = SCREEN_WIDTH - left;
|
|
|
|
if (top+height >= SCREEN_HEIGHT) height = SCREEN_HEIGHT - top;
|
|
|
|
|
2007-03-13 23:30:36 +00:00
|
|
|
Common::Rect q(width, height);
|
|
|
|
q.moveTo(left, top);
|
|
|
|
|
2007-03-13 20:47:59 +00:00
|
|
|
copyRect(
|
|
|
|
kBitBack,
|
2007-03-13 23:30:36 +00:00
|
|
|
q,
|
|
|
|
_buffers[kBit2] + q.left + q.top * SCREEN_WIDTH,
|
2007-03-13 20:47:59 +00:00
|
|
|
SCREEN_WIDTH
|
|
|
|
);
|
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
|
|
|
// printf("free_static_cnv()\n");
|
|
|
|
|
|
|
|
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-03-04 10:57:30 +00:00
|
|
|
memcpy(_buffers[kBitBack], background, SCREEN_WIDTH*SCREEN_HEIGHT);
|
2007-03-04 20:12:55 +00:00
|
|
|
copyScreen(kBitBack, kBit2);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::setMask(byte *mask) {
|
2007-03-04 10:57:30 +00:00
|
|
|
memcpy(_buffers[kMask0], mask, SCREENMASK_WIDTH*SCREEN_HEIGHT);
|
|
|
|
}
|
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-03-13 23:30:36 +00:00
|
|
|
byte *d = _buffers[dstbuffer] + r.left + SCREEN_WIDTH * 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;
|
|
|
|
d += SCREEN_WIDTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-03-13 23:30:36 +00:00
|
|
|
byte *s = _buffers[srcbuffer] + r.left + SCREEN_WIDTH * 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
|
|
|
|
|
|
|
s += SCREEN_WIDTH;
|
|
|
|
dst += pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-06 14:45:20 +00:00
|
|
|
void Gfx::plotMaskPixel(uint16 x, uint16 y, byte color) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
uint16 _ax = x + y * SCREEN_WIDTH;
|
2007-03-14 21:57:07 +00:00
|
|
|
_buffers[kMask0][_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-03-13 19:59:45 +00:00
|
|
|
uint16 _di = r.left/4 + r.top*80;
|
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-05-06 14:45:20 +00:00
|
|
|
memset(&_buffers[kMask0][_di], color, r.width()/4+1);
|
2007-01-14 21:29:12 +00:00
|
|
|
_di += 80;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// HACK
|
|
|
|
// this routine is only invoked from the 'intgrotta scenario'
|
|
|
|
//
|
2007-03-12 20:41:25 +00:00
|
|
|
void Gfx::intGrottaHackMask() {
|
2007-01-14 21:29:12 +00:00
|
|
|
memset(_buffers[kMask0] + 3600, 0, 3600);
|
|
|
|
_bgLayers[1] = 500;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
g_system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
|
|
g_system->endGFXTransaction();
|
|
|
|
|
2007-04-11 20:20:22 +00:00
|
|
|
_buffers[kBitFront] = (byte*)malloc(SCREEN_SIZE);
|
|
|
|
_buffers[kBitBack] = (byte*)malloc(SCREEN_SIZE);
|
|
|
|
_buffers[kBit2] = (byte*)malloc(SCREEN_SIZE);
|
|
|
|
_buffers[kMask0] = (byte*)malloc(SCREENMASK_WIDTH * SCREEN_HEIGHT);
|
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-03-04 08:58:23 +00:00
|
|
|
free(_buffers[kMask0]);
|
|
|
|
free(_buffers[kBitFront]);
|
|
|
|
free(_buffers[kBitBack]);
|
|
|
|
free(_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
|