diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-22 18:01:01 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-22 18:01:01 +0100 |
commit | 242ccb6346647f3f32fcda5ef4239f0569618404 (patch) | |
tree | 536527b51cdb7617210ed5f0e80e155c31680a00 | |
parent | Refractoring: Refractored the Makefile to make use of pkg-config (diff) | |
download | CHIP8-Emulator-242ccb6346647f3f32fcda5ef4239f0569618404.tar.gz CHIP8-Emulator-242ccb6346647f3f32fcda5ef4239f0569618404.tar.bz2 CHIP8-Emulator-242ccb6346647f3f32fcda5ef4239f0569618404.zip |
Feature: Implemented various instructions
-rw-r--r-- | emulator.c | 21 | ||||
-rw-r--r-- | roms/trip8.ch8 | bin | 0 -> 3203 bytes |
2 files changed, 18 insertions, 3 deletions
diff --git a/emulator.c b/emulator.c index f976af3..fa6abe7 100644 --- a/emulator.c +++ b/emulator.c @@ -93,6 +93,10 @@ int emulator_tick(Emulator* emulator) memset(emulator->display, 0, sizeof(emulator->display)); emulator->draw_flag = 1; break; + case 0x0EE: //00EE: Return from subroutine + //pop callee pc from stack and set current pc to it + emulator->pc = emulator->stack[--emulator->sp]; + break; default: printf("DEFAULT: Instr: 0x%x\n", instr); assert(0); @@ -113,8 +117,11 @@ int emulator_tick(Emulator* emulator) break; case 0x2: - printf("TODO: Instr: 0x%x\n", instr); - assert(0); + dbgprintf("CALL SUBROUTINE! (0x%x)\n", NNN); + //push pc to stack and increment sp + emulator->stack[emulator->sp++] = emulator->pc; + + emulator->pc = NNN; break; case 0x3: dbgprintf("SKIP INSTR IF REGISTER VX == NN!\n"); @@ -260,7 +267,15 @@ int emulator_tick(Emulator* emulator) emulator->regs.V[i] = emulator->memory[emulator->regs.I + i]; emulator->regs.I += X + 1; break; - default: + case 0x15: //FX15 + dbgprintf("SET THE DELAY TIMER TO V[X]!\n"); + emulator->delay_timer = emulator->regs.V[X]; + break; + case 0x07: //FX07 + dbgprintf("SET V[X] TO THE DELAY TIMER!\n"); + emulator->regs.V[X] = emulator->delay_timer; + break; + default: printf("DEFAULT: Instr: 0x%x\n", instr); assert(0); } diff --git a/roms/trip8.ch8 b/roms/trip8.ch8 new file mode 100644 index 0000000..d88d28f --- /dev/null +++ b/roms/trip8.ch8 Binary files differ |