about summary refs log tree commit diff
path: root/emulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'emulator.c')
-rw-r--r--emulator.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/emulator.c b/emulator.c
index e69de29..afc78b1 100644
--- a/emulator.c
+++ b/emulator.c
@@ -0,0 +1,29 @@
+#include <emulator.h>
+
+int emulator_load_rom(Emulator* emulator, char* rom_name)
+{
+    printf("load rom!: %s\n", rom_name);
+    FILE* rom = fopen(rom_name, "r");
+    if(rom == NULL)
+    {
+        perror("no rom file!\n");
+        return 1;
+    }
+
+    struct stat st;
+    fstat(fileno(rom), &st);
+
+    int bytes_read = fread(emulator->memory, 1, st.st_size, rom);
+    if(bytes_read != st.st_size)
+    {
+        perror("doesnt cuadrar\n");
+        return 2;
+    }
+
+    return 0;
+}
+
+int emulator_tick(Emulator* emulator)
+{
+    return 0;
+}