]> Shamusworld >> Repos - stargem2/blobdiff - src/v6821.h
Finally fixed problems with demo mode.
[stargem2] / src / v6821.h
diff --git a/src/v6821.h b/src/v6821.h
new file mode 100644 (file)
index 0000000..a4faebb
--- /dev/null
@@ -0,0 +1,44 @@
+//
+// Virtual 6821 (PIA) Header file
+//
+// by James Hammons
+//
+// (C) 2022 Underground Software
+//
+#ifndef __V6821_H__
+#define __V6821_H__
+
+#include <cstddef>
+#include <stdint.h>
+
+struct V6821PIA
+{
+       public:
+               uint8_t ddra, ddrb;             // Data Direction Register A/B
+               uint8_t pa, pb;                 // Peripheral Interface A/B
+               uint8_t cra, crb;               // Control Register A/B
+               uint8_t ora, orb;               // Output Register A/B
+               bool ca1, ca2, cb1, cb2;        // CA1/2, CB1/2
+               bool irqa1, irqa2, irqb1, irqb2;        // Internal state flags
+               bool irqaState, irqbState;      // More internal state flags
+
+               void (* IRQA)(bool);    // Address of IRQ A routine
+               void (* IRQB)(bool);    // Address of IRQ B routine
+
+
+               V6821PIA();                             // We have to do this because function pointers
+                                                               // can't have default parameters...  :-P
+               V6821PIA(void (* a)(bool), void (* b)(bool));
+               void Reset(void);
+               uint8_t Read(uint8_t);
+               void Write(uint8_t, uint8_t);
+               void CA1(bool);
+               void CA2(bool);
+               void CB1(bool);
+               void CB2(bool);
+
+       private:
+               void HandleIRQs(void);
+};
+
+#endif // __V6821_H__