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