aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/director/lingo/lingo-code.cpp14
-rw-r--r--engines/director/lingo/lingo-gr.cpp22
-rw-r--r--engines/director/lingo/lingo-gr.y22
3 files changed, 29 insertions, 29 deletions
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index fbee0d8360..3dead580da 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -833,7 +833,7 @@ void Lingo::c_repeatwhilecode(void) {
d.toInt();
while (d.u.i) {
- g_lingo->execute(body); /* body */
+ g_lingo->execute(body + savepc - 1); /* body */
if (g_lingo->_returning)
break;
@@ -848,7 +848,7 @@ void Lingo::c_repeatwhilecode(void) {
}
if (!g_lingo->_returning)
- g_lingo->_pc = end; /* next stmt */
+ g_lingo->_pc = end + savepc - 1; /* next stmt */
}
void Lingo::c_repeatwithcode(void) {
@@ -867,14 +867,14 @@ void Lingo::c_repeatwithcode(void) {
error("Cast ref used as index: %s", countername.c_str());
}
- g_lingo->execute(init); /* condition */
+ g_lingo->execute(init + savepc - 1); /* condition */
d = g_lingo->pop();
d.toInt();
counter->u.i = d.u.i;
counter->type = INT;
while (true) {
- g_lingo->execute(body); /* body */
+ g_lingo->execute(body + savepc - 1); /* body */
if (g_lingo->_returning)
break;
@@ -884,7 +884,7 @@ void Lingo::c_repeatwithcode(void) {
}
counter->u.i += inc;
- g_lingo->execute(finish); /* condition */
+ g_lingo->execute(finish + savepc - 1); /* condition */
d = g_lingo->pop();
d.toInt();
@@ -893,7 +893,7 @@ void Lingo::c_repeatwithcode(void) {
}
if (!g_lingo->_returning)
- g_lingo->_pc = end; /* next stmt */
+ g_lingo->_pc = end + savepc - 1; /* next stmt */
}
void Lingo::c_exitRepeat(void) {
@@ -933,7 +933,7 @@ void Lingo::c_ifcode() {
void Lingo::c_whencode() {
Datum d;
uint start = g_lingo->_pc;
- uint end = READ_UINT32(&(*g_lingo->_currentScript)[start]);
+ uint end = READ_UINT32(&(*g_lingo->_currentScript)[start]) + start - 1;
Common::String eventname((char *)&(*g_lingo->_currentScript)[start + 1]);
start += g_lingo->calcStringAlignment(eventname.c_str()) + 1;
diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp
index d63a1363bd..453c92652c 100644
--- a/engines/director/lingo/lingo-gr.cpp
+++ b/engines/director/lingo/lingo-gr.cpp
@@ -2270,8 +2270,8 @@ yyreduce:
#line 201 "engines/director/lingo/lingo-gr.y"
{
inst body = 0, end = 0;
- WRITE_UINT32(&body, (yyvsp[(5) - (7)].code));
- WRITE_UINT32(&end, (yyvsp[(6) - (7)].code));
+ WRITE_UINT32(&body, (yyvsp[(5) - (7)].code) - (yyvsp[(1) - (7)].code));
+ WRITE_UINT32(&end, (yyvsp[(6) - (7)].code) - (yyvsp[(1) - (7)].code));
(*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 1] = body; /* body of loop */
(*g_lingo->_currentScript)[(yyvsp[(1) - (7)].code) + 2] = end; /* end, if cond fails */
@@ -2282,10 +2282,10 @@ yyreduce:
#line 214 "engines/director/lingo/lingo-gr.y"
{
inst init = 0, finish = 0, body = 0, end = 0, inc = 0;
- WRITE_UINT32(&init, (yyvsp[(3) - (10)].code));
- WRITE_UINT32(&finish, (yyvsp[(6) - (10)].code));
- WRITE_UINT32(&body, (yyvsp[(8) - (10)].code));
- WRITE_UINT32(&end, (yyvsp[(9) - (10)].code));
+ WRITE_UINT32(&init, (yyvsp[(3) - (10)].code) - (yyvsp[(1) - (10)].code));
+ WRITE_UINT32(&finish, (yyvsp[(6) - (10)].code) - (yyvsp[(1) - (10)].code));
+ WRITE_UINT32(&body, (yyvsp[(8) - (10)].code) - (yyvsp[(1) - (10)].code));
+ WRITE_UINT32(&end, (yyvsp[(9) - (10)].code) - (yyvsp[(1) - (10)].code));
WRITE_UINT32(&inc, 1);
(*g_lingo->_currentScript)[(yyvsp[(1) - (10)].code) + 1] = init; /* initial count value */
(*g_lingo->_currentScript)[(yyvsp[(1) - (10)].code) + 2] = finish;/* final count value */
@@ -2300,10 +2300,10 @@ yyreduce:
#line 232 "engines/director/lingo/lingo-gr.y"
{
inst init = 0, finish = 0, body = 0, end = 0, inc = 0;
- WRITE_UINT32(&init, (yyvsp[(3) - (11)].code));
- WRITE_UINT32(&finish, (yyvsp[(7) - (11)].code));
- WRITE_UINT32(&body, (yyvsp[(9) - (11)].code));
- WRITE_UINT32(&end, (yyvsp[(10) - (11)].code));
+ WRITE_UINT32(&init, (yyvsp[(3) - (11)].code) - (yyvsp[(1) - (11)].code));
+ WRITE_UINT32(&finish, (yyvsp[(7) - (11)].code) - (yyvsp[(1) - (11)].code));
+ WRITE_UINT32(&body, (yyvsp[(9) - (11)].code) - (yyvsp[(1) - (11)].code));
+ WRITE_UINT32(&end, (yyvsp[(10) - (11)].code) - (yyvsp[(1) - (11)].code));
WRITE_UINT32(&inc, -1);
(*g_lingo->_currentScript)[(yyvsp[(1) - (11)].code) + 1] = init; /* initial count value */
(*g_lingo->_currentScript)[(yyvsp[(1) - (11)].code) + 2] = finish;/* final count value */
@@ -2318,7 +2318,7 @@ yyreduce:
#line 246 "engines/director/lingo/lingo-gr.y"
{
inst end = 0;
- WRITE_UINT32(&end, (yyvsp[(3) - (3)].code));
+ WRITE_UINT32(&end, (yyvsp[(3) - (3)].code) - (yyvsp[(1) - (3)].code));
g_lingo->code1(STOP);
(*g_lingo->_currentScript)[(yyvsp[(1) - (3)].code) + 1] = end;
;}
diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y
index 4fb2f4c01a..150cad6c49 100644
--- a/engines/director/lingo/lingo-gr.y
+++ b/engines/director/lingo/lingo-gr.y
@@ -200,8 +200,8 @@ stmt: stmtoneliner
//
| repeatwhile '(' cond ')' stmtlist end ENDCLAUSE {
inst body = 0, end = 0;
- WRITE_UINT32(&body, $5);
- WRITE_UINT32(&end, $6);
+ WRITE_UINT32(&body, $5 - $1);
+ WRITE_UINT32(&end, $6 - $1);
(*g_lingo->_currentScript)[$1 + 1] = body; /* body of loop */
(*g_lingo->_currentScript)[$1 + 2] = end; /* end, if cond fails */
@@ -213,10 +213,10 @@ stmt: stmtoneliner
//
| repeatwith '=' expr end tTO expr end stmtlist end ENDCLAUSE {
inst init = 0, finish = 0, body = 0, end = 0, inc = 0;
- WRITE_UINT32(&init, $3);
- WRITE_UINT32(&finish, $6);
- WRITE_UINT32(&body, $8);
- WRITE_UINT32(&end, $9);
+ WRITE_UINT32(&init, $3 - $1);
+ WRITE_UINT32(&finish, $6 - $1);
+ WRITE_UINT32(&body, $8 - $1);
+ WRITE_UINT32(&end, $9 - $1);
WRITE_UINT32(&inc, 1);
(*g_lingo->_currentScript)[$1 + 1] = init; /* initial count value */
(*g_lingo->_currentScript)[$1 + 2] = finish;/* final count value */
@@ -231,10 +231,10 @@ stmt: stmtoneliner
//
| repeatwith '=' expr end tDOWN tTO expr end stmtlist end ENDCLAUSE {
inst init = 0, finish = 0, body = 0, end = 0, inc = 0;
- WRITE_UINT32(&init, $3);
- WRITE_UINT32(&finish, $7);
- WRITE_UINT32(&body, $9);
- WRITE_UINT32(&end, $10);
+ WRITE_UINT32(&init, $3 - $1);
+ WRITE_UINT32(&finish, $7 - $1);
+ WRITE_UINT32(&body, $9 - $1);
+ WRITE_UINT32(&end, $10 - $1);
WRITE_UINT32(&inc, -1);
(*g_lingo->_currentScript)[$1 + 1] = init; /* initial count value */
(*g_lingo->_currentScript)[$1 + 2] = finish;/* final count value */
@@ -245,7 +245,7 @@ stmt: stmtoneliner
checkEnd($11, "repeat", true); }
| when stmtoneliner end {
inst end = 0;
- WRITE_UINT32(&end, $3);
+ WRITE_UINT32(&end, $3 - $1);
g_lingo->code1(STOP);
(*g_lingo->_currentScript)[$1 + 1] = end;
}