aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo
diff options
context:
space:
mode:
Diffstat (limited to 'engines/director/lingo')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp34
-rw-r--r--engines/director/lingo/lingo-code.cpp12
-rw-r--r--engines/director/lingo/lingo-the.cpp50
-rw-r--r--engines/director/lingo/lingo.cpp15
4 files changed, 77 insertions, 34 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index f554f43cd8..cb6a7d67ec 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -21,7 +21,11 @@
*/
#include "common/system.h"
+#include "common/events.h"
+
#include "director/lingo/lingo.h"
+#include "director/frame.h"
+#include "director/sprite.h"
namespace Director {
@@ -379,7 +383,7 @@ void Lingo::printSTUBWithArglist(const char *funcname, int nargs, const char *pr
s += ")";
- warning("%s: %s", prefix, s.c_str());
+ warning("%s %s", prefix, s.c_str());
}
void Lingo::convertVOIDtoString(int arg, int nargs) {
@@ -1163,9 +1167,12 @@ void Lingo::b_move(int nargs) {
}
void Lingo::b_moveableSprite(int nargs) {
- g_lingo->printSTUBWithArglist("b_moveableSprite", nargs);
+ Frame *frame = g_director->getCurrentScore()->_frames[g_director->getCurrentScore()->getCurrentFrame()];
- g_lingo->dropStack(nargs);
+ // Will have no effect
+ frame->_sprites[g_lingo->_currentEntityId]->_moveable = true;
+
+ g_director->setDraggedSprite(frame->_sprites[g_lingo->_currentEntityId]->_castId);
}
void Lingo::b_pasteClipBoardInto(int nargs) {
@@ -1216,9 +1223,26 @@ void Lingo::b_ramNeeded(int nargs) {
void Lingo::b_rollOver(int nargs) {
Datum d = g_lingo->pop();
- warning("STUB: b_rollOver(%d)", d.u.i);
- g_lingo->push(Datum(0));
+ d.toInt();
+
+ int arg = d.u.i;
+
+ d.u.i = 0; // FALSE
+
+ Frame *frame = g_director->getCurrentScore()->_frames[g_director->getCurrentScore()->getCurrentFrame()];
+
+ if (arg >= frame->_sprites.size()) {
+ g_lingo->push(d);
+ return;
+ }
+
+ Common::Point pos = g_system->getEventManager()->getMousePos();
+
+ if (frame->checkSpriteIntersection(arg, pos))
+ d.u.i = 1; // TRUE
+
+ g_lingo->push(d);
}
void Lingo::b_spriteBox(int nargs) {
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 7bc82eddcf..d0d29dd04c 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -307,10 +307,14 @@ void Lingo::c_assign() {
}
if (d1.type == REFERENCE) {
- if (!g_director->getCurrentScore()->_castsInfo.contains(d1.u.i)) {
- warning("c_assign: Unknown REFERENCE %d", d1.u.i);
- g_lingo->pushVoid();
- return;
+ if (!g_director->getCurrentScore()->_loadedText->contains(d1.u.i)) {
+ if (!g_director->getCurrentScore()->_loadedText->contains(d1.u.i - 1024)) {
+ warning("c_assign: Unknown REFERENCE %d", d1.u.i);
+ g_lingo->pushVoid();
+ return;
+ } else {
+ d1.u.i -= 1024;
+ }
}
warning("STUB: c_assing REFERENCE");
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 8f874435f7..68999f66ef 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -332,8 +332,8 @@ void Lingo::setTheSprite(Datum &id1, int field, Datum &d) {
switch (field) {
case kTheCastNum:
- if (_vm->getCurrentScore()->_casts.contains(d.u.i)) {
- sprite->_cast = _vm->getCurrentScore()->_casts[d.u.i];
+ if (_vm->getCurrentScore()->_castTypes.contains(d.u.i)) {
+ _vm->getCurrentScore()->loadCastInto(sprite, d.u.i);
sprite->_castId = d.u.i;
}
break;
@@ -638,9 +638,9 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
return d;
}
- Cast *cast;
+ CastType castType;
CastInfo *castInfo;
- if (!_vm->getCurrentScore()->_casts.contains(id)) {
+ if (!_vm->getCurrentScore()->_castTypes.contains(id)) {
if (field == kTheLoaded) {
d.type = INT;
d.u.i = 0;
@@ -651,14 +651,14 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
warning("The cast %d found", id);
}
- cast = _vm->getCurrentScore()->_casts[id];
+ castType = _vm->getCurrentScore()->_castTypes[id];
castInfo = _vm->getCurrentScore()->_castsInfo[id];
d.type = INT;
switch (field) {
case kTheCastType:
- d.u.i = cast->type;
+ d.u.i = castType;
break;
case kTheFileName:
d.toString();
@@ -673,32 +673,32 @@ Datum Lingo::getTheCast(Datum &id1, int field) {
d.u.s = &castInfo->script;
break;
case kTheWidth:
- d.u.i = cast->initialRect.width();
+ d.u.i = _vm->getCurrentScore()->getCastMemberInitialRect(id).width();
break;
case kTheHeight:
- d.u.i = cast->initialRect.height();
+ d.u.i = _vm->getCurrentScore()->getCastMemberInitialRect(id).height();
break;
case kTheBackColor:
{
- if (cast->type != kCastShape) {
+ if (castType != kCastShape) {
warning("Field %d of cast %d not found", field, id);
d.type = VOID;
return d;
}
- ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
+ ShapeCast *shape = _vm->getCurrentScore()->_loadedShapes->getVal(id);
d.u.i = shape->bgCol;
}
break;
case kTheForeColor:
{
- if (cast->type != kCastShape) {
+ if (castType != kCastShape) {
warning("Field %d of cast %d not found", field, id);
d.type = VOID;
return d;
}
- ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
+ ShapeCast *shape = _vm->getCurrentScore()->_loadedShapes->getVal(id);
d.u.i = shape->fgCol;
}
break;
@@ -729,18 +729,20 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
return;
}
- Cast *cast = _vm->getCurrentScore()->_casts[id];
+ CastType castType = _vm->getCurrentScore()->_castTypes[id];
CastInfo *castInfo = _vm->getCurrentScore()->_castsInfo[id];
- if (!cast) {
+ if (!castInfo) {
warning("The cast %d found", id);
return;
}
switch (field) {
case kTheCastType:
- cast->type = static_cast<CastType>(d.u.i);
- cast->modified = 1;
+ // TODO: You can actually switch the cast type!?
+ warning("Tried to switch cast type of %d", id);
+ //cast->type = static_cast<CastType>(d.u.i);
+ //cast->modified = 1;
break;
case kTheFileName:
castInfo->fileName = *d.u.s;
@@ -752,30 +754,30 @@ void Lingo::setTheCast(Datum &id1, int field, Datum &d) {
castInfo->script = *d.u.s;
break;
case kTheWidth:
- cast->initialRect.setWidth(d.u.i);
- cast->modified = 1;
+ _vm->getCurrentScore()->getCastMemberInitialRect(id).setWidth(d.u.i);
+ _vm->getCurrentScore()->setCastMemberModified(id);
break;
case kTheHeight:
- cast->initialRect.setHeight(d.u.i);
- cast->modified = 1;
+ _vm->getCurrentScore()->getCastMemberInitialRect(id).setHeight(d.u.i);
+ _vm->getCurrentScore()->setCastMemberModified(id);
break;
case kTheBackColor:
{
- if (cast->type != kCastShape) {
+ if (castType != kCastShape) {
warning("Field %d of cast %d not found", field, id);
}
- ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
+ ShapeCast *shape = _vm->getCurrentScore()->_loadedShapes->getVal(id);
shape->bgCol = d.u.i;
shape->modified = 1;
}
break;
case kTheForeColor:
{
- if (cast->type != kCastShape) {
+ if (castType != kCastShape) {
warning("Field %d of cast %d not found", field, id);
return;
}
- ShapeCast *shape = static_cast<ShapeCast *>(_vm->getCurrentScore()->_casts[id]);
+ ShapeCast *shape = _vm->getCurrentScore()->_loadedShapes->getVal(id);
shape->fgCol = d.u.i;
shape->modified = 1;
}
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 706f76777d..a51ff222c7 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -299,7 +299,7 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
if (entityId < 0)
return;
- debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId);
+ debugC(9, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId);
_currentEntityId = entityId;
@@ -307,8 +307,11 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
error("processEvent: Unknown event %d for entity %d", event, entityId);
if (_handlers.contains(ENTITY_INDEX(event, entityId))) {
+ debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId);
call(_eventHandlerTypes[event], 0); // D4+ Events
} else if (_scripts[st].contains(entityId)) {
+ debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId);
+
executeScript(st, entityId); // D3 list of scripts.
} else {
debugC(3, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
@@ -318,6 +321,13 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
void Lingo::restartLingo() {
warning("STUB: restartLingo()");
+ for (int i = 0; i <= kMaxScriptType; i++) {
+ for (ScriptHash::iterator it = _scripts[i].begin(); it != _scripts[i].end(); ++it)
+ delete it->_value;
+
+ _scripts[i].clear();
+ }
+
// TODO
//
// reset the following:
@@ -403,6 +413,9 @@ Common::String *Datum::toString() {
case VAR:
*s = Common::String::format("var: #%s", u.sym->name.c_str());
break;
+ case REFERENCE:
+ *s = Common::String::format("field#%d", u.i);
+ break;
default:
warning("Incorrect operation toString() for type: %s", type2str());
}