1 /*****************************************************************************/
\r
2 /* FAME Fast and Accurate Motorola 68000 Emulation Core */
\r
3 /* (c) 2005 Oscar Orallo Pelaez */
\r
5 /* Date: 08-20-2005 */
\r
6 /* See FAME.HTML for documentation and license information */
\r
7 /*****************************************************************************/
\r
17 #define FAMEC_FETCHBITS 8
\r
18 #define M68K_FETCHBANK1 (1 << FAMEC_FETCHBITS)
\r
20 //#define M68K_RUNNING 0x01
\r
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
30 /************************************/
\r
31 /* General library defines */
\r
32 /************************************/
\r
37 #ifndef M68K_RUNNING
\r
38 #define M68K_RUNNING 1
\r
40 #ifndef M68K_NO_SUP_ADDR_SPACE
\r
41 #define M68K_NO_SUP_ADDR_SPACE 2
\r
43 #ifndef M68K_DOUBLE_BUS_FAULT
\r
44 #define M68K_DOUBLE_BUS_FAULT -1
\r
46 #ifndef M68K_INV_REG
\r
47 #define M68K_INV_REG -1
\r
50 /* Hardware interrupt state */
\r
52 #ifndef M68K_IRQ_LEVEL_ERROR
\r
53 #define M68K_IRQ_LEVEL_ERROR -1
\r
55 #ifndef M68K_IRQ_INV_PARAMS
\r
56 #define M68K_IRQ_INV_PARAMS -2
\r
59 /* Defines to specify hardware interrupt type */
\r
61 #ifndef M68K_AUTOVECTORED_IRQ
\r
62 #define M68K_AUTOVECTORED_IRQ -1
\r
64 #ifndef M68K_SPURIOUS_IRQ
\r
65 #define M68K_SPURIOUS_IRQ -2
\r
68 #ifndef M68K_AUTO_LOWER_IRQ
\r
69 #define M68K_AUTO_LOWER_IRQ 1
\r
71 #ifndef M68K_MANUAL_LOWER_IRQ
\r
72 #define M68K_MANUAL_LOWER_IRQ 0
\r
75 /* Defines to specify address space */
\r
77 #ifndef M68K_SUP_ADDR_SPACE
\r
78 #define M68K_SUP_ADDR_SPACE 0
\r
80 #ifndef M68K_USER_ADDR_SPACE
\r
81 #define M68K_USER_ADDR_SPACE 2
\r
83 #ifndef M68K_PROG_ADDR_SPACE
\r
84 #define M68K_PROG_ADDR_SPACE 0
\r
86 #ifndef M68K_DATA_ADDR_SPACE
\r
87 #define M68K_DATA_ADDR_SPACE 1
\r
91 /*******************/
\r
92 /* Data definition */
\r
93 /*******************/
\r
105 /* M68K CPU CONTEXT */
\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
120 unsigned char interrupts[8];
\r
122 unsigned short execinfo;
\r
124 int io_cycle_counter; // cycles left
\r
126 unsigned int Opcode;
\r
127 signed int cycles_needed;
\r
129 unsigned short *PC;
\r
130 unsigned long BasePC;
\r
131 unsigned int flag_C;
\r
132 unsigned int flag_V;
\r
133 unsigned int flag_NotZ;
\r
134 unsigned int flag_N;
\r
135 unsigned int flag_X;
\r
136 unsigned int flag_T;
\r
137 unsigned int flag_S;
\r
138 unsigned int flag_I;
\r
140 unsigned char not_polling;
\r
141 unsigned char pad[3];
\r
143 unsigned long Fetch[M68K_FETCHBANK1];
\r
146 extern M68K_CONTEXT *g_m68kcontext;
\r
148 /************************/
\r
149 /* Function definition */
\r
150 /************************/
\r
152 /* General purpose functions */
\r
153 void fm68k_init(void);
\r
154 int fm68k_reset(void);
\r
155 int fm68k_emulate(int n, int idle_mode);
\r
156 int fm68k_would_interrupt(void); // to be called from fm68k_emulate()
\r
158 unsigned fm68k_get_pc(M68K_CONTEXT *context);
\r