diff options
Diffstat (limited to 'engines')
42 files changed, 560 insertions, 400 deletions
diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp index bcd064b420..ea25dc7847 100644 --- a/engines/director/archive.cpp +++ b/engines/director/archive.cpp @@ -298,6 +298,7 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff res.offset = offset; res.size = size; res.name = name; + res.tag = tag; } _stream = stream; @@ -402,6 +403,7 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff Resource res; res.offset = offset; res.size = size; + res.tag = tag; resources.push_back(res); // APPL is a special case; it has an embedded "normal" archive diff --git a/engines/director/archive.h b/engines/director/archive.h index 28be6cf03c..4549e1ec48 100644 --- a/engines/director/archive.h +++ b/engines/director/archive.h @@ -39,6 +39,7 @@ struct Resource { uint32 offset; uint32 size; uint32 castId; + uint32 tag; Common::String name; Common::Array<Resource> children; }; diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index 0f63a96435..9fe84b4a9b 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -26,7 +26,7 @@ namespace Director { -BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint16 version) { +BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint32 castTag, uint16 version) { if (version < 4) { flags = stream.readByte(); someFlaggyThing = stream.readUint16(); @@ -40,7 +40,7 @@ BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint16 version) { unk1 = stream.readUint16(); unk2 = stream.readUint16(); } - } else { + } else if (version == 4) { stream.readByte(); stream.readByte(); @@ -65,8 +65,39 @@ BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint16 version) { } warning("BitmapCast: %d bytes left", tail); + } else if (version == 5) { + // WIP! + uint32 unk1 = stream.readUint32(); + uint32 unk2 = stream.readUint32(); + uint32 unk3 = stream.readUint32(); + uint32 unk4 = stream.readUint32(); + uint32 unk5 = stream.readUint32(); + uint32 unk6 = stream.readUint32(); + uint32 unk7 = stream.readUint32(); + + uint16 count = stream.readUint16(); + for (uint16 cc = 0; cc < count; cc++) + stream.readUint32(); + + uint32 stringLength = stream.readUint32(); + for (int s = 0; s < stringLength; s++) + stream.readByte(); + + uint16 width = stream.readUint16LE(); //maybe? + initialRect = Score::readRect(stream); + + uint32 somethingElse = stream.readUint32(); + boundingRect = Score::readRect(stream); + + bitsPerPixel = stream.readUint16(); + + regX = 0; + regY = 0; + + stream.readUint32(); } modified = 0; + tag = castTag; } TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { @@ -205,7 +236,7 @@ ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextC ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) { if (version < 4) { error("Unhandled Script cast"); - } else { + } else if (version == 4) { stream.readByte(); stream.readByte(); @@ -218,6 +249,18 @@ ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) { stream.readByte(); // There should be no more data assert(stream.eos()); + } else if (version > 4) { + stream.readByte(); + stream.readByte(); + + initialRect = Score::readRect(stream); + boundingRect = Score::readRect(stream); + + id = stream.readUint32(); + + debugC(4, kDebugLoading, "CASt: Script id: %d", id); + + // WIP need to complete this! } modified = 0; } diff --git a/engines/director/cast.h b/engines/director/cast.h index f304456e12..69641b553d 100644 --- a/engines/director/cast.h +++ b/engines/director/cast.h @@ -59,7 +59,7 @@ public: class BitmapCast : public Cast { public: - BitmapCast(Common::ReadStreamEndian &stream, uint16 version = 2); + BitmapCast(Common::ReadStreamEndian &stream, uint32 castTag, uint16 version = 2); uint16 regX; uint16 regY; @@ -68,6 +68,8 @@ public: uint16 unk1, unk2; uint16 bitsPerPixel; + + uint32 tag; }; enum ShapeType { diff --git a/engines/director/detection_tables.h b/engines/director/detection_tables.h index 798326b7f4..1ee5d761ec 100644 --- a/engines/director/detection_tables.h +++ b/engines/director/detection_tables.h @@ -221,6 +221,20 @@ static const DirectorGameDescription gameDescriptions[] = { 5 }, + { + { + "gadget", + "Gadget: Past as Future", + AD_ENTRY1s("GADGET.EXE", "d62438566e44826960fc16c5c23dbe43", 2212541), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, //ADGF_HICOLOR, + GUIO1(GUIO_NOASPECT) + }, + GID_GENERIC, + 5 + }, + { AD_TABLE_END_MARKER, GID_GENERIC, 0 } }; diff --git a/engines/director/events.cpp b/engines/director/events.cpp index f4806f332e..f55a7c8991 100644 --- a/engines/director/events.cpp +++ b/engines/director/events.cpp @@ -92,8 +92,8 @@ void DirectorEngine::processEvents() { if (getVersion() > 3) { // TODO: check that this is the order of script execution! - _lingo->processEvent(kEventNone, kCastScript, currentFrame->_sprites[spriteId]->_castId); - _lingo->processEvent(kEventNone, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId); + _lingo->processEvent(kEventMouseUp, kCastScript, currentFrame->_sprites[spriteId]->_castId); + _lingo->processEvent(kEventMouseUp, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId); } else { // Frame script overrides sprite script if (!currentFrame->_sprites[spriteId]->_scriptId) diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 92aa851d06..ba5b9033ab 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -559,7 +559,6 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { continue; CastType castType = kCastTypeNull; - Cast *cast = nullptr; if (_vm->getVersion() < 4) { debugC(1, kDebugImages, "Channel: %d type: %d", i, _sprites[i]->_spriteType); switch (_sprites[i]->_spriteType) { @@ -594,9 +593,9 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { if (castType == kCastShape) { renderShape(surface, i); } else if (castType == kCastText) { - renderText(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : cast->children[0].index); + renderText(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_textCast->children[0].index); } else if (castType == kCastButton) { - renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : cast->children[0].index); + renderButton(surface, i, _vm->getVersion() < 4 ? _sprites[i]->_castId + 1024 : _sprites[i]->_buttonCast->children[0].index); } else { if (!_sprites[i]->_bitmapCast) { warning("No cast ID for sprite %d", i); @@ -611,7 +610,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { int x = _sprites[i]->_startPoint.x - regX + rectLeft; int y = _sprites[i]->_startPoint.y - regY + rectTop; int height = _sprites[i]->_height; - int width = _sprites[i]->_width; + int width = _vm->getVersion() > 4 ? _sprites[i]->_bitmapCast->initialRect.width() : _sprites[i]->_width; Common::Rect drawRect(x, y, x + width, y + height); addDrawRect(i, drawRect); @@ -742,8 +741,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo if (textStream == NULL) return; - uint16 castId = _sprites[spriteId]->_castId; - TextCast *textCast = _vm->getCurrentScore()->_loadedText->getVal(castId); + TextCast *textCast = _sprites[spriteId]->_buttonCast != nullptr ? (TextCast*)_sprites[spriteId]->_buttonCast : _sprites[spriteId]->_textCast; uint32 unk1 = textStream->readUint32(); uint32 strLen = textStream->readUint32(); diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 3ab17fc835..0e9b51e64e 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -130,13 +130,17 @@ void Score::loadArchive() { } assert(_movieArchive->hasResource(MKTAG('V', 'W', 'S', 'C'), 1024)); - assert(_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), 1024)); - loadFrames(*_movieArchive->getResource(MKTAG('V', 'W', 'S', 'C'), 1024)); - loadConfig(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'F'), 1024)); - if (_vm->getVersion() < 4) { - assert(_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'R'), 1024)); + + if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), -1)) { + loadConfig(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'F'), 1024)); + } else { + // TODO: Source this from somewhere! + _movieRect = Common::Rect(0, 0, 640, 480); + } + + if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'R'), -1)) { loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'R'), 1024)); } @@ -195,35 +199,43 @@ void Score::loadSpriteImages(bool isSharedCast) { Common::HashMap<int, BitmapCast *>::iterator bc; for (bc = _loadedBitmaps->begin(); bc != _loadedBitmaps->end(); ++bc) { if (bc->_value) { + uint32 tag = bc->_value->tag; uint16 imgId = bc->_key + 1024; BitmapCast *bitmapCast = bc->_value; - if (_vm->getVersion() >= 4 && bitmapCast->children.size() > 0) + if (_vm->getVersion() >= 4 && bitmapCast->children.size() > 0) { imgId = bitmapCast->children[0].index; - - Image::ImageDecoder *img = NULL; - - if (_movieArchive->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) { - img = new DIBDecoder(); - img->loadStream(*_movieArchive->getResource(MKTAG('D', 'I', 'B', ' '), imgId)); - bitmapCast->surface = img->getSurface(); - } - - if (isSharedCast && _vm->getSharedDIB() != NULL && _vm->getSharedDIB()->contains(imgId)) { - img = new DIBDecoder(); - img->loadStream(*_vm->getSharedDIB()->getVal(imgId)); - bitmapCast->surface = img->getSurface(); + tag = bitmapCast->children[0].tag; } + Image::ImageDecoder *img = NULL; Common::SeekableReadStream *pic = NULL; - if (isSharedCast) { - debugC(4, kDebugImages, "Shared cast BMP: id: %d", imgId); - pic = _vm->getSharedBMP()->getVal(imgId); - if (pic != NULL) - pic->seek(0); // TODO: this actually gets re-read every loop... we need to rewind it! - } else if (_movieArchive->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) { - pic = _movieArchive->getResource(MKTAG('B', 'I', 'T', 'D'), imgId); + switch (tag) { + case MKTAG('D', 'I', 'B', ' '): + if (_movieArchive->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) { + img = new DIBDecoder(); + img->loadStream(*_movieArchive->getResource(MKTAG('D', 'I', 'B', ' '), imgId)); + bitmapCast->surface = img->getSurface(); + } else if (isSharedCast && _vm->getSharedDIB() != NULL && _vm->getSharedDIB()->contains(imgId)) { + img = new DIBDecoder(); + img->loadStream(*_vm->getSharedDIB()->getVal(imgId)); + bitmapCast->surface = img->getSurface(); + } + break; + case MKTAG('B', 'I', 'T', 'D'): + if (isSharedCast) { + debugC(4, kDebugImages, "Shared cast BMP: id: %d", imgId); + pic = _vm->getSharedBMP()->getVal(imgId); + if (pic != NULL) + pic->seek(0); // TODO: this actually gets re-read every loop... we need to rewind it! + } else if (_movieArchive->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) { + pic = _movieArchive->getResource(MKTAG('B', 'I', 'T', 'D'), imgId); + } + break; + default: + warning("Unknown Bitmap Cast Tag: [%d] %s", tag, tag2str(tag)); + break; } int w = bitmapCast->initialRect.width(), h = bitmapCast->initialRect.height(); @@ -241,9 +253,9 @@ void Score::loadSpriteImages(bool isSharedCast) { img->loadStream(*pic); bitmapCast->surface = img->getSurface(); + } else { + warning("Image %d not found", imgId); } - - warning("Image %d not found", imgId); } } } @@ -291,7 +303,7 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { uint32 size = stream.readUint32(); size -= 4; - if (_vm->getVersion() > 3) { + if (_vm->getVersion() == 4) { uint32 unk1 = stream.readUint32(); uint32 unk2 = stream.readUint32(); uint16 unk3 = stream.readUint16(); @@ -302,6 +314,28 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { warning("STUB: Score::loadFrames. unk1: %x unk2: %x unk3: %x unk4: %x unk5: %x unk6: %x", unk1, unk2, unk3, unk4, unk5, unk6); // Unknown, some bytes - constant (refer to contuinity). + } else if (_vm->getVersion() > 4) { + //what data is up the top of D5 VWSC? + stream.readUint32(); + stream.readUint32(); + uint32 blockSize = stream.readUint32() - 1; + stream.readUint32(); + stream.readUint32(); + stream.readUint32(); + stream.readUint32(); + for (int skip = 0; skip < blockSize * 4; skip++) + stream.readByte(); + + //header number two... this is our actual score entry point. + uint32 unk1 = stream.readUint32(); + uint32 unk2 = stream.readUint32(); + stream.readUint32(); + uint16 unk3 = stream.readUint16(); + uint16 unk4 = stream.readUint16(); + uint16 unk5 = stream.readUint16(); + uint16 unk6 = stream.readUint16(); + + warning("STUB: Score::loadFrames. unk1: %x unk2: %x unk3: %x unk4: %x unk5: %x unk6: %x", unk1, unk2, unk3, unk4, unk5, unk6); } uint16 channelSize; @@ -320,36 +354,39 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { while (size != 0 && !stream.eos()) { uint16 frameSize = stream.readUint16(); debugC(kDebugLoading, 8, "++++ score frame %d (frameSize %d) size %d", _frames.size(), frameSize, size); - size -= frameSize; - frameSize -= 2; - Frame *frame = new Frame(_vm); - - while (frameSize != 0) { - if (_vm->getVersion() < 4) { - channelSize = stream.readByte() * 2; - channelOffset = stream.readByte() * 2; - frameSize -= channelSize + 2; - } else { - channelSize = stream.readUint16(); - channelOffset = stream.readUint16(); - frameSize -= channelSize + 4; - } + if (frameSize > 0) { + Frame *frame = new Frame(_vm); + size -= frameSize; + frameSize -= 2; - assert(channelOffset + channelSize < kChannelDataSize); + while (frameSize != 0) { - stream.read(&channelData[channelOffset], channelSize); - } + if (_vm->getVersion() < 4) { + channelSize = stream.readByte() * 2; + channelOffset = stream.readByte() * 2; + frameSize -= channelSize + 2; + } else { + channelSize = stream.readUint16(); + channelOffset = stream.readUint16(); + frameSize -= channelSize + 4; + } - Common::MemoryReadStreamEndian *str = new Common::MemoryReadStreamEndian(channelData, ARRAYSIZE(channelData), stream.isBE()); - //Common::hexdump(channelData, ARRAYSIZE(channelData)); - frame->readChannels(str); + assert(channelOffset + channelSize < kChannelDataSize); + stream.read(&channelData[channelOffset], channelSize); + } - debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId); + Common::MemoryReadStreamEndian *str = new Common::MemoryReadStreamEndian(channelData, ARRAYSIZE(channelData), stream.isBE()); + frame->readChannels(str); + delete str; - delete str; + debugC(3, kDebugLoading, "Frame %d actionId: %d", _frames.size(), frame->_actionId); - _frames.push_back(frame); + _frames.push_back(frame); + } else { + warning("zero sized frame!? exiting loop until we know what to do with the tags that follow."); + size = 0; + } } } @@ -390,7 +427,8 @@ void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { switch (castType) { case kCastBitmap: debugC(3, kDebugLoading, "CastTypes id: %d BitmapCast", id); - _loadedBitmaps->setVal(id, new BitmapCast(stream)); + // TODO: Work out the proper tag! + _loadedBitmaps->setVal(id, new BitmapCast(stream, MKTAG('B', 'I', 'T', 'D'))); _castTypes[id] = kCastBitmap; break; case kCastText: @@ -409,7 +447,7 @@ void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { _castTypes[id] = kCastButton; break; default: - warning("Score::loadCastDataVWCR(): Unhandled cast type: %d", castType); + warning("Score::loadCastDataVWCR(): Unhandled cast type: %d [%s]", castType, tag2str(castType)); stream.skip(size - 1); break; } @@ -430,6 +468,12 @@ void Score::setSpriteCasts() { if (_vm->getSharedScore()->_loadedButtons->contains(castId)) { _frames[i]->_sprites[j]->_buttonCast = _vm->getSharedScore()->_loadedButtons->getVal(castId); + if (_frames[i]->_sprites[j]->_buttonCast->children.size() == 1) { + _frames[i]->_sprites[j]->_textCast = + _vm->getSharedScore()->_loadedText->getVal(_frames[i]->_sprites[j]->_buttonCast->children[0].index); + } else if (_frames[i]->_sprites[j]->_buttonCast->children.size() > 0) { + warning("Cast %d has too many children!", j); + } } else if (_loadedButtons->contains(castId)) { _frames[i]->_sprites[j]->_buttonCast = _loadedButtons->getVal(castId); } @@ -466,14 +510,14 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, debugC(3, kDebugLoading, "CASt: id: %d", id); - if (debugChannelSet(5, kDebugLoading)) + if (debugChannelSet(5, kDebugLoading) && stream.size() < 2048) stream.hexdump(stream.size()); uint32 size1, size2, size3, castType; byte unk1 = 0, unk2 = 0, unk3 = 0; if (_vm->getVersion() <= 3) { - size1 = stream.readUint16(); + size1 = stream.readUint16() + 16; // 16 is for bounding rects size2 = stream.readUint32(); size3 = 0; castType = stream.readByte(); @@ -481,46 +525,57 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, unk2 = stream.readByte(); unk3 = stream.readByte(); } else if (_vm->getVersion() == 4) { - size1 = stream.readUint16() + 2; + size1 = stream.readUint16() + 2 + 16; // 16 is for bounding rects size2 = stream.readUint32(); size3 = 0; castType = stream.readByte(); unk1 = stream.readByte(); - } else { + } else if (_vm->getVersion() == 5) { // FIXME: only the cast type and the strings are good castType = stream.readUint32(); - size2 = stream.readUint32(); + size3 = stream.readUint32(); + size2 = stream.readUint32(); size1 = stream.readUint32(); - assert(size1 == 0x14); - size1 = 0; + // assert(size1 == 0x14); + + // don't read the strings later, the full cast data is needed to be parsed. + size1 = stream.size(); + } else { + error("Score::loadCastData: unsupported Director version (%d)", _vm->getVersion()); } debugC(3, kDebugLoading, "CASt: id: %d type: %x size1: %d size2: %d (%x) size3: %d unk1: %d unk2: %d unk3: %d", id, castType, size1, size2, size2, size3, unk1, unk2, unk3); - byte *data = (byte *)calloc(size1 + 16, 1); // 16 is for bounding rects - stream.read(data, size1 + 16); + byte *data = (byte *)calloc(size1, 1); + stream.read(data, size1); - Common::MemoryReadStreamEndian castStream(data, size1 + 16, stream.isBE()); + Common::MemoryReadStreamEndian castStream(data, size1, stream.isBE()); switch (castType) { case kCastBitmap: - _loadedBitmaps->setVal(id, new BitmapCast(castStream, _vm->getVersion())); + _loadedBitmaps->setVal(id, new BitmapCast(castStream, res->tag, _vm->getVersion())); for (uint child = 0; child < res->children.size(); child++) _loadedBitmaps->getVal(id)->children.push_back(res->children[child]); _castTypes[id] = kCastBitmap; break; case kCastText: _loadedText->setVal(id, new TextCast(castStream, _vm->getVersion())); + for (uint child = 0; child < res->children.size(); child++) + _loadedText->getVal(id)->children.push_back(res->children[child]); _castTypes[id] = kCastText; break; case kCastShape: _loadedShapes->setVal(id, new ShapeCast(castStream, _vm->getVersion())); + for (uint child = 0; child < res->children.size(); child++) + _loadedShapes->getVal(id)->children.push_back(res->children[child]); _castTypes[id] = kCastShape; break; case kCastButton: _loadedButtons->setVal(id, new ButtonCast(castStream, _vm->getVersion())); + for (uint child = 0; child < res->children.size(); child++) + _loadedButtons->getVal(id)->children.push_back(res->children[child]); _castTypes[id] = kCastButton; break; case kCastLingoScript: @@ -528,13 +583,15 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id, _castTypes[id] = kCastLingoScript; break; default: - warning("Score::loadCastData(): Unhandled cast type: %d", castType); + warning("Score::loadCastData(): Unhandled cast type: %d [%s]", castType, tag2str(castType)); + // also don't try and read the strings... we don't know what this item is. + size2 = 0; break; } free(data); - if (size2) { + if (size2 && _vm->getVersion() < 5) { uint32 entryType = 0; Common::Array<Common::String> castStrings = loadStrings(stream, entryType, false); diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp index fd5b593fa3..47eea18ec5 100644 --- a/engines/titanic/carry/carry.cpp +++ b/engines/titanic/carry/carry.cpp @@ -98,7 +98,7 @@ void CCarry::load(SimpleFile *file) { bool CCarry::MouseDragStartMsg(CMouseDragStartMsg *msg) { CString name = getName(); - debugC(ERROR_BASIC, kDebugScripts, "MosueDragStartMsg - %s", name.c_str()); + debugC(DEBUG_BASIC, kDebugScripts, "MosueDragStartMsg - %s", name.c_str()); if (_canTake) { if (checkStartDragging(msg)) { @@ -122,7 +122,7 @@ bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { } bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { - debugC(ERROR_BASIC, kDebugScripts, "MouseDragEndMsg"); + debugC(DEBUG_BASIC, kDebugScripts, "MouseDragEndMsg"); showMouse(); if (msg->_dropTarget) { diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 50c5dc6d1e..f99e2cc255 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -645,7 +645,7 @@ void CGameObject::playMovie(int startFrame, int endFrame, int initialFrame, uint } void CGameObject::playClip(const CString &name, uint flags) { - debugC(ERROR_DETAILED, kDebugScripts, "playClip - %s", name.c_str()); + debugC(DEBUG_DETAILED, kDebugScripts, "playClip - %s", name.c_str()); _frameNumber = -1; CMovieClip *clip = _movieClips.findByName(name); @@ -654,7 +654,7 @@ void CGameObject::playClip(const CString &name, uint flags) { } void CGameObject::playClip(uint startFrame, uint endFrame) { - debugC(ERROR_DETAILED, kDebugScripts, "playClip - %d to %d", startFrame, endFrame); + debugC(DEBUG_DETAILED, kDebugScripts, "playClip - %d to %d", startFrame, endFrame); CMovieClip *clip = new CMovieClip("", startFrame, endFrame); CGameManager *gameManager = getGameManager(); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 3d6c66dbf2..42a67c85ad 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -436,12 +436,12 @@ MODULE_OBJS := \ star_control/dvector.o \ star_control/fmatrix.o \ star_control/fpoint.o \ + star_control/fpose.o \ star_control/frange.o \ star_control/frect.o \ star_control/fvector.o \ star_control/star_control_sub2.o \ star_control/star_control_sub5.o \ - star_control/star_control_sub6.o \ star_control/star_control_sub7.o \ star_control/star_control_sub8.o \ star_control/star_control_sub12.o \ diff --git a/engines/titanic/npcs/doorbot.cpp b/engines/titanic/npcs/doorbot.cpp index 03d723a384..a1534fa673 100644 --- a/engines/titanic/npcs/doorbot.cpp +++ b/engines/titanic/npcs/doorbot.cpp @@ -82,7 +82,7 @@ void CDoorbot::load(SimpleFile *file) { } bool CDoorbot::MovieEndMsg(CMovieEndMsg *msg) { - debugC(ERROR_DETAILED, kDebugScripts, "CDoorbot MovieEndMsg flags=%x v=%d, start=%d, end=%d", + debugC(DEBUG_DETAILED, kDebugScripts, "CDoorbot MovieEndMsg flags=%x v=%d, start=%d, end=%d", _npcFlags, _introMovieNum, msg->_startFrame, msg->_endFrame); if (_npcFlags & NPCFLAG_DOORBOT_INTRO) { @@ -555,7 +555,7 @@ bool CDoorbot::EnterViewMsg(CEnterViewMsg *msg) { } bool CDoorbot::ActMsg(CActMsg *msg) { - debugC(ERROR_DETAILED, kDebugScripts, "CDoorbot ActMsg action=%s v108=%d v110=%d v114=%d", + debugC(DEBUG_DETAILED, kDebugScripts, "CDoorbot ActMsg action=%s v108=%d v110=%d v114=%d", msg->_action.c_str(), _introMovieNum, _field110, _field114); if (msg->_action == "DoorbotPlayerPressedTopButton") { diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 768ce46338..f70a2f84d1 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -96,7 +96,7 @@ bool CTrueTalkNPC::DismissBotMsg(CDismissBotMsg *msg) { } bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) { - debugC(ERROR_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechStartedMsg flags=%x dialogueId=%d", + debugC(DEBUG_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechStartedMsg flags=%x dialogueId=%d", getName().c_str(), _npcFlags, msg->_dialogueId); _npcFlags |= NPCFLAG_SPEAKING; @@ -129,7 +129,7 @@ bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMs } bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { - debugC(ERROR_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechEndedMsg flags=%x dialogueId=%d", getName().c_str(), _npcFlags, msg->_dialogueId); + debugC(DEBUG_DETAILED, kDebugScripts, "%s TrueTalkNotifySpeechEndedMsg flags=%x dialogueId=%d", getName().c_str(), _npcFlags, msg->_dialogueId); _npcFlags &= ~NPCFLAG_SPEAKING; --_speechCounter; _speechDuration = 0; diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp index f7cfedf8c4..6db804ee16 100644 --- a/engines/titanic/pet_control/pet_conversations.cpp +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -545,7 +545,7 @@ void CPetConversations::npcDialChange(uint dialNum, uint oldLevel, uint newLevel assert(oldLevel <= 100 && newLevel <= 100); if (newLevel != oldLevel) { - debugC(ERROR_DETAILED, kDebugScripts, "Dial %d change from %d to %d", + debugC(DEBUG_DETAILED, kDebugScripts, "Dial %d change from %d to %d", dialNum, oldLevel, newLevel); uint src = ascending[0], dest = ascending[1]; if (newLevel < oldLevel) { diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp index 989d74452a..e2ed619d11 100644 --- a/engines/titanic/pet_control/pet_remote.cpp +++ b/engines/titanic/pet_control/pet_remote.cpp @@ -445,6 +445,7 @@ bool CPetRemote::loadGlyph(int glyphIndex) { case GLYPH_GOTO_BAR: glyph = new CGotoBarGlyph(); + break; case GLYPH_GOTO_PROMENADE: glyph = new CGotoPromenadeDeckGlyph(); diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp index fc61eb71ea..cfadedd8e7 100644 --- a/engines/titanic/star_control/base_star.cpp +++ b/engines/titanic/star_control/base_star.cpp @@ -159,7 +159,7 @@ void CBaseStar::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarC } void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -174,17 +174,17 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -244,7 +244,7 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -259,17 +259,17 @@ void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -330,7 +330,7 @@ void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -339,23 +339,26 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; - double *v1Ptr = &_value1, *v2Ptr = &_value2, *v3Ptr = &_value3; - double tempX, tempY, tempZ, total2; + double *v1Ptr = &_value1, *v2Ptr = &_value2; + double *v3Ptr = &_value3, *v4Ptr = &_value4; + double tempX, tempY, tempZ, total2, sVal; + int xStart, yStart, rgb; + uint16 *pixelP; for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -363,13 +366,47 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar if (tempZ <= threshold || total2 >= MAX_VAL) continue; - int xStart = (int)((tempX + *v3Ptr) * *v1Ptr / tempZ + centroid._x); - int yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); + // First pixel + xStart = (int)((tempX + *v3Ptr) * *v1Ptr / tempZ + centroid._x); + yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); + if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1) + continue; + + sVal = sqrt(total2); + sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9); + sVal *= 255.0; + + if (sVal > 255.0) + sVal = 255.0; + if (sVal > 2.0) { + pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); + rgb = ((int)(sVal - 0.5) & 0xf8) << 7; + + switch (entry._thickness) { + case 0: + *pixelP = rgb; + break; + + case 1: + *pixelP = rgb; + *(pixelP + 1) = rgb; + *(pixelP + surfaceArea->_pitch / 2) = rgb; + *(pixelP + surfaceArea->_pitch / 2 + 1) = rgb; + break; + + default: + break; + } + } + + // Second pixel + xStart = (int)((tempX + *v4Ptr) * *v1Ptr / tempZ + centroid._x); + yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1) continue; - double sVal = sqrt(total2); + sVal = sqrt(total2); sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9); sVal *= 255.0; @@ -377,8 +414,8 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar sVal = 255.0; if (sVal > 2.0) { - uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); - int rgb = ((int)(sVal - 0.5) & 0xf8) << 7; + pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); + rgb = ((int)(sVal - 0.5) & 0xf8) << 7; switch (entry._thickness) { case 0: @@ -400,7 +437,7 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -418,17 +455,17 @@ void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar const CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp index 5885658835..11d96536f3 100644 --- a/engines/titanic/star_control/fmatrix.cpp +++ b/engines/titanic/star_control/fmatrix.cpp @@ -105,15 +105,15 @@ void FMatrix::fn1(const FVector &v) { } void FMatrix::fn2(const FMatrix &m) { - double x1 = _row1._y * m._row2._x + _row1._z * m._row3._x + _row1._x * m._row1._x; - double y1 = _row1._x * m._row1._y + m._row2._y * _row1._y + m._row3._y * _row1._z; - double z1 = _row1._x * m._row1._z + _row1._y * m._row2._z + _row1._z * m._row3._z; - double x2 = m._row1._x * _row2._x + m._row3._x * _row2._z + m._row2._x * _row2._y; - double y2 = m._row3._y * _row2._z + m._row1._y * _row2._x + m._row2._y * _row2._y; - double z2 = _row2._z * m._row3._z + _row2._x * m._row1._z + _row2._y * m._row2._z; - double x3 = m._row1._x * _row3._x + _row3._z * m._row3._x + _row3._y * m._row2._x; - double y3 = _row3._y * m._row2._y + _row3._z * m._row3._y + _row3._x * m._row1._y; - double z3 = _row3._x * m._row1._z + _row3._y * m._row2._z + _row3._z * m._row3._z; + float x1 = _row1._y * m._row2._x + _row1._z * m._row3._x + _row1._x * m._row1._x; + float y1 = _row1._x * m._row1._y + m._row2._y * _row1._y + m._row3._y * _row1._z; + float z1 = _row1._x * m._row1._z + _row1._y * m._row2._z + _row1._z * m._row3._z; + float x2 = m._row1._x * _row2._x + m._row3._x * _row2._z + m._row2._x * _row2._y; + float y2 = m._row3._y * _row2._z + m._row1._y * _row2._x + m._row2._y * _row2._y; + float z2 = _row2._z * m._row3._z + _row2._x * m._row1._z + _row2._y * m._row2._z; + float x3 = m._row1._x * _row3._x + _row3._z * m._row3._x + _row3._y * m._row2._x; + float y3 = _row3._y * m._row2._y + _row3._z * m._row3._y + _row3._x * m._row1._y; + float z3 = _row3._x * m._row1._z + _row3._y * m._row2._z + _row3._z * m._row3._z; _row1 = FVector(x1, y1, z1); _row2 = FVector(x2, y2, z2); @@ -121,15 +121,15 @@ void FMatrix::fn2(const FMatrix &m) { } void FMatrix::fn3(const FMatrix &m) { - double x1 = _row2._x * m._row1._y + m._row1._z * _row3._x + _row1._x * m._row1._x; - double y1 = m._row1._x * _row1._y + _row3._y * m._row1._z + _row2._y * m._row1._y; - double z1 = m._row1._x * _row1._z + m._row1._y * _row2._z + m._row1._z * _row3._z; - double x2 = _row1._x * m._row2._x + _row2._x * m._row2._y + _row3._x * m._row2._z; - double y2 = _row3._y * m._row2._z + _row1._y * m._row2._x + _row2._y * m._row2._y; - double z2 = m._row2._z * _row3._z + m._row2._x * _row1._z + m._row2._y * _row2._z; - double x3 = _row1._x * m._row3._x + m._row3._z * _row3._x + m._row3._y * _row2._x; - double y3 = m._row3._y * _row2._y + m._row3._z * _row3._y + m._row3._x * _row1._y; - double z3 = m._row3._x * _row1._z + m._row3._y * _row2._z + m._row3._z * _row3._z; + float x1 = _row2._x * m._row1._y + m._row1._z * _row3._x + _row1._x * m._row1._x; + float y1 = m._row1._x * _row1._y + _row3._y * m._row1._z + _row2._y * m._row1._y; + float z1 = m._row1._x * _row1._z + m._row1._y * _row2._z + m._row1._z * _row3._z; + float x2 = _row1._x * m._row2._x + _row2._x * m._row2._y + _row3._x * m._row2._z; + float y2 = _row3._y * m._row2._z + _row1._y * m._row2._x + _row2._y * m._row2._y; + float z2 = m._row2._z * _row3._z + m._row2._x * _row1._z + m._row2._y * _row2._z; + float x3 = _row1._x * m._row3._x + m._row3._z * _row3._x + m._row3._y * _row2._x; + float y3 = m._row3._y * _row2._y + m._row3._z * _row3._y + m._row3._x * _row1._y; + float z3 = m._row3._x * _row1._z + m._row3._y * _row2._z + m._row3._z * _row3._z; _row1 = FVector(x1, y1, z1); _row2 = FVector(x2, y2, z2); diff --git a/engines/titanic/star_control/fpoint.cpp b/engines/titanic/star_control/fpoint.cpp index a7c764177a..e70cd64ebd 100644 --- a/engines/titanic/star_control/fpoint.cpp +++ b/engines/titanic/star_control/fpoint.cpp @@ -25,11 +25,11 @@ namespace Titanic { -double FPoint::normalize() { - double hyp = sqrt(_x * _x + _y * _y); +float FPoint::normalize() { + float hyp = sqrt(_x * _x + _y * _y); assert(hyp != 0.0); - double fraction = 1.0 / hyp; + float fraction = 1.0 / hyp; _x *= fraction; _y *= fraction; return hyp; diff --git a/engines/titanic/star_control/fpoint.h b/engines/titanic/star_control/fpoint.h index d967351289..d65da1a13f 100644 --- a/engines/titanic/star_control/fpoint.h +++ b/engines/titanic/star_control/fpoint.h @@ -32,10 +32,10 @@ namespace Titanic { */ class FPoint { public: - double _x, _y; + float _x, _y; public: FPoint() : _x(0), _y(0) {} - FPoint(double x, double y) : _x(x), _y(y) {} + FPoint(float x, float y) : _x(x), _y(y) {} FPoint(const Common::Point &pt) : _x(pt.x), _y(pt.y) {} bool operator==(const FPoint &p) const { return _x == p._x && _y == p._y; } @@ -57,7 +57,7 @@ public: * Normalises the X and Y coordinates as fractions relative to the * value of the hypotenuse formed by a triangle from the origin (0,0) */ - double normalize(); + float normalize(); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/fpose.cpp index db9c4e59ab..3f7b03df85 100644 --- a/engines/titanic/star_control/star_control_sub6.cpp +++ b/engines/titanic/star_control/fpose.cpp @@ -20,73 +20,73 @@ * */ -#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fpose.h" namespace Titanic { -CStarControlSub6::CStarControlSub6() { +FPose::FPose() { clear(); } -CStarControlSub6::CStarControlSub6(Axis axis, double amount) { +FPose::FPose(Axis axis, float amount) { setRotationMatrix(axis, amount); } -CStarControlSub6::CStarControlSub6(const CStarControlSub6 *src) { +FPose::FPose(const FPose &src) : FMatrix() { copyFrom(src); } -CStarControlSub6::CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2) { - _row1._x = s2->_row1._x * s1->_row1._x - + s1->_row1._z * s2->_row3._x - + s1->_row1._y * s2->_row2._x; - _row1._y = s1->_row1._x * s2->_row1._y - + s2->_row3._y * s1->_row1._z - + s2->_row2._y * s1->_row1._y; - _row1._z = s1->_row1._x * s2->_row1._z - + s2->_row3._z * s1->_row1._z - + s2->_row2._z * s1->_row1._y; - _row2._x = s2->_row1._x * s1->_row2._x - + s1->_row2._y * s2->_row2._x - + s1->_row2._z * s2->_row3._x; - _row2._y = s1->_row2._y * s2->_row2._y - + s1->_row2._z * s2->_row3._y - + s2->_row1._y * s1->_row2._x; - _row2._z = s2->_row1._z * s1->_row2._x - + s1->_row2._y * s2->_row2._z - + s1->_row2._z * s2->_row3._z; - _row3._x = s2->_row1._x * s1->_row3._x - + s1->_row3._y * s2->_row2._x - + s1->_row3._z * s2->_row3._x; - _row3._y = s1->_row3._z * s2->_row3._y - + s1->_row3._y * s2->_row2._y - + s2->_row1._y * s1->_row3._x; - _row3._z = s2->_row3._z * s1->_row3._z - + s2->_row2._z * s1->_row3._y - + s2->_row1._z * s1->_row3._x; - _vector._x = s2->_row1._x * s1->_vector._x - + s1->_vector._y * s2->_row2._x - + s1->_vector._z * s2->_row3._x - + s2->_vector._x; - _vector._y = s1->_vector._z * s2->_row3._y - + s1->_vector._y * s2->_row2._y - + s1->_vector._x * s2->_row1._y - + s2->_vector._y; - _vector._z = s1->_vector._y * s2->_row2._z - + s1->_vector._z * s2->_row3._z - + s1->_vector._x * s2->_row1._z - + s2->_vector._z; +FPose::FPose(const FPose &s1, const FPose &s2) { + _row1._x = s2._row1._x * s1._row1._x + + s1._row1._z * s2._row3._x + + s1._row1._y * s2._row2._x; + _row1._y = s1._row1._x * s2._row1._y + + s2._row3._y * s1._row1._z + + s2._row2._y * s1._row1._y; + _row1._z = s1._row1._x * s2._row1._z + + s2._row3._z * s1._row1._z + + s2._row2._z * s1._row1._y; + _row2._x = s2._row1._x * s1._row2._x + + s1._row2._y * s2._row2._x + + s1._row2._z * s2._row3._x; + _row2._y = s1._row2._y * s2._row2._y + + s1._row2._z * s2._row3._y + + s2._row1._y * s1._row2._x; + _row2._z = s2._row1._z * s1._row2._x + + s1._row2._y * s2._row2._z + + s1._row2._z * s2._row3._z; + _row3._x = s2._row1._x * s1._row3._x + + s1._row3._y * s2._row2._x + + s1._row3._z * s2._row3._x; + _row3._y = s1._row3._z * s2._row3._y + + s1._row3._y * s2._row2._y + + s2._row1._y * s1._row3._x; + _row3._z = s2._row3._z * s1._row3._z + + s2._row2._z * s1._row3._y + + s2._row1._z * s1._row3._x; + _vector._x = s2._row1._x * s1._vector._x + + s1._vector._y * s2._row2._x + + s1._vector._z * s2._row3._x + + s2._vector._x; + _vector._y = s1._vector._z * s2._row3._y + + s1._vector._y * s2._row2._y + + s1._vector._x * s2._row1._y + + s2._vector._y; + _vector._z = s1._vector._y * s2._row2._z + + s1._vector._z * s2._row3._z + + s1._vector._x * s2._row1._z + + s2._vector._z; } -void CStarControlSub6::identity() { +void FPose::identity() { FMatrix::identity(); _vector.clear(); } -void CStarControlSub6::setRotationMatrix(Axis axis, double amount) { - const double ROTATION = 2 * M_PI / 360.0; - double sinVal = sin(amount * ROTATION); - double cosVal = cos(amount * ROTATION); +void FPose::setRotationMatrix(Axis axis, float amount) { + const float ROTATION = 2 * M_PI / 360.0; + float sinVal = sin(amount * ROTATION); + float cosVal = cos(amount * ROTATION); switch (axis) { case X_AXIS: @@ -110,7 +110,7 @@ void CStarControlSub6::setRotationMatrix(Axis axis, double amount) { _row2._z = 0.0; _row3._x = -sinVal; _row3._y = 0.0; - _row3._z = sinVal; + _row3._z = cosVal; break; case Z_AXIS: @@ -132,23 +132,23 @@ void CStarControlSub6::setRotationMatrix(Axis axis, double amount) { _vector.clear(); } -void CStarControlSub6::copyFrom(const CStarControlSub6 *src) { - _row1 = src->_row1; - _row2 = src->_row2; - _row3 = src->_row3; - _vector = src->_vector; +void FPose::copyFrom(const FPose &src) { + _row1 = src._row1; + _row2 = src._row2; + _row3 = src._row3; + _vector = src._vector; } -void CStarControlSub6::copyFrom(const FMatrix &src) { +void FPose::copyFrom(const FMatrix &src) { _row1 = src._row1; _row2 = src._row2; _row3 = src._row3; } -CStarControlSub6 CStarControlSub6::fn4() const { - double v2, v3, v6, v7, v8, v9, v10, v11; - double v12, v13, v14, v15, v16, v17, v18; - CStarControlSub6 result; +FPose FPose::fn4() const { + float v2, v3, v6, v7, v8, v9, v10, v11; + float v12, v13, v14, v15, v16, v17, v18; + FPose result; v16 = _row3._z * _row2._y; v2 = _row1._x * v16; diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/fpose.h index 6ac22a79df..dbdd832067 100644 --- a/engines/titanic/star_control/star_control_sub6.h +++ b/engines/titanic/star_control/fpose.h @@ -20,21 +20,24 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB6_H -#define TITANIC_STAR_CONTROL_SUB6_H +#ifndef TITANIC_FPOSE_H +#define TITANIC_FPOSE_H #include "titanic/star_control/fmatrix.h" namespace Titanic { -class CStarControlSub6 : public FMatrix { +/* + * This class combines a position and orientation in 3D space + */ +class FPose : public FMatrix { public: FVector _vector; public: - CStarControlSub6(); - CStarControlSub6(Axis axis, double amount); - CStarControlSub6(const CStarControlSub6 *src); - CStarControlSub6(const CStarControlSub6 *s1, const CStarControlSub6 *s2); + FPose(); + FPose(Axis axis, float amount); + FPose(const FPose &src); + FPose(const FPose &s1, const FPose &s2); /** * Sets an identity matrix @@ -44,18 +47,21 @@ public: /** * Sets a rotation matrix for the given axis for the given amount */ - void setRotationMatrix(Axis axis, double val); + void setRotationMatrix(Axis axis, float val); - void copyFrom(const CStarControlSub6 *src); + /** + * Copy from the specified source pose + */ + void copyFrom(const FPose &src); /** - * Copy from the specified matrix + * Copy from the specified source matrix */ void copyFrom(const FMatrix &src); - CStarControlSub6 fn4() const; + FPose fn4() const; }; } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB6_H */ +#endif /* TITANIC_FPOSE_H */ diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp index eec16d1778..19fbefb75c 100644 --- a/engines/titanic/star_control/fvector.cpp +++ b/engines/titanic/star_control/fvector.cpp @@ -22,7 +22,7 @@ #include "titanic/star_control/fvector.h" #include "titanic/star_control/dvector.h" -#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fpose.h" #include "common/algorithm.h" #include "common/textconsole.h" @@ -48,8 +48,8 @@ FVector FVector::crossProduct(const FVector &src) const { ); } -double FVector::normalize() { - double hyp = sqrt(_x * _x + _y * _y + _z * _z); +float FVector::normalize() { + float hyp = sqrt(_x * _x + _y * _y + _z * _z); assert(hyp); _x *= 1.0 / hyp; @@ -66,19 +66,19 @@ const FVector *FVector::addAndNormalize(FVector &dest, const FVector &v1, const return &dest; } -double FVector::getDistance(const FVector &src) const { - double xd = src._x - _x; - double yd = src._y - _y; - double zd = src._z - _z; +float FVector::getDistance(const FVector &src) const { + float xd = src._x - _x; + float yd = src._y - _y; + float zd = src._z - _z; return sqrt(xd * xd + yd * yd + zd * zd); } -FVector FVector::fn5(const CStarControlSub6 *sub6) const { +FVector FVector::fn5(const FPose &pose) const { FVector v; - v._x = sub6->_row2._x * _y + sub6->_row3._x * _z + sub6->_row1._x * _x + sub6->_vector._x; - v._y = sub6->_row2._y * _y + sub6->_row3._y * _z + sub6->_row1._y * _x + sub6->_vector._y; - v._z = sub6->_row3._z * _z + sub6->_row2._z * _y + sub6->_row1._z * _x + sub6->_vector._z; + v._x = pose._row2._x * _y + pose._row3._x * _z + pose._row1._x * _x + pose._vector._x; + v._y = pose._row2._y * _y + pose._row3._y * _z + pose._row1._y * _x + pose._vector._y; + v._z = pose._row3._z * _z + pose._row2._z * _y + pose._row1._z * _x + pose._vector._z; return v; } diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h index dd8a25e957..6ad281883d 100644 --- a/engines/titanic/star_control/fvector.h +++ b/engines/titanic/star_control/fvector.h @@ -29,7 +29,7 @@ namespace Titanic { enum Axis { X_AXIS, Y_AXIS, Z_AXIS }; -class CStarControlSub6; +class FPose; class DVector; /** @@ -38,10 +38,10 @@ class DVector; */ class FVector { public: - double _x, _y, _z; + float _x, _y, _z; public: FVector() : _x(0), _y(0), _z(0) {} - FVector(double x, double y, double z) : _x(x), _y(y), _z(z) {} + FVector(float x, float y, float z) : _x(x), _y(y), _z(z) {} FVector(const DVector &src); /** @@ -61,7 +61,7 @@ public: /** * Normalizes the vector so the length from origin equals 1.0 */ - double normalize(); + float normalize(); /** * Adds two vectors together and then normalizes the result @@ -71,9 +71,9 @@ public: /** * Returns the distance between a specified point and this one */ - double getDistance(const FVector &src) const; + float getDistance(const FVector &src) const; - FVector fn5(const CStarControlSub6 *sub6) const; + FVector fn5(const FPose &pose) const; /** * Returns true if the passed vector equals this one @@ -97,7 +97,7 @@ public: return FVector(_x - delta._x, _y - delta._y, _z - delta._z); } - const FVector operator*(double right) const { + const FVector operator*(float right) const { return FVector(_x * right, _y * right, _z * right); } diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index abdbf194b5..fd007d33b6 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -25,7 +25,7 @@ #include "titanic/star_control/star_control.h" #include "titanic/star_control/dmatrix.h" #include "titanic/star_control/error_code.h" -#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fpose.h" #include "titanic/star_control/star_control_sub12.h" #include "titanic/game_manager.h" #include "titanic/core/dont_save_file_item.h" diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp index 1f6df61104..8893902a53 100644 --- a/engines/titanic/star_control/star_control_sub12.cpp +++ b/engines/titanic/star_control/star_control_sub12.cpp @@ -25,6 +25,7 @@ #include "titanic/star_control/star_control_sub22.h" #include "titanic/star_control/dmatrix.h" #include "titanic/star_control/fmatrix.h" +#include "titanic/titanic.h" namespace Titanic { @@ -166,9 +167,9 @@ void CStarControlSub12::proc20(double factor) { _sub13.reposition(factor); } -void CStarControlSub12::proc21(const CStarControlSub6 *sub6) { +void CStarControlSub12::proc21(const FPose &pose) { if (!isLocked()) { - _sub13.setPosition(sub6); + _sub13.setPosition(pose); set108(); } } @@ -178,11 +179,11 @@ void CStarControlSub12::proc22(FMatrix &m) { _sub13.fn15(m); } -CStarControlSub6 CStarControlSub12::proc23() { +FPose CStarControlSub12::proc23() { return _sub13.getSub1(); } -CStarControlSub6 CStarControlSub12::proc24() { +FPose CStarControlSub12::proc24() { return _sub13.getSub2(); } @@ -198,15 +199,17 @@ int CStarControlSub12::proc27() const { return _sub13._field24; } -void CStarControlSub12::proc28(int index, const FVector &src, FVector &dest) { +FVector CStarControlSub12::proc28(int index, const FVector &src) { + FVector dest; dest._x = ((_sub13._valArray[index] + src._x) * _sub13._centerVector._x) / (_sub13._centerVector._y * src._z); dest._y = src._y * _sub13._centerVector._x / (_sub13._centerVector._z * src._z); dest._z = src._z; + return dest; } -void CStarControlSub12::proc29(int index, const FVector &src, FVector &dest) { - _sub13.fn16(index, src, dest); +FVector CStarControlSub12::proc29(int index, const FVector &src) { + return _sub13.fn16(index, src); } FVector CStarControlSub12::proc30(int index, const FVector &v) { @@ -218,21 +221,21 @@ FVector CStarControlSub12::proc31(int index, const FVector &v) { } void CStarControlSub12::setViewportPosition(const FPoint &angles) { + debug(DEBUG_INTERMEDIATE, "setViewportPosition %f %f", angles._x, angles._y); + if (isLocked()) return; if (_matrixRow == -1) { - CStarControlSub6 subX(X_AXIS, angles._x); - CStarControlSub6 subY(Y_AXIS, angles._y); - CStarControlSub6 sub(&subX, &subY); - subY.copyFrom(&sub); - proc22(subY); + FPose subX(X_AXIS, angles._y); + FPose subY(Y_AXIS, angles._x); + FPose sub(subX, subY); + proc22(sub); } else if (_matrixRow == 0) { FVector row1 = _matrix._row1; - CStarControlSub6 subX(X_AXIS, angles._x); - CStarControlSub6 subY(Y_AXIS, angles._y); - CStarControlSub6 sub(&subX, &subY); - subX.copyFrom(&sub); + FPose subX(X_AXIS, angles._y); + FPose subY(Y_AXIS, angles._x); + FPose sub(subX, subY); FMatrix m1 = _sub13.getMatrix(); FVector tempV1 = _sub13._position; @@ -277,10 +280,10 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) { tempV6._y = tempV6._y - row1._y; tempV6._z = tempV6._z - row1._z; - FVector modV1 = tempV1.fn5(&subX); - FVector modV2 = tempV4.fn5(&subX); - FVector modV3 = tempV5.fn5(&subX); - FVector modV4 = tempV6.fn5(&subX); + FVector modV1 = tempV1.fn5(sub); + FVector modV2 = tempV4.fn5(sub); + FVector modV3 = tempV5.fn5(sub); + FVector modV4 = tempV6.fn5(sub); tempV1 = modV1; tempV4 = modV2; tempV5 = modV3; @@ -320,7 +323,7 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) { DVector tempV13, tempV14, tempV15, tempV16; DMatrix subX(0, _matrix._row1); - DMatrix subY(Y_AXIS, angles._x); + DMatrix subY(Y_AXIS, angles._y); tempV1 = _matrix._row2 - _matrix._row1; diffV = tempV1; diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h index c36960e24a..f54ba11b08 100644 --- a/engines/titanic/star_control/star_control_sub12.h +++ b/engines/titanic/star_control/star_control_sub12.h @@ -85,15 +85,15 @@ public: virtual void proc18(); virtual void proc19(); virtual void proc20(double factor); - virtual void proc21(const CStarControlSub6 *sub6); + virtual void proc21(const FPose &pose); virtual void proc22(FMatrix &m); - virtual CStarControlSub6 proc23(); - virtual CStarControlSub6 proc24(); + virtual FPose proc23(); + virtual FPose proc24(); virtual double proc25() const; virtual double proc26() const; virtual int proc27() const; - virtual void proc28(int index, const FVector &src, FVector &dest); - virtual void proc29(int index, const FVector &src, FVector &dest); + virtual FVector proc28(int index, const FVector &src); + virtual FVector proc29(int index, const FVector &src); virtual FVector proc30(int index, const FVector &v); virtual FVector proc31(int index, const FVector &v); diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp index d96a29075b..49bcdbcef7 100644 --- a/engines/titanic/star_control/star_control_sub13.cpp +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -39,7 +39,7 @@ CStarControlSub13::CStarControlSub13() { } CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) : - _matrix(src->_matrix), _sub1(&src->_sub1), _sub2(&src->_sub2) { + _matrix(src->_matrix), _sub1(src->_sub1), _sub2(src->_sub2) { _position = src->_position; _fieldC = src->_fieldC; _field10 = src->_field10; @@ -105,9 +105,9 @@ void CStarControlSub13::setPosition(const FVector &v) { _flag = false; } -void CStarControlSub13::setPosition(const CStarControlSub6 *sub6) { - _position.fn5(sub6); - _position = sub6->_row1; +void CStarControlSub13::setPosition(const FPose &pose) { + _position.fn5(pose); + _position = pose._row1; _flag = false; } @@ -148,12 +148,12 @@ void CStarControlSub13::set1C(double v) { void CStarControlSub13::fn12() { _matrix.identity(); - CStarControlSub6 m1(X_AXIS, g_vm->getRandomNumber(359)); - CStarControlSub6 m2(Y_AXIS, g_vm->getRandomNumber(359)); - CStarControlSub6 m3(Z_AXIS, g_vm->getRandomNumber(359)); + FPose m1(X_AXIS, g_vm->getRandomNumber(359)); + FPose m2(Y_AXIS, g_vm->getRandomNumber(359)); + FPose m3(Z_AXIS, g_vm->getRandomNumber(359)); - CStarControlSub6 s1(&m1, &m2); - CStarControlSub6 s2(&s1, &m3); + FPose s1(m1, m2); + FPose s2(s1, m3); m1.copyFrom(s2); _matrix.fn2(m1); @@ -185,35 +185,37 @@ void CStarControlSub13::fn15(const FMatrix &matrix) { _flag = false; } -CStarControlSub6 CStarControlSub13::getSub1() { +FPose CStarControlSub13::getSub1() { if (!_flag) reset(); return _sub1; } -CStarControlSub6 CStarControlSub13::getSub2() { +FPose CStarControlSub13::getSub2() { if (!_flag) reset(); return _sub2; } -void CStarControlSub13::fn16(int index, const FVector &src, FVector &dest) { - CStarControlSub6 temp = getSub1(); +FVector CStarControlSub13::fn16(int index, const FVector &src) { + FPose temp = getSub1(); + FVector dest; dest._x = temp._row3._x * src._z + temp._row2._x * src._y + src._x * temp._row1._x + temp._vector._x; dest._y = temp._row3._y * src._z + temp._row2._y * src._y + src._x * temp._row1._y + temp._vector._y; dest._z = temp._row3._z * src._z + temp._row2._z * src._y + src._x * temp._row1._z + temp._vector._z; + return dest; } FVector CStarControlSub13::fn17(int index, const FVector &src) { FVector dest; - CStarControlSub6 sub6 = getSub1(); - FVector tv = src.fn5(&sub6); + FPose pose = getSub1(); + FVector tv = src.fn5(pose); dest._x = (_valArray[index] + tv._x) * _centerVector._x / (_centerVector._y * tv._z); @@ -224,8 +226,8 @@ FVector CStarControlSub13::fn17(int index, const FVector &src) { FVector CStarControlSub13::fn18(int index, const FVector &src) { FVector dest; - CStarControlSub6 sub6 = getSub2(); - FVector tv = src.fn5(&sub6); + FPose pose = getSub2(); + FVector tv = src.fn5(pose); dest._x = (_valArray[index] + tv._x) * _centerVector._x / (_centerVector._y * tv._z); diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h index e47c42e6eb..123ca0914c 100644 --- a/engines/titanic/star_control/star_control_sub13.h +++ b/engines/titanic/star_control/star_control_sub13.h @@ -25,7 +25,7 @@ #include "titanic/support/simple_file.h" #include "titanic/star_control/base_star.h" -#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fpose.h" #include "titanic/star_control/fmatrix.h" namespace Titanic { @@ -38,8 +38,8 @@ private: int _width; int _height; FMatrix _matrix; - CStarControlSub6 _sub1; - CStarControlSub6 _sub2; + FPose _sub1; + FPose _sub2; FPoint _center; bool _flag; private: @@ -78,7 +78,7 @@ public: /** * Sets the position */ - void setPosition(const CStarControlSub6 *sub6); + void setPosition(const FPose &pose); /** * Sets the matrix @@ -90,9 +90,9 @@ public: void fn13(StarMode mode, double val); void reposition(double factor); void fn15(const FMatrix &matrix); - CStarControlSub6 getSub1(); - CStarControlSub6 getSub2(); - void fn16(int index, const FVector &src, FVector &dest); + FPose getSub1(); + FPose getSub2(); + FVector fn16(int index, const FVector &src); FVector fn17(int index, const FVector &src); FVector fn18(int index, const FVector &src); void fn19(double *v1, double *v2, double *v3, double *v4); diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h index fa3656328e..082c18dd53 100644 --- a/engines/titanic/star_control/star_control_sub23.h +++ b/engines/titanic/star_control/star_control_sub23.h @@ -39,7 +39,7 @@ protected: FVector _row3; int _field34; double _field38; - int _field3C; + double _field3C; int _field40; int _field44; int _field48; diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp index 98c237c7fd..cdd2dbbce8 100644 --- a/engines/titanic/star_control/star_control_sub27.cpp +++ b/engines/titanic/star_control/star_control_sub27.cpp @@ -28,7 +28,7 @@ namespace Titanic { void CStarControlSub27::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) { CStarControlSub23::proc2(v1, v2, m1, m2); - int v24 = _field24; + double factor = _field24; if (_field24 > 0.0) { _field8 = 1; _field34 = 1; @@ -43,7 +43,7 @@ void CStarControlSub27::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2 _field60 = 0.1; _field8 = 1; } else { - _field60 = 1.0 / (double)v24; + _field60 = 1.0 / factor; _field8 = 1; } } diff --git a/engines/titanic/star_control/star_control_sub5.cpp b/engines/titanic/star_control/star_control_sub5.cpp index 328a992ea5..2fd8a119dd 100644 --- a/engines/titanic/star_control/star_control_sub5.cpp +++ b/engines/titanic/star_control/star_control_sub5.cpp @@ -189,7 +189,7 @@ bool CStarControlSub5::setup2(int val1, int val2) { return false; } -void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, double v1, double v2, double v3, +void CStarControlSub5::proc2(const FPose &pose, const FVector &vector, double v1, double v2, double v3, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { const int VALUES[] = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4 }; double val1 = sub12->proc25(); @@ -252,15 +252,15 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub _sub1._vector._x = f22 * f10 + vector._x; _sub1._vector._y = f9 * f22 + vector._y; _sub1._vector._z = f22 * f12 + vector._z; - _sub2._row1._x = sub6->_row1._x * f13 + f16 * sub6->_row3._x + f15 * sub6->_row2._x; - _sub2._row1._y = f15 * sub6->_row2._y + f16 * sub6->_row3._y + f13 * sub6->_row1._y; - _sub2._row1._z = f16 * sub6->_row3._z + f13 * sub6->_row1._z + f15 * sub6->_row2._z; - _sub2._row2._x = sub6->_row1._x * f17 + f19 * sub6->_row3._x + f18 * sub6->_row2._x; - _sub2._row2._y = f18 * sub6->_row2._y + f17 * sub6->_row1._y + f19 * sub6->_row3._y; - _sub2._row2._z = f18 * sub6->_row2._z + f19 * sub6->_row3._z + f17 * sub6->_row1._z; - _sub2._row3._x = sub6->_row1._x * f20 + f21 * sub6->_row3._x; - _sub2._row3._y = f20 * sub6->_row1._y + f21 * sub6->_row3._y; - _sub2._row3._z = f20 * sub6->_row1._z + f21 * sub6->_row3._z; + _sub2._row1._x = pose._row1._x * f13 + f16 * pose._row3._x + f15 * pose._row2._x; + _sub2._row1._y = f15 * pose._row2._y + f16 * pose._row3._y + f13 * pose._row1._y; + _sub2._row1._z = f16 * pose._row3._z + f13 * pose._row1._z + f15 * pose._row2._z; + _sub2._row2._x = pose._row1._x * f17 + f19 * pose._row3._x + f18 * pose._row2._x; + _sub2._row2._y = f18 * pose._row2._y + f17 * pose._row1._y + f19 * pose._row3._y; + _sub2._row2._z = f18 * pose._row2._z + f19 * pose._row3._z + f17 * pose._row1._z; + _sub2._row3._x = pose._row1._x * f20 + f21 * pose._row3._x; + _sub2._row3._y = f20 * pose._row1._y + f21 * pose._row3._y; + _sub2._row3._z = f20 * pose._row1._z + f21 * pose._row3._z; f23 = _sub1._vector._y; f24 = _sub1._vector._z; @@ -269,18 +269,18 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub f27 = _sub1._vector._x; f28 = _sub1._vector._y; - _sub2._vector._x = sub6->_row1._x * _sub1._vector._x - + sub6->_row3._x * _sub1._vector._z - + sub6->_row2._x * f28 - + sub6->_vector._x; - _sub2._vector._y = f23 * sub6->_row2._y - + f24 * sub6->_row3._y - + f25 * sub6->_row1._y - + sub6->_vector._y; - _sub2._vector._z = f26 * sub6->_row3._z - + f27 * sub6->_row1._z - + f28 * sub6->_row2._z - + sub6->_vector._z; + _sub2._vector._x = pose._row1._x * _sub1._vector._x + + pose._row3._x * _sub1._vector._z + + pose._row2._x * f28 + + pose._vector._x; + _sub2._vector._y = f23 * pose._row2._y + + f24 * pose._row3._y + + f25 * pose._row1._y + + pose._vector._y; + _sub2._vector._z = f26 * pose._row3._z + + f27 * pose._row1._z + + f28 * pose._row2._z + + pose._vector._z; size2 = (int)_array[1]._data2.size(); size1 = (int)_array[1]._data1.size(); @@ -318,7 +318,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - sub12->proc28(2, gridEntry, tempV); + tempV = sub12->proc28(2, gridEntry); gridEntry._position._x = tempV._x; gridEntry._position._y = tempV._y + v2; } @@ -340,7 +340,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - sub12->proc28(0, gridEntry, tempV); + tempV = sub12->proc28(0, gridEntry); gridEntry._position._x = tempV._x + v1; gridEntry._position._y = tempV._y + v2; } @@ -362,7 +362,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - sub12->proc28(1, gridEntry, tempV); + tempV = sub12->proc28(1, gridEntry); gridEntry._position._x = tempV._x + v1; gridEntry._position._y = tempV._y + v2; } @@ -407,22 +407,22 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub const FVector &d2v = entry._data2[ctr]; FVector newV = d2v + vector; - f41 = sub6->_row1._x; - f42 = sub6->_row3._x; - f43 = sub6->_row2._x; + f41 = pose._row1._x; + f42 = pose._row3._x; + f43 = pose._row2._x; f44 = f43 * newV._y; f45 = f41 * newV._x + f42 * newV._z + f44; - f46 = f45 + sub6->_vector._x; + f46 = f45 + pose._vector._x; gridEntry._x = f46; - gridEntry._y = newV._y * sub6->_row2._y - + newV._z * sub6->_row3._y - + newV._x * sub6->_row1._y - + sub6->_vector._y; - gridEntry._z = newV._z * sub6->_row3._z - + newV._y * sub6->_row2._z - + newV._x * sub6->_row1._z - + sub6->_vector._z; + gridEntry._y = newV._y * pose._row2._y + + newV._z * pose._row3._y + + newV._x * pose._row1._y + + pose._vector._y; + gridEntry._z = newV._z * pose._row3._z + + newV._y * pose._row2._z + + newV._x * pose._row1._z + + pose._vector._z; } if (val2 <= 0) { @@ -432,7 +432,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - sub12->proc28(2, gridEntry, tempV); + tempV = sub12->proc28(2, gridEntry); gridEntry._position._x = tempV._x + v1; gridEntry._position._y = tempV._y + v2; } @@ -454,7 +454,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - sub12->proc28(2, gridEntry, tempV); + tempV = sub12->proc28(2, gridEntry); gridEntry._position._x = tempV._x + v1; gridEntry._position._y = tempV._y + v2; } @@ -476,7 +476,7 @@ void CStarControlSub5::proc2(CStarControlSub6 *sub6, const FVector &vector, doub for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - sub12->proc28(2, gridEntry, tempV); + tempV = sub12->proc28(2, gridEntry); gridEntry._position._x = tempV._x + v1; gridEntry._position._y = tempV._y + v2; } diff --git a/engines/titanic/star_control/star_control_sub5.h b/engines/titanic/star_control/star_control_sub5.h index dc25ddc62b..25aafa87c8 100644 --- a/engines/titanic/star_control/star_control_sub5.h +++ b/engines/titanic/star_control/star_control_sub5.h @@ -25,7 +25,7 @@ #include "common/array.h" #include "titanic/star_control/fvector.h" -#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fpose.h" #include "titanic/star_control/error_code.h" #include "titanic/star_control/surface_area.h" @@ -93,7 +93,7 @@ class CStarControlSub5 { }; private: bool _flag; - CStarControlSub6 _sub1, _sub2; + FPose _sub1, _sub2; SubEntry _array[5]; Entry _entries[1284]; int _multiplier; @@ -116,7 +116,7 @@ public: virtual ~CStarControlSub5() {} virtual bool setup(); - virtual void proc2(CStarControlSub6 *sub6, const FVector &vector, double v1, double v2, double v3, + virtual void proc2(const FPose &pose, const FVector &vector, double v1, double v2, double v3, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); virtual void proc3(CErrorCode *errorCode); diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp index 3e1f718053..3324711160 100644 --- a/engines/titanic/star_control/star_control_sub7.cpp +++ b/engines/titanic/star_control/star_control_sub7.cpp @@ -29,7 +29,7 @@ void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, if (_data.empty()) return; - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); double threshold = sub12->proc25(); FPoint center((double)surfaceArea->_width * 0.5, surfaceArea->_height * 0.5); @@ -42,16 +42,15 @@ void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, for (uint idx = 0; idx < _data.size(); ++idx) { const CBaseStarEntry &star = _data[idx]; - newV._x = sub6._row1._x * star._position._x + sub6._row3._x * star._position._z - + sub6._row2._x * star._position._y + sub6._vector._x; - newV._y = sub6._row1._y * star._position._x + sub6._row3._y * star._position._z - + sub6._row2._y * star._position._x + sub6._vector._y; - newV._z = sub6._row1._z * star._position._x + sub6._row3._z * star._position._z - + sub6._row2._z * star._position._y + sub6._vector._z; + newV._x = pose._row1._x * star._position._x + pose._row3._x * star._position._z + + pose._row2._x * star._position._y + pose._vector._x; + newV._y = pose._row1._y * star._position._x + pose._row3._y * star._position._z + + pose._row2._y * star._position._x + pose._vector._y; + newV._z = pose._row1._z * star._position._x + pose._row3._z * star._position._z + + pose._row2._z * star._position._y + pose._vector._z; if (newV._z > threshold) { - FVector vTemp; - sub12->proc28(2, newV, vTemp); + FVector vTemp = sub12->proc28(2, newV); FRect r1(center._x + vTemp._x, center._y + vTemp._y, center._x + vTemp._x + 4.0, center._y + vTemp._y + 4.0); diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index f071f16de2..d7e4935895 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -188,13 +188,12 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, const CBaseStarEntry *dataP = _sub7.getDataPtr(_sub8._fieldC); v2 = dataP->_position; - FVector tv; - sub12->proc29(2, v2, tv); + FVector tv = sub12->proc29(2, v2); if (sub12->proc25() >= tv._z) return -1.0; - sub12->proc28(2, tv, tv); + tv = sub12->proc28(2, tv); v1 = FVector(tv._x + surfaceArea->_centroid._x, tv._y + surfaceArea->_centroid._y, tv._z); diff --git a/engines/titanic/star_control/star_points1.cpp b/engines/titanic/star_control/star_points1.cpp index 0467461222..cf5c98ebf4 100644 --- a/engines/titanic/star_control/star_points1.cpp +++ b/engines/titanic/star_control/star_points1.cpp @@ -61,7 +61,7 @@ void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { if (_data.empty()) return; - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); double threshold = sub12->proc25(); FVector vector1, vector2, vector3, vector4; FVector vTemp = _data[0]; @@ -74,24 +74,22 @@ void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { surface->setColorFromPixel(); SurfaceAreaMode oldMode = surface->setMode(SA_NONE); - vector1._z = vTemp._x * sub6._row1._z + vTemp._y * sub6._row2._z + vTemp._z * sub6._row3._z + sub6._vector._z; - vector1._x = vTemp._x * sub6._row1._x + vTemp._y * sub6._row2._x + vTemp._z * sub6._row3._x + sub6._vector._x; - vector1._y = vTemp._x * sub6._row1._y + vTemp._y * sub6._row2._y + vTemp._z * sub6._row3._y + sub6._vector._y; + vector1._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z; + vector1._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x + pose._vector._x; + vector1._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y + pose._vector._y; for (uint idx = 1; idx < _data.size(); ++idx) { const FVector &sv = _data[idx]; bool flag = _data[idx - 1]._flag; vTemp = sv; - vector3._x = vTemp._x * sub6._row1._x + vTemp._y * sub6._row2._x + vTemp._z * sub6._row3._x * sub6._vector._x; - vector3._y = vTemp._x * sub6._row1._y + vTemp._y * sub6._row2._y + vTemp._z * sub6._row3._y * sub6._vector._y; - vector3._z = vTemp._x * sub6._row1._z + vTemp._y * sub6._row2._z + vTemp._z * sub6._row3._z + sub6._vector._z; + vector3._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x * pose._vector._x; + vector3._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y * pose._vector._y; + vector3._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z; if (flag && vector1._z > threshold && vector3._z > threshold) { - vector2.clear(); - vector4.clear(); - sub12->proc28(2, vector1, vector2); - sub12->proc28(2, vector3, vector4); + vector2 = sub12->proc28(2, vector1); + vector4 = sub12->proc28(2, vector3); r.bottom = vector4._y + vHeight2; r.right = vector4._x + vWidth2; diff --git a/engines/titanic/star_control/star_points2.cpp b/engines/titanic/star_control/star_points2.cpp index 03de314244..7dec3f8605 100644 --- a/engines/titanic/star_control/star_points2.cpp +++ b/engines/titanic/star_control/star_points2.cpp @@ -66,7 +66,7 @@ void CStarPoints2::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { if (_data.empty()) return; - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); double threshold = sub12->proc25(); FVector vector1, vector2, vector3, vector4; double vWidth2 = (double)surface->_width * 0.5; @@ -85,24 +85,22 @@ void CStarPoints2::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { for (uint idx = 0; idx < re.size(); ++idx) { const CStarPointEntry &se = re[idx]; - vector1._z = sub6._row2._z * se._v1._y + sub6._row3._z * se._v1._z - + sub6._row1._z * se._v1._x + sub6._vector._z; - vector1._x = sub6._row2._x * se._v1._y + sub6._row3._x * se._v1._z - + sub6._row1._x * se._v1._x + sub6._vector._x; - vector1._y = sub6._row2._y * se._v1._y + sub6._row3._y * se._v1._z - + sub6._row1._y * se._v1._x + sub6._vector._y; - vector3._z = sub6._row2._z * se._v2._y + sub6._row2._x * se._v2._z - + sub6._row1._z * se._v2._x + sub6._vector._y; - vector3._x = sub6._row3._z * se._v2._y + sub6._row3._x * se._v2._z - + sub6._row1._x * se._v2._x + sub6._vector._y; - vector3._y = sub6._row2._y * se._v2._y + sub6._row3._y * se._v2._z - + sub6._row1._y * se._v2._x + sub6._vector._y; + vector1._z = pose._row2._z * se._v1._y + pose._row3._z * se._v1._z + + pose._row1._z * se._v1._x + pose._vector._z; + vector1._x = pose._row2._x * se._v1._y + pose._row3._x * se._v1._z + + pose._row1._x * se._v1._x + pose._vector._x; + vector1._y = pose._row2._y * se._v1._y + pose._row3._y * se._v1._z + + pose._row1._y * se._v1._x + pose._vector._y; + vector3._z = pose._row2._z * se._v2._y + pose._row2._x * se._v2._z + + pose._row1._z * se._v2._x + pose._vector._y; + vector3._x = pose._row3._z * se._v2._y + pose._row3._x * se._v2._z + + pose._row1._x * se._v2._x + pose._vector._y; + vector3._y = pose._row2._y * se._v2._y + pose._row3._y * se._v2._z + + pose._row1._y * se._v2._x + pose._vector._y; if (vector1._z > threshold && vector3._z > threshold) { - vector2.clear(); - vector4.clear(); - sub12->proc28(2, vector1, vector2); - sub12->proc28(2, vector3, vector4); + vector2 = sub12->proc28(2, vector1); + vector4 = sub12->proc28(2, vector3); r.bottom = vector4._y + vHeight2; r.right = vector4._x + vWidth2; diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp index c1aae24de1..dfea8aa980 100644 --- a/engines/titanic/star_control/star_ref.cpp +++ b/engines/titanic/star_control/star_ref.cpp @@ -29,7 +29,7 @@ void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) { return; const double MAX_VAL = 1.0e9 * 1.0e9; - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); double threshold = sub12->proc25(); double vWidth2 = (double)surface->_width * 0.5; double vHeight2 = (double)surface->_height * 0.5; @@ -39,14 +39,13 @@ void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) { for (int idx = 0; idx < _star->size(); ++idx) { const CBaseStarEntry &se = _star->_data[idx]; vTemp = se._position; - vector1._x = vTemp._x * sub6._row1._x + vTemp._y * sub6._row2._x + vTemp._z * sub6._row3._x + sub6._vector._x; - vector1._y = vTemp._x * sub6._row1._y + vTemp._y * sub6._row2._y + vTemp._z * sub6._row3._y + sub6._vector._y; - vector1._z = vTemp._x * sub6._row1._z + vTemp._y * sub6._row2._z + vTemp._z * sub6._row3._z + sub6._vector._z; + vector1._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x + pose._vector._x; + vector1._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y + pose._vector._y; + vector1._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z; double hyp = vector1._x * vector1._x + vector1._y * vector1._y + vector1._z * vector1._z; if (vector1._z > threshold && hyp >= 1.0e12 && hyp < MAX_VAL) { - vector2.clear(); - sub12->proc28(2, vector1, vector2); + vector2 = sub12->proc28(2, vector1); const Common::Point pt((int)(vector2._x + vWidth2 - -0.5), (int)(vector2._y + vHeight2 - -0.5)); diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h index c6fec90fbc..3cd016e804 100644 --- a/engines/titanic/star_control/star_ref.h +++ b/engines/titanic/star_control/star_ref.h @@ -50,7 +50,7 @@ public: int _index; public: CStarRef1(CBaseStar *star, const Common::Point &pt) : - CBaseStarRef(star), _index(-1) {} + CBaseStarRef(star), _position(pt), _index(-1) {} virtual ~CStarRef1() {} virtual bool check(const Common::Point &pt, int index); diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp index 2f98ecc5e6..6cd539144c 100644 --- a/engines/titanic/star_control/star_view.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -126,16 +126,16 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) { FPoint centerPt(300.0, 170.0); if (fpt != centerPt) { - double threshold = MIN(centerPt._x, centerPt._y) * 0.5; + float threshold = MIN(centerPt._x, centerPt._y) * 0.5; FPoint tempPt = fpt - centerPt; - double distance = tempPt.normalize(); + float distance = tempPt.normalize(); if (distance >= threshold) { distance -= threshold; - FPoint relPt(tempPt._x * -2.0 * distance / threshold, + FPoint angle(tempPt._x * -2.0 * distance / threshold, tempPt._y * -2.0 * distance / threshold); - _sub12.setViewportPosition(relPt); + _sub12.setViewportPosition(angle); return true; } } @@ -145,7 +145,7 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) { } bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { - CStarControlSub6 sub6; + FPose pose; int v = _starField ? _starField->get88() : -1; switch (key) { @@ -177,8 +177,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_z: case Common::KEYCODE_c: if (v == -1) { - sub6.setRotationMatrix(key == Common::KEYCODE_z ? Y_AXIS : X_AXIS, 1.0); - _sub12.proc22(sub6); + pose.setRotationMatrix(key == Common::KEYCODE_z ? Y_AXIS : X_AXIS, 1.0); + _sub12.proc22(pose); _sub12.proc15(errorCode); return true; } @@ -210,8 +210,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_x: if (v == -1) { - sub6.setRotationMatrix(Y_AXIS, -1.0); - _sub12.proc22(sub6); + pose.setRotationMatrix(Y_AXIS, -1.0); + _sub12.proc22(pose); _sub12.proc15(errorCode); return true; } @@ -219,8 +219,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_QUOTE: if (v == -1) { - sub6.setRotationMatrix(X_AXIS, -1.0); - _sub12.proc22(sub6); + pose.setRotationMatrix(X_AXIS, -1.0); + _sub12.proc22(pose); _sub12.proc15(errorCode); return true; } @@ -450,8 +450,8 @@ void CStarView::randomizeVectors1(FVector &v1, FVector &v2) { v2.normalize(); */ // Values temporarily hardcoded to match hacked values in original EXE - v1 = FVector(69481544.0, 69481544.0, 69481544.0); - v2 = FVector(-0.577350259, -0.577350259, -0.577350259); + v1 = FVector((float)69481544.0, (float)69481544.0, (float)69481544.0); + v2 = FVector((float)-0.577350259, (float)-0.577350259, (float)-0.577350259); } void CStarView::randomizeVectors2(FVector &v1, FVector &v2) { @@ -466,8 +466,8 @@ void CStarView::randomizeVectors2(FVector &v1, FVector &v2) { v2.normalize(); */ // Values temporarily hardcoded to match hacked values in original EXE - v1 = FVector(69481544.0, 69481544.0, 69481544.0); - v2 = FVector(0.624659300, -0.468542814, -0.624714553); + v1 = FVector((float)69481544.0, (float)69481544.0, (float)69481544.0); + v2 = FVector((float)0.624659300, (float)-0.468542814, (float)-0.624714553); } void CStarView::resizeSurface(CScreenManager *scrManager, int width, int height, diff --git a/engines/titanic/support/direct_draw.cpp b/engines/titanic/support/direct_draw.cpp index faed140ea7..9fbfe0c5ee 100644 --- a/engines/titanic/support/direct_draw.cpp +++ b/engines/titanic/support/direct_draw.cpp @@ -33,7 +33,7 @@ DirectDraw::DirectDraw() : _windowed(false), _width(0), _height(0), } void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) { - debugC(ERROR_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp", + debugC(DEBUG_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp", width, height, bpp); assert(bpp == 16); @@ -42,7 +42,7 @@ void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) } void DirectDraw::diagnostics() { - debugC(ERROR_BASIC, kDebugGraphics, "Running DirectDraw Diagnostic..."); + debugC(DEBUG_BASIC, kDebugGraphics, "Running DirectDraw Diagnostic..."); } DirectDrawSurface *DirectDraw::createSurfaceFromDesc(const DDSurfaceDesc &desc) { @@ -61,7 +61,7 @@ DirectDrawManager::DirectDrawManager(TitanicEngine *vm, bool windowed) { } void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSurfaces) { - debugC(ERROR_BASIC, kDebugGraphics, "Initialising video surfaces"); + debugC(DEBUG_BASIC, kDebugGraphics, "Initialising video surfaces"); _directDraw._width = width; _directDraw._numBackSurfaces = numBackSurfaces; _directDraw._height = height; @@ -75,7 +75,7 @@ void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSur } void DirectDrawManager::initFullScreen() { - debugC(ERROR_BASIC, kDebugGraphics, "Creating surfaces"); + debugC(DEBUG_BASIC, kDebugGraphics, "Creating surfaces"); _directDraw.setDisplayMode(_directDraw._width, _directDraw._height, _directDraw._bpp, 0); diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index b886dc094c..4f848342eb 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -527,6 +527,7 @@ void OSVideoSurface::clear() { if (!loadIfReady()) error("Could not load resource"); + _ddSurface->fill(nullptr, 0); } void OSVideoSurface::playMovie(uint flags, CGameObject *obj) { diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h index 6bc999cd40..90537e7100 100644 --- a/engines/titanic/titanic.h +++ b/engines/titanic/titanic.h @@ -63,9 +63,9 @@ enum TitanicDebugChannels { #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 -#define ERROR_BASIC 1 -#define ERROR_INTERMEDIATE 2 -#define ERROR_DETAILED 3 +#define DEBUG_BASIC 1 +#define DEBUG_INTERMEDIATE 2 +#define DEBUG_DETAILED 3 #define TOTAL_ITEMS 46 #define TOTAL_ROOMS 34 |