aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-07 20:58:33 +0000
committerMartin Kiewitz2009-10-07 20:58:33 +0000
commit0b83993a6476dc63475f985feb20d3044d20d7f8 (patch)
tree4f35c81992876cd02f7e5625c212dcba2b7d89b7
parent20a51e79e889fa10fd0f0b9ba3c66e11855c8b5b (diff)
downloadscummvm-rg350-0b83993a6476dc63475f985feb20d3044d20d7f8.tar.gz
scummvm-rg350-0b83993a6476dc63475f985feb20d3044d20d7f8.tar.bz2
scummvm-rg350-0b83993a6476dc63475f985feb20d3044d20d7f8.zip
SCI/newgui: kDrawPic cleanup, addToFlag inverse detection currently not working needs fixing
svn-id: r44756
-rw-r--r--engines/sci/engine/kgraphics.cpp26
-rw-r--r--engines/sci/gui/gui.cpp7
-rw-r--r--engines/sci/gui/gui.h2
-rw-r--r--engines/sci/gui/gui_gfx.cpp4
-rw-r--r--engines/sci/gui/gui_gfx.h2
-rw-r--r--engines/sci/gui/gui_picture.cpp203
-rw-r--r--engines/sci/gui/gui_picture.h7
-rw-r--r--engines/sci/gui32/gui32.cpp9
-rw-r--r--engines/sci/gui32/gui32.h2
9 files changed, 40 insertions, 222 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index a8c50fbdc1..9a96d07579 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -906,22 +906,30 @@ void _k_view_list_free_backgrounds(EngineState *s, ViewObject *list, int list_nr
reg_t kDrawPic(EngineState *s, int argc, reg_t *argv) {
GuiResourceId pictureId = argv[0].toUint16();
- uint16 flags = 0;
- uint16 style = 1;
+ int16 flags = 0;
+ int16 animationNr = -1;
+ bool mirroredFlag = false;
+ bool addToFlag = false;
int16 EGApaletteNo = 0; // default needs to be 0
- if (argc >= 2)
- style = argv[1].toUint16();
+ if (argc >= 2) {
+ flags = argv[1].toSint16();
+ animationNr = flags & 0xFF;
+ if (flags & K_DRAWPIC_FLAG_MIRRORED)
+ mirroredFlag = true;
+ }
if (argc >= 3) {
- if (!s->_kernel->usesOldGfxFunctions())
- flags = !argv[2].toUint16();
- else
- flags = argv[2].toUint16();
+ // FIXME: usesOldGfxFunctions() seems to be butchered, cause sq3 has it set, but uses bit 0 correctly
+ //if (!s->_kernel->usesOldGfxFunctions())
+ // flags = !argv[2].toUint16();
+ //else
+ if (!argv[2].isNull())
+ addToFlag = true;
}
if (argc >= 4)
EGApaletteNo = argv[3].toUint16();
- s->gui->drawPicture(pictureId, style, flags, EGApaletteNo);
+ s->gui->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
return s->r_acc;
}
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index f04956cb48..c3ca647e80 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -251,15 +251,14 @@ void SciGui::drawStatus(const char *text, int16 colorPen, int16 colorBack) {
_screen->copyToScreen();
}
-void SciGui::drawPicture(GuiResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) {
- bool addToFlag = flags ? true : false;
+void SciGui::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
GuiPort *oldPort = _gfx->SetPort((GuiPort *)_windowMgr->_picWind);
if (_windowMgr->isFrontWindow(_windowMgr->_picWind)) {
- _gfx->drawPicture(pictureId, style, addToFlag, EGApaletteNo);
+ _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
} else {
_windowMgr->BeginUpdate(_windowMgr->_picWind);
- _gfx->drawPicture(pictureId, style, addToFlag, EGApaletteNo);
+ _gfx->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
_windowMgr->EndUpdate(_windowMgr->_picWind);
}
_screen->copyToScreen();
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index ba3f1fd9f4..ee32d66e9f 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -60,7 +60,7 @@ public:
virtual void textColors(int argc, reg_t *argv);
virtual void drawStatus(const char *text, int16 colorPen, int16 colorBack);
- virtual void drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo);
+ virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
virtual void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
virtual void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);
diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp
index 25010eb3f6..fdb7445408 100644
--- a/engines/sci/gui/gui_gfx.cpp
+++ b/engines/sci/gui/gui_gfx.cpp
@@ -994,7 +994,7 @@ void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control)
}
}
-void SciGuiGfx::drawPicture(GuiResourceId pictureId, uint16 style, bool addToFlag, GuiResourceId paletteId) {
+void SciGuiGfx::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId) {
SciGuiPicture *picture;
picture = new SciGuiPicture(_s, this, _screen, _palette, pictureId);
@@ -1005,7 +1005,7 @@ void SciGuiGfx::drawPicture(GuiResourceId pictureId, uint16 style, bool addToFla
else
ClearScreen(15);
}
- picture->draw(style, addToFlag, paletteId);
+ picture->draw(animationNr, mirroredFlag, addToFlag, paletteId);
}
void SciGuiGfx::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo) {
diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h
index 6ee4ce992b..05ef4d46b5 100644
--- a/engines/sci/gui/gui_gfx.h
+++ b/engines/sci/gui/gui_gfx.h
@@ -101,7 +101,7 @@ public:
void Draw_String(const char *text);
void Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control);
- void drawPicture(GuiResourceId pictureId, uint16 style, bool addToFlag, GuiResourceId paletteId);
+ void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId);
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo);
int16 onControl(uint16 screenMask, Common::Rect rect);
diff --git a/engines/sci/gui/gui_picture.cpp b/engines/sci/gui/gui_picture.cpp
index 9075070319..c1df49ad3b 100644
--- a/engines/sci/gui/gui_picture.cpp
+++ b/engines/sci/gui/gui_picture.cpp
@@ -53,8 +53,9 @@ GuiResourceId SciGuiPicture::getResourceId() {
return _resourceId;
}
-void SciGuiPicture::draw(uint16 style, bool addToFlag, int16 EGApaletteNo) {
- _style = style;
+void SciGuiPicture::draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
+ _animationNr = animationNr;
+ _mirroredFlag = mirroredFlag;
_addToFlag = addToFlag;
_EGApaletteNo = EGApaletteNo;
_priority = 0;
@@ -518,15 +519,15 @@ void SciGuiPicture::vectorGetAbsCoords(byte *data, int &curPos, int16 &x, int16
byte byte = data[curPos++];
x = data[curPos++] + ((byte & 0xF0) << 4);
y = data[curPos++] + ((byte & 0x0F) << 8);
- if (_style & PIC_STYLE_MIRRORED) x = 319 - x;
+ if (_mirroredFlag) x = 319 - x;
}
void SciGuiPicture::vectorGetRelCoords(byte *data, int &curPos, int16 &x, int16 &y) {
byte byte = data[curPos++];
if (byte & 0x80) {
- x -= ((byte >> 4) & 7) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+ x -= ((byte >> 4) & 7) * (_mirroredFlag ? -1 : 1);
} else {
- x += (byte >> 4) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+ x += (byte >> 4) * (_mirroredFlag ? -1 : 1);
}
if (byte & 0x08) {
y -= (byte & 7);
@@ -544,9 +545,9 @@ void SciGuiPicture::vectorGetRelCoordsMed(byte *data, int &curPos, int16 &x, int
}
byte = data[curPos++];
if (byte & 0x80) {
- x -= (128 - (byte & 0x7F)) * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+ x -= (128 - (byte & 0x7F)) * (_mirroredFlag ? -1 : 1);
} else {
- x += byte * (_style & PIC_STYLE_MIRRORED ? -1 : 1);
+ x += byte * (_mirroredFlag ? -1 : 1);
}
}
@@ -556,192 +557,4 @@ void SciGuiPicture::vectorGetPatternTexture(byte *data, int &curPos, int16 patte
}
}
-#if 0
-void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control) {
-
-void SciGuiPicture::vectorFloodFillRecursive(byte *data, int &curPos, int16 &x, int16 &y) {
-
-void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds,
- int legalcolor, int legalmask, int color, int priority, int drawenable, int sci_titlebar_size) {
- int linewidth = pic->mode->scaleFactor * 320;
- int miny = pic->mode->scaleFactor * sci_titlebar_size;
- int maxy = pic->mode->scaleFactor * 200;
- int xl, xr;
- int oldytotal = y * linewidth;
-
- do {
- int ytotal = oldytotal + (linewidth * dy);
- int xcont;
- int state;
-
- y += dy;
-
- if (y < miny || y >= maxy) {
- error("ABRT on failed initial assertion!");
- return;
- }
-# define proj_xl_bound 0
-# define proj_xr_bound 319
-
- // Now we have the projected limits, get the real ones:
-
- xl = (old_xl > proj_xl_bound) ? old_xl : proj_xl_bound;
- if (!IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { // go left as far as possible
- while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y + 1, bounds[ytotal + xl - 1])))
- --xl;
- } else // go right until the fillable area starts
- while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])))
- ++xl;
-
-
- if ((xl > proj_xr_bound)
- || (xl > old_xr)) {
- error("ABRT because xl > xr_bound");
- return;
- }
-
- xr = (xl > old_xl) ? xl : old_xl;
- while (xr < proj_xr_bound && (!IS_BOUNDARY(xr + 1, y + 1, bounds[ytotal + xr + 1])))
- ++xr;
-
- PRINT_DEBUG1("%d> -> ", xr);
-
- if (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) {
- error("ABRT because xl illegal");
- return;
- }
-
- if (drawenable & GFX_MASK_VISUAL)
- memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
-
- if (drawenable & GFX_MASK_PRIORITY)
- memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
-
-
- // Check whether we need to recurse on branches in the same direction
- state = 0;
- xcont = xr + 1;
- while (xcont <= old_xr) {
- if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont]))
- state = xcont;
- else if (state) { // recurse
- vectorFloodFillRecursive(pic, state, xcont, y - dy, dy, bounds, legalcolor,
- legalmask, color, priority, drawenable, sci_titlebar_size);
- state = 0;
- }
- ++xcont;
- }
-
- // Check whether we need to recurse on backward branches:
- // left
- if (xl < old_xl - 1) {
- state = 0;
- for (xcont = old_xl - 1; xcont >= xl; xcont--) {
- if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
- state = xcont;
- else if (state) { // recurse
- vectorFloodFillRecursive(pic, xcont, state, y, -dy, bounds,
- legalcolor, legalmask, color, priority, drawenable,
- sci_titlebar_size);
- state = 0;
- }
- }
- }
-
- // right
- if (xr > old_xr + 1) {
- state = 0;
- for (xcont = old_xr + 1; xcont <= xr; xcont++) {
- if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
- state = xcont;
- else if (state) { // recurse
- vectorFloodFillRecursive(pic, state, xcont, y, -dy, bounds,
- legalcolor, legalmask, color, priority, drawenable,
- sci_titlebar_size);
- state = 0;
- }
- }
- }
-
- oldytotal = ytotal;
- old_xl = xl;
- old_xr = xr;
-
- } while (1);
-}
-
-void SciGuiPicture::vectorFloodFillRecursive(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable,
- int sci_titlebar_size) {
- int linewidth = pic->mode->scaleFactor * 320;
- int x, y;
- int xl, xr;
- int ytotal;
- int bitmask;
- byte *bounds = NULL;
- int legalcolor, legalmask;
- int original_drawenable = drawenable; // Backup, since we need the unmodified value
- // for filling the aux and control map
-
- // Restrict drawenable not to restrict itself to zero
- if (pic->control_map->index_data[y_200 * 320 + x_320] != 0)
- drawenable &= ~GFX_MASK_CONTROL;
-
- if (color == 0xff)
- drawenable &= ~GFX_MASK_VISUAL;
-
- if (priority == 0) {
- drawenable &= ~GFX_MASK_PRIORITY;
- original_drawenable &= ~GFX_MASK_PRIORITY;
- }
-
- AUXBUF_FILL(pic, x_320, y_200, original_drawenable, (drawenable & GFX_MASK_CONTROL) ? control : 0,
- sci_titlebar_size);
-
- x = x_320;
- y = y_200;
-
- ytotal = y * linewidth;
-
- if (!drawenable)
- return;
-
- if (drawenable & GFX_MASK_VISUAL) {
- bounds = pic->visual_map->index_data;
- legalmask = 0x0ff0;
- legalcolor = 0xff;
- } else if (drawenable & GFX_MASK_PRIORITY) {
- bounds = pic->priority_map->index_data;
- legalcolor = 0;
- legalmask = 0x0f0f;
- } else {
- legalcolor = 0;
- legalmask = 0x0f0f;
- }
-
- if (!bounds || IS_BOUNDARY(x, y, bounds[ytotal + x]))
- return;
-
- if (bounds) {
- xl = x;
- while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y, bounds[ytotal + xl -1])))
- --xl;
-
- while (x < proj_xr_bound && (!IS_BOUNDARY(x + 1, y, bounds[ytotal + x + 1])))
- ++x;
- xr = x;
-
- if (drawenable & GFX_MASK_VISUAL)
- memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
-
- if (drawenable & GFX_MASK_PRIORITY)
- memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
-
- vectorFloodFillRecursive(pic, xl, xr, y, -1, bounds, legalcolor, legalmask, color, priority, drawenable,
- sci_titlebar_size);
- vectorFloodFillRecursive(pic, xl, xr, y, + 1, bounds, legalcolor, legalmask, color, priority, drawenable,
- sci_titlebar_size);
- }
-}
-#endif
-
} // End of namespace Sci
diff --git a/engines/sci/gui/gui_picture.h b/engines/sci/gui/gui_picture.h
index 541cc7d3d6..f60b5c059e 100644
--- a/engines/sci/gui/gui_picture.h
+++ b/engines/sci/gui/gui_picture.h
@@ -28,15 +28,13 @@
namespace Sci {
-#define PIC_STYLE_MIRRORED 0x4000
-
class SciGuiPicture {
public:
SciGuiPicture(EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, SciGuiPalette *palette, GuiResourceId resourceId);
~SciGuiPicture();
GuiResourceId getResourceId();
- void draw(uint16 style, bool addToFlag, int16 EGApaletteNo);
+ void draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
private:
void initData(GuiResourceId resourceId);
@@ -59,7 +57,8 @@ private:
int16 _resourceId;
Resource *_resource;
- uint16 _style;
+ int16 _animationNr;
+ bool _mirroredFlag;
bool _addToFlag;
int16 _EGApaletteNo;
byte _priority;
diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp
index af0ddebd2c..329d55db28 100644
--- a/engines/sci/gui32/gui32.cpp
+++ b/engines/sci/gui32/gui32.cpp
@@ -497,11 +497,10 @@ void SciGui32::drawStatus(const char *text, int16 colorPen, int16 colorBack) {
gfxop_update(s->gfx_state);
}
-void SciGui32::drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo) {
+void SciGui32::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo) {
drawn_pic_t dp;
gfx_color_t transparent = s->wm_port->_bgcolor;
int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
- bool add_to_pic = flags;
dp.nr = pictureId;
if (EGApaletteNo != -1) {
@@ -510,7 +509,7 @@ void SciGui32::drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 fla
dp.palette = 0;
}
- if (showStyle & K_DRAWPIC_FLAG_MIRRORED)
+ if (mirroredFlag)
picFlags |= DRAWPIC1_FLAG_MIRRORED;
gfxop_disable_dirty_frames(s->gfx_state);
@@ -522,7 +521,7 @@ void SciGui32::drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 fla
s->old_screen = gfxop_grab_pixmap(s->gfx_state, gfx_rect(0, 10, 320, 190));
debugC(2, kDebugLevelGraphics, "Drawing pic.%03d\n", pictureId);
- if (add_to_pic) {
+ if (addToFlag) {
gfxop_add_to_pic(s->gfx_state, dp.nr, picFlags, dp.palette);
} else {
gfxop_new_pic(s->gfx_state, dp.nr, picFlags, dp.palette);
@@ -546,7 +545,7 @@ void SciGui32::drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 fla
s->pic_priority_table = gfxop_get_pic_metainfo(s->gfx_state);
- s->pic_animate = showStyle & 0xff; // The animation used during kAnimate() later on
+ s->pic_animate = animationNr; // The animation used during kAnimate() later on
s->dyn_views = NULL;
s->drop_views = NULL;
diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h
index c2fa45da8a..f134e86fba 100644
--- a/engines/sci/gui32/gui32.h
+++ b/engines/sci/gui32/gui32.h
@@ -53,7 +53,7 @@ public:
void textColors(int argc, reg_t *argv);
void drawStatus(const char *text, int16 colorPen, int16 colorBack);
- void drawPicture(GuiResourceId pictureId, uint16 showStyle, uint16 flags, int16 EGApaletteNo);
+ void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);