summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vcpu.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/vcpu.c b/src/vcpu.c
index e35d07e..f38ba01 100644
--- a/src/vcpu.c
+++ b/src/vcpu.c
@@ -13,7 +13,7 @@ unsigned short S;
// General purpose registers (8 bits each)
// Note last one often used as a flag register
-unsigned char R[16];
+unsigned char V[16];
// Delay timer (8 bits)
unsigned char DT;
@@ -34,19 +34,35 @@ void VCPUFetch(){
}
void VCPUDecode(){
- char X=(State.opcode<<4) & 0xF0;
- char Y=(State.opcode<<8) & 0xF0;
- char N=(State.opcode<<12) & 0xF0;
- char NN=(State.opcode<<8) & 0xFF;
- short NNN=(State.opcode<<4) & 0xFFF0;
+ State.X=(State.opcode<<4) & 0xF0;
+ State.Y=(State.opcode<<8) & 0xF0;
+ State.N=(State.opcode<<12) & 0xF0;
+ State.NN=(State.opcode<<8) & 0xFF;
+ State.NNN=(State.opcode<<4) & 0xFFF0;
}
void VCPUExecute(){
- switch(State.opcode){
- case 0x00E0:
+ switch(State.opcode & 0xF){
+ case 0x0:
ScreenClear();
break
;;
+ case 0x1:
+ PC=State.NNN;
+ break
+ ;;
+ case 0x6:
+ V[State.X]=State.NN;
+ break
+ ;;
+ case 0x7:
+ V[State.X]+=State.NN;
+ break
+ ;;
+ case 0xA:
+ I=State.NNN;
+ break
+ ;;
}
}