SCI: adding GfxPaint class, implementing kernelDrawPicture for GfxPaint16 and GfxPaint32, using those classes directly when drawing pictures instead of SciGui/32. Making draw_pic command work in sci32 that way, using _gfxPaint16 for kDrawPic because that command is sci16 exclusive

svn-id: r47883
This commit is contained in:
Martin Kiewitz 2010-02-04 19:22:40 +00:00
parent 5dc8f75b68
commit 3ce2e22978
13 changed files with 142 additions and 24 deletions

View File

@ -46,6 +46,7 @@
#include "sci/graphics/gui32.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/paint.h"
#include "sci/graphics/palette.h"
#include "sci/parser/vocabulary.h"
@ -1075,7 +1076,7 @@ bool Console::cmdDrawPic(int argc, const char **argv) {
uint16 resourceId = atoi(argv[1]);
_engine->_gamestate->_gui->drawPicture(resourceId, 100, false, false, false, 0);
_engine->_gamestate->_gfxPaint->kernelDrawPicture(resourceId, 100, false, false, false, 0);
_engine->_gamestate->_gfxScreen->copyToScreen();
return true;
}

View File

@ -41,6 +41,7 @@
#include "sci/graphics/controls.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/paint16.h"
#include "sci/graphics/ports.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/view.h"
@ -559,7 +560,7 @@ reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
if (argc >= 4)
EGApaletteNo = argv[3].toUint16();
s->_gui->drawPicture(pictureId, animationNr, animationBlackoutFlag, mirroredFlag, addToFlag, EGApaletteNo);
s->_gfxPaint16->kernelDrawPicture(pictureId, animationNr, animationBlackoutFlag, mirroredFlag, addToFlag, EGApaletteNo);
return s->r_acc;
}

View File

@ -55,6 +55,9 @@ class GfxAnimate;
class GfxCache;
class GfxControls;
class GfxMenu;
class GfxPaint;
class GfxPaint16;
class GfxPaint32;
class GfxPalette;
class GfxPorts;
class GfxScreen;
@ -152,6 +155,8 @@ public:
GfxControls *_gfxControls; // Controls for 16-bit gfx
GfxMenu *_gfxMenu; // Menu for 16-bit gfx
GfxPalette *_gfxPalette;
GfxPaint *_gfxPaint;
GfxPaint16 *_gfxPaint16; // Painting in 16-bit gfx
GfxPorts *_gfxPorts; // Port managment for 16-bit gfx
GfxScreen *_gfxScreen;
SciGui *_gui; /* Currently active Gui */

View File

@ -54,8 +54,10 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
: _s(state), _screen(screen), _palette(palette), _cache(cache), _cursor(cursor), _ports(ports), _audio(audio) {
_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());
_paint16 = new GfxPaint16(_s->resMan, _s->_segMan, _s->_kernel, _cache, _ports, _screen, _palette, _transitions);
_s->_gfxPaint = _paint16;
_s->_gfxPaint16 = _paint16;
_animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions);
_s->_gfxAnimate = _animate;
_text16 = new GfxText16(_s->resMan, _cache, _ports, _paint16, _screen);
@ -276,21 +278,6 @@ void SciGui::drawMenuBar(bool clear) {
}
}
void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
if (_ports->isFrontWindow(_ports->_picWind)) {
_screen->_picNotValid = 1;
_paint16->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_transitions->setup(animationNr, animationBlackoutFlag);
} else {
_ports->beginUpdate(_ports->_picWind);
_paint16->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_ports->endUpdate(_ports->_picWind);
}
_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())) {

View File

@ -76,7 +76,6 @@ public:
virtual void drawStatus(const char *text, int16 colorPen, int16 colorBack);
virtual void drawMenuBar(bool clear);
virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
virtual void drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo, bool hiresMode = false, reg_t upscaledHiresHandle = NULL_REG);
virtual void graphFillBoxForeground(Common::Rect rect);

View File

@ -50,6 +50,7 @@ SciGui32::SciGui32(EngineState *state, GfxScreen *screen, GfxPalette *palette, G
_compare = new GfxCompare(_s->_segMan, _s->_kernel, _cache, _screen);
_paint32 = new GfxPaint32(_s->resMan, _s->_segMan, _s->_kernel, _cache, _screen, _palette);
_s->_gfxPaint = _paint32;
_frameout = new GfxFrameout(_s->_segMan, _s->resMan, _cache, _screen, _palette, _paint32);
}

