int AGOSEngine::runScript() { bool flag; if (shouldQuit()) return 1; do { if (DebugMan.isDebugChannelEnabled(kDebugOpcode)) dumpOpcode(_codePtr); if (getGameType() == GType_ELVIRA1) { _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } else { _opcode = getByte(); if (_opcode == 0xFF) return 0; } if (_runScriptReturn1) return 1; /* Invert condition? */ flag = false; if (getGameType() == GType_ELVIRA1) { if (_opcode == 203) { flag = true; _opcode = getVarOrWord(); if (_opcode == 10000) return 0; } } else { if (_opcode == 0) { flag = true; _opcode = getByte(); if (_opcode == 0xFF) return 0; } } setScriptCondition(true); setScriptReturn(0); if (_opcode > _numOpcodes) error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); } while (getScriptCondition() != flag && !getScriptReturn() && !shouldQuit()); return (shouldQuit()) ? 1 : getScriptReturn(); }
int AGOSEngine_PN::doaction() { if (_linct == 0) return 0; _opcode = readfromline(); if (_opcode > 63) { return (actCallD(_opcode - 64)); } setScriptReturn(0); executeOpcode(_opcode); delay(0); return getScriptReturn(); }
unsigned int CPU::step() { if (Q_UNLIKELY(m_paused)) { return 0; } byte opcode = fetchOpcode(m_state.pc++); bool interrupted = false; if (Q_UNLIKELY(m_state.interrupt && m_state.int_enabled)) { interrupted = true; m_state.halt_flag = false; m_state.int_enabled = false; m_state.interrupt = false; opcode = m_state.interrupt_opcode; m_state.interrupt_opcode = 0; m_state.pc--; } if (Q_LIKELY(!m_state.halt_flag)) { for (auto opcodeDef : m_opcodes) { if (opcodeDef.isMatching(opcode)) { auto clockCycles = executeOpcode(opcodeDef, opcode); return clockCycles; } } } else { return 0; } error((QString("Illegal instruction : 0x") + QString::number(opcode, 16) + "/" + QString::number(opcode, 2) + (interrupted ? " (interruption)" : " (Address : 0x" + QString::number(m_state.pc - 1, 16) + ")")).toStdString()); }