chip8

CHIP-8 emulator
git clone git://git.christosmarg.xyz/chip8.git
Log | Files | Refs | README | LICENSE

commit a7d8e25db355dbcbbaba78363f52d361ca804fd4
parent 6b5851ff4788abff85181dfd948753ddc6c85247
Author: Christos Margiolis <christos@margiolis.net>
Date:   Tue, 19 May 2020 14:40:40 +0300

removed some printfs

Diffstat:
Mbin/chip8 | 0
Mobj/chip8.o | 0
Mobj/main.o | 0
Aroms/15PUZZLE | 0
Aroms/BLINKY | 0
Aroms/BLITZ | 0
Aroms/BRIX | 0
Aroms/CONNECT4 | 0
Aroms/GUESS | 0
Aroms/HIDDEN | 0
Aroms/INVADERS | 0
Aroms/KALEID | 0
Aroms/MAZE | 0
Aroms/MERLIN | 0
Aroms/MISSILE | 0
Aroms/PONG | 0
Aroms/PONG2 | 0
Aroms/PUZZLE | 0
Aroms/SYZYGY | 0
Aroms/TANK | 0
Aroms/TETRIS | 0
Aroms/TICTAC | 0
Aroms/UFO | 0
Aroms/VBRIX | 0
Aroms/VERS | 0
Aroms/WIPEOFF | 0
Msrc/chip8.c | 8--------
Msrc/main.c | 13++++++++++---
28 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/bin/chip8 b/bin/chip8 Binary files differ. diff --git a/obj/chip8.o b/obj/chip8.o Binary files differ. diff --git a/obj/main.o b/obj/main.o Binary files differ. diff --git a/roms/15PUZZLE b/roms/15PUZZLE Binary files differ. diff --git a/roms/BLINKY b/roms/BLINKY Binary files differ. diff --git a/roms/BLITZ b/roms/BLITZ Binary files differ. diff --git a/roms/BRIX b/roms/BRIX Binary files differ. diff --git a/roms/CONNECT4 b/roms/CONNECT4 Binary files differ. diff --git a/roms/GUESS b/roms/GUESS Binary files differ. diff --git a/roms/HIDDEN b/roms/HIDDEN Binary files differ. diff --git a/roms/INVADERS b/roms/INVADERS Binary files differ. diff --git a/roms/KALEID b/roms/KALEID Binary files differ. diff --git a/roms/MAZE b/roms/MAZE Binary files differ. diff --git a/roms/MERLIN b/roms/MERLIN Binary files differ. diff --git a/roms/MISSILE b/roms/MISSILE Binary files differ. diff --git a/roms/PONG b/roms/PONG Binary files differ. diff --git a/roms/PONG2 b/roms/PONG2 Binary files differ. diff --git a/roms/PUZZLE b/roms/PUZZLE Binary files differ. diff --git a/roms/SYZYGY b/roms/SYZYGY Binary files differ. diff --git a/roms/TANK b/roms/TANK Binary files differ. diff --git a/roms/TETRIS b/roms/TETRIS Binary files differ. diff --git a/roms/TICTAC b/roms/TICTAC Binary files differ. diff --git a/roms/UFO b/roms/UFO Binary files differ. diff --git a/roms/VBRIX b/roms/VBRIX Binary files differ. diff --git a/roms/VERS b/roms/VERS Binary files differ. diff --git a/roms/WIPEOFF b/roms/WIPEOFF Binary files differ. diff --git a/src/chip8.c b/src/chip8.c @@ -220,22 +220,14 @@ decode(Chip8 *chip8) int yl, xl; for (yl = 0; yl < h; yl++) { - printf("Decoding: %x\n", opcode); pixel = memory[I + yl]; for (xl = 0; xl < 8; xl++) { - printf("Decoding: %x\n", opcode); - printf("VX: %x\n", VX); - printf("VY: %x\n", VY); - printf("Pixel: %d\n", pixel); - printf("yline: %d\txline: %d\n", yl, xl); - if ((pixel & (0x80 >> xl)) != 0) { if (gfx[VX + xl + ((VY + yl) * 64)] == 1) V[0xF] = 1; gfx[VX + xl + ((VY + yl) * 64)] ^= 1; - printf("gfx: %d\n", gfx[VX + xl + ((VY + yl) * 64)]); } } } diff --git a/src/main.c b/src/main.c @@ -2,7 +2,7 @@ #include <SDL2/SDL.h> #include <unistd.h> -static uint8_t keymap[16] = { +static const uint8_t keymap[16] = { SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_q, SDLK_w, @@ -21,6 +21,12 @@ main(int argc, char **argv) uint32_t pixels[2048]; srand(time(NULL)); + if (argc != 2) + { + fprintf(stderr, "Usage: ./chip8 [ROM]\n"); + return -1; + } + if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { fprintf(stderr, "Cannot initialize SDL. Exiting. . .\n"); @@ -32,7 +38,8 @@ main(int argc, char **argv) SDL_WINDOW_SHOWN); if (win == NULL) { - fprintf(stderr, "Cannot create SDL window. Exiting. . .\n%s\n", SDL_GetError()); + fprintf(stderr, "Cannot create SDL window. Exiting. . .\n%s\n", + SDL_GetError()); return -1; } @@ -44,7 +51,7 @@ main(int argc, char **argv) Chip8 chip8; chip8_init(&chip8); - if (load(&chip8, argv[1]) == -1) return -1; + if (load(&chip8, argv[1]) < 0) return -1; for (;;) {