Skip to content

Commit

Permalink
bus arbitration fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeykt committed May 4, 2023
1 parent 3f31082 commit 0d230e7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions 68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,8 @@ void M68K_Clock(m68k_t* chip, int clk1, int clk2)
chip->o_rw = 0;
else if (chip->rw_l && !chip->w409)
chip->o_rw = 1;
else
chip->o_rw = state_z;

if (clk2)
chip->w362 = chip->w382;
Expand Down
7 changes: 4 additions & 3 deletions fc1004.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void FC1004_Clock(fc1004_t *chip, int mclk, uint64_t cycles)
((chip->tmss.ext_test_0 && !chip->tmss.ext_test_2) ? chip->vdp.prescaler.mclk_dclk : chip->arb.edclk.ext_edclk);

chip->o_vdata_dir = 0;
chip->o_vaddress_dir = 0;
if (chip->ioc.ext_bc2 && chip->tmss.ext_data_out_en && chip->vdp_data_dir)
{
chip->o_vdata_dir |= 0xff;
Expand All @@ -132,17 +133,17 @@ void FC1004_Clock(fc1004_t *chip, int mclk, uint64_t cycles)
if (chip->ioc.ext_bc5 && chip->vdp_address_dir)
{
chip->o_vaddress_dir |= 0x7f;
chip->o_vaddress |= ~0x7f;
chip->o_vaddress &= ~0x7f;
}
if (chip->arb.w131 && chip->vdp_address_dir)
{
chip->o_vaddress_dir |= 0xfff80;
chip->o_vaddress |= ~0xfff80;
chip->o_vaddress &= ~0xfff80;
}
if (chip->arb.w142 && chip->vdp_address_dir)
{
chip->o_vaddress_dir |= 0x700000;
chip->o_vaddress |= ~0x700000;
chip->o_vaddress &= ~0x700000;
}

chip->br = 1;
Expand Down
4 changes: 2 additions & 2 deletions iochip.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ void IOC_Clock(iochip_t *chip)

chip->byte_sel = chip->input.ext_cas0 && (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);
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);

chip->ext_bc1 = chip->input.ext_vz || chip->input.ext_t1;
chip->ext_bc2 = chip->arb_w1 || chip->input.ext_t1;
Expand Down
17 changes: 17 additions & 0 deletions md.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ int main(int argc, char *argv[])
rw = ym.o_rw;
if (m68k.o_rw != state_z)
rw = m68k.o_rw;
iorq = 1;
if (z80.o_iorq != state_z)
iorq = !z80.o_iorq;
mreq = 1;
if (z80.o_mreq != state_z)
mreq = !z80.o_mreq;
if (ym.o_mreq != state_z)
Expand All @@ -403,6 +405,8 @@ int main(int argc, char *argv[])
wr = ym.o_zwr;
if (z80.o_wr != state_z)
wr = !z80.o_wr;
if (ym.o_zrd != state_z)
rd = ym.o_zrd;
if (z80.o_rd != state_z)
rd = !z80.o_rd;

Expand Down Expand Up @@ -506,6 +510,8 @@ int main(int argc, char *argv[])
ym.i_zwr = wr;
ym.i_zrd = rd;
ym.i_m1 = !z80.o_m1;
if (ym.o_cas0 != state_z)
ym.i_cas0 = ym.o_cas0;

FC1004_Clock(&ym, mcycles & 1, mcycles);

Expand Down Expand Up @@ -588,6 +594,17 @@ int main(int argc, char *argv[])
}
}

#if 0
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);
}
}
#endif

// 68k ram
if (!ym.vdp.o_ras0)
{
Expand Down

0 comments on commit 0d230e7

Please sign in to comment.