Skip to content

Commit

Permalink
DIRECTOR: Lingo: Implement 'repeat with down' control keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 82756b3 commit 5874611
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 203 deletions.
3 changes: 3 additions & 0 deletions engines/director/director.cpp
Expand Up @@ -101,6 +101,9 @@ end repeat\n\
repeat with z = 10 to 15\n\
put z\n\
end repeat\n\
repeat with y = 5 down to 1\n\
put y\n\
end repeat\n\
", kMovieScript, 3);

_lingo->executeScript(kMovieScript, 3);
Expand Down
9 changes: 5 additions & 4 deletions engines/director/lingo/lingo-code.cpp
Expand Up @@ -282,8 +282,9 @@ void Lingo::c_repeatwithcode(void) {
int init = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc]);
int finish = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 1]);
int body = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 2]);
int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 3]);
Common::String countername((char *)&(*g_lingo->_currentScript)[savepc + 4]);
int inc = (int32)READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 3]);
int end = READ_LE_UINT32(&(*g_lingo->_currentScript)[savepc + 4]);
Common::String countername((char *)&(*g_lingo->_currentScript)[savepc + 5]);
Symbol *counter = g_lingo->lookupVar(countername.c_str());

g_lingo->execute(init); /* condition */
Expand All @@ -296,11 +297,11 @@ void Lingo::c_repeatwithcode(void) {
if (g_lingo->_returning)
break;

counter->u.val++;
counter->u.val += inc;
g_lingo->execute(finish); /* condition */
d = g_lingo->pop();

if (counter->u.val > d.val)
if (counter->u.val == d.val + inc)
break;
}

Expand Down

0 comments on commit 5874611

Please sign in to comment.