--- /dev/null
+#include "SystemVIA.h"
+#include <QDebug>
+
+SystemVIA::SystemVIA(Memory *inside):
+ MemoryMap(inside) {
+
+ inside->hookMemoryMap(0xFE40, 0xFE5F, this);
+
+ mPinLevelA = 0xFF;
+ mPinLevelB = 0xFF;
+
+ // Set (almost) everything to zero.
+
+ mIRA = 0;
+ mIRB = 0xF0; // The top bit is set hig
+ mORA = 0;
+ mORB = 0;
+ mDDRA = 0;
+ mDDRB = 0;
+ mACR = 0;
+ mTimer1 = 0;
+ mTimer2 = 0;
+ mT1LL = 0;
+ mT1LH = 0;
+ mT2LL = 0;
+ mT2LH = 0;
+ mSR = 0;
+
+}
+
+int SystemVIA::read(int address) {
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+
+ switch (address) {
+ case 0xfe40:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe41:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe42:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe43:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe44:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe45:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe46:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe47:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe48:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe49:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4a:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4b:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4c:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4d:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4e:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4f:
+ qDebug() << QString("System VIA read from %1").arg(address, 4, 16);
+ break;
+
+ }
+ return 0;
+}
+
+void SystemVIA::write(int address, int value) {
+ switch (address)
+ {
+ case 0xfe40:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe41:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe42:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe43:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe44:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe45:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe46:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe47:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe48:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe49:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4a:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4b:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4c:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4d:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4e:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+
+ case 0xfe4f:
+ qDebug() << QString("System VIA write to %1").arg(address, 4, 16);
+ break;
+ }
+}
+
+// Stubs for now:
+
+void SystemVIA::keyDown(int row, int col) {
+ Q_UNUSED(row);
+ Q_UNUSED(col);
+ // ...
+}
+
+void SystemVIA::keyUp(int row, int col) {
+ Q_UNUSED(row);
+ Q_UNUSED(col);
+ // ...
+}
+
+void SystemVIA::allKeysUp() {
+ // ...
+}
--- /dev/null
+#ifndef SYSTEMVIA_H
+#define SYSTEMVIA_H 1
+
+#include "Memory.h"
+#include "MemoryMap.h"
+
+class SystemVIA: public MemoryMap {
+
+ Q_OBJECT
+
+ public:
+ SystemVIA(Memory *inside);
+
+ int read(int address);
+ void write(int address, int value);
+
+ public slots:
+
+ /**
+ * Received when a key is pressed.
+ *
+ * \param key The key. Multiply the
+ * row number by 100 and add
+ * the column number.
+ */
+ void keyDown(int key);
+
+ /**
+ * Received when a key is released.
+ *
+ * \param key The key. Multiply the
+ * row number by 100 and add
+ * the column number.
+ */
+ void keyUp(int key);
+
+ /**
+ * Received to cause all keys to be
+ * released.
+ */
+ void allKeysUp();
+
+ signals:
+ /**
+ * Sent to turn the Caps Lock LED on or off.
+ *
+ * \param on Whether it's on.
+ */
+ void CapsLED(bool caps, bool on);
+
+ /**
+ * Sent to turn the Shift Lock LED on or off.
+ *
+ * \param on Whether it's on.
+ */
+ void ShiftLED(bool caps, bool on);
+
+ protected:
+
+ // These are the registers of the 6522 VIA.
+
+ int mORB;
+ int mORA;
+ int mDDRB;
+ int mDDRA;
+ int mT1CL;
+ int mT1CH; // maybe do these as one?
+ int mT1LL;
+ int mT1LH;
+ int mT2CL;
+ int mT2CH;
+ int mSR;
+ int mACR;
+ int mPCR;
+ int mIFR;
+ int mIER;
+
+};
+
+#endif