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