Rewrote kBaseSetter() to use new graphics functions and behave like the original, and fixed a bug in the process (the previous code ignored z when calculating the height)

svn-id: r45463
This commit is contained in:
Filippos Karapetis 2009-10-28 14:23:23 +00:00
parent effb6b60eb
commit 394fc76719
4 changed files with 32 additions and 88 deletions

View File

@ -3151,7 +3151,7 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) {
nsrect = get_nsrect(s, pos, 0);
nsrect_clipped = get_nsrect(s, pos, 1);
brrect = set_base(s, pos);
//brrect = set_base(s, pos);
printf("new nsRect: [%d..%d]x[%d..%d]\n", nsrect.x, nsrect.xend, nsrect.y, nsrect.yend);
printf("new clipped nsRect: [%d..%d]x[%d..%d]\n", nsrect_clipped.x, nsrect_clipped.xend, nsrect_clipped.y, nsrect_clipped.yend);
printf("new brRect: [%d..%d]x[%d..%d]\n", brrect.x, brrect.xend, brrect.y, brrect.yend);

View File

@ -28,7 +28,6 @@
#include "sci/resource.h"
#include "sci/engine/state.h"
#include "sci/engine/kernel_types.h"
#include "sci/gfx/operations.h" // for gfxop_get_cel_parameters
namespace Sci {
@ -729,69 +728,4 @@ bool Kernel::loadKernelNames() {
return true;
}
Common::Rect set_base(EngineState *s, reg_t object) {
SegManager *segMan = s->_segMan;
int x, y, original_y, z, ystep, xsize = 0, ysize = 0;
int xbase, ybase, xend, yend;
int view, loop, cel;
int oldloop, oldcel;
int xmod = 0, ymod = 0;
Common::Rect retval;
x = (int16)GET_SEL32V(segMan, object, x);
original_y = y = (int16)GET_SEL32V(segMan, object, y);
if (s->_kernel->_selectorCache.z > -1)
z = (int16)GET_SEL32V(segMan, object, z);
else
z = 0;
y -= z; // Subtract z offset
ystep = (int16)GET_SEL32V(segMan, object, yStep);
view = (int16)GET_SEL32V(segMan, object, view);
int l = GET_SEL32V(segMan, object, loop);
oldloop = loop = (l & 0x80) ? l - 256 : l;
int c = GET_SEL32V(segMan, object, cel);
oldcel = cel = (c & 0x80) ? c - 256 : c;
Common::Point offset = Common::Point(0, 0);
if (loop != oldloop) {
loop = 0;
PUT_SEL32V(segMan, object, loop, 0);
debugC(2, kDebugLevelGraphics, "Resetting loop for %04x:%04x!\n", PRINT_REG(object));
}
if (cel != oldcel) {
cel = 0;
PUT_SEL32V(segMan, object, cel, 0);
}
#ifdef INCLUDE_OLDGFX
gfxop_get_cel_parameters(s->gfx_state, view, loop, cel, &xsize, &ysize, &offset);
#else
// TODO
#endif
xmod = offset.x;
ymod = offset.y;
xbase = x - xmod - (xsize >> 1);
xend = xbase + xsize;
yend = y /* - ymod */ + 1;
ybase = yend - ystep;
debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
x, y, xmod, ymod, xsize, ysize, xbase, ybase, xend, yend);
retval.left = xbase;
retval.top = ybase;
retval.right = xend;
retval.bottom = yend;
return retval;
}
} // End of namespace Sci

View File

@ -236,13 +236,6 @@ int _find_view_priority(EngineState *s, int y);
/******************** Dynamic view list functions ********************/
/**
* Determines the base rectangle of the specified view object
* @param s The state to use
* @param object The object to set
* @return The absolute base rectangle
*/
Common::Rect set_base(EngineState *s, reg_t object);
/**
* Determines the now-seen rectangle of a view object

View File

@ -491,21 +491,38 @@ reg_t kBaseSetter(EngineState *s, int argc, reg_t *argv) {
reg_t object = argv[0];
if (lookup_selector(s->_segMan, object, s->_kernel->_selectorCache.brLeft, NULL, NULL) == kSelectorVariable) {
// Note: there was a check here for a very old version of SCI, which supposedly needed
// to subtract 1 from absrect.top. The original check was for version 0.000.256, which
// does not exist (earliest one was KQ4 SCI, version 0.000.274). This code is left here
// for reference only
#if 0
if (getSciVersion() <= SCI_VERSION_0)
--absrect.top; // Compensate for early SCI OB1 'bug'
#endif
Common::Rect absrect = set_base(s, object);
SegManager *segMan = s->_segMan;
PUT_SEL32V(segMan, object, brLeft, absrect.left);
PUT_SEL32V(segMan, object, brRight, absrect.right);
PUT_SEL32V(segMan, object, brTop, absrect.top);
PUT_SEL32V(segMan, object, brBottom, absrect.bottom);
int x = (int16)GET_SEL32V(segMan, object, x);
int y = (int16)GET_SEL32V(segMan, object, y);
int z = (s->_kernel->_selectorCache.z > -1) ? (int16)GET_SEL32V(segMan, object, z) : 0;
y -= z; // Subtract z offset
int ystep = (int16)GET_SEL32V(segMan, object, yStep);
int view = (int16)GET_SEL32V(segMan, object, view);
int loop = GET_SEL32V(segMan, object, loop);
int cel = GET_SEL32V(segMan, object, cel);
Common::Point offset;
SciGuiView *tmpView = new SciGuiView(s->resMan, NULL, NULL, view);
sciViewCelInfo *celInfo = tmpView->getCelInfo(loop, cel);
int left = x + celInfo->displaceX - (celInfo->width >> 1);
int right = left + celInfo->width;
int bottom = y + celInfo->displaceY - z + 1;
int top = bottom - celInfo->height;
debugC(2, kDebugLevelBaseSetter, "(%d,%d)+/-(%d,%d), (%d x %d) -> (%d, %d) to (%d, %d)\n",
x, y, celInfo->displaceX, celInfo->displaceY, celInfo->width, celInfo->height, left, top, bottom, right);
delete tmpView;
PUT_SEL32V(segMan, object, brLeft, left);
PUT_SEL32V(segMan, object, brRight, right);
PUT_SEL32V(segMan, object, brTop, top);
PUT_SEL32V(segMan, object, brBottom, bottom);
}
return s->r_acc;