diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-22 23:17:22 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-22 23:17:22 +0100 |
commit | ddaa5907d5238adb782f52486efcf6a86951d7fd (patch) | |
tree | f9a205e775611e1a8a58aa562b47256f8b50f2ab | |
parent | Feature: Implemented various instructions (diff) | |
download | CHIP8-Emulator-ddaa5907d5238adb782f52486efcf6a86951d7fd.tar.gz CHIP8-Emulator-ddaa5907d5238adb782f52486efcf6a86951d7fd.tar.bz2 CHIP8-Emulator-ddaa5907d5238adb782f52486efcf6a86951d7fd.zip |
Feature: Implemented various instructions
-rw-r--r-- | emulator.c | 25 | ||||
-rw-r--r-- | main.c | 2 |
2 files changed, 13 insertions, 14 deletions
diff --git a/emulator.c b/emulator.c index fa6abe7..1972cc4 100644 --- a/emulator.c +++ b/emulator.c @@ -132,8 +132,12 @@ int emulator_tick(Emulator* emulator) } break; case 0x4: - printf("TODO: Instr: 0x%x\n", instr); - assert(0); + dbgprintf("SKIP INSTR IF REGISTER VX != NN!\n"); + if(emulator->regs.V[X] != NN) + { + dbgprintf("SKIPPED COZ THEY WERE NOT EQUAL!\n"); + emulator_step(emulator); + } break; case 0x5: dbgprintf("SKIP INSTR IF REGISTER VX == VY!\n"); @@ -159,28 +163,23 @@ int emulator_tick(Emulator* emulator) emulator->regs.V[X] = emulator->regs.V[Y]; break; case 0x1: - case 0x2: printf("TODO: Instr: 0x%x -- %d\n", instr, N); assert(0); break; + case 0x2: + emulator->regs.V[X] &= emulator->regs.V[Y]; + break; case 0x3: emulator->regs.V[X] ^= emulator->regs.V[Y]; break; case 0x4: dbgprintf("ADD VY TO VX!\n"); - if(emulator->regs.V[X] + emulator->regs.V[Y] > 255) - emulator->regs.VF = 1; + emulator->regs.V[X] += emulator->regs.V[Y]; + if(emulator->regs.V[Y] > emulator->regs.V[X]) + emulator->regs.VF = 1; //carry else emulator->regs.VF = 0; - /* - * emulator->regs.V[X] += emulator->regs.V[Y]; - if(emulator->regs.V[Y] > emulator->regs.V[X]) - emulator->regs.VF = 1; //carry - else - emulator->regs.VF = 0; //carry*/ - - emulator->regs.V[X] += emulator->regs.V[Y]; break; case 0x5: if(emulator->regs.V[X] > emulator->regs.V[Y]) diff --git a/main.c b/main.c index 90e4bb2..d061a59 100644 --- a/main.c +++ b/main.c @@ -64,7 +64,7 @@ int main(int argc, char** argv) emulator.draw_flag = 0; } - usleep(1000000 / INSTRUCTIONS_PER_SECOND); + //usleep(1000000 / INSTRUCTIONS_PER_SECOND); } exit: |