summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2019-09-28 21:38:39 -0400
committerAndrew Opalach <andrew@akon.city> 2019-09-28 21:38:39 -0400
commitab810064c790bbdb7b67927c30e7c1535004adab (patch)
tree2db3419491129b1cf34b77f2f22f5272d415f6c2
parent398ee4538c2ae4a818f2de7a61aeaa7e8e5f7f13 (diff)
downloadchip8-ab810064c790bbdb7b67927c30e7c1535004adab.tar.gz
chip8-ab810064c790bbdb7b67927c30e7c1535004adab.tar.bz2
chip8-ab810064c790bbdb7b67927c30e7c1535004adab.zip
fonts + right sdl dimensions
-rw-r--r--chip8.c6
-rw-r--r--ui_sdl.c2
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;