SCI: renamed SciPalette to GfxPalette, Screen to GfxScreen, GfxPalette is now called directly w/o SciGui

svn-id: r47752
This commit is contained in:
Martin Kiewitz 2010-01-31 16:21:11 +00:00
parent c991a5bceb
commit 72c2d360f7
41 changed files with 172 additions and 208 deletions

View file

@ -46,6 +46,7 @@
#include "sci/graphics/gui32.h" #include "sci/graphics/gui32.h"
#include "sci/graphics/cursor.h" #include "sci/graphics/cursor.h"
#include "sci/graphics/screen.h" #include "sci/graphics/screen.h"
#include "sci/graphics/palette.h"
#include "sci/parser/vocabulary.h" #include "sci/parser/vocabulary.h"
@ -1059,7 +1060,7 @@ bool Console::cmdSetPalette(int argc, const char **argv) {
uint16 resourceId = atoi(argv[1]); uint16 resourceId = atoi(argv[1]);
_vm->_gamestate->_gui->paletteSet(resourceId, true); _vm->_gamestate->_gfxPalette->kernelSetFromResource(resourceId, true);
return true; return true;
} }
@ -1074,7 +1075,7 @@ bool Console::cmdDrawPic(int argc, const char **argv) {
uint16 resourceId = atoi(argv[1]); uint16 resourceId = atoi(argv[1]);
_vm->_gamestate->_gui->drawPicture(resourceId, 100, false, false, false, 0); _vm->_gamestate->_gui->drawPicture(resourceId, 100, false, false, false, 0);
_vm->_gamestate->_screen->copyToScreen(); _vm->_gamestate->_gfxScreen->copyToScreen();
return true; return true;
} }

View file

@ -39,6 +39,7 @@
#include "sci/graphics/ports.h" #include "sci/graphics/ports.h"
#include "sci/graphics/animate.h" #include "sci/graphics/animate.h"
#include "sci/graphics/cursor.h" #include "sci/graphics/cursor.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/screen.h" #include "sci/graphics/screen.h"
#include "sci/graphics/view.h" #include "sci/graphics/view.h"
@ -618,7 +619,9 @@ reg_t kSetNowSeen(EngineState *s, int argc, reg_t *argv) {
} }
reg_t kPalette(EngineState *s, int argc, reg_t *argv) { reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
if (!s->_gui) // we are called on EGA/amiga games as well, this doesnt make sense.
// doing this would actually break the system EGA/amiga palette
if (!s->resMan->isVGA())
return s->r_acc; return s->r_acc;
switch (argv[0].toUint16()) { switch (argv[0].toUint16()) {
@ -626,21 +629,21 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
if (argc==3) { if (argc==3) {
GuiResourceId resourceId = argv[1].toUint16(); GuiResourceId resourceId = argv[1].toUint16();
bool force = argv[2].toUint16() == 2 ? true : false; bool force = argv[2].toUint16() == 2 ? true : false;
s->_gui->paletteSet(resourceId, force); s->_gfxPalette->kernelSetFromResource(resourceId, force);
} }
break; break;
case 2: { // Set palette-flag(s) case 2: { // Set palette-flag(s)
uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255); uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255); uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255);
uint16 flags = argv[3].toUint16(); uint16 flags = argv[3].toUint16();
s->_gui->paletteSetFlag(fromColor, toColor, flags); s->_gfxPalette->kernelSetFlag(fromColor, toColor, flags);
break; break;
} }
case 3: { // Remove palette-flag(s) case 3: { // Remove palette-flag(s)
uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255); uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255); uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255);
uint16 flags = argv[3].toUint16(); uint16 flags = argv[3].toUint16();
s->_gui->paletteUnsetFlag(fromColor, toColor, flags); s->_gfxPalette->kernelUnsetFlag(fromColor, toColor, flags);
break; break;
} }
case 4: { // Set palette intensity case 4: { // Set palette intensity
@ -652,7 +655,7 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
uint16 intensity = argv[3].toUint16(); uint16 intensity = argv[3].toUint16();
bool setPalette = (argc < 5) ? true : (argv[4].isNull()) ? true : false; bool setPalette = (argc < 5) ? true : (argv[4].isNull()) ? true : false;
s->_gui->paletteSetIntensity(fromColor, toColor, intensity, setPalette); s->_gfxPalette->kernelSetIntensity(fromColor, toColor, intensity, setPalette);
break; break;
} }
default: default:
@ -665,7 +668,7 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
uint16 g = argv[2].toUint16(); uint16 g = argv[2].toUint16();
uint16 b = argv[3].toUint16(); uint16 b = argv[3].toUint16();
return make_reg(0, s->_gui->paletteFind(r, g, b)); return make_reg(0, s->_gfxPalette->kernelFind(r, g, b));
} }
case 6: { // Animate case 6: { // Animate
int16 argNr; int16 argNr;
@ -674,11 +677,11 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
uint16 fromColor = argv[argNr].toUint16(); uint16 fromColor = argv[argNr].toUint16();
uint16 toColor = argv[argNr + 1].toUint16(); uint16 toColor = argv[argNr + 1].toUint16();
int16 speed = argv[argNr + 2].toSint16(); int16 speed = argv[argNr + 2].toSint16();
if (s->_gui->paletteAnimate(fromColor, toColor, speed)) if (s->_gfxPalette->kernelAnimate(fromColor, toColor, speed))
paletteChanged = true; paletteChanged = true;
} }
if (paletteChanged) if (paletteChanged)
s->_gui->paletteAnimateSet(); s->_gfxPalette->kernelAnimateSet();
break; break;
} }
case 7: { // Save palette to heap case 7: { // Save palette to heap

View file

@ -28,6 +28,7 @@
#include "sci/engine/selector.h" #include "sci/engine/selector.h"
#include "sci/engine/kernel.h" #include "sci/engine/kernel.h"
#include "sci/graphics/gui.h" #include "sci/graphics/gui.h"
#include "sci/graphics/palette.h"
#include "common/list.h" #include "common/list.h"
@ -292,10 +293,10 @@ static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int ty
// Red : Barred access // Red : Barred access
// Yellow: Contained access // Yellow: Contained access
int poly_colors[4] = { int poly_colors[4] = {
s->_gui->paletteFind(0, 255, 0), // green s->_gfxPalette->kernelFind(0, 255, 0), // green
s->_gui->paletteFind(0, 0, 255), // blue s->_gfxPalette->kernelFind(0, 0, 255), // blue
s->_gui->paletteFind(255, 0, 0), // red s->_gfxPalette->kernelFind(255, 0, 0), // red
s->_gui->paletteFind(255, 255, 0) // yellow s->_gfxPalette->kernelFind(255, 255, 0) // yellow
}; };
// Clip // Clip
@ -314,8 +315,8 @@ static void draw_point(EngineState *s, Common::Point p, int start, int width, in
// Green: End point // Green: End point
// Blue: Starting point // Blue: Starting point
int point_colors[2] = { int point_colors[2] = {
s->_gui->paletteFind(0, 255, 0), // green s->_gfxPalette->kernelFind(0, 255, 0), // green
s->_gui->paletteFind(0, 0, 255) // blue s->_gfxPalette->kernelFind(0, 0, 255) // blue
}; };
Common::Rect rect = Common::Rect(p.x - 1, p.y - 1, p.x - 1 + 3, p.y - 1 + 3); Common::Rect rect = Common::Rect(p.x - 1, p.y - 1, p.x - 1 + 3, p.y - 1 + 3);

View file

@ -53,7 +53,8 @@ class SciEvent;
class Menubar; class Menubar;
class GfxAnimate; class GfxAnimate;
class GfxPorts; class GfxPorts;
class Screen; class GfxScreen;
class GfxPalette;
class SciGui; class SciGui;
class Cursor; class Cursor;
class MessageState; class MessageState;
@ -152,7 +153,8 @@ public:
GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
GfxPorts *_gfxPorts; // Port managment for 16-bit gfx GfxPorts *_gfxPorts; // Port managment for 16-bit gfx
Screen *_screen; // gfx screen GfxScreen *_gfxScreen;
GfxPalette *_gfxPalette;
SciGui *_gui; /* Currently active Gui */ SciGui *_gui; /* Currently active Gui */
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32

View file

@ -42,7 +42,7 @@
namespace Sci { namespace Sci {
GfxAnimate::GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette, Cursor *cursor, Transitions *transitions) GfxAnimate::GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen, GfxPalette *palette, Cursor *cursor, Transitions *transitions)
: _s(state), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen), _palette(palette), _cursor(cursor), _transitions(transitions) { : _s(state), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen), _palette(palette), _cursor(cursor), _transitions(transitions) {
init(); init();
} }

View file

@ -64,7 +64,7 @@ class SciPalette;
class Transitions; class Transitions;
class GfxAnimate { class GfxAnimate {
public: public:
GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen, SciPalette *palette, Cursor *cursor, Transitions *transitions); GfxAnimate(EngineState *state, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen, GfxPalette *palette, Cursor *cursor, Transitions *transitions);
~GfxAnimate(); ~GfxAnimate();
// FIXME: Don't store EngineState // FIXME: Don't store EngineState
@ -98,8 +98,8 @@ private:
GfxCache *_cache; GfxCache *_cache;
GfxPorts *_ports; GfxPorts *_ports;
GfxPaint16 *_paint16; GfxPaint16 *_paint16;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
Cursor *_cursor; Cursor *_cursor;
Transitions *_transitions; Transitions *_transitions;

View file

@ -36,7 +36,7 @@
namespace Sci { namespace Sci {
GfxCache::GfxCache(ResourceManager *resMan, Screen *screen, SciPalette *palette) GfxCache::GfxCache(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette)
: _resMan(resMan), _screen(screen), _palette(palette) { : _resMan(resMan), _screen(screen), _palette(palette) {
} }

View file

@ -39,7 +39,7 @@ typedef Common::HashMap<int, View *> ViewCache;
class GfxCache { class GfxCache {
public: public:
GfxCache(ResourceManager *resMan, Screen *screen, SciPalette *palette); GfxCache(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette);
~GfxCache(); ~GfxCache();
View *getView(GuiResourceId viewNum); View *getView(GuiResourceId viewNum);
@ -48,8 +48,8 @@ private:
void purgeCache(); void purgeCache();
ResourceManager *_resMan; ResourceManager *_resMan;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
ViewCache _cachedViews; ViewCache _cachedViews;
}; };

View file

@ -38,7 +38,7 @@
namespace Sci { namespace Sci {
GfxCompare::GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, Screen *screen) GfxCompare::GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen)
: _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen) { : _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen) {
} }

View file

@ -36,7 +36,7 @@ class Screen;
class GfxCompare { class GfxCompare {
public: public:
GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, Screen *screen); GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen);
~GfxCompare(); ~GfxCompare();
uint16 onControl(uint16 screenMask, Common::Rect rect); uint16 onControl(uint16 screenMask, Common::Rect rect);
@ -47,7 +47,7 @@ private:
SegManager *_segMan; SegManager *_segMan;
Kernel *_kernel; Kernel *_kernel;
GfxCache *_cache; GfxCache *_cache;
Screen *_screen; GfxScreen *_screen;
}; };
} // End of namespace Sci } // End of namespace Sci

View file

