z80: implement data bus
-needed for ZXspectrum mode 2 interrupts -use with FetchDB function
This commit is contained in:
parent
dab3b85599
commit
d09e73b592
|
@ -89,22 +89,22 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
cur_instr = new ushort[]
|
||||
{IDLE,
|
||||
IDLE,
|
||||
FTCH_DB,
|
||||
TR, Z, DB,
|
||||
TR, W, I,
|
||||
IDLE,
|
||||
DEC16, SPl, SPh,
|
||||
WR, SPl, SPh, PCh,
|
||||
IDLE,
|
||||
DEC16, SPl, SPh,
|
||||
WR, SPl, SPh, PCl,
|
||||
IDLE,
|
||||
ASGN, PCl, 0,
|
||||
TR, PCh, I,
|
||||
IDLE,
|
||||
WR, SPl, SPh, PCl,
|
||||
IDLE,
|
||||
RD, Z, PCl, PCh,
|
||||
INC16, PCl, PCh,
|
||||
RD, PCl, Z, W,
|
||||
INC16, Z, W,
|
||||
IDLE,
|
||||
RD, PCh, Z, W,
|
||||
IDLE,
|
||||
RD, W, PCl, PCh,
|
||||
IDLE,
|
||||
TR16, PCl, PCh, Z, W,
|
||||
OP };
|
||||
}
|
||||
|
||||
|
|
|
@ -8,31 +8,37 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
public void Read_Func(ushort dest, ushort src_l, ushort src_h)
|
||||
{
|
||||
Regs[dest] = ReadMemory((ushort)(Regs[src_l] | (Regs[src_h]) << 8));
|
||||
Regs[DB] = Regs[dest];
|
||||
}
|
||||
|
||||
public void I_Read_Func(ushort dest, ushort src_l, ushort src_h, ushort inc)
|
||||
{
|
||||
Regs[dest] = ReadMemory((ushort)((Regs[src_l] | (Regs[src_h] << 8)) + inc));
|
||||
Regs[DB] = Regs[dest];
|
||||
}
|
||||
|
||||
public void Write_Func(ushort dest_l, ushort dest_h, ushort src)
|
||||
{
|
||||
Regs[DB] = Regs[src];
|
||||
WriteMemory((ushort)(Regs[dest_l] | (Regs[dest_h] << 8)), (byte)Regs[src]);
|
||||
}
|
||||
|
||||
public void I_Write_Func(ushort dest_l, ushort dest_h, ushort inc, ushort src)
|
||||
{
|
||||
Regs[DB] = Regs[src];
|
||||
WriteMemory((ushort)((Regs[dest_l] | (Regs[dest_h] << 8)) + inc), (byte)Regs[src]);
|
||||
}
|
||||
|
||||
public void OUT_Func(ushort dest, ushort src)
|
||||
{
|
||||
Regs[DB] = Regs[src];
|
||||
WriteHardware(Regs[dest], (byte)(Regs[src]));
|
||||
}
|
||||
|
||||
public void IN_Func(ushort dest, ushort src)
|
||||
{
|
||||
Regs[dest] = ReadHardware(Regs[src]);
|
||||
Regs[DB] = Regs[dest];
|
||||
}
|
||||
|
||||
public void TR_Func(ushort dest, ushort src)
|
||||
|
@ -738,5 +744,10 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
Flag3 = (Regs[A] & 0x08) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void FTCH_DB_Func()
|
||||
{
|
||||
Regs[DB] = FetchDB();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
public partial class Z80A
|
||||
{
|
||||
// registers
|
||||
// note these are not constants. When shadows are used, they will be changed accordingly
|
||||
public ushort PCl = 0;
|
||||
public ushort PCh = 1;
|
||||
public ushort SPl = 2;
|
||||
|
@ -40,6 +39,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
public ushort E_s = 29;
|
||||
public ushort H_s = 30;
|
||||
public ushort L_s = 31;
|
||||
public ushort DB = 32;
|
||||
|
||||
public ushort[] Regs = new ushort[36];
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
public const ushort SET_FL_IR = 59;
|
||||
public const ushort I_BIT = 60;
|
||||
public const ushort HL_BIT = 61;
|
||||
public const ushort FTCH_DB = 62;
|
||||
|
||||
public byte temp_R;
|
||||
|
||||
|
@ -106,6 +107,11 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
public Func<ushort, byte> ReadHardware;
|
||||
public Action<ushort, byte> WriteHardware;
|
||||
|
||||
// Data BUs
|
||||
// Interrupting Devices are responsible for putting a value onto the data bus
|
||||
// for as long as the interrupt is valid
|
||||
public Func<byte> FetchDB;
|
||||
|
||||
//this only calls when the first byte of an instruction is fetched.
|
||||
public Action<ushort> OnExecFetch;
|
||||
|
||||
|
@ -339,6 +345,9 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
|
||||
case HALT:
|
||||
halted = true;
|
||||
// NOTE: Check how halt state effects the DB
|
||||
Regs[DB] = 0xFF;
|
||||
|
||||
if (EI_pending > 0)
|
||||
{
|
||||
EI_pending--;
|
||||
|
@ -595,6 +604,9 @@ namespace BizHawk.Emulation.Cores.Components.Z80A
|
|||
case SET_FL_IR:
|
||||
SET_FL_IR_Func(cur_instr[instr_pntr++]);
|
||||
break;
|
||||
case FTCH_DB:
|
||||
FTCH_DB_Func();
|
||||
break;
|
||||
}
|
||||
totalExecutedCycles++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue