diff options
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/detection_tables.h | 17 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 12 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.cpp | 79 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_code.h | 3 | ||||
-rw-r--r-- | engines/mohawk/livingbooks_lbx.cpp | 17 | ||||
-rw-r--r-- | engines/mohawk/view.cpp | 4 |
6 files changed, 113 insertions, 19 deletions
diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h index 87635bfc6a..0d5dc1a405 100644 --- a/engines/mohawk/detection_tables.h +++ b/engines/mohawk/detection_tables.h @@ -1361,6 +1361,23 @@ static const MohawkGameDescription gameDescriptions[] = { "GRANDMA.EXE" }, + // Just Grandma and Me 1.1 Mac + // From eisnerguy1 in bug#3610725 + { + { + "grandma", + "v1.1", + AD_ENTRY1("BookOutline", "76eb265ec5fe42bc5b07f2bb418bd871"), + Common::EN_ANY, + Common::kPlatformMacintosh, + ADGF_NO_FLAGS, + GUIO1(GUIO_NOASPECT) + }, + GType_LIVINGBOOKSV1, + 0, + 0 + }, + // from jjnryan in bug #3389857 { { diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 2b0a45d4e6..f80dbfacbd 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -245,6 +245,8 @@ Common::Error MohawkEngine_LivingBooks::run() { case Common::KEYCODE_ESCAPE: if (_curMode == kLBIntroMode) tryLoadPageStart(kLBControlMode, 1); + else + _video->stopVideos(); break; case Common::KEYCODE_LEFT: @@ -587,8 +589,8 @@ void MohawkEngine_LivingBooks::updatePage() { _items.remove_at(i); i--; _orderedItems.remove(delayedEvent.item); - delete delayedEvent.item; _page->itemDestroyed(delayedEvent.item); + delete delayedEvent.item; if (_focus == delayedEvent.item) _focus = NULL; break; @@ -1356,8 +1358,9 @@ void MohawkEngine_LivingBooks::handleNotify(NotifyEvent &event) { if (!loadPage((LBMode)event.newMode, event.newPage, event.newSubpage)) { if (event.newPage != 0 || !loadPage((LBMode)event.newMode, _curPage, event.newSubpage)) if (event.newSubpage != 0 || !loadPage((LBMode)event.newMode, event.newPage, 1)) - error("kLBNotifyChangeMode failed to move to mode %d, page %d.%d", - event.newMode, event.newPage, event.newSubpage); + if (event.newSubpage != 1 || !loadPage((LBMode)event.newMode, event.newPage, 0)) + error("kLBNotifyChangeMode failed to move to mode %d, page %d.%d", + event.newMode, event.newPage, event.newSubpage); } break; case 3: @@ -3775,7 +3778,7 @@ LBMovieItem::~LBMovieItem() { void LBMovieItem::update() { if (_playing) { VideoHandle videoHandle = _vm->_video->findVideoHandle(_resourceId); - if (_vm->_video->endOfVideo(videoHandle)) + if (videoHandle == NULL_VID_HANDLE || _vm->_video->endOfVideo(videoHandle)) done(true); } @@ -3785,6 +3788,7 @@ void LBMovieItem::update() { bool LBMovieItem::togglePlaying(bool playing, bool restart) { if (playing) { if ((_loaded && _enabled && _globalEnabled) || _phase == kLBPhaseNone) { + debug("toggled video for phase %d", _phase); _vm->_video->playMovie(_resourceId, _rect.left, _rect.top); return true; diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp index bb8f7a0d05..c45efb2c39 100644 --- a/engines/mohawk/livingbooks_code.cpp +++ b/engines/mohawk/livingbooks_code.cpp @@ -519,9 +519,17 @@ void LBCode::parseMain() { *val = _stack.pop(); _stack.push(*val); } else - _stack.push(LBValue()); - } else if (_currToken == kTokenAndEquals) { - debugN(" &= "); + error("assignment failed, no dest"); +// _stack.push(LBValue()); + } else if (_currToken == kTokenPlusEquals || _currToken == kTokenMinusEquals || _currToken == kTokenAndEquals) { + // FIXME: do +=/-= belong here? + byte token = _currToken; + if (_currToken == kTokenPlusEquals) + debugN(" += "); + else if (_currToken == kTokenMinusEquals) + debugN(" -= "); + else if (_currToken == kTokenAndEquals) + debugN(" &= "); nextToken(); parseStatement(); if (!_stack.size()) @@ -532,9 +540,19 @@ void LBCode::parseMain() { else val = &_vm->_variables[varname]; if (val) { - if (val->type != kLBValueString) - error("operator &= used on non-string"); - val->string = val->string + _stack.pop().toString(); + if (token == kTokenAndEquals) { + if (val->type != kLBValueString) + error("operator &= used on non-string"); + val->string = val->string + _stack.pop().toString(); + } else { + // FIXME: non-integers + if (val->type != kLBValueInteger) + error("operator used on non-integer"); + if (token == kTokenPlusEquals) + val->integer = val->integer + _stack.pop().toInt(); + else + val->integer = val->integer - _stack.pop().toInt(); + } _stack.push(*val); } else _stack.push(LBValue()); @@ -581,6 +599,7 @@ void LBCode::parseMain() { debugN("--"); nextToken(); + // FIXME: do we need to handle indexing? if (_currToken != kTokenIdentifier) error("expected identifier"); assert(_currValue.type == kLBValueString); @@ -669,6 +688,24 @@ void LBCode::parseMain() { _stack.push(_stack.pop().isZero() ? 1 : 0); break; + case kTokenEval: + // FIXME: original token? + debugN(".."); + nextToken(); + parseStatement(); + if (!_stack.size()) + error("eval op failed"); + { + // FIXME: XXX + LBValue in = _stack.pop(); + if (in.type != kLBValueString) + error("eval op on non-string"); + Common::String varname = in.string; + LBValue &val = _vm->_variables[varname]; + _stack.push(val); + } + break; + case kTokenGeneralCommand: runGeneralCommand(); break; @@ -692,9 +729,7 @@ void LBCode::parseMain() { assert(val.isNumeric()); // FIXME if (prefix == kTokenMinus) - val.integer--; - else - val.integer++; + val.integer = -val.integer; _stack.push(val); } } @@ -1554,12 +1589,32 @@ uint LBCode::nextFreeString() { error("nextFreeString couldn't find a space"); } +static const char *const functionNameAliases[][2] = { + { "makerect", "getRect" }, + { "makepair", "makePt" }, + { "getframerect", "getFrameBounds" }, + { "dragbegin", "dragBeginFrom" }, + { "x", "xpos" }, + { "y", "ypos" } +}; + /* * Helper function for parseCode: * Given a name, appends the appropriate data to the provided code array and * returns true if it's a function, or false otherwise. */ -bool LBCode::parseCodeSymbol(const Common::String &name, uint &pos, Common::Array<byte> &code) { +bool LBCode::parseCodeSymbol(Common::String name, uint &pos, Common::Array<byte> &code, bool useAllAliases) { + // Check to see if we have one of the older function names + // and remap it to the newer function names + for (uint i = 0; i < ARRAYSIZE(functionNameAliases); i++) { + if (name.equalsIgnoreCase(functionNameAliases[i][0])) { + if (name.size() == 1 && !useAllAliases) + continue; + name = functionNameAliases[i][1]; + break; + } + } + // first, check whether the name matches a known function for (uint i = 0; i < 2; i++) { byte cmdToken; @@ -1770,7 +1825,7 @@ uint LBCode::parseCode(const Common::String &source) { break; tempString += source[pos++]; } - wasFunction = parseCodeSymbol(tempString, pos, code); + wasFunction = parseCodeSymbol(tempString, pos, code, true); if (!wasFunction) error("while parsing script '%s', encountered explicit function call to unknown function '%s'", source.c_str(), tempString.c_str()); @@ -1805,7 +1860,7 @@ uint LBCode::parseCode(const Common::String &source) { } else if (tempString.equalsIgnoreCase("false")) { code.push_back(kTokenFalse); } else { - wasFunction = parseCodeSymbol(tempString, pos, code); + wasFunction = parseCodeSymbol(tempString, pos, code, false); } } else { error("while parsing script '%s', couldn't parse '%c'", source.c_str(), token); diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h index 47dd90f814..c9d9ae06e6 100644 --- a/engines/mohawk/livingbooks_code.h +++ b/engines/mohawk/livingbooks_code.h @@ -188,6 +188,7 @@ enum { kTokenConstEventId = 0x42, kTokenConstScriptOpcode = 0x43, // ?? kTokenConstScriptParam = 0x44, // ?? + kTokenEval = 0x4b, kTokenGeneralCommand = 0x4d, kTokenItemCommand = 0x4e, kTokenNotifyCommand = 0x4f, @@ -242,7 +243,7 @@ protected: void runNotifyCommand(); uint nextFreeString(); - bool parseCodeSymbol(const Common::String &name, uint &pos, Common::Array<byte> &code); + bool parseCodeSymbol(Common::String name, uint &pos, Common::Array<byte> &code, bool useAllAliases); public: void cmdUnimplemented(const Common::Array<LBValue> ¶ms); diff --git a/engines/mohawk/livingbooks_lbx.cpp b/engines/mohawk/livingbooks_lbx.cpp index 9628e06294..2b8b22ec81 100644 --- a/engines/mohawk/livingbooks_lbx.cpp +++ b/engines/mohawk/livingbooks_lbx.cpp @@ -48,8 +48,10 @@ LBXDataFile::~LBXDataFile() { enum { kLBXDataFileOpen = 1, + kLBXDataFileAddSection = 3, kLBXDataFileGetSectionList = 4, kLBXDataFileSetCurSection = 5, + kLBXDataFileSetKey = 7, kLBXDataFileLoadCurSectionVars = 8, kLBXDataFileDeleteCurSection = 10, kLBXDataFileSectionExists = 14 @@ -64,6 +66,14 @@ bool LBXDataFile::call(uint callId, const Common::Array<LBValue> ¶ms, LBValu open(params[0].toString()); return false; + case kLBXDataFileAddSection: + if (params.size() != 1) + error("incorrect number of parameters (%d) to LBXDataFile::addSection", params.size()); + + _dataFile.addSection(params[0].toString()); + _curSection = params[0].toString(); + return false; + case kLBXDataFileGetSectionList: { Common::SharedPtr<LBList> list = Common::SharedPtr<LBList>(new LBList); @@ -81,6 +91,13 @@ bool LBXDataFile::call(uint callId, const Common::Array<LBValue> ¶ms, LBValu _curSection = params[0].toString(); return false; + case kLBXDataFileSetKey: + if (params.size() != 2) + error("incorrect number of parameters (%d) to LBXDataFile::setKey", params.size()); + + _dataFile.setKey(params[0].toString(), _curSection, params[1].toString()); + return false; + case kLBXDataFileLoadCurSectionVars: if (params.size() != 0) error("incorrect number of parameters (%d) to LBXDataFile::loadCurSectionVars", params.size()); diff --git a/engines/mohawk/view.cpp b/engines/mohawk/view.cpp index 36e8f8466e..719c288af5 100644 --- a/engines/mohawk/view.cpp +++ b/engines/mohawk/view.cpp @@ -361,8 +361,8 @@ void View::idleView() { void View::setModule(Module *module) { if (_currentModule) { - module->shutdown(); - delete module; + _currentModule->shutdown(); + delete _currentModule; } _currentModule = NULL; |