@ -36,7 +36,7 @@
namespace Sci { namespace Sci {
Cursor::Cursor(ResourceManager *resMan, SciPalette *palette, Screen *screen) Cursor::Cursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen)
: _resMan(resMan), _palette(palette), _screen(screen) { : _resMan(resMan), _palette(palette), _screen(screen) {
_upscaledHires = _screen->getUpscaledHires(); _upscaledHires = _screen->getUpscaledHires();

View file

@ -42,7 +42,7 @@ typedef Common::HashMap<int, View *> CursorCache;
class Cursor { class Cursor {
public: public:
Cursor(ResourceManager *resMan, SciPalette *palette, Screen *screen); Cursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *screen);
~Cursor(); ~Cursor();
void show(); void show();
@ -65,8 +65,8 @@ private:
void purgeCache(); void purgeCache();
ResourceManager *_resMan; ResourceManager *_resMan;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
bool _upscaledHires; bool _upscaledHires;

View file

@ -78,7 +78,7 @@ byte *Font::getCharData(byte chr) {
return chr < _numChars ? _resourceData + _chars[chr].offset + 2 : 0; return chr < _numChars ? _resourceData + _chars[chr].offset + 2 : 0;
} }
void Font::draw(Screen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput) { void Font::draw(GfxScreen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput) {
int charWidth = MIN<int>(getCharWidth(chr), screen->getWidth() - left); int charWidth = MIN<int>(getCharWidth(chr), screen->getWidth() - left);
int charHeight = MIN<int>(getCharHeight(chr), screen->getHeight() - top); int charHeight = MIN<int>(getCharHeight(chr), screen->getHeight() - top);
byte b = 0, mask = 0xFF; byte b = 0, mask = 0xFF;

View file

@ -40,7 +40,7 @@ public:
byte getCharWidth(byte chr); byte getCharWidth(byte chr);
byte getCharHeight(byte chr); byte getCharHeight(byte chr);
byte *getCharData(byte chr); byte *getCharData(byte chr);
void draw(Screen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput); void draw(GfxScreen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput);
private: private:
ResourceManager *_resMan; ResourceManager *_resMan;

View file

@ -50,7 +50,7 @@
namespace Sci { namespace Sci {
SciGui::SciGui(EngineState *state, Screen *screen, SciPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio) SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio)
: _s(state), _screen(screen), _palette(palette), _cursor(cursor), _ports(ports), _audio(audio) { : _s(state), _screen(screen), _palette(palette), _cursor(cursor), _ports(ports), _audio(audio) {
_cache = new GfxCache(_s->resMan, _screen, _palette); _cache = new GfxCache(_s->resMan, _screen, _palette);
@ -507,45 +507,6 @@ int16 SciGui::picNotValid(int16 newPicNotValid) {
} }
void SciGui::paletteSet(GuiResourceId resourceId, bool force) {
// we are also called on EGA games as well, this doesnt make sense. doing this would actually break the system EGA palette
if (!_s->resMan->isVGA())
return;
_palette->setFromResource(resourceId, force);
}
void SciGui::paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
_palette->setFlag(fromColor, toColor, flag);
}
void SciGui::paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
_palette->unsetFlag(fromColor, toColor, flag);
}
int16 SciGui::paletteFind(uint16 r, uint16 g, uint16 b) {
return _palette->matchColor(&_palette->_sysPalette, r, g, b) & 0xFF;
}
void SciGui::paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette) {
// we are also called on Amiga as well, but for colors above 32, so it doesnt make sense
if (!_s->resMan->isVGA())
return;
_palette->setIntensity(fromColor, toColor, intensity, setPalette);
}
bool SciGui::paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed) {
// we are also called on Amiga as well, but for colors above 32, so it doesnt make sense
if (!_s->resMan->isVGA())
return false;
return _palette->animate(fromColor, toColor, speed);
}
void SciGui::paletteAnimateSet() {
_palette->setOnScreen();
}
void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) { void SciGui::shakeScreen(uint16 shakeCount, uint16 directions) {
while (shakeCount--) { while (shakeCount--) {
if (directions & SCI_SHAKE_DIRECTION_VERTICAL) if (directions & SCI_SHAKE_DIRECTION_VERTICAL)
@ -755,7 +716,7 @@ void SciGui::stopPalVary() {
_palVaryId = -1; // invalidate the target palette _palVaryId = -1; // invalidate the target palette
// HACK: just set the target palette // HACK: just set the target palette
_palette->setFromResource(_palVaryId, true); _palette->kernelSetFromResource(_palVaryId, true);
} }
void SciGui::palVaryCallback(void *refCon) { void SciGui::palVaryCallback(void *refCon) {

View file

@ -42,7 +42,7 @@ enum {
}; };
class Screen; class Screen;
class SciPalette; class GfxPalette;
class Cursor; class Cursor;
class GfxCache; class GfxCache;
class GfxCompare; class GfxCompare;
@ -57,24 +57,17 @@ class Transitions;
class SciGui { class SciGui {
public: public:
SciGui(EngineState *s, Screen *screen, SciPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio); SciGui(EngineState *s, GfxScreen *screen, GfxPalette *palette, Cursor *cursor, GfxPorts *ports, AudioPlayer *audio);
virtual ~SciGui(); virtual ~SciGui();
virtual void init(bool usesOldGfxFunctions); virtual void init(bool usesOldGfxFunctions);
virtual void wait(int16 ticks); 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 globalToLocal(int16 *x, int16 *y); virtual void globalToLocal(int16 *x, int16 *y);
virtual void localToGlobal(int16 *x, int16 *y); virtual void localToGlobal(int16 *x, int16 *y);
virtual int16 coordinateToPriority(int16 y); virtual int16 coordinateToPriority(int16 y);
virtual int16 priorityToCoordinate(int16 priority); 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 void display(const char *text, int argc, reg_t *argv); virtual void display(const char *text, int argc, reg_t *argv);
virtual void textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight); virtual void textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
@ -112,14 +105,6 @@ public:
virtual int16 picNotValid(int16 newPicNotValid); virtual int16 picNotValid(int16 newPicNotValid);
virtual void paletteSet(GuiResourceId resourceNo, bool force);
virtual void paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
virtual void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
virtual int16 paletteFind(uint16 r, uint16 g, uint16 b);
virtual void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
virtual bool paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed);
virtual void paletteAnimateSet();
virtual void shakeScreen(uint16 shakeCount, uint16 directions); virtual void shakeScreen(uint16 shakeCount, uint16 directions);
virtual uint16 onControl(byte screenMask, Common::Rect rect); virtual uint16 onControl(byte screenMask, Common::Rect rect);
@ -164,8 +149,8 @@ public:
protected: protected:
Cursor *_cursor; Cursor *_cursor;
EngineState *_s; EngineState *_s;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
GfxCache *_cache; GfxCache *_cache;
GfxCompare *_compare; GfxCompare *_compare;
GfxPorts *_ports; GfxPorts *_ports;

View file

@ -44,7 +44,7 @@
namespace Sci { namespace Sci {
SciGui32::SciGui32(EngineState *state, Screen *screen, SciPalette *palette, Cursor *cursor) SciGui32::SciGui32(EngineState *state, GfxScreen *screen, GfxPalette *palette, Cursor *cursor)
: _s(state), _screen(screen), _palette(palette), _cursor(cursor) { : _s(state), _screen(screen), _palette(palette), _cursor(cursor) {
_cache = new GfxCache(_s->resMan, _screen, _palette); _cache = new GfxCache(_s->resMan, _screen, _palette);

View file

@ -39,7 +39,7 @@ class Text;
class SciGui32 { class SciGui32 {
public: public:
SciGui32(EngineState *s, Screen *screen, SciPalette *palette, Cursor *cursor); SciGui32(EngineState *s, GfxScreen *screen, GfxPalette *palette, Cursor *cursor);
~SciGui32(); ~SciGui32();
void init(); void init();
@ -91,8 +91,8 @@ public:
protected: protected:
Cursor *_cursor; Cursor *_cursor;
EngineState *_s; EngineState *_s;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
GfxCache *_cache; GfxCache *_cache;
GfxCompare *_compare; GfxCompare *_compare;

View file

@ -43,7 +43,7 @@
namespace Sci { namespace Sci {
Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, Screen *screen, Cursor *cursor) Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, GfxScreen *screen, Cursor *cursor)
: _event(event), _segMan(segMan), _gui(gui), _ports(ports), _paint16(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; _listCount = 0;

View file

@ -78,7 +78,7 @@ typedef Common::List<GuiMenuItemEntry *> GuiMenuItemList;
class Menu { class Menu {
public: public:
Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, Screen *screen, Cursor *cursor); Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, GfxScreen *screen, Cursor *cursor);
~Menu(); ~Menu();
void reset(); void reset();
@ -108,7 +108,7 @@ private:
GfxPorts *_ports; GfxPorts *_ports;
GfxPaint16 *_paint16; GfxPaint16 *_paint16;
Text *_text; Text *_text;
Screen *_screen; GfxScreen *_screen;
Cursor *_cursor; Cursor *_cursor;
uint16 _listCount; uint16 _listCount;

View file

@ -43,7 +43,7 @@
namespace Sci { namespace Sci {
GfxPaint16::GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, Screen *screen, SciPalette *palette) 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) { : _resMan(resMan), _segMan(segMan), _kernel(kernel), _cache(cache), _ports(ports), _screen(screen), _palette(palette) {
} }

View file

@ -41,7 +41,7 @@ class View;
class GfxPaint16 { class GfxPaint16 {
public: public:
GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, Screen *screen, SciPalette *palette); GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette);
~GfxPaint16(); ~GfxPaint16();
void init(Text *text); void init(Text *text);
@ -74,8 +74,8 @@ private:
Kernel *_kernel; Kernel *_kernel;
GfxCache *_cache; GfxCache *_cache;
GfxPorts *_ports; GfxPorts *_ports;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
Text *_text; Text *_text;
// true means make EGA picture drawing visible // true means make EGA picture drawing visible

View file

@ -33,7 +33,7 @@
namespace Sci { namespace Sci {
SciPalette::SciPalette(ResourceManager *resMan, Screen *screen, bool autoSetPalette) GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen, bool autoSetPalette)
: _resMan(resMan), _screen(screen) { : _resMan(resMan), _screen(screen) {
int16 color; int16 color;
@ -59,17 +59,17 @@ SciPalette::SciPalette(ResourceManager *resMan, Screen *screen, bool autoSetPale
else if (_resMan->isAmiga32color()) else if (_resMan->isAmiga32color())
setAmiga(); setAmiga();
else else
setFromResource(999, true); kernelSetFromResource(999, true);
} }
} }
SciPalette::~SciPalette() { GfxPalette::~GfxPalette() {
} }
#define SCI_PAL_FORMAT_CONSTANT 1 #define SCI_PAL_FORMAT_CONSTANT 1
#define SCI_PAL_FORMAT_VARIABLE 0 #define SCI_PAL_FORMAT_VARIABLE 0
void SciPalette::createFromData(byte *data, Palette *paletteOut) { void GfxPalette::createFromData(byte *data, Palette *paletteOut) {
int palFormat = 0; int palFormat = 0;
int palOffset = 0; int palOffset = 0;
int palColorStart = 0; int palColorStart = 0;
@ -114,7 +114,7 @@ void SciPalette::createFromData(byte *data, Palette *paletteOut) {
} }
// Will try to set amiga palette by using "spal" file. If not found, we return false // Will try to set amiga palette by using "spal" file. If not found, we return false
bool SciPalette::setAmiga() { bool GfxPalette::setAmiga() {
Common::File file; Common::File file;
int curColor, byte1, byte2; int curColor, byte1, byte2;
@ -138,7 +138,7 @@ bool SciPalette::setAmiga() {
} }
// Called from picture class, some amiga sci1 games set half of the palette // Called from picture class, some amiga sci1 games set half of the palette
void SciPalette::modifyAmigaPalette(byte *data) { void GfxPalette::modifyAmigaPalette(byte *data) {
int16 curColor, curPos = 0; int16 curColor, curPos = 0;
byte byte1, byte2; byte byte1, byte2;
for (curColor = 0; curColor < 16; curColor++) { for (curColor = 0; curColor < 16; curColor++) {
@ -151,7 +151,7 @@ void SciPalette::modifyAmigaPalette(byte *data) {
_screen->setPalette(&_sysPalette); _screen->setPalette(&_sysPalette);
} }
void SciPalette::setEGA() { void GfxPalette::setEGA() {
int curColor; int curColor;
byte color1, color2; byte color1, color2;
@ -185,19 +185,7 @@ void SciPalette::setEGA() {
setOnScreen(); setOnScreen();
} }
bool SciPalette::setFromResource(GuiResourceId resourceId, bool force) { void GfxPalette::set(Palette *sciPal, bool force, bool forceRealMerge) {
Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), 0);
Palette palette;
if (palResource) {
createFromData(palResource->data, &palette);
set(&palette, true);
return true;
}
return false;
}
void SciPalette::set(Palette *sciPal, bool force, bool forceRealMerge) {
uint32 systime = _sysPalette.timestamp; uint32 systime = _sysPalette.timestamp;
if (force || sciPal->timestamp != systime) { if (force || sciPal->timestamp != systime) {
merge(sciPal, &_sysPalette, force, forceRealMerge); merge(sciPal, &_sysPalette, force, forceRealMerge);
@ -207,7 +195,7 @@ void SciPalette::set(Palette *sciPal, bool force, bool forceRealMerge) {
} }
} }
void SciPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge) { void GfxPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge) {
uint16 res; uint16 res;
int i,j; int i,j;
@ -269,7 +257,7 @@ void SciPalette::merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealM
pTo->timestamp = g_system->getMillis() * 60 / 1000; pTo->timestamp = g_system->getMillis() * 60 / 1000;
} }
uint16 SciPalette::matchColor(Palette *pPal, byte r, byte g, byte b) { uint16 GfxPalette::matchColor(Palette *pPal, byte r, byte g, byte b) {
byte found = 0xFF; byte found = 0xFF;
int diff = 0x2FFFF, cdiff; int diff = 0x2FFFF, cdiff;
int16 dr,dg,db; int16 dr,dg,db;
@ -294,12 +282,12 @@ uint16 SciPalette::matchColor(Palette *pPal, byte r, byte g, byte b) {
return found; return found;
} }
void SciPalette::getSys(Palette *pal) { void GfxPalette::getSys(Palette *pal) {
if (pal != &_sysPalette) if (pal != &_sysPalette)
memcpy(pal, &_sysPalette,sizeof(Palette)); memcpy(pal, &_sysPalette,sizeof(Palette));
} }
void SciPalette::setOnScreen() { void GfxPalette::setOnScreen() {
// if (pal != &_sysPalette) // if (pal != &_sysPalette)
// memcpy(&_sysPalette,pal,sizeof(Palette)); // memcpy(&_sysPalette,pal,sizeof(Palette));
// We dont change palette at all times for amiga // We dont change palette at all times for amiga
@ -308,28 +296,44 @@ void SciPalette::setOnScreen() {
_screen->setPalette(&_sysPalette); _screen->setPalette(&_sysPalette);
} }
void SciPalette::setFlag(uint16 fromColor, uint16 toColor, uint16 flag) { bool GfxPalette::kernelSetFromResource(GuiResourceId resourceId, bool force) {
Resource *palResource = _resMan->findResource(ResourceId(kResourceTypePalette, resourceId), 0);
Palette palette;
if (palResource) {
createFromData(palResource->data, &palette);
set(&palette, true);
return true;
}
return false;
}
void GfxPalette::kernelSetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
uint16 colorNr; uint16 colorNr;
for (colorNr = fromColor; colorNr < toColor; colorNr++) { for (colorNr = fromColor; colorNr < toColor; colorNr++) {
_sysPalette.colors[colorNr].used |= flag; _sysPalette.colors[colorNr].used |= flag;
} }
} }
void SciPalette::unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) { void GfxPalette::kernelUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
uint16 colorNr; uint16 colorNr;
for (colorNr = fromColor; colorNr < toColor; colorNr++) { for (colorNr = fromColor; colorNr < toColor; colorNr++) {
_sysPalette.colors[colorNr].used &= ~flag; _sysPalette.colors[colorNr].used &= ~flag;
} }
} }
void SciPalette::setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette) { void GfxPalette::kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette) {
memset(&_sysPalette.intensity[0] + fromColor, intensity, toColor - fromColor); memset(&_sysPalette.intensity[0] + fromColor, intensity, toColor - fromColor);
if (setPalette) if (setPalette)
setOnScreen(); setOnScreen();
} }
int16 GfxPalette::kernelFind(uint16 r, uint16 g, uint16 b) {
return matchColor(&_sysPalette, r, g, b) & 0xFF;
}
// Returns true, if palette got changed // Returns true, if palette got changed
bool SciPalette::animate(byte fromColor, byte toColor, int speed) { bool GfxPalette::kernelAnimate(byte fromColor, byte toColor, int speed) {
Color col; Color col;
//byte colorNr; //byte colorNr;
int16 colorCount; int16 colorCount;
@ -383,6 +387,10 @@ bool SciPalette::animate(byte fromColor, byte toColor, int speed) {
return false; return false;
} }
void GfxPalette::kernelAnimateSet() {
setOnScreen();
}
// palVary // palVary
// init - only does, if palVaryOn == false // init - only does, if palVaryOn == false
// target, start, new palette allocation // target, start, new palette allocation

View file

@ -31,16 +31,15 @@
namespace Sci { namespace Sci {
class Screen; class Screen;
class SciPalette { class GfxPalette {
public: public:
SciPalette(ResourceManager *resMan, Screen *screen, bool autoSetPalette = true); GfxPalette(ResourceManager *resMan, GfxScreen *screen, bool autoSetPalette = true);
~SciPalette(); ~GfxPalette();
void createFromData(byte *data, Palette *paletteOut); void createFromData(byte *data, Palette *paletteOut);
bool setAmiga(); bool setAmiga();
void modifyAmigaPalette(byte *data); void modifyAmigaPalette(byte *data);
void setEGA(); void setEGA();
bool setFromResource(GuiResourceId resourceId, bool force);
void set(Palette *sciPal, bool force, bool forceRealMerge = false); void set(Palette *sciPal, bool force, bool forceRealMerge = false);
void merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge); void merge(Palette *pFrom, Palette *pTo, bool force, bool forceRealMerge);
uint16 matchColor(Palette *pPal, byte r, byte g, byte b); uint16 matchColor(Palette *pPal, byte r, byte g, byte b);
@ -48,15 +47,18 @@ public:
void setOnScreen(); void setOnScreen();
void setFlag(uint16 fromColor, uint16 toColor, uint16 flag); bool kernelSetFromResource(GuiResourceId resourceId, bool force);
void unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag); void kernelSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
void setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette); void kernelUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
bool animate(byte fromColor, byte toColor, int speed); void kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
int16 GfxPalette::kernelFind(uint16 r, uint16 g, uint16 b);
bool kernelAnimate(byte fromColor, byte toColor, int speed);
void kernelAnimateSet();
Palette _sysPalette; Palette _sysPalette;
private: private:
Screen *_screen; GfxScreen *_screen;
ResourceManager *_resMan; ResourceManager *_resMan;
Common::Array<PalSchedule> _schedules; Common::Array<PalSchedule> _schedules;

View file

@ -33,7 +33,7 @@
namespace Sci { namespace Sci {
SciGuiPicture::SciGuiPicture(ResourceManager *resMan, GfxPorts *ports, Screen *screen, SciPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize) SciGuiPicture::SciGuiPicture(ResourceManager *resMan, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize)
: _resMan(resMan), _ports(ports), _screen(screen), _palette(palette), _resourceId(resourceId), _EGAdrawingVisualize(EGAdrawingVisualize) { : _resMan(resMan), _ports(ports), _screen(screen), _palette(palette), _resourceId(resourceId), _EGAdrawingVisualize(EGAdrawingVisualize) {
assert(resourceId != -1); assert(resourceId != -1);
initData(resourceId); initData(resourceId);

View file

@ -38,7 +38,7 @@ class SciPalette;
class SciGuiPicture { class SciGuiPicture {
public: public:
SciGuiPicture(ResourceManager *resMan, GfxPorts *ports, Screen *screen, SciPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false); SciGuiPicture(ResourceManager *resMan, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId, bool EGAdrawingVisualize = false);
~SciGuiPicture(); ~SciGuiPicture();
GuiResourceId getResourceId(); GuiResourceId getResourceId();
@ -68,8 +68,8 @@ private:
ResourceManager *_resMan; ResourceManager *_resMan;
GfxPorts *_ports; GfxPorts *_ports;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
int16 _resourceId; int16 _resourceId;
Resource *_resource; Resource *_resource;

View file

@ -38,7 +38,7 @@
namespace Sci { namespace Sci {
Portrait::Portrait(ResourceManager *resMan, SciEvent *event, SciGui *gui, Screen *screen, SciPalette *palette, AudioPlayer *audio, Common::String resourceName) Portrait::Portrait(ResourceManager *resMan, SciEvent *event, SciGui *gui, GfxScreen *screen, GfxPalette *palette, AudioPlayer *audio, Common::String resourceName)
: _resMan(resMan), _event(event), _gui(gui), _screen(screen), _palette(palette), _audio(audio), _resourceName(resourceName) { : _resMan(resMan), _event(event), _gui(gui), _screen(screen), _palette(palette), _audio(audio), _resourceName(resourceName) {
init(); init();
} }

View file

@ -42,7 +42,7 @@ struct PortraitBitmap {
*/ */
class Portrait { class Portrait {
public: public:
Portrait(ResourceManager *resMan, SciEvent *event, SciGui *gui, Screen *screen, SciPalette *palette, AudioPlayer *audio, Common::String resourceName); Portrait(ResourceManager *resMan, SciEvent *event, SciGui *gui, GfxScreen *screen, GfxPalette *palette, AudioPlayer *audio, Common::String resourceName);
~Portrait(); ~Portrait();
void setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq); void setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
@ -58,8 +58,8 @@ private:
ResourceManager *_resMan; ResourceManager *_resMan;
SciEvent *_event; SciEvent *_event;
SciGui *_gui; SciGui *_gui;
SciPalette *_palette; GfxPalette *_palette;
Screen *_screen; GfxScreen *_screen;
AudioPlayer *_audio; AudioPlayer *_audio;
uint16 _height; uint16 _height;

View file

@ -44,7 +44,7 @@ enum {
SCI_WINDOWMGR_STYLE_USER = (1 << 7) SCI_WINDOWMGR_STYLE_USER = (1 << 7)
}; };
GfxPorts::GfxPorts(SegManager *segMan, Screen *screen) GfxPorts::GfxPorts(SegManager *segMan, GfxScreen *screen)
: _segMan(segMan), _screen(screen) { : _segMan(segMan), _screen(screen) {
} }

View file

@ -38,7 +38,7 @@ class Text;
class GfxPorts { class GfxPorts {
public: public:
GfxPorts(SegManager *segMan, Screen *screen); GfxPorts(SegManager *segMan, GfxScreen *screen);
~GfxPorts(); ~GfxPorts();
void init(SciGui *gui, GfxPaint16 *paint16, Text *text, Common::String gameId); void init(SciGui *gui, GfxPaint16 *paint16, Text *text, Common::String gameId);
@ -97,7 +97,7 @@ private:
SegManager *_segMan; SegManager *_segMan;
SciGui *_gui; SciGui *_gui;
GfxPaint16 *_paint16; GfxPaint16 *_paint16;
Screen *_screen; GfxScreen *_screen;
Text *_text; Text *_text;
/** The list of open 'windows' (and ports), in visual order. */ /** The list of open 'windows' (and ports), in visual order. */

View file

@ -31,7 +31,7 @@
namespace Sci { namespace Sci {
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
Robot::Robot(ResourceManager *resMan, Screen *screen, GuiResourceId resourceId) Robot::Robot(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId)
: _resMan(resMan), _screen(screen), _resourceId(resourceId) { : _resMan(resMan), _screen(screen), _resourceId(resourceId) {
assert(resourceId != -1); assert(resourceId != -1);
initData(resourceId); initData(resourceId);

View file

@ -33,7 +33,7 @@ namespace Sci {
#ifdef ENABLE_SCI32 #ifdef ENABLE_SCI32
class Robot { class Robot {
public: public:
Robot(ResourceManager *resMan, Screen *screen, GuiResourceId resourceId); Robot(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId);
~Robot(); ~Robot();
void draw(); void draw();
@ -42,7 +42,7 @@ private:
void initData(GuiResourceId resourceId); void initData(GuiResourceId resourceId);
ResourceManager *_resMan; ResourceManager *_resMan;
Screen *_screen; GfxScreen *_screen;
GuiResourceId _resourceId; GuiResourceId _resourceId;
Resource *_resource; Resource *_resource;

View file

@ -33,7 +33,7 @@
namespace Sci { namespace Sci {
Screen::Screen(ResourceManager *resMan, int16 width, int16 height, bool upscaledHires) : GfxScreen::GfxScreen(ResourceManager *resMan, int16 width, int16 height, bool upscaledHires) :
_resMan(resMan), _width(width), _height(height), _upscaledHires(upscaledHires) { _resMan(resMan), _width(width), _height(height), _upscaledHires(upscaledHires) {
_pixels = _width * _height; _pixels = _width * _height;
@ -75,32 +75,32 @@ Screen::Screen(ResourceManager *resMan, int16 width, int16 height, bool upscaled
initGraphics(_displayWidth, _displayHeight, _displayWidth > 320); initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
} }
Screen::~Screen() { GfxScreen::~GfxScreen() {
free(_visualScreen); free(_visualScreen);
free(_priorityScreen); free(_priorityScreen);
free(_controlScreen); free(_controlScreen);
free(_displayScreen); free(_displayScreen);
} }
void Screen::copyToScreen() { void GfxScreen::copyToScreen() {
g_system->copyRectToScreen(_activeScreen, _displayWidth, 0, 0, _displayWidth, _displayHeight); g_system->copyRectToScreen(_activeScreen, _displayWidth, 0, 0, _displayWidth, _displayHeight);
} }
void Screen::copyFromScreen(byte *buffer) { void GfxScreen::copyFromScreen(byte *buffer) {
Graphics::Surface *screen; Graphics::Surface *screen;
screen = g_system->lockScreen(); screen = g_system->lockScreen();
memcpy(buffer, screen->pixels, _displayWidth * _displayHeight); memcpy(buffer, screen->pixels, _displayWidth * _displayHeight);
g_system->unlockScreen(); g_system->unlockScreen();
} }
void Screen::syncWithFramebuffer() { void GfxScreen::syncWithFramebuffer() {
Graphics::Surface *screen = g_system->lockScreen(); Graphics::Surface *screen = g_system->lockScreen();
memcpy(_displayScreen, screen->pixels, _displayPixels); memcpy(_displayScreen, screen->pixels, _displayPixels);
g_system->unlockScreen(); g_system->unlockScreen();
} }
void Screen::copyRectToScreen(const Common::Rect &rect) { void GfxScreen::copyRectToScreen(const Common::Rect &rect) {
if (!_upscaledHires) { if (!_upscaledHires) {
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height()); g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height());
} else { } else {
@ -109,13 +109,13 @@ void Screen::copyRectToScreen(const Common::Rect &rect) {
} }
// This copies a rect to screen w/o scaling adjustment and is only meant to be used on hires graphics used in upscaled hires mode // This copies a rect to screen w/o scaling adjustment and is only meant to be used on hires graphics used in upscaled hires mode
void Screen::copyDisplayRectToScreen(const Common::Rect &rect) { void GfxScreen::copyDisplayRectToScreen(const Common::Rect &rect) {
if (!_upscaledHires) if (!_upscaledHires)
error("copyDisplayRectToScreen: not in upscaled hires mode"); error("copyDisplayRectToScreen: not in upscaled hires mode");
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height()); g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height());
} }
void Screen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) { void GfxScreen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
if (!_upscaledHires) { if (!_upscaledHires) {
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, x, y, rect.width(), rect.height()); g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, x, y, rect.width(), rect.height());
} else { } else {
@ -123,7 +123,7 @@ void Screen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
} }
} }
byte Screen::getDrawingMask(byte color, byte prio, byte control) { byte GfxScreen::getDrawingMask(byte color, byte prio, byte control) {
byte flag = 0; byte flag = 0;
if (color != 255) if (color != 255)
flag |= SCI_SCREEN_MASK_VISUAL; flag |= SCI_SCREEN_MASK_VISUAL;
@ -134,7 +134,7 @@ byte Screen::getDrawingMask(byte color, byte prio, byte control) {
return flag; return flag;
} }
void Screen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) { void GfxScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) {
int offset = y * _width + x; int offset = y * _width + x;
if (drawMask & SCI_SCREEN_MASK_VISUAL) { if (drawMask & SCI_SCREEN_MASK_VISUAL) {
@ -157,14 +157,14 @@ void Screen::putPixel(int x, int y, byte drawMask, byte color, byte priority, by
// This will just change a pixel directly on displayscreen. Its supposed to get only used on upscaled-Hires games where // This will just change a pixel directly on displayscreen. Its supposed to get only used on upscaled-Hires games where
// hires content needs to get drawn ONTO the upscaled display screen (like japanese fonts, hires portraits, etc.) // hires content needs to get drawn ONTO the upscaled display screen (like japanese fonts, hires portraits, etc.)
void Screen::putPixelOnDisplay(int x, int y, byte color) { void GfxScreen::putPixelOnDisplay(int x, int y, byte color) {
int offset = y * _displayWidth + x; int offset = y * _displayWidth + x;
_displayScreen[offset] = color; _displayScreen[offset] = color;
} }
// Sierra's Bresenham line drawing // Sierra's Bresenham line drawing
// WARNING: Do not just blindly replace this with Graphics::drawLine(), as it seems to create issues with flood fill // WARNING: Do not just blindly replace this with Graphics::drawLine(), as it seems to create issues with flood fill
void Screen::drawLine(Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control) { void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control) {
int16 left = startPoint.x; int16 left = startPoint.x;
int16 top = startPoint.y; int16 top = startPoint.y;
int16 right = endPoint.x; int16 right = endPoint.x;
@ -226,19 +226,19 @@ void Screen::drawLine(Common::Point startPoint, Common::Point endPoint, byte col
} }
} }
byte Screen::getVisual(int x, int y) { byte GfxScreen::getVisual(int x, int y) {
return _visualScreen[y * _width + x]; return _visualScreen[y * _width + x];
} }
byte Screen::getPriority(int x, int y) { byte GfxScreen::getPriority(int x, int y) {
return _priorityScreen[y * _width + x]; return _priorityScreen[y * _width + x];
} }
byte Screen::getControl(int x, int y) { byte GfxScreen::getControl(int x, int y) {
return _controlScreen[y * _width + x]; return _controlScreen[y * _width + x];
} }
byte Screen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con) { byte GfxScreen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con) {
int offset = y * _width + x; int offset = y * _width + x;
byte match = 0; byte match = 0;
@ -251,7 +251,7 @@ byte Screen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, byte t
return match; return match;
} }
int Screen::bitsGetDataSize(Common::Rect rect, byte mask) { int GfxScreen::bitsGetDataSize(Common::Rect rect, byte mask) {
int byteCount = sizeof(rect) + sizeof(mask); int byteCount = sizeof(rect) + sizeof(mask);
int pixels = rect.width() * rect.height(); int pixels = rect.width() * rect.height();
if (mask & SCI_SCREEN_MASK_VISUAL) { if (mask & SCI_SCREEN_MASK_VISUAL) {
@ -277,7 +277,7 @@ int Screen::bitsGetDataSize(Common::Rect rect, byte mask) {
return byteCount; return byteCount;
} }
void Screen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) { void GfxScreen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) {
memcpy(memoryPtr, (void *)&rect, sizeof(rect)); memoryPtr += sizeof(rect); memcpy(memoryPtr, (void *)&rect, sizeof(rect)); memoryPtr += sizeof(rect);
memcpy(memoryPtr, (void *)&mask, sizeof(mask)); memoryPtr += sizeof(mask); memcpy(memoryPtr, (void *)&mask, sizeof(mask)); memoryPtr += sizeof(mask);
@ -298,7 +298,7 @@ void Screen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) {
} }
} }
void Screen::bitsSaveScreen(Common::Rect rect, byte *screen, uint16 screenWidth, byte *&memoryPtr) { void GfxScreen::bitsSaveScreen(Common::Rect rect, byte *screen, uint16 screenWidth, byte *&memoryPtr) {
int width = rect.width(); int width = rect.width();
int y; int y;
@ -310,7 +310,7 @@ void Screen::bitsSaveScreen(Common::Rect rect, byte *screen, uint16 screenWidth,
} }
} }
void Screen::bitsSaveDisplayScreen(Common::Rect rect, byte *&memoryPtr) { void GfxScreen::bitsSaveDisplayScreen(Common::Rect rect, byte *&memoryPtr) {
byte *screen = _displayScreen; byte *screen = _displayScreen;
int width = rect.width(); int width = rect.width();
int y; int y;
@ -329,11 +329,11 @@ void Screen::bitsSaveDisplayScreen(Common::Rect rect, byte *&memoryPtr) {
} }
} }
void Screen::bitsGetRect(byte *memoryPtr, Common::Rect *destRect) { void GfxScreen::bitsGetRect(byte *memoryPtr, Common::Rect *destRect) {
memcpy((void *)destRect, memoryPtr, sizeof(Common::Rect)); memcpy((void *)destRect, memoryPtr, sizeof(Common::Rect));
} }
void Screen::bitsRestore(byte *memoryPtr) { void GfxScreen::bitsRestore(byte *memoryPtr) {
Common::Rect rect; Common::Rect rect;
byte mask; byte mask;
@ -357,7 +357,7 @@ void Screen::bitsRestore(byte *memoryPtr) {
} }
} }
void Screen::bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *screen, uint16 screenWidth) { void GfxScreen::bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *screen, uint16 screenWidth) {
int width = rect.width(); int width = rect.width();
int y; int y;
@ -369,7 +369,7 @@ void Screen::bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *screen
} }
} }
void Screen::bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr) { void GfxScreen::bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr) {
byte *screen = _displayScreen; byte *screen = _displayScreen;
int width = rect.width(); int width = rect.width();
int y; int y;
@ -388,7 +388,7 @@ void Screen::bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr) {
} }
} }
void Screen::setPalette(Palette*pal) { void GfxScreen::setPalette(Palette*pal) {
// just copy palette to system // just copy palette to system
byte bpal[4 * 256]; byte bpal[4 * 256];
// Get current palette, update it and put back // Get current palette, update it and put back
@ -404,14 +404,14 @@ void Screen::setPalette(Palette*pal) {
g_system->setPalette(bpal, 0, 256); g_system->setPalette(bpal, 0, 256);
} }
void Screen::setVerticalShakePos(uint16 shakePos) { void GfxScreen::setVerticalShakePos(uint16 shakePos) {
if (!_upscaledHires) if (!_upscaledHires)
g_system->setShakePos(shakePos); g_system->setShakePos(shakePos);
else else
g_system->setShakePos(shakePos * 2); g_system->setShakePos(shakePos * 2);
} }
void Screen::dither(bool addToFlag) { void GfxScreen::dither(bool addToFlag) {
int y, x; int y, x;
byte color, ditheredColor; byte color, ditheredColor;
byte *visualPtr = _visualScreen; byte *visualPtr = _visualScreen;
@ -477,18 +477,18 @@ void Screen::dither(bool addToFlag) {
} }
} }
void Screen::unditherSetState(bool flag) { void GfxScreen::unditherSetState(bool flag) {
_unditherState = flag; _unditherState = flag;
} }
int16 *Screen::unditherGetMemorial() { int16 *GfxScreen::unditherGetMemorial() {
if (_unditherState) if (_unditherState)
return (int16 *)&_unditherMemorial; return (int16 *)&_unditherMemorial;
else else
return NULL; return NULL;
} }
void Screen::debugShowMap(int mapNo) { void GfxScreen::debugShowMap(int mapNo) {
// We cannot really support changing maps when in upscaledHires mode // We cannot really support changing maps when in upscaledHires mode
if (_upscaledHires) if (_upscaledHires)
return; return;
@ -510,7 +510,7 @@ void Screen::debugShowMap(int mapNo) {
copyToScreen(); copyToScreen();
} }
void Screen::scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight) { void GfxScreen::scale2x(byte *src, byte *dst, int16 srcWidth, int16 srcHeight) {
int newWidth = srcWidth * 2; int newWidth = srcWidth * 2;
byte *srcPtr = src; byte *srcPtr = src;

View file

@ -41,10 +41,10 @@ namespace Sci {
#define SCI_SCREEN_UNDITHERMEMORIAL_SIZE 256 #define SCI_SCREEN_UNDITHERMEMORIAL_SIZE 256
class Screen { class GfxScreen {
public: public:
Screen(ResourceManager *resMan, int16 width = 320, int16 height = 200, bool upscaledHires = false); GfxScreen(ResourceManager *resMan, int16 width = 320, int16 height = 200, bool upscaledHires = false);
~Screen(); ~GfxScreen();
uint16 getWidth() { return _width; }; uint16 getWidth() { return _width; };
uint16 getHeight() { return _height; }; uint16 getHeight() { return _height; };

View file

@ -36,7 +36,7 @@
namespace Sci { namespace Sci {
Text::Text(ResourceManager *resMan, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen) Text::Text(ResourceManager *resMan, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen)
: _resMan(resMan), _ports(ports), _paint16(paint16), _screen(screen) { : _resMan(resMan), _ports(ports), _paint16(paint16), _screen(screen) {
init(); init();
} }

View file

@ -38,7 +38,7 @@ class Screen;
class Font; class Font;
class Text { class Text {
public: public:
Text(ResourceManager *_resMan, GfxPorts *ports, GfxPaint16 *paint16, Screen *screen); Text(ResourceManager *_resMan, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen);
~Text(); ~Text();
GuiResourceId GetFontId(); GuiResourceId GetFontId();
@ -72,7 +72,7 @@ private:
ResourceManager *_resMan; ResourceManager *_resMan;
GfxPorts *_ports; GfxPorts *_ports;
GfxPaint16 *_paint16; GfxPaint16 *_paint16;
Screen *_screen; GfxScreen *_screen;
int _codeFontsCount; int _codeFontsCount;
GuiResourceId *_codeFonts; GuiResourceId *_codeFonts;

View file

@ -37,7 +37,7 @@
namespace Sci { namespace Sci {
Transitions::Transitions(SciGui *gui, Screen *screen, SciPalette *palette, bool isVGA) Transitions::Transitions(SciGui *gui, GfxScreen *screen, GfxPalette *palette, bool isVGA)
: _gui(gui), _screen(screen), _palette(palette), _isVGA(isVGA) { : _gui(gui), _screen(screen), _palette(palette), _isVGA(isVGA) {
init(); init();
} }
@ -292,7 +292,7 @@ void Transitions::fadeIn() {
int16 stepNr; int16 stepNr;
for (stepNr = 0; stepNr <= 100; stepNr += 10) { for (stepNr = 0; stepNr <= 100; stepNr += 10) {
_palette->setIntensity(1, 255, stepNr, true); _palette->kernelSetIntensity(1, 255, stepNr, true);
_gui->wait(2); _gui->wait(2);
} }
} }

View file

@ -62,7 +62,7 @@ enum {
class Screen; class Screen;
class Transitions { class Transitions {
public: public:
Transitions(SciGui *gui, Screen *screen, SciPalette *palette, bool isVGA); Transitions(SciGui *gui, GfxScreen *screen, GfxPalette *palette, bool isVGA);
~Transitions(); ~Transitions();
void setup(int16 number, bool blackoutFlag); void setup(int16 number, bool blackoutFlag);
@ -90,8 +90,8 @@ private:
void updateScreenAndWait(int msec); void updateScreenAndWait(int msec);
SciGui *_gui; SciGui *_gui;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
bool _isVGA; bool _isVGA;
const GuiTransitionTranslateEntry *_translationTable; const GuiTransitionTranslateEntry *_translationTable;

View file

@ -31,7 +31,7 @@
namespace Sci { namespace Sci {
View::View(ResourceManager *resMan, Screen *screen, SciPalette *palette, GuiResourceId resourceId) View::View(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId)
: _resMan(resMan), _screen(screen), _palette(palette), _resourceId(resourceId) { : _resMan(resMan), _screen(screen), _palette(palette), _resourceId(resourceId) {
assert(resourceId != -1); assert(resourceId != -1);
initData(resourceId); initData(resourceId);

View file

@ -53,7 +53,7 @@ class SciPalette;
class View { class View {
public: public:
View(ResourceManager *resMan, Screen *screen, SciPalette *palette, GuiResourceId resourceId); View(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId);
~View(); ~View();
GuiResourceId getResourceId(); GuiResourceId getResourceId();
@ -76,8 +76,8 @@ private:
void unditherBitmap(byte *bitmap, int16 width, int16 height, byte clearKey); void unditherBitmap(byte *bitmap, int16 width, int16 height, byte clearKey);
ResourceManager *_resMan; ResourceManager *_resMan;
Screen *_screen; GfxScreen *_screen;
SciPalette *_palette; GfxPalette *_palette;
GuiResourceId _resourceId; GuiResourceId _resourceId;
Resource *_resource; Resource *_resource;

View file

@ -141,15 +141,15 @@ Common::Error SciEngine::run() {
upscaledHires = true; upscaledHires = true;
// Initialize graphics-related parts // Initialize graphics-related parts
Screen *screen = 0; GfxScreen *screen = 0;
// invokes initGraphics() // invokes initGraphics()
if (_resMan->detectHires()) if (_resMan->detectHires())
screen = new Screen(_resMan, 640, 480, false); screen = new GfxScreen(_resMan, 640, 480, false);
else else
screen = new Screen(_resMan, 320, 200, upscaledHires); screen = new GfxScreen(_resMan, 320, 200, upscaledHires);
SciPalette *palette = new SciPalette(_resMan, screen); GfxPalette *palette = new GfxPalette(_resMan, screen);
Cursor *cursor = new Cursor(_resMan, palette, screen); Cursor *cursor = new Cursor(_resMan, palette, screen);
// Create debugger console. It requires GFX to be initialized // Create debugger console. It requires GFX to be initialized
@ -184,7 +184,8 @@ Common::Error SciEngine::run() {
_gamestate->_ports = new GfxPorts(_segMan, _screen); _gamestate->_ports = new GfxPorts(_segMan, _screen);
_gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor, _audio); _gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor, _audio);
#endif #endif
_gamestate->_screen = screen; _gamestate->_gfxPalette = palette;
_gamestate->_gfxScreen = screen;
if (game_init(_gamestate)) { /* Initialize */ if (game_init(_gamestate)) { /* Initialize */
warning("Game initialization failed: Aborting..."); warning("Game initialization failed: Aborting...");