]> Shamusworld >> Repos - thunder/blob - src/v6809.h
ae8a33754efbab92c42927d80e2b6ca511004993
[thunder] / src / v6809.h
1 //
2 // Virtual 6809 Header file
3 //
4 // by James L. Hammons
5 //
6 // (C) 1997, 2004 Underground Software
7 //
8
9 #ifndef __V6809_H__
10 #define __V6809_H__
11
12 #include <stdint.h>
13
14 // Useful defines
15
16 #define FLAG_E          0x80            // Entire
17 #define FLAG_F          0x40            // Fast IRQ
18 #define FLAG_H          0x20            // Half carry
19 #define FLAG_I          0x10            // IRQ
20 #define FLAG_N          0x08            // Negative
21 #define FLAG_Z          0x04            // Zero
22 #define FLAG_V          0x02            // oVerflow
23 #define FLAG_C          0x01            // Carry
24
25 #define V6809_ASSERT_LINE_RESET         0x0001          // v6809 RESET line
26 #define V6809_ASSERT_LINE_IRQ           0x0002          // v6809 IRQ line
27 #define V6809_ASSERT_LINE_FIRQ          0x0004          // v6809 FIRQ line
28 #define V6809_ASSERT_LINE_NMI           0x0008          // v6809 NMI line
29 #define V6809_STATE_SYNC                        0x0010          // v6809 SYNC line
30 #define V6809_STATE_ILLEGAL_INST        0x0020          // Illegal instruction executed flag
31
32 //#define V6809_START_DEBUG_LOG EQU     0020h           // Debug log go (temporary!)
33
34 // Useful structs
35
36 struct V6809REGS
37 {
38         uint16_t pc;                                    // 6809 PC register
39         uint16_t x;                                             // 6809 X index register
40         uint16_t y;                                             // 6809 Y index register
41         uint16_t s;                                             // 6809 System stack pointer
42         uint16_t u;                                             // 6809 User stack pointer
43         uint8_t cc;                                             // 6809 Condition Code register
44         uint8_t a;                                              // 6809 A register
45         uint8_t b;                                              // 6809 B register
46         uint8_t dp;                                             // 6809 Direct Page register
47         uint64_t clock;                                 // 6809 clock (@ 1 MHz, wraps at 570842 years)
48         uint8_t (* RdMem)(uint16_t);    // Address of uint8 read routine
49         void (* WrMem)(uint16_t, uint8_t);      // Address of uint8 write routine
50         uint32_t cpuFlags;                              // v6809 IRQ/RESET flags
51         uint32_t clockOverrun;
52 };
53
54 // Function prototypes
55
56 void Execute6809(V6809REGS *, uint32_t);                // Function to execute 6809 instructions
57 uint64_t GetCurrentV6809Clock(void);                    // Get the clock of the currently executing CPU
58 uint16_t GetCurrentV6809PC(void);                               // Get the PC of the currently executing CPU
59 void SetLineOfCurrentV6809(uint32_t line);              // Set a line of the currently executing CPU
60 void ClearLineOfCurrentV6809(uint32_t line);    // Clear a line of the currently executing CPU
61
62 #endif  // __V6809_H__
63