SCUMM: HE: Preliminar clean up for WIZ rewrite pt.2

This commit is contained in:
AndywinXp 2024-02-06 21:58:15 +01:00 committed by Eugene Sandulenko
parent 823aca6784
commit b3f60f4414
6 changed files with 37 additions and 20 deletions

View File

@ -77,7 +77,7 @@ int MoviePlayer::load(const Common::Path &filename, int flags, int image) {
debug(1, "Playing video %s", filename.toString().c_str());
if (flags & 2)
if (flags & vfImageSurface)
_vm->_wiz->createWizEmptyImage(image, 0, 0, _video->getWidth(), _video->getHeight());
_flags = flags;
@ -155,13 +155,13 @@ void MoviePlayer::handleNextFrame() {
VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen];
if (_flags & 2) {
if (_flags & vfImageSurface) {
uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum);
assert(dstPtr);
uint8 *dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0);
assert(dst);
copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bytesPerPixel);
} else if (_flags & 1) {
} else if (_flags & vfBackground) {
copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch);
Common::Rect imageRect(_video->getWidth(), _video->getHeight());

View File

@ -39,7 +39,17 @@ namespace Scumm {
class ScummEngine_v90he;
class MoviePlayer {
public:
enum VideoFlags {
vfBackground = 0x00000001,
vfImageSurface = 0x00000002,
vfForeground = 0x00000004,
vfLooping = 0x00000008,
vfAllowFrameSkip = 0x00000010,
vfDefault = (vfForeground),
};
MoviePlayer(ScummEngine_v90he *vm, Audio::Mixer *mixer);
~MoviePlayer();

View File

@ -174,14 +174,18 @@ skip:
}
void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
// To test this operation: use room 33 of BluesBirthday yellow disc
uint8 *dst;
VirtScreen *vs = &vm->_virtscr[kMainVirtScreen];
if (ffp->flags & 0x8000) {
int32 colorBackMask = vm->_game.heversion > 99 ? 0x01000000 : 0x8000;
if (ffp->color & colorBackMask) {
dst = vs->getBackPixels(0, vs->topline);
} else {
dst = vs->getPixels(0, vs->topline);
}
uint8 color = ffp->flags & 0xFF;
uint8 color = ffp->color & 0xFF;
Common::Rect r;
r.left = r.top = 12345;
@ -204,7 +208,7 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
ffs->color1 = *(dst + ffp->y * vs->w + ffp->x);
}
debug(5, "floodFill() x=%d y=%d color1=%d ffp->flags=0x%X", ffp->x, ffp->y, ffs->color1, ffp->flags);
debug(5, "floodFill() x=%d y=%d color1=%d ffp->color=0x%X", ffp->x, ffp->y, ffs->color1, ffp->color);
if (ffs->color1 != color) {
floodFillProcess(ffp->x, ffp->y, ffs, floodFillPixelCheck);
r = ffs->dstBox;
@ -214,10 +218,10 @@ void floodFill(FloodFillParameters *ffp, ScummEngine_v90he *vm) {
delete[] ffs->fillLineTable;
delete ffs;
vm->VAR(119) = 1;
vm->VAR(vm->VAR_OPERATION_FAILURE) = 1;
if (r.left <= r.right && r.top <= r.bottom) {
if (ffp->flags & 0x8000) {
if (ffp->color & colorBackMask) {
vm->restoreBackgroundHE(r);
} else {
++r.bottom;

View File

@ -30,12 +30,14 @@ struct FloodFillParameters {
Common::Rect box;
int32 x;
int32 y;
int32 color;
int32 flags;
void reset() {
box.top = box.left = box.bottom = box.right = 0;
x = 0;
y = 0;
color = 0;
flags = 0;
}
};

View File

@ -2292,7 +2292,7 @@ void ScummEngine_v100he::o100_videoOps() {
case SO_IMAGE:
_videoParams.wizResNum = pop();
if (_videoParams.wizResNum)
_videoParams.flags |= 2;
_videoParams.flags |= MoviePlayer::vfImageSurface;
break;
case SO_LOAD:
copyScriptString(_videoParams.filename, sizeof(_videoParams.filename));
@ -2305,12 +2305,12 @@ void ScummEngine_v100he::o100_videoOps() {
if (_videoParams.status == SO_LOAD) {
// Start video
if (_videoParams.flags == 0)
_videoParams.flags = 4;
_videoParams.flags = MoviePlayer::vfDefault;
if (_videoParams.flags & 2) {
VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
if (_videoParams.flags & MoviePlayer::vfImageSurface) {
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
VAR(119) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
}
} else if (_videoParams.status == SO_CLOSE) {
// Stop video

View File

@ -1350,10 +1350,12 @@ void ScummEngine_v90he::o90_getWizData() {
switch (fontProperty) {
case 2: // PFONT_EXTENT_X
//push(PFONT_GetStringWidth(iImage, szResultString));
push(0);
break;
case 3: // PFONT_EXTENT_Y
//push(PFONT_GetStringHeight(iImage, szResultString));
push(0);
break;
default:
// No default case in the original...
@ -1432,7 +1434,7 @@ void ScummEngine_v90he::o90_priorityChainScript() {
void ScummEngine_v90he::o90_videoOps() {
// Uses Smacker video
int status = fetchScriptByte();
int subOp = status - 49;
int subOp = status;
switch (subOp) {
case SO_LOAD: // 49
@ -1452,7 +1454,7 @@ void ScummEngine_v90he::o90_videoOps() {
case SO_IMAGE: // 63
_videoParams.wizResNum = pop();
if (_videoParams.wizResNum)
_videoParams.flags |= 2;
_videoParams.flags |= MoviePlayer::vfImageSurface;
break;
case SO_CLOSE: // 165
_videoParams.status = status;
@ -1461,9 +1463,9 @@ void ScummEngine_v90he::o90_videoOps() {
if (_videoParams.status == SO_LOAD) {
// Start video
if (_videoParams.flags == 0)
_videoParams.flags = 4;
_videoParams.flags = MoviePlayer::vfDefault;
if (_videoParams.flags & 2) {
if (_videoParams.flags & MoviePlayer::vfImageSurface) {
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags, _videoParams.wizResNum);
} else {
VAR(VAR_OPERATION_FAILURE) = _moviePlay->load(convertFilePath(_videoParams.filename), _videoParams.flags);
@ -1517,7 +1519,7 @@ void ScummEngine_v90he::o90_floodFill() {
switch (subOp) {
case SO_SET_FLAGS: // 54
// TODO floodInfo.flags |= pop();
_floodFillParams.flags |= pop();
pop();
break;
case SO_INIT: // 57
@ -1526,14 +1528,13 @@ void ScummEngine_v90he::o90_floodFill() {
_floodFillParams.box.top = 0;
_floodFillParams.box.right = 639;
_floodFillParams.box.bottom = 479;
adjustRect(_floodFillParams.box);
break;
case SO_AT: // 65
_floodFillParams.y = pop();
_floodFillParams.x = pop();
break;
case SO_COLOR: // 66
_floodFillParams.flags = pop(); // TODO: Should be .color!
_floodFillParams.color = pop();
break;
case SO_CLIPPED: // 67
_floodFillParams.box.bottom = pop();