summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2007-05-07 02:01:56 +0000
committerIan C <ianc@noddybox.co.uk>2007-05-07 02:01:56 +0000
commitd1591dc8440a5a896f22875b519e94cf177d8855 (patch)
tree871505d3a9cd950e62776f4dc8b0d8173248720d /source
parenteeb34217e85320a135a8ee6d2b5888cb98f49575 (diff)
Display not yet working; emulation too slow.HEADmaster
Diffstat (limited to 'source')
-rw-r--r--source/keyboard.c2
-rw-r--r--source/main.c2
-rw-r--r--source/spec.c22
-rw-r--r--source/z80.c191
-rw-r--r--source/z80_decode.c125
-rw-r--r--source/z80_dis.c26
6 files changed, 181 insertions, 187 deletions
diff --git a/source/keyboard.c b/source/keyboard.c
index 2c4d63f..2dab4f7 100644
--- a/source/keyboard.c
+++ b/source/keyboard.c
@@ -97,7 +97,7 @@ void SK_DisplayKeyboard(uint16 *vram)
loadPCX(keyb_bin,&img);
image8to16(&img);
- dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
+ dmaCopy(img.image.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
}
diff --git a/source/main.c b/source/main.c
index e8b4c6b..d4ac2ee 100644
--- a/source/main.c
+++ b/source/main.c
@@ -221,7 +221,7 @@ int main(int argc, char *argv[])
/* Initialise processor and the Spectrum
*/
- z80=Z80Init(SPECPeek,SPECPoke,SPECReadPort,SPECWritePort,SPECDisPeek);
+ z80=Z80Init(SPECReadPort,SPECWritePort);
if (!z80)
{
diff --git a/source/spec.c b/source/spec.c
index 10a5d0a..0e569b5 100644
--- a/source/spec.c
+++ b/source/spec.c
@@ -62,9 +62,9 @@ static const int ROM_LOAD=0x562;
#define SCRDATA 0x4000
#define ATTR 0x5800
-#define ATTR_AT(x,y) mem[ATTR+(x)+((y)/8)*32]
+#define ATTR_AT(x,y) Z80_MEMORY[ATTR+(x)+((y)/8)*32]
-static Z80Byte mem[0x10000];
+Z80Byte Z80_MEMORY[0x10000];
/* Number of cycles per frame
*/
@@ -169,7 +169,7 @@ static void DrawScreen(void)
vr=vram;
- swiWaitForVBlank();
+ /* swiWaitForVBlank(); */
for(y=0;y<SCR_H;y++)
{
@@ -257,36 +257,36 @@ static void RomPatch(void)
int f;
for(f=0;save[f]!=0xff;f++)
- mem[ROM_SAVE+f]=save[f];
+ Z80_MEMORY[ROM_SAVE+f]=save[f];
for(f=0;load[f]!=0xff;f++)
- mem[ROM_LOAD+f]=load[f];
+ Z80_MEMORY[ROM_LOAD+f]=load[f];
}
Z80Byte SPECPeek(Z80 *cpu, Z80Word addr)
{
- return mem[addr];
+ return Z80_MEMORY[addr];
}
Z80Byte SnapPeek(Z80Word addr)
{
- return mem[addr];
+ return Z80_MEMORY[addr];
}
void SPECPoke(Z80 *cpu, Z80Word addr, Z80Byte val)
{
if (addr>=ROMLEN)
- mem[addr]=val;
+ Z80_MEMORY[addr]=val;
}
void SnapPoke(Z80Word addr, Z80Byte val)
{
if (addr>=ROMLEN)
- mem[addr]=val;
+ Z80_MEMORY[addr]=val;
}
@@ -365,7 +365,7 @@ void SPECInit(uint16 *v, Z80 *z80)
{
vram=v;
- memcpy(mem,spec48_bin,ROMLEN);
+ memcpy(Z80_MEMORY,spec48_bin,ROMLEN);
/* Patch the ROM
*/
@@ -491,7 +491,7 @@ void SPECReset(Z80 *z80)
r=0;
for(f=0;f<SCR_H;f++)
{
- line[f]=mem+SCRDATA+(c*8*TXT_W)+(r*TXT_W);
+ line[f]=Z80_MEMORY+SCRDATA+(c*8*TXT_W)+(r*TXT_W);
c++;
diff --git a/source/z80.c b/source/z80.c
index 60dbca4..36c5793 100644
--- a/source/z80.c
+++ b/source/z80.c
@@ -55,40 +55,43 @@ static void Z80_CheckInterrupt(Z80 *cpu)
{
/* Check interrupts
*/
- if (cpu->raise)
+ if (PRIV->raise)
{
- if (cpu->nmi)
+ if (PRIV->nmi)
{
- if (cpu->halt)
+ if (PRIV->halt)
{
- cpu->halt=FALSE;
+ PRIV->halt=FALSE;
CALLBACK(eZ80_Halt,0);
cpu->PC++;
}
TSTATE(2);
cpu->IFF1=0;
- cpu->nmi=FALSE;
+ PRIV->nmi=FALSE;
PUSH(cpu->PC);
cpu->PC=0x66;
}
else if (cpu->IFF1)
{
- if (cpu->halt)
+ if (PRIV->halt)
{
- cpu->halt=FALSE;
+ PRIV->halt=FALSE;
CALLBACK(eZ80_Halt,0);
cpu->PC++;
}
TSTATE(2);
+ cpu->IFF1=0;
+ cpu->IFF2=0;
+
switch(cpu->IM)
{
default:
case 0:
INC_R;
- Z80_Decode(cpu,cpu->devbyte);
+ Z80_Decode(cpu,PRIV->devbyte);
return;
break;
@@ -99,12 +102,12 @@ static void Z80_CheckInterrupt(Z80 *cpu)
case 2:
PUSH(cpu->PC);
- cpu->PC=(Z80Word)cpu->I*256+cpu->devbyte;
+ cpu->PC=(Z80Word)cpu->I*256+PRIV->devbyte;
break;
}
}
- cpu->raise=FALSE;
+ PRIV->raise=FALSE;
}
}
@@ -112,11 +115,16 @@ static void Z80_CheckInterrupt(Z80 *cpu)
/* ---------------------------------------- INTERFACES
*/
-Z80 *Z80Init(Z80ReadMemory read_memory,
- Z80WriteMemory write_memory,
- Z80ReadPort read_port,
- Z80WritePort write_port,
- Z80ReadMemory read_disassem)
+#ifdef ENABLE_ARRAY_MEMORY
+Z80 *Z80Init(Z80ReadPort read_port,
+ Z80WritePort write_port)
+#else
+Z80 *Z80Init(Z80ReadMemory read_memory,
+ Z80WriteMemory write_memory,
+ Z80ReadPort read_port,
+ Z80WritePort write_port,
+ Z80ReadMemory read_for_disassem)
+#endif
{
Z80 *cpu;
int f;
@@ -124,24 +132,38 @@ Z80 *Z80Init(Z80ReadMemory read_memory,
InitTables();
+#ifndef ENABLE_ARRAY_MEMORY
if (!read_memory || !write_memory)
return NULL;
+#endif
cpu=malloc(sizeof *cpu);
if (cpu)
{
- cpu->mread=read_memory;
- cpu->mwrite=write_memory;
- cpu->pread=read_port;
- cpu->pwrite=write_port;
- cpu->disread=read_disassem;
+ cpu->priv=malloc(sizeof *cpu->priv);
+
+ if (cpu->priv)
+ {
+#ifndef ENABLE_ARRAY_MEMORY
+ PRIV->mread=read_memory;
+ PRIV->mwrite=write_memory;
+ PRIV->disread=read_for_disassem;
+#endif
+ PRIV->pread=read_port;
+ PRIV->pwrite=write_port;
- for(f=0;f<eZ80_NO_CALLBACK;f++)
- for(r=0;r<MAX_PER_CALLBACK;r++)
- cpu->callback[f][r]=NULL;
+ for(f=0;f<eZ80_NO_CALLBACK;f++)
+ for(r=0;r<MAX_PER_CALLBACK;r++)
+ PRIV->callback[f][r]=NULL;
- Z80Reset(cpu);
+ Z80Reset(cpu);
+ }
+ else
+ {
+ free(cpu);
+ cpu=NULL;
+ }
}
return cpu;
@@ -150,7 +172,7 @@ Z80 *Z80Init(Z80ReadMemory read_memory,
void Z80Reset(Z80 *cpu)
{
- cpu->cycle=0;
+ PRIV->cycle=0;
cpu->PC=0;
cpu->AF.w=0xffff;
@@ -171,28 +193,22 @@ void Z80Reset(Z80 *cpu)
cpu->IM=0;
cpu->I=0;
cpu->R=0;
- cpu->halt=0;
-
- cpu->raise=FALSE;
- cpu->nmi=FALSE;
-}
-
+ PRIV->halt=0;
-void Z80SetPC(Z80 *cpu,Z80Word PC)
-{
- cpu->PC=PC;
+ PRIV->raise=FALSE;
+ PRIV->nmi=FALSE;
}
-Z80Word Z80GetPC(Z80 *cpu)
+Z80Val Z80Cycles(Z80 *cpu)
{
- return cpu->PC;
+ return PRIV->cycle;
}
void Z80ResetCycles(Z80 *cpu, Z80Val cycles)
{
- cpu->cycle=cycles;
+ PRIV->cycle=cycles;
}
@@ -202,9 +218,9 @@ int Z80LodgeCallback(Z80 *cpu, Z80CallbackReason reason, Z80Callback callback)
for(f=0;f<MAX_PER_CALLBACK;f++)
{
- if (!cpu->callback[reason][f])
+ if (!PRIV->callback[reason][f])
{
- cpu->callback[reason][f]=callback;
+ PRIV->callback[reason][f]=callback;
return TRUE;
}
}
@@ -218,23 +234,27 @@ void Z80RemoveCallback(Z80 *cpu, Z80CallbackReason reason, Z80Callback callback)
int f;
for(f=0;f<MAX_PER_CALLBACK;f++)
- if (cpu->callback[reason][f]==callback)
- cpu->callback[reason][f]=NULL;
+ {
+ if (PRIV->callback[reason][f]==callback)
+ {
+ PRIV->callback[reason][f]=NULL;
+ }
+ }
}
void Z80Interrupt(Z80 *cpu, Z80Byte devbyte)
{
- cpu->raise=TRUE;
- cpu->devbyte=devbyte;
- cpu->nmi=FALSE;
+ PRIV->raise=TRUE;
+ PRIV->devbyte=devbyte;
+ PRIV->nmi=FALSE;
}
void Z80NMI(Z80 *cpu)
{
- cpu->raise=TRUE;
- cpu->nmi=TRUE;
+ PRIV->raise=TRUE;
+ PRIV->nmi=TRUE;
}
@@ -242,12 +262,12 @@ int Z80SingleStep(Z80 *cpu)
{
Z80Byte opcode;
- cpu->last_cb=TRUE;
- cpu->shift=0;
+ PRIV->last_cb=TRUE;
+ PRIV->shift=0;
Z80_CheckInterrupt(cpu);
- CALLBACK(eZ80_Instruction,cpu->cycle);
+ CALLBACK(eZ80_Instruction,PRIV->cycle);
INC_R;
@@ -255,7 +275,7 @@ int Z80SingleStep(Z80 *cpu)
Z80_Decode(cpu,opcode);
- return cpu->last_cb;
+ return PRIV->last_cb;
}
@@ -265,68 +285,6 @@ void Z80Exec(Z80 *cpu)
}
-void Z80GetState(Z80 *cpu, Z80State *state)
-{
- state->cycle= cpu->cycle;
-
- state->AF = cpu->AF.w;
- state->BC = cpu->BC.w;
- state->DE = cpu->DE.w;
- state->HL = cpu->HL.w;
-
- state->AF_ = cpu->AF_;
- state->BC_ = cpu->BC_;
- state->DE_ = cpu->DE_;
- state->HL_ = cpu->HL_;
-
- state->IX = cpu->IX.w;
- state->IY = cpu->IY.w;
-
- state->SP = cpu->SP;
- state->PC = cpu->PC;
-
- state->IFF1 = cpu->IFF1;
- state->IFF2 = cpu->IFF2;
- state->IM = cpu->IM;
- state->I = cpu->I;
- state->R = cpu->R;
-}
-
-
-void Z80SetState(Z80 *cpu, const Z80State *state)
-{
- cpu->cycle = state->cycle;
-
- cpu->AF.w = state->AF;
- cpu->BC.w = state->BC;
- cpu->DE.w = state->DE;
- cpu->HL.w = state->HL;
-
- cpu->AF_ = state->AF_;
- cpu->BC_ = state->BC_;
- cpu->DE_ = state->DE_;
- cpu->HL_ = state->HL_;
-
- cpu->IX.w = state->IX;
- cpu->IY.w = state->IY;
-
- cpu->SP = state->SP;
- cpu->PC = state->PC;
-
- cpu->IFF1 = state->IFF1;
- cpu->IFF2 = state->IFF2;
- cpu->IM = state->IM;
- cpu->I = state->I;
- cpu->R = state->R;
-}
-
-
-Z80Val Z80Cycles(Z80 *cpu)
-{
- return cpu->cycle;
-}
-
-
void Z80SetLabels(Z80Label labels[])
{
z80_labels=labels;
@@ -336,6 +294,7 @@ void Z80SetLabels(Z80Label labels[])
const char *Z80Disassemble(Z80 *cpu, Z80Word *pc)
{
#ifdef ENABLE_DISASSEM
+ Z80Byte Z80_Dis_FetchByte(Z80 *cpu, Z80Word *pc);
static char s[80];
Z80Word opc,npc;
Z80Byte op;
@@ -350,7 +309,13 @@ const char *Z80Disassemble(Z80 *cpu, Z80Word *pc)
strcat(s,Z80_Dis_Printf("%-40s ;",Z80_Dis_GetArg()));
for(f=0;f<5 && opc!=npc;f++)
- strcat(s,Z80_Dis_Printf(" %.2x",(int)cpu->disread(cpu,opc++)));
+ {
+#ifdef ENABLE_ARRAY_MEMORY
+ strcat(s,Z80_Dis_Printf(" %.2x",(int)Z80_MEMORY[opc++]));
+#else
+ strcat(s,Z80_Dis_Printf(" %.2x",(int)PRIV->disread(cpu,opc++)));
+#endif
+ }
if (opc!=npc)
for(f=1;f<3;f++)
diff --git a/source/z80_decode.c b/source/z80_decode.c
index ced7fbd..a8f66ca 100644
--- a/source/z80_decode.c
+++ b/source/z80_decode.c
@@ -40,8 +40,11 @@ static Z80Byte Stable[512];
static Z80Byte Ztable[512];
-static int HI;
-static int LO;
+int Z80_HI_WORD;
+int Z80_LO_WORD;
+
+#define HI Z80_HI_WORD
+#define LO Z80_LO_WORD
/* ---------------------------------------- MISC FUNCTIONS
*/
@@ -118,6 +121,7 @@ void Z80_InitialiseInternals(void)
}
}
+#ifndef ENABLE_ARRAY_MEMORY
static Z80Word FPEEKW(Z80 *cpu, Z80Word addr)
{
return (PEEK(addr) | (Z80Word)PEEK(addr+1)<<8);
@@ -126,9 +130,10 @@ static Z80Word FPEEKW(Z80 *cpu, Z80Word addr)
static void FPOKEW(Z80 *cpu, Z80Word addr, Z80Word val)
{
- cpu->mwrite(cpu,addr,val);
- cpu->mwrite(cpu,addr+1,val>>8);
+ PRIV->mwrite(cpu,addr,val);
+ PRIV->mwrite(cpu,addr+1,val>>8);
}
+#endif
/* ---------------------------------------- GENERAL MACROS
@@ -274,35 +279,35 @@ do { \
#define OP_ON_MEM(OP,addr) \
do { \
- Z80Byte memop=cpu->mread(cpu,addr); \
+ Z80Byte memop=PEEK(addr); \
OP(memop); \
- cpu->mwrite(cpu,addr,memop); \
+ POKE(addr,memop); \
} while(0)
#define OP_ON_MEM_WITH_ARG(OP,addr,arg) \
do { \
- Z80Byte memop=cpu->mread(cpu,addr); \
+ Z80Byte memop=PEEK(addr); \
OP(memop,arg); \
- cpu->mwrite(cpu,addr,memop); \
+ POKE(addr,memop); \
} while(0)
#define OP_ON_MEM_WITH_COPY(OP,addr,copy) \
do { \
- Z80Byte memop=cpu->mread(cpu,addr); \
+ Z80Byte memop=PEEK(addr); \
OP(memop); \
copy=memop; \
- cpu->mwrite(cpu,addr,memop); \
+ POKE(addr,memop); \
} while(0)
#define OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,arg,copy) \
do { \
- Z80Byte memop=cpu->mread(cpu,addr); \
+ Z80Byte memop=PEEK(addr); \
OP(memop,arg); \
copy=memop; \
- cpu->mwrite(cpu,addr,memop); \
+ POKE(addr,memop); \
} while(0)
@@ -748,7 +753,7 @@ do { \
case BASE+6: /* LD DEST,(HL) */ \
TSTATE(7); \
OFFSET(off); \
- DEST2=cpu->mread(cpu,*HL+off); \
+ DEST2=PEEK(*HL+off); \
break; \
\
case BASE+7: /* LD DEST,A */ \
@@ -1018,9 +1023,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x40: /* IN B,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->BC.b[HI]=cpu->pread(cpu,cpu->BC.w);
+ cpu->BC.b[HI]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1033,7 +1038,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x41: /* OUT (C),B */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->BC.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b[HI]);
break;
case 0x42: /* SBC HL,BC */
@@ -1077,9 +1082,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x48: /* IN C,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->BC.b[LO]=cpu->pread(cpu,cpu->BC.w);
+ cpu->BC.b[LO]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1092,7 +1097,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x49: /* OUT (C),C */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->BC.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b[LO]);
break;
case 0x4a: /* ADC HL,BC */
@@ -1137,9 +1142,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x50: /* IN D,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->DE.b[HI]=cpu->pread(cpu,cpu->BC.w);
+ cpu->DE.b[HI]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1152,7 +1157,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x51: /* OUT (C),D */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->DE.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b[HI]);
break;
case 0x52: /* SBC HL,DE */
@@ -1196,9 +1201,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x58: /* IN E,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->DE.b[LO]=cpu->pread(cpu,cpu->BC.w);
+ cpu->DE.b[LO]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1211,7 +1216,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x59: /* OUT (C),E */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->DE.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b[LO]);
break;
case 0x5a: /* ADC HL,DE */
@@ -1255,9 +1260,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x60: /* IN H,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->HL.b[HI]=cpu->pread(cpu,cpu->BC.w);
+ cpu->HL.b[HI]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1270,7 +1275,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x61: /* OUT (C),H */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->HL.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b[HI]);
break;
case 0x62: /* SBC HL,HL */
@@ -1325,9 +1330,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x68: /* IN L,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->HL.b[LO]=cpu->pread(cpu,cpu->BC.w);
+ cpu->HL.b[LO]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1340,7 +1345,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x69: /* OUT (C),L */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->HL.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b[LO]);
break;
case 0x6a: /* ADC HL,HL */
@@ -1398,9 +1403,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- b=cpu->pread(cpu,cpu->BC.w);
+ b=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1414,7 +1419,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x71: /* OUT (C) */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,0);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,0);
break;
case 0x72: /* SBC HL,SP */
@@ -1458,9 +1463,9 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x78: /* IN A,(C) */
TSTATE(12);
- if (cpu->pread)
+ if (PRIV->pread)
{
- cpu->AF.b[HI]=cpu->pread(cpu,cpu->BC.w);
+ cpu->AF.b[HI]=PRIV->pread(cpu,cpu->BC.w);
}
else
{
@@ -1473,7 +1478,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x79: /* OUT (C),A */
TSTATE(12);
- if (cpu->pwrite) cpu->pwrite(cpu,cpu->BC.w,cpu->AF.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->AF.b[HI]);
break;
case 0x7a: /* ADC HL,SP */
@@ -1695,7 +1700,7 @@ static void ShiftedDecodeCB(Z80 *cpu, Z80Byte opcode, Z80Relative offset)
/* See if we've come here from a IX/IY shift.
*/
- switch (cpu->shift)
+ switch (PRIV->shift)
{
case 0xdd:
addr=cpu->IX.w+offset;
@@ -1760,7 +1765,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
/* See if we've come here from a IX/IY shift
*/
- switch (cpu->shift)
+ switch (PRIV->shift)
{
case 0xdd:
HL=&(cpu->IX.w);
@@ -2063,7 +2068,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x36: /* LD (HL),n */
TSTATE(10);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,FETCH_BYTE);
+ POKE(*HL+off,FETCH_BYTE);
break;
case 0x37: /* SCF */
@@ -2084,7 +2089,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x3a: /* LD A,(nnnn) */
TSTATE(13);
- cpu->AF.b[HI]=cpu->mread(cpu,FETCH_WORD);
+ cpu->AF.b[HI]=PEEK(FETCH_WORD);
break;
case 0x3b: /* DEC SP */
@@ -2129,53 +2134,53 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x70: /* LD (HL),B */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->BC.b[HI]);
+ POKE(*HL+off,cpu->BC.b[HI]);
break;
case 0x71: /* LD (HL),C */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->BC.b[LO]);
+ POKE(*HL+off,cpu->BC.b[LO]);
break;
case 0x72: /* LD (HL),D */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->DE.b[HI]);
+ POKE(*HL+off,cpu->DE.b[HI]);
break;
case 0x73: /* LD (HL),E */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->DE.b[LO]);
+ POKE(*HL+off,cpu->DE.b[LO]);
break;
case 0x74: /* LD (HL),H */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->HL.b[HI]);
+ POKE(*HL+off,cpu->HL.b[HI]);
break;
case 0x75: /* LD (HL),L */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->HL.b[LO]);
+ POKE(*HL+off,cpu->HL.b[LO]);
break;
case 0x76: /* HALT */
TSTATE(4);
cpu->PC--;
- if (!cpu->halt)
+ if (!PRIV->halt)
CALLBACK(eZ80_Halt,1);
- cpu->halt=TRUE;
+ PRIV->halt=TRUE;
break;
case 0x77: /* LD (HL),A */
TSTATE(7);
OFFSET(off);
- cpu->mwrite(cpu,*HL+off,cpu->AF.b[HI]);
+ POKE(*HL+off,cpu->AF.b[HI]);
break;
LD_BLOCK(0x78,cpu->AF.b[HI],cpu->AF.b[HI])
@@ -2242,7 +2247,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
/* Check for previous IX/IY shift.
*/
- if (cpu->shift!=0)
+ if (PRIV->shift!=0)
{
Z80Relative cb_offset;
@@ -2287,8 +2292,14 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0xd3: /* OUT (n),A */
TSTATE(11);
- if (cpu->pwrite)
- cpu->pwrite(cpu,FETCH_BYTE,cpu->AF.b[HI]);
+ if (PRIV->pwrite)
+ {
+ Z80Word port;
+
+ port=FETCH_BYTE;
+ port|=(Z80Word)cpu->AF.b[HI]<<8;
+ PRIV->pwrite(cpu,port,cpu->AF.b[HI]);
+ }
else
cpu->PC++;
break;
@@ -2328,13 +2339,13 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0xdb: /* IN A,(n) */
TSTATE(11);
- if (cpu->pread)
+ if (PRIV->pread)
{
Z80Word port;
port=FETCH_BYTE;
port|=(Z80Word)cpu->AF.b[HI]<<8;
- cpu->AF.b[HI]=cpu->pread(cpu,port);
+ cpu->AF.b[HI]=PRIV->pread(cpu,port);
}
else
cpu->PC++;
@@ -2348,7 +2359,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
TSTATE(4);
INC_R;
- cpu->shift=opcode;
+ PRIV->shift=opcode;
Z80_Decode(cpu,FETCH_BYTE);
break;
@@ -2502,7 +2513,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
TSTATE(4);
INC_R;
- cpu->shift=opcode;
+ PRIV->shift=opcode;
Z80_Decode(cpu,FETCH_BYTE);
break;
diff --git a/source/z80_dis.c b/source/z80_dis.c
index 9d42829..8a8ade8 100644
--- a/source/z80_dis.c
+++ b/source/z80_dis.c
@@ -25,6 +25,8 @@
*/
static const char ident[]="$Id$";
+#include "z80_config.h"
+
#ifdef ENABLE_DISASSEM
#include <stdio.h>
@@ -62,7 +64,11 @@ const char *Z80_Dis_Printf(const char *format, ...)
Z80Byte Z80_Dis_FetchByte(Z80 *cpu, Z80Word *pc)
{
- return cpu->disread(cpu,(*pc)++);
+#ifdef ENABLE_ARRAY_MEMORY
+ return Z80_MEMORY[(*pc)++];
+#else
+ return cpu->priv->disread(cpu,(*pc)++);
+#endif
}
@@ -1454,7 +1460,11 @@ static void DIS_DJNZ (Z80 *z80, Z80Byte op, Z80Word *pc)
{
Z80Word new;
- new=*pc+(Z80Relative)z80->disread(z80,*pc)+1;
+#ifdef ENABLE_ARRAY_MEMORY
+ new=*pc+(Z80Relative)Z80_MEMORY[*pc]+1;
+#else
+ new=*pc+(Z80Relative)z80->priv->disread(z80,*pc)+1;
+#endif
(*pc)++;
Z80_Dis_Set("djnz",Z80_Dis_Printf("$%.4x",new));
}
@@ -1469,7 +1479,11 @@ static void DIS_JR (Z80 *z80, Z80Byte op, Z80Word *pc)
Z80Word new;
const char *p;
- new=*pc+(Z80Relative)z80->disread(z80,*pc)+1;
+#ifdef ENABLE_ARRAY_MEMORY
+ new=*pc+(Z80Relative)Z80_MEMORY[*pc]+1;
+#else
+ new=*pc+(Z80Relative)z80->priv->disread(z80,*pc)+1;
+#endif
(*pc)++;
if ((p=GetLabel(new)))
@@ -1490,7 +1504,11 @@ static void DIS_JR_CO (Z80 *z80, Z80Byte op, Z80Word *pc)
const char *p;
con=z80_dis_condition[(op-0x20)/8];
- new=*pc+(Z80Relative)z80->disread(z80,*pc)+1;
+#ifdef ENABLE_ARRAY_MEMORY
+ new=*pc+(Z80Relative)Z80_MEMORY[*pc]+1;
+#else
+ new=*pc+(Z80Relative)z80->priv->disread(z80,*pc)+1;
+#endif
(*pc)++;
if ((p=GetLabel(new)))