From ab810064c790bbdb7b67927c30e7c1535004adab Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sat, 28 Sep 2019 21:38:39 -0400 Subject: fonts + right sdl dimensions --- chip8.c | 6 +++++- ui_sdl.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chip8.c b/chip8.c index 6b7040d..a911656 100644 --- a/chip8.c +++ b/chip8.c @@ -39,6 +39,10 @@ static u8 font[] = { void init_vm() { vm.PC = 0x200; // start of chip8 programs + + for (int i = 0; i < sizeof(font); i++) { + vm.rom[0x100 + i] = font[i]; + } } void load_rom(char *file_path) { @@ -242,7 +246,7 @@ void vm_step() { vm.I += vm.Vx[in>>8&0xF]; break; case 0x29: // LD F, Vx - // characters + vm.I = 0x100 + (vm.Vx[in>>8&0xF] * 5); break; case 0x33: // LD B, Vx vm.rom[vm.I] = (vm.Vx[in>>8&0xF] / 100); diff --git a/ui_sdl.c b/ui_sdl.c index ccadcbf..2295a74 100644 --- a/ui_sdl.c +++ b/ui_sdl.c @@ -28,7 +28,7 @@ void draw() { SDL_RenderClear(r); SDL_SetRenderDrawColor(r, 160, 200, 255, 255); //SDL_RenderFillRect(r, &box); - for (int x = 0; x < 0x3F; x++) { + for (int x = 0; x <= 0x3F; x++) { for (int y = 0; y <= 0x1F; y++) { int byte = y * 64 + x; int bit = byte & 0x07; -- cgit v1.2.3-101-g0448