about summary refs log tree commit diff
path: root/emulator.c
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-19 14:54:33 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-19 14:54:33 +0100
commitd0737d93433f09d9d1024d768a5c97b83f311a6a (patch)
tree4c564fd8b23c4842d2609ecca2d18b9243291d3d /emulator.c
parentMisc: Load roms after 0x200 (diff)
downloadCHIP8-Emulator-d0737d93433f09d9d1024d768a5c97b83f311a6a.tar.gz
CHIP8-Emulator-d0737d93433f09d9d1024d768a5c97b83f311a6a.tar.bz2
CHIP8-Emulator-d0737d93433f09d9d1024d768a5c97b83f311a6a.zip
Feature: Added a font
Diffstat (limited to 'emulator.c')
-rw-r--r--emulator.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/emulator.c b/emulator.c
index 699999c..1c02036 100644
--- a/emulator.c
+++ b/emulator.c
@@ -1,5 +1,31 @@
 #include <emulator.h>
 
+int emulator_initialise(Emulator* emulator)
+{
+    uint8_t font[] = {
+        0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
+        0x20, 0x60, 0x20, 0x20, 0x70, // 1
+        0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
+        0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
+        0x90, 0x90, 0xF0, 0x10, 0x10, // 4
+        0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
+        0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
+        0xF0, 0x10, 0x20, 0x40, 0x40, // 7
+        0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
+        0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
+        0xF0, 0x90, 0xF0, 0x90, 0x90, // A
+        0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
+        0xF0, 0x80, 0x80, 0x80, 0xF0, // C
+        0xE0, 0x90, 0x90, 0x90, 0xE0, // D
+        0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
+        0xF0, 0x80, 0xF0, 0x80, 0x80  // F
+                     };
+
+        memcpy(emulator->memory + 0x50, font, sizeof(font));
+
+        return 0;
+}
+
 int emulator_load_rom(Emulator* emulator, char* rom_name)
 {
     printf("load rom!: %s\n", rom_name);