Turn Wiz struct into class as requested.

svn-id: r18224
This commit is contained in:
Eugene Sandulenko 2005-05-23 02:00:49 +00:00
parent f7e418d638
commit b9e8e40805
11 changed files with 73 additions and 58 deletions

View file

@ -802,7 +802,7 @@ public:
ScummEngine_v70he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16], int substResFileNameIndex);
~ScummEngine_v70he();
Wiz _wiz;
Wiz *_wiz;
protected:
virtual void setupOpcodes();

View file

@ -342,7 +342,7 @@ int ScummEngine::findObject(int x, int y) {
if (b == 0) {
#ifndef DISABLE_HE
if (_heversion >= 70) {
if (((ScummEngine_v70he *)this)->_wiz.polygonHit(_objs[i].obj_nr, x, y))
if (((ScummEngine_v70he *)this)->_wiz->polygonHit(_objs[i].obj_nr, x, y))
return _objs[i].obj_nr;
}
#endif
@ -870,13 +870,13 @@ void ScummEngine_v6::clearDrawQueues() {
void ScummEngine_v70he::clearDrawQueues() {
ScummEngine_v6::clearDrawQueues();
_wiz.polygonClear();
_wiz->polygonClear();
}
void ScummEngine_v80he::clearDrawQueues() {
ScummEngine_v70he::clearDrawQueues();
_wiz.clearWizBuffer();
_wiz->clearWizBuffer();
}
#endif

View file

@ -526,7 +526,7 @@ void ScummEngine::initRoomSubBlocks() {
if (_heversion >= 80) {
ptr = findResourceData(MKID('POLD'), roomptr);
if (ptr) {
((ScummEngine_v70he *)this)->_wiz.polygonLoad(ptr);
((ScummEngine_v70he *)this)->_wiz->polygonLoad(ptr);
}
}
#endif

View file

@ -1052,7 +1052,7 @@ void ScummEngine_v70he::saveOrLoad(Serializer *s, uint32 savegameVersion) {
};
if (_heversion >= 71) {
s->saveLoadArrayOf(_wiz._polygons, ARRAYSIZE(_wiz._polygons), sizeof(_wiz._polygons[0]), polygonEntries);
s->saveLoadArrayOf(_wiz->_polygons, ARRAYSIZE(_wiz->_polygons), sizeof(_wiz->_polygons[0]), polygonEntries);
}
s->saveLoadEntries(this, HE70Entries);

View file

@ -735,8 +735,8 @@ int ScummEngine_v72he::findObject(int x, int y, int num, int *args) {
continue;
// Check polygon bounds
if (_wiz.polygonDefined(_objs[i].obj_nr)) {
if (_wiz.polygonHit(_objs[i].obj_nr, x, y))
if (_wiz->polygonDefined(_objs[i].obj_nr)) {
if (_wiz->polygonHit(_objs[i].obj_nr, x, y))
result = _objs[i].obj_nr;
else if (VAR_POLYGONS_ONLY != 0xFF && VAR(VAR_POLYGONS_ONLY))
continue;

View file

@ -813,14 +813,14 @@ void ScummEngine_v70he::o70_kernelSetFunctions() {
a->_clipOverride.bottom = args[2];
break;
case 42:
_wiz._rectOverrideEnabled = true;
_wiz._rectOverride.left = args[1];
_wiz._rectOverride.top = args[2];
_wiz._rectOverride.right = args[3];
_wiz._rectOverride.bottom = args[4];
_wiz->_rectOverrideEnabled = true;
_wiz->_rectOverride.left = args[1];
_wiz->_rectOverride.top = args[2];
_wiz->_rectOverride.right = args[3];
_wiz->_rectOverride.bottom = args[4];
break;
case 43:
_wiz._rectOverrideEnabled = false;
_wiz->_rectOverrideEnabled = false;
break;
default:
error("o70_kernelSetFunctions: default case %d (param count %d)", args[0], num);
@ -1067,13 +1067,13 @@ void ScummEngine_v70he::o70_polygonOps() {
vert1x = pop();
flag = (subOp == 69 || subOp == 248);
id = pop();
_wiz.polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
_wiz->polygonStore(id, flag, vert1x, vert1y, vert2x, vert2y, vert3x, vert3y, vert4x, vert4y);
break;
case 28: // HE 100
case 247:
toId = pop();
fromId = pop();
_wiz.polygonErase(fromId, toId);
_wiz->polygonErase(fromId, toId);
break;
default:
error("o70_polygonOps: default case %d", subOp);
@ -1083,7 +1083,7 @@ void ScummEngine_v70he::o70_polygonOps() {
void ScummEngine_v70he::o70_polygonHit() {
int y = pop();
int x = pop();
push(_wiz.polygonHit(0, x, y));
push(_wiz->polygonHit(0, x, y));
}
} // End of namespace Scumm

View file

@ -1899,7 +1899,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
wp.vert[i].x = args1[i * 2 + 0];
wp.vert[i].y = args1[i * 2 + 1];
}
push(_wiz.polygonContains(wp, args2[0], args2[1]) ? 1 : 0);
push(_wiz->polygonContains(wp, args2[0], args2[1]) ? 1 : 0);
}
}
break;
@ -2591,14 +2591,14 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
// Used in readdemo
break;
case 42:
_wiz._rectOverrideEnabled = true;
_wiz._rectOverride.left = args[1];
_wiz._rectOverride.top = args[2];
_wiz._rectOverride.right = args[3];
_wiz._rectOverride.bottom = args[4];
_wiz->_rectOverrideEnabled = true;
_wiz->_rectOverride.left = args[1];
_wiz->_rectOverride.top = args[2];
_wiz->_rectOverride.right = args[3];
_wiz->_rectOverride.bottom = args[4];
break;
case 43:
_wiz._rectOverrideEnabled = false;
_wiz->_rectOverrideEnabled = false;
break;
case 714:
break;

View file

@ -1318,6 +1318,8 @@ ScummEngine_v70he::ScummEngine_v70he(GameDetector *detector, OSystem *syst, cons
else
_resExtractor = new Win32ResExtractor(this);
_wiz = new Wiz(this);
_heV7RoomOffsets = NULL;
_heSndSoundId = 0;

View file

@ -85,14 +85,14 @@ void ScummEngine_v90he::getSpriteBounds(int spriteId, bool checkGroup, Common::R
}
}
if ((spi->flags & kSFRotated) && angle)
_wiz.polygonRotatePoints(pts, 4, angle);
_wiz->polygonRotatePoints(pts, 4, angle);
for (int j = 0; j < 4; ++j) {
pts[j].x += x1;
pts[j].y += y1;
}
_wiz.polygonCalcBoundBox(pts, 4, bound);
_wiz->polygonCalcBoundBox(pts, 4, bound);
}
} else {
bound.left = 1234;
@ -195,7 +195,7 @@ int ScummEngine_v90he::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGro
if (spi->flags & kSFRotated && angle) {
angle = (360 - angle) % 360;
Common::Point pts[1];
_wiz.polygonRotatePoints(pts, 1, angle);
_wiz->polygonRotatePoints(pts, 1, angle);
}
getWizImageDim(resId, resState, w, h);
@ -1314,14 +1314,14 @@ void ScummEngine_v90he::spritesProcessWiz(bool arg) {
}
}
if ((spi->flags & kSFRotated) && angle)
_wiz.polygonRotatePoints(pts, 4, angle);
_wiz->polygonRotatePoints(pts, 4, angle);
for (int j = 0; j < 4; ++j) {
pts[j].x += wiz.img.x1;
pts[j].y += wiz.img.y1;
}
_wiz.polygonCalcBoundBox(pts, 4, spi->bbox);
_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
}
} else {
bboxPtr->left = 1234;

View file

@ -29,7 +29,7 @@
namespace Scumm {
Wiz::Wiz() {
Wiz::Wiz(ScummEngine_v70he *vm) : _vm(vm) {
_imagesNum = 0;
memset(&_images, 0, sizeof(_images));
memset(&_polygons, 0, sizeof(_polygons));
@ -947,8 +947,8 @@ void ScummEngine_v72he::getWizImageDim(int resNum, int state, int32 &w, int32 &h
void ScummEngine_v72he::displayWizImage(WizImage *pwi) {
if (_fullRedraw) {
assert(_wiz._imagesNum < ARRAYSIZE(_wiz._images));
WizImage *wi = &_wiz._images[_wiz._imagesNum];
assert(_wiz->_imagesNum < ARRAYSIZE(_wiz->_images));
WizImage *wi = &_wiz->_images[_wiz->_imagesNum];
wi->resNum = pwi->resNum;
wi->x1 = pwi->x1;
wi->y1 = pwi->y1;
@ -958,7 +958,7 @@ void ScummEngine_v72he::displayWizImage(WizImage *pwi) {
wi->xmapNum = 0;
wi->field_390 = 0;
wi->paletteNum = 0;
++_wiz._imagesNum;
++_wiz->_imagesNum;
} else if (pwi->flags & kWIFIsPolygon) {
drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, 0, 0, 0);
} else {
@ -1053,9 +1053,9 @@ uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, in
} else {
return 0;
}
} else if (_wiz._rectOverrideEnabled) {
if (rScreen.intersects(_wiz._rectOverride)) {
rScreen.clip(_wiz._rectOverride);
} else if (_wiz->_rectOverrideEnabled) {
if (rScreen.intersects(_wiz->_rectOverride)) {
rScreen.clip(_wiz->_rectOverride);
} else {
return 0;
}
@ -1074,7 +1074,7 @@ uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, in
switch (comp) {
case 0:
color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1;
_wiz.copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
_wiz->copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
break;
case 1:
// TODO Adding masking for flags 0x80 and 0x100
@ -1085,11 +1085,11 @@ uint8 *ScummEngine_v72he::drawWizImage(int resNum, int state, int x1, int y1, in
// Used in readdemo
warning("drawWizImage: Unhandled flag 0x100");
}
_wiz.copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
_wiz->copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
break;
case 2:
color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1;
_wiz.copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
_wiz->copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
break;
case 5:
// Used in Moonbase Commander
@ -1198,7 +1198,7 @@ void ScummEngine_v72he::drawWizComplexPolygon(int resNum, int state, int po_x, i
}
}
if (angle)
_wiz.polygonRotatePoints(pts, 4, angle);
_wiz->polygonRotatePoints(pts, 4, angle);
for (int i = 0; i < 4; ++i) {
pts[i].x += po_x;
@ -1218,7 +1218,7 @@ void ScummEngine_v72he::drawWizComplexPolygon(int resNum, int state, int po_x, i
}
Common::Rect bounds;
_wiz.polygonCalcBoundBox(pts, 4, bounds);
_wiz->polygonCalcBoundBox(pts, 4, bounds);
int x1 = bounds.left;
int y1 = bounds.top;
@ -1248,9 +1248,9 @@ void ScummEngine_v72he::drawWizPolygon(int resNum, int state, int id, int flags,
debug(1, "drawWizPolygon(resNum %d, id %d, flags 0x%X, xmapNum %d paletteNum %d)", resNum, id, flags, xmapNum, paletteNum);
int i;
WizPolygon *wp = NULL;
for (i = 0; i < ARRAYSIZE(_wiz._polygons); ++i) {
if (_wiz._polygons[i].id == id) {
wp = &_wiz._polygons[i];
for (i = 0; i < ARRAYSIZE(_wiz->_polygons); ++i) {
if (_wiz->_polygons[i].id == id) {
wp = &_wiz->_polygons[i];
break;
}
}
@ -1352,8 +1352,8 @@ void ScummEngine_v72he::drawWizPolygon(int resNum, int state, int id, int flags,
}
void ScummEngine_v72he::flushWizBuffer() {
for (int i = 0; i < _wiz._imagesNum; ++i) {
WizImage *pwi = &_wiz._images[i];
for (int i = 0; i < _wiz->_imagesNum; ++i) {
WizImage *pwi = &_wiz->_images[i];
if (pwi->flags & kWIFIsPolygon) {
drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, pwi->xmapNum, 0, pwi->paletteNum);
} else {
@ -1361,7 +1361,7 @@ void ScummEngine_v72he::flushWizBuffer() {
drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, pwi->zorder, pwi->xmapNum, pwi->field_390, r, pwi->flags, 0, pwi->paletteNum);
}
}
_wiz._imagesNum = 0;
_wiz->_imagesNum = 0;
}
void ScummEngine_v80he::loadImgSpot(int resId, int state, int16 &x, int16 &y) {
@ -1469,8 +1469,8 @@ void ScummEngine_v72he::displayWizComplexImage(const WizParameters *params) {
if (maskImgResNum != 0 || (params->processFlags & (kWPFZoom | kWPFRotate)))
error("Can't do this command in the enter script.");
assert(_wiz._imagesNum < ARRAYSIZE(_wiz._images));
WizImage *pwi = &_wiz._images[_wiz._imagesNum];
assert(_wiz->_imagesNum < ARRAYSIZE(_wiz->_images));
WizImage *pwi = &_wiz->_images[_wiz->_imagesNum];
pwi->resNum = params->img.resNum;
pwi->x1 = po_x;
pwi->y1 = po_y;
@ -1480,7 +1480,7 @@ void ScummEngine_v72he::displayWizComplexImage(const WizParameters *params) {
pwi->xmapNum = xmapNum;
pwi->field_390 = field_390;
pwi->paletteNum = paletteNum;
++_wiz._imagesNum;
++_wiz->_imagesNum;
} else {
if (maskImgResNum != 0) {
// TODO
@ -1881,15 +1881,20 @@ int ScummEngine_v90he::isWizPixelNonTransparent(int resNum, int state, int x, in
}
switch (c) {
case 0:
ret = _wiz.getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR)) != VAR(VAR_WIZ_TCOLOR) ? 1 : 0;
ret = _wiz->getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR)) != VAR(VAR_WIZ_TCOLOR) ? 1 : 0;
break;
case 1:
ret = _wiz.isWizPixelNonTransparent(wizd, x, y, w, h);
ret = _wiz->isWizPixelNonTransparent(wizd, x, y, w, h);
break;
case 2:
// Used baseball2003
warning("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
break;
case 4:
case 5:
// Used in Moonbase Commander
warning("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
break;
default:
error("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
break;
@ -1911,11 +1916,12 @@ uint8 ScummEngine_v90he::getWizPixelColor(int resNum, int state, int x, int y, i
assert(wizd);
switch (c) {
case 0:
color = _wiz.getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
color = _wiz->getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
break;
case 1:
color = _wiz.getWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
color = _wiz->getWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
break;
case 4:
case 5:
// Used in Moonbase Commander
color = 1;
@ -1949,10 +1955,10 @@ int ScummEngine_v90he::computeWizHistogram(int resNum, int state, int x, int y,
memset(histogram, 0, sizeof(histogram));
switch (c) {
case 0:
_wiz.computeRawWizHistogram(histogram, wizd, w, &rCap);
_wiz->computeRawWizHistogram(histogram, wizd, w, &rCap);
break;
case 1:
_wiz.computeWizHistogram(histogram, wizd, &rCap);
_wiz->computeWizHistogram(histogram, wizd, &rCap);
break;
default:
error("computeWizHistogram: Unhandled wiz compression type %d", c);

View file

@ -133,7 +133,10 @@ enum WizProcessFlags {
kWPFMaskImg = 0x80000
};
struct Wiz {
class ScummEngine_v70he;
class Wiz {
public:
enum {
NUM_POLYGONS = 200,
NUM_IMAGES = 255
@ -143,7 +146,8 @@ struct Wiz {
uint16 _imagesNum;
WizPolygon _polygons[NUM_POLYGONS];
Wiz();
Wiz(ScummEngine_v70he *vm);
void clearWizBuffer();
Common::Rect _rectOverride;
bool _rectOverrideEnabled;
@ -168,6 +172,9 @@ struct Wiz {
uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect *srcRect);
void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect *srcRect);
private:
ScummEngine_v70he *_vm;
};
} // End of namespace Scumm