diff options
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/exec_br.cpp | 29 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 30 | ||||
-rw-r--r-- | engines/parallaction/objects.cpp | 44 | ||||
-rw-r--r-- | engines/parallaction/objects.h | 29 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 3 | ||||
-rw-r--r-- | engines/parallaction/parser_ns.cpp | 9 |
8 files changed, 61 insertions, 89 deletions
diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 5c718bf61a..e58ec13d98 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -321,12 +321,7 @@ DECLARE_INSTRUCTION_OPCODE(off) { DECLARE_INSTRUCTION_OPCODE(set) { InstructionPtr inst = *_ctxt.inst; - - int16 rvalue = inst->_opB.getRValue(); - int16* lvalue = inst->_opA.getLValue(); - - *lvalue = rvalue; - + inst->_opA.setValue(inst->_opB.getValue()); } @@ -334,7 +329,7 @@ DECLARE_INSTRUCTION_OPCODE(set) { DECLARE_INSTRUCTION_OPCODE(inc) { InstructionPtr inst = *_ctxt.inst; - int16 rvalue = inst->_opB.getRValue(); + int16 rvalue = inst->_opB.getValue(); if (inst->_flags & kInstMod) { // mod int16 _bx = (rvalue > 0 ? rvalue : -rvalue); @@ -343,32 +338,30 @@ DECLARE_INSTRUCTION_OPCODE(inc) { rvalue = (rvalue > 0 ? 1 : -1); } - int16 *lvalue = inst->_opA.getLValue(); + int16 lvalue = inst->_opA.getValue(); switch (inst->_index) { case INST_INC: - *lvalue += rvalue; + lvalue += rvalue; break; case INST_DEC: - *lvalue -= rvalue; + lvalue -= rvalue; break; case INST_MUL: - *lvalue *= rvalue; + lvalue *= rvalue; break; case INST_DIV: - *lvalue /= rvalue; + lvalue /= rvalue; break; default: error("This should never happen. Report immediately"); } - if (inst->_opA._flags & kParaLocal) { - inst->_opA._local->wrap(); - } + inst->_opA.setValue(lvalue); } @@ -401,11 +394,7 @@ DECLARE_INSTRUCTION_OPCODE(move) { DECLARE_INSTRUCTION_OPCODE(color) { InstructionPtr inst = *_ctxt.inst; - - int16 entry = inst->_opB.getRValue(); - - _vm->_gfx->_palette.setEntry(entry, inst->_colors[0], inst->_colors[1], inst->_colors[2]); - + _vm->_gfx->_palette.setEntry(inst->_opB.getValue(), inst->_colors[0], inst->_colors[1], inst->_colors[2]); } diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index bd05c169e7..d63582f8d1 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -80,7 +80,7 @@ DECLARE_INSTRUCTION_OPCODE(off) { DECLARE_INSTRUCTION_OPCODE(loop) { InstructionPtr inst = *_ctxt.inst; - _ctxt.program->_loopCounter = inst->_opB.getRValue(); + _ctxt.program->_loopCounter = inst->_opB.getValue(); _ctxt.program->_loopStart = _ctxt.ip; } @@ -93,7 +93,7 @@ DECLARE_INSTRUCTION_OPCODE(endloop) { DECLARE_INSTRUCTION_OPCODE(inc) { InstructionPtr inst = *_ctxt.inst; - int16 _si = inst->_opB.getRValue(); + int16 _si = inst->_opB.getValue(); if (inst->_flags & kInstMod) { // mod int16 _bx = (_si > 0 ? _si : -_si); @@ -102,29 +102,22 @@ DECLARE_INSTRUCTION_OPCODE(inc) { _si = (_si > 0 ? 1 : -1); } - int16* lvalue = inst->_opA.getLValue(); + int16 lvalue = inst->_opA.getValue(); if (inst->_index == INST_INC) { - *lvalue += _si; + lvalue += _si; } else { - *lvalue -= _si; + lvalue -= _si; } - if (inst->_opA._flags & kParaLocal) { - inst->_opA._local->wrap(); - } + inst->_opA.setValue(lvalue); } DECLARE_INSTRUCTION_OPCODE(set) { InstructionPtr inst = *_ctxt.inst; - - int16 _si = inst->_opB.getRValue(); - int16 *lvalue = inst->_opA.getLValue(); - - *lvalue = _si; - + inst->_opA.setValue(inst->_opB.getValue()); } @@ -135,8 +128,8 @@ DECLARE_INSTRUCTION_OPCODE(put) { v18.h = inst->_a->height(); v18.pixels = inst->_a->getFrameData(inst->_a->_frame); - int16 x = inst->_opA.getRValue(); - int16 y = inst->_opB.getRValue(); + int16 x = inst->_opA.getValue(); + int16 y = inst->_opB.getValue(); bool mask = (inst->_flags & kInstMaskedPut) == kInstMaskedPut; _vm->_gfx->patchBackground(v18, x, y, mask); @@ -176,8 +169,8 @@ DECLARE_INSTRUCTION_OPCODE(sound) { DECLARE_INSTRUCTION_OPCODE(move) { InstructionPtr inst = (*_ctxt.inst); - int16 x = inst->_opA.getRValue(); - int16 y = inst->_opB.getRValue(); + int16 x = inst->_opA.getValue(); + int16 y = inst->_opB.getValue(); _vm->_char.scheduleWalk(x, y); } @@ -352,7 +345,6 @@ void Parallaction_ns::drawAnimations() { if (((anim->_flags & kFlagsActive) == 0) && (anim->_flags & kFlagsRemove)) { anim->_flags &= ~kFlagsRemove; - anim->_oldPos.x = -1000; } if ((anim->_flags & kFlagsActive) && (anim->_flags & kFlagsRemove)) { diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp index c387484de7..b91644d02d 100644 --- a/engines/parallaction/objects.cpp +++ b/engines/parallaction/objects.cpp @@ -115,24 +115,29 @@ int16 Program::addLocal(const char *name, int16 value, int16 min, int16 max) { assert(_numLocals < NUM_LOCALS); strcpy(_localNames[_numLocals], name); - _locals[_numLocals]._value = value; - - _locals[_numLocals]._min = min; - _locals[_numLocals]._max = max; + _locals[_numLocals].setRange(min, max); + _locals[_numLocals].setValue(value); return _numLocals++; } -void LocalVariable::wrap() { +void LocalVariable::setValue(int16 value) { + if (value >= _max) + value = _min; + if (value < _min) + value = _max - 1; - if (_value >= _max) - _value = _min; - if (_value < _min) - _value = _max - 1; + _value = value; +} - return; +void LocalVariable::setRange(int16 min, int16 max) { + _max = max; + _min = min; } +int16 LocalVariable::getValue() const { + return _value; +} Zone::Zone() { @@ -273,14 +278,14 @@ Instruction::~Instruction() { free(_text2); } -int16 ScriptVar::getRValue() { +int16 ScriptVar::getValue() { if (_flags & kParaImmediate) { return _value; } if (_flags & kParaLocal) { - return _local->_value; + return _local->getValue(); } if (_flags & kParaField) { @@ -296,28 +301,29 @@ int16 ScriptVar::getRValue() { return 0; } -int16* ScriptVar::getLValue() { +void ScriptVar::setValue(int16 value) { + if ((_flags & kParaLValue) == 0) { + error("Only l-value can be set"); + } if (_flags & kParaLocal) { - return &_local->_value; + _local->setValue(value); } if (_flags & kParaField) { - return _pvalue; + *_pvalue = value; } - error("Parameter is not an l-value"); - } void ScriptVar::setLocal(LocalVariable *local) { _local = local; - _flags |= kParaLocal; + _flags |= (kParaLocal | kParaLValue); } void ScriptVar::setField(int16 *field) { _pvalue = field; - _flags |= kParaField; + _flags |= (kParaField | kParaLValue); } void ScriptVar::setImmediate(int16 value) { diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index 7e7a811ba6..ee681a5dc4 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -306,8 +306,7 @@ struct Zone { uint32 _type; uint32 _flags; uint _label; - uint16 field_2C; // unused - uint16 field_2E; // unused + TypeData u; CommandList _commands; Common::Point _moveTo; @@ -328,24 +327,33 @@ struct Zone { struct LocalVariable { +protected: int16 _value; int16 _min; int16 _max; +public: + LocalVariable() { _value = 0; _min = -10000; _max = 10000; } - void wrap(); + void setRange(int16 min, int16 max); + + int16 getValue() const; + void setValue(int16 value); }; + enum ParaFlags { kParaImmediate = 1, // instruction is using an immediate parameter kParaLocal = 2, // instruction is using a local variable kParaField = 0x10, // instruction is using an animation's field - kParaRandom = 0x100 + kParaRandom = 0x100, + + kParaLValue = 0x20 }; @@ -358,8 +366,8 @@ struct ScriptVar { ScriptVar(); - int16 getRValue(); - int16* getLValue(); + int16 getValue(); + void setValue(int16 value); void setLocal(LocalVariable *local); void setField(int16 *field); @@ -431,18 +439,11 @@ typedef Common::List<ProgramPtr> ProgramList; struct Animation : public Zone { - Common::Point _oldPos; GfxObj *gfxobj; char *_scriptName; int16 _frame; - uint16 field_50; // unused int16 _z; - uint16 field_54; // unused - uint16 field_56; // unused - uint16 field_58; // unused - uint16 field_5A; // unused - uint16 field_5C; // unused - uint16 field_5E; // unused + Animation(); virtual ~Animation(); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index dca3d04157..195dc7a89a 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -513,8 +513,6 @@ Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) { _ani->_left = 150; _ani->_top = 100; _ani->_z = 10; - _ani->_oldPos.x = -1000; - _ani->_oldPos.y = -1000; _ani->_frame = 0; _ani->_flags = kFlagsActive | kFlagsNoName; _ani->_type = kZoneYou; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index bfbe7c3eb3..b95fcf68b2 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -318,10 +318,6 @@ void Parallaction_ns::changeLocation(char *location) { strcpy(_saveData1, locname.location()); parseLocation(_saveData1); - _char._ani->_oldPos.x = -1000; - _char._ani->_oldPos.y = -1000; - - _char._ani->field_50 = 0; if (_location._startPosition.x != -1000) { _char._ani->_left = _location._startPosition.x; _char._ani->_top = _location._startPosition.y; diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index dee08485fb..b71ac44d3c 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -849,9 +849,6 @@ DECLARE_ANIM_PARSER(endanimation) { ctxt.a->_bottom = ctxt.a->height(); } - ctxt.a->_oldPos.x = -1000; - ctxt.a->_oldPos.y = -1000; - ctxt.a->_flags |= 0x1000000; _parser->popTables(); diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index dd4a79a8d2..52256c341c 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -221,9 +221,6 @@ DECLARE_ANIM_PARSER(type) { } } - ctxt.a->_oldPos.x = -1000; - ctxt.a->_oldPos.y = -1000; - ctxt.a->_flags |= 0x1000000; _parser->popTables(); @@ -284,10 +281,6 @@ DECLARE_ANIM_PARSER(moveto) { DECLARE_ANIM_PARSER(endanimation) { debugC(7, kDebugParser, "ANIM_PARSER(endanimation) "); - - ctxt.a->_oldPos.x = -1000; - ctxt.a->_oldPos.y = -1000; - ctxt.a->_flags |= 0x1000000; _parser->popTables(); @@ -523,7 +516,7 @@ DECLARE_INSTRUCTION_PARSER(defLocal) { } ctxt.inst->_opA.setLocal(&ctxt.locals[index]); - ctxt.inst->_opB.setImmediate(ctxt.locals[index]._value); + ctxt.inst->_opB.setImmediate(ctxt.locals[index].getValue()); ctxt.inst->_index = INST_SET; } |