Skip to content

Commit

Permalink
update 68000 only on clock state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeykt committed May 9, 2023
1 parent f51be78 commit 75372be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
39 changes: 29 additions & 10 deletions 68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ void M68K_Clock(m68k_t* chip, int clk1, int clk2)

chip->w257 = chip->w211 ? chip->w853 : 0;

chip->w266 = chip->input.i_vpa == state_test;
chip->w266 = chip->input.i_vpa_test;

if (clk1)
{
Expand Down Expand Up @@ -2156,7 +2156,7 @@ void M68K_Clock(m68k_t* chip, int clk1, int clk2)
chip->w317 = chip->w305;

chip->w343[0] = !chip->input.i_vpa;
chip->w343[2] = chip->w343[0];
chip->w343[2] = chip->w343[1];

chip->w359[0] = !chip->input.i_dtack;
chip->w359[2] = chip->w359[1];
Expand Down Expand Up @@ -6733,12 +6733,31 @@ void M68K_Clock2(m68k_t *chip, int clk1, int clk2)
chip->input.i_clk_phase = 1;
if (clk2)
chip->input.i_clk_phase = 2;
if (!memcmp(&chip->input, &chip->input_old, sizeof(chip->input)))
return;

M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
chip->input_old = chip->input;
chip->input.i_vpa_test = chip->input.i_vpa = state_test;

if (clk2)
{
chip->w343[0] = !chip->input.i_vpa;
chip->w268[0] = !chip->input.i_br;
chip->w269[0] = !chip->input.i_bgack;
chip->w275[0] = !chip->input.i_reset;
chip->w276[0] = !chip->input.i_halt;
chip->w296[0] = !chip->input.i_ipl0;
chip->w297[0] = !chip->input.i_ipl1;
chip->w298[0] = !chip->input.i_ipl2;
chip->w359[0] = !chip->input.i_dtack;
chip->w435[0] = !chip->input.i_berr;
chip->data_l = chip->input.i_data;
}

if (chip->input.i_clk_phase != chip->input_clk_phase_o
|| chip->input.i_vpa_test != chip->input_vpa_test_o)
{
M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
M68K_Clock(chip, clk1, clk2);
chip->input_clk_phase_o = chip->input.i_clk_phase;
chip->input_vpa_test_o = chip->input.i_vpa_test;
}
}
5 changes: 4 additions & 1 deletion 68k.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ typedef struct {
int i_dtack;
int i_berr;
int i_data;
int i_vpa_test;
} m68k_input_t;

typedef struct {
int val;
} busstate_t;

typedef struct {
m68k_input_t input, input_old;
m68k_input_t input;
int input_clk_phase_o;
int input_vpa_test_o;

int o_e;
int o_bg;
Expand Down

0 comments on commit 75372be

Please sign in to comment.