mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-09 15:39:08 +00:00
Attempts to start updating a started machine.
No real progress on graphics output though.
This commit is contained in:
parent
11c28357a1
commit
e2ceb77501
OSBindings/Qt
@ -7,6 +7,7 @@
|
||||
|
||||
#include "../../Numeric/CRC.hpp"
|
||||
|
||||
|
||||
/*
|
||||
General Qt implementation notes:
|
||||
|
||||
@ -35,11 +36,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
connect(qTimer.get(), SIGNAL(timeout()), timer.get(), SLOT(tick()));
|
||||
|
||||
// Start the thread and timer.
|
||||
// TODO: not until there's actually something to display.
|
||||
timerThread->start();
|
||||
qTimer->start();
|
||||
|
||||
// Hide the missing ROMs box unless or until it's needed; grab the text it
|
||||
// began with as a prefix for future mutation.
|
||||
ui->missingROMsBox->setVisible(false);
|
||||
@ -144,12 +140,26 @@ void MainWindow::launchMachine() {
|
||||
std::unique_ptr<Machine::DynamicMachine> machine(Machine::MachineForTargets(targets, rom_fetcher, error));
|
||||
|
||||
switch(error) {
|
||||
default:
|
||||
default: {
|
||||
ui->missingROMsBox->setVisible(false);
|
||||
uiPhase = UIPhase::RunningMachine;
|
||||
|
||||
// TODO: launch machine.
|
||||
break;
|
||||
// TODO: Install the OpenGL scan target.
|
||||
// This is subject to having created an OpenGL context.
|
||||
// const auto scan_producer = machine->scan_producer();
|
||||
// if(scan_producer) {
|
||||
// scan_producer->set_scan_target(&scanTarget);
|
||||
// }
|
||||
|
||||
// If this is a timed machine, start up the timer.
|
||||
const auto timedMachine = machine->timed_machine();
|
||||
if(timedMachine) {
|
||||
timer->setMachine(timedMachine);
|
||||
timerThread->start();
|
||||
qTimer->start();
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case Machine::Error::MissingROM: {
|
||||
ui->missingROMsBox->setVisible(true);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
||||
#include "../../Machines/Utility/MachineForTarget.hpp"
|
||||
#include "../../Outputs/OpenGL/ScanTarget.hpp"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
@ -42,6 +43,9 @@ class MainWindow : public QMainWindow {
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
|
||||
// Output.
|
||||
Outputs::Display::OpenGL::ScanTarget scanTarget;
|
||||
|
||||
private slots:
|
||||
void open();
|
||||
};
|
||||
|
@ -2,13 +2,19 @@
|
||||
|
||||
#include "../../ClockReceiver/TimeTypes.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <QDebug>
|
||||
|
||||
Timer::Timer(QObject *parent) : QObject(parent) {}
|
||||
|
||||
void Timer::tick() {
|
||||
// static int64_t last = 0;
|
||||
// const auto now = Time::nanos_now();
|
||||
// qDebug() << now - last;
|
||||
// last = now;
|
||||
void Timer::setMachine(MachineTypes::TimedMachine *machine) {
|
||||
this->machine = machine;
|
||||
}
|
||||
|
||||
void Timer::tick() {
|
||||
const auto now = Time::nanos_now();
|
||||
const auto duration = std::min(now - lastTickNanos, int64_t(500'000));
|
||||
lastTickNanos = now;
|
||||
|
||||
machine->run_for(double(duration) / 1e9);
|
||||
}
|
||||
|
@ -3,15 +3,22 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "../../Machines/Utility/MachineForTarget.hpp"
|
||||
|
||||
class Timer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Timer(QObject *parent = nullptr);
|
||||
void setMachine(MachineTypes::TimedMachine *machine);
|
||||
|
||||
public slots:
|
||||
void tick();
|
||||
|
||||
private:
|
||||
MachineTypes::TimedMachine *machine = nullptr;
|
||||
int64_t lastTickNanos = 0;
|
||||
};
|
||||
|
||||
#endif // TIMER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user