70357ce5 |
1 | /*****************************************************************************/\r |
2 | /* FAME Fast and Accurate Motorola 68000 Emulation Core */\r |
3 | /* (c) 2005 Oscar Orallo Pelaez */\r |
4 | /* Version: 1.24 */\r |
5 | /* Date: 08-20-2005 */\r |
6 | /* See FAME.HTML for documentation and license information */\r |
7 | /*****************************************************************************/\r |
8 | \r |
9 | #ifndef __FAME_H__\r |
10 | #define __FAME_H__\r |
11 | \r |
12 | #ifdef __cplusplus\r |
13 | extern "C" {\r |
14 | #endif\r |
15 | \r |
16 | // PicoDrive hacks\r |
17 | #define FAMEC_FETCHBITS 8\r |
18 | #define M68K_FETCHBANK1 (1 << FAMEC_FETCHBITS)\r |
19 | \r |
20 | //#define M68K_RUNNING 0x01\r |
03e4f2a3 |
21 | #define FM68K_HALTED 0x80\r |
22 | //#define M68K_WAITING 0x04\r |
23 | //#define M68K_DISABLE 0x20\r |
24 | //#define M68K_FAULTED 0x40\r |
25 | #define FM68K_EMULATE_GROUP_0 0x02\r |
26 | #define FM68K_EMULATE_TRACE 0x08\r |
27 | #define FM68K_DO_TRACE 0x10\r |
70357ce5 |
28 | \r |
29 | \r |
30 | /************************************/\r |
31 | /* General library defines */\r |
32 | /************************************/\r |
33 | \r |
34 | #ifndef M68K_OK\r |
35 | #define M68K_OK 0\r |
36 | #endif\r |
37 | #ifndef M68K_RUNNING\r |
38 | #define M68K_RUNNING 1\r |
39 | #endif\r |
40 | #ifndef M68K_NO_SUP_ADDR_SPACE\r |
41 | #define M68K_NO_SUP_ADDR_SPACE 2\r |
42 | #endif\r |
43 | #ifndef M68K_DOUBLE_BUS_FAULT\r |
44 | #define M68K_DOUBLE_BUS_FAULT -1\r |
45 | #endif\r |
46 | #ifndef M68K_INV_REG\r |
47 | #define M68K_INV_REG -1\r |
48 | #endif\r |
49 | \r |
50 | /* Hardware interrupt state */\r |
51 | \r |
52 | #ifndef M68K_IRQ_LEVEL_ERROR\r |
53 | #define M68K_IRQ_LEVEL_ERROR -1\r |
54 | #endif\r |
55 | #ifndef M68K_IRQ_INV_PARAMS\r |
56 | #define M68K_IRQ_INV_PARAMS -2\r |
57 | #endif\r |
58 | \r |
59 | /* Defines to specify hardware interrupt type */\r |
60 | \r |
61 | #ifndef M68K_AUTOVECTORED_IRQ\r |
62 | #define M68K_AUTOVECTORED_IRQ -1\r |
63 | #endif\r |
64 | #ifndef M68K_SPURIOUS_IRQ\r |
65 | #define M68K_SPURIOUS_IRQ -2\r |
66 | #endif\r |
67 | \r |
68 | #ifndef M68K_AUTO_LOWER_IRQ\r |
69 | #define M68K_AUTO_LOWER_IRQ 1\r |
70 | #endif\r |
71 | #ifndef M68K_MANUAL_LOWER_IRQ\r |
72 | #define M68K_MANUAL_LOWER_IRQ 0\r |
73 | #endif\r |
74 | \r |
75 | /* Defines to specify address space */\r |
76 | \r |
77 | #ifndef M68K_SUP_ADDR_SPACE\r |
78 | #define M68K_SUP_ADDR_SPACE 0\r |
79 | #endif\r |
80 | #ifndef M68K_USER_ADDR_SPACE\r |
81 | #define M68K_USER_ADDR_SPACE 2\r |
82 | #endif\r |
83 | #ifndef M68K_PROG_ADDR_SPACE\r |
84 | #define M68K_PROG_ADDR_SPACE 0\r |
85 | #endif\r |
86 | #ifndef M68K_DATA_ADDR_SPACE\r |
87 | #define M68K_DATA_ADDR_SPACE 1\r |
88 | #endif\r |
89 | \r |
90 | \r |
91 | /*******************/\r |
92 | /* Data definition */\r |
93 | /*******************/\r |
94 | \r |
70357ce5 |
95 | typedef union\r |
96 | {\r |
97 | unsigned char B;\r |
98 | signed char SB;\r |
99 | unsigned short W;\r |
100 | signed short SW;\r |
101 | unsigned int D;\r |
102 | signed int SD;\r |
103 | } famec_union32;\r |
104 | \r |
70357ce5 |
105 | /* M68K CPU CONTEXT */\r |
106 | typedef struct\r |
107 | {\r |
108 | unsigned int (*read_byte )(unsigned int a);\r |
109 | unsigned int (*read_word )(unsigned int a);\r |
110 | unsigned int (*read_long )(unsigned int a);\r |
111 | void (*write_byte)(unsigned int a,unsigned char d);\r |
112 | void (*write_word)(unsigned int a,unsigned short d);\r |
113 | void (*write_long)(unsigned int a,unsigned int d);\r |
114 | void (*reset_handler)(void);\r |
115 | void (*iack_handler)(unsigned level);\r |
116 | famec_union32 dreg[8];\r |
117 | famec_union32 areg[8];\r |
118 | unsigned asp;\r |
119 | unsigned pc;\r |
120 | unsigned char interrupts[8];\r |
121 | unsigned short sr;\r |
122 | unsigned short execinfo;\r |
123 | // PD extension\r |
124 | int io_cycle_counter; // cycles left\r |
125 | unsigned int Fetch[M68K_FETCHBANK1];\r |
126 | } M68K_CONTEXT;\r |
127 | \r |
128 | extern M68K_CONTEXT *g_m68kcontext;\r |
129 | \r |
130 | /************************/\r |
131 | /* Function definition */\r |
132 | /************************/\r |
133 | \r |
134 | /* General purpose functions */\r |
03e4f2a3 |
135 | void fm68k_init(void);\r |
136 | int fm68k_reset(void);\r |
8022f53d |
137 | int fm68k_emulate(int n, int dualcore);\r |
03e4f2a3 |
138 | int fm68k_would_interrupt(void); // to be called from fm68k_emulate()\r |
70357ce5 |
139 | \r |
03e4f2a3 |
140 | unsigned fm68k_get_pc(M68K_CONTEXT *context);\r |
70357ce5 |
141 | \r |
142 | \r |
143 | #ifdef __cplusplus\r |
144 | }\r |
145 | #endif\r |
146 | \r |
147 | #endif\r |