chip8

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

commit b03a879d31f31a5f47590c693a01fbdd2f85367c
parent a51b4d3667de918b2b9329c69be06bc7b57e48c2
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sun, 30 Aug 2020 23:54:35 +0300

added screenshots

Diffstat:
MREADME.md | 13+++++++++++--
Msrc/main.c | 18++++++------------
2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md @@ -24,6 +24,15 @@ $ make clean # optional ``` The binary will be installed at `/usr/local/bin/` -## To Do +## Screenshots -* Fix flickering +<table> + <tr> + <td><img src="https://user-images.githubusercontent.com/54286563/91669143-75219180-eb1b-11ea-8b81-9dea80b61fe7.png"/></td> + <td><img src="https://user-images.githubusercontent.com/54286563/91669145-75ba2800-eb1b-11ea-9378-81ca0e412e8f.png"/></td> + </tr> + <tr> + <td><img src="https://user-images.githubusercontent.com/54286563/91669146-75ba2800-eb1b-11ea-9945-a0584713d896.png"/></td> + <td><img src="https://user-images.githubusercontent.com/54286563/91669147-7652be80-eb1b-11ea-81be-26251e88e95b.png"/></td> + </tr> +</table> diff --git a/src/main.c b/src/main.c @@ -4,18 +4,14 @@ #include "chip8.h" static const uint8_t keymap[16] = { - SDLK_1, SDLK_2, - SDLK_3, SDLK_4, - SDLK_q, SDLK_w, - SDLK_e, SDLK_r, - SDLK_a, SDLK_s, - SDLK_d, SDLK_f, - SDLK_z, SDLK_x, - SDLK_c, SDLK_v, + SDLK_1, SDLK_2, SDLK_3, SDLK_4, + SDLK_q, SDLK_w, SDLK_e, SDLK_r, + SDLK_a, SDLK_s, SDLK_d, SDLK_f, + SDLK_z, SDLK_x, SDLK_c, SDLK_v }; static int -events_handle(Chip8 *chip8) +evts(Chip8 *chip8) { int i; SDL_Event e; @@ -90,12 +86,10 @@ main(int argc, char **argv) Chip8 chip8; chip8_init(&chip8); if (!chip8_rom_load(&chip8, argv[1])) return EXIT_FAILURE; - for (;;) + for (; evts(&chip8); usleep(1500)) { chip8_emulate(&chip8); - if (!events_handle(&chip8)) return EXIT_SUCCESS; if (chip8.drawflag) render(renderer, texture, &chip8); - usleep(1500); } SDL_DestroyTexture(texture);