diff options
Diffstat (limited to 'z80_private.h')
-rw-r--r-- | z80_private.h | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/z80_private.h b/z80_private.h index 7a23d36..6675c12 100644 --- a/z80_private.h +++ b/z80_private.h @@ -85,8 +85,10 @@ struct Z80 Z80Byte devbyte; int nmi; - Z80Byte *memory; - int *memctrl; + Z80ReadMemory disread; + + Z80ReadMemory mread; + Z80WriteMemory mwrite; Z80ReadPort pread; Z80WritePort pwrite; @@ -105,13 +107,6 @@ struct Z80 */ -/* HI/LO -*/ -#define SET_HI(reg,v) reg = (reg & 0x00ff) | ((v) << 8) -#define SET_LO(reg,v) reg = (reg & 0xff00) | ((v) & 0xff) -#define GET_HI(reg,v) ((reg & 0xff00) >> 8) -#define GET_LO(reg,v) (reg & 0xff) - /* Invoke a callback class */ #define CALLBACK(r,d) do \ @@ -143,30 +138,14 @@ struct Z80 #define SETFLAG(f) SET(cpu->AF.b[LO],f) #define CLRFLAG(f) CLR(cpu->AF.b[LO],f) -#define PEEK(addr) (cpu->memory[addr]) +#define PEEK(addr) (cpu->mread(cpu,addr)) #define PEEKW(addr) FPEEKW(cpu,addr) -#define POKE(addr,val) do \ - { \ - Z80Word ba=addr; \ - Z80Word bv=val; \ - if (cpu->memctrl[(ba)/256]) \ - { \ - cpu->memory[ba]=bv; \ - } \ - } while (0) -#define POKEW(addr,val) do \ - { \ - Z80Word wa=addr; \ - Z80Word wv=val; \ - POKE(wa,wv); \ - POKE(wa+1,wv>>8); \ - } while(0) +#define POKE(addr,val) cpu->mwrite(cpu,addr,val) +#define POKEW(addr,val) FPOKEW(cpu,addr,val) -#define FETCH_BYTE (cpu->memory[cpu->PC++]) -#define FETCH_WORD (cpu->PC+=2, \ - cpu->memory[cpu->PC-2]| \ - ((Z80Word)cpu->memory[cpu->PC-1]<<8)) +#define FETCH_BYTE (cpu->mread(cpu,cpu->PC++)) +#define FETCH_WORD (cpu->PC+=2,FPEEKW(cpu,cpu->PC-2)) #define IS_C (cpu->AF.b[LO]&C_Z80) #define IS_N (cpu->AF.b[LO]&N_Z80) @@ -185,15 +164,19 @@ struct Z80 #define ADD_R(v) cpu->R=((cpu->R&0x80)|((cpu->R+(v))&0x7f)) #define INC_R ADD_R(1) -#define PUSH(REG) do \ - { \ - cpu->SP-=2; \ - POKEW(cpu->SP,REG); \ +#define PUSH(REG) do \ + { \ + Z80Word pushv=REG; \ + cpu->SP-=2; \ + cpu->mwrite(cpu,cpu->SP,pushv); \ + cpu->mwrite(cpu,cpu->SP+1,pushv>>8);\ } while(0) -#define POP(REG) do \ - { \ - REG=PEEKW(cpu->SP); \ - cpu->SP+=2; \ + +#define POP(REG) do \ + { \ + REG=PEEK(cpu->SP) | \ + (Z80Word)PEEK(cpu->SP+1)<<8; \ + cpu->SP+=2; \ } while(0) #define SETHIDDEN(res) cpu->AF.b[LO]=(cpu->AF.b[LO]&~(B3_Z80|B5_Z80))|\ @@ -204,6 +187,7 @@ struct Z80 PUSH(cpu->PC+2); \ cpu->PC=PEEKW(cpu->PC); \ } while(0) + #define NOCALL cpu->PC+=2 #define JP cpu->PC=PEEKW(cpu->PC) #define NOJP cpu->PC+=2 |