diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-23 14:52:26 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2021-07-23 14:53:53 +0100 |
commit | 77a99cf59ba35f27871cd6127e0786f3ff8c285d (patch) | |
tree | f0bdb67a76269c5a8f735a5fdaef5a3a71b5a78e | |
parent | Feature: Implemented various instructions (diff) | |
download | CHIP8-Emulator-77a99cf59ba35f27871cd6127e0786f3ff8c285d.tar.gz CHIP8-Emulator-77a99cf59ba35f27871cd6127e0786f3ff8c285d.tar.bz2 CHIP8-Emulator-77a99cf59ba35f27871cd6127e0786f3ff8c285d.zip |
Feature: Implemented various instructions and added a few roms
-rw-r--r-- | emulator.c | 21 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | roms/BLINKY | bin | 0 -> 2356 bytes | |||
-rw-r--r-- | roms/INVADERS | bin | 0 -> 1283 bytes | |||
-rw-r--r-- | roms/KALEID | bin | 0 -> 120 bytes | |||
-rw-r--r-- | roms/PONG | bin | 0 -> 246 bytes | |||
-rw-r--r-- | roms/TETRIS | bin | 0 -> 494 bytes | |||
-rw-r--r-- | roms/TICTAC | bin | 0 -> 486 bytes | |||
-rw-r--r-- | roms/WIPEOFF | bin | 0 -> 206 bytes |
9 files changed, 18 insertions, 7 deletions
diff --git a/emulator.c b/emulator.c index 5c83226..615c4fe 100644 --- a/emulator.c +++ b/emulator.c @@ -211,9 +211,8 @@ int emulator_tick(Emulator* emulator) emulator->regs.V[X] = emulator->regs.V[Y]; break; case 0x1: - printf("TODO: Instr: 0x%x -- %d\n", instr, N); - assert(0); - break; + emulator->regs.V[X] |= emulator->regs.V[Y]; + break; case 0x2: emulator->regs.V[X] &= emulator->regs.V[Y]; break; @@ -241,6 +240,13 @@ int emulator_tick(Emulator* emulator) emulator->regs.V[X] = emulator->regs.V[X] >> 1; emulator->regs.VF = N == 0x1 ? 1 : 0; break; + case 0x7: + if(emulator->regs.V[Y] > emulator->regs.V[X]) + emulator->regs.VF = 1; + else + emulator->regs.VF = 0; + 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; @@ -295,11 +301,16 @@ int emulator_tick(Emulator* emulator) case 0xE: switch(NN) { - case 0xA1: + case 0xA1: //EX9E //skip if key not pressed if(emulator->keys[emulator->regs.V[X]].activated == 0) *pc += 2; break; + case 0x9E: //EX9E + //skip if key pressed + if(emulator->keys[emulator->regs.V[X]].activated == 1) + *pc += 2; + break; default: printf("DEFAULT: Instr: 0x%x\n", instr); assert(0); @@ -402,7 +413,7 @@ void* emulator_timers_thread(Emulator* emulator) { if(emulator->delay_timer > 0) { - printf("lower timer!\n"); + dbgprintf("lower timer!\n"); --emulator->delay_timer; } diff --git a/main.c b/main.c index 6bde0e1..e6f6cf1 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,7 @@ #include <SDL.h> int main(int argc, char** argv); -void show_help(); +static void show_help(); int main(int argc, char** argv) { @@ -89,7 +89,7 @@ int main(int argc, char** argv) return 0; } -void show_help() +static void show_help() { printf("BAD USAGE! -> ./chip8_emulator [ROM]\n"); } diff --git a/roms/BLINKY b/roms/BLINKY new file mode 100644 index 0000000..235cf98 --- /dev/null +++ b/roms/BLINKY Binary files differdiff --git a/roms/INVADERS b/roms/INVADERS new file mode 100644 index 0000000..f7db5f5 --- /dev/null +++ b/roms/INVADERS Binary files differdiff --git a/roms/KALEID b/roms/KALEID new file mode 100644 index 0000000..a1bc7cc --- /dev/null +++ b/roms/KALEID Binary files differdiff --git a/roms/PONG b/roms/PONG new file mode 100644 index 0000000..e371e91 --- /dev/null +++ b/roms/PONG Binary files differdiff --git a/roms/TETRIS b/roms/TETRIS new file mode 100644 index 0000000..9f5e087 --- /dev/null +++ b/roms/TETRIS Binary files differdiff --git a/roms/TICTAC b/roms/TICTAC new file mode 100644 index 0000000..4d4bc99 --- /dev/null +++ b/roms/TICTAC Binary files differdiff --git a/roms/WIPEOFF b/roms/WIPEOFF new file mode 100644 index 0000000..2d5e513 --- /dev/null +++ b/roms/WIPEOFF Binary files differ |