about summary refs log tree commit diff
path: root/emulator.h
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-19 16:58:51 +0100
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2021-07-19 16:58:51 +0100
commit90f1c5689c4fc5f4ad75d544496c16ce54d01533 (patch)
tree460bb2e568b7b6f9f0015fc4657653ab0cacefd5 /emulator.h
parentFeature: Added placeholder for basic instructions needed to run the logo rom (diff)
downloadCHIP8-Emulator-90f1c5689c4fc5f4ad75d544496c16ce54d01533.tar.gz
CHIP8-Emulator-90f1c5689c4fc5f4ad75d544496c16ce54d01533.tar.bz2
CHIP8-Emulator-90f1c5689c4fc5f4ad75d544496c16ce54d01533.zip
Feature: Implemented instructions to run the logo rom
Diffstat (limited to 'emulator.h')
-rw-r--r--emulator.h46
1 files changed, 28 insertions, 18 deletions
diff --git a/emulator.h b/emulator.h
index 78ae516..05cd3ef 100644
--- a/emulator.h
+++ b/emulator.h
@@ -1,32 +1,42 @@
 #ifndef _EMULATOR_H_
 #define _EMULATOR_H_
 
-#include <stdio.h>
 #include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <sys/stat.h>
 #include <string.h>
 
 typedef struct
 {
     // general purpose registers
-    uint8_t V0;
-    uint8_t V1;
-    uint8_t V2;
-    uint8_t V3;
-    uint8_t V4;
-    uint8_t V5;
-    uint8_t V6;
-    uint8_t V7;
-    uint8_t V8;
-    uint8_t V9;
-    uint8_t VA;
-    uint8_t VB;
-    uint8_t VC;
-    uint8_t VD;
-    uint8_t VE;
-    uint8_t VF; //flag register
+    union
+    {
+        uint8_t V[16]; //VF is the flag register
+
+        struct
+        {
+            uint8_t V0;
+            uint8_t V1;
+            uint8_t V2;
+            uint8_t V3;
+            uint8_t V4;
+            uint8_t V5;
+            uint8_t V6;
+            uint8_t V7;
+            uint8_t V8;
+            uint8_t V9;
+            uint8_t VA;
+            uint8_t VB;
+            uint8_t VC;
+            uint8_t VD;
+            uint8_t VE;
+            uint8_t VF; //flag register
+        };
+    };
 
-    uint16_t I; // index register
+    // index register
+    uint16_t I;
 } Registers;
 
 typedef struct