| 1 | /* ======================================================================== */\r |
| 2 | /* ========================= LICENSING & COPYRIGHT ======================== */\r |
| 3 | /* ======================================================================== */\r |
| 4 | /*\r |
| 5 | * MUSASHI\r |
| 6 | * Version 3.3\r |
| 7 | *\r |
| 8 | * A portable Motorola M680x0 processor emulation engine.\r |
| 9 | * Copyright 1998-2001 Karl Stenerud. All rights reserved.\r |
| 10 | *\r |
| 11 | * This code may be freely used for non-commercial purposes as long as this\r |
| 12 | * copyright notice remains unaltered in the source code and any binary files\r |
| 13 | * containing this code in compiled form.\r |
| 14 | *\r |
| 15 | * All other lisencing terms must be negotiated with the author\r |
| 16 | * (Karl Stenerud).\r |
| 17 | *\r |
| 18 | * The latest version of this code can be obtained at:\r |
| 19 | * http://kstenerud.cjb.net\r |
| 20 | */\r |
| 21 | \r |
| 22 | \r |
| 23 | // notaz: kill some stupid VC warnings\r |
| 24 | #ifndef __GNUC__\r |
| 25 | #pragma warning (disable:4100) // unreferenced formal parameter\r |
| 26 | #pragma warning (disable:4127) // conditional expression is constant\r |
| 27 | #pragma warning (disable:4245) // type conversion\r |
| 28 | #pragma warning (disable:4514) // unreferenced inline function has been removed\r |
| 29 | #endif\r |
| 30 | \r |
| 31 | \r |
| 32 | #ifndef M68KCONF__HEADER\r |
| 33 | #define M68KCONF__HEADER\r |
| 34 | \r |
| 35 | \r |
| 36 | /* Configuration switches.\r |
| 37 | * Use OPT_SPECIFY_HANDLER for configuration options that allow callbacks.\r |
| 38 | * OPT_SPECIFY_HANDLER causes the core to link directly to the function\r |
| 39 | * or macro you specify, rather than using callback functions whose pointer\r |
| 40 | * must be passed in using m68k_set_xxx_callback().\r |
| 41 | */\r |
| 42 | #define OPT_OFF 0\r |
| 43 | #define OPT_ON 1\r |
| 44 | #define OPT_SPECIFY_HANDLER 2\r |
| 45 | \r |
| 46 | \r |
| 47 | /* ======================================================================== */\r |
| 48 | /* ============================== MAME STUFF ============================== */\r |
| 49 | /* ======================================================================== */\r |
| 50 | \r |
| 51 | /* If you're compiling this for MAME, only change M68K_COMPILE_FOR_MAME\r |
| 52 | * to OPT_ON and use m68kmame.h to configure the 68k core.\r |
| 53 | */\r |
| 54 | #ifndef M68K_COMPILE_FOR_MAME\r |
| 55 | #define M68K_COMPILE_FOR_MAME OPT_OFF\r |
| 56 | #endif /* M68K_COMPILE_FOR_MAME */\r |
| 57 | \r |
| 58 | \r |
| 59 | #if M68K_COMPILE_FOR_MAME == OPT_OFF\r |
| 60 | \r |
| 61 | \r |
| 62 | /* ======================================================================== */\r |
| 63 | /* ============================= CONFIGURATION ============================ */\r |
| 64 | /* ======================================================================== */\r |
| 65 | \r |
| 66 | /* Turn ON if you want to use the following M68K variants */\r |
| 67 | #define M68K_EMULATE_008 OPT_OFF\r |
| 68 | #define M68K_EMULATE_010 OPT_OFF\r |
| 69 | #define M68K_EMULATE_EC020 OPT_OFF\r |
| 70 | #define M68K_EMULATE_020 OPT_OFF\r |
| 71 | #define M68K_EMULATE_040 OPT_OFF\r |
| 72 | \r |
| 73 | \r |
| 74 | /* If ON, the CPU will call m68k_read_immediate_xx() for immediate addressing\r |
| 75 | * and m68k_read_pcrelative_xx() for PC-relative addressing.\r |
| 76 | * If off, all read requests from the CPU will be redirected to m68k_read_xx()\r |
| 77 | */\r |
| 78 | #define M68K_SEPARATE_READS OPT_ON\r |
| 79 | \r |
| 80 | /* If ON, the CPU will call m68k_write_32_pd() when it executes move.l with a\r |
| 81 | * predecrement destination EA mode instead of m68k_write_32().\r |
| 82 | * To simulate real 68k behavior, m68k_write_32_pd() must first write the high\r |
| 83 | * word to [address+2], and then write the low word to [address].\r |
| 84 | */\r |
| 85 | #define M68K_SIMULATE_PD_WRITES OPT_OFF\r |
| 86 | \r |
| 87 | /* If ON, CPU will call the interrupt acknowledge callback when it services an\r |
| 88 | * interrupt.\r |
| 89 | * If off, all interrupts will be autovectored and all interrupt requests will\r |
| 90 | * auto-clear when the interrupt is serviced.\r |
| 91 | */\r |
| 92 | #define M68K_EMULATE_INT_ACK OPT_ON\r |
| 93 | #define M68K_INT_ACK_CALLBACK(A) your_int_ack_handler_function(A)\r |
| 94 | \r |
| 95 | \r |
| 96 | /* If ON, CPU will call the breakpoint acknowledge callback when it encounters\r |
| 97 | * a breakpoint instruction and it is running a 68010+.\r |
| 98 | */\r |
| 99 | #define M68K_EMULATE_BKPT_ACK OPT_OFF\r |
| 100 | #define M68K_BKPT_ACK_CALLBACK() your_bkpt_ack_handler_function()\r |
| 101 | \r |
| 102 | \r |
| 103 | /* If ON, the CPU will monitor the trace flags and take trace exceptions\r |
| 104 | */\r |
| 105 | #define M68K_EMULATE_TRACE OPT_ON\r |
| 106 | \r |
| 107 | \r |
| 108 | /* If ON, CPU will call the output reset callback when it encounters a reset\r |
| 109 | * instruction.\r |
| 110 | */\r |
| 111 | #define M68K_EMULATE_RESET OPT_OFF\r |
| 112 | #define M68K_RESET_CALLBACK() your_reset_handler_function()\r |
| 113 | \r |
| 114 | \r |
| 115 | /* If ON, CPU will call the callback when it encounters a cmpi.l #v, dn\r |
| 116 | * instruction.\r |
| 117 | */\r |
| 118 | #define M68K_CMPILD_HAS_CALLBACK OPT_OFF\r |
| 119 | #define M68K_CMPILD_CALLBACK(v,r) your_cmpild_handler_function(v,r)\r |
| 120 | \r |
| 121 | \r |
| 122 | /* If ON, CPU will call the callback when it encounters a rte\r |
| 123 | * instruction.\r |
| 124 | */\r |
| 125 | #define M68K_RTE_HAS_CALLBACK OPT_OFF\r |
| 126 | #define M68K_RTE_CALLBACK() your_rte_handler_function()\r |
| 127 | \r |
| 128 | \r |
| 129 | /* If ON, CPU will call the callback when it encounters a tas\r |
| 130 | * instruction.\r |
| 131 | */\r |
| 132 | #define M68K_TAS_HAS_CALLBACK OPT_ON\r |
| 133 | #define M68K_TAS_CALLBACK() your_tas_handler_function()\r |
| 134 | \r |
| 135 | \r |
| 136 | /* If ON, CPU will call the set fc callback on every memory access to\r |
| 137 | * differentiate between user/supervisor, program/data access like a real\r |
| 138 | * 68000 would. This should be enabled and the callback should be set if you\r |
| 139 | * want to properly emulate the m68010 or higher. (moves uses function codes\r |
| 140 | * to read/write data from different address spaces)\r |
| 141 | */\r |
| 142 | #define M68K_EMULATE_FC OPT_OFF\r |
| 143 | #define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A)\r |
| 144 | \r |
| 145 | \r |
| 146 | /* If ON, CPU will call the pc changed callback when it changes the PC by a\r |
| 147 | * large value. This allows host programs to be nicer when it comes to\r |
| 148 | * fetching immediate data and instructions on a banked memory system.\r |
| 149 | */\r |
| 150 | #define M68K_MONITOR_PC OPT_OFF\r |
| 151 | #define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A)\r |
| 152 | \r |
| 153 | \r |
| 154 | /* If ON, CPU will call the instruction hook callback before every\r |
| 155 | * instruction.\r |
| 156 | */\r |
| 157 | #define M68K_INSTRUCTION_HOOK OPT_OFF\r |
| 158 | //#define M68K_INSTRUCTION_HOOK OPT_SPECIFY_HANDLER\r |
| 159 | #define M68K_INSTRUCTION_CALLBACK() instruction_hook()\r |
| 160 | \r |
| 161 | \r |
| 162 | /* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */\r |
| 163 | #define M68K_EMULATE_PREFETCH OPT_OFF\r |
| 164 | \r |
| 165 | \r |
| 166 | /* If ON, the CPU will generate address error exceptions if it tries to\r |
| 167 | * access a word or longword at an odd address.\r |
| 168 | * NOTE: This is only emulated properly for 68000 mode.\r |
| 169 | */\r |
| 170 | #define M68K_EMULATE_ADDRESS_ERROR OPT_OFF\r |
| 171 | \r |
| 172 | \r |
| 173 | /* Turn ON to enable logging of illegal instruction calls.\r |
| 174 | * M68K_LOG_FILEHANDLE must be #defined to a stdio file stream.\r |
| 175 | * Turn on M68K_LOG_1010_1111 to log all 1010 and 1111 calls.\r |
| 176 | */\r |
| 177 | #define M68K_LOG_ENABLE OPT_OFF\r |
| 178 | #define M68K_LOG_1010_1111 OPT_OFF\r |
| 179 | #define M68K_LOG_FILEHANDLE some_file_handle\r |
| 180 | \r |
| 181 | \r |
| 182 | /* ----------------------------- COMPATIBILITY ---------------------------- */\r |
| 183 | \r |
| 184 | /* The following options set optimizations that violate the current ANSI\r |
| 185 | * standard, but will be compliant under the forthcoming C9X standard.\r |
| 186 | */\r |
| 187 | \r |
| 188 | \r |
| 189 | /* If ON, the enulation core will use 64-bit integers to speed up some\r |
| 190 | * operations.\r |
| 191 | */\r |
| 192 | #define M68K_USE_64_BIT OPT_OFF\r |
| 193 | \r |
| 194 | \r |
| 195 | /* Set to your compiler's static inline keyword to enable it, or\r |
| 196 | * set it to blank to disable it.\r |
| 197 | * If you define INLINE in the makefile, it will override this value.\r |
| 198 | * NOTE: not enabling inline functions will SEVERELY slow down emulation.\r |
| 199 | */\r |
| 200 | #ifndef INLINE\r |
| 201 | #define INLINE static __inline\r |
| 202 | #endif /* INLINE */\r |
| 203 | \r |
| 204 | #endif /* M68K_COMPILE_FOR_MAME */\r |
| 205 | \r |
| 206 | \r |
| 207 | /* ======================================================================== */\r |
| 208 | /* ============================== END OF FILE ============================= */\r |
| 209 | /* ======================================================================== */\r |
| 210 | \r |
| 211 | #endif /* M68KCONF__HEADER */\r |