Skip to content

Commit

Permalink
z80 and iochip fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeykt committed May 4, 2023
1 parent 0d230e7 commit 7747601
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
4 changes: 2 additions & 2 deletions arbiter.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,13 @@ void ARB_Clock(arbiter_t *chip)
chip->za15_in = (chip->input.ext_zaddress_in & 32768) != 0;


SDFFR_UpdateWide(&chip->z80bank, chip->w150, ((chip->z80bank.l2 & 0x1ff) >> 1) | ((chip->input.ext_zdata_in & 1) << 8),
SDFFR_UpdateWide(&chip->z80bank, chip->w150, ((chip->z80bank.q & 0x1ff) >> 1) | ((chip->input.ext_zdata_in & 1) << 8),
chip->sres_syncv.l2, 511);
if (chip->input.ext_m3) // MD
{
chip->va_out = (chip->input.ext_zaddress_in & 0x7f00) >> 8;
if (chip->w86)
chip->va_out |= (chip->z80bank.l2 & 0x1ff) << 7;
chip->va_out |= (chip->z80bank.q & 0x1ff) << 7;
else
chip->va_out |= 0xc000;
}
Expand Down
4 changes: 2 additions & 2 deletions iochip.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void IOC_Clock(iochip_t *chip)

chip->io_access = !(chip->zaccess || chip->input.ext_io || chip->input.ext_cas0);

chip->byte_sel = chip->input.ext_cas0 && (chip->input.ext_zaddress_in & 1) == 0;
chip->byte_sel = chip->input.ext_m3 && (chip->input.ext_zaddress_in & 1) == 0;

chip->arb_w1 = !(chip->io_access && chip->input.ext_m3) && (chip->input.ext_zv || !chip->input.ext_cas0) && (chip->input.ext_vz || chip->input.ext_cas0);
chip->arb_w2 = (chip->input.ext_zv || chip->input.ext_cas0) && (chip->input.ext_vz || !chip->input.ext_cas0);
Expand Down Expand Up @@ -438,7 +438,7 @@ void IOC_UpdateOutputBus(iochip_t *chip)
{
*chip->ext_vdata_out &= ~0xff00;
*chip->ext_vdata_out |= (chip->vdata & 0xfe) << 8;
if (chip->io_access)
if (chip->input.ext_m3)
{
*chip->ext_vdata_out |= (chip->vdata & 1) << 8;
}
Expand Down
42 changes: 38 additions & 4 deletions md.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ int main(int argc, char *argv[])
ym.i_iorq = iorq;
ym.arb.input.ext_mreq_in = mreq;
ym.i_dtack = dtack;
ym.i_zres = ym.o_zres == state_z ? 1 : 0;
ym.i_zres = ym.o_zres == state_z ? 1 : ym.o_zres;
ym.i_zwr = wr;
ym.i_zrd = rd;
ym.i_m1 = !z80.o_m1;
Expand Down Expand Up @@ -577,6 +577,8 @@ int main(int argc, char *argv[])
if (!rd)
{
zdata = zram[zaddress & 0x1fff];
//if (zaddress == 0x36)
// printf("read vdata %x zdata %x\n", vdata, zdata);
}
//if (!wr)
//{
Expand All @@ -594,13 +596,39 @@ int main(int argc, char *argv[])
}
}

#if 0
#if 1
if (m68k.o_rw == state_z)
{
if ((uds == 0 || lds == 0) && as == 0)
{
printf("vdp/z80 access ulrw %i%i%i address %x data %x\n",
uds, lds, rw, vaddress*2, vdata);
if (mcycles == 4705622)
mcycles += 0;
printf("cycles %i vdp/z80 acc ulrw %i%i%i va %x vd %x za %x zd %x zrw %i%i\n",
(int)mcycles, uds, lds, rw, vaddress*2, vdata, zaddress, zdata, z80.o_rd, z80.o_wr);
printf("z80: clk %i w2 %i wait %i\n", z80.input.clk, z80.w2, z80.input.i_wait);
}
}

{
static int bit;
static int zbank;
static int st;
if (!ym.arb.w150)
{
bit = zdata & 1;
printf("cycles %i bank upd: %i\n", (int)mcycles, bit);
st = 1;
}
else
{
if (st)
{
zbank = zbank >> 1;
zbank |= bit << 23;
zbank &= 0xff8000;
printf("zbank %x\n", zbank);
st = 0;
}
}
}
#endif
Expand Down Expand Up @@ -630,6 +658,12 @@ int main(int argc, char *argv[])
if (!wr)
{
zram[zaddress & 0x1fff] = zdata;
if ((zaddress & 0x1fc0) == 0x1b40 || zaddress == 0x36)
{
//if (zaddress == 0x36)
// printf("write vdata %x zdata %x\n", vdata, zdata);
printf("cycles %d: z80 %x = %x\n", (int)mcycles, zaddress, zdata);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void Z80_BusLogic(z80_t *chip, int clk)
chip->w69 = !(chip->w55 || (chip->w41 && !chip->w131));
if (clk)
chip->l1 = chip->w69;
if (!clk && chip->l1)
if (!clk && !chip->l1)
chip->w2 = 0;
if (clk && chip->w15)
chip->w2 = 1;
Expand Down

0 comments on commit 7747601

Please sign in to comment.