00001
00002
00003
00004
00005 #ifndef __CPU_Z80_H__
00006 #define __CPU_Z80_H__
00007
00008 #include "mempage.h"
00009 #include "cpu/cycle.h"
00010
00011 #ifdef OE_ENDIAN_LITTLE
00012 union CPU_Z80_reg16 {
00013 uint16 val;
00014 struct {
00015 uint8 H;
00016 uint8 L;
00017 };
00018 };
00019 #else
00020 union CPU_Z80_reg16 {
00021 uint16 val;
00022 struct {
00023 uint8 L;
00024 uint8 H;
00025 };
00026 };
00027 #endif
00028
00029 enum { CPU_Z80_AF, CPU_Z80_BC, CPU_Z80_DE, CPU_Z80_HL };
00030
00031 struct CPU_Z80_STATE {
00032 };
00033
00034 struct CPU_Z80_DEBUG_STATE {
00035 };
00036
00037 struct CPU_Z80_ins {
00038 };
00039
00040 class CPU_Z80 {
00041 public:
00042 void init();
00043
00044
00045 void reset();
00046
00047 CPU_CYCLE_COUNT cycles;
00048 void cycle(dword numleft);
00049
00050 void save_state(CPU_Z80_STATE *foo);
00051 void restore_state(CPU_Z80_STATE *foo);
00052
00053
00054 void set_debug_mode(uint16 mode);
00055 char *debug_str(CPU_Z80_DEBUG_STATE *s);
00056 CPU_DBGINF dbg;
00057 CPU_Z80_DEBUG_STATE dbg_iop_state;
00058
00059
00060 oe_pagetable mem;
00061
00062
00063 uint16 HLT;
00064 uint16 IRQ;
00065 uint16 NMI;
00066
00067 BYTE (*read_port)(CPU_Z80 *ref, uint16 port);
00068 void (*write_port)(CPU_Z80 *ref, uint16 portl, uint8 val);
00069
00070 private:
00071 uint16 curbank;
00072 uint16 interrupt_mode;
00073 uint8 interrupt_data[12];
00074
00075 uint16 *ireg;
00076 uint16 *reg16_1;
00077 uint16 *reg16_2;
00078
00079 uint8 *reg8_1;
00080 uint8 *reg8_2;
00081
00082 uint16 regaddr;
00083
00084
00085 CPU_Z80_reg16 regs[2][4];
00086 uint8 IFF1;
00087 uint8 IFF2;
00088
00089 #ifdef OE_ENDIAN_LITTLE
00090 union{
00091 uint16 IX;
00092 struct {
00093 uint8 IXh;
00094 uint8 IXl;
00095 };
00096 };
00097 union {
00098 uint16 IY;
00099 struct {
00100 uint8 IYh;
00101 uint8 IYl;
00102 };
00103 };
00104 union {
00105 uint16 PC;
00106 struct {
00107 uint8 PCh;
00108 uint8 PCl;
00109 };
00110 };
00111 union {
00112 uint16 IR;
00113 struct {
00114 uint8 I;
00115 uint8 R;
00116 };
00117 };
00118 union {
00119 uint16 SP;
00120 struct {
00121 uint8 SPh;
00122 uint8 SPl;
00123 };
00124 };
00125 #else
00126 union {
00127 uint16 IX;
00128 struct {
00129 uint8 IXl;
00130 uint8 IXh;
00131 };
00132 };
00133 union {
00134 uint16 IY;
00135 struct {
00136 uint8 IYl;
00137 uint8 IYh;
00138 };
00139 };
00140 union {
00141 uint16 PC;
00142 struct {
00143 uint8 PCl;
00144 uint8 PCh;
00145 };
00146 };
00147 union {
00148 uint16 IR;
00149 struct {
00150 uint8 R;
00151 uint8 I;
00152 };
00153 };
00154 union {
00155 uint16 SP;
00156 struct {
00157 uint8 SPl;
00158 uint8 SPh;
00159 };
00160 };
00161 #endif
00162
00163
00164 void setjumptable(int ins, int mode);
00165 CPU_Z80_ins iinf[4][256];
00166
00167 void (CPU_Z80::*inst[4][256])(void);
00168
00169
00170 void IllegalOpcode();
00171
00172
00173
00174 };
00175
00176 #endif