summaryrefslogtreecommitdiff
path: root/src/vcpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vcpu.c')
-rw-r--r--src/vcpu.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/src/vcpu.c b/src/vcpu.c
index f38ba01..3bce28a 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -2,35 +2,17 @@
#include "mem.h"
#include "screen.h"
-// Program Counter (16 bits but only 12 bits used (4096 memory addresses))
-unsigned short PC;
-
-// Index register (16 bits but only 12 bits used (4096 memory addresses))
-unsigned short I;
-
-// Stack register (16 bits)
-unsigned short S;
-
-// General purpose registers (8 bits each)
-// Note last one often used as a flag register
-unsigned char V[16];
-
-// Delay timer (8 bits)
-unsigned char DT;
-
-// Sound timer (8 bits)
-unsigned char ST;
// Current VCPU state
VCPU_State State;
void VCPUInit(){
- PC=ADDR_ROM;
+ State.PC=ADDR_ROM;
}
void VCPUFetch(){
- MemRead((char *)&(State.opcode),2,PC);
- PC+=2;
+ MemRead((char *)&(State.opcode),2,State.PC);
+ State.PC+=2;
}
void VCPUDecode(){
@@ -48,19 +30,19 @@ void VCPUExecute(){
break
;;
case 0x1:
- PC=State.NNN;
+ State.PC=State.NNN;
break
;;
case 0x6:
- V[State.X]=State.NN;
+ State.V[State.X]=State.NN;
break
;;
case 0x7:
- V[State.X]+=State.NN;
+ State.V[State.X]+=State.NN;
break
;;
case 0xA:
- I=State.NNN;
+ State.I=State.NNN;
break
;;