diff options
author | Borja Lorente | 2016-06-28 20:56:55 +0200 |
---|---|---|
committer | Borja Lorente | 2016-08-14 18:41:15 +0200 |
commit | 0485483254e9ce94acfd4750122a466984227904 (patch) | |
tree | 4a48b4adb66ba658a6da038cffa904598d37b108 /engines/macventure | |
parent | 08588eb6f914fc77aa443f3844681787bde02949 (diff) | |
download | scummvm-rg350-0485483254e9ce94acfd4750122a466984227904.tar.gz scummvm-rg350-0485483254e9ce94acfd4750122a466984227904.tar.bz2 scummvm-rg350-0485483254e9ce94acfd4750122a466984227904.zip |
MACVENTURE: Minor fixes and skull rising
Diffstat (limited to 'engines/macventure')
-rw-r--r-- | engines/macventure/container.h | 13 | ||||
-rw-r--r-- | engines/macventure/gui.cpp | 37 | ||||
-rw-r--r-- | engines/macventure/gui.h | 1 | ||||
-rw-r--r-- | engines/macventure/image.cpp | 4 | ||||
-rw-r--r-- | engines/macventure/macventure.cpp | 14 | ||||
-rw-r--r-- | engines/macventure/macventure.h | 2 | ||||
-rw-r--r-- | engines/macventure/script.cpp | 27 | ||||
-rw-r--r-- | engines/macventure/script.h | 2 | ||||
-rw-r--r-- | engines/macventure/stringtable.h | 9 | ||||
-rw-r--r-- | engines/macventure/world.cpp | 3 |
10 files changed, 72 insertions, 40 deletions
diff --git a/engines/macventure/container.h b/engines/macventure/container.h index 440c0cb977..f0094a786b 100644 --- a/engines/macventure/container.h +++ b/engines/macventure/container.h @@ -173,12 +173,9 @@ public: /** * getItemByteSize should be called before this one */ - Common::SeekableReadStream *getItem(uint32 id) { - _res->seek(0); - Common::SeekableReadStream *res = _res->readStream(_res->size()); + Common::SeekableReadStream *getItem(uint32 id) { if (_simplified) { - res->seek((id * _lenObjs) + sizeof(_header), SEEK_SET); - return res; + _res->seek((id * _lenObjs) + sizeof(_header), SEEK_SET); } else { uint32 groupID = (id >> 6); uint32 objectIndex = id & 0x3f; // Index within the group @@ -188,10 +185,12 @@ public: offset += _groups[groupID].lengths[i]; } - res->seek(_groups[groupID].offset + offset + sizeof(_header), SEEK_SET); + _res->seek(_groups[groupID].offset + offset + sizeof(_header), SEEK_SET); - return res; } + + Common::SeekableReadStream *res = _res->readStream(getItemByteSize(id) * 2); + return res; } protected: diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index 0b13923cb0..c8f6b3bf62 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -34,8 +34,8 @@ namespace MacVenture { enum MenuAction; enum { - kCursorWidth = 10, // HACK Arbitrary width to test - kCursorHeight = 10 + kCursorWidth = 2, // HACK Arbitrary width to test + kCursorHeight = 2 }; enum { @@ -126,7 +126,7 @@ void Gui::draw() { _wm.draw(); drawDraggedObject(); - + //drawWindowTitle(kMainGameWindow, _mainGameWindow->getSurface()); } @@ -202,8 +202,8 @@ void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array ObjID child = children[i]; if (ref != kMainGameWindow) { Common::Point childPos = _engine->getObjPosition(child); - originx = originx > childPos.x ? childPos.x : originx; - originy = originy > childPos.y ? childPos.y : originy; + originx = originx > (uint)childPos.x ? (uint)childPos.x : originx; + originy = originy > (uint)childPos.y ? (uint)childPos.y : originy; } data.children.push_back(DrawableObject(child, kBlitBIC)); } @@ -362,7 +362,7 @@ void Gui::loadBorder(Graphics::MacWindow * target, Common::String filename, bool } void Gui::loadGraphics() { - _graphics = new Container("Shadowgate II/Shadow Graphic"); + _graphics = new Container(_engine->getFilePath(kGraphicPathID).c_str()); } bool Gui::loadMenus() { @@ -616,11 +616,11 @@ void Gui::drawExitsWindow() { WindowData &objData = findWindowData(kMainGameWindow); Common::Point pos; ObjID child; - BlitMode mode; + //BlitMode mode; Common::Rect exit; for (uint i = 0; i < objData.children.size(); i++) { child = objData.children[i].obj; - mode = (BlitMode)objData.children[i].mode; + //mode = (BlitMode)objData.children[i].mode; pos = _engine->getObjExitPosition(child); pos.x += border.leftOffset; pos.y += border.topOffset; @@ -788,6 +788,13 @@ void Gui::selectDraggable(ObjID child, Common::Point pos) { void Gui::handleDragRelease(Common::Point pos) { _draggedObj.id = 0; _engine->updateDelta(pos); + _engine->preparedToRun(); +} + +Common::Rect Gui::calculateClickRect(Common::Point clickPos, Common::Rect windowBounds) { + int left = clickPos.x - windowBounds.left; + int top = clickPos.y - windowBounds.top; + return Common::Rect(left - kCursorWidth, top - kCursorHeight, left + kCursorWidth, top + kCursorHeight); } @@ -967,6 +974,12 @@ bool Gui::processEvent(Common::Event &event) { _draggedObj.pos = event.mouse; } processed = true; + + // TEST + Common::Rect mr = calculateClickRect(event.mouse, _screen.getBounds()); + _screen.fillRect(mr, kColorGreen); + g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h); + g_system->updateScreen(); } else if (event.type == Common::EVENT_LBUTTONUP) { if (_draggedObj.id != 0) { @@ -1023,9 +1036,7 @@ bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & e ObjID child; Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ - int left = event.mouse.x - _mainGameWindow->getDimensions().left; - int top = event.mouse.y - _mainGameWindow->getDimensions().top; - Common::Rect clickRect(left, top, left + kCursorWidth, top + kCursorHeight); + Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions()); for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) { child = (*it).obj; if (isRectInsideObject(clickRect, child)) { @@ -1085,9 +1096,7 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { ObjID child; Common::Point pos; // Click rect to local coordinates. We assume the click is inside the window ^ - int left = event.mouse.x - _inventoryWindows[i]->getDimensions().left; - int top = event.mouse.y - _inventoryWindows[i]->getDimensions().top; - Common::Rect clickRect(left, top, left + kCursorWidth, top + kCursorHeight); + Common::Rect clickRect = calculateClickRect(event.mouse, _inventoryWindows[i]->getDimensions()); for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) { child = (*it).obj; if (isRectInsideObject(clickRect, child)) { diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h index 9d48d6320b..73c4318408 100644 --- a/engines/macventure/gui.h +++ b/engines/macventure/gui.h @@ -258,6 +258,7 @@ private: // Methods bool isRectInsideObject(Common::Rect target, ObjID obj); void selectDraggable(ObjID child, Common::Point pos); void handleDragRelease(Common::Point pos); + Common::Rect calculateClickRect(Common::Point clickPos, Common::Rect windowBounds); }; diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp index e70a82154f..d880e142bb 100644 --- a/engines/macventure/image.cpp +++ b/engines/macventure/image.cpp @@ -192,9 +192,9 @@ void ImageAsset::decodeHuffGraphic(const PPICHuff & huff, Common::BitStream & st blank = 2 - (blank >> 1); } - uint pos = 0; + uint16 pos = 0; for (uint y = 0; y < _bitHeight; y++) { - uint x = 0; + uint16 x = 0; for (; x < _bitWidth >> 3; x++) { byte hi = walkHuff(huff, stream) << 4; data[pos++] = walkHuff(huff, stream) | hi; diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index a87da312dd..8624159a95 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -537,15 +537,17 @@ uint MacVentureEngine::getPrefixNdx(ObjID obj) { } Common::String MacVentureEngine::getPrefixString(uint flag, ObjID obj) { - uint ndx = _world->getObjAttr(obj, kAttrPrefixes); // HACK should check the type of that one + uint ndx = getPrefixNdx(obj); ndx = ((ndx) >> flag) & 3; if (ndx) { - return (*_decodingNamingArticles->getStrings())[ndx]; + return _decodingNamingArticles->getString(ndx); + } else { + return Common::String("missigno "); } } Common::String MacVentureEngine::getNoun(ObjID ndx) { - return (*_decodingIndirectArticles->getStrings())[ndx]; + return _decodingIndirectArticles->getString(ndx); } void MacVentureEngine::highlightExit(ObjID objID) { @@ -740,11 +742,11 @@ Common::String MacVentureEngine::getCommandsPausedString() const { } Common::String MacVentureEngine::getFilePath(FilePathID id) const { - const Common::Array<Common::String> *names = _filenames->getStrings(); + const Common::Array<Common::String> &names = _filenames->getStrings(); if (id <= 3) { // We don't want a file in the subdirectory - return Common::String((*names)[id]); + return Common::String(names[id]); } else { // We want a game file - return Common::String((*names)[3] + "/" + (*names)[id]); + return Common::String(names[3] + "/" + names[id]); } } diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h index c63864de20..28c3bf9ad3 100644 --- a/engines/macventure/macventure.h +++ b/engines/macventure/macventure.h @@ -175,7 +175,7 @@ public: void enqueueObject(ObjectQueueID type, ObjID objID, ObjID target = 0); void enqueueText(TextQueueID type, ObjID target, ObjID source, ObjID text); - + void runObjQueue(); bool printTexts(); diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp index cca144e2d8..cc9474e6d4 100644 --- a/engines/macventure/script.cpp +++ b/engines/macventure/script.cpp @@ -84,6 +84,7 @@ bool ScriptEngine::execFrame(bool execAll) { else { fail = resumeFunc(frame); } if (fail) { frame->haltedInFirst = true; + _engine->preparedToRun(); return true; } doFamily = true; @@ -101,6 +102,7 @@ bool ScriptEngine::execFrame(bool execAll) { if (fail) { // We are stuck, so we don't shift the frame frame->haltedInFamily = true; frame->familyIdx = i; + _engine->preparedToRun(); return true; } doFamily = true; @@ -112,6 +114,7 @@ bool ScriptEngine::execFrame(bool execAll) { frame->haltedInSaves = false; if (resumeFunc(frame)) { frame->haltedInSaves = true; + _engine->preparedToRun(); return true; } } @@ -131,6 +134,7 @@ bool ScriptEngine::execFrame(bool execAll) { frame->saves[localHigh].rank = 0; if (loadScript(frame, frame->saves[localHigh].func)) { frame->haltedInSaves = true; + _engine->preparedToRun(); return true; } } @@ -352,7 +356,8 @@ bool ScriptEngine::runFunc(EngineFrame *frame) { opbbFORK(state, frame); break; case 0xbc: //call - opbcCALL(state, frame, script); + if (opbcCALL(state, frame, script)) + return true; break; case 0xbd: //focus object opbdFOOB(state, frame); @@ -907,11 +912,12 @@ void ScriptEngine::opbbFORK(EngineState * state, EngineFrame * frame) { _frames.push_back(newframe); } -void ScriptEngine::opbcCALL(EngineState * state, EngineFrame * frame, ScriptAsset &script) { +bool ScriptEngine::opbcCALL(EngineState * state, EngineFrame * frame, ScriptAsset &script) { word id = state->pop(); ScriptAsset newfun = ScriptAsset(id, _scripts); ScriptAsset current = script; - loadScript(frame, id); + if (loadScript(frame, id)) + return true; frame->scripts.pop_front(); script = frame->scripts.front(); debug(3, "SCRIPT: Return from fuction %d", id); @@ -987,12 +993,23 @@ void ScriptEngine::opc9WAIT(EngineState * state, EngineFrame * frame) { } void ScriptEngine::opcaTIME(EngineState * state, EngineFrame * frame) { - for (uint i = 0; i < 6; i++) // Dummy + for (uint i = 0; i < 3; i++) // We skip year, month and date state->push(0x00); - op00NOOP(0xca); + + uint32 totalPlayTime = _engine->getTotalPlayTime() / 1000; // In seconds + word hours = totalPlayTime / 3600; + totalPlayTime %= 3600; + state->push(hours); + word minutes = totalPlayTime / 60; + totalPlayTime %= 60; + state->push(minutes); + state->push(totalPlayTime); + debug("Saved time: h[%d] m[%d] s[%d]", hours, minutes, totalPlayTime); + } void ScriptEngine::opcbDAY(EngineState * state, EngineFrame * frame) { + // Probaby irrelevant, so we push Day [9] state->push(9); } diff --git a/engines/macventure/script.h b/engines/macventure/script.h index 1a143cffd0..acbffcd315 100644 --- a/engines/macventure/script.h +++ b/engines/macventure/script.h @@ -240,7 +240,7 @@ private: void opb9CHI(EngineState *state, EngineFrame *frame); //cancel high priority void opbaCRAN(EngineState *state, EngineFrame *frame); //cancel priority range void opbbFORK(EngineState *state, EngineFrame *frame); //fork - void opbcCALL(EngineState *state, EngineFrame *frame, ScriptAsset &script); //call + bool opbcCALL(EngineState *state, EngineFrame *frame, ScriptAsset &script); //call void opbdFOOB(EngineState *state, EngineFrame *frame); //focus object void opbeSWOB(EngineState *state, EngineFrame *frame); //swap objects void opbfSNOB(EngineState *state, EngineFrame *frame); //snap object diff --git a/engines/macventure/stringtable.h b/engines/macventure/stringtable.h index 87ec9775cb..ffb9d375ab 100644 --- a/engines/macventure/stringtable.h +++ b/engines/macventure/stringtable.h @@ -52,8 +52,13 @@ public: } - const Common::Array<Common::String> *getStrings() { - return &_strings; + const Common::Array<Common::String> &getStrings() { + return _strings; + } + + Common::String getString(uint ndx) { + assert(ndx < _strings.size()); + return _strings[ndx]; } private: diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index 02d388ab5f..8e83f91057 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -23,8 +23,7 @@ World::World(MacVentureEngine *engine, Common::MacResManager *resMan) { _objectConstants = new Container(_engine->getFilePath(kObjectPathID).c_str()); calculateObjectRelations(); - warning("Test functions about to happen"); - _gameText = new Container("Shadowgate II/Shadow Text"); + _gameText = new Container(_engine->getFilePath(kTextPathID).c_str()); delete saveGameRes; saveGameFile.close(); |