Skip to content

Commit

Permalink
CPU: Clear waiting with disabled interrupt (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
LRFLEW authored Oct 23, 2022
1 parent 752ef55 commit d5d813e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cpu/65c02.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static void stp() {
// *******************************************************************************************

static void wai() {
if (~status & FLAG_INTERRUPT) waiting = 1;
waiting = 1;
}

// *******************************************************************************************
Expand Down
14 changes: 8 additions & 6 deletions src/cpu/fake6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,17 @@ void nmi6502() {
push8(status);
status |= FLAG_INTERRUPT;
pc = (uint16_t)read6502(0xFFFA) | ((uint16_t)read6502(0xFFFB) << 8);
waiting = 0;
waiting = 0;
}

void irq6502() {
push16(pc);
push8(status & ~FLAG_BREAK);
status |= FLAG_INTERRUPT;
pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8);
waiting = 0;
if (!(status & FLAG_INTERRUPT)) {
push16(pc);
push8(status & ~FLAG_BREAK);
status |= FLAG_INTERRUPT;
pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8);
}
waiting = 0;
}

uint8_t callexternal = 0;
Expand Down
6 changes: 2 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,10 +1295,8 @@ emulator_loop(void *param)
}

if (video_get_irq_out() || via2_irq()) {
if (!(status & 4)) {
// printf("IRQ!\n");
irq6502();
}
// printf("IRQ!\n");
irq6502();
}

if (pc == 0xffff) {
Expand Down

0 comments on commit d5d813e

Please sign in to comment.