SCI: self drawn stuff on amiga uses ega palette, we need to match it onto currently used amiga palette (fixes user interface colors for amiga sci1 games)

svn-id: r47520
This commit is contained in:
Martin Kiewitz 2010-01-24 20:31:01 +00:00
parent 69e6b2a27a
commit b4ecf7f0e1
3 changed files with 73 additions and 29 deletions

View File

@ -176,6 +176,11 @@ int16 SciGui::priorityToCoordinate(int16 priority) {
reg_t SciGui::newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title) {
Window *wnd = NULL;
if (_s->resMan->getViewType() == kViewAmiga) {
colorPen = _palette->mapAmigaColor(colorPen);
colorBack = _palette->mapAmigaColor(colorBack);
}
if (restoreRect.top != 0 && restoreRect.left != 0 && restoreRect.height() != 0 && restoreRect.width() != 0)
wnd = _windowMgr->NewWindow(dims, &restoreRect, title, style, priority, false);
else
@ -206,7 +211,7 @@ void SciGui::disposeWindow(uint16 windowPtr, bool reanimate) {
void SciGui::display(const char *text, int argc, reg_t *argv) {
int displayArg;
TextAlignment alignment = SCI_TEXT_ALIGNMENT_LEFT;
int16 bgcolor = -1, width = -1, bRedraw = 1;
int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1;
bool doSaveUnder = false;
Common::Rect rect;
@ -231,11 +236,16 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
argc--; argv++;
break;
case SCI_DISPLAY_SETPENCOLOR:
_gfx->PenColor(argv[0].toUint16());
colorPen = argv[0].toUint16();
if (_s->resMan->getViewType() == kViewAmiga)
colorPen = _palette->mapAmigaColor(colorPen);
_gfx->PenColor(colorPen);
argc--; argv++;
break;
case SCI_DISPLAY_SETBACKGROUNDCOLOR:
bgcolor = argv[0].toUint16();
colorBack = argv[0].toUint16();
if (_s->resMan->getViewType() == kViewAmiga)
colorBack = _palette->mapAmigaColor(colorBack);
argc--; argv++;
break;
case SCI_DISPLAY_SETGREYEDOUTPUT:
@ -280,8 +290,8 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
if (doSaveUnder)
_s->r_acc = _gfx->BitsSave(rect, SCI_SCREEN_MASK_VISUAL);
if (bgcolor != -1)
_gfx->FillRect(rect, SCI_SCREEN_MASK_VISUAL, bgcolor, 0, 0);
if (colorBack != -1)
_gfx->FillRect(rect, SCI_SCREEN_MASK_VISUAL, colorBack, 0, 0);
_text->Box(text, 0, rect, alignment, -1);
if (_screen->_picNotValid == 0 && bRedraw)
_gfx->BitsShow(rect);
@ -314,6 +324,11 @@ void SciGui::textColors(int argc, reg_t *argv) {
void SciGui::drawStatus(const char *text, int16 colorPen, int16 colorBack) {
Port *oldPort = _gfx->SetPort(_gfx->_menuPort);
if (_s->resMan->getViewType() == kViewAmiga) {
colorPen = _palette->mapAmigaColor(colorPen);
colorBack = _palette->mapAmigaColor(colorBack);
}
_gfx->FillRect(_gfx->_menuBarRect, 1, colorBack);
_gfx->PenColor(colorPen);
_gfx->MoveTo(0, 1);
@ -491,17 +506,23 @@ void SciGui::graphFillBoxBackground(Common::Rect rect) {
}
void SciGui::graphFillBox(Common::Rect rect, uint16 colorMask, int16 color, int16 priority, int16 control) {
if (_s->resMan->getViewType() == kViewAmiga)
color = _palette->mapAmigaColor(color);
_gfx->FillRect(rect, colorMask, color, priority, control);
}
void SciGui::graphFrameBox(Common::Rect rect, int16 color) {
int16 oldColor = _gfx->GetPort()->penClr;
if (_s->resMan->getViewType() == kViewAmiga)
color = _palette->mapAmigaColor(color);
_gfx->PenColor(color);
_gfx->FrameRect(rect);
_gfx->PenColor(oldColor);
}
void SciGui::graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control) {
if (_s->resMan->getViewType() == kViewAmiga)
color = _palette->mapAmigaColor(color);
_gfx->OffsetLine(startPoint, endPoint);
_screen->drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, color, priority, control);
}

View File

@ -113,6 +113,24 @@ void SciPalette::createFromData(byte *data, Palette *paletteOut) {
}
}
static const byte EGApalette[16][3] = {
{ 0x000, 0x000, 0x000 },
{ 0x000, 0x000, 0x0AA },
{ 0x000, 0x0AA, 0x000 },
{ 0x000, 0x0AA, 0x0AA },
{ 0x0AA, 0x000, 0x000 },
{ 0x0AA, 0x000, 0x0AA },
{ 0x0AA, 0x055, 0x000 },
{ 0x0AA, 0x0AA, 0x0AA },
{ 0x055, 0x055, 0x055 },
{ 0x055, 0x055, 0x0FF },
{ 0x055, 0x0FF, 0x055 },
{ 0x055, 0x0FF, 0x0FF },
{ 0x0FF, 0x055, 0x055 },
{ 0x0FF, 0x055, 0x0FF },
{ 0x0FF, 0x0FF, 0x055 },
{ 0x0FF, 0x0FF, 0x0FF }
};
// Will try to set amiga palette by using "spal" file. If not found, we return false
bool SciPalette::setAmiga() {
@ -132,40 +150,42 @@ bool SciPalette::setAmiga() {
}
file.close();
setOnScreen();
// Create EGA to amiga table
for (curColor = 0; curColor < 16; curColor++) {
_amigaEGAtable[curColor] = matchColor(&_sysPalette, EGApalette[curColor][0], EGApalette[curColor][1], EGApalette[curColor][2]);
}
return true;
}
return false;
}
// On amiga the scripts send us an EGA color, we need to match it to the active amiga palette
int16 SciPalette::mapAmigaColor(int16 color) {
// TODO: not sure what pq3 means by using color 31
if (color > 15)
return color;
//color = CLIP<int16>(color, 0, 15);
return _amigaEGAtable[color];
}
void SciPalette::setEGA() {
int i;
int curColor;
byte color1, color2;
_sysPalette.colors[1].r = 0x000; _sysPalette.colors[1].g = 0x000; _sysPalette.colors[1].b = 0x0AA;
_sysPalette.colors[2].r = 0x000; _sysPalette.colors[2].g = 0x0AA; _sysPalette.colors[2].b = 0x000;
_sysPalette.colors[3].r = 0x000; _sysPalette.colors[3].g = 0x0AA; _sysPalette.colors[3].b = 0x0AA;
_sysPalette.colors[4].r = 0x0AA; _sysPalette.colors[4].g = 0x000; _sysPalette.colors[4].b = 0x000;
_sysPalette.colors[5].r = 0x0AA; _sysPalette.colors[5].g = 0x000; _sysPalette.colors[5].b = 0x0AA;
_sysPalette.colors[6].r = 0x0AA; _sysPalette.colors[6].g = 0x055; _sysPalette.colors[6].b = 0x000;
_sysPalette.colors[7].r = 0x0AA; _sysPalette.colors[7].g = 0x0AA; _sysPalette.colors[7].b = 0x0AA;
_sysPalette.colors[8].r = 0x055; _sysPalette.colors[8].g = 0x055; _sysPalette.colors[8].b = 0x055;
_sysPalette.colors[9].r = 0x055; _sysPalette.colors[9].g = 0x055; _sysPalette.colors[9].b = 0x0FF;
_sysPalette.colors[10].r = 0x055; _sysPalette.colors[10].g = 0x0FF; _sysPalette.colors[10].b = 0x055;
_sysPalette.colors[11].r = 0x055; _sysPalette.colors[11].g = 0x0FF; _sysPalette.colors[11].b = 0x0FF;
_sysPalette.colors[12].r = 0x0FF; _sysPalette.colors[12].g = 0x055; _sysPalette.colors[12].b = 0x055;
_sysPalette.colors[13].r = 0x0FF; _sysPalette.colors[13].g = 0x055; _sysPalette.colors[13].b = 0x0FF;
_sysPalette.colors[14].r = 0x0FF; _sysPalette.colors[14].g = 0x0FF; _sysPalette.colors[14].b = 0x055;
_sysPalette.colors[15].r = 0x0FF; _sysPalette.colors[15].g = 0x0FF; _sysPalette.colors[15].b = 0x0FF;
for (i = 0; i <= 15; i++) {
_sysPalette.colors[i].used = 1;
for (curColor = 0; curColor <= 15; curColor++) {
_sysPalette.colors[curColor].used = 1;
_sysPalette.colors[curColor].r = EGApalette[curColor][0];
_sysPalette.colors[curColor].g = EGApalette[curColor][1];
_sysPalette.colors[curColor].b = EGApalette[curColor][2];
}
// Now setting colors 16-254 to the correct mix colors that occur when not doing a dithering run on
// finished pictures
for (i = 0x10; i <= 0xFE; i++) {
_sysPalette.colors[i].used = 1;
color1 = i & 0x0F; color2 = i >> 4;
_sysPalette.colors[i].r = (_sysPalette.colors[color1].r >> 1) + (_sysPalette.colors[color2].r >> 1);
_sysPalette.colors[i].g = (_sysPalette.colors[color1].g >> 1) + (_sysPalette.colors[color2].g >> 1);
_sysPalette.colors[i].b = (_sysPalette.colors[color1].b >> 1) + (_sysPalette.colors[color2].b >> 1);
for (curColor = 0x10; curColor <= 0xFE; curColor++) {
_sysPalette.colors[curColor].used = curColor;
color1 = curColor & 0x0F; color2 = curColor >> 4;
_sysPalette.colors[curColor].r = (_sysPalette.colors[color1].r >> 1) + (_sysPalette.colors[color2].r >> 1);
_sysPalette.colors[curColor].g = (_sysPalette.colors[color1].g >> 1) + (_sysPalette.colors[color2].g >> 1);
_sysPalette.colors[curColor].b = (_sysPalette.colors[color1].b >> 1) + (_sysPalette.colors[color2].b >> 1);
}
setOnScreen();
}

View File

@ -38,6 +38,7 @@ public:
void createFromData(byte *data, Palette *paletteOut);
bool setAmiga();
int16 mapAmigaColor(int16 color);
void setEGA();
bool setFromResource(GuiResourceId resourceId, uint16 flag);
void set(Palette *sciPal, uint16 flag);
@ -59,6 +60,8 @@ private:
ResourceManager *_resMan;
Common::Array<PalSchedule> _schedules;
byte _amigaEGAtable[16];
};
} // End of namespace Sci