Skip to content

Commit ef1b187

Browse files
committed
Fix incorrect flags #21
1 parent f9ab071 commit ef1b187

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/chip8.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,17 @@ void chip8_execute(CHIP8 *chip8)
514514
Legacy: Set Vx = Vy SHR 1.
515515
S-CHIP: Set Vx = Vx SHR 1. */
516516
case 0x06:
517+
{
517518
if (!chip8->quirks[1])
518519
{
519520
chip8->V[x] = chip8->V[y];
520521
}
521522

522-
chip8->V[0x0F] = chip8->V[x] & 0x01;
523+
int carry = chip8->V[x] & 0x01;
523524
chip8->V[x] >>= 1;
525+
chip8->V[0x0F] = carry;
524526
break;
527+
}
525528

526529
/* SUBN Vx, Vy (8xy7)
527530
Set Vx = Vy - Vx, set VF = NOT borrow. */
@@ -537,15 +540,19 @@ void chip8_execute(CHIP8 *chip8)
537540
Legacy: Set Vx = Vy SHL 1.
538541
S-CHIP: Set Vx = Vx SHL 1. */
539542
case 0x0E:
543+
{
540544
if (!chip8->quirks[1])
541545
{
542546
chip8->V[x] = chip8->V[y];
543547
}
544548

545-
chip8->V[0x0F] = (chip8->V[x] & 0x80) >> 7;
549+
//chip8->V[0x0F] = (chip8->V[x] & 0x80) >> 7;
550+
int carry = (chip8->V[x] & 0x80) >> 7;
546551
chip8->V[x] <<= 1;
552+
chip8->V[0x0F] = carry;
547553
break;
548554
}
555+
}
549556

550557
break;
551558

0 commit comments

Comments
 (0)