2008-07-31 10:47:15 +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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-03-04 11:53:25 +00:00
|
|
|
#ifdef ENABLE_LOL
|
|
|
|
|
2008-07-31 10:47:15 +00:00
|
|
|
#include "kyra/screen_lol.h"
|
|
|
|
#include "kyra/lol.h"
|
2009-04-03 21:32:50 +00:00
|
|
|
#include "kyra/resource.h"
|
2008-07-31 10:47:15 +00:00
|
|
|
|
|
|
|
namespace Kyra {
|
|
|
|
|
|
|
|
Screen_LoL::Screen_LoL(LoLEngine *vm, OSystem *system) : Screen_v2(vm, system), _vm(vm) {
|
2009-01-18 17:04:24 +00:00
|
|
|
_paletteOverlay1 = new uint8[0x100];
|
|
|
|
_paletteOverlay2 = new uint8[0x100];
|
|
|
|
_grayOverlay = new uint8[0x100];
|
|
|
|
memset(_paletteOverlay1, 0, 0x100);
|
|
|
|
memset(_paletteOverlay2, 0, 0x100);
|
|
|
|
memset(_grayOverlay, 0, 0x100);
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
_levelOverlays[i] = new uint8[256];
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
_fadeFlag = 2;
|
2009-02-01 19:27:01 +00:00
|
|
|
_curDimIndex = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Screen_LoL::~Screen_LoL() {
|
|
|
|
for (int i = 0; i < _screenDimTableCount; i++)
|
|
|
|
delete _customDimTable[i];
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _customDimTable;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _levelOverlays[i];
|
2009-01-18 17:04:24 +00:00
|
|
|
|
2009-01-18 17:38:29 +00:00
|
|
|
delete[] _paletteOverlay1;
|
|
|
|
delete[] _paletteOverlay2;
|
|
|
|
delete[] _grayOverlay;
|
2008-07-31 10:47:15 +00:00
|
|
|
}
|
|
|
|
|
2009-04-25 13:15:05 +00:00
|
|
|
bool Screen_LoL::init() {
|
|
|
|
if (Screen::init()) {
|
|
|
|
_screenDimTable = _use16ColorMode ? _screenDimTable16C : _screenDimTable256C;
|
|
|
|
_customDimTable = new ScreenDim*[_screenDimTableCount];
|
2009-05-29 12:52:03 +00:00
|
|
|
memset(_customDimTable, 0, sizeof(ScreenDim *)* _screenDimTableCount);
|
2009-04-25 13:15:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-31 10:47:15 +00:00
|
|
|
void Screen_LoL::setScreenDim(int dim) {
|
|
|
|
assert(dim < _screenDimTableCount);
|
2009-01-18 17:04:24 +00:00
|
|
|
_curDim = _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];
|
2009-02-01 19:27:01 +00:00
|
|
|
_curDimIndex = dim;
|
2008-07-31 10:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const ScreenDim *Screen_LoL::getScreenDim(int dim) {
|
|
|
|
assert(dim < _screenDimTableCount);
|
2009-01-18 17:04:24 +00:00
|
|
|
return _customDimTable[dim] ? (const ScreenDim *)_customDimTable[dim] : &_screenDimTable[dim];
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::modifyScreenDim(int dim, int x, int y, int w, int h) {
|
|
|
|
delete _customDimTable[dim];
|
|
|
|
_customDimTable[dim] = new ScreenDim;
|
|
|
|
memcpy(_customDimTable[dim], &_screenDimTable[dim], sizeof(ScreenDim));
|
|
|
|
_customDimTable[dim]->sx = x;
|
|
|
|
_customDimTable[dim]->sy = y;
|
|
|
|
_customDimTable[dim]->w = w;
|
|
|
|
_customDimTable[dim]->h = h;
|
|
|
|
setScreenDim(dim);
|
|
|
|
}
|
|
|
|
|
2008-12-29 14:37:51 +00:00
|
|
|
void Screen_LoL::fprintString(const char *format, int x, int y, uint8 col1, uint8 col2, uint16 flags, ...) {
|
|
|
|
if (!format)
|
|
|
|
return;
|
|
|
|
|
|
|
|
char string[240];
|
|
|
|
va_list vaList;
|
|
|
|
va_start(vaList, flags);
|
|
|
|
vsnprintf(string, sizeof(string), format, vaList);
|
|
|
|
va_end(vaList);
|
|
|
|
|
|
|
|
if (flags & 1)
|
2009-06-15 20:52:09 +00:00
|
|
|
x -= (getTextWidth(string) >> 1);
|
2008-12-29 14:37:51 +00:00
|
|
|
|
|
|
|
if (flags & 2)
|
|
|
|
x -= getTextWidth(string);
|
|
|
|
|
|
|
|
if (flags & 4) {
|
|
|
|
printText(string, x - 1, y, 1, col2);
|
|
|
|
printText(string, x, y + 1, 1, col2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & 8) {
|
|
|
|
printText(string, x - 1, y, 227, col2);
|
|
|
|
printText(string, x, y + 1, 227, col2);
|
|
|
|
}
|
|
|
|
|
|
|
|
printText(string, x, y, col1, col2);
|
|
|
|
}
|
|
|
|
|
2008-07-31 10:47:15 +00:00
|
|
|
void Screen_LoL::fprintStringIntro(const char *format, int x, int y, uint8 c1, uint8 c2, uint8 c3, uint16 flags, ...) {
|
|
|
|
char buffer[400];
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, flags);
|
2009-01-01 15:06:43 +00:00
|
|
|
vsnprintf(buffer, sizeof(buffer), format, args);
|
2008-07-31 10:47:15 +00:00
|
|
|
va_end(args);
|
2009-01-01 15:06:43 +00:00
|
|
|
|
2008-07-31 10:47:15 +00:00
|
|
|
if ((flags & 0x0F00) == 0x100)
|
|
|
|
x -= getTextWidth(buffer) >> 1;
|
|
|
|
if ((flags & 0x0F00) == 0x200)
|
|
|
|
x -= getTextWidth(buffer);
|
|
|
|
|
|
|
|
if ((flags & 0x00F0) == 0x20) {
|
|
|
|
printText(buffer, x-1, y, c3, c2);
|
|
|
|
printText(buffer, x, y+1, c3, c2);
|
|
|
|
}
|
|
|
|
|
|
|
|
printText(buffer, x, y, c1, c2);
|
|
|
|
}
|
|
|
|
|
2009-06-25 19:59:06 +00:00
|
|
|
void Screen_LoL::generateGrayOverlay(const Palette &srcPal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool skipSpecialColors) {
|
2009-06-25 19:57:35 +00:00
|
|
|
Palette tmpPal(lastColor);
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
for (int i = 0; i != lastColor; i++) {
|
|
|
|
int v = (((srcPal[3 * i] & 0x3f) * factor) / 0x40) + addR;
|
|
|
|
tmpPal[3 * i] = (v > 0x3f) ? 0x3f : v & 0xff;
|
|
|
|
v = (((srcPal[3 * i + 1] & 0x3f) * factor) / 0x40) + addG;
|
|
|
|
tmpPal[3 * i + 1] = (v > 0x3f) ? 0x3f : v & 0xff;
|
|
|
|
v = (((srcPal[3 * i + 2] & 0x3f) * factor) / 0x40) + addB;
|
|
|
|
tmpPal[3 * i + 2] = (v > 0x3f) ? 0x3f : v & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < lastColor; i++)
|
2009-06-27 13:15:47 +00:00
|
|
|
grayOverlay[i] = findLeastDifferentColor(tmpPal.getData() + 3 * i, srcPal, 0, lastColor, skipSpecialColors);
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 19:59:06 +00:00
|
|
|
uint8 *Screen_LoL::generateLevelOverlay(const Palette &srcPal, uint8 *ovl, int opColor, int weight) {
|
|
|
|
if (!ovl)
|
2009-01-18 17:04:24 +00:00
|
|
|
return ovl;
|
|
|
|
|
|
|
|
if (weight > 255)
|
|
|
|
weight = 255;
|
|
|
|
|
|
|
|
uint16 r = srcPal[opColor * 3];
|
|
|
|
uint16 g = srcPal[opColor * 3 + 1];
|
|
|
|
uint16 b = srcPal[opColor * 3 + 2];
|
|
|
|
|
|
|
|
uint8 *d = ovl;
|
|
|
|
*d++ = 0;
|
|
|
|
|
|
|
|
for (int i = 1; i != 255; i++) {
|
|
|
|
uint16 a = srcPal[i * 3];
|
|
|
|
uint8 dr = a - ((((a - r) * (weight >> 1)) << 1) >> 8);
|
|
|
|
a = srcPal[i * 3 + 1];
|
|
|
|
uint8 dg = a - ((((a - g) * (weight >> 1)) << 1) >> 8);
|
|
|
|
a = srcPal[i * 3 + 2];
|
|
|
|
uint8 db = a - ((((a - b) * (weight >> 1)) << 1) >> 8);
|
|
|
|
|
|
|
|
int l = opColor;
|
|
|
|
int m = 0x7fff;
|
|
|
|
int ii = 127;
|
|
|
|
int x = 1;
|
2009-06-25 19:59:06 +00:00
|
|
|
const uint8 *s = srcPal.getData() + 3;
|
2009-01-18 17:04:24 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
if (i == x) {
|
|
|
|
s += 3;
|
|
|
|
} else {
|
|
|
|
int t = *s++ - dr;
|
|
|
|
int c = t * t;
|
|
|
|
t = *s++ - dg;
|
|
|
|
c += (t * t);
|
|
|
|
t = *s++ - db;
|
|
|
|
c += (t * t);
|
|
|
|
|
|
|
|
if (!c) {
|
|
|
|
l = x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c <= m) {
|
|
|
|
m = c;
|
|
|
|
l = x;
|
2009-05-21 13:13:09 +00:00
|
|
|
}
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
x++;
|
|
|
|
} while (--ii);
|
|
|
|
|
|
|
|
*d++ = l & 0xff;
|
|
|
|
}
|
|
|
|
|
2009-05-21 13:13:09 +00:00
|
|
|
return ovl;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::drawGridBox(int x, int y, int w, int h, int col) {
|
|
|
|
if (w <= 0 || x >= 320 || h <= 0 || y >= 200)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (x < 0) {
|
|
|
|
x += w;
|
|
|
|
if (x <= 0)
|
|
|
|
return;
|
|
|
|
w = x;
|
2009-05-21 13:13:09 +00:00
|
|
|
x = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tmp = x + w;
|
|
|
|
if (tmp >= 320) {
|
|
|
|
w = 320 - x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pitch = 320 - w;
|
|
|
|
|
|
|
|
if (y < 0) {
|
|
|
|
y += h;
|
|
|
|
if (y <= 0)
|
|
|
|
return;
|
|
|
|
h = y;
|
2009-05-21 13:13:09 +00:00
|
|
|
y = 0;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp = y + h;
|
|
|
|
if (tmp >= 200) {
|
|
|
|
h = 200 - y;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = (y + x) & 1;
|
|
|
|
uint8 *p = getPagePtr(_curPage) + y * 320 + x;
|
|
|
|
uint8 s = (tmp >> 8) & 1;
|
|
|
|
|
|
|
|
w >>= 1;
|
|
|
|
int w2 = w;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
while (h--) {
|
|
|
|
if (w) {
|
|
|
|
while (w--) {
|
|
|
|
*(p + tmp) = col;
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
w = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s == 1) {
|
|
|
|
if (tmp == 0)
|
|
|
|
*p = col;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
tmp ^= 1;
|
|
|
|
p += pitch;
|
|
|
|
w = w2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
void Screen_LoL::fadeClearSceneWindow(int delay) {
|
|
|
|
if (_fadeFlag == 1)
|
|
|
|
return;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-06-22 02:36:54 +00:00
|
|
|
Palette tpal(getPalette(0).getNumColors());
|
2009-06-25 19:52:49 +00:00
|
|
|
tpal.copy(getPalette(0), 128);
|
2009-02-01 19:27:01 +00:00
|
|
|
|
2009-06-29 16:08:16 +00:00
|
|
|
loadSpecialColors(tpal);
|
2009-02-01 19:27:01 +00:00
|
|
|
fadePalette(tpal, delay);
|
2009-06-22 02:36:54 +00:00
|
|
|
|
2009-02-01 19:27:01 +00:00
|
|
|
fillRect(112, 0, 288, 120, 0);
|
|
|
|
|
|
|
|
_fadeFlag = 1;
|
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
void Screen_LoL::backupSceneWindow(int srcPageNum, int dstPageNum) {
|
|
|
|
uint8 *src = getPagePtr(srcPageNum) + 112;
|
|
|
|
uint8 *dst = getPagePtr(dstPageNum) + 0xa500;
|
|
|
|
|
|
|
|
for (int h = 0; h < 120; h++) {
|
|
|
|
for (int w = 0; w < 176; w++)
|
|
|
|
*dst++ = *src++;
|
|
|
|
src += 144;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::restoreSceneWindow(int srcPageNum, int dstPageNum) {
|
|
|
|
uint8 *src = getPagePtr(srcPageNum) + 0xa500;
|
|
|
|
uint8 *dst = getPagePtr(dstPageNum) + 112;
|
|
|
|
|
|
|
|
for (int h = 0; h < 120; h++) {
|
|
|
|
memcpy(dst, src, 176);
|
|
|
|
src += 176;
|
|
|
|
dst += 320;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dstPageNum)
|
|
|
|
addDirtyRect(112, 0, 176, 120);
|
|
|
|
}
|
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
void Screen_LoL::clearGuiShapeMemory(int pageNum) {
|
|
|
|
uint8 *dst = getPagePtr(pageNum) + 0x79b0;
|
|
|
|
for (int i = 0; i < 23; i++) {
|
|
|
|
memset(dst, 0, 176);
|
|
|
|
dst += 320;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 15:52:09 +00:00
|
|
|
void Screen_LoL::copyGuiShapeFromSceneBackupBuffer(int srcPageNum, int dstPageNum) {
|
2009-05-25 22:58:05 +00:00
|
|
|
uint8 *src = getPagePtr(srcPageNum) + 0x79c3;
|
2009-05-30 15:52:09 +00:00
|
|
|
uint8 *dst = getPagePtr(dstPageNum);
|
2009-05-25 22:58:05 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 23; i++) {
|
|
|
|
uint8 len = 0;
|
|
|
|
uint8 v = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = *src++;
|
|
|
|
len++;
|
|
|
|
} while (!v);
|
|
|
|
|
|
|
|
*dst++ = len;
|
2009-05-29 12:52:03 +00:00
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
len = 69 - len;
|
|
|
|
memcpy(dst, src, len);
|
|
|
|
src += (len + 251);
|
2009-05-29 12:52:03 +00:00
|
|
|
dst += len;
|
2009-05-25 22:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 15:52:09 +00:00
|
|
|
void Screen_LoL::copyGuiShapeToSurface(int srcPageNum, int dstPageNum) {
|
|
|
|
uint8 *src = getPagePtr(srcPageNum);
|
2009-05-25 22:58:05 +00:00
|
|
|
uint8 *dst = getPagePtr(dstPageNum) + 0xe7c3;
|
|
|
|
|
|
|
|
for (int i = 0; i < 23; i++) {
|
|
|
|
uint8 v = *src++;
|
|
|
|
uint8 len = 69 - v;
|
|
|
|
dst += v;
|
|
|
|
memcpy(dst, src, len);
|
|
|
|
src += (len - 1);
|
|
|
|
dst += len;
|
2009-05-29 12:52:03 +00:00
|
|
|
|
2009-05-25 22:58:05 +00:00
|
|
|
for (int ii = 0; ii < len; ii++)
|
|
|
|
*dst++ = *src--;
|
|
|
|
|
|
|
|
src += (len + 1);
|
2009-05-29 12:52:03 +00:00
|
|
|
dst += (v + 38);
|
2009-05-25 22:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
void Screen_LoL::smoothScrollZoomStepTop(int srcPageNum, int dstPageNum, int x, int y) {
|
|
|
|
uint8 *src = getPagePtr(srcPageNum) + 0xa500 + y * 176 + x;
|
|
|
|
uint8 *dst = getPagePtr(dstPageNum) + 0xa500;
|
|
|
|
|
|
|
|
x <<= 1;
|
|
|
|
uint16 width = 176 - x;
|
|
|
|
uint16 scaleX = (((x + 1) << 8) / width + 0x100);
|
|
|
|
uint16 cntW = scaleX >> 8;
|
|
|
|
scaleX <<= 8;
|
|
|
|
width--;
|
|
|
|
uint16 widthCnt = width;
|
|
|
|
|
|
|
|
uint16 height = 46 - y;
|
|
|
|
uint16 scaleY = (((y + 1) << 8) / height + 0x100);
|
|
|
|
scaleY <<= 8;
|
|
|
|
|
|
|
|
uint32 scaleYc = 0;
|
|
|
|
while (height) {
|
|
|
|
uint32 scaleXc = 0;
|
|
|
|
do {
|
|
|
|
scaleXc += scaleX;
|
|
|
|
int numbytes = cntW + (scaleXc >> 16);
|
|
|
|
scaleXc &= 0xffff;
|
|
|
|
memset(dst, *src++, numbytes);
|
|
|
|
dst += numbytes;
|
|
|
|
} while (--widthCnt);
|
|
|
|
|
|
|
|
*dst++ = *src++;
|
|
|
|
widthCnt = width;
|
|
|
|
|
|
|
|
src += x;
|
|
|
|
scaleYc += scaleY;
|
|
|
|
|
|
|
|
if (scaleYc >> 16) {
|
|
|
|
scaleYc = 0;
|
|
|
|
src -= 176;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
height--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::smoothScrollZoomStepBottom(int srcPageNum, int dstPageNum, int x, int y) {
|
|
|
|
uint8 *src = getPagePtr(srcPageNum) + 0xc4a0 + x;
|
|
|
|
uint8 *dst = getPagePtr(dstPageNum) + 0xc4a0;
|
|
|
|
|
|
|
|
x <<= 1;
|
|
|
|
uint16 width = 176 - x;
|
|
|
|
uint16 scaleX = (((x + 1) << 8) / width + 0x100);
|
|
|
|
uint16 cntW = scaleX >> 8;
|
|
|
|
scaleX <<= 8;
|
|
|
|
width--;
|
|
|
|
uint16 widthCnt = width;
|
|
|
|
|
|
|
|
uint16 height = 74 - y;
|
|
|
|
uint16 scaleY = (((y + 1) << 8) / height + 0x100);
|
|
|
|
scaleY <<= 8;
|
|
|
|
|
|
|
|
uint32 scaleYc = 0;
|
|
|
|
while (height) {
|
|
|
|
uint32 scaleXc = 0;
|
|
|
|
do {
|
|
|
|
scaleXc += scaleX;
|
|
|
|
int numbytes = cntW + (scaleXc >> 16);
|
|
|
|
scaleXc &= 0xffff;
|
|
|
|
memset(dst, *src++, numbytes);
|
|
|
|
dst += numbytes;
|
|
|
|
} while (--widthCnt);
|
|
|
|
|
|
|
|
*dst++ = *src++;
|
|
|
|
widthCnt = width;
|
|
|
|
|
|
|
|
src += x;
|
|
|
|
scaleYc += scaleY;
|
|
|
|
|
|
|
|
if (scaleYc >> 16) {
|
|
|
|
scaleYc = 0;
|
|
|
|
src -= 176;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
height--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::smoothScrollHorizontalStep(int pageNum, int srcX, int dstX, int w) {
|
|
|
|
uint8 *d = getPagePtr(pageNum);
|
|
|
|
uint8 *s = d + 112 + srcX;
|
|
|
|
|
|
|
|
int w2 = srcX + w - dstX;
|
|
|
|
int pitchS = 320 + w2 - (w << 1);
|
|
|
|
|
|
|
|
int pitchD = 320 - w;
|
|
|
|
int h = 120;
|
|
|
|
|
|
|
|
while (h--) {
|
|
|
|
for (int i = 0; i < w; i++)
|
|
|
|
*d++ = *s++;
|
|
|
|
d -= w;
|
|
|
|
s -= w2;
|
|
|
|
|
|
|
|
for (int i = 0; i < w; i++)
|
|
|
|
*s++ = *d++;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
s += pitchS;
|
|
|
|
d += pitchD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::smoothScrollTurnStep1(int srcPage1Num, int srcPage2Num, int dstPageNum) {
|
|
|
|
uint8 *s = getPagePtr(srcPage1Num) + 273;
|
|
|
|
uint8 *d = getPagePtr(dstPageNum) + 0xa500;
|
|
|
|
|
|
|
|
for (int i = 0; i < 120; i++) {
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
|
|
|
|
for (int ii = 0; ii < 14; ii++) {
|
|
|
|
a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
s += 305;
|
|
|
|
d += 132;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = getPagePtr(srcPage2Num) + 112;
|
|
|
|
d = getPagePtr(dstPageNum) + 0xa52c;
|
|
|
|
|
|
|
|
for (int i = 0; i < 120; i++) {
|
|
|
|
for (int ii = 0; ii < 33; ii++) {
|
|
|
|
*d++ = *s++;
|
|
|
|
*d++ = *s++;
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
s += 221;
|
|
|
|
d += 44;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::smoothScrollTurnStep2(int srcPage1Num, int srcPage2Num, int dstPageNum) {
|
|
|
|
uint8 *s = getPagePtr(srcPage1Num) + 244;
|
|
|
|
uint8 *d = getPagePtr(dstPageNum) + 0xa500;
|
|
|
|
|
|
|
|
for (int k = 0; k < 2; k++) {
|
|
|
|
for (int i = 0; i < 120; i++) {
|
|
|
|
for (int ii = 0; ii < 44; ii++) {
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
s += 276;
|
|
|
|
d += 88;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = getPagePtr(srcPage2Num) + 112;
|
|
|
|
d = getPagePtr(dstPageNum) + 0xa558;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::smoothScrollTurnStep3(int srcPage1Num, int srcPage2Num, int dstPageNum) {
|
|
|
|
uint8 *s = getPagePtr(srcPage1Num) + 189;
|
|
|
|
uint8 *d = getPagePtr(dstPageNum) + 0xa500;
|
|
|
|
|
|
|
|
for (int i = 0; i < 120; i++) {
|
|
|
|
for (int ii = 0; ii < 33; ii++) {
|
|
|
|
*d++ = *s++;
|
|
|
|
*d++ = *s++;
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
s += 221;
|
|
|
|
d += 44;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = getPagePtr(srcPage2Num) + 112;
|
|
|
|
d = getPagePtr(dstPageNum) + 0xa584;
|
|
|
|
|
|
|
|
for (int i = 0; i < 120; i++) {
|
|
|
|
for (int ii = 0; ii < 14; ii++) {
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 a = *s++;
|
|
|
|
*d++ = a;
|
|
|
|
*d++ = a;
|
|
|
|
|
|
|
|
s += 305;
|
|
|
|
d += 132;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
void Screen_LoL::copyRegionSpecial(int page1, int w1, int h1, int x1, int y1, int page2, int w2, int h2, int x2, int y2, int w3, int h3, int mode, ...) {
|
|
|
|
if (!w3 || !h3)
|
|
|
|
return;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
uint8 *table1 = 0;
|
|
|
|
uint8 *table2 = 0;
|
|
|
|
|
|
|
|
if (mode == 2) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, mode);
|
|
|
|
table1 = va_arg(args, uint8*);
|
|
|
|
table2 = va_arg(args, uint8*);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
int na = 0, nb = 0, nc = w3;
|
|
|
|
if (!calcBounds(w1, h1, x1, y1, w3, h3, na, nb, nc))
|
2009-05-15 06:29:08 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
int iu5_1 = na;
|
|
|
|
int iu6_1 = nb;
|
|
|
|
int ibw_1 = w3;
|
|
|
|
//int ibh_1 = h3;
|
|
|
|
int dx_1 = x1;
|
|
|
|
int dy_1 = y1;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
if (!calcBounds(w2, h2, x2, y2, w3, h3, na, nb, nc))
|
2009-05-15 06:29:08 +00:00
|
|
|
return;
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
int iu5_2 = na;
|
|
|
|
int iu6_2 = nb;
|
|
|
|
int ibw_2 = w3;
|
|
|
|
int ibh_2 = h3;
|
|
|
|
int dx_2 = x2;
|
|
|
|
int dy_2 = y2;
|
2009-05-15 06:29:08 +00:00
|
|
|
|
|
|
|
uint8 *src = getPagePtr(page1) + (dy_1 + iu6_2) * w1;
|
|
|
|
uint8 *dst = getPagePtr(page2) + (dy_2 + iu6_1) * w2;
|
|
|
|
|
|
|
|
for (int i = 0; i < ibh_2; i++) {
|
|
|
|
uint8 *s = src + iu5_2 + dx_1;
|
|
|
|
uint8 *d = dst + iu5_1 + dx_2;
|
|
|
|
|
|
|
|
if (mode == 0) {
|
|
|
|
memcpy(d, s, ibw_2);
|
|
|
|
|
|
|
|
} else if (mode == 1) {
|
|
|
|
if (!(i & 1)) {
|
|
|
|
s++;
|
|
|
|
d++;
|
|
|
|
}
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
for (int ii = (i & 1) ^ 1; ii < ibw_2; ii += 2 ) {
|
|
|
|
*d = *s;
|
|
|
|
d += 2;
|
|
|
|
s += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (mode == 2) {
|
|
|
|
for (int ii = 0; ii < ibw_2; ii++) {
|
|
|
|
uint8 cmd = *s++;
|
|
|
|
uint8 offs = table1[cmd];
|
|
|
|
if (!(offs & 0x80))
|
|
|
|
cmd = table2[(offs << 8) | *d];
|
|
|
|
*d++ = cmd;
|
|
|
|
}
|
2009-05-21 13:13:09 +00:00
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
} else if (mode == 3) {
|
|
|
|
s = s - iu5_2 + ibw_1;
|
|
|
|
s = s - iu5_2 - 1;
|
|
|
|
for (int ii = 0; ii < ibw_2; ii++)
|
|
|
|
*d++ = *s--;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst += w2;
|
|
|
|
src += w1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!page2)
|
2009-07-05 14:58:22 +00:00
|
|
|
addDirtyRect(x2, y2, w2, h2);
|
2009-05-15 06:29:08 +00:00
|
|
|
}
|
|
|
|
|
2009-05-16 12:53:05 +00:00
|
|
|
void Screen_LoL::copyBlockAndApplyOverlay(int page1, int x1, int y1, int page2, int x2, int y2, int w, int h, int dim, uint8 *ovl) {
|
2009-04-03 21:32:50 +00:00
|
|
|
if (!w || !h || !ovl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const ScreenDim *cdim = getScreenDim(dim);
|
2009-07-05 14:58:22 +00:00
|
|
|
int ix = cdim->sx << 3;
|
|
|
|
int iy = cdim->sy;
|
|
|
|
int iw = cdim->w << 3;
|
|
|
|
int ih = cdim->h;
|
2009-04-03 21:32:50 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
int na = 0, nb = 0, nc = w;
|
|
|
|
if (!calcBounds(iw, ih, x2, y2, w, h, na, nb, nc))
|
2009-04-03 21:32:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
uint8 *src = getPagePtr(page1) + y1 * 320 + x1;
|
2009-07-05 14:58:22 +00:00
|
|
|
uint8 *dst = getPagePtr(page2) + (y2 + iy) * 320;
|
2009-04-03 21:32:50 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
for (int i = 0; i < h; i++) {
|
|
|
|
uint8 *s = src + na;
|
|
|
|
uint8 *d = dst + (x2 + ix);
|
2009-04-03 21:32:50 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
for (int ii = 0; ii < w; ii++) {
|
2009-04-03 21:32:50 +00:00
|
|
|
uint8 p = ovl[*s++];
|
|
|
|
if (p)
|
|
|
|
*d = p;
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst += 320;
|
|
|
|
src += 320;
|
|
|
|
}
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
if (!page2)
|
2009-07-05 14:58:22 +00:00
|
|
|
addDirtyRect(x2 + ix, y2 + iy, w, h);
|
2009-04-25 13:15:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::applyOverlaySpecial(int page1, int x1, int y1, int page2, int x2, int y2, int w, int h, int dim, int flag, uint8 *ovl) {
|
|
|
|
if (!w || !h || !ovl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const ScreenDim *cdim = getScreenDim(dim);
|
2009-07-05 14:58:22 +00:00
|
|
|
int ix = cdim->sx << 3;
|
|
|
|
int iy = cdim->sy;
|
|
|
|
int iw = cdim->w << 3;
|
|
|
|
int ih = cdim->h;
|
2009-04-25 13:15:05 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
int na = 0, nb = 0, nc = w;
|
|
|
|
if (!calcBounds(iw, ih, x2, y2, w, h, na, nb, nc))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// _internDimH: h0
|
|
|
|
// _internDimW: w0
|
|
|
|
// _internDimDstX: x1
|
|
|
|
// _internDimDstY: y1
|
|
|
|
// _internBlockWidth: w1
|
|
|
|
// _internBlockHeight: h1
|
|
|
|
// _internDimU5: x2 na
|
|
|
|
// _internDimU6: y2 nb
|
|
|
|
// _internBlockWidth2: w2 nc
|
|
|
|
|
|
|
|
// _internDimX = _internDimY = 0;
|
|
|
|
// _internDimW = w1;
|
|
|
|
/* _internDimH = h1;
|
|
|
|
calcBoundariesIntern(x1, y1, w3, h3);
|
2009-04-25 13:15:05 +00:00
|
|
|
if (_internBlockWidth == -1)
|
|
|
|
return;
|
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
calcBoundariesIntern(x2, y2, w, h);
|
|
|
|
if (_internBlockWidth == -1)
|
|
|
|
return;*/
|
|
|
|
|
2009-04-25 13:15:05 +00:00
|
|
|
uint8 *src = getPagePtr(page1) + y1 * 320 + x1;
|
2009-07-05 14:58:22 +00:00
|
|
|
uint8 *dst = getPagePtr(page2) + (y2 + iy) * 320;
|
2009-04-25 13:15:05 +00:00
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
for (int i = 0; i < h; i++) {
|
|
|
|
uint8 *s = src + na;
|
|
|
|
uint8 *d = dst + (x2 + ix);
|
2009-04-25 13:15:05 +00:00
|
|
|
|
|
|
|
if (flag)
|
|
|
|
d += (i >> 1);
|
|
|
|
|
2009-07-05 14:58:22 +00:00
|
|
|
for (int ii = 0; ii < w; ii++) {
|
2009-04-25 13:15:05 +00:00
|
|
|
if (*s++)
|
|
|
|
*d = ovl[*d];
|
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
|
|
|
dst += 320;
|
|
|
|
src += 320;
|
|
|
|
}
|
|
|
|
|
2009-05-15 06:29:08 +00:00
|
|
|
if (!page2)
|
2009-07-05 14:58:22 +00:00
|
|
|
addDirtyRect(x2 + ix, y2 + iy, w, h);
|
2009-04-03 21:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-31 00:42:44 +00:00
|
|
|
void Screen_LoL::copyBlockAndApplyOverlayOutro(int srcPage, int dstPage, const uint8 *ovl) {
|
|
|
|
if (!ovl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const byte *src = getCPagePtr(srcPage);
|
|
|
|
byte *dst = getPagePtr(dstPage);
|
|
|
|
|
|
|
|
for (int y = 0; y < 200; ++y) {
|
|
|
|
for (int x = 0; x < 80; ++x) {
|
|
|
|
uint32 srcData = READ_LE_UINT32(src); src += 4;
|
|
|
|
uint32 dstData = READ_LE_UINT32(dst);
|
|
|
|
uint16 offset = 0;
|
|
|
|
|
|
|
|
offset = ((srcData & 0xFF) << 8) + (dstData & 0xFF);
|
|
|
|
*dst++ = ovl[offset];
|
|
|
|
|
|
|
|
offset = (srcData & 0xFF00) + ((dstData & 0xFF00) >> 8);
|
|
|
|
*dst++ = ovl[offset];
|
|
|
|
|
|
|
|
srcData >>= 16;
|
|
|
|
dstData >>= 16;
|
|
|
|
|
|
|
|
offset = ((srcData & 0xFF) << 8) + (dstData & 0xFF);
|
|
|
|
*dst++ = ovl[offset];
|
|
|
|
|
|
|
|
offset = (srcData & 0xFF00) + ((dstData & 0xFF00) >> 8);
|
|
|
|
*dst++ = ovl[offset];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
void Screen_LoL::fadeToBlack(int delay, const UpdateFunctor *upFunc) {
|
|
|
|
Screen::fadeToBlack(delay, upFunc);
|
|
|
|
_fadeFlag = 2;
|
|
|
|
}
|
|
|
|
|
2009-05-10 23:08:32 +00:00
|
|
|
void Screen_LoL::fadeToPalette1(int delay) {
|
2009-06-29 16:08:16 +00:00
|
|
|
loadSpecialColors(getPalette(1));
|
2009-06-22 02:36:54 +00:00
|
|
|
fadePalette(getPalette(1), delay);
|
2009-05-10 23:08:32 +00:00
|
|
|
_fadeFlag = 0;
|
|
|
|
}
|
|
|
|
|
2009-06-29 16:08:16 +00:00
|
|
|
void Screen_LoL::loadSpecialColors(Palette &dst) {
|
|
|
|
dst.copy(*_screenPalette, 192, 4);
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
void Screen_LoL::copyColor(int dstColorIndex, int srcColorIndex) {
|
2009-06-22 02:34:35 +00:00
|
|
|
uint8 *s = _screenPalette->getData() + srcColorIndex * 3;
|
|
|
|
uint8 *d = _screenPalette->getData() + dstColorIndex * 3;
|
2009-02-14 00:51:07 +00:00
|
|
|
memcpy(d, s, 3);
|
|
|
|
|
|
|
|
uint8 ci[4];
|
|
|
|
ci[0] = (d[0] << 2) | (d[0] & 3);
|
|
|
|
ci[1] = (d[1] << 2) | (d[1] & 3);
|
|
|
|
ci[2] = (d[2] << 2) | (d[2] & 3);
|
|
|
|
ci[3] = 0;
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
_system->setPalette(ci, dstColorIndex, 1);
|
2009-02-01 19:27:01 +00:00
|
|
|
}
|
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
bool Screen_LoL::fadeColor(int dstColorIndex, int srcColorIndex, uint32 elapsedTime, uint32 targetTime) {
|
2009-06-22 02:37:57 +00:00
|
|
|
const uint8 *dst = _screenPalette->getData() + 3 * dstColorIndex;
|
|
|
|
const uint8 *src = _screenPalette->getData() + 3 * srcColorIndex;
|
2009-06-22 02:35:45 +00:00
|
|
|
uint8 *p = getPalette(1).getData() + 3 * dstColorIndex;
|
2009-02-01 19:27:01 +00:00
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
int16 t1 = 0;
|
|
|
|
int16 t2 = 0;
|
2009-02-01 19:27:01 +00:00
|
|
|
int32 t3 = 0;
|
|
|
|
|
|
|
|
uint8 tmpPalEntry[3];
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
2009-02-14 00:51:07 +00:00
|
|
|
if (elapsedTime < targetTime) {
|
|
|
|
t1 = *src & 0x3f;
|
|
|
|
t2 = *dst & 0x3f;
|
2009-02-01 19:27:01 +00:00
|
|
|
|
|
|
|
t3 = t1 - t2;
|
2009-02-14 00:51:07 +00:00
|
|
|
if (t3)
|
2009-02-01 19:27:01 +00:00
|
|
|
res = true;
|
|
|
|
|
2009-02-14 00:51:07 +00:00
|
|
|
t3 = (((t3 << 8) / (int)targetTime) * (int)elapsedTime) >> 8;
|
|
|
|
t3 = t2 + t3;
|
2009-02-01 19:27:01 +00:00
|
|
|
} else {
|
2009-02-14 00:51:07 +00:00
|
|
|
t1 = *dst & 0x3f;
|
2009-02-01 19:27:01 +00:00
|
|
|
*p = t3 = t1;
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpPalEntry[i] = t3 & 0xff;
|
2009-02-14 00:51:07 +00:00
|
|
|
src++;
|
|
|
|
dst++;
|
2009-02-01 19:27:01 +00:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2009-06-22 02:37:57 +00:00
|
|
|
_internFadePalette->copy(*_screenPalette);
|
|
|
|
_internFadePalette->copy(tmpPalEntry, 0, 1, dstColorIndex);
|
|
|
|
setScreenPalette(*_internFadePalette);
|
2009-05-10 13:40:28 +00:00
|
|
|
updateScreen();
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:46:40 +00:00
|
|
|
bool Screen_LoL::fadePaletteStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 targetTime) {
|
2009-06-22 02:36:54 +00:00
|
|
|
Palette &p1 = getPalette(1);
|
2009-05-10 13:40:28 +00:00
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
for (int i = 0; i < 768; i++) {
|
|
|
|
uint8 out = 0;
|
2009-06-22 02:36:54 +00:00
|
|
|
|
2009-05-10 13:40:28 +00:00
|
|
|
if (elapsedTime < targetTime) {
|
2009-05-21 16:46:40 +00:00
|
|
|
int32 d = ((pal2[i] & 0x3f) - (pal1[i] & 0x3f));
|
2009-05-10 13:40:28 +00:00
|
|
|
if (d)
|
|
|
|
res = true;
|
|
|
|
|
2009-05-21 16:46:40 +00:00
|
|
|
int32 val = ((((d << 8) / (int32)targetTime) * (int32)elapsedTime) >> 8);
|
|
|
|
out = ((pal1[i] & 0x3f) + (int8)val);
|
2009-05-10 13:40:28 +00:00
|
|
|
} else {
|
|
|
|
out = p1[i] = (pal2[i] & 0x3f);
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
|
2009-06-22 02:37:57 +00:00
|
|
|
(*_internFadePalette)[i] = out;
|
2009-05-10 13:40:28 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 02:37:57 +00:00
|
|
|
setScreenPalette(*_internFadePalette);
|
2009-02-14 00:51:07 +00:00
|
|
|
updateScreen();
|
2009-02-01 19:27:01 +00:00
|
|
|
|
|
|
|
return res;
|
2009-01-18 17:04:24 +00:00
|
|
|
}
|
|
|
|
|
2009-06-07 00:37:30 +00:00
|
|
|
uint8 *Screen_LoL::generateFadeTable(uint8 *dst, uint8 *src1, uint8 *src2, int numTabs) {
|
|
|
|
if (!src1)
|
2009-06-22 02:34:35 +00:00
|
|
|
src1 = _screenPalette->getData();
|
2009-06-07 00:37:30 +00:00
|
|
|
|
|
|
|
uint8 *p1 = dst;
|
|
|
|
uint8 *p2 = src1;
|
|
|
|
uint8 *p3 = src2;
|
|
|
|
|
|
|
|
for (int i = 0; i < 768; i++) {
|
|
|
|
int8 val = (int8)*p3++ - (int8)*p2++;
|
|
|
|
*dst++ = (uint8)val;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 t = 0;
|
|
|
|
int16 d = 256 / numTabs;
|
2009-06-21 16:59:51 +00:00
|
|
|
|
2009-06-07 00:37:30 +00:00
|
|
|
for (int i = 1; i < numTabs - 1; i++) {
|
|
|
|
p2 = src1;
|
|
|
|
p3 = p1;
|
|
|
|
t += d;
|
|
|
|
|
|
|
|
for (int ii = 0; ii < 768; ii++) {
|
2009-06-15 20:52:09 +00:00
|
|
|
int16 val = (((int8)*p3++ * t) >> 8) + (int8)*p2++;
|
2009-06-07 00:37:30 +00:00
|
|
|
*dst++ = (uint8)val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(p1, src1, 768);
|
|
|
|
memcpy(dst, src2, 768);
|
|
|
|
|
|
|
|
dst += 768;
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2009-01-18 17:04:24 +00:00
|
|
|
uint8 Screen_LoL::getShapePaletteSize(const uint8 *shp) {
|
|
|
|
return shp[10];
|
|
|
|
}
|
|
|
|
|
2009-06-25 15:22:08 +00:00
|
|
|
void Screen_LoL::mergeOverlay(int x, int y, int w, int h) {
|
|
|
|
// For now we convert to 16 colors on overlay merging. If that gives
|
|
|
|
// any problems, like Screen functionallity not prepared for the
|
|
|
|
// format PC98 16 color uses, we'll need to think of a better way.
|
|
|
|
//
|
|
|
|
// We must do this before merging the overlay, else the font colors
|
|
|
|
// will be wrong.
|
|
|
|
if (_use16ColorMode)
|
|
|
|
convertPC98Gfx(_sjisOverlayPtrs[0] + y * 640 + x, w, h, 640);
|
|
|
|
|
|
|
|
Screen_v2::mergeOverlay(x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Screen_LoL::convertPC98Gfx(uint8 *data, int w, int h, int pitch) {
|
|
|
|
while (h--) {
|
|
|
|
for (int i = 0; i < w; ++i) {
|
|
|
|
*data = _paletteConvTable[*data];
|
|
|
|
++data;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += pitch - w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-29 18:00:18 +00:00
|
|
|
void Screen_LoL::postProcessCursor(uint8 *data, int w, int h, int pitch) {
|
2009-06-29 20:16:59 +00:00
|
|
|
if (!_use16ColorMode)
|
|
|
|
return;
|
|
|
|
|
2009-06-29 18:00:18 +00:00
|
|
|
while (h--) {
|
|
|
|
for (int i = 0; i < w; ++i) {
|
2009-06-29 18:49:17 +00:00
|
|
|
if (*data != _cursorColorKey)
|
2009-06-29 18:00:18 +00:00
|
|
|
*data = _paletteConvTable[*data];
|
|
|
|
++data;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += pitch - w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-31 10:47:15 +00:00
|
|
|
} // end of namespace Kyra
|
|
|
|
|
2009-03-04 11:53:25 +00:00
|
|
|
#endif // ENABLE_LOL
|
|
|
|
|