LOL/PC-98: start fixing color issues (still not working correctly though)

svn-id: r44223
This commit is contained in:
Florian Kagerer 2009-09-20 23:25:39 +00:00
parent e062a56c31
commit 4d9258d3e5
5 changed files with 89 additions and 45 deletions

View File

@ -1697,12 +1697,18 @@ void LoLEngine::setPaletteBrightness(const Palette &srcPal, int brightness, int
void LoLEngine::generateBrightnessPalette(const Palette &src, Palette &dst, int brightness, int modifier) {
dst.copy(src);
if (_flags.use16ColorMode) {
if (!(brightness && modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)))
if (!brightness)
modifier = 0;
else if (modifier < 0 || modifier > 7 || (_flagsTable[31] & 0x08))
modifier = 8;
modifier >>= 1;
if (modifier)
modifier--;
_blockBrightness = 16 * modifier;
if (modifier > 3)
modifier = 3;
_blockBrightness = modifier << 4;
_sceneUpdateRequired = true;
} else {
_screen->loadSpecialColors(dst);
@ -1743,7 +1749,6 @@ void LoLEngine::createGfxTables() {
return;
if (_flags.use16ColorMode) {
_screen->loadPalette("lol.nol", _screen->getPalette(0));
} else {
Palette tpal(256);
@ -3902,6 +3907,7 @@ void LoLEngine::displayAutomap() {
for (int i = 0; i < 109; i++)
_automapShapes[i] = _screen->getPtrToShape(shp, i + 11);
if (!_flags.use16ColorMode)
_screen->generateGrayOverlay(_screen->getPalette(3), _mapOverlay, 52, 0, 0, 0, 256, false);
_screen->loadFont(Screen::FID_9_FNT, "FONT9PN.FNT");

View File

@ -1095,7 +1095,7 @@ private:
uint16 _specialGuiShapeY;
uint16 _specialGuiShapeMirrorFlag;
char _lastSuppFile[12];
char _lastBlockDataFile[12];
char _lastOverridePalFile[12];
char *_lastOverridePalFilePtr;
int _lastSpecialColor;

View File

@ -348,7 +348,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
if (file) {
_lastSpecialColor = specialColor;
_lastSpecialColorWeight = weight;
strcpy(_lastSuppFile, file);
strcpy(_lastBlockDataFile, file);
if (palFile) {
strcpy(_lastOverridePalFile, palFile);
_lastOverridePalFilePtr = _lastOverridePalFile;
@ -359,14 +359,11 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
if (_flags.use16ColorMode) {
if (_lastSpecialColor == 0x66)
//_lastSpecialColor = stricmp(file, "YVEL2") ? 0xcc : 0x44;
_lastSpecialColor = scumm_stricmp(file, "YVEL2") ? 0xc : 0x4;
_lastSpecialColor = stricmp(file, "YVEL2") ? 0xcc : 0x44;
else if (_lastSpecialColor == 0x6b)
//_lastSpecialColor = 0xcc;
_lastSpecialColor = 0xc;
_lastSpecialColor = 0xcc;
else
//_lastSpecialColor = 0x44;
_lastSpecialColor = 0x4;
_lastSpecialColor = 0x44;
}
char fname[13];
@ -374,7 +371,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
int tlen = 0;
if (_flags.use16ColorMode) {
snprintf(fname, sizeof(fname), "%s.VCF", _lastSuppFile);
snprintf(fname, sizeof(fname), "%s.VCF", _lastBlockDataFile);
_screen->loadBitmap(fname, 3, 3, 0);
v = _screen->getCPagePtr(2);
tlen = READ_LE_UINT16(v) << 5;
@ -387,7 +384,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
memcpy(_vcfBlocks, v, tlen);
}
snprintf(fname, sizeof(fname), "%s.VCN", _lastSuppFile);
snprintf(fname, sizeof(fname), "%s.VCN", _lastBlockDataFile);
_screen->loadBitmap(fname, 3, 3, 0);
v = _screen->getCPagePtr(2);
tlen = READ_LE_UINT16(v);
@ -401,13 +398,12 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
_vcnBlocks = new uint8[vcnLen];
if (_flags.use16ColorMode) {
_screen->getPalette(0).fill(0, 16, 0xff);
_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
/*static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
Palette &pl = _screen->getPalette(0);
for (int i = 15; i >= 0; i--)
pl.copy(pl, i, 1, colTable[i]);*/
pl.copy(pl, i, 1, i);*/
} else {
if (_vcnShift)
@ -444,7 +440,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
memcpy(_vcnBlocks, v, vcnLen);
v += vcnLen;
snprintf(fname, sizeof(fname), "%s.VMP", _lastSuppFile);
snprintf(fname, sizeof(fname), "%s.VMP", _lastBlockDataFile);
_screen->loadBitmap(fname, 3, 3, 0);
v = _screen->getCPagePtr(2);
@ -464,12 +460,13 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
weight = (weight > 0) ? (weight * 255) / 100 : 0;
_screen->generateLevelOverlay(_screen->getPalette(0), _screen->getLevelOverlay(i), _lastSpecialColor, weight);
for (int ii = 0; ii < 128; ii++) {
int l = _flags.use16ColorMode ? 256 : 128;
for (int ii = 0; ii < l; ii++) {
if (_screen->getLevelOverlay(i)[ii] == 255)
_screen->getLevelOverlay(i)[ii] = 0;
}
for (int ii = 128; ii < 256; ii++)
for (int ii = l; ii < 256; ii++)
_screen->getLevelOverlay(i)[ii] = ii & 0xff;
}
@ -477,22 +474,21 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
_screen->getLevelOverlay(7)[i] = i & 0xff;
if (_flags.use16ColorMode) {
//_screen->getLevelOverlay(6)[0xee] = 0xee;
//if (_lastSpecialColor == 0x44)
// _screen->getLevelOverlay(5)[0xee] = 0xee;
_screen->getLevelOverlay(6)[0xe] = 0xe;
if (_lastSpecialColor == 0x4)
_screen->getLevelOverlay(5)[0xe] = 0xe;
_screen->getLevelOverlay(6)[0xee] = 0xee;
if (_lastSpecialColor == 0x44)
_screen->getLevelOverlay(5)[0xee] = 0xee;
for (int i = 0; i < 7; i++)
memcpy(_screen->getLevelOverlay(i), _screen->getLevelOverlay(i + 1), 256);
_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
for (int i = 0; i < 8; i++) {
uint8 *pl = _screen->getLevelOverlay(7 - i);
for (int ii = 15; ii >= 0; ii--)
_vcnExpTable[((7 - i) << 4) + ii] = pl[colTable[ii]];
for (int ii = 0; ii < 16; ii++)
_vcnExpTable[(i << 4) + ii] = pl[colTable[ii]];
}
}
@ -1496,9 +1492,13 @@ void LoLEngine::prepareSpecialScene(int fieldType, int hasDialogue, int suspendG
gui_disableControls(controlMode);
if (fadeFlag) {
if (_flags.use16ColorMode) {
setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
} else {
_screen->getPalette(3).copy(_screen->getPalette(0), 128);
_screen->loadSpecialColors(_screen->getPalette(3));
_screen->fadePalette(_screen->getPalette(3), 10);
}
_screen->_fadeFlag = 0;
}
@ -2086,10 +2086,26 @@ void LoLEngine::drawDecorations(int index) {
xOffs = _levelShapeProperties[l].shapeX[shpIx];
yOffs = _levelShapeProperties[l].shapeY[shpIx];
shpIx = _dscOvlMap[shpIx];
ovl = _screen->getLevelOverlay(ovlIndex);
int ov = ovlIndex;
if (_flags.use16ColorMode) {
uint8 bb = _blockBrightness >> 4;
if (ov > bb)
ov -= bb;
else
ov = 0;
}
ovl = _screen->getLevelOverlay(ov);
} else if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {
scaleW = scaleH = 0x100;
ovl = _screen->getLevelOverlay(7);
int ov = 7;
if (_flags.use16ColorMode) {
uint8 bb = _blockBrightness >> 4;
if (ov > bb)
ov -= bb;
else
ov = 0;
}
ovl = _screen->getLevelOverlay(ov);
}
if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {

View File

@ -165,29 +165,33 @@ uint8 *Screen_LoL::generateLevelOverlay(const Palette &srcPal, uint8 *ovl, int o
if (weight > 255)
weight = 255;
uint16 r = srcPal[opColor * 3];
uint16 g = srcPal[opColor * 3 + 1];
uint16 b = srcPal[opColor * 3 + 2];
uint8 *srt = new uint8[768];
memset(srt, 0x3f, 768);
memcpy(srt, srcPal.getData(), srcPal.getNumColors() * 3);
uint16 r = srt[opColor * 3];
uint16 g = srt[opColor * 3 + 1];
uint16 b = srt[opColor * 3 + 2];
uint8 *d = ovl;
*d++ = 0;
for (int i = 1; i != srcPal.getNumColors() - 1; i++) {
uint16 a = srcPal[i * 3];
for (int i = 1; i != 255; i++) {
uint16 a = srt[i * 3];
uint8 dr = a - ((((a - r) * (weight >> 1)) << 1) >> 8);
a = srcPal[i * 3 + 1];
a = srt[i * 3 + 1];
uint8 dg = a - ((((a - g) * (weight >> 1)) << 1) >> 8);
a = srcPal[i * 3 + 2];
a = srt[i * 3 + 2];
uint8 db = a - ((((a - b) * (weight >> 1)) << 1) >> 8);
int l = opColor;
int m = 0x7fff;
int ii = 127;
int m = _use16ColorMode ? 0xffff : 0x7fff;
int ii = _use16ColorMode ? 255 : 127;
int x = 1;
const uint8 *s = srcPal.getData() + 3;
const uint8 *s = srt + 3;
do {
if (i == x) {
if (!_use16ColorMode && i == x) {
s += 3;
} else {
int t = *s++ - dr;
@ -203,16 +207,19 @@ uint8 *Screen_LoL::generateLevelOverlay(const Palette &srcPal, uint8 *ovl, int o
}
if (c <= m) {
if (!_use16ColorMode || x != opColor && i != x) {
m = c;
l = x;
}
}
}
x++;
} while (--ii);
*d++ = l & 0xff;
}
delete []srt;
return ovl;
}

View File

@ -940,6 +940,14 @@ void LoLEngine::drawDoor(uint8 *shape, uint8 *table, int index, int unk2, int w,
if (d > 7)
d = 7;
if (_flags.use16ColorMode) {
uint8 bb = _blockBrightness >> 4;
if (d > bb)
d -= bb;
else
d = 0;
}
uint8 *ovl = _screen->getLevelOverlay(d);
int doorScaledWitdh = _screen->getShapeScaledWidth(shape, _dmScaleW);
@ -992,6 +1000,13 @@ uint8 *LoLEngine::drawItemOrMonster(uint8 *shape, uint8 *table, int x, int y, in
if (tblValue == -1) {
r = 7 - ((r / 3) - 1);
r = CLIP(r, 0, 7);
if (_flags.use16ColorMode) {
uint8 bb = _blockBrightness >> 4;
if (r > bb)
r -= bb;
else
r = 0;
}
ovl = _screen->getLevelOverlay(r);
} else {
memset(tmpOvl + 1, tblValue, 15);