1 /* Multi-Z80 32 Bit emulator */
3 /* Copyright 1996, Neil Bradley, All rights reserved
7 * The mZ80 emulator may be distributed in unmodified form to any medium.
9 * mZ80 May not be sold, or sold as a part of a commercial package without
10 * the express written permission of Neil Bradley (neil@synthcom.com). This
13 * Modified versions of mZ80 may not be publicly redistributed without author
14 * approval (neil@synthcom.com). This includes distributing via a publicly
15 * accessible LAN. You may make your own source modifications and distribute
16 * mZ80 in object only form.
18 * mZ80 Licensing for commercial applications is available. Please email
19 * neil@synthcom.com for details.
21 * Synthcom Systems, Inc, and Neil Bradley will not be held responsible for
22 * any damage done by the use of mZ80. It is purely "as-is".
24 * If you use mZ80 in a freeware application, credit in the following text:
26 * "Multi-Z80 CPU emulator by Neil Bradley (neil@synthcom.com)"
28 * must accompany the freeware application within the application itself or
29 * in the documentation.
33 * If you find problems with mZ80, please email the author so they can get
34 * resolved. If you find a bug and fix it, please also email the author so
35 * that those bug fixes can be propogated to the installed base of mZ80
36 * users. If you find performance improvements or problems with mZ80, please
37 * email the author with your changes/suggestions and they will be rolled in
38 * with subsequent releases of mZ80.
40 * The whole idea of this emulator is to have the fastest available 32 bit
41 * Multi-z80 emulator for the PC, giving maximum performance.
44 /* General z80 based defines */
50 #define UINT32 unsigned long int
54 #define UINT16 unsigned short int
58 #define UINT8 unsigned char
62 #define INT32 signed long int
66 #define INT16 signed short int
70 #define INT8 signed char
77 #ifndef _MEMORYREADWRITEBYTE_
78 #define _MEMORYREADWRITEBYTE_
80 struct MemoryWriteByte
84 void (*memoryCall
)(UINT32
, UINT8
, struct MemoryWriteByte
*);
92 UINT8 (*memoryCall
)(UINT32
, struct MemoryReadByte
*);
96 #endif // _MEMORYREADWRITEBYTE_
102 void (*IOCall
)(UINT16
, UINT8
, struct z80PortWrite
*);
110 UINT16 (*IOCall
)(UINT16
, struct z80PortRead
*);
127 #ifdef WORDS_BIGENDIAN
139 #define z80AF z80af.af
140 #define z80A z80af.half.a
141 #define z80F z80af.half.f
149 #ifdef WORDS_BIGENDIAN
161 #define z80BC z80bc.bc
162 #define z80B z80bc.half.b
163 #define z80C z80bc.half.c
171 #ifdef WORDS_BIGENDIAN
183 #define z80DE z80de.de
184 #define z80D z80de.half.d
185 #define z80E z80de.half.e
193 #ifdef WORDS_BIGENDIAN
205 #define z80HL z80hl.hl
206 #define z80H z80hl.half.h
207 #define z80L z80hl.half.l
209 #define z80SP z80sp.sp
217 #ifdef WORDS_BIGENDIAN
229 #define z80IX z80ix.ix
230 #define z80XH z80ix.half.xh
231 #define z80XL z80ix.half.xl
239 #ifdef WORDS_BIGENDIAN
251 #define z80IY z80iy.iy
252 #define z80YH z80iy.half.yh
253 #define z80YL z80iy.half.yl
258 struct MemoryReadByte
*z80MemRead
;
259 struct MemoryWriteByte
*z80MemWrite
;
260 struct z80PortRead
*z80IoRead
;
261 struct z80PortWrite
*z80IoWrite
;
262 UINT32 z80clockticks
;
264 UINT32 z80interruptMode
;
287 // These are the enumerations used for register access. DO NOT ALTER THEIR
288 // ORDER! It must match the same order as in the mz80.c/mz80.asm files!
320 CPUREG_Z80_HALFCARRY
,
331 extern UINT32
mz80exec(UINT32
);
332 extern UINT32
mz80GetContextSize(void);
333 extern UINT32
mz80GetElapsedTicks(UINT32
);
334 extern void mz80ReleaseTimeslice(void);
335 extern void mz80GetContext(void *);
336 extern void mz80SetContext(void *);
337 extern void mz80reset(void);
338 extern void mz80ClearPendingInterrupt(void);
339 extern UINT32
mz80int(UINT32
);
340 extern UINT32
mz80nmi(void);
341 extern void mz80init(void);
342 extern UINT32 z80intAddr
;
343 extern UINT32 z80nmiAddr
;
345 // Debugger useful routines
347 extern UINT8
mz80SetRegisterValue(void *, UINT32
, UINT32
);
348 extern UINT32
mz80GetRegisterValue(void *, UINT32
);
349 extern UINT32
mz80GetRegisterTextValue(void *, UINT32
, UINT8
*);
350 extern UINT8
*mz80GetRegisterName(UINT32
);
352 // Memory/IO read/write commands
363 #define VALUE_DWORD 2
370 extern void mz80WriteValue(UINT8 bWhat
, UINT32 dwAddr
, UINT32 dwData
);
371 extern UINT32
mz80ReadValue(UINT8 bWhat
, UINT32 dwAddr
);
375 #define Z80_FLAG_CARRY 0x01
376 #define Z80_FLAG_NEGATIVE 0x02
377 #define Z80_FLAG_OVERFLOW_PARITY 0x04
378 #define Z80_FLAG_UNDEFINED1 0x08
379 #define Z80_FLAG_HALF_CARRY 0x10
380 #define Z80_FLAG_UNDEFINED2 0x20
381 #define Z80_FLAG_ZERO 0x40
382 #define Z80_FLAG_SIGN 0x80
387 typedef struct mz80context CONTEXTMZ80
;