1 /* Header file for the instruction set simulator.
2    Copyright (C) 1995  Frank D. Cringle.
3    Modifications for MMU and CP/M 3.1 Copyright (C) 2000/2003 by Andreas Gerlich
4 
5 
6 This file is part of yaze-ag - yet another Z80 emulator by ag.
7 
8 Yaze-ag is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your
11 option) any later version.
12 
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 
22 /* SEE limits and BYTE-, WORD- and FASTREG - defintions im MEM_MMU.h */
23 
24 /* #include <stdbool.h> */
25 
26 /* two sets of accumulator / flags */
27 extern WORD af[2];
28 extern int af_sel;
29 
30 /* two sets of 16-bit registers */
31 extern struct ddregs {
32 	WORD bc;
33 	WORD de;
34 	WORD hl;
35 } regs[2];
36 extern int regs_sel;
37 
38 extern WORD ir;
39 extern WORD ix;
40 extern WORD iy;
41 extern WORD sp;
42 extern WORD pc;
43 extern WORD IFF;
44 extern FASTREG tStates_save;
45 extern ui32 startTime_save, tStatesInSlice_save;
46 extern ui32 clockFrequency_save;
47 extern bool brakeini;
48 
49 /* see definitions for memory in mem_mmu.h */
50 
51 #ifdef DEBUG
52 extern volatile int stopsim;
53 #endif
54 
55 extern FASTWORK simz80(FASTREG PC);
56 extern FASTWORK simz80_with_tStates(FASTREG PC);
57 
58 #define FLAG_C	1
59 #define FLAG_N	2
60 #define FLAG_P	4
61 #define FLAG_H	16
62 #define FLAG_Z	64
63 #define FLAG_S	128
64 
65 #define SETFLAG(f,c)	AF = (c) ? AF | FLAG_ ## f : AF & ~FLAG_ ## f
66 #define TSTFLAG(f)	((AF & FLAG_ ## f) != 0)
67 
68 #define ldig(x)		((x) & 0xf)
69 #define hdig(x)		(((x)>>4)&0xf)
70 #define lreg(x)		((x)&0xff)
71 #define hreg(x)		(((x)>>8)&0xff)
72 
73 #define Setlreg(x, v)	x = (((x)&0xff00) | ((v)&0xff))
74 #define Sethreg(x, v)	x = (((x)&0xff) | (((v)&0xff) << 8))
75 
76 /* SEE functions for manipulating of memory in mem_mmu.h
77       line RAM, GetBYTE, GetWORD, PutBYTE, PutWORD, ....
78 */
79 
80 #ifndef BIOS
81 extern int in(unsigned int);
82 extern void out(unsigned int, unsigned char);
83 #define Input(port) in(port)
84 #define Output(port, value) out(port,value)
85 #else
86 /* Define these as macros or functions if you really want to simulate I/O */
87 #define Input(port)	0
88 #define Output(port, value)
89 #endif
90