about summary refs log tree commit diff
path: root/emulator.c
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-24 21:22:20 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-24 21:22:20 +0100
commitdca69272607b8ac3c5c2cbef852932d8669a0d77 (patch)
tree3f60c21bf758075d180feade1ac2b10002b38090 /emulator.c
parentMisc: Added the timer thread variable to the emulator struct (diff)
downloadCHIP8-Emulator-master.tar.gz
CHIP8-Emulator-master.tar.bz2
CHIP8-Emulator-master.zip
Feature: Added a config value to add COSMAC VIP compatiblity HEAD master
Diffstat (limited to 'emulator.c')
-rw-r--r--emulator.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/emulator.c b/emulator.c
index 8fed056..466a9f2 100644
--- a/emulator.c
+++ b/emulator.c
@@ -248,8 +248,8 @@ int emulator_tick(Emulator* emulator)
                     emulator->regs.V[X] -= emulator->regs.V[Y];    
                     break;
                 case 0x6:
-                    emulator->regs.V[X] = emulator->regs.V[X] >> 1;
-                    emulator->regs.VF = N == 0x1 ? 1 : 0;
+                    emulator->regs.VF = emulator->regs.V[X] & 0x1;
+                    emulator->regs.V[X] >>= 1;
                     break;
                 case 0x7:
                     if(emulator->regs.V[Y] > emulator->regs.V[X])
@@ -259,8 +259,8 @@ int emulator_tick(Emulator* emulator)
                     emulator->regs.V[X] = emulator->regs.V[Y] - emulator->regs.V[X];
                     break;
                 case 0xE:
-                    emulator->regs.V[X] = emulator->regs.V[X] << 1;
-                    emulator->regs.VF = first_nibble == 0x1 ? 1 : 0;
+                    emulator->regs.VF = emulator->regs.V[X] >> 7;
+                    emulator->regs.V[X] <<= 1;
                     break;
             default:
                 printf("DEFAULT: Instr: 0x%x\n", instr);
@@ -342,12 +342,12 @@ int emulator_tick(Emulator* emulator)
             case 0x55: //FX55
                 for (int i = 0; i <= X; ++i)
                     emulator->memory[emulator->regs.I + i] = emulator->regs.V[i];
-                emulator->regs.I += X + 1;
+                COSMAC_VIP(emulator->regs.I += X + 1;)
                 break;
             case 0x65: //FX65
                 for (int i = 0; i <= X; ++i)
                     emulator->regs.V[i] = emulator->memory[emulator->regs.I + i];
-                emulator->regs.I += X + 1;
+                COSMAC_VIP(emulator->regs.I += X + 1;)
                 break;
             case 0x15: //FX15
                 dbgprintf("SET THE DELAY TIMER TO V[X]!\n");