[Scummvm-cvs-logs] SF.net SVN: scummvm:[47745] scummvm/trunk/engines/sci
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Sun Jan 31 13:35:19 CET 2010
Revision: 47745
http://scummvm.svn.sourceforge.net/scummvm/?rev=47745&view=rev
Author: m_kiewitz
Date: 2010-01-31 12:35:15 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
SCI: cleaned up graphics classes, removed gfx&windowmgr, added gfxports, gfxcompare, gfxpaint16, gfxcache. kernel uses gfxports directly w/o going through SciGui
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/state.h
scummvm/trunk/engines/sci/graphics/animate.cpp
scummvm/trunk/engines/sci/graphics/animate.h
scummvm/trunk/engines/sci/graphics/controls.cpp
scummvm/trunk/engines/sci/graphics/controls.h
scummvm/trunk/engines/sci/graphics/gui.cpp
scummvm/trunk/engines/sci/graphics/gui.h
scummvm/trunk/engines/sci/graphics/gui32.cpp
scummvm/trunk/engines/sci/graphics/gui32.h
scummvm/trunk/engines/sci/graphics/menu.cpp
scummvm/trunk/engines/sci/graphics/menu.h
scummvm/trunk/engines/sci/graphics/picture.cpp
scummvm/trunk/engines/sci/graphics/picture.h
scummvm/trunk/engines/sci/graphics/robot.cpp
scummvm/trunk/engines/sci/graphics/text.cpp
scummvm/trunk/engines/sci/graphics/text.h
scummvm/trunk/engines/sci/graphics/view.cpp
scummvm/trunk/engines/sci/graphics/view.h
scummvm/trunk/engines/sci/sci.cpp
Added Paths:
-----------
scummvm/trunk/engines/sci/graphics/cache.cpp
scummvm/trunk/engines/sci/graphics/cache.h
scummvm/trunk/engines/sci/graphics/compare.cpp
scummvm/trunk/engines/sci/graphics/compare.h
scummvm/trunk/engines/sci/graphics/paint16.cpp
scummvm/trunk/engines/sci/graphics/paint16.h
scummvm/trunk/engines/sci/graphics/ports.cpp
scummvm/trunk/engines/sci/graphics/ports.h
Removed Paths:
-------------
scummvm/trunk/engines/sci/graphics/gfx.cpp
scummvm/trunk/engines/sci/graphics/gfx.h
scummvm/trunk/engines/sci/graphics/windowmgr.cpp
scummvm/trunk/engines/sci/graphics/windowmgr.h
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -36,6 +36,7 @@
#include "sci/engine/kernel.h"
#include "sci/graphics/gui.h"
#include "sci/graphics/gui32.h"
+#include "sci/graphics/ports.h"
#include "sci/graphics/animate.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/screen.h"
@@ -991,19 +992,19 @@
}
reg_t kGetPort(EngineState *s, int argc, reg_t *argv) {
- return s->_gui->getPort();
+ return s->_gfxPorts->kernelGetActive();
}
reg_t kSetPort(EngineState *s, int argc, reg_t *argv) {
- uint16 portPtr;
+ uint16 portId;
Common::Rect picRect;
int16 picTop, picLeft;
bool initPriorityBandsFlag = false;
switch (argc) {
case 1:
- portPtr = argv[0].toSint16();
- s->_gui->setPort(portPtr);
+ portId = argv[0].toSint16();
+ s->_gfxPorts->kernelSetActive(portId);
break;
case 7:
@@ -1016,7 +1017,7 @@
picRect.right = argv[3].toSint16();
picTop = (argc >= 6) ? argv[4].toSint16() : 0;
picLeft = (argc >= 6) ? argv[5].toSint16() : 0;
- s->_gui->setPortPic(picRect, picTop, picLeft, initPriorityBandsFlag);
+ s->_gfxPorts->kernelSetPicWindow(picRect, picTop, picLeft, initPriorityBandsFlag);
break;
default:
@@ -1061,12 +1062,12 @@
}
reg_t kDisposeWindow(EngineState *s, int argc, reg_t *argv) {
- int goner_nr = argv[0].toSint16();
+ int windowId = argv[0].toSint16();
bool reanimate = false;
if ((argc != 2) || (argv[1].isNull()))
reanimate = true;
- s->_gui->disposeWindow(goner_nr, reanimate);
+ s->_gfxPorts->kernelDisposeWindow(windowId, reanimate);
return s->r_acc;
}
@@ -1090,7 +1091,7 @@
title = s->strSplit(title.c_str(), NULL);
}
- return s->_gui->newWindow(rect1, rect2, style, priority, colorPen, colorBack, title.c_str());
+ return s->_gfxPorts->kernelNewWindow(rect1, rect2, style, priority, colorPen, colorBack, title.c_str());
}
reg_t kAnimate(EngineState *s, int argc, reg_t *argv) {
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -38,6 +38,7 @@
#include "sci/engine/vm_types.h"
#include "sci/engine/script.h" // for SCI_OBJ_EXPORTS and SCI_OBJ_SYNONYMS
#include "sci/graphics/gui.h"
+#include "sci/graphics/ports.h"
#include "sci/sound/audio.h"
#ifdef USE_OLD_MUSIC_FUNCTIONS
#include "sci/sound/iterator/core.h"
@@ -366,7 +367,7 @@
Common::Rect picPortRect;
if (s.isSaving())
- picPortRect = _gui->getPortPic(picPortTop, picPortLeft);
+ picPortRect = _gfxPorts->kernelGetPicWindow(picPortTop, picPortLeft);
s.syncAsSint16LE(picPortRect.top);
s.syncAsSint16LE(picPortRect.left);
Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/engine/state.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -51,6 +51,7 @@
class SciEvent;
class Menubar;
+class GfxPorts;
class SciGui;
class Cursor;
class MessageState;
@@ -147,6 +148,7 @@
/* Non-VM information */
+ GfxPorts *_gfxPorts; // Port managment for 16-bit gui
SciGui *_gui; /* Currently active Gui */
#ifdef ENABLE_SCI32
Modified: scummvm/trunk/engines/sci/graphics/animate.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/animate.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/animate.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -31,7 +31,9 @@
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
#include "sci/engine/vm.h"
-#include "sci/graphics/gfx.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
#include "sci/graphics/view.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/transitions.h"
@@ -39,8 +41,8 @@
namespace Sci {
-SciGuiAnimate::SciGuiAnimate(EngineState *state, Gfx *gfx, Screen *screen, SciPalette *palette)
- : _s(state), _gfx(gfx), _screen(screen), _palette(palette) {
+SciGuiAnimate::SciGuiAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette)
+ : _s(state), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen), _palette(palette) {
init();
}
@@ -211,7 +213,7 @@
curObject = listEntry->object;
// Get the corresponding view
- view = _gfx->getView(listEntry->viewId);
+ view = _cache->getView(listEntry->viewId);
// adjust loop and cel, if any of those is invalid
if (listEntry->loopNo >= view->getLoopCount()) {
@@ -238,7 +240,7 @@
// Calculate current priority according to y-coordinate
if (!(signal & kSignalFixedPriority)) {
- listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+ listEntry->priority = _ports->coordinateToPriority(listEntry->y);
PUT_SEL32V(_s->_segMan, curObject, priority, listEntry->priority);
}
@@ -281,10 +283,10 @@
if (!(signal & kSignalRemoveView)) {
bitsHandle = GET_SEL32(_s->_segMan, curObject, underBits);
if (_screen->_picNotValid != 1) {
- _gfx->BitsRestore(bitsHandle);
+ _paint16->bitsRestore(bitsHandle);
listEntry->showBitsFlag = true;
} else {
- _gfx->BitsFree(bitsHandle);
+ _paint16->bitsFree(bitsHandle);
}
PUT_SEL32V(_s->_segMan, curObject, underBits, 0);
}
@@ -306,14 +308,14 @@
if (signal & kSignalAlwaysUpdate) {
// draw corresponding cel
- _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
+ _paint16->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
listEntry->showBitsFlag = true;
signal &= 0xFFFF ^ (kSignalStopUpdate | kSignalViewUpdated | kSignalNoUpdate | kSignalForceUpdate);
if ((signal & kSignalIgnoreActor) == 0) {
rect = listEntry->celRect;
- rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
- _gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ rect.top = CLIP<int16>(_ports->priorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
+ _paint16->fillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
}
listEntry->signal = signal;
}
@@ -333,9 +335,9 @@
} else {
signal &= 0xFFFF ^ kSignalRemoveView;
if (signal & kSignalIgnoreActor)
- bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+ bitsHandle = _paint16->bitsSave(listEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
else
- bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+ bitsHandle = _paint16->bitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
PUT_SEL32(_s->_segMan, curObject, underBits, bitsHandle);
}
listEntry->signal = signal;
@@ -352,13 +354,13 @@
if (signal & kSignalNoUpdate && !(signal & kSignalHidden)) {
// draw corresponding cel
- _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
+ _paint16->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
listEntry->showBitsFlag = true;
if ((signal & kSignalIgnoreActor) == 0) {
rect = listEntry->celRect;
- rect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
- _gfx->FillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ rect.top = CLIP<int16>(_ports->priorityToCoordinate(listEntry->priority) - 1, rect.top, rect.bottom - 1);
+ _paint16->fillRect(rect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
}
}
listIterator++;
@@ -383,11 +385,11 @@
if (!(signal & (kSignalNoUpdate | kSignalHidden | kSignalAlwaysUpdate))) {
// Save background
- bitsHandle = _gfx->BitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
+ bitsHandle = _paint16->bitsSave(listEntry->celRect, SCI_SCREEN_MASK_ALL);
PUT_SEL32(_s->_segMan, curObject, underBits, bitsHandle);
// draw corresponding cel
- _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
+ _paint16->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo, listEntry->scaleX, listEntry->scaleY);
listEntry->showBitsFlag = true;
if (signal & kSignalRemoveView) {
@@ -432,14 +434,14 @@
workerRect = lsRect;
workerRect.extend(listEntry->celRect);
} else {
- _gfx->BitsShow(lsRect);
+ _paint16->bitsShow(lsRect);
workerRect = listEntry->celRect;
}
PUT_SEL32V(_s->_segMan, curObject, lsLeft, workerRect.left);
PUT_SEL32V(_s->_segMan, curObject, lsTop, workerRect.top);
PUT_SEL32V(_s->_segMan, curObject, lsRight, workerRect.right);
PUT_SEL32V(_s->_segMan, curObject, lsBottom, workerRect.bottom);
- _gfx->BitsShow(workerRect);
+ _paint16->bitsShow(workerRect);
if (signal & kSignalHidden) {
listEntry->signal |= kSignalRemoveView;
@@ -481,7 +483,7 @@
signal = GET_SEL32V(_s->_segMan, curObject, signal);
if ((signal & (kSignalNoUpdate | kSignalRemoveView)) == 0) {
- _gfx->BitsRestore(GET_SEL32(_s->_segMan, curObject, underBits));
+ _paint16->bitsRestore(GET_SEL32(_s->_segMan, curObject, underBits));
PUT_SEL32V(_s->_segMan, curObject, underBits, 0);
}
@@ -501,20 +503,20 @@
lastCastEntry = _lastCastData;
lastCastCount = _lastCastCount;
while (lastCastCount > 0) {
- lastCastEntry->castHandle = _gfx->BitsSave(lastCastEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
- _gfx->drawCel(lastCastEntry->viewId, lastCastEntry->loopNo, lastCastEntry->celNo, lastCastEntry->celRect, lastCastEntry->priority, lastCastEntry->paletteNo, lastCastEntry->scaleX, lastCastEntry->scaleY);
+ lastCastEntry->castHandle = _paint16->bitsSave(lastCastEntry->celRect, SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY);
+ _paint16->drawCel(lastCastEntry->viewId, lastCastEntry->loopNo, lastCastEntry->celNo, lastCastEntry->celRect, lastCastEntry->priority, lastCastEntry->paletteNo, lastCastEntry->scaleX, lastCastEntry->scaleY);
lastCastEntry++; lastCastCount--;
}
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
// restoring
lastCastCount = _lastCastCount;
while (lastCastCount > 0) {
lastCastEntry--;
- _gfx->BitsRestore(lastCastEntry->castHandle);
+ _paint16->bitsRestore(lastCastEntry->castHandle);
lastCastCount--;
}
} else {
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
}
/*
@@ -553,19 +555,19 @@
curObject = listEntry->object;
if (listEntry->priority == -1)
- listEntry->priority = _gfx->CoordinateToPriority(listEntry->y);
+ listEntry->priority = _ports->coordinateToPriority(listEntry->y);
// Get the corresponding view
- view = _gfx->getView(listEntry->viewId);
+ view = _cache->getView(listEntry->viewId);
// Create rect according to coordinates and given cel
view->getCelRect(listEntry->loopNo, listEntry->celNo, listEntry->x, listEntry->y, listEntry->z, &listEntry->celRect);
// draw corresponding cel
- _gfx->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
+ _paint16->drawCel(listEntry->viewId, listEntry->loopNo, listEntry->celNo, listEntry->celRect, listEntry->priority, listEntry->paletteNo);
if ((listEntry->signal & kSignalIgnoreActor) == 0) {
- listEntry->celRect.top = CLIP<int16>(_gfx->PriorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
- _gfx->FillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
+ listEntry->celRect.top = CLIP<int16>(_ports->priorityToCoordinate(listEntry->priority) - 1, listEntry->celRect.top, listEntry->celRect.bottom - 1);
+ _paint16->fillRect(listEntry->celRect, SCI_SCREEN_MASK_CONTROL, 0, 0, 15);
}
listIterator++;
@@ -573,12 +575,12 @@
}
void SciGuiAnimate::addToPicDrawView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
- View *view = _gfx->getView(viewId);
+ View *view = _cache->getView(viewId);
Common::Rect celRect;
// Create rect according to coordinates and given cel
view->getCelRect(loopNo, celNo, leftPos, topPos, priority, &celRect);
- _gfx->drawCel(view, loopNo, celNo, celRect, priority, 0);
+ _paint16->drawCel(view, loopNo, celNo, celRect, priority, 0);
}
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/graphics/animate.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/animate.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/animate.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -56,13 +56,15 @@
kScaleSignalUnknown2 = 0x0004 // really unknown
};
-class Gfx;
+class GfxCache;
+class GfxPorts;
+class GfxPaint16;
class Screen;
class SciPalette;
class Transitions;
class SciGuiAnimate {
public:
- SciGuiAnimate(EngineState *state, Gfx *gfx, Screen *screen, SciPalette *palette);
+ SciGuiAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette);
~SciGuiAnimate();
// FIXME: Don't store EngineState
@@ -86,7 +88,9 @@
void init();
EngineState *_s;
- Gfx *_gfx;
+ GfxCache *_cache;
+ GfxPorts *_ports;
+ GfxPaint16 *_paint16;
Screen *_screen;
SciPalette *_palette;
Copied: scummvm/trunk/engines/sci/graphics/cache.cpp (from rev 47705, scummvm/trunk/engines/sci/graphics/gfx.cpp)
===================================================================
--- scummvm/trunk/engines/sci/graphics/cache.cpp (rev 0)
+++ scummvm/trunk/engines/sci/graphics/cache.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -0,0 +1,66 @@
+/* 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$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/font.h"
+#include "sci/graphics/view.h"
+
+namespace Sci {
+
+GfxCache::GfxCache(ResourceManager *resMan, Screen *screen, SciPalette *palette)
+ : _resMan(resMan), _screen(screen), _palette(palette) {
+}
+
+GfxCache::~GfxCache() {
+ purgeCache();
+}
+
+void GfxCache::purgeCache() {
+ for (ViewCache::iterator iter = _cachedViews.begin(); iter != _cachedViews.end(); ++iter) {
+ delete iter->_value;
+ iter->_value = 0;
+ }
+
+ _cachedViews.clear();
+}
+
+View *GfxCache::getView(GuiResourceId viewNum) {
+ if (_cachedViews.size() >= MAX_CACHED_VIEWS)
+ purgeCache();
+
+ if (!_cachedViews.contains(viewNum))
+ _cachedViews[viewNum] = new View(_resMan, _screen, _palette, viewNum);
+
+ return _cachedViews[viewNum];
+}
+
+} // End of namespace Sci
Copied: scummvm/trunk/engines/sci/graphics/cache.h (from rev 47705, scummvm/trunk/engines/sci/graphics/gfx.h)
===================================================================
--- scummvm/trunk/engines/sci/graphics/cache.h (rev 0)
+++ scummvm/trunk/engines/sci/graphics/cache.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -0,0 +1,59 @@
+/* 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$
+ *
+ */
+
+#ifndef SCI_GRAPHICS_CACHE_H
+#define SCI_GRAPHICS_CACHE_H
+
+#include "sci/graphics/gui.h"
+
+#include "common/hashmap.h"
+
+namespace Sci {
+
+class Font;
+class View;
+
+typedef Common::HashMap<int, View *> ViewCache;
+
+class GfxCache {
+public:
+ GfxCache(ResourceManager *resMan, Screen *screen, SciPalette *palette);
+ ~GfxCache();
+
+ View *getView(GuiResourceId viewNum);
+
+private:
+ void purgeCache();
+
+ ResourceManager *_resMan;
+ Screen *_screen;
+ SciPalette *_palette;
+
+ ViewCache _cachedViews;
+};
+
+} // End of namespace Sci
+
+#endif
Copied: scummvm/trunk/engines/sci/graphics/compare.cpp (from rev 47744, scummvm/trunk/engines/sci/graphics/gfx.cpp)
===================================================================
--- scummvm/trunk/engines/sci/graphics/compare.cpp (rev 0)
+++ scummvm/trunk/engines/sci/graphics/compare.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -0,0 +1,131 @@
+/* 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$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
+#include "sci/graphics/compare.h"
+#include "sci/graphics/animate.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/screen.h"
+#include "sci/graphics/view.h"
+
+namespace Sci {
+
+GfxCompare::GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, Screen *screen)
+ : _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen) {
+}
+
+GfxCompare::~GfxCompare() {
+}
+
+uint16 GfxCompare::onControl(uint16 screenMask, Common::Rect rect) {
+ int16 x, y;
+ uint16 result = 0;
+
+ if (rect.isEmpty())
+ return 0;
+
+ if (screenMask & SCI_SCREEN_MASK_PRIORITY) {
+ for (y = rect.top; y < rect.bottom; y++) {
+ for (x = rect.left; x < rect.right; x++) {
+ result |= 1 << _screen->getPriority(x, y);
+ }
+ }
+ } else {
+ for (y = rect.top; y < rect.bottom; y++) {
+ for (x = rect.left; x < rect.right; x++) {
+ result |= 1 << _screen->getControl(x, y);
+ }
+ }
+ }
+ return result;
+}
+
+static inline int sign_extend_byte(int value) {
+ if (value & 0x80)
+ return value - 256;
+ else
+ return value;
+}
+
+bool GfxCompare::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) {
+ reg_t curAddress = list->first;
+ Node *curNode = _segMan->lookupNode(curAddress);
+ reg_t curObject;
+ uint16 signal;
+ Common::Rect curRect;
+
+ while (curNode) {
+ curObject = curNode->value;
+ if (curObject != checkObject) {
+ signal = GET_SEL32V(_segMan, curObject, signal);
+ if ((signal & (kSignalIgnoreActor | kSignalRemoveView | kSignalNoUpdate)) == 0) {
+ curRect.left = GET_SEL32V(_segMan, curObject, brLeft);
+ curRect.top = GET_SEL32V(_segMan, curObject, brTop);
+ curRect.right = GET_SEL32V(_segMan, curObject, brRight);
+ curRect.bottom = GET_SEL32V(_segMan, curObject, brBottom);
+ // Check if curRect is within checkRect
+ if (curRect.right > checkRect.left && curRect.left < checkRect.right && curRect.bottom > checkRect.top && curRect.top < checkRect.bottom) {
+ return false;
+ }
+ }
+ }
+ curAddress = curNode->succ;
+ curNode = _segMan->lookupNode(curAddress);
+ }
+ return true;
+}
+
+void GfxCompare::SetNowSeen(reg_t objectReference) {
+ View *view = NULL;
+ Common::Rect celRect(0, 0);
+ GuiResourceId viewId = (GuiResourceId)GET_SEL32V(_segMan, objectReference, view);
+ int16 loopNo = sign_extend_byte((int16)GET_SEL32V(_segMan, objectReference, loop));
+ int16 celNo = sign_extend_byte((int16)GET_SEL32V(_segMan, objectReference, cel));
+ int16 x = (int16)GET_SEL32V(_segMan, objectReference, x);
+ int16 y = (int16)GET_SEL32V(_segMan, objectReference, y);
+ int16 z = 0;
+ if (_kernel->_selectorCache.z > -1)
+ z = (int16)GET_SEL32V(_segMan, objectReference, z);
+
+ // now get cel rectangle
+ view = _cache->getView(viewId);
+ view->getCelRect(loopNo, celNo, x, y, z, &celRect);
+
+ // TODO: sometimes loop is negative. Check what it means
+ if (lookup_selector(_segMan, objectReference, _kernel->_selectorCache.nsTop, NULL, NULL) == kSelectorVariable) {
+ PUT_SEL32V(_segMan, objectReference, nsLeft, celRect.left);
+ PUT_SEL32V(_segMan, objectReference, nsRight, celRect.right);
+ PUT_SEL32V(_segMan, objectReference, nsTop, celRect.top);
+ PUT_SEL32V(_segMan, objectReference, nsBottom, celRect.bottom);
+ }
+}
+
+} // End of namespace Sci
Copied: scummvm/trunk/engines/sci/graphics/compare.h (from rev 47744, scummvm/trunk/engines/sci/graphics/gfx.h)
===================================================================
--- scummvm/trunk/engines/sci/graphics/compare.h (rev 0)
+++ scummvm/trunk/engines/sci/graphics/compare.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -0,0 +1,55 @@
+/* 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$
+ *
+ */
+
+#ifndef SCI_GRAPHICS_GFX_H
+#define SCI_GRAPHICS_GFX_H
+
+#include "sci/graphics/gui.h"
+
+#include "common/hashmap.h"
+
+namespace Sci {
+
+class Screen;
+
+class GfxCompare {
+public:
+ GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, Screen *screen);
+ ~GfxCompare();
+
+ uint16 onControl(uint16 screenMask, Common::Rect rect);
+ bool CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list);
+ void SetNowSeen(reg_t objectReference);
+
+private:
+ SegManager *_segMan;
+ Kernel *_kernel;
+ GfxCache *_cache;
+ Screen *_screen;
+};
+
+} // End of namespace Sci
+
+#endif
Modified: scummvm/trunk/engines/sci/graphics/controls.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/controls.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/controls.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -31,15 +31,16 @@
#include "sci/event.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
-#include "sci/graphics/gfx.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
#include "sci/graphics/font.h"
#include "sci/graphics/text.h"
#include "sci/graphics/controls.h"
namespace Sci {
-Controls::Controls(SegManager *segMan, Gfx *gfx, Text *text)
- : _segMan(segMan), _gfx(gfx), _text(text) {
+Controls::Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, Text *text)
+ : _segMan(segMan), _ports(ports), _paint16(paint16), _text(text) {
init();
}
@@ -56,7 +57,7 @@
void Controls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias) {
Common::Rect workerRect = rect;
GuiResourceId oldFontId = _text->GetFontId();
- int16 oldPenColor = _gfx->_curPort->penClr;
+ int16 oldPenColor = _ports->_curPort->penClr;
uint16 fontSize = 0;
int16 i;
const char *listEntry;
@@ -64,9 +65,9 @@
int16 lastYpos;
// draw basic window
- _gfx->EraseRect(workerRect);
+ _paint16->eraseRect(workerRect);
workerRect.grow(1);
- _gfx->FrameRect(workerRect);
+ _paint16->frameRect(workerRect);
// draw UP/DOWN arrows
// we draw UP arrow one pixel lower than sierra did, because it looks nicer. Also the DOWN arrow has one pixel
@@ -79,25 +80,25 @@
// Draw inner lines
workerRect.top = rect.top + 9;
workerRect.bottom -= 10;
- _gfx->FrameRect(workerRect);
+ _paint16->frameRect(workerRect);
workerRect.grow(-1);
_text->SetFont(fontId);
- fontSize = _gfx->_curPort->fontHeight;
- _gfx->PenColor(_gfx->_curPort->penClr); _gfx->BackColor(_gfx->_curPort->backClr);
+ fontSize = _ports->_curPort->fontHeight;
+ _ports->penColor(_ports->_curPort->penClr); _ports->backColor(_ports->_curPort->backClr);
workerRect.bottom = workerRect.top + 9;
lastYpos = rect.bottom - fontSize;
// Write actual text
for (i = upperPos; i < count; i++) {
- _gfx->EraseRect(workerRect);
+ _paint16->eraseRect(workerRect);
listEntry = entries[i];
if (listEntry[0]) {
- _gfx->MoveTo(workerRect.left, workerRect.top);
+ _ports->moveTo(workerRect.left, workerRect.top);
listEntryLen = strlen(listEntry);
_text->Draw(listEntry, 0, MIN(maxChars, listEntryLen), oldFontId, oldPenColor);
if ((!isAlias) && (i == cursorPos)) {
- _gfx->InvertRect(workerRect);
+ _paint16->invertRect(workerRect);
}
}
workerRect.translate(0, fontSize);
@@ -119,8 +120,8 @@
_texteditCursorRect.top = rect.top;
_texteditCursorRect.bottom = _texteditCursorRect.top + _text->_font->getHeight();
_texteditCursorRect.right = _texteditCursorRect.left + (text[curPos] == 0 ? 1 : _text->_font->getCharWidth(text[curPos]));
- _gfx->InvertRect(_texteditCursorRect);
- _gfx->BitsShow(_texteditCursorRect);
+ _paint16->invertRect(_texteditCursorRect);
+ _paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = true;
TexteditSetBlinkTime();
}
@@ -128,8 +129,8 @@
void Controls::TexteditCursorErase() {
if (_texteditCursorVisible) {
- _gfx->InvertRect(_texteditCursorRect);
- _gfx->BitsShow(_texteditCursorRect);
+ _paint16->invertRect(_texteditCursorRect);
+ _paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = false;
}
TexteditSetBlinkTime();
@@ -209,9 +210,9 @@
rect = Common::Rect(GET_SEL32V(_segMan, controlObject, nsLeft), GET_SEL32V(_segMan, controlObject, nsTop),
GET_SEL32V(_segMan, controlObject, nsRight), GET_SEL32V(_segMan, controlObject, nsBottom));
TexteditCursorErase();
- _gfx->EraseRect(rect);
+ _paint16->eraseRect(rect);
_text->Box(text.c_str(), 0, rect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
_text->SetFont(fontId);
TexteditCursorDraw(rect, text.c_str(), cursorPos);
_text->SetFont(oldFontId);
@@ -219,8 +220,8 @@
_segMan->strcpy(textReference, text.c_str());
} else {
if (g_system->getMillis() >= _texteditBlinkTime) {
- _gfx->InvertRect(_texteditCursorRect);
- _gfx->BitsShow(_texteditCursorRect);
+ _paint16->invertRect(_texteditCursorRect);
+ _paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = !_texteditCursorVisible;
TexteditSetBlinkTime();
}
Modified: scummvm/trunk/engines/sci/graphics/controls.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/controls.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/controls.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -28,12 +28,13 @@
namespace Sci {
-class Gfx;
+class GfxPorts;
+class GfxPaint16;
class Font;
class Text;
class Controls {
public:
- Controls(SegManager *segMan, Gfx *gfx, Text *text);
+ Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, Text *text);
~Controls();
void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias);
@@ -46,7 +47,8 @@
void TexteditSetBlinkTime();
SegManager *_segMan;
- Gfx *_gfx;
+ GfxPorts *_ports;
+ GfxPaint16 *_paint16;
Text *_text;
// Textedit-Control related
Deleted: scummvm/trunk/engines/sci/graphics/gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gfx.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gfx.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -1,613 +0,0 @@
-/* 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$
- *
- */
-
-#include "common/util.h"
-#include "common/stack.h"
-#include "graphics/primitives.h"
-
-#include "sci/sci.h"
-#include "sci/engine/state.h"
-#include "sci/engine/selector.h"
-#include "sci/graphics/gfx.h"
-#include "sci/graphics/animate.h"
-#include "sci/graphics/font.h"
-#include "sci/graphics/picture.h"
-#include "sci/graphics/view.h"
-#include "sci/graphics/screen.h"
-#include "sci/graphics/palette.h"
-#include "sci/graphics/text.h"
-
-namespace Sci {
-
-Gfx::Gfx(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, Screen *screen, SciPalette *palette)
- : _resMan(resMan), _segMan(segMan), _kernel(kernel), _screen(screen), _palette(palette) {
-}
-
-Gfx::~Gfx() {
- purgeCache();
-
- delete _mainPort;
- delete _menuPort;
-}
-
-void Gfx::init(Text *text) {
- _text = text;
-
- // _mainPort is not known to windowmanager, that's okay according to sierra sci
- // its not even used currently in our engine
- _mainPort = new Port(0);
- SetPort(_mainPort);
- OpenPort(_mainPort);
-
- // _menuPort has actually hardcoded id 0xFFFF. Its not meant to be known to windowmanager according to sierra sci
- _menuPort = new Port(0xFFFF);
- OpenPort(_menuPort);
- _text->SetFont(0);
- _menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight());
- _menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9);
- _menuRect = Common::Rect(0, 0, _screen->getWidth(), 10);
- _menuLine = Common::Rect(0, 9, _screen->getWidth(), 10);
-
- _EGAdrawingVisualize = false;
-
- priorityBandsMemoryActive = false;
-}
-
-void Gfx::purgeCache() {
- for (ViewCache::iterator iter = _cachedViews.begin(); iter != _cachedViews.end(); ++iter) {
- delete iter->_value;
- iter->_value = 0;
- }
-
- _cachedViews.clear();
-}
-
-View *Gfx::getView(GuiResourceId viewNum) {
- if (_cachedViews.size() >= MAX_CACHED_VIEWS)
- purgeCache();
-
- if (!_cachedViews.contains(viewNum))
- _cachedViews[viewNum] = new View(_resMan, _screen, _palette, viewNum);
-
- return _cachedViews[viewNum];
-}
-
-Port *Gfx::SetPort(Port *newPort) {
- Port *oldPort = _curPort;
- _curPort = newPort;
- return oldPort;
-}
-
-Port *Gfx::GetPort() {
- return _curPort;
-}
-
-void Gfx::SetOrigin(int16 left, int16 top) {
- _curPort->left = left;
- _curPort->top = top;
-}
-
-void Gfx::MoveTo(int16 left, int16 top) {
- _curPort->curTop = top;
- _curPort->curLeft = left;
-}
-
-void Gfx::Move(int16 left, int16 top) {
- _curPort->curTop += top;
- _curPort->curLeft += left;
-}
-
-void Gfx::OpenPort(Port *port) {
- port->fontId = 0;
- port->fontHeight = 8;
-
- Port *tmp = _curPort;
- _curPort = port;
- _text->SetFont(port->fontId);
- _curPort = tmp;
-
- port->top = 0;
- port->left = 0;
- port->greyedOutput = false;
- port->penClr = 0;
- port->backClr = 255;
- port->penMode = 0;
- port->rect = _bounds;
-}
-
-void Gfx::PenColor(int16 color) {
- _curPort->penClr = color;
-}
-
-void Gfx::BackColor(int16 color) {
- _curPort->backClr = color;
-}
-
-void Gfx::PenMode(int16 mode) {
- _curPort->penMode = mode;
-}
-
-void Gfx::TextGreyedOutput(bool state) {
- _curPort->greyedOutput = state;
-}
-
-int16 Gfx::GetPointSize() {
- return _curPort->fontHeight;
-}
-
-void Gfx::ClearScreen(byte color) {
- FillRect(_curPort->rect, SCI_SCREEN_MASK_ALL, color, 0, 0);
-}
-
-void Gfx::InvertRect(const Common::Rect &rect) {
- int16 oldpenmode = _curPort->penMode;
- _curPort->penMode = 2;
- FillRect(rect, 1, _curPort->penClr, _curPort->backClr);
- _curPort->penMode = oldpenmode;
-}
-
-void Gfx::EraseRect(const Common::Rect &rect) {
- FillRect(rect, 1, _curPort->backClr);
-}
-
-void Gfx::PaintRect(const Common::Rect &rect) {
- FillRect(rect, 1, _curPort->penClr);
-}
-
-void Gfx::FillRect(const Common::Rect &rect, int16 drawFlags, byte clrPen, byte clrBack, byte bControl) {
- Common::Rect r = rect;
- r.clip(_curPort->rect);
- if (r.isEmpty()) // nothing to fill
- return;
-
- int16 oldPenMode = _curPort->penMode;
- OffsetRect(r);
- int16 x, y;
- byte curVisual;
-
- // Doing visual first
- if (drawFlags & SCI_SCREEN_MASK_VISUAL) {
- if (oldPenMode == 2) { // invert mode
- for (y = r.top; y < r.bottom; y++) {
- for (x = r.left; x < r.right; x++) {
- curVisual = _screen->getVisual(x, y);
- if (curVisual == clrPen) {
- _screen->putPixel(x, y, 1, clrBack, 0, 0);
- } else if (curVisual == clrBack) {
- _screen->putPixel(x, y, 1, clrPen, 0, 0);
- }
- }
- }
- } else { // just fill rect with ClrPen
- for (y = r.top; y < r.bottom; y++) {
- for (x = r.left; x < r.right; x++) {
- _screen->putPixel(x, y, 1, clrPen, 0, 0);
- }
- }
- }
- }
-
- if (drawFlags < 2)
- return;
- drawFlags &= SCI_SCREEN_MASK_PRIORITY|SCI_SCREEN_MASK_CONTROL;
-
- if (oldPenMode != 2) {
- for (y = r.top; y < r.bottom; y++) {
- for (x = r.left; x < r.right; x++) {
- _screen->putPixel(x, y, drawFlags, 0, clrBack, bControl);
- }
- }
- } else {
- for (y = r.top; y < r.bottom; y++) {
- for (x = r.left; x < r.right; x++) {
- _screen->putPixel(x, y, drawFlags, 0, !_screen->getPriority(x, y), !_screen->getControl(x, y));
- }
- }
- }
-}
-
-void Gfx::FrameRect(const Common::Rect &rect) {
- Common::Rect r;
- // left
- r = rect;
- r.right = rect.left + 1;
- PaintRect(r);
- // right
- r.right = rect.right;
- r.left = rect.right - 1;
- PaintRect(r);
- //top
- r.left = rect.left;
- r.bottom = rect.top + 1;
- PaintRect(r);
- //bottom
- r.bottom = rect.bottom;
- r.top = rect.bottom - 1;
- PaintRect(r);
-}
-
-void Gfx::OffsetRect(Common::Rect &r) {
- r.top += _curPort->top;
- r.bottom += _curPort->top;
- r.left += _curPort->left;
- r.right += _curPort->left;
-}
-
-void Gfx::OffsetLine(Common::Point &start, Common::Point &end) {
- start.x += _curPort->left;
- start.y += _curPort->top;
- end.x += _curPort->left;
- end.y += _curPort->top;
-}
-
-void Gfx::BitsShow(const Common::Rect &rect) {
- Common::Rect workerRect(rect.left, rect.top, rect.right, rect.bottom);
- workerRect.clip(_curPort->rect);
- if (workerRect.isEmpty()) // nothing to show
- return;
-
- OffsetRect(workerRect);
- _screen->copyRectToScreen(workerRect);
-}
-
-void Gfx::BitsShowHires(const Common::Rect &rect) {
- _screen->copyDisplayRectToScreen(rect);
-}
-
-reg_t Gfx::BitsSave(const Common::Rect &rect, byte screenMask) {
- reg_t memoryId;
- byte *memoryPtr;
- int size;
-
- Common::Rect workerRect(rect.left, rect.top, rect.right, rect.bottom);
- workerRect.clip(_curPort->rect);
- if (workerRect.isEmpty()) // nothing to save
- return NULL_REG;
-
- if (screenMask == SCI_SCREEN_MASK_DISPLAY) {
- // Adjust rect to upscaled hires, but dont adjust according to port
- workerRect.top *= 2; workerRect.bottom *= 2; workerRect.bottom++;
- workerRect.left *= 2; workerRect.right *= 2; workerRect.right++;
- } else {
- OffsetRect(workerRect);
- }
-
- // now actually ask _screen how much space it will need for saving
- size = _screen->bitsGetDataSize(workerRect, screenMask);
-
- memoryId = kalloc(_segMan, "SaveBits()", size);
- memoryPtr = kmem(_segMan, memoryId);
- _screen->bitsSave(workerRect, screenMask, memoryPtr);
- return memoryId;
-}
-
-void Gfx::BitsGetRect(reg_t memoryHandle, Common::Rect *destRect) {
- byte *memoryPtr = NULL;
-
- if (!memoryHandle.isNull()) {
- memoryPtr = kmem(_segMan, memoryHandle);
-
- if (memoryPtr) {
- _screen->bitsGetRect(memoryPtr, destRect);
- }
- }
-}
-
-void Gfx::BitsRestore(reg_t memoryHandle) {
- byte *memoryPtr = NULL;
-
- if (!memoryHandle.isNull()) {
- memoryPtr = kmem(_segMan, memoryHandle);
-
- if (memoryPtr) {
- _screen->bitsRestore(memoryPtr);
- kfree(_segMan, memoryHandle);
- }
- }
-}
-
-void Gfx::BitsFree(reg_t memoryHandle) {
- if (!memoryHandle.isNull()) {
- kfree(_segMan, memoryHandle);
- }
-}
-
-void Gfx::setEGAdrawingVisualize(bool state) {
- _EGAdrawingVisualize = state;
-}
-
-void Gfx::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) {
- SciGuiPicture *picture = new SciGuiPicture(_resMan, this, _screen, _palette, pictureId, _EGAdrawingVisualize);
-
- // do we add to a picture? if not -> clear screen with white
- if (!addToFlag)
- ClearScreen(_screen->getColorWhite());
-
- picture->draw(animationNr, mirroredFlag, addToFlag, paletteId);
- delete picture;
-}
-
-// This one is the only one that updates screen!
-void Gfx::drawCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
- View *view = getView(viewId);
- Common::Rect celRect;
-
- if (view) {
- celRect.left = leftPos;
- celRect.top = topPos;
- celRect.right = celRect.left + view->getWidth(loopNo, celNo);
- celRect.bottom = celRect.top + view->getHeight(loopNo, celNo);
-
- drawCel(view, loopNo, celNo, celRect, priority, paletteNo, scaleX, scaleY);
-
- if (getSciVersion() >= SCI_VERSION_1_1) {
- if (!_screen->_picNotValidSci11) {
- BitsShow(celRect);
- }
- } else {
- if (!_screen->_picNotValid)
- BitsShow(celRect);
- }
- }
-}
-
-// This version of drawCel is not supposed to call BitsShow()!
-void Gfx::drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
- drawCel(getView(viewId), loopNo, celNo, celRect, priority, paletteNo, scaleX, scaleY);
-}
-
-// This version of drawCel is not supposed to call BitsShow()!
-void Gfx::drawCel(View *view, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
- Common::Rect clipRect = celRect;
- clipRect.clip(_curPort->rect);
- if (clipRect.isEmpty()) // nothing to draw
- return;
-
- Common::Rect clipRectTranslated = clipRect;
- OffsetRect(clipRectTranslated);
- if (scaleX == 128 && scaleY == 128) {
- view->draw(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, paletteNo, false);
- } else {
- view->drawScaled(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, scaleX, scaleY);
- }
-}
-
-// This is used as replacement for drawCelAndShow() when hires-cels are drawn to screen
-// Hires-cels are available only SCI 1.1+
-void Gfx::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, reg_t upscaledHiresHandle, uint16 scaleX, uint16 scaleY) {
- View *view = getView(viewId);
- Common::Rect celRect, curPortRect, clipRect, clipRectTranslated;
- Common::Point curPortPos;
- bool upscaledHiresHack = false;
-
- if (view) {
- if ((leftPos == 0) && (topPos == 0)) {
- // HACK: in kq6, we get leftPos&topPos == 0 SOMETIMES, that's why we need to get coordinates from upscaledHiresHandle
- // I'm not sure if this is what we are supposed to do or if there is some other bug that actually makes
- // coordinates to be 0 in the first place
- byte *memoryPtr = NULL;
- memoryPtr = kmem(_segMan, upscaledHiresHandle);
- if (memoryPtr) {
- Common::Rect upscaledHiresRect;
- _screen->bitsGetRect(memoryPtr, &upscaledHiresRect);
- leftPos = upscaledHiresRect.left;
- topPos = upscaledHiresRect.top;
- upscaledHiresHack = true;
- }
- }
-
- celRect.left = leftPos;
- celRect.top = topPos;
- celRect.right = celRect.left + view->getWidth(loopNo, celNo);
- celRect.bottom = celRect.top + view->getHeight(loopNo, celNo);
- // adjust curPort to upscaled hires
- clipRect = celRect;
- curPortRect = _curPort->rect;
- curPortRect.top *= 2; curPortRect.bottom *= 2; curPortRect.bottom++;
- curPortRect.left *= 2; curPortRect.right *= 2; curPortRect.right++;
- clipRect.clip(curPortRect);
- if (clipRect.isEmpty()) // nothing to draw
- return;
-
- clipRectTranslated = clipRect;
- if (!upscaledHiresHack) {
- curPortPos.x = _curPort->left * 2; curPortPos.y = _curPort->top * 2;
- clipRectTranslated.top += curPortPos.y; clipRectTranslated.bottom += curPortPos.y;
- clipRectTranslated.left += curPortPos.x; clipRectTranslated.right += curPortPos.x;
- }
-
- view->draw(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, paletteNo, true);
- if (!_screen->_picNotValidSci11) {
- _screen->copyDisplayRectToScreen(clipRectTranslated);
- }
- }
-}
-
-uint16 Gfx::onControl(uint16 screenMask, Common::Rect rect) {
- int16 x, y;
- uint16 result = 0;
-
- if (rect.isEmpty())
- return 0;
-
- if (screenMask & SCI_SCREEN_MASK_PRIORITY) {
- for (y = rect.top; y < rect.bottom; y++) {
- for (x = rect.left; x < rect.right; x++) {
- result |= 1 << _screen->getPriority(x, y);
- }
- }
- } else {
- for (y = rect.top; y < rect.bottom; y++) {
- for (x = rect.left; x < rect.right; x++) {
- result |= 1 << _screen->getControl(x, y);
- }
- }
- }
- return result;
-}
-
-static inline int sign_extend_byte(int value) {
- if (value & 0x80)
- return value - 256;
- else
- return value;
-}
-
-void Gfx::PriorityBandsInit(int16 bandCount, int16 top, int16 bottom) {
- int16 y;
- int32 bandSize;
-
- // This code is for 320x200 games only
- if (_screen->getHeight() != 200)
- return;
-
- if (bandCount != -1)
- _priorityBandCount = bandCount;
-
- _priorityTop = top;
- _priorityBottom = bottom;
-
- // Do NOT modify this algo or optimize it anyhow, sierra sci used int32 for calculating the
- // priority bands and by using double or anything rounding WILL destroy the result
- bandSize = ((_priorityBottom - _priorityTop) * 2000) / _priorityBandCount;
-
- memset(_priorityBands, 0, sizeof(byte) * _priorityTop);
- for (y = _priorityTop; y < _priorityBottom; y++)
- _priorityBands[y] = 1 + (((y - _priorityTop) * 2000) / bandSize);
- if (_priorityBandCount == 15) {
- // When having 15 priority bands, we actually replace band 15 with band 14, cause the original sci interpreter also
- // does it that way as well
- y = _priorityBottom;
- while (_priorityBands[--y] == _priorityBandCount)
- _priorityBands[y]--;
- }
- // We fill space that is left over with the highest band (hardcoded 200 limit, because this algo isnt meant to be used on hires)
- for (y = _priorityBottom; y < 200; y++)
- _priorityBands[y] = _priorityBandCount;
-}
-
-void Gfx::PriorityBandsInit(byte *data) {
- int i = 0, inx;
- byte priority = 0;
-
- for (inx = 0; inx < 14; inx++) {
- priority = *data++;
- while (i < priority)
- _priorityBands[i++] = inx;
- }
- while (i < 200)
- _priorityBands[i++] = inx;
-}
-
-// Gets used by picture class to remember priority bands data from sci1.1 pictures that need to get applied when
-// transitioning to that picture
-void Gfx::PriorityBandsRemember(byte *data) {
- int bandNo;
- for (bandNo = 0; bandNo < 14; bandNo++) {
- priorityBandsMemory[bandNo] = READ_LE_UINT16(data);
- data += 2;
- }
- priorityBandsMemoryActive = true;
-}
-
-void Gfx::PriorityBandsRecall() {
- if (priorityBandsMemoryActive) {
- PriorityBandsInit((byte *)&priorityBandsMemory);
- priorityBandsMemoryActive = false;
- }
-}
-
-byte Gfx::CoordinateToPriority(int16 y) {
- if (y < _priorityTop)
- return _priorityBands[_priorityTop];
- if (y > _priorityBottom)
- return _priorityBands[_priorityBottom];
- return _priorityBands[y];
-}
-
-int16 Gfx::PriorityToCoordinate(byte priority) {
- int16 y;
- if (priority <= _priorityBandCount) {
- for (y = 0; y <= _priorityBottom; y++)
- if (_priorityBands[y] == priority)
- return y;
- }
- return _priorityBottom;
-}
-
-bool Gfx::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) {
- reg_t curAddress = list->first;
- Node *curNode = _segMan->lookupNode(curAddress);
- reg_t curObject;
- uint16 signal;
- Common::Rect curRect;
-
- while (curNode) {
- curObject = curNode->value;
- if (curObject != checkObject) {
- signal = GET_SEL32V(_segMan, curObject, signal);
- if ((signal & (kSignalIgnoreActor | kSignalRemoveView | kSignalNoUpdate)) == 0) {
- curRect.left = GET_SEL32V(_segMan, curObject, brLeft);
- curRect.top = GET_SEL32V(_segMan, curObject, brTop);
- curRect.right = GET_SEL32V(_segMan, curObject, brRight);
- curRect.bottom = GET_SEL32V(_segMan, curObject, brBottom);
- // Check if curRect is within checkRect
- if (curRect.right > checkRect.left && curRect.left < checkRect.right && curRect.bottom > checkRect.top && curRect.top < checkRect.bottom) {
- return false;
- }
- }
- }
- curAddress = curNode->succ;
- curNode = _segMan->lookupNode(curAddress);
- }
- return true;
-}
-
-void Gfx::SetNowSeen(reg_t objectReference) {
- View *view = NULL;
- Common::Rect celRect(0, 0);
- GuiResourceId viewId = (GuiResourceId)GET_SEL32V(_segMan, objectReference, view);
- int16 loopNo = sign_extend_byte((int16)GET_SEL32V(_segMan, objectReference, loop));
- int16 celNo = sign_extend_byte((int16)GET_SEL32V(_segMan, objectReference, cel));
- int16 x = (int16)GET_SEL32V(_segMan, objectReference, x);
- int16 y = (int16)GET_SEL32V(_segMan, objectReference, y);
- int16 z = 0;
- if (_kernel->_selectorCache.z > -1)
- z = (int16)GET_SEL32V(_segMan, objectReference, z);
-
- // now get cel rectangle
- view = getView(viewId);
- view->getCelRect(loopNo, celNo, x, y, z, &celRect);
-
- // TODO: sometimes loop is negative. Check what it means
- if (lookup_selector(_segMan, objectReference, _kernel->_selectorCache.nsTop, NULL, NULL) == kSelectorVariable) {
- PUT_SEL32V(_segMan, objectReference, nsLeft, celRect.left);
- PUT_SEL32V(_segMan, objectReference, nsRight, celRect.right);
- PUT_SEL32V(_segMan, objectReference, nsTop, celRect.top);
- PUT_SEL32V(_segMan, objectReference, nsBottom, celRect.bottom);
- }
-}
-
-} // End of namespace Sci
Deleted: scummvm/trunk/engines/sci/graphics/gfx.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gfx.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gfx.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -1,142 +0,0 @@
-/* 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$
- *
- */
-
-#ifndef SCI_GRAPHICS_GFX_H
-#define SCI_GRAPHICS_GFX_H
-
-#include "sci/graphics/gui.h"
-
-#include "common/hashmap.h"
-
-namespace Sci {
-
-#define SCI_TEXT_ALIGNMENT_RIGHT -1
-#define SCI_TEXT_ALIGNMENT_CENTER 1
-#define SCI_TEXT_ALIGNMENT_LEFT 0
-
-class Screen;
-class SciPalette;
-class Font;
-class SciGuiPicture;
-class View;
-
-typedef Common::HashMap<int, View *> ViewCache;
-
-class Gfx {
-public:
- Gfx(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, Screen *screen, SciPalette *palette);
- ~Gfx();
-
- void init(Text *text);
-
- byte *GetSegment(byte seg);
- void ResetScreen();
-
- Port *SetPort(Port *port);
- Port *GetPort();
- void SetOrigin(int16 left, int16 top);
- void MoveTo(int16 left, int16 top);
- void Move(int16 left, int16 top);
- void OpenPort(Port *port);
- void PenColor(int16 color);
- void BackColor(int16 color);
- void PenMode(int16 mode);
- void TextGreyedOutput(bool state);
- int16 GetPointSize();
-
- void ClearScreen(byte color = 255);
- void InvertRect(const Common::Rect &rect);
- void EraseRect(const Common::Rect &rect);
- void PaintRect(const Common::Rect &rect);
- void FillRect(const Common::Rect &rect, int16 drawFlags, byte clrPen, byte clrBack = 0, byte bControl = 0);
- void FrameRect(const Common::Rect &rect);
- void OffsetRect(Common::Rect &r);
- void OffsetLine(Common::Point &start, Common::Point &end);
-
- void BitsShow(const Common::Rect &r);
- void BitsShowHires(const Common::Rect &rect);
- reg_t BitsSave(const Common::Rect &rect, byte screenFlags);
- void BitsGetRect(reg_t memoryHandle, Common::Rect *destRect);
- void BitsRestore(reg_t memoryHandle);
- void BitsFree(reg_t memoryHandle);
-
- void setEGAdrawingVisualize(bool state);
-
- void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId);
- void drawCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, uint16 scaleX = 128, uint16 scaleY = 128);
- void drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX = 128, uint16 scaleY = 128);
- void drawCel(View *view, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX = 128, uint16 scaleY = 128);
- void drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, reg_t upscaledHiresHandle, uint16 scaleX = 128, uint16 scaleY = 128);
-
- uint16 onControl(uint16 screenMask, Common::Rect rect);
-
- void PriorityBandsInit(int16 bandCount, int16 top, int16 bottom);
- void PriorityBandsInit(byte *data);
- void PriorityBandsRemember(byte *data);
- void PriorityBandsRecall();
- byte CoordinateToPriority(int16 y);
- int16 PriorityToCoordinate(byte priority);
-
- bool CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list);
-
- void SetNowSeen(reg_t objectReference);
-
- Port *_menuPort;
- Common::Rect _menuBarRect;
- Common::Rect _menuRect;
- Common::Rect _menuLine;
- Port *_curPort;
-
- View *getView(GuiResourceId viewNum);
-
-private:
- void purgeCache();
-
- ResourceManager *_resMan;
- SegManager *_segMan;
- Kernel *_kernel;
- Screen *_screen;
- SciPalette *_palette;
- Text *_text;
-
- Common::Rect _bounds;
- Port *_mainPort;
-
- // Priority Bands related variables
- int16 _priorityTop, _priorityBottom, _priorityBandCount;
- byte _priorityBands[200];
-
- ViewCache _cachedViews;
-
- // true means make EGA picture drawing visible
- bool _EGAdrawingVisualize;
-
- byte priorityBandsMemory[14];
- bool priorityBandsMemoryActive;
-};
-
-} // End of namespace Sci
-
-#endif
Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -35,8 +35,10 @@
#include "sci/graphics/screen.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/cursor.h"
-#include "sci/graphics/gfx.h"
-#include "sci/graphics/windowmgr.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/compare.h"
#include "sci/graphics/animate.h"
#include "sci/graphics/controls.h"
#include "sci/graphics/menu.h"
@@ -48,26 +50,29 @@
namespace Sci {
-SciGui::SciGui(EngineState *state, Screen *screen, SciPalette *palette, Cursor *cursor, AudioPlayer *audio)
- : _s(state), _screen(screen), _palette(palette), _cursor(cursor), _audio(audio) {
+SciGui::SciGui(EngineState *state, Screen *screen, SciPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio)
+ : _s(state), _screen(screen), _palette(palette), _cursor(cursor), _ports(ports), _audio(audio) {
- _gfx = new Gfx(_s->resMan, _s->_segMan, _s->_kernel, _screen, _palette);
+ _cache = new GfxCache(_s->resMan, _screen, _palette);
+ _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen);
+ _paint16 = new GfxPaint16(_s->resMan, _s->_segMan, _s->_kernel, _cache, _ports, _screen, _palette);
_transitions = new Transitions(this, _screen, _palette, _s->resMan->isVGA());
- _animate = new SciGuiAnimate(_s, _gfx, _screen, _palette);
- _text = new Text(_s->resMan, _gfx, _screen);
- _windowMgr = new WindowMgr(this, _screen, _gfx, _text);
- _controls = new Controls(_s->_segMan, _gfx, _text);
- _menu = new Menu(_s->_event, _s->_segMan, this, _gfx, _text, _screen, _cursor);
+ _animate = new SciGuiAnimate(_s, _cache, _ports, _paint16, _screen, _palette);
+ _text = new Text(_s->resMan, _ports, _paint16, _screen);
+ _controls = new Controls(_s->_segMan, _ports, _paint16, _text);
+ _menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text, _screen, _cursor);
}
SciGui::~SciGui() {
delete _menu;
delete _controls;
- delete _windowMgr;
delete _text;
delete _animate;
delete _transitions;
- delete _gfx;
+ delete _paint16;
+ delete _ports;
+ delete _compare;
+ delete _cache;
}
void SciGui::resetEngineState(EngineState *s) {
@@ -78,19 +83,19 @@
void SciGui::init(bool usesOldGfxFunctions) {
_usesOldGfxFunctions = usesOldGfxFunctions;
- _gfx->init(_text);
- _windowMgr->init(_s->_gameId);
+ _ports->init(this, _paint16, _text, _s->_gameId);
+ _paint16->init(_text);
initPriorityBands();
}
void SciGui::initPriorityBands() {
if (_usesOldGfxFunctions) {
- _gfx->PriorityBandsInit(15, 42, 200);
+ _ports->priorityBandsInit(15, 42, 200);
} else {
if (getSciVersion() >= SCI_VERSION_1_1)
- _gfx->PriorityBandsInit(14, 0, 190);
+ _ports->priorityBandsInit(14, 0, 190);
else
- _gfx->PriorityBandsInit(14, 42, 190);
+ _ports->priorityBandsInit(14, 42, 190);
}
}
@@ -105,76 +110,26 @@
kernel_sleep(_s->_event, ticks * 1000 / 60);
}
-void SciGui::setPort(uint16 portPtr) {
- switch (portPtr) {
- case 0:
- _gfx->SetPort(_windowMgr->_wmgrPort);
- break;
- case 0xFFFF:
- _gfx->SetPort(_gfx->_menuPort);
- break;
- default:
- _gfx->SetPort(_windowMgr->getPortById(portPtr));
- };
-}
-
-Common::Rect SciGui::getPortPic(int16 &picTop, int16 &picLeft) {
- picTop = _windowMgr->_picWind->top;
- picLeft = _windowMgr->_picWind->left;
- return _windowMgr->_picWind->rect;
-}
-
-void SciGui::setPortPic(Common::Rect rect, int16 picTop, int16 picLeft, bool initPriorityBandsFlag) {
- _windowMgr->_picWind->rect = rect;
- _windowMgr->_picWind->top = picTop;
- _windowMgr->_picWind->left = picLeft;
- if (initPriorityBandsFlag)
- initPriorityBands();
-}
-
-reg_t SciGui::getPort() {
- return make_reg(0, _gfx->GetPort()->id);
-}
-
void SciGui::globalToLocal(int16 *x, int16 *y) {
- Port *curPort = _gfx->GetPort();
+ Port *curPort = _ports->getPort();
*x = *x - curPort->left;
*y = *y - curPort->top;
}
void SciGui::localToGlobal(int16 *x, int16 *y) {
- Port *curPort = _gfx->GetPort();
+ Port *curPort = _ports->getPort();
*x = *x + curPort->left;
*y = *y + curPort->top;
}
int16 SciGui::coordinateToPriority(int16 y) {
- return _gfx->CoordinateToPriority(y);
+ return _ports->coordinateToPriority(y);
}
int16 SciGui::priorityToCoordinate(int16 priority) {
- return _gfx->PriorityToCoordinate(priority);
+ return _ports->priorityToCoordinate(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 (restoreRect.top != 0 && restoreRect.left != 0 && restoreRect.height() != 0 && restoreRect.width() != 0)
- wnd = _windowMgr->NewWindow(dims, &restoreRect, title, style, priority, false);
- else
- wnd = _windowMgr->NewWindow(dims, NULL, title, style, priority, false);
- wnd->penClr = colorPen;
- wnd->backClr = colorBack;
- _windowMgr->DrawWindow(wnd);
-
- return make_reg(0, wnd->id);
-}
-
-void SciGui::disposeWindow(uint16 windowPtr, bool reanimate) {
- Window *wnd = (Window *)_windowMgr->getPortById(windowPtr);
- _windowMgr->DisposeWindow(wnd, reanimate);
-}
-
#define SCI_DISPLAY_MOVEPEN 100
#define SCI_DISPLAY_SETALIGNMENT 101
#define SCI_DISPLAY_SETPENCOLOR 102
@@ -194,19 +149,19 @@
Common::Rect rect;
// Make a "backup" of the port settings
- Port oldPort = *_gfx->GetPort();
+ Port oldPort = *_ports->getPort();
// setting defaults
- _gfx->PenMode(0);
- _gfx->PenColor(0);
- _gfx->TextGreyedOutput(false);
+ _ports->penMode(0);
+ _ports->penColor(0);
+ _ports->textGreyedOutput(false);
// processing codes in argv
while (argc > 0) {
displayArg = argv[0].toUint16();
argc--; argv++;
switch (displayArg) {
case SCI_DISPLAY_MOVEPEN:
- _gfx->MoveTo(argv[0].toUint16(), argv[1].toUint16());
+ _ports->moveTo(argv[0].toUint16(), argv[1].toUint16());
argc -= 2; argv += 2;
break;
case SCI_DISPLAY_SETALIGNMENT:
@@ -215,7 +170,7 @@
break;
case SCI_DISPLAY_SETPENCOLOR:
colorPen = argv[0].toUint16();
- _gfx->PenColor(colorPen);
+ _ports->penColor(colorPen);
argc--; argv++;
break;
case SCI_DISPLAY_SETBACKGROUNDCOLOR:
@@ -223,7 +178,7 @@
argc--; argv++;
break;
case SCI_DISPLAY_SETGREYEDOUTPUT:
- _gfx->TextGreyedOutput(argv[0].isNull() ? false : true);
+ _ports->textGreyedOutput(argv[0].isNull() ? false : true);
argc--; argv++;
break;
case SCI_DISPLAY_SETFONT:
@@ -238,9 +193,9 @@
doSaveUnder = true;
break;
case SCI_DISPLAY_RESTOREUNDER:
- _gfx->BitsGetRect(argv[0], &rect);
- rect.translate(-_gfx->GetPort()->left, -_gfx->GetPort()->top);
- _gfx->BitsRestore(argv[0]);
+ _paint16->bitsGetRect(argv[0], &rect);
+ rect.translate(-_ports->getPort()->left, -_ports->getPort()->top);
+ _paint16->bitsRestore(argv[0]);
graphRedrawBox(rect);
// finishing loop
argc = 0;
@@ -256,23 +211,23 @@
// now drawing the text
_text->Size(rect, text, -1, width);
- rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop);
+ rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop);
if (getSciVersion() >= SCI_VERSION_1_LATE) {
int16 leftPos = rect.right <= _screen->getWidth() ? 0 : _screen->getWidth() - rect.right;
int16 topPos = rect.bottom <= _screen->getHeight() ? 0 : _screen->getHeight() - rect.bottom;
- _gfx->Move(leftPos, topPos);
- rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop);
+ _ports->move(leftPos, topPos);
+ rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop);
}
if (doSaveUnder)
- _s->r_acc = _gfx->BitsSave(rect, SCI_SCREEN_MASK_VISUAL);
+ _s->r_acc = _paint16->bitsSave(rect, SCI_SCREEN_MASK_VISUAL);
if (colorBack != -1)
- _gfx->FillRect(rect, SCI_SCREEN_MASK_VISUAL, colorBack, 0, 0);
+ _paint16->fillRect(rect, SCI_SCREEN_MASK_VISUAL, colorBack, 0, 0);
_text->Box(text, 0, rect, alignment, -1);
if (_screen->_picNotValid == 0 && bRedraw)
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
// restoring port and cursor pos
- Port *currport = _gfx->GetPort();
+ Port *currport = _ports->getPort();
uint16 tTop = currport->curTop;
uint16 tLeft = currport->curLeft;
*currport = oldPort;
@@ -298,22 +253,22 @@
}
void SciGui::drawStatus(const char *text, int16 colorPen, int16 colorBack) {
- Port *oldPort = _gfx->SetPort(_gfx->_menuPort);
+ Port *oldPort = _ports->setPort(_ports->_menuPort);
- _gfx->FillRect(_gfx->_menuBarRect, 1, colorBack);
- _gfx->PenColor(colorPen);
- _gfx->MoveTo(0, 1);
+ _paint16->fillRect(_ports->_menuBarRect, 1, colorBack);
+ _ports->penColor(colorPen);
+ _ports->moveTo(0, 1);
_text->Draw_String(text);
- _gfx->BitsShow(_gfx->_menuBarRect);
- _gfx->SetPort(oldPort);
+ _paint16->bitsShow(_ports->_menuBarRect);
+ _ports->setPort(oldPort);
}
void SciGui::drawMenuBar(bool clear) {
if (!clear) {
- Port *oldPort = _gfx->SetPort(_gfx->_menuPort);
+ Port *oldPort = _ports->setPort(_ports->_menuPort);
_menu->drawBar();
- _gfx->BitsShow(_gfx->_menuBarRect);
- _gfx->SetPort(oldPort);
+ _paint16->bitsShow(_ports->_menuBarRect);
+ _ports->setPort(oldPort);
} else {
drawStatus("", 0, 0);
}
@@ -321,7 +276,7 @@
void SciGui::menuReset() {
delete _menu;
- _menu = new Menu(_s->_event, _s->_segMan, this, _gfx, _text, _screen, _cursor);
+ _menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text, _screen, _cursor);
}
void SciGui::menuAdd(Common::String title, Common::String content, reg_t contentVmPtr) {
@@ -341,26 +296,26 @@
}
void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
- Port *oldPort = _gfx->SetPort((Port *)_windowMgr->_picWind);
+ Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
- if (_windowMgr->isFrontWindow(_windowMgr->_picWind)) {
+ if (_ports->isFrontWindow(_ports->_picWind)) {
_screen->_picNotValid = 1;
- _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
+ _paint16->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_transitions->setup(animationNr, animationBlackoutFlag);
} else {
- _windowMgr->BeginUpdate(_windowMgr->_picWind);
- _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
- _windowMgr->EndUpdate(_windowMgr->_picWind);
+ _ports->beginUpdate(_ports->_picWind);
+ _paint16->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
+ _ports->endUpdate(_ports->_picWind);
}
- _gfx->SetPort(oldPort);
+ _ports->setPort(oldPort);
}
void SciGui::drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo, bool hiresMode, reg_t upscaledHiresHandle) {
// some calls are hiresMode even under kq6 DOS, that's why we check for upscaled hires here
if ((!hiresMode) || (!_screen->getUpscaledHires())) {
- _gfx->drawCelAndShow(viewId, loopNo, celNo, leftPos, topPos, priority, paletteNo);
+ _paint16->drawCelAndShow(viewId, loopNo, celNo, leftPos, topPos, priority, paletteNo);
} else {
- _gfx->drawHiresCelAndShow(viewId, loopNo, celNo, leftPos, topPos, priority, paletteNo, upscaledHiresHandle);
+ _paint16->drawHiresCelAndShow(viewId, loopNo, celNo, leftPos, topPos, priority, paletteNo, upscaledHiresHandle);
}
_palette->setOnScreen();
}
@@ -374,40 +329,40 @@
void SciGui::drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
- _gfx->EraseRect(rect);
- _gfx->FrameRect(rect);
+ _paint16->eraseRect(rect);
+ _paint16->frameRect(rect);
rect.grow(-2);
- _gfx->TextGreyedOutput(style & 1 ? false : true);
+ _ports->textGreyedOutput(style & 1 ? false : true);
_text->Box(text, 0, rect, SCI_TEXT_ALIGNMENT_CENTER, fontId);
- _gfx->TextGreyedOutput(false);
+ _ports->textGreyedOutput(false);
rect.grow(1);
if (style & 8) // selected
- _gfx->FrameRect(rect);
+ _paint16->frameRect(rect);
if (!getControlPicNotValid()) {
rect.grow(1);
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
}
} else {
- _gfx->InvertRect(rect);
- _gfx->BitsShow(rect);
+ _paint16->invertRect(rect);
+ _paint16->bitsShow(rect);
}
}
void SciGui::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, TextAlignment alignment, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
- _gfx->EraseRect(rect);
+ _paint16->eraseRect(rect);
rect.grow(-1);
_text->Box(text, 0, rect, alignment, fontId);
if (style & 8) { // selected
- _gfx->FrameRect(rect);
+ _paint16->frameRect(rect);
}
rect.grow(1);
if (!getControlPicNotValid())
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
} else {
- _gfx->InvertRect(rect);
- _gfx->BitsShow(rect);
+ _paint16->invertRect(rect);
+ _paint16->bitsShow(rect);
}
}
@@ -417,9 +372,9 @@
rect.grow(1);
_controls->TexteditCursorErase();
- _gfx->EraseRect(rect);
+ _paint16->eraseRect(rect);
_text->Box(text, 0, textRect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
- _gfx->FrameRect(rect);
+ _paint16->frameRect(rect);
if (style & 8) {
_text->SetFont(fontId);
rect.grow(-1);
@@ -428,20 +383,20 @@
rect.grow(1);
}
if (!getControlPicNotValid())
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
}
void SciGui::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite) {
if (!hilite) {
- _gfx->drawCelAndShow(viewId, loopNo, celNo, rect.left, rect.top, priority, 0);
+ _paint16->drawCelAndShow(viewId, loopNo, celNo, rect.left, rect.top, priority, 0);
if (style & 0x20) {
- _gfx->FrameRect(rect);
+ _paint16->frameRect(rect);
}
if (!getControlPicNotValid())
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
} else {
- _gfx->InvertRect(rect);
- _gfx->BitsShow(rect);
+ _paint16->invertRect(rect);
+ _paint16->bitsShow(rect);
}
}
@@ -450,10 +405,10 @@
_controls->drawListControl(rect, obj, maxChars, count, entries, fontId, upperPos, cursorPos, isAlias);
rect.grow(1);
if (isAlias && (style & 8)) {
- _gfx->FrameRect(rect);
+ _paint16->frameRect(rect);
}
if (!getControlPicNotValid())
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
}
}
@@ -469,66 +424,66 @@
}
void SciGui::graphFillBoxForeground(Common::Rect rect) {
- _gfx->PaintRect(rect);
+ _paint16->paintRect(rect);
}
void SciGui::graphFillBoxBackground(Common::Rect rect) {
- _gfx->EraseRect(rect);
+ _paint16->eraseRect(rect);
}
void SciGui::graphFillBox(Common::Rect rect, uint16 colorMask, int16 color, int16 priority, int16 control) {
- _gfx->FillRect(rect, colorMask, color, priority, control);
+ _paint16->fillRect(rect, colorMask, color, priority, control);
}
void SciGui::graphFrameBox(Common::Rect rect, int16 color) {
- int16 oldColor = _gfx->GetPort()->penClr;
- _gfx->PenColor(color);
- _gfx->FrameRect(rect);
- _gfx->PenColor(oldColor);
+ int16 oldColor = _ports->getPort()->penClr;
+ _ports->penColor(color);
+ _paint16->frameRect(rect);
+ _ports->penColor(oldColor);
}
void SciGui::graphDrawLine(Common::Point startPoint, Common::Point endPoint, int16 color, int16 priority, int16 control) {
- _gfx->OffsetLine(startPoint, endPoint);
+ _ports->offsetLine(startPoint, endPoint);
_screen->drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y, color, priority, control);
}
reg_t SciGui::graphSaveBox(Common::Rect rect, uint16 screenMask) {
- return _gfx->BitsSave(rect, screenMask);
+ return _paint16->bitsSave(rect, screenMask);
}
reg_t SciGui::graphSaveUpscaledHiresBox(Common::Rect rect) {
- return _gfx->BitsSave(rect, SCI_SCREEN_MASK_DISPLAY);
+ return _paint16->bitsSave(rect, SCI_SCREEN_MASK_DISPLAY);
}
void SciGui::graphRestoreBox(reg_t handle) {
- _gfx->BitsRestore(handle);
+ _paint16->bitsRestore(handle);
}
void SciGui::graphUpdateBox(Common::Rect rect, bool hiresMode) {
// some calls are hiresMode even under kq6 DOS, that's why we check for upscaled hires here
if ((!hiresMode) || (!_screen->getUpscaledHires()))
- _gfx->BitsShow(rect);
+ _paint16->bitsShow(rect);
else
- _gfx->BitsShowHires(rect);
+ _paint16->bitsShowHires(rect);
}
void SciGui::graphRedrawBox(Common::Rect rect) {
localToGlobal(&rect.left, &rect.top);
localToGlobal(&rect.right, &rect.bottom);
- Port *oldPort = _gfx->SetPort((Port *)_windowMgr->_picWind);
+ Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
globalToLocal(&rect.left, &rect.top);
globalToLocal(&rect.right, &rect.bottom);
_animate->reAnimate(rect);
- _gfx->SetPort(oldPort);
+ _ports->setPort(oldPort);
}
void SciGui::graphAdjustPriority(int top, int bottom) {
if (_usesOldGfxFunctions) {
- _gfx->PriorityBandsInit(15, top, bottom);
+ _ports->priorityBandsInit(15, top, bottom);
} else {
- _gfx->PriorityBandsInit(14, top, bottom);
+ _ports->priorityBandsInit(14, top, bottom);
}
}
@@ -605,20 +560,20 @@
}
uint16 SciGui::onControl(byte screenMask, Common::Rect rect) {
- Port *oldPort = _gfx->SetPort((Port *)_windowMgr->_picWind);
+ Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
Common::Rect adjustedRect(rect.left, rect.top, rect.right, rect.bottom);
uint16 result;
- adjustedRect.clip(_gfx->GetPort()->rect);
- _gfx->OffsetRect(adjustedRect);
- result = _gfx->onControl(screenMask, adjustedRect);
+ adjustedRect.clip(_ports->getPort()->rect);
+ _ports->offsetRect(adjustedRect);
+ result = _compare->onControl(screenMask, adjustedRect);
- _gfx->SetPort(oldPort);
+ _ports->setPort(oldPort);
return result;
}
void SciGui::animateShowPic() {
- Port *picPort = _windowMgr->_picWind;
+ Port *picPort = _ports->_picWind;
Common::Rect picRect = picPort->rect;
bool previousCursorState = _cursor->isVisible();
@@ -631,7 +586,7 @@
_cursor->show();
// We set SCI1.1 priority band information here
- _gfx->PriorityBandsRecall();
+ _ports->priorityBandsRecall();
}
void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
@@ -653,16 +608,16 @@
return;
}
- Port *oldPort = _gfx->SetPort((Port *)_windowMgr->_picWind);
+ Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
_animate->disposeLastCast();
_animate->makeSortedList(list);
_animate->fill(old_picNotValid);
if (old_picNotValid) {
- _windowMgr->BeginUpdate(_windowMgr->_picWind);
+ _ports->beginUpdate(_ports->_picWind);
_animate->update();
- _windowMgr->EndUpdate(_windowMgr->_picWind);
+ _ports->endUpdate(_ports->_picWind);
}
_animate->drawCels();
@@ -676,7 +631,7 @@
if (_animate->getLastCastCount() > 1)
_s->_throttleTrigger = true;
- _gfx->SetPort(oldPort);
+ _ports->setPort(oldPort);
}
void SciGui::addToPicSetPicNotValid() {
@@ -689,7 +644,7 @@
void SciGui::addToPicList(reg_t listReference, int argc, reg_t *argv) {
List *list;
- _gfx->SetPort((Port *)_windowMgr->_picWind);
+ _ports->setPort((Port *)_ports->_picWind);
list = _s->_segMan->lookupList(listReference);
if (!list)
@@ -702,17 +657,17 @@
}
void SciGui::addToPicView(GuiResourceId viewId, int16 loopNo, int16 celNo, int16 leftPos, int16 topPos, int16 priority, int16 control) {
- _gfx->SetPort((Port *)_windowMgr->_picWind);
+ _ports->setPort((Port *)_ports->_picWind);
_animate->addToPicDrawView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
addToPicSetPicNotValid();
}
void SciGui::setNowSeen(reg_t objectReference) {
- _gfx->SetNowSeen(objectReference);
+ _compare->SetNowSeen(objectReference);
}
bool SciGui::canBeHere(reg_t curObject, reg_t listReference) {
- Port *oldPort = _gfx->SetPort((Port *)_windowMgr->_picWind);
+ Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
Common::Rect checkRect;
Common::Rect adjustedRect;
uint16 signal, controlMask;
@@ -724,25 +679,25 @@
checkRect.bottom = GET_SEL32V(_s->_segMan, curObject, brBottom);
adjustedRect = checkRect;
- adjustedRect.clip(_gfx->GetPort()->rect);
- _gfx->OffsetRect(adjustedRect);
+ adjustedRect.clip(_ports->getPort()->rect);
+ _ports->offsetRect(adjustedRect);
signal = GET_SEL32V(_s->_segMan, curObject, signal);
controlMask = GET_SEL32V(_s->_segMan, curObject, illegalBits);
- result = (_gfx->onControl(SCI_SCREEN_MASK_CONTROL, adjustedRect) & controlMask) ? false : true;
+ result = (_compare->onControl(SCI_SCREEN_MASK_CONTROL, adjustedRect) & controlMask) ? false : true;
if ((result) && (signal & (kSignalIgnoreActor | kSignalRemoveView)) == 0) {
List *list = _s->_segMan->lookupList(listReference);
if (!list)
error("kCanBeHere called with non-list as parameter");
- result = _gfx->CanBeHereCheckRectList(curObject, checkRect, list);
+ result = _compare->CanBeHereCheckRectList(curObject, checkRect, list);
}
- _gfx->SetPort(oldPort);
+ _ports->setPort(oldPort);
return result;
}
bool SciGui::isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position) {
- View *tmpView = _gfx->getView(viewId);
+ View *tmpView = _cache->getView(viewId);
CelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo);
position.x = CLIP<int>(position.x, 0, celInfo->width - 1);
position.y = CLIP<int>(position.y, 0, celInfo->height - 1);
@@ -761,7 +716,7 @@
int16 loopNo = GET_SEL32V(_s->_segMan, object, loop);
int16 celNo = GET_SEL32V(_s->_segMan, object, cel);
- View *tmpView = _gfx->getView(viewId);
+ View *tmpView = _cache->getView(viewId);
Common::Rect celRect;
tmpView->getCelRect(loopNo, celNo, x, y, z, &celRect);
@@ -796,8 +751,8 @@
}
void SciGui::setCursorPos(Common::Point pos) {
- pos.y += _gfx->GetPort()->top;
- pos.x += _gfx->GetPort()->left;
+ pos.y += _ports->getPort()->top;
+ pos.x += _ports->getPort()->left;
moveCursor(pos);
}
@@ -806,11 +761,11 @@
}
void SciGui::moveCursor(Common::Point pos) {
- pos.y += _windowMgr->_picWind->rect.top;
- pos.x += _windowMgr->_picWind->rect.left;
+ pos.y += _ports->_picWind->rect.top;
+ pos.x += _ports->_picWind->rect.left;
- pos.y = CLIP<int16>(pos.y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
- pos.x = CLIP<int16>(pos.x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
+ pos.y = CLIP<int16>(pos.y, _ports->_picWind->rect.top, _ports->_picWind->rect.bottom - 1);
+ pos.x = CLIP<int16>(pos.x, _ports->_picWind->rect.left, _ports->_picWind->rect.right - 1);
if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) {
warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
@@ -829,19 +784,19 @@
}
int16 SciGui::getCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo) {
- return _gfx->getView(viewId)->getCelInfo(loopNo, celNo)->width;
+ return _cache->getView(viewId)->getCelInfo(loopNo, celNo)->width;
}
int16 SciGui::getCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo) {
- return _gfx->getView(viewId)->getCelInfo(loopNo, celNo)->height;
+ return _cache->getView(viewId)->getCelInfo(loopNo, celNo)->height;
}
int16 SciGui::getLoopCount(GuiResourceId viewId) {
- return _gfx->getView(viewId)->getLoopCount();
+ return _cache->getView(viewId)->getLoopCount();
}
int16 SciGui::getCelCount(GuiResourceId viewId, int16 loopNo) {
- return _gfx->getView(viewId)->getLoopInfo(loopNo)->celCount;
+ return _cache->getView(viewId)->getLoopInfo(loopNo)->celCount;
}
void SciGui::syncWithFramebuffer() {
@@ -858,7 +813,7 @@
// TODO: cache portraits
// adjust given coordinates to curPort (but dont adjust coordinates on upscaledHires_Save_Box and give us hires coordinates
// on kDrawCel, yeah this whole stuff makes sense)
- position.x += _gfx->GetPort()->left; position.y += _gfx->GetPort()->top;
+ position.x += _ports->getPort()->left; position.y += _ports->getPort()->top;
position.x *= 2; position.y *= 2;
myPortrait->doit(position, resourceId, noun, verb, cond, seq);
delete myPortrait;
@@ -911,7 +866,7 @@
}
bool SciGui::debugEGAdrawingVisualize(bool state) {
- _gfx->setEGAdrawingVisualize(state);
+ _paint16->setEGAdrawingVisualize(state);
return false;
}
Modified: scummvm/trunk/engines/sci/graphics/gui.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gui.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -44,7 +44,10 @@
class Screen;
class SciPalette;
class Cursor;
-class Gfx;
+class GfxCache;
+class GfxCompare;
+class GfxPorts;
+class GfxPaint16;
class WindowMgr;
class SciGuiAnimate;
class Controls;
@@ -54,23 +57,23 @@
class SciGui {
public:
- SciGui(EngineState *s, Screen *screen, SciPalette *palette, Cursor *cursor, AudioPlayer *audio);
+ SciGui(EngineState *s, Screen *screen, SciPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio);
virtual ~SciGui();
virtual void init(bool usesOldGfxFunctions);
virtual void wait(int16 ticks);
- virtual void setPort(uint16 portPtr);
- virtual Common::Rect getPortPic(int16 &picTop, int16 &picLeft);
- virtual void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft, bool initPriorityBandsFlag);
- virtual reg_t getPort();
+ // virtual void setPort(uint16 portPtr);
+ // virtual Common::Rect getPortPic(int16 &picTop, int16 &picLeft);
+ // virtual void setPortPic(Common::Rect rect, int16 picTop, int16 picLeft, bool initPriorityBandsFlag);
+ // virtual reg_t getPort();
virtual void globalToLocal(int16 *x, int16 *y);
virtual void localToGlobal(int16 *x, int16 *y);
virtual int16 coordinateToPriority(int16 y);
virtual int16 priorityToCoordinate(int16 priority);
- virtual reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
- virtual void disposeWindow(uint16 windowPtr, bool reanimate);
+ // virtual reg_t newWindow(Common::Rect dims, Common::Rect restoreRect, uint16 style, int16 priority, int16 colorPen, int16 colorBack, const char *title);
+ // virtual void disposeWindow(uint16 windowPtr, bool reanimate);
virtual void display(const char *text, int argc, reg_t *argv);
@@ -167,7 +170,10 @@
EngineState *_s;
Screen *_screen;
SciPalette *_palette;
- Gfx *_gfx;
+ GfxCache *_cache;
+ GfxCompare *_compare;
+ GfxPorts *_ports;
+ GfxPaint16 *_paint16;
private:
virtual void initPriorityBands();
@@ -176,7 +182,6 @@
static void palVaryCallback(void *refCon);
void doPalVary();
- WindowMgr *_windowMgr;
AudioPlayer *_audio;
SciGuiAnimate *_animate;
Controls *_controls;
Modified: scummvm/trunk/engines/sci/graphics/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui32.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gui32.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -35,7 +35,8 @@
#include "sci/graphics/screen.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/cursor.h"
-#include "sci/graphics/gfx.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/compare.h"
#include "sci/graphics/picture.h"
#include "sci/graphics/robot.h"
#include "sci/graphics/text.h"
@@ -46,11 +47,13 @@
SciGui32::SciGui32(EngineState *state, Screen *screen, SciPalette *palette, Cursor *cursor)
: _s(state), _screen(screen), _palette(palette), _cursor(cursor) {
- _gfx = new Gfx(_s->resMan, _s->_segMan, _s->_kernel, _screen, _palette);
+ _cache = new GfxCache(_s->resMan, _screen, _palette);
+ _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen);
}
SciGui32::~SciGui32() {
- delete _gfx;
+ delete _compare;
+ delete _cache;
}
void SciGui32::resetEngineState(EngineState *s) {
@@ -95,12 +98,12 @@
adjustedRect.translate(0, 10);
- result = _gfx->onControl(screenMask, rect);
+ result = _compare->onControl(screenMask, rect);
return result;
}
void SciGui32::setNowSeen(reg_t objectReference) {
- _gfx->SetNowSeen(objectReference);
+ _compare->SetNowSeen(objectReference);
}
bool SciGui32::canBeHere(reg_t curObject, reg_t listReference) {
@@ -114,19 +117,19 @@
checkRect.bottom = GET_SEL32V(_s->_segMan, curObject, brBottom);
signal = GET_SEL32V(_s->_segMan, curObject, signal);
controlMask = GET_SEL32V(_s->_segMan, curObject, illegalBits);
- result = (_gfx->onControl(SCI_SCREEN_MASK_CONTROL, checkRect) & controlMask) ? false : true;
+ result = (_compare->onControl(SCI_SCREEN_MASK_CONTROL, checkRect) & controlMask) ? false : true;
if ((result)) { // gui16 && (signal & (kSignalIgnoreActor | kSignalRemoveView)) == 0) {
List *list = _s->_segMan->lookupList(listReference);
if (!list)
error("kCanBeHere called with non-list as parameter");
- result = _gfx->CanBeHereCheckRectList(curObject, checkRect, list);
+ result = _compare->CanBeHereCheckRectList(curObject, checkRect, list);
}
return result;
}
bool SciGui32::isItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position) {
- View *tmpView = _gfx->getView(viewId);
+ View *tmpView = _cache->getView(viewId);
CelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo);
position.x = CLIP<int>(position.x, 0, celInfo->width - 1);
position.y = CLIP<int>(position.y, 0, celInfo->height - 1);
@@ -146,7 +149,7 @@
int16 celNo = GET_SEL32V(_s->_segMan, object, cel);
if (viewId != SIGNAL_OFFSET) {
- View *tmpView = _gfx->getView(viewId);
+ View *tmpView = _cache->getView(viewId);
Common::Rect celRect;
tmpView->getCelRect(loopNo, celNo, x, y, z, &celRect);
@@ -215,19 +218,19 @@
}
int16 SciGui32::getCelWidth(GuiResourceId viewId, int16 loopNo, int16 celNo) {
- return _gfx->getView(viewId)->getCelInfo(loopNo, celNo)->width;
+ return _cache->getView(viewId)->getCelInfo(loopNo, celNo)->width;
}
int16 SciGui32::getCelHeight(GuiResourceId viewId, int16 loopNo, int16 celNo) {
- return _gfx->getView(viewId)->getCelInfo(loopNo, celNo)->height;
+ return _cache->getView(viewId)->getCelInfo(loopNo, celNo)->height;
}
int16 SciGui32::getLoopCount(GuiResourceId viewId) {
- return _gfx->getView(viewId)->getLoopCount();
+ return _cache->getView(viewId)->getLoopCount();
}
int16 SciGui32::getCelCount(GuiResourceId viewId, int16 loopNo) {
- return _gfx->getView(viewId)->getLoopInfo(loopNo)->celCount;
+ return _cache->getView(viewId)->getLoopInfo(loopNo)->celCount;
}
void SciGui32::syncWithFramebuffer() {
@@ -320,7 +323,7 @@
if (viewId != 0xffff) {
Common::Rect celRect;
- View *view = _gfx->getView(viewId);
+ View *view = _cache->getView(viewId);
view->getCelRect(loopNo, celNo, x, y, z, &celRect);
Modified: scummvm/trunk/engines/sci/graphics/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui32.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/gui32.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -33,13 +33,13 @@
class Screen;
class SciPalette;
class Cursor;
-class Gfx;
+class GfxCache;
+class GfxCompare;
class Text;
class SciGui32 {
public:
SciGui32(EngineState *s, Screen *screen, SciPalette *palette, Cursor *cursor);
- SciGui32();
~SciGui32();
void init();
@@ -93,7 +93,8 @@
EngineState *_s;
Screen *_screen;
SciPalette *_palette;
- Gfx *_gfx;
+ GfxCache *_cache;
+ GfxCompare *_compare;
private:
Common::Array<reg_t> _screenItems;
Modified: scummvm/trunk/engines/sci/graphics/menu.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.cpp 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/menu.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -31,8 +31,9 @@
#include "sci/event.h"
#include "sci/engine/state.h"
#include "sci/engine/selector.h"
-#include "sci/graphics/helpers.h"
-#include "sci/graphics/gfx.h"
+#include "sci/graphics/gui.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
#include "sci/graphics/animate.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/font.h"
@@ -42,8 +43,8 @@
namespace Sci {
-Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, Gfx *gfx, Text *text, Screen *screen, Cursor *cursor)
- : _event(event), _segMan(segMan), _gui(gui), _gfx(gfx), _text(text), _screen(screen), _cursor(cursor) {
+Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, Screen *screen, Cursor *cursor)
+ : _event(event), _segMan(segMan), _gui(gui), _ports(ports), _paint16(paint16), _text(text), _screen(screen), _cursor(cursor) {
_listCount = 0;
// We actually set active item in here and remember last selection of the user
@@ -302,10 +303,10 @@
GuiMenuList::iterator listEnd = _list.end();
// Hardcoded black on white and a black line afterwards
- _gfx->FillRect(_gfx->_menuBarRect, 1, _screen->getColorWhite());
- _gfx->FillRect(_gfx->_menuLine, 1, 0);
- _gfx->PenColor(0);
- _gfx->MoveTo(8, 1);
+ _paint16->fillRect(_ports->_menuBarRect, 1, _screen->getColorWhite());
+ _paint16->fillRect(_ports->_menuLine, 1, 0);
+ _ports->penColor(0);
+ _ports->moveTo(8, 1);
listIterator = _list.begin();
while (listIterator != listEnd) {
@@ -410,21 +411,21 @@
}
if (!_menuSaveHandle.isNull()) {
- _gfx->BitsRestore(_menuSaveHandle);
+ _paint16->bitsRestore(_menuSaveHandle);
// Display line inbetween menubar and actual menu
Common::Rect menuLine = _menuRect;
menuLine.bottom = menuLine.top + 1;
- _gfx->BitsShow(menuLine);
+ _paint16->bitsShow(menuLine);
_gui->graphRedrawBox(_menuRect);
_menuSaveHandle = NULL_REG;
}
if (!_barSaveHandle.isNull()) {
- _gfx->BitsRestore(_barSaveHandle);
- _gfx->BitsShow(_gfx->_menuRect);
+ _paint16->bitsRestore(_barSaveHandle);
+ _paint16->bitsShow(_ports->_menuRect);
_barSaveHandle = NULL_REG;
}
if (_oldPort)
- _gfx->SetPort(_oldPort);
+ _ports->setPort(_oldPort);
if ((itemEntry) || (forceClaimed))
PUT_SEL32(_segMan, eventObject, claimed, make_reg(0, 1));
@@ -477,18 +478,18 @@
// Remove menu, if one is displayed
if (!_menuSaveHandle.isNull()) {
- _gfx->BitsRestore(_menuSaveHandle);
+ _paint16->bitsRestore(_menuSaveHandle);
// Display line inbetween menubar and actual menu
Common::Rect menuLine = _menuRect;
menuLine.bottom = menuLine.top + 1;
- _gfx->BitsShow(menuLine);
+ _paint16->bitsShow(menuLine);
_gui->graphRedrawBox(_menuRect);
}
// First calculate rect of menu and also invert old and new menu text
- _menuRect.top = _gfx->_menuBarRect.bottom;
- menuTextRect.top = _gfx->_menuBarRect.top;
- menuTextRect.bottom = _gfx->_menuBarRect.bottom;
+ _menuRect.top = _ports->_menuBarRect.bottom;
+ menuTextRect.top = _ports->_menuBarRect.top;
+ menuTextRect.bottom = _ports->_menuBarRect.bottom;
menuTextRect.left = menuTextRect.right = 7;
listIterator = _list.begin();
while (listIterator != listEnd) {
@@ -500,20 +501,20 @@
_menuRect.left = menuTextRect.left;
if ((listNr == newMenuId) || (listNr == oldMenuId)) {
menuTextRect.translate(1, 0);
- _gfx->InvertRect(menuTextRect);
+ _paint16->invertRect(menuTextRect);
menuTextRect.translate(-1, 0);
}
listIterator++;
}
- _gfx->BitsShow(_gfx->_menuBarRect);
+ _paint16->bitsShow(_ports->_menuBarRect);
_menuRect.bottom = _menuRect.top + 2;
listItemIterator = _itemList.begin();
while (listItemIterator != listItemEnd) {
listItemEntry = *listItemIterator;
if (listItemEntry->menuId == newMenuId) {
- _menuRect.bottom += _gfx->_curPort->fontHeight;
+ _menuRect.bottom += _ports->_curPort->fontHeight;
maxTextWidth = MAX<int16>(maxTextWidth, listItemEntry->textWidth);
maxTextRightAlignedWidth = MAX<int16>(maxTextRightAlignedWidth, listItemEntry->textRightAlignedWidth);
}
@@ -525,12 +526,12 @@
_menuRect.right -= 5;
// Save background
- _menuSaveHandle = _gfx->BitsSave(_menuRect, SCI_SCREEN_MASK_VISUAL);
+ _menuSaveHandle = _paint16->bitsSave(_menuRect, SCI_SCREEN_MASK_VISUAL);
// Do the drawing
- _gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, 0);
+ _paint16->fillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, 0);
_menuRect.left++; _menuRect.right--; _menuRect.bottom--;
- _gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->getColorWhite());
+ _paint16->fillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->getColorWhite());
_menuRect.left += 8;
topPos = _menuRect.top + 1;
@@ -539,33 +540,33 @@
listItemEntry = *listItemIterator;
if (listItemEntry->menuId == newMenuId) {
if (!listItemEntry->separatorLine) {
- _gfx->TextGreyedOutput(listItemEntry->enabled ? false : true);
- _gfx->MoveTo(_menuRect.left, topPos);
+ _ports->textGreyedOutput(listItemEntry->enabled ? false : true);
+ _ports->moveTo(_menuRect.left, topPos);
_text->Draw_String(listItemEntry->text.c_str());
- _gfx->MoveTo(_menuRect.right - listItemEntry->textRightAlignedWidth - 5, topPos);
+ _ports->moveTo(_menuRect.right - listItemEntry->textRightAlignedWidth - 5, topPos);
_text->Draw_String(listItemEntry->textRightAligned.c_str());
} else {
// We dont 100% follow sierra here, we draw the line from left to right. Looks better
// BTW. SCI1.1 seems to put 2 pixels and then skip one, we don't do this at all (lsl6)
- pixelPos.y = topPos + (_gfx->_curPort->fontHeight >> 1) - 1;
+ pixelPos.y = topPos + (_ports->_curPort->fontHeight >> 1) - 1;
pixelPos.x = _menuRect.left - 7;
while (pixelPos.x < (_menuRect.right - 1)) {
_screen->putPixel(pixelPos.x, pixelPos.y, SCI_SCREEN_MASK_VISUAL, 0, 0, 0);
pixelPos.x += 2;
}
}
- topPos += _gfx->_curPort->fontHeight;
+ topPos += _ports->_curPort->fontHeight;
}
listItemIterator++;
}
- _gfx->TextGreyedOutput(false);
+ _ports->textGreyedOutput(false);
// Draw the black line again
- _gfx->FillRect(_gfx->_menuLine, 1, 0);
+ _paint16->fillRect(_ports->_menuLine, 1, 0);
_menuRect.left -= 8;
_menuRect.left--; _menuRect.right++; _menuRect.bottom++;
- _gfx->BitsShow(_menuRect);
+ _paint16->bitsShow(_menuRect);
}
void Menu::invertMenuSelection(uint16 itemId) {
@@ -574,12 +575,12 @@
if (itemId == 0)
return;
- itemRect.top += (itemId - 1) * _gfx->_curPort->fontHeight + 1;
- itemRect.bottom = itemRect.top + _gfx->_curPort->fontHeight;
+ itemRect.top += (itemId - 1) * _ports->_curPort->fontHeight + 1;
+ itemRect.bottom = itemRect.top + _ports->_curPort->fontHeight;
itemRect.left++; itemRect.right--;
- _gfx->InvertRect(itemRect);
- _gfx->BitsShow(itemRect);
+ _paint16->invertRect(itemRect);
+ _paint16->bitsShow(itemRect);
}
void Menu::interactiveShowMouse() {
@@ -627,7 +628,7 @@
while (listItemIterator != listItemEnd) {
listItemEntry = *listItemIterator;
if (listItemEntry->menuId == menuId) {
- curYstart += _gfx->_curPort->fontHeight;
+ curYstart += _ports->_curPort->fontHeight;
// Found it
if ((!itemId) && (curYstart > mousePosition.y))
itemId = listItemEntry->id;
@@ -650,17 +651,17 @@
// Also sierra sci didnt allow mouse interaction, when menu was activated via keyboard
calculateTextWidth();
- _oldPort = _gfx->SetPort(_gfx->_menuPort);
- _barSaveHandle = _gfx->BitsSave(_gfx->_menuRect, SCI_SCREEN_MASK_VISUAL);
+ _oldPort = _ports->setPort(_ports->_menuPort);
+ _barSaveHandle = _paint16->bitsSave(_ports->_menuRect, SCI_SCREEN_MASK_VISUAL);
- _gfx->PenColor(0);
- _gfx->BackColor(_screen->getColorWhite());
+ _ports->penColor(0);
+ _ports->backColor(_screen->getColorWhite());
drawBar();
drawMenu(0, curItemEntry->menuId);
invertMenuSelection(curItemEntry->id);
- _gfx->BitsShow(_gfx->_menuRect);
- _gfx->BitsShow(_menuRect);
+ _paint16->bitsShow(_ports->_menuRect);
+ _paint16->bitsShow(_menuRect);
while (true) {
curEvent = _event->get(SCI_EVENT_ANY);
@@ -771,14 +772,14 @@
GuiMenuItemEntry *curItemEntry = NULL;
calculateTextWidth();
- _oldPort = _gfx->SetPort(_gfx->_menuPort);
- _barSaveHandle = _gfx->BitsSave(_gfx->_menuRect, SCI_SCREEN_MASK_VISUAL);
+ _oldPort = _ports->setPort(_ports->_menuPort);
+ _barSaveHandle = _paint16->bitsSave(_ports->_menuRect, SCI_SCREEN_MASK_VISUAL);
- _gfx->PenColor(0);
- _gfx->BackColor(_screen->getColorWhite());
+ _ports->penColor(0);
+ _ports->backColor(_screen->getColorWhite());
drawBar();
- _gfx->BitsShow(_gfx->_menuRect);
+ _paint16->bitsShow(_ports->_menuRect);
while (true) {
curEvent = _event->get(SCI_EVENT_ANY);
@@ -812,7 +813,7 @@
// Menu changed, remove cur menu and paint new menu
drawMenu(curMenuId, newMenuId);
if (firstMenuChange) {
- _gfx->BitsShow(_gfx->_menuBarRect);
+ _paint16->bitsShow(_ports->_menuBarRect);
firstMenuChange = false;
}
curMenuId = newMenuId;
Modified: scummvm/trunk/engines/sci/graphics/menu.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.h 2010-01-31 10:22:09 UTC (rev 47744)
+++ scummvm/trunk/engines/sci/graphics/menu.h 2010-01-31 12:35:15 UTC (rev 47745)
@@ -78,7 +78,7 @@
class Menu {
public:
- Menu(SciEvent *event, SegManager *segMan, SciGui *gui, Gfx *gfx, Text *text, Screen *screen, Cursor *cursor);
+ Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, Screen *screen, Cursor *cursor);
~Menu();
void reset();
@@ -105,7 +105,8 @@
SciEvent *_event;
SegManager *_segMan;
SciGui *_gui;
- Gfx *_gfx;
+ GfxPorts *_ports;
+ GfxPaint16 *_paint16;
Text *_text;
Screen *_screen;
Cursor *_cursor;
Copied: scummvm/trunk/engines/sci/graphics/paint16.cpp (from rev 47743, scummvm/trunk/engines/sci/graphics/gfx.cpp)
===================================================================
--- scummvm/trunk/engines/sci/graphics/paint16.cpp (rev 0)
+++ scummvm/trunk/engines/sci/graphics/paint16.cpp 2010-01-31 12:35:15 UTC (rev 47745)
@@ -0,0 +1,333 @@
+/* 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$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/engine/selector.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
+#include "sci/graphics/animate.h"
+#include "sci/graphics/font.h"
+#include "sci/graphics/picture.h"
+#include "sci/graphics/view.h"
+#include "sci/graphics/screen.h"
+#include "sci/graphics/palette.h"
+#include "sci/graphics/text.h"
+
+namespace Sci {
+
+GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, Screen *screen, SciPalette *palette)
+ : _resMan(resMan), _segMan(segMan), _kernel(kernel), _cache(cache), _ports(ports), _screen(screen), _palette(palette) {
+}
+
+GfxPaint16::~GfxPaint16() {
+}
+
+void GfxPaint16::init(Text *text) {
+ _text = text;
+
+ _EGAdrawingVisualize = false;
+}
+
+void GfxPaint16::setEGAdrawingVisualize(bool state) {
+ _EGAdrawingVisualize = state;
+}
+
+void GfxPaint16::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) {
+ SciGuiPicture *picture = new SciGuiPicture(_resMan, _ports, _screen, _palette, pictureId, _EGAdrawingVisualize);
+
+ // do we add to a picture? if not -> clear screen with white
+ if (!addToFlag)
+ clearScreen(_screen->getColorWhite());
+
+ picture->draw(animationNr, mirroredFlag, addToFlag, paletteId);
+ delete picture;
+}
+
+// This one is the only one that updates screen!
+void GfxPaint16::drawCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
+ View *view = _cache->getView(viewId);
+ Common::Rect celRect;
+
+ if (view) {
+ celRect.left = leftPos;
+ celRect.top = topPos;
+ celRect.right = celRect.left + view->getWidth(loopNo, celNo);
+ celRect.bottom = celRect.top + view->getHeight(loopNo, celNo);
+
+ drawCel(view, loopNo, celNo, celRect, priority, paletteNo, scaleX, scaleY);
+
+ if (getSciVersion() >= SCI_VERSION_1_1) {
+ if (!_screen->_picNotValidSci11) {
+ bitsShow(celRect);
+ }
+ } else {
+ if (!_screen->_picNotValid)
+ bitsShow(celRect);
+ }
+ }
+}
+
+// This version of drawCel is not supposed to call BitsShow()!
+void GfxPaint16::drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
+ drawCel(_cache->getView(viewId), loopNo, celNo, celRect, priority, paletteNo, scaleX, scaleY);
+}
+
+// This version of drawCel is not supposed to call BitsShow()!
+void GfxPaint16::drawCel(View *view, int16 loopNo, int16 celNo, Common::Rect celRect, byte priority, uint16 paletteNo, uint16 scaleX, uint16 scaleY) {
+ Common::Rect clipRect = celRect;
+ clipRect.clip(_ports->_curPort->rect);
+ if (clipRect.isEmpty()) // nothing to draw
+ return;
+
+ Common::Rect clipRectTranslated = clipRect;
+ _ports->offsetRect(clipRectTranslated);
+ if (scaleX == 128 && scaleY == 128) {
+ view->draw(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, paletteNo, false);
+ } else {
+ view->drawScaled(celRect, clipRect, clipRectTranslated, loopNo, celNo, priority, scaleX, scaleY);
+ }
+}
+
+// This is used as replacement for drawCelAndShow() when hires-cels are drawn to screen
+// Hires-cels are available only SCI 1.1+
+void GfxPaint16::drawHiresCelAndShow(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo, reg_t upscaledHiresHandle, uint16 scaleX, uint16 scaleY) {
+ View *view = _cache->getView(viewId);
+ Common::Rect celRect, curPortRect, clipRect, clipRectTranslated;
+ Common::Point curPortPos;
+ bool upscaledHiresHack = false;
+
+ if (view) {
+ if ((leftPos == 0) && (topPos == 0)) {
+ // HACK: in kq6, we get leftPos&topPos == 0 SOMETIMES, that's why we need to get coordinates from upscaledHiresHandle
+ // I'm not sure if this is what we are supposed to do or if there is some other bug that actually makes
+ // coordinates to be 0 in the first place
+ byte *memoryPtr = NULL;
+ memoryPtr = kmem(_segMan, upscaledHiresHandle);
+ if (memoryPtr) {
+ Common::Rect upscaledHiresRect;
+ _screen->bitsGetRect(memoryPtr, &upscaledHiresRect);
+ leftPos = upscaledHiresRect.left;
+ topPos = upscaledHiresRect.top;
+ upscaledHiresHack = true;
+ }
+ }
+
+ celRect.left = leftPos;
+ celRect.top = topPos;
+ celRect.right = celRect.left + view->getWidth(loopNo, celNo);
+ celRect.bottom = celRect.top + view->getHeight(loopNo, celNo);
+ // adjust curPort to upscaled hires
+ clipRect = celRect;
+ curPortRect = _ports->_curPort->rect;
+ curPortRect.top *= 2; curPortRect.bottom *= 2; curPortRect.bottom++;
+ curPortRect.left *= 2; curPortRect.right *= 2; curPortRect.right++;
+ clipRect.clip(curPortRect);
+ if (clipRect.isEmpty()) // nothing to draw
+ return;
+
+ clipRectTranslated = clipRect;
+ if (!upscaledHiresHack) {
+ curPortPos.x = _ports->_curPort->left * 2; curPortPos.y = _ports->_curPort->top * 2;
+ clipRectTranslated.top += curPortPos.y; clipRectTranslated.bottom += curPortPos.y;
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list