Skip to content

Commit c61bcc5

Browse files
Writing to 65c22 IFR (reg 13) clears any flag specified in the written byte (#347)
* Writing to 65c22 IFR clears any flag specified in the written byte This matches the behavior of the hardware. Previous implementation only cleared CA2 or CB2 flags, and then only if they were configured as independent interrupts. * Avoid touching IFR7 on write * remove unused variable --------- Co-authored-by: mooinglemur <[email protected]>
1 parent 1e07a40 commit c61bcc5

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/via.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ via_read(via_t *via, uint8_t reg, bool debug)
9898
static void
9999
via_write(via_t *via, uint8_t reg, uint8_t value)
100100
{
101-
uint8_t pcr;
102101
switch (reg) {
103102
case 0: // ORB
104103
via_clear_prb_irqs(via);
@@ -132,13 +131,7 @@ via_write(via_t *via, uint8_t reg, uint8_t value)
132131
via->registers[10] = value;
133132
break;
134133
case 13: // IFR
135-
pcr = via->registers[12];
136-
if ((value & 0x01) && ((pcr & 0b00001010) == 0b00000010)) {
137-
via->registers[13] &= ~0x01;
138-
}
139-
if ((value & 0x08) && ((pcr & 0b10100000) == 0b00100000)) {
140-
via->registers[13] &= ~0x08;
141-
}
134+
via->registers[13] &= ~(value & 0x7f);
142135
break;
143136
case 14: // IER
144137
if (value & 0x80) {

0 commit comments

Comments
 (0)