diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-20 10:50:42 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-20 10:50:42 +0100 |
commit | c380e4af44f4fdcc8ff828a716ae4341adf6b537 (patch) | |
tree | 8bb61c348d95f8e3227c8b8387d6f2c08c48ea46 | |
parent | Misc: Added some debug output to the implemented instructions (diff) | |
download | CHIP8-Emulator-c380e4af44f4fdcc8ff828a716ae4341adf6b537.tar.gz CHIP8-Emulator-c380e4af44f4fdcc8ff828a716ae4341adf6b537.tar.bz2 CHIP8-Emulator-c380e4af44f4fdcc8ff828a716ae4341adf6b537.zip |
Feature: Implemented various instructions
-rw-r--r-- | chip8_emulator.core | bin | 34790048 -> 35143480 bytes | |||
-rw-r--r-- | emulator.c | 42 |
2 files changed, 42 insertions, 0 deletions
diff --git a/chip8_emulator.core b/chip8_emulator.core index 5911628..a898238 100644 --- a/chip8_emulator.core +++ b/chip8_emulator.core Binary files differdiff --git a/emulator.c b/emulator.c index b0b3e61..b46e870 100644 --- a/emulator.c +++ b/emulator.c @@ -93,6 +93,9 @@ int emulator_tick(Emulator* emulator) memset(emulator->display, 0, sizeof(emulator->display)); emulator->draw_flag = 1; break; + default: + printf("DEFAULT: Instr: 0x%x\n", instr); + assert(0); } break; @@ -164,12 +167,27 @@ int emulator_tick(Emulator* emulator) emulator->regs.V[X] += emulator->regs.V[Y]; break; case 0x5: + emulator->regs.V[X] -= emulator->regs.V[Y]; + break; case 0x6: case 0xE: + printf("TODO: Instr: 0x%x\n", instr); + assert(0); break; + default: + printf("DEFAULT: Instr: 0x%x\n", instr); + assert(0); } break; + case 0x9: + dbgprintf("SKIP INSTR IF REGISTER VX != VY!\n"); + if(emulator->regs.V[X] != emulator->regs.V[Y]) + { + dbgprintf("SKIPPED COZ THEY WERE NOT EQUAL!\n"); + *pc += 2; + } + break; case 0xA: dbgprintf("SET INDEX REGISTER I! (0x%x)\n", NNN); emulator->regs.I = NNN; @@ -204,9 +222,30 @@ int emulator_tick(Emulator* emulator) emulator->draw_flag = 1; break; case 0xE: + printf("TODO: Instr: 0x%x\n", instr); + assert(0); break; case 0xF: + switch(N) + { + case 0xE: //FX1E + dbgprintf("ADD V[X] to the I register!\n"); + emulator->regs.I += emulator->regs.V[X]; + break; + case 0x5: //FX55 + for (int i = 0; i <= X; ++i) + emulator->memory[emulator->regs.I + i] = emulator->regs.V[i]; + emulator->regs.I += X + 1; + break; + default: + printf("DEFAULT: Instr: 0x%x\n", instr); + assert(0); + } + break; + default: + printf("DEFAULT!: Instr: 0x%x -- %d\n", instr, N); + assert(0); } dbgprintf("\n"); @@ -224,7 +263,10 @@ void* emulator_timers_thread(Emulator* emulator) --emulator->delay_timer; if(emulator->sound_timer > 0) + { + printf("lower timer!\n"); --emulator->sound_timer; + } usleep(1000000 / 60); } |