48 #define Z80_CATCH_HALT
105 Z80_STATUS_ED_UNDEFINED,
166#define Z80_S_FLAG_SHIFT 7
167#define Z80_Z_FLAG_SHIFT 6
168#define Z80_Y_FLAG_SHIFT 5
169#define Z80_H_FLAG_SHIFT 4
170#define Z80_X_FLAG_SHIFT 3
171#define Z80_PV_FLAG_SHIFT 2
172#define Z80_N_FLAG_SHIFT 1
173#define Z80_C_FLAG_SHIFT 0
175#define Z80_S_FLAG (1 << Z80_S_FLAG_SHIFT)
176#define Z80_Z_FLAG (1 << Z80_Z_FLAG_SHIFT)
177#define Z80_Y_FLAG (1 << Z80_Y_FLAG_SHIFT)
178#define Z80_H_FLAG (1 << Z80_H_FLAG_SHIFT)
179#define Z80_X_FLAG (1 << Z80_X_FLAG_SHIFT)
180#define Z80_PV_FLAG (1 << Z80_PV_FLAG_SHIFT)
181#define Z80_N_FLAG (1 << Z80_N_FLAG_SHIFT)
182#define Z80_C_FLAG (1 << Z80_C_FLAG_SHIFT)
184#define Z80_P_FLAG_SHIFT Z80_PV_FLAG_SHIFT
185#define Z80_V_FLAG_SHIFT Z80_PV_FLAG_SHIFT
186#define Z80_P_FLAG Z80_PV_FLAG
187#define Z80_V_FLAG Z80_PV_FLAG
194 Z80_INTERRUPT_MODE_0,
195 Z80_INTERRUPT_MODE_1,
205 unsigned char byte[14];
206 unsigned short word[7];
209 unsigned short alternates[4];
211 int i, r, pc, iff1, iff2, im;
215 void * register_table[16];
216 void * dd_register_table[16];
217 void * fd_register_table[16];
229 typedef int (*ReadByteCallback)(
void * context,
int addr);
230 typedef void (*WriteByteCallback)(
void * context,
int addr,
int value);
231 typedef int (*ReadWordCallback)(
void * context,
int addr);
232 typedef void (*WriteWordCallback)(
void * context,
int addr,
int value);
233 typedef int (*ReadIOCallback)(
void * context,
int addr);
234 typedef void (*WriteIOCallback)(
void * context,
int addr,
int value);
236 void setCallbacks(
void * context, ReadByteCallback readByte, WriteByteCallback writeByte, ReadWordCallback readWord, WriteWordCallback writeWord, ReadIOCallback readIO, WriteIOCallback writeIO) {
238 m_readByte = readByte;
239 m_writeByte = writeByte;
240 m_readWord = readWord;
241 m_writeWord = writeWord;
254 int IRQ(
int data_on_bus);
266 uint8_t readRegByte(
int reg) {
return state.registers.byte[reg]; }
267 void writeRegByte(
int reg, uint8_t value) { state.registers.byte[reg] = value; }
269 uint16_t readRegWord(
int reg) {
return state.registers.word[reg]; }
270 void writeRegWord(
int reg, uint16_t value) { state.registers.word[reg] = value; }
272 uint16_t getPC() {
return state.pc; }
273 void setPC(uint16_t value) { state.pc = value; }
275 int getStatus() {
return state.status; }
276 int getIM() {
return state.im; }
277 int getIFF1() {
return state.iff1; }
278 int getIFF2() {
return state.iff2; }
282 int intemulate(
int opcode,
int elapsed_cycles);
290 ReadByteCallback m_readByte;
291 WriteByteCallback m_writeByte;
292 ReadWordCallback m_readWord;
293 WriteWordCallback m_writeWord;
294 ReadIOCallback m_readIO;
295 WriteIOCallback m_writeIO;