about summary refs log tree commit diff
path: root/emulator.h
diff options
context:
space:
mode:
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