82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
#ifndef MAINWINDOW_H
|
|
#define MAINWINDOW_H
|
|
|
|
#include <QMainWindow>
|
|
#include <memory>
|
|
|
|
class MachineController;
|
|
class Machine;
|
|
class QLineEdit;
|
|
|
|
namespace Ui {
|
|
class MainWindow;
|
|
}
|
|
|
|
class MainWindow : public QMainWindow
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
|
~MainWindow();
|
|
|
|
std::shared_ptr<Machine> machine() const { return m_machine; }
|
|
MachineController* controller() const { return m_controller.get(); }
|
|
|
|
void startExecution();
|
|
void stopExecution();
|
|
void stepExecution();
|
|
|
|
void setTestRegisterValues();
|
|
|
|
private slots:
|
|
void updateRegisterDisplays();
|
|
void updateMemoryDisplay();
|
|
void updateDisassemblyDisplay();
|
|
void onRegisterFieldChanged();
|
|
void onMemoryInc256();
|
|
void onMemoryInc4096();
|
|
void onMemoryInc65536();
|
|
void onMemoryDec256();
|
|
void onMemoryDec4096();
|
|
void onMemoryDec65536();
|
|
void onMemoryGoToStart();
|
|
void onMemoryGoToEnd();
|
|
void onDisassemblyInc();
|
|
void onDisassemblyInc16();
|
|
void onDisassemblyInc256();
|
|
void onDisassemblyDec();
|
|
void onDisassemblyDec16();
|
|
void onDisassemblyDec256();
|
|
void onDisassemblyGoToStart();
|
|
void onDisassemblyGoToEnd();
|
|
|
|
private:
|
|
Ui::MainWindow *ui;
|
|
std::shared_ptr<Machine> m_machine;
|
|
std::unique_ptr<MachineController> m_controller;
|
|
int m_memoryOffset = 0;
|
|
int m_disassemblyOffset = 0;
|
|
|
|
void connectRegisterFields();
|
|
void updateSingleRegisterDisplay(const QString& fieldName, int value);
|
|
void updateAllFormatsForRegister(const QString& regPrefix, int value);
|
|
void updateFloatRegisterFormats(const QString& regPrefix, double value);
|
|
void handleFloatRegisterFieldChanged(QLineEdit* field, const QString& objectName);
|
|
void loadDemoProgram();
|
|
void setupMemoryDisplay();
|
|
void setupDisassemblyDisplay();
|
|
|
|
struct DisassembledInstruction {
|
|
int address;
|
|
int size;
|
|
QString mnemonic;
|
|
QString operand;
|
|
int effectiveAddr;
|
|
bool isImmediate;
|
|
bool isIndirect;
|
|
};
|
|
DisassembledInstruction disassembleAt(int address);
|
|
};
|
|
|
|
#endif // MAINWINDOW_H
|