SCI: added plane coordinate adjustment code for sci32 when drawing pictures, put everything into GfxCoordAdjuster

svn-id: r47939
This commit is contained in:
Martin Kiewitz 2010-02-06 19:35:51 +00:00
parent cf1b03f694
commit 4cae2b13e2
10 changed files with 51 additions and 27 deletions

View file

@ -78,6 +78,12 @@ void GfxCoordAdjuster16::moveCursor(Common::Point &pos) {
pos.x = CLIP<int16>(pos.x, _ports->_picWind->rect.left, _ports->_picWind->rect.right - 1); pos.x = CLIP<int16>(pos.x, _ports->_picWind->rect.left, _ports->_picWind->rect.right - 1);
} }
Common::Rect GfxCoordAdjuster16::pictureGetDisplayArea() {
Common::Rect displayArea(_ports->getPort()->rect.right, _ports->getPort()->rect.bottom);
displayArea.moveTo(_ports->getPort()->left, _ports->getPort()->top);
return displayArea;
};
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
GfxCoordAdjuster32::GfxCoordAdjuster32(SegManager *segMan) GfxCoordAdjuster32::GfxCoordAdjuster32(SegManager *segMan)
: _segMan(segMan) { : _segMan(segMan) {
@ -108,6 +114,14 @@ Common::Rect GfxCoordAdjuster32::onControl(Common::Rect rect) {
adjustedRect.translate(0, 10); adjustedRect.translate(0, 10);
return adjustedRect; return adjustedRect;
} }
void GfxCoordAdjuster32::pictureSetDisplayArea(Common::Rect displayArea) {
_pictureDisplayArea = displayArea;
}
Common::Rect GfxCoordAdjuster32::pictureGetDisplayArea() {
return _pictureDisplayArea;
};
#endif #endif
} // End of namespace Sci } // End of namespace Sci

View file

@ -49,6 +49,8 @@ public:
virtual Common::Rect onControl(Common::Rect rect) { return rect; }; virtual Common::Rect onControl(Common::Rect rect) { return rect; };
virtual void setCursorPos(Common::Point &pos) { }; virtual void setCursorPos(Common::Point &pos) { };
virtual void moveCursor(Common::Point &pos) { }; virtual void moveCursor(Common::Point &pos) { };
virtual Common::Rect pictureGetDisplayArea() { return Common::Rect(0, 0); };
private: private:
}; };
@ -63,6 +65,8 @@ public:
Common::Rect onControl(Common::Rect rect); Common::Rect onControl(Common::Rect rect);
void setCursorPos(Common::Point &pos); void setCursorPos(Common::Point &pos);
void moveCursor(Common::Point &pos); void moveCursor(Common::Point &pos);
Common::Rect pictureGetDisplayArea();
private: private:
GfxPorts *_ports; GfxPorts *_ports;
@ -80,9 +84,14 @@ public:
void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG); void kernelLocalToGlobal(int16 &x, int16 &y, reg_t planeObject = NULL_REG);
Common::Rect onControl(Common::Rect rect); Common::Rect onControl(Common::Rect rect);
void pictureSetDisplayArea(Common::Rect displayArea);
Common::Rect pictureGetDisplayArea();
private: private:
SegManager *_segMan; SegManager *_segMan;
Common::Rect _pictureDisplayArea;
}; };
#endif #endif

View file

@ -32,6 +32,7 @@
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/engine/vm.h" #include "sci/engine/vm.h"
#include "sci/graphics/cache.h" #include "sci/graphics/cache.h"
#include "sci/graphics/coordadjuster.h"
#include "sci/graphics/font.h" #include "sci/graphics/font.h"
#include "sci/graphics/view.h" #include "sci/graphics/view.h"
#include "sci/graphics/screen.h" #include "sci/graphics/screen.h"
@ -41,9 +42,10 @@
namespace Sci { namespace Sci {
GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCache *cache, GfxScreen *screen, GfxPalette *palette, GfxPaint32 *paint32) GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxCache *cache, GfxScreen *screen, GfxPalette *palette, GfxPaint32 *paint32)
: _segMan(segMan), _resMan(resMan), _cache(cache), _screen(screen), _palette(palette), _paint32(paint32) { : _segMan(segMan), _resMan(resMan), _cache(cache), _screen(screen), _palette(palette), _paint32(paint32) {
_coordAdjuster = (GfxCoordAdjuster32 *)coordAdjuster;
_highPlanePri = 0; _highPlanePri = 0;
} }
@ -148,8 +150,10 @@ void GfxFrameout::kernelFrameout() {
planePictureNr = GET_SEL32V(_segMan, planeObject, SELECTOR(picture)); planePictureNr = GET_SEL32V(_segMan, planeObject, SELECTOR(picture));
if ((planePictureNr != 0xFFFF) && (planePictureNr != 0xFFFE)) { if ((planePictureNr != 0xFFFF) && (planePictureNr != 0xFFFE)) {
planePicture = new GfxPicture(_resMan, 0, _screen, _palette, planePictureNr, false); planePicture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, planePictureNr, false);
planePictureCels = planePicture->getSci32celCount(); planePictureCels = planePicture->getSci32celCount();
_coordAdjuster->pictureSetDisplayArea(planeRect);
} }
// Fill our itemlist for this plane // Fill our itemlist for this plane

View file

@ -50,7 +50,7 @@ class GfxPaint32;
*/ */
class GfxFrameout { class GfxFrameout {
public: public:
GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCache *cache, GfxScreen *screen, GfxPalette *palette, GfxPaint32 *paint32); GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxCache *cache, GfxScreen *screen, GfxPalette *palette, GfxPaint32 *paint32);
~GfxFrameout(); ~GfxFrameout();
void kernelAddPlane(reg_t object); void kernelAddPlane(reg_t object);
@ -64,6 +64,7 @@ public:
private: private:
SegManager *_segMan; SegManager *_segMan;
ResourceManager *_resMan; ResourceManager *_resMan;
GfxCoordAdjuster32 *_coordAdjuster;
GfxCache *_cache; GfxCache *_cache;
GfxPalette *_palette; GfxPalette *_palette;
GfxScreen *_screen; GfxScreen *_screen;

View file

@ -54,9 +54,9 @@ SciGui32::SciGui32(EngineState *state, GfxScreen *screen, GfxPalette *palette, G
_cursor->init(_coordAdjuster, _s->_event); _cursor->init(_coordAdjuster, _s->_event);
_compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster); _compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen, _coordAdjuster);
_s->_gfxCompare = _compare; _s->_gfxCompare = _compare;
_paint32 = new GfxPaint32(_s->resMan, _s->_segMan, _s->_kernel, _cache, _screen, _palette); _paint32 = new GfxPaint32(_s->resMan, _s->_segMan, _s->_kernel, _coordAdjuster, _cache, _screen, _palette);
_s->_gfxPaint = _paint32; _s->_gfxPaint = _paint32;
_frameout = new GfxFrameout(_s->_segMan, _s->resMan, _cache, _screen, _palette, _paint32); _frameout = new GfxFrameout(_s->_segMan, _s->resMan, _coordAdjuster, _cache, _screen, _palette, _paint32);
_s->_gfxFrameout = _frameout; _s->_gfxFrameout = _frameout;
} }

View file

@ -64,7 +64,7 @@ void GfxPaint16::setEGAdrawingVisualize(bool state) {
} }
void GfxPaint16::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) { void GfxPaint16::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) {
GfxPicture *picture = new GfxPicture(_resMan, _ports, _screen, _palette, pictureId, _EGAdrawingVisualize); GfxPicture *picture = new GfxPicture(_resMan, _coordAdjuster, _ports, _screen, _palette, pictureId, _EGAdrawingVisualize);
// do we add to a picture? if not -> clear screen with white // do we add to a picture? if not -> clear screen with white
if (!addToFlag) if (!addToFlag)

View file

@ -30,6 +30,7 @@
#include "sci/sci.h" #include "sci/sci.h"
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/graphics/coordadjuster.h"
#include "sci/graphics/cache.h" #include "sci/graphics/cache.h"
#include "sci/graphics/paint32.h" #include "sci/graphics/paint32.h"
#include "sci/graphics/font.h" #include "sci/graphics/font.h"
@ -40,8 +41,8 @@
namespace Sci { namespace Sci {
GfxPaint32::GfxPaint32(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen, GfxPalette *palette) GfxPaint32::GfxPaint32(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCoordAdjuster *coordAdjuster, GfxCache *cache, GfxScreen *screen, GfxPalette *palette)
: _resMan(resMan), _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen), _palette(palette) { : _resMan(resMan), _segMan(segMan), _kernel(kernel), _coordAdjuster(coordAdjuster), _cache(cache), _screen(screen), _palette(palette) {
} }
GfxPaint32::~GfxPaint32() { GfxPaint32::~GfxPaint32() {
@ -57,7 +58,7 @@ void GfxPaint32::fillRect(Common::Rect rect, byte color) {
} }
void GfxPaint32::kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) { void GfxPaint32::kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
GfxPicture *picture = new GfxPicture(_resMan, 0, _screen, _palette, pictureId, false); GfxPicture *picture = new GfxPicture(_resMan, _coordAdjuster, 0, _screen, _palette, pictureId, false);
picture->draw(animationNr, mirroredFlag, addToFlag, EGApaletteNo); picture->draw(animationNr, mirroredFlag, addToFlag, EGApaletteNo);
delete picture; delete picture;

View file

@ -40,7 +40,7 @@ class GfxPorts;
*/ */
class GfxPaint32 : public GfxPaint { class GfxPaint32 : public GfxPaint {
public: public:
GfxPaint32(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen, GfxPalette *palette); GfxPaint32(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCoordAdjuster *coordAdjuster, GfxCache *cache, GfxScreen *screen, GfxPalette *palette);
~GfxPaint32(); ~GfxPaint32();
void fillRect(Common::Rect rect, byte color); void fillRect(Common::Rect rect, byte color);
@ -53,6 +53,7 @@ private:
ResourceManager *_resMan; ResourceManager *_resMan;
SegManager *_segMan; SegManager *_segMan;
Kernel *_kernel; Kernel *_kernel;
GfxCoordAdjuster *_coordAdjuster;
GfxCache *_cache; GfxCache *_cache;
GfxScreen *_screen; GfxScreen *_screen;
GfxPalette *_palette; GfxPalette *_palette;

View file

@ -28,13 +28,14 @@
#include "sci/engine/state.h" #include "sci/engine/state.h"
#include "sci/graphics/screen.h" #include "sci/graphics/screen.h"
#include "sci/graphics/palette.h" #include "sci/graphics/palette.h"
#include "sci/graphics/coordadjuster.h"
#include "sci/graphics/ports.h" #include "sci/graphics/ports.h"
#include "sci/graphics/picture.h" #include "sci/graphics/picture.h"
namespace Sci { namespace Sci {
GfxPicture::GfxPicture(ResourceManager *resMan, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize) GfxPicture::GfxPicture(ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize)
: _resMan(resMan), _ports(ports), _screen(screen), _palette(palette), _resourceId(resourceId), _EGAdrawingVisualize(EGAdrawingVisualize) { : _resMan(resMan), _coordAdjuster(coordAdjuster), _ports(ports), _screen(screen), _palette(palette), _resourceId(resourceId), _EGAdrawingVisualize(EGAdrawingVisualize) {
assert(resourceId != -1); assert(resourceId != -1);
initData(resourceId); initData(resourceId);
} }
@ -280,20 +281,12 @@ void GfxPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rlePos
memcpy(celBitmap, rlePtr, pixelCount); memcpy(celBitmap, rlePtr, pixelCount);
} }
if (_ports) { Common::Rect displayArea = _coordAdjuster->pictureGetDisplayArea();
// Set initial vertical coordinate by using current port
y = callerY + _ports->getPort()->top; y = callerY + displayArea.top;
lastY = MIN<int16>(height + y, _ports->getPort()->rect.bottom + _ports->getPort()->top); lastY = MIN<int16>(height + y, displayArea.bottom);
leftX = callerX + _ports->getPort()->left; leftX = callerX + displayArea.left;
rightX = MIN<int16>(width + leftX, _ports->getPort()->rect.right + _ports->getPort()->left); rightX = MIN<int16>(width + leftX, displayArea.right);
} else {
y = callerY + 10; // TODO: Implement plane support for SCI32
lastY = y + height;
if (lastY > _screen->getHeight())
lastY = _screen->getHeight();
leftX = callerX;
rightX = leftX + width;
}
// Change clearcolor to white, if we dont add to an existing picture. That way we will paint everything on screen // Change clearcolor to white, if we dont add to an existing picture. That way we will paint everything on screen
// but white and that wont matter because the screen is supposed to be already white. It seems that most (if not all) // but white and that wont matter because the screen is supposed to be already white. It seems that most (if not all)

View file

@ -42,7 +42,7 @@ class GfxPalette;
*/ */
class GfxPicture { class GfxPicture {
public: public:
GfxPicture(ResourceManager *resMan, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false); GfxPicture(ResourceManager *resMan, GfxCoordAdjuster *coordAdjuster, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false);
~GfxPicture(); ~GfxPicture();
GuiResourceId getResourceId(); GuiResourceId getResourceId();
@ -73,6 +73,7 @@ private:
void vectorPatternTexturedCircle(Common::Rect box, byte size, byte color, byte prio, byte control, byte texture); void vectorPatternTexturedCircle(Common::Rect box, byte size, byte color, byte prio, byte control, byte texture);
ResourceManager *_resMan; ResourceManager *_resMan;
GfxCoordAdjuster *_coordAdjuster;
GfxPorts *_ports; GfxPorts *_ports;
GfxScreen *_screen; GfxScreen *_screen;
GfxPalette *_palette; GfxPalette *_palette;