diff options
Diffstat (limited to 'src/vcpu.c')
| -rw-r--r-- | src/vcpu.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1,7 +1,7 @@ #include "vcpu.h" #include "mem.h" #include "screen.h" - +#include <stdio.h> // Current VCPU state VCPU_State State; @@ -11,7 +11,11 @@ void VCPUInit(){ } void VCPUFetch(){ - MemRead((char *)&(State.opcode),2,State.PC); + unsigned char byte[2]; + MemRead(byte,2,State.PC); // Little indian to -1 no +1 + State.opcode=byte[0]; + State.opcode=State.opcode<<8; + State.opcode=State.opcode | byte[1]; State.PC+=2; } @@ -24,7 +28,7 @@ void VCPUDecode(){ } void VCPUExecute(){ - switch(State.opcode & 0xF){ + switch(State.opcode >> 12){ case 0x0: ScreenClear(); break @@ -45,6 +49,18 @@ void VCPUExecute(){ State.I=State.NNN; break ;; - + case 0xD: + int X=State.V[State.X]%63; + int Y=State.V[State.Y]%31; + State.V[0xF]=0; // Set flag to 0 + for(char row=0;row<State.N;row++){ + + } + break; + ;; } } + +void VCPUDump(){ + printf("opcode: 0x%04x\n",State.opcode&0xFFFF); +} |
