aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-06-21 03:02:14 +0200
committerBorja Lorente2016-08-14 18:31:16 +0200
commitccc76f2119dcd3b802604294fc1f7bccad645374 (patch)
treed8c5373dd9a12cf40371a6e34913105ea91e6d1c /engines/macventure
parentbbf0c62f14326818d135a75bc6f9e58ad59346a1 (diff)
downloadscummvm-rg350-ccc76f2119dcd3b802604294fc1f7bccad645374.tar.gz
scummvm-rg350-ccc76f2119dcd3b802604294fc1f7bccad645374.tar.bz2
scummvm-rg350-ccc76f2119dcd3b802604294fc1f7bccad645374.zip
MACVENTURE: Add PPIC0, 1 and 2 decoding
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/container.h14
-rw-r--r--engines/macventure/gui.cpp77
-rw-r--r--engines/macventure/gui.h6
-rw-r--r--engines/macventure/image.cpp256
-rw-r--r--engines/macventure/image.h51
-rw-r--r--engines/macventure/macventure.cpp84
-rw-r--r--engines/macventure/macventure.h7
-rw-r--r--engines/macventure/module.mk1
-rw-r--r--engines/macventure/script.cpp10
-rw-r--r--engines/macventure/world.cpp10
-rw-r--r--engines/macventure/world.h2
11 files changed, 477 insertions, 41 deletions
diff --git a/engines/macventure/container.h b/engines/macventure/container.h
index bd88f663b8..4dc5172fd7 100644
--- a/engines/macventure/container.h
+++ b/engines/macventure/container.h
@@ -117,7 +117,7 @@ public:
uint32 bitSize = _lens[x];
bits += bitSize & 0xF;
if (bits & 0x10) {
- bits &= 0xf;
+ bits &= 0xF;
_res->seek(2, SEEK_CUR);
}
bitSize >>= 4;
@@ -129,7 +129,11 @@ public:
else length >>= (32 - bitSize) - bits;
length &= (1 << bitSize) - 1;
length |= 1 << bitSize;
- bits += bitSize;
+ bits += bitSize;
+ if (bits & 0x10) {
+ bits &= 0xF;
+ _res->seek(2, SEEK_CUR);
+ }
}
group.lengths[j] = length;
@@ -173,16 +177,14 @@ public:
return _res;
} else {
uint32 groupID = (id >> 6);
- uint32 objectIndex = id & 0x3f; // Index within the group
-
- _res->seek(4 + (groupID * 6), SEEK_SET);
+ uint32 objectIndex = id & 0x3f; // Index within the group
uint32 offset = 0;
for (uint i = 0; i < objectIndex; i++) {
offset += _groups[groupID].lengths[i];
}
- _res->seek(offset, SEEK_CUR);
+ _res->seek(_groups[groupID].offset + offset + sizeof(_header), SEEK_SET);
return _res;
}
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index c5c6df30cb..725ce38268 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -99,7 +99,11 @@ void Gui::drawMenu() {
}
bool Gui::processEvent(Common::Event &event) {
- return _wm.processEvent(event);
+ bool processed = false;
+ if (event.type == Common::EVENT_LBUTTONDOWN) {
+ debug("Click on the ui");
+ }
+ return (processed || _wm.processEvent(event));
}
const WindowData& Gui::getWindowData(WindowReference reference) {
@@ -141,6 +145,27 @@ void Gui::setWindowTitle(WindowReference winID, Common::String string) {
findWindowData(winID).titleLength = string.size();
}
+void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children) {
+ WindowData &data = findWindowData(ref);
+ data.children.clear();
+ uint32 originx = 0x7fff;
+ uint32 originy = 0x7fff;
+ for (uint i = 0; i < children.size(); i++) {
+ if (children[i] != 1) {
+ 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;
+ }
+ data.children.push_back(child);
+ }
+ }
+ if (originx != 0x7fff) data.bounds.left = originx;
+ if (originy != 0x7fff) data.bounds.top = originy;
+ if (ref != kMainGameWindow) data.updateScroll = true;
+}
+
void Gui::initGUI() {
_screen.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
_wm.setScreen(&_screen);
@@ -160,6 +185,7 @@ void Gui::initGUI() {
if (!loadControls())
error("Could not load controls");
+
draw();
}
@@ -323,7 +349,7 @@ bool Gui::loadWindows() {
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = _resourceManager->getResource(MKTAG('W', 'I', 'N', 'D'), *iter);
WindowData data;
- uint16 top, left, bottom, right;
+ uint16 top, left, bottom, right;
top = res->readUint16BE();
left = res->readUint16BE();
bottom = res->readUint16BE();
@@ -346,7 +372,7 @@ bool Gui::loadWindows() {
data.title = Common::String(newTitle);
}
- debug(5, "Window loaded: %s", data.title);
+ debug(4, "Window loaded: %s", data.title);
_windowData->push_back(data);
}
@@ -451,10 +477,30 @@ void Gui::drawMainGameWindow() {
srf->w,
kColorBlack,
Graphics::kTextAlignCenter);
+
+ WindowData &data = findWindowData(kMainGameWindow);
+ for (Common::Array<ObjID>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
+ Common::Point pos = _engine->getObjPosition(*it);
+ srf->fillRect(
+ Common::Rect(
+ border.leftOffset * 2 + pos.x,
+ border.topOffset * 2 + pos.y,
+ 5,
+ 5),
+ kColorBlack);
+ }
}
void Gui::drawSelfWindow() {
- warning("drawSelfWindow: Unimplemented");
+ Graphics::ManagedSurface *srf = _selfWindow->getSurface();
+ BorderBounds border = borderBounds(getWindowData(kSelfWindow).type);
+ srf->fillRect(
+ Common::Rect(
+ border.leftOffset * 2,
+ border.topOffset * 2,
+ srf->w - (border.rightOffset * 3),
+ srf->h - (border.bottomOffset * 3)),
+ kColorWhite);
}
WindowData & Gui::findWindowData(WindowReference reference) {
@@ -477,7 +523,6 @@ WindowData & Gui::findWindowData(WindowReference reference) {
bool commandsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
-
return g->processCommandEvents(click, event);
}
@@ -577,7 +622,7 @@ void Gui::updateWindow(WindowReference winID, bool containerOpen) {
if (winID > 0x90) return;
if (winID == kSelfWindow || containerOpen) {
if (winID == kMainGameWindow) {
- warning("Unimplemented: draw main game window");
+ drawMainGameWindow();
} else {
warning("Unimplemented: fill window with background");
}
@@ -618,9 +663,22 @@ WindowReference Gui::createInventoryWindow() {
loadBorder(newWindow, "border_self_inac.bmp", false);
loadBorder(newWindow, "border_self_act.bmp", true);
_inventoryWindows.push_back(newWindow);
+
+ debug(3, "Create new inventory window. Reference: %d", newData.refcon);
return newData.refcon;
}
+bool Gui::tryCloseWindow(WindowReference winID) {
+ WindowData data = findWindowData(winID);
+ Graphics::MacWindow *wind;
+ if (winID < 0x80) { // Inventory window
+ warning("Window closing not implemented");
+ } else {
+ warning("Window closing not implemented");
+ }
+ return true;
+}
+
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
@@ -635,7 +693,7 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
Common::List<CommandButton>::const_iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
if (it->isInsideBounds(position)) {
- debug("Command active: %s", it->getData().title);
+ debug(4, "Command active: %s", it->getData().title);
data = *it;
}
}
@@ -649,26 +707,21 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
}
bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & event) {
- debug(6, "Processing event in Main Game Window");
return getWindowData(kMainGameWindow).visible;
}
bool MacVenture::Gui::processOutConsoleEvents(WindowClick click, Common::Event & event) {
- debug(6, "Processing event in Out Console Window");
return getWindowData(kOutConsoleWindow).visible;
}
bool MacVenture::Gui::processSelfEvents(WindowClick click, Common::Event & event) {
- debug(6, "Processing event in Self Window");
return getWindowData(kSelfWindow).visible;
}
bool MacVenture::Gui::processExitsEvents(WindowClick click, Common::Event & event) {
- debug(6, "Processing event in Exits Window");
return getWindowData(kExitsWindow).visible;
}
bool MacVenture::Gui::processDiplomaEvents(WindowClick click, Common::Event & event) {
- debug(6, "Processing event in Diploma Window");
return getWindowData(kDiplomaWindow).visible;
}
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index dc08a77cec..8c964aea93 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -27,6 +27,10 @@
#include "graphics/macgui/macwindow.h"
#include "graphics/macgui/macmenu.h"
+#include "graphics/font.h"
+
+#include "macventure/image.h"
+
namespace MacVenture {
using namespace Graphics::MacGUIConstants;
@@ -138,6 +142,7 @@ public:
void updateWindow(WindowReference winID, bool containerOpen);
WindowReference createInventoryWindow();
+ bool tryCloseWindow(WindowReference winID);
// Event processors
bool processCommandEvents(WindowClick click, Common::Event &event);
@@ -155,6 +160,7 @@ public:
// Modifiers
void bringToFront(WindowReference window);
void setWindowTitle(WindowReference winID, Common::String string);
+ void updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children);
// Ugly switches
BorderBounds borderBounds(MVWindowType type);
diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp
new file mode 100644
index 0000000000..33f8ce8848
--- /dev/null
+++ b/engines/macventure/image.cpp
@@ -0,0 +1,256 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#include "macventure/image.h"
+
+namespace MacVenture {
+
+PPICHuff PPIC1Huff = {
+ // Masks
+ { 0x0000,0x2000,0x4000,0x5000,0x6000,0x7000,0x8000,0x9000,0xa000,
+ 0xb000,0xc000,0xd000,0xd800,0xe000,0xe800,0xf000,0xf800 },
+ // Lens
+ { 3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5 },
+ // Symbols
+ { 0x00,0x0f,0x03,0x05,0x06,0x07,0x08,0x09,0x0a,0x0c,0xff,0x01,
+ 0x02,0x04,0x0b,0x0d,0xe }
+};
+
+PPICHuff PPIC2Huff = {
+ // Masks
+ { 0x0000,0x4000,0x8000,0xc000,0xc800,0xd000,0xd800,0xe000,0xe800,
+ 0xf000,0xf400,0xf600,0xf800,0xfa00,0xfc00,0xfe00,0xff00 },
+ // Lens
+ { 2,2,2,5,5,5,5,5,5,6,7,7,7,7,7,8,8 },
+ // Symbols
+ { 0xff,0x00,0x0f,0x01,0x03,0x07,0x0e,0x0c,0x08,0x06,0x02,0x04,
+ 0x09,0x0d,0x0b,0x0a,0x05 }
+};
+
+ImageAsset::ImageAsset(ObjID id, Container * container) {
+ _id = id;
+ _container = container;
+
+ decodePPIC();
+}
+
+ImageAsset::~ImageAsset() {
+ delete _surface;
+ delete _mask;
+ delete[] _data;
+}
+
+void ImageAsset::blit(Graphics::ManagedSurface * target) {
+ debug("Blitting image %x ", _id);
+}
+
+void ImageAsset::decodePPIC() {
+ ObjID realID = _id;
+ uint32 size = _container->getItemByteSize(_id);
+ if (size == 2 || size == 0) {
+ realID = _container->getItem(_id)->readUint16BE();
+ }
+ Common::BitStream32BEMSB stream(_container->getItem(realID));
+
+ uint8 mode = stream.getBits(3);
+ int w, h;
+ if (stream.getBit()) h = stream.getBits(10);
+ else h = stream.getBits(6);
+
+ if (stream.getBit()) w = stream.getBits(10);
+ else w = stream.getBits(6);
+
+ _rowBytes = ((w + 0xF) >> 3) & 0xFFFE;
+ _bitWidth = w;
+ _bitHeight = h;
+
+ _surface = new Graphics::ManagedSurface(_rowBytes, h, Graphics::PixelFormat::createFormatCLUT8());
+ _mask = new Graphics::ManagedSurface(_rowBytes, h, Graphics::PixelFormat::createFormatCLUT8());
+ _data = new byte[_surface->w * _surface->h];
+
+ switch (mode)
+ {
+ case MacVenture::kPPIC0:
+ decodePPIC0(stream);
+ break;
+ case MacVenture::kPPIC1:
+ decodePPIC1(stream);
+ break;
+ case MacVenture::kPPIC2:
+ decodePPIC2(stream);
+ break;
+ case MacVenture::kPPIC3:
+ decodePPIC3(stream);
+ break;
+ }
+}
+
+void ImageAsset::decodePPIC0(Common::BitStream & stream) {
+ for (uint y = 0; y < _surface->h; y++)
+ for (uint x = 0; x < _surface->w; x++)
+ *(byte*)_surface->getBasePtr(x, y) = (byte)stream.getBits(8);
+}
+
+void ImageAsset::decodePPIC1(Common::BitStream & stream) {
+ decodeHuffGraphic(PPIC1Huff, stream);
+}
+
+void ImageAsset::decodePPIC2(Common::BitStream & stream) {
+ decodeHuffGraphic(PPIC2Huff, stream);
+}
+
+void ImageAsset::decodePPIC3(Common::BitStream & stream) {
+
+}
+
+void ImageAsset::decodeHuffGraphic(const PPICHuff & huff, Common::BitStream & stream) {
+ byte flags = 0;
+ _walkRepeat = 0;
+ _walkLast = 0;
+ if (_bitWidth & 3)
+ flags = stream.getBits(5);
+ else
+ flags = stream.getBits(4) << 1;
+
+ byte odd = 0;
+ byte blank = _bitWidth & 0xf;
+ if (blank) {
+ blank >>= 2;
+ odd = blank & 1;
+ blank = 2 - (blank >> 1);
+ }
+
+ uint pos = 0;
+ for (uint y = 0; y < _bitHeight; y++) {
+ uint x = 0;
+ for (; x < _bitWidth >> 3; x++) {
+ byte hi = walkHuff(huff, stream) << 4;
+ _data[pos++] = walkHuff(huff, stream) | hi;
+ }
+ if (odd) {
+ _data[pos] = walkHuff(huff, stream) << 4;
+ }
+ pos += blank;
+ }
+ uint16 edge = _bitWidth & 3;
+ uint16 bits = 0;
+ uint16 val = 0;
+ uint16 v;
+ if (edge) {
+ pos = _rowBytes - blank;
+ for (uint y = 0; y < _bitHeight; y++) {
+ if (flags & 1) {
+ if (bits < edge) {
+ v = walkHuff(huff, stream) << 4;
+ val |= v >> bits;
+ bits += 4;
+ }
+ bits -= edge;
+ v = val;
+ val <<= edge;
+ val &= 0xFF;
+ } else {
+ v = stream.getBits(edge);
+ v <<= 8 - edge;
+ }
+ if (odd)
+ v >>= 4;
+
+ _data[pos] |= v & 0xff;
+ pos += _rowBytes;
+ }
+ }
+ if (flags & 8) {
+ pos = 0;
+ for (uint y = 0; y < _bitHeight; y++) {
+ if (flags & 2) {
+ for (uint x = 0; x < _rowBytes; x++)
+ {
+ _data[pos] ^= v;
+ v = _data[pos];
+ pos++;
+ }
+ }
+ else {
+ for (uint x = 0; x < _rowBytes; x++) {
+ val = _data[pos] ^ v;
+ val ^= (val >> 4) & 0xf;
+ _data[pos] = val;
+ pos++;
+ v = (val << 4) & 0xff;
+ }
+ }
+ }
+ }
+ if (flags & 4) {
+ uint16 delta = _rowBytes * 4;
+ if (flags & 2) delta *= 2;
+ pos = 0;
+ uint q = delta;
+ for (uint i = 0;i < _surface->h * _rowBytes - delta;i++) {
+ _data[q] ^= _data[pos];
+ q++;
+ pos++;
+ }
+ }
+}
+
+byte ImageAsset::walkHuff(const PPICHuff & huff, Common::BitStream & stream) {
+ if (_walkRepeat) {
+ _walkRepeat--;
+ _walkLast = ((_walkLast << 8) & 0xFF00) | (_walkLast >> 8);
+ return _walkLast & 0xFF;
+ }
+ uint16 dw = stream.peekBits(16);
+ uint16 i = 0;
+ for (;i < 16; i++) {
+ if (huff.masks[i + 1] > dw)
+ break;
+ }
+ stream.skip(huff.lens[i]);
+ uint8 val = huff.symbols[i];
+ if (val == 0xFF) {
+ if (!stream.getBit()) {
+ _walkLast &= 0xFF;
+ _walkLast |= _walkLast << 8;
+ }
+ _walkRepeat = stream.getBits(3);
+ if (_walkRepeat < 3) {
+ _walkRepeat <<= 4;
+ _walkRepeat |= stream.getBits(4);
+ if (_walkRepeat < 8) {
+ _walkRepeat <<= 8;
+ _walkRepeat |= stream.getBits(8);
+ }
+ }
+ _walkRepeat -= 2;
+ _walkLast = ((_walkLast << 8) & 0xFF00) | (_walkLast >> 8);
+ return _walkLast & 0xFF;
+ } else {
+ _walkLast <<= 8;
+ _walkLast |= val;
+ _walkLast &= 0xFFFF;
+ }
+ return val;
+}
+
+} // End of namespace MacVenture
diff --git a/engines/macventure/image.h b/engines/macventure/image.h
index 4cc40f1ed0..847b757788 100644
--- a/engines/macventure/image.h
+++ b/engines/macventure/image.h
@@ -24,26 +24,59 @@
#define MACVENTURE_IMAGE_H
#include "macventure/macventure.h"
+#include "macventure/container.h"
namespace MacVenture {
+typedef uint32 ObjID;
+class Container;
+
+enum GraphicsEncoding {
+ kPPIC0 = 0,
+ kPPIC1 = 1,
+ kPPIC2 = 2,
+ kPPIC3 = 3
+};
+
+struct PPICHuff {
+ uint16 masks[17];
+ uint16 lens[17];
+ uint8 symbols[17];
+};
+
class ImageAsset {
public:
- ImageAsset(ObjID id, Container *container) {
- _id = id;
- _container = container;
- }
- ~ImageAsset() {
+ ImageAsset(ObjID id, Container *container);
+ ~ImageAsset();
+
+ void blit(Graphics::ManagedSurface *target);
- }
+private:
+ void decodePPIC();
+
+ void decodePPIC0(Common::BitStream &stream);
+ void decodePPIC1(Common::BitStream &stream);
+ void decodePPIC2(Common::BitStream &stream);
+ void decodePPIC3(Common::BitStream &stream);
- void blit(Graphics::ManagedSurface *target) {
- debug("Blitting image %x ", _id);
- }
+ void decodeHuffGraphic(const PPICHuff &huff, Common::BitStream &stream);
+ byte walkHuff(const PPICHuff &huff, Common::BitStream &stream);
private:
ObjID _id;
Container *_container;
+
+ uint16 _walkRepeat;
+ uint16 _walkLast;
+
+ uint16 _rowBytes;
+ uint16 _bitWidth;
+ uint16 _bitHeight;
+
+ byte* _data;
+
+ Graphics::ManagedSurface *_surface;
+ Graphics::ManagedSurface *_mask;
};
} // End of namespace MacVenture
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 5c8f6b4051..f277d242cf 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -224,6 +224,29 @@ void MacVentureEngine::enqueueText(TextQueueID type, ObjID target, ObjID source,
void MacVentureEngine::printTexts() {
warning("printTexts: unimplemented");
+ for (uint i = 0; i < _textQueue.size(); i++) {
+ QueuedText text = _textQueue.front();
+ _textQueue.remove_at(0);
+ switch (text.id) {
+ case kTextNumber:
+ debug("Print Number: %d", text.asset);
+ break;
+ case kTextNewLine:
+ debug("Print Newline: ");
+ break;
+ case kTextPlain:
+ debug("Print Plain Text: %s", _world->getText(text.asset).c_str());
+ break;
+ }
+ }
+}
+
+void MacVentureEngine::focusObjWin(ObjID objID) {
+ _gui->bringToFront(getObjWindow(objID));
+}
+
+void MacVentureEngine::updateWindow(WindowReference winID) {
+ _gui->updateWindow(winID, true);
}
const GlobalSettings& MacVentureEngine::getGlobalSettings() const {
@@ -356,8 +379,8 @@ void MacVentureEngine::runObjQueue() {
void MacVentureEngine::updateControls() {
if (_activeControl)
_activeControl = kNoCommand;
- toggleExits();
- // resetVars();
+ toggleExits();
+ resetVars();
}
void MacVentureEngine::resetVars() {
@@ -378,9 +401,11 @@ void MacVentureEngine::focusObjectWindow(ObjID objID) {
}
void MacVentureEngine::openObject(ObjID objID) {
+
+ debug("openObject: %d", objID);
if (getObjWindow(objID)) return;
if (objID == _world->getObjAttr(1, kAttrParentObject)) {
- //_gui->setRefcon(objID, kMainGameWindow); // FIXME: Find better name
+ _gui->updateWindowInfo(kMainGameWindow, objID, _world->getChildren(objID, true)); // FIXME: Find better name
_gui->updateWindow(kMainGameWindow, _world->getObjAttr(objID, kAttrContainerOpen));
//_gui->drawExits();
_gui->setWindowTitle(kMainGameWindow, _world->getText(objID));
@@ -390,17 +415,54 @@ void MacVentureEngine::openObject(ObjID objID) {
//globalToDesktop(p);
WindowReference invID = _gui->createInventoryWindow();
_gui->setWindowTitle(invID, _world->getText(objID));
- //_gui->setRefCon(objID, invID);
+ _gui->updateWindowInfo(invID, objID, _world->getChildren(objID, true));
_gui->updateWindow(invID, _world->getObjAttr(objID, kAttrContainerOpen));
}
}
void MacVentureEngine::closeObject(ObjID objID) {
- warning("closeObject: unimplemented");
+ warning("closeObject: not fully implemented");
+ bool success = _gui->tryCloseWindow(getObjWindow(objID));
+ return;
}
void MacVentureEngine::checkObject(ObjID objID) {
- warning("checkObject: unimplemented");
+ //warning("checkObject: unimplemented");
+ bool hasChanged = false;
+ debug("Check Object[%d] parent[%d] x[%d] y[%d]",
+ objID,
+ _world->getObjAttr(objID, kAttrParentObject),
+ _world->getObjAttr(objID, kAttrPosX),
+ _world->getObjAttr(objID, kAttrPosY));
+ //bool incoming = isIncomingObj(objID);
+ //if (incoming) removeIncoming(objID);
+ if (objID == 1) {
+ if (_world->getObjAttr(objID, kAttrParentObject) != 0) {
+ enqueueObject(kSetToPlayerParent, objID);
+ }
+ }
+ _gui->updateWindow(findParentWindow(objID), true);
+
+ WindowReference win = getObjWindow(objID);
+ ObjID parent = objID;
+ ObjID root = _world->getObjAttr(1, kAttrParentObject);
+ while (parent != root) {
+ if (parent == 0 || !_world->getObjAttr(parent, kAttrContainerOpen)) break;
+ parent = _world->getObjAttr(parent, kAttrParentObject);
+ }
+ if (parent == root) {
+ if (win) return;
+ enqueueObject(kOpenWindow, objID);
+ } else {
+ if (!win) return;
+ enqueueObject(kCloseWindow, objID);
+ }
+
+ // Update children
+ Common::Array<ObjID> children = _world->getChildren(objID, true);
+ for (uint i = 0; i < children.size(); i++) {
+ enqueueObject(kUpdateObject, children[i]);
+ }
}
void MacVentureEngine::reflectSwap(ObjID objID) {
@@ -475,6 +537,10 @@ uint32 MacVentureEngine::getInvolvedObjects() {
return (_selectedControl ? _globalSettings.cmdArgCnts[_selectedControl - 1] : 3000);
}
+Common::Point MacVentureEngine::getObjPosition(ObjID objID) {
+ return Common::Point(_world->getObjAttr(objID, kAttrPosX), _world->getObjAttr(objID, kAttrPosY));
+}
+
WindowReference MacVentureEngine::getObjWindow(ObjID objID) {
switch (objID) {
case 0xfffc: return kExitsWindow;
@@ -490,6 +556,12 @@ WindowReference MacVentureEngine::findObjWindow(ObjID objID) {
return kMainGameWindow;
}
+WindowReference MacVentureEngine::findParentWindow(ObjID objID) {
+ if (objID == 1) return kSelfWindow;
+ ObjID parent = _world->getObjAttr(objID, kAttrParentObject);
+ return getObjWindow(parent);
+}
+
Common::Point MacVentureEngine::getDeltaPoint() {
return _deltaPoint;
}
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index bb4eec83f5..a23dbecd30 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -177,6 +177,9 @@ public:
void runObjQueue();
void printTexts();
+ void focusObjWin(ObjID objID);
+ void updateWindow(WindowReference winID);
+
// Data retrieval
bool isPaused();
Common::String getCommandsPausedString() const;
@@ -186,8 +189,12 @@ public:
const HuffmanLists *getDecodingHuffman() const;
uint32 randBetween(uint32 min, uint32 max);
uint32 getInvolvedObjects();
+
+ Common::Point getObjPosition(ObjID objID);
+
WindowReference getObjWindow(ObjID objID);
WindowReference findObjWindow(ObjID objID);
+ WindowReference findParentWindow(ObjID objID);
Common::Point getDeltaPoint();
ObjID getDestObject();
diff --git a/engines/macventure/module.mk b/engines/macventure/module.mk
index c0dc818d96..efd5a693be 100644
--- a/engines/macventure/module.mk
+++ b/engines/macventure/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
text.o \
world.o \
script.o \
+ image.o \
macventure.o
MODULE_DIRS += \
diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp
index 715249ca6d..64f94af16d 100644
--- a/engines/macventure/script.cpp
+++ b/engines/macventure/script.cpp
@@ -54,14 +54,14 @@ bool ScriptEngine::runControl(ControlAction action, ObjID source, ObjID destinat
frame.haltedInFirst = false;
frame.haltedInFamily = false;
_frames.push_back(frame);
- debug(7, "SCRIPT: Stored frame %d, action: %d src: %d dest: %d point: (%d, %d)",
+ debug(3, "SCRIPT: Stored frame %d, action: %d src: %d dest: %d point: (%d, %d)",
_frames.size() - 1, frame.action, frame.src, frame.dest, frame.x, frame.y);
return resume(true);
}
bool ScriptEngine::resume(bool execAll) {
- debug(7, "SCRIPT: Resume");
+ debug(3, "SCRIPT: Resume");
while (_frames.size()) {
bool fail = execFrame(execAll);
if (fail) return true;
@@ -145,13 +145,13 @@ bool ScriptEngine::resumeFunc(EngineFrame * frame) {
}
bool ScriptEngine::runFunc(EngineFrame *frame) {
- debug(7, "SCRIPT: I'm running the function");
+ debug(3, "SCRIPT: I'm running the function");
ScriptAsset &script = frame->scripts.front();
EngineState *state = &frame->state;
byte op;
while (script.hasNext()) {
op = script.fetch();
- debug(8, "SCRIPT: I'm running operation %x", op);
+ debug(3, "SCRIPT: I'm running operation %x", op);
if (!(op & 0x80)) {
state->push(op);
} else {
@@ -1157,7 +1157,7 @@ void ScriptAsset::loadInstructions() {
for (uint i = 0; i < amount; i++) {
_instructions.push_back(res->readByte());
}
- debug(7, "SCRIPT: Load %d instructions for script %d", amount, _id);
+ debug(3, "SCRIPT: Load %d instructions for script %d", amount, _id);
}
} // End of namespace MacVenture \ No newline at end of file
diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp
index c7b103efd7..36e9e21158 100644
--- a/engines/macventure/world.cpp
+++ b/engines/macventure/world.cpp
@@ -23,11 +23,15 @@ World::World(MacVentureEngine *engine, Common::MacResManager *resMan) {
_objectConstants = new Container(_engine->getFilePath(kObjectPathID).c_str());
calculateObjectRelations();
- _gameText = new Container("Shadowgate II/Shadow Text");
+ warning("Test functions about to happen");
+ _gameGraphics = new Container("Shadowgate II/Shadow Graphic");
+ _gameText = new Container("Shadowgate II/Shadow Text");
ObjID tid = (ObjID)1;
TextAsset test = TextAsset(tid, _gameText, _engine->isOldText(), _engine->getDecodingHuffman());
+ ImageAsset testImg(((428 * 2) + 1), _gameGraphics);
+
delete saveGameRes;
saveGameFile.close();
}
@@ -140,9 +144,9 @@ void World::updateObj(ObjID objID) {
win = _engine->getObjWindow(objID);
}
if (win) {
- //focusObjWin(objID);
+ _engine->focusObjWin(objID);
_engine->runObjQueue();
- //_engine->updateWindow(win);
+ _engine->updateWindow(win);
}
}
diff --git a/engines/macventure/world.h b/engines/macventure/world.h
index fe45508623..8afa75c83c 100644
--- a/engines/macventure/world.h
+++ b/engines/macventure/world.h
@@ -122,8 +122,10 @@ private:
Common::String _startGameFileName;
SaveGame *_saveGame;
+
Container *_objectConstants;
Container *_gameText;
+ Container *_gameGraphics;
Common::Array<ObjID> _relations; // Parent-child relations, stored in Williams Heap format
};