--- /dev/null
+//
+// 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__