1 /* 2 * libtilemcore - Graphing calculator emulation library 3 * 4 * Copyright (C) 2009 Benjamin Moody 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public License 8 * as published by the Free Software Foundation; either version 2.1 of 9 * the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, see 18 * <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef _TILEM_Z80_H 22 #define _TILEM_Z80_H 23 24 /* Internal Z80 data structures */ 25 26 struct _TilemZ80Timer { 27 int next, prev; 28 dword count; 29 dword period; 30 TilemZ80TimerFunc callback; 31 void* callbackdata; 32 }; 33 34 struct _TilemZ80Breakpoint { 35 int next, prev; 36 int type; 37 dword start; 38 dword end; 39 dword mask; 40 TilemZ80BreakpointFunc testfunc; 41 void* testdata; 42 }; 43 44 /* Useful definitions */ 45 46 #define AF (calc->z80.r.af.d) 47 #define BC (calc->z80.r.bc.d) 48 #define DE (calc->z80.r.de.d) 49 #define HL (calc->z80.r.hl.d) 50 #define AF2 (calc->z80.r.af2.d) 51 #define BC2 (calc->z80.r.bc2.d) 52 #define DE2 (calc->z80.r.de2.d) 53 #define HL2 (calc->z80.r.hl2.d) 54 #define IX (calc->z80.r.ix.d) 55 #define IY (calc->z80.r.iy.d) 56 #define SP (calc->z80.r.sp.d) 57 #define PC (calc->z80.r.pc.d) 58 #define IR (calc->z80.r.ir.d) 59 60 #define A (calc->z80.r.af.b.h) 61 #define F (calc->z80.r.af.b.l) 62 #define B (calc->z80.r.bc.b.h) 63 #define C (calc->z80.r.bc.b.l) 64 #define D (calc->z80.r.de.b.h) 65 #define E (calc->z80.r.de.b.l) 66 #define H (calc->z80.r.hl.b.h) 67 #define L (calc->z80.r.hl.b.l) 68 #define IXh (calc->z80.r.ix.b.h) 69 #define IXl (calc->z80.r.ix.b.l) 70 #define IYh (calc->z80.r.iy.b.h) 71 #define IYl (calc->z80.r.iy.b.l) 72 #define I (calc->z80.r.ir.b.h) 73 #define Rh (calc->z80.r.r7) 74 #define Rl (calc->z80.r.ir.b.l) 75 #define R ((Rl & 0x7f) | Rh) 76 77 #ifdef DISABLE_Z80_WZ_REGISTER 78 # define WZ temp_wz.d 79 # define WZ2 temp_wz2.d 80 # define W temp_wz.b.h 81 # define Z temp_wz.b.l 82 #else 83 # define WZ (calc->z80.r.wz.d) 84 # define WZ2 (calc->z80.r.wz2.d) 85 # define W (calc->z80.r.wz.b.h) 86 # define Z (calc->z80.r.wz.b.l) 87 #endif 88 89 #define IFF1 (calc->z80.r.iff1) 90 #define IFF2 (calc->z80.r.iff2) 91 #define IM (calc->z80.r.im) 92 93 #define FLAG_S 0x80 94 #define FLAG_Z 0x40 95 #define FLAG_Y 0x20 96 #define FLAG_H 0x10 97 #define FLAG_X 0x08 98 #define FLAG_P 0x04 99 #define FLAG_V FLAG_P 100 #define FLAG_N 0x02 101 #define FLAG_C 0x01 102 103 #define BCw (calc->z80.r.bc.w.l) 104 #define DEw (calc->z80.r.de.w.l) 105 #define HLw (calc->z80.r.hl.w.l) 106 #define SPw (calc->z80.r.sp.w.l) 107 #define IXw (calc->z80.r.ix.w.l) 108 #define IYw (calc->z80.r.iy.w.l) 109 110 #endif 111