diff options
author | Eugene Sandulenko | 2016-06-18 17:07:50 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 5bbfea01fef459e1fb6fb1f40780e94b78e720b1 (patch) | |
tree | aa7d814d108223d0463153563ad132d3e1f61277 /engines/director/lingo | |
parent | 7760ea8d86e92e448fd0a23fd7f7500d3454516f (diff) | |
download | scummvm-rg350-5bbfea01fef459e1fb6fb1f40780e94b78e720b1.tar.gz scummvm-rg350-5bbfea01fef459e1fb6fb1f40780e94b78e720b1.tar.bz2 scummvm-rg350-5bbfea01fef459e1fb6fb1f40780e94b78e720b1.zip |
DIRECTOR: Lingo: Added some lingo-func code
Diffstat (limited to 'engines/director/lingo')
-rw-r--r-- | engines/director/lingo/lingo-funcs.cpp | 41 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.cpp | 48 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.h | 2 | ||||
-rw-r--r-- | engines/director/lingo/lingo-gr.y | 4 | ||||
-rw-r--r-- | engines/director/lingo/lingo.cpp | 1 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 6 |
6 files changed, 71 insertions, 31 deletions
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp index 1fb4c19bee..4557ace065 100644 --- a/engines/director/lingo/lingo-funcs.cpp +++ b/engines/director/lingo/lingo-funcs.cpp @@ -165,7 +165,24 @@ void Lingo::exec_mciwait(Common::String *s) { warning("MCI wait file: %s", s->c_str()); } +void Lingo::push(Datum d) { + _stack.push_back(d); +} + +Datum Lingo::pop(void) { + if (_stack.size() == 0) + error("stack underflow"); + + Datum ret = _stack.back(); + _stack.pop_back(); + + return ret; +} + void Lingo::func_constpush() { + Datum d; + d.val = ((Symbol *)*g_lingo->_pc++)->u.val; + g_lingo->push(d); } void Lingo::func_varpush() { @@ -178,15 +195,39 @@ void Lingo::func_eval() { } void Lingo::func_add() { + Datum d1, d2; + d2 = g_lingo->pop(); + d1 = g_lingo->pop(); + d1.val += d2.val; + g_lingo->push(d1); } void Lingo::func_sub() { + Datum d1, d2; + d2 = g_lingo->pop(); + d1 = g_lingo->pop(); + d1.val -= d2.val; + g_lingo->push(d1); } void Lingo::func_mul() { + Datum d1, d2; + d2 = g_lingo->pop(); + d1 = g_lingo->pop(); + d1.val *= d2.val; + g_lingo->push(d1); } void Lingo::func_div() { + Datum d1, d2; + d2 = g_lingo->pop(); + + if (d2.val == 0) + error("division by zero"); + + d1 = g_lingo->pop(); + d1.val /= d2.val; + g_lingo->push(d1); } void Lingo::func_negate() { diff --git a/engines/director/lingo/lingo-gr.cpp b/engines/director/lingo/lingo-gr.cpp index 4950ee44b2..21164ed451 100644 --- a/engines/director/lingo/lingo-gr.cpp +++ b/engines/director/lingo/lingo-gr.cpp @@ -111,10 +111,6 @@ void yyerror(char *s) { warning("%s", s); } using namespace Director; -namespace Director { -extern Lingo *g_lingo; -} - /* Enabling traces. */ @@ -137,10 +133,10 @@ extern Lingo *g_lingo; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 43 "engines/director/lingo/lingo-gr.y" +#line 39 "engines/director/lingo/lingo-gr.y" { float f; int i; Common::String *s; } /* Line 193 of yacc.c. */ -#line 144 "engines/director/lingo/lingo-gr.cpp" +#line 140 "engines/director/lingo/lingo-gr.cpp" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -153,7 +149,7 @@ typedef union YYSTYPE /* Line 216 of yacc.c. */ -#line 157 "engines/director/lingo/lingo-gr.cpp" +#line 153 "engines/director/lingo/lingo-gr.cpp" #ifdef short # undef short @@ -443,9 +439,9 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 67, 67, 68, 71, 72, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 87, 88, 89, 90, - 91 + 0, 63, 63, 64, 67, 68, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 83, 84, 85, 86, + 87 }; #endif @@ -1369,78 +1365,78 @@ yyreduce: switch (yyn) { case 6: -#line 75 "engines/director/lingo/lingo-gr.y" +#line 71 "engines/director/lingo/lingo-gr.y" { (yyval.i) = g_lingo->code2(g_lingo->func_constpush, (inst)(yyvsp[(1) - (1)].i)); ;} break; case 7: -#line 76 "engines/director/lingo/lingo-gr.y" +#line 72 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(1) - (1)].s)->c_str()); (yyval.i) = g_lingo->code1(g_lingo->func_eval); delete (yyvsp[(1) - (1)].s); ;} break; case 8: -#line 77 "engines/director/lingo/lingo-gr.y" +#line 73 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_add); ;} break; case 9: -#line 78 "engines/director/lingo/lingo-gr.y" +#line 74 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_sub); ;} break; case 10: -#line 79 "engines/director/lingo/lingo-gr.y" +#line 75 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_mul); ;} break; case 11: -#line 80 "engines/director/lingo/lingo-gr.y" +#line 76 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_div); ;} break; case 12: -#line 81 "engines/director/lingo/lingo-gr.y" +#line 77 "engines/director/lingo/lingo-gr.y" { (yyval.i) = (yyvsp[(2) - (2)].i); ;} break; case 13: -#line 82 "engines/director/lingo/lingo-gr.y" +#line 78 "engines/director/lingo/lingo-gr.y" { (yyval.i) = (yyvsp[(2) - (2)].i); g_lingo->code1(g_lingo->func_negate); ;} break; case 14: -#line 83 "engines/director/lingo/lingo-gr.y" +#line 79 "engines/director/lingo/lingo-gr.y" { (yyval.i) = (yyvsp[(2) - (3)].i); ;} break; case 16: -#line 87 "engines/director/lingo/lingo-gr.y" +#line 83 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_mci); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;} break; case 17: -#line 88 "engines/director/lingo/lingo-gr.y" +#line 84 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_mciwait); g_lingo->codeString((yyvsp[(2) - (2)].s)->c_str()); delete (yyvsp[(2) - (2)].s); ;} break; case 18: -#line 89 "engines/director/lingo/lingo-gr.y" +#line 85 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(4) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.i) = (yyvsp[(2) - (4)].i); delete (yyvsp[(4) - (4)].s); ;} break; case 19: -#line 90 "engines/director/lingo/lingo-gr.y" +#line 86 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.i) = (yyvsp[(4) - (4)].i); delete (yyvsp[(2) - (4)].s); ;} break; case 20: -#line 91 "engines/director/lingo/lingo-gr.y" +#line 87 "engines/director/lingo/lingo-gr.y" { g_lingo->code1(g_lingo->func_varpush); g_lingo->codeString((yyvsp[(2) - (4)].s)->c_str()); g_lingo->code1(g_lingo->func_assign); (yyval.i) = (yyvsp[(4) - (4)].i); delete (yyvsp[(2) - (4)].s); ;} break; /* Line 1267 of yacc.c. */ -#line 1444 "engines/director/lingo/lingo-gr.cpp" +#line 1440 "engines/director/lingo/lingo-gr.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1654,6 +1650,6 @@ yyreturn: } -#line 94 "engines/director/lingo/lingo-gr.y" +#line 90 "engines/director/lingo/lingo-gr.y" diff --git a/engines/director/lingo/lingo-gr.h b/engines/director/lingo/lingo-gr.h index 90f23d642e..81753f7c9b 100644 --- a/engines/director/lingo/lingo-gr.h +++ b/engines/director/lingo/lingo-gr.h @@ -70,7 +70,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 43 "engines/director/lingo/lingo-gr.y" +#line 39 "engines/director/lingo/lingo-gr.y" { float f; int i; Common::String *s; } /* Line 1529 of yacc.c. */ #line 77 "engines/director/lingo/lingo-gr.hpp" diff --git a/engines/director/lingo/lingo-gr.y b/engines/director/lingo/lingo-gr.y index aadcd3c11a..7d73f6707e 100644 --- a/engines/director/lingo/lingo-gr.y +++ b/engines/director/lingo/lingo-gr.y @@ -34,10 +34,6 @@ void yyerror(char *s) { warning("%s", s); } using namespace Director; -namespace Director { -extern Lingo *g_lingo; -} - %} %union { float f; int i; Common::String *s; } diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 141f227af8..4ac9c12ed3 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -73,6 +73,7 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { _eventHandlerTypes[t->handler] = t->name; _currentScript = 0; + _pc = 0; warning("Lingo Inited"); } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 34bb6b0ad1..bfb5a765df 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -125,6 +125,8 @@ public: private: int parse(const char *code); + void push(Datum d); + Datum pop(void); Common::HashMap<uint32, const char *> _eventHandlerTypes; Common::HashMap<Common::String, Audio::AudioStream *> _audioAliases; @@ -132,11 +134,15 @@ private: ScriptHash _scripts[kMaxScriptType + 1]; ScriptData *_currentScript; + inst *_pc; + StackData _stack; DirectorEngine *_vm; }; +extern Lingo *g_lingo; + } // End of namespace Director #endif |