2 // Virtual 63701 Header file
5 // (C) 2014 Underground Software
14 #define FLAG_H 0x20 // Half carry
15 #define FLAG_I 0x10 // IRQ
16 #define FLAG_N 0x08 // Negative
17 #define FLAG_Z 0x04 // Zero
18 #define FLAG_V 0x02 // oVerflow
19 #define FLAG_C 0x01 // Carry
21 #define V63701_LINE_RESET 0x0001 // v63701 RESET line
22 #define V63701_LINE_IRQ 0x0002 // v63701 IRQ line
23 #define V63701_LINE_NMI 0x0004 // v63701 NMI line
24 #define V63701_STATE_WAI 0x0008 // v63701 wait for IRQ line
25 #define V63701_TIMER_OVERFLOW 0x0010
26 #define V63701_OUTPUT_COMPARE 0x0020
27 #define V63701_INPUT_CAPTURE 0x0040
28 #define V63701_TRAP 0x0080 // Illegal instruction executed flag
29 //#define V6809_START_DEBUG_LOG 0x8000 // Debug log go (temporary!)
37 uint8_t b0: 1; uint8_t b1: 1; uint8_t b2: 1; uint8_t b3: 1;
38 uint8_t b4: 1; uint8_t b5: 1; uint8_t b6: 1; uint8_t b7: 1;
73 uint8_t etoi: 1; // Enable Timer Over
74 uint8_t eoci: 1; // Enable Output Compare
75 uint8_t eici: 1; // Enable Input Capture
76 uint8_t tof: 1; // Timer Over
77 uint8_t ocf: 1; // Output Compare
78 uint8_t icf: 1; // Input Capture
95 uint16_t pc; // 63701 PC register
96 uint16_t x; // 63701 X index register
97 uint16_t s; // 63701 System stack pointer
98 uint8_t cc; // 63701 Condition Code register
99 // uint8_t a; // 63701 A register
100 // uint8_t b; // 63701 B register
101 WordReg d; // 63701 A & B registers (A is hi, B is lo)
102 TCSR tcsr; // 63701 Timer control/Status register
103 Word counter; // 63701 Counter register
104 Word outputCompare; // 63701 Output Compare register
110 uint8_t cWriteLatch; // Counter write latch
111 uint8_t cReadLatch; // Counter read latch
112 bool tcsrWasRead; // TCSR was read flag
113 uint64_t clock; // 63701 clock
114 uint8_t (* RdMem)(uint16_t); // Address of uint8 read routine
115 void (* WrMem)(uint16_t, uint8_t); // Address of uint8 write routine
116 uint32_t cpuFlags; // v63701 IRQ/RESET flags
117 uint32_t clockOverrun; // Amount of overflow between runs
120 // Function prototypes
122 void Execute63701(V63701REGS *, uint32_t); // Function to execute 63701 instructions
123 uint64_t GetCurrentV63701Clock(void); // Get the clock of the currently executing CPU
125 // It's the responsibility of the user to call these from their R/W handlers.
126 // These are usually memory mapped at $00-$1F.
127 uint8_t InternalRegisterRead(uint16_t);
128 void InternalRegisterWrite(uint16_t, uint8_t);
130 // These functions must be implemented by the user...
131 extern uint8_t V63701ReadPort1(void);
132 extern uint8_t V63701ReadPort2(void);
133 extern void V63701WritePort1(uint8_t);
134 extern void V63701WritePort2(uint8_t);
136 #endif // __V63701_H__