From e6ca4b4568e311b47239bfe83de15ed9e91c57b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 15 Dec 2017 22:45:28 +0100 Subject: Implement few initial graphic elements --- qtmips_machine/qtmipsmachine.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'qtmips_machine/qtmipsmachine.cpp') diff --git a/qtmips_machine/qtmipsmachine.cpp b/qtmips_machine/qtmipsmachine.cpp index 7b44a7b..191a7c7 100644 --- a/qtmips_machine/qtmipsmachine.cpp +++ b/qtmips_machine/qtmipsmachine.cpp @@ -9,6 +9,7 @@ QtMipsMachine::QtMipsMachine(const MachineConfig &cc) { program.to_memory(mem); program_end = program.end(); + program_ended = false; MemoryAccess *coremem; switch (cc.cache()) { @@ -35,6 +36,8 @@ QtMipsMachine::QtMipsMachine(const MachineConfig &cc) { void QtMipsMachine::set_speed(unsigned val) { run_speed = val; + if (run_t->isActive()) + play(); } const Registers *QtMipsMachine::registers() { @@ -54,19 +57,31 @@ const Core *QtMipsMachine::core() { } void QtMipsMachine::play() { + if (program_ended) + return; run_t->start(run_speed); } void QtMipsMachine::pause() { + if (program_ended) + return; run_t->stop(); } void QtMipsMachine::step() { + if (program_ended) // Ignore if program ended + return; + emit tick(); cr->step(); - if (regs->read_pc() >= program_end) + if (regs->read_pc() >= program_end) { + program_ended = true; + run_t->stop(); emit program_exit(); + } } void QtMipsMachine::restart() { + if (!program_ended) + run_t->stop(); // Stop timer if program is still running // TODO } -- cgit v1.2.3