Skip to content

Commit

Permalink
Clear D Flag on IRQ/NMI
Browse files Browse the repository at this point in the history
  • Loading branch information
LRFLEW committed Oct 15, 2022
1 parent d01df96 commit f7567cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/cpu/fake6502.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,18 @@ static void putvalue(uint16_t saveval) {

void nmi6502() {
push16(pc);
push8(status);
status |= FLAG_INTERRUPT;
push8(status & ~FLAG_BREAK);
setinterrupt();
cleardecimal();
pc = (uint16_t)read6502(0xFFFA) | ((uint16_t)read6502(0xFFFB) << 8);
waiting = 0;
}

void irq6502() {
push16(pc);
push8(status & ~FLAG_BREAK);
status |= FLAG_INTERRUPT;
setinterrupt();
cleardecimal();
pc = (uint16_t)read6502(0xFFFE) | ((uint16_t)read6502(0xFFFF) << 8);
waiting = 0;
}
Expand Down
4 changes: 3 additions & 1 deletion src/cpu/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ void reset6502() {
x = 0;
y = 0;
sp = 0xFD;
status |= FLAG_CONSTANT;
status |= FLAG_CONSTANT | FLAG_BREAK;
setinterrupt();
cleardecimal();
waiting = 0;
}

0 comments on commit f7567cf

Please sign in to comment.