View File

@ -0,0 +1,46 @@
/* 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/paint.h"
namespace Sci {
GfxPaint::GfxPaint() {
}
GfxPaint::~GfxPaint() {
}
void GfxPaint::kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
}
} // End of namespace Sci

View File

@ -0,0 +1,47 @@
/* 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_PAINT_H
#define SCI_GRAPHICS_PAINT_H
#include "sci/graphics/gui.h"
#include "common/hashmap.h"
namespace Sci {
class GfxPaint {
public:
GfxPaint();
virtual ~GfxPaint();
virtual void kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
private:
};
} // End of namespace Sci
#endif

View File

@ -40,11 +40,12 @@
#include "sci/graphics/screen.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/text16.h"
#include "sci/graphics/transitions.h"
namespace Sci {
GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette)
: _resMan(resMan), _segMan(segMan), _kernel(kernel), _cache(cache), _ports(ports), _screen(screen), _palette(palette) {
GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, Transitions *transitions)
: _resMan(resMan), _segMan(segMan), _kernel(kernel), _cache(cache), _ports(ports), _screen(screen), _palette(palette), _transitions(transitions) {
}
GfxPaint16::~GfxPaint16() {
@ -330,4 +331,19 @@ void GfxPaint16::bitsFree(reg_t memoryHandle) {
}
}
void GfxPaint16::kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
Port *oldPort = _ports->setPort((Port *)_ports->_picWind);
if (_ports->isFrontWindow(_ports->_picWind)) {
_screen->_picNotValid = 1;
drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_transitions->setup(animationNr, animationBlackoutFlag);
} else {
_ports->beginUpdate(_ports->_picWind);
drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_ports->endUpdate(_ports->_picWind);
}
_ports->setPort(oldPort);
}
} // End of namespace Sci

View File

@ -27,6 +27,7 @@
#define SCI_GRAPHICS_PAINT16_H
#include "sci/graphics/gui.h"
#include "sci/graphics/paint.h"
#include "common/hashmap.h"
@ -39,9 +40,9 @@ class Font;
class SciGuiPicture;
class View;
class GfxPaint16 {
class GfxPaint16 : public GfxPaint {
public:
GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette);
GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, Transitions *transitions);
~GfxPaint16();
void init(GfxText16 *text16);
@ -68,6 +69,8 @@ public:
void bitsRestore(reg_t memoryHandle);
void bitsFree(reg_t memoryHandle);
void kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
private:
ResourceManager *_resMan;
SegManager *_segMan;
@ -77,6 +80,7 @@ private:
GfxScreen *_screen;
GfxPalette *_palette;
GfxText16 *_text16;
Transitions *_transitions;
// true means make EGA picture drawing visible
bool _EGAdrawingVisualize;

View File

@ -56,4 +56,11 @@ void GfxPaint32::fillRect(Common::Rect rect, byte color) {
}
}
void GfxPaint32::kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
SciGuiPicture *picture = new SciGuiPicture(_resMan, 0, _screen, _palette, pictureId, false);
picture->draw(animationNr, mirroredFlag, addToFlag, EGApaletteNo);
delete picture;
}
} // End of namespace Sci

View File

@ -27,6 +27,7 @@
#define SCI_GRAPHICS_PAINT32_H
#include "sci/graphics/gui.h"
#include "sci/graphics/paint.h"
#include "common/hashmap.h"
@ -34,13 +35,15 @@ namespace Sci {
class GfxPorts;
class GfxPaint32 {
class GfxPaint32 : public GfxPaint {
public:
GfxPaint32(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen, GfxPalette *palette);
~GfxPaint32();
void fillRect(Common::Rect rect, byte color);
void kernelDrawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
private:
ResourceManager *_resMan;
SegManager *_segMan;

View File

@ -42,6 +42,7 @@ MODULE_OBJS := \
graphics/font.o \
graphics/gui.o \
graphics/menu.o \
graphics/paint.o \
graphics/paint16.o \
graphics/palette.o \
graphics/picture.o \