]> Shamusworld >> Repos - stargem2/blob - src/v6821.h
Finally fixed problems with demo mode.
[stargem2] / src / v6821.h
1 //
2 // Virtual 6821 (PIA) Header file
3 //
4 // by James Hammons
5 //
6 // (C) 2022 Underground Software
7 //
8 #ifndef __V6821_H__
9 #define __V6821_H__
10
11 #include <cstddef>
12 #include <stdint.h>
13
14 struct V6821PIA
15 {
16         public:
17                 uint8_t ddra, ddrb;             // Data Direction Register A/B
18                 uint8_t pa, pb;                 // Peripheral Interface A/B
19                 uint8_t cra, crb;               // Control Register A/B
20                 uint8_t ora, orb;               // Output Register A/B
21                 bool ca1, ca2, cb1, cb2;        // CA1/2, CB1/2
22                 bool irqa1, irqa2, irqb1, irqb2;        // Internal state flags
23                 bool irqaState, irqbState;      // More internal state flags
24
25                 void (* IRQA)(bool);    // Address of IRQ A routine
26                 void (* IRQB)(bool);    // Address of IRQ B routine
27
28
29                 V6821PIA();                             // We have to do this because function pointers
30                                                                 // can't have default parameters...  :-P
31                 V6821PIA(void (* a)(bool), void (* b)(bool));
32                 void Reset(void);
33                 uint8_t Read(uint8_t);
34                 void Write(uint8_t, uint8_t);
35                 void CA1(bool);
36                 void CA2(bool);
37                 void CB1(bool);
38                 void CB2(bool);
39
40         private:
41                 void HandleIRQs(void);
42 };
43
44 #endif  // __V6821_H__