diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/spec.h | 4 | ||||
-rw-r--r-- | include/z80.h | 26 | ||||
-rw-r--r-- | include/z80_config.h | 9 | ||||
-rw-r--r-- | include/z80_private.h | 20 |
4 files changed, 36 insertions, 23 deletions
diff --git a/include/spec.h b/include/spec.h index 85fb5e7..8171a4f 100644 --- a/include/spec.h +++ b/include/spec.h @@ -67,13 +67,9 @@ void SPECReconfigure(void); /* Interfaces for the Z80 */ -Z80Byte SPECReadMem(Z80 *z80, Z80Word addr); -void SPECWriteMem(Z80 *z80, Z80Word addr, Z80Byte val); Z80Byte SPECReadPort(Z80 *z80, Z80Word port); void SPECWritePort(Z80 *z80, Z80Word port, Z80Byte val); -#define SPECReadDisassem SPECReadMem - /* Interface for snap */ void SPECWriteMemSNAP(Z80Word addr, Z80Byte val); diff --git a/include/z80.h b/include/z80.h index ab095d8..c9bd107 100644 --- a/include/z80.h +++ b/include/z80.h @@ -56,20 +56,30 @@ typedef signed char Z80Relative; typedef unsigned short Z80Word; -/* A Z80 16-bit register. To access the HI/LO component use the indexes - Z80_HI_WORD and Z80_LO_WORD which will be initialised once Z80Init has been - called. +/* A Z80 16-bit register made up of 2 8-bit registers. */ +#ifdef Z80_LITTLE_ENDIAN +typedef struct +{ + Z80Byte lo; + Z80Byte hi; +} Z80RegPair; +#endif + +#ifdef Z80_BIG_ENDIAN +typedef struct +{ + Z80Byte hi; + Z80Byte lo; +} Z80RegPair; +#endif + typedef union { Z80Word w; - Z80Byte b[2]; + Z80RegPair b; } Z80Reg; -extern int Z80_HI_WORD; -extern int Z80_LO_WORD; - - /* The processor */ struct Z80Private; diff --git a/include/z80_config.h b/include/z80_config.h index 8d9ee79..2a56cb1 100644 --- a/include/z80_config.h +++ b/include/z80_config.h @@ -36,6 +36,11 @@ */ #define ENABLE_DISASSEM +/* Pick one of these as appropriate for your real CPU +#define Z80_BIG_ENDIAN +*/ +#define Z80_LITTLE_ENDIAN + /* Define this to enable the array-based memory model. In this mode an externally visible Z80Byte array called Z80_MEMORY must be @@ -44,11 +49,11 @@ In this mode the signature of Z80Init changes so that the memory functions are not passed. ALL processor instances share the same memory. -#define ENABLE_ARRAY_MEMORY */ +#define ENABLE_ARRAY_MEMORY #ifdef ENABLE_ARRAY_MEMORY -#define RAMBOT 0x0000 +#define RAMBOT 0x4000 #define RAMTOP 0xffff #endif diff --git a/include/z80_private.h b/include/z80_private.h index e0b3381..a7022d8 100644 --- a/include/z80_private.h +++ b/include/z80_private.h @@ -121,13 +121,15 @@ extern Z80Byte Z80_MEMORY[]; #define SET(v,b) (v)|=b #define CLR(v,b) (v)&=~(b) -#define SETFLAG(f) SET(cpu->AF.b[LO],f) -#define CLRFLAG(f) CLR(cpu->AF.b[LO],f) +#define SETFLAG(f) SET(cpu->AF.b.lo,f) +#define CLRFLAG(f) CLR(cpu->AF.b.lo,f) #ifdef ENABLE_ARRAY_MEMORY #define PEEK(addr) Z80_MEMORY[addr] +/* This can't be a macro as the macro is used as PEEKW(FETCH_WORD) +*/ static inline Z80Word PEEKW(Z80Word addr) { return (PEEK(addr) | (Z80Word)PEEK(addr+1)<<8); @@ -168,12 +170,12 @@ static inline Z80Word PEEKW(Z80Word addr) #endif -#define IS_C (cpu->AF.b[LO]&C_Z80) -#define IS_N (cpu->AF.b[LO]&N_Z80) -#define IS_P (cpu->AF.b[LO]&P_Z80) -#define IS_H (cpu->AF.b[LO]&H_Z80) -#define IS_Z (cpu->AF.b[LO]&Z_Z80) -#define IS_S (cpu->AF.b[LO]&S_Z80) +#define IS_C (cpu->AF.b.lo&C_Z80) +#define IS_N (cpu->AF.b.lo&N_Z80) +#define IS_P (cpu->AF.b.lo&P_Z80) +#define IS_H (cpu->AF.b.lo&H_Z80) +#define IS_Z (cpu->AF.b.lo&Z_Z80) +#define IS_S (cpu->AF.b.lo&S_Z80) #define CARRY IS_C @@ -219,7 +221,7 @@ static inline Z80Word PEEKW(Z80Word addr) cpu->SP+=2; \ } while(0) -#define SETHIDDEN(res) cpu->AF.b[LO]=(cpu->AF.b[LO]&~(B3_Z80|B5_Z80))|\ +#define SETHIDDEN(res) cpu->AF.b.lo=(cpu->AF.b.lo&~(B3_Z80|B5_Z80))|\ ((res)&(B3_Z80|B5_Z80)) #define CALL do \ |