2 // C interface to the UAE core
5 // (C) 2011 Underground Software
7 // Most of these functions are in place to help make it easy to replace the
8 // Musashi core with my bastardized UAE one. :-)
11 #ifndef __M68KINTERFACE_H__
12 #define __M68KINTERFACE_H__
18 /* Registers used by m68k_get_reg() and m68k_set_reg() */
22 M68K_REG_D0, /* Data registers */
30 M68K_REG_A0, /* Address registers */
38 M68K_REG_PC, /* Program Counter */
39 M68K_REG_SR, /* Status Register */
40 M68K_REG_SP, /* The current Stack Pointer (located in A7) */
41 M68K_REG_USP, /* User Stack Pointer */
43 /* Assumed registers */
44 /* These are cheat registers which emulate the 1-longword prefetch
45 * present in the 68000 and 68010.
47 M68K_REG_PREF_ADDR, /* Last prefetch address */
48 M68K_REG_PREF_DATA, /* Last prefetch data */
50 /* Convenience registers */
51 M68K_REG_PPC, /* Previous value in the program counter */
52 M68K_REG_IR, /* Instruction register */
55 /* Special interrupt acknowledge values.
56 * Use these as special returns from the interrupt acknowledge callback
57 * (specified later in this header).
60 /* Causes an interrupt autovector (0x18 + interrupt level) to be taken.
61 * This happens in a real 68K if VPA or AVEC is asserted during an interrupt
62 * acknowledge cycle instead of DTACK.
64 #define M68K_INT_ACK_AUTOVECTOR 0xFFFFFFFF
66 /* Causes the spurious interrupt vector (0x18) to be taken
67 * This happens in a real 68K if BERR is asserted during the interrupt
68 * acknowledge cycle (i.e. no devices responded to the acknowledge).
70 #define M68K_INT_ACK_SPURIOUS 0xFFFFFFFE
72 void m68k_set_cpu_type(unsigned int);
73 void m68k_pulse_reset(void);
74 int m68k_execute(int num_cycles);
75 void m68k_set_irq(unsigned int int_level);
77 // Functions that MUST be implemented by the user:
80 unsigned int m68k_read_memory_8(unsigned int address);
81 unsigned int m68k_read_memory_16(unsigned int address);
82 unsigned int m68k_read_memory_32(unsigned int address);
85 void m68k_write_memory_8(unsigned int address, unsigned int value);
86 void m68k_write_memory_16(unsigned int address, unsigned int value);
87 void m68k_write_memory_32(unsigned int address, unsigned int value);
89 int irq_ack_handler(int);
91 // Convenience functions
93 /* Peek at the internals of a CPU context. This can either be a context
94 * retrieved using m68k_get_context() or the currently running context.
95 * If context is NULL, the currently running CPU context will be used.
97 unsigned int m68k_get_reg(void * context, m68k_register_t reg);
99 /* Poke values into the internals of the currently running CPU context */
100 void m68k_set_reg(m68k_register_t reg, unsigned int value);
102 // Dummy functions, for now...
104 /* Check if an instruction is valid for the specified CPU type */
105 unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type);
107 /* Disassemble 1 instruction using the epecified CPU type at pc. Stores
108 * disassembly in str_buff and returns the size of the instruction in bytes.
110 unsigned int m68k_disassemble(char * str_buff, unsigned int pc, unsigned int cpu_type);
112 /* These functions let you read/write/modify the number of cycles left to run
113 * while m68k_execute() is running.
114 * These are useful if the 68k accesses a memory-mapped port on another device
115 * that requires immediate processing by another CPU.
117 int m68k_cycles_run(void); // Number of cycles run so far
118 int m68k_cycles_remaining(void); // Number of cycles left
119 void m68k_modify_timeslice(int cycles); // Modify cycles left
120 void m68k_end_timeslice(void); // End timeslice now
126 #endif // __M68KINTERFACE_H__