| 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 |
| 21 | #define M68K_HALTED 0x80\r |
| 22 | #define M68K_WAITING 0x04\r |
| 23 | #define M68K_DISABLE 0x20\r |
| 24 | #define M68K_FAULTED 0x40\r |
| 25 | #define M68K_EMULATE_GROUP_0 0x02\r |
| 26 | #define M68K_EMULATE_TRACE 0x08\r |
| 27 | #define M68K_DO_TRACE 0x10\r |
| 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 |
| 95 | /* M68K registers */\r |
| 96 | typedef enum {\r |
| 97 | M68K_REG_D0=0,\r |
| 98 | M68K_REG_D1,\r |
| 99 | M68K_REG_D2,\r |
| 100 | M68K_REG_D3,\r |
| 101 | M68K_REG_D4,\r |
| 102 | M68K_REG_D5,\r |
| 103 | M68K_REG_D6,\r |
| 104 | M68K_REG_D7,\r |
| 105 | M68K_REG_A0,\r |
| 106 | M68K_REG_A1,\r |
| 107 | M68K_REG_A2,\r |
| 108 | M68K_REG_A3,\r |
| 109 | M68K_REG_A4,\r |
| 110 | M68K_REG_A5,\r |
| 111 | M68K_REG_A6,\r |
| 112 | M68K_REG_A7,\r |
| 113 | M68K_REG_ASP,\r |
| 114 | M68K_REG_PC,\r |
| 115 | M68K_REG_SR\r |
| 116 | } m68k_register;\r |
| 117 | \r |
| 118 | typedef union\r |
| 119 | {\r |
| 120 | unsigned char B;\r |
| 121 | signed char SB;\r |
| 122 | unsigned short W;\r |
| 123 | signed short SW;\r |
| 124 | unsigned int D;\r |
| 125 | signed int SD;\r |
| 126 | } famec_union32;\r |
| 127 | \r |
| 128 | /* M68K CPU CONTEXT */\r |
| 129 | typedef struct\r |
| 130 | {\r |
| 131 | unsigned int (*read_byte )(unsigned int a);\r |
| 132 | unsigned int (*read_word )(unsigned int a);\r |
| 133 | unsigned int (*read_long )(unsigned int a);\r |
| 134 | void (*write_byte)(unsigned int a,unsigned char d);\r |
| 135 | void (*write_word)(unsigned int a,unsigned short d);\r |
| 136 | void (*write_long)(unsigned int a,unsigned int d);\r |
| 137 | void (*reset_handler)(void);\r |
| 138 | void (*iack_handler)(unsigned level);\r |
| 139 | famec_union32 dreg[8];\r |
| 140 | famec_union32 areg[8];\r |
| 141 | unsigned asp;\r |
| 142 | unsigned pc;\r |
| 143 | unsigned char interrupts[8];\r |
| 144 | unsigned short sr;\r |
| 145 | unsigned short execinfo;\r |
| 146 | // PD extension\r |
| 147 | int io_cycle_counter; // cycles left\r |
| 148 | unsigned int Fetch[M68K_FETCHBANK1];\r |
| 149 | } M68K_CONTEXT;\r |
| 150 | \r |
| 151 | extern M68K_CONTEXT *g_m68kcontext;\r |
| 152 | \r |
| 153 | /************************/\r |
| 154 | /* Function definition */\r |
| 155 | /************************/\r |
| 156 | \r |
| 157 | /* General purpose functions */\r |
| 158 | void m68k_init(void);\r |
| 159 | int m68k_reset(void);\r |
| 160 | int m68k_emulate(int n);\r |
| 161 | \r |
| 162 | unsigned m68k_get_pc(M68K_CONTEXT *context);\r |
| 163 | unsigned m68k_get_register(M68K_CONTEXT *context, m68k_register reg);\r |
| 164 | unsigned m68k_set_register(M68K_CONTEXT *context, m68k_register reg, unsigned value);\r |
| 165 | \r |
| 166 | \r |
| 167 | #ifdef __cplusplus\r |
| 168 | }\r |
| 169 | #endif\r |
| 170 | \r |
| 171 | #endif\r |