diff --git a/src/vcpu.c b/src/vcpu.c index e722bb0..4ca5cc1 100644 --- a/src/vcpu.c +++ b/src/vcpu.c @@ -20,14 +20,19 @@ void VCPUFetch(){ } void VCPUDecode(){ - 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; + State.X=(State.opcode>>8) & 0xF; + State.Y=(State.opcode>>4) & 0xF; + State.N=State.opcode & 0xF; + + State.NN=State.Y; + State.NN=State.NN<<4; + State.NN=State.NN | State.N; + + State.NNN=State.opcode&0x0FFF; } void VCPUExecute(){ + // VCPUDump(); switch(State.opcode >> 12){ case 0x0: ScreenClear(); @@ -63,4 +68,9 @@ void VCPUExecute(){ void VCPUDump(){ printf("opcode: 0x%04x\n",State.opcode&0xFFFF); + printf("X: 0x%01x\n",State.X); + printf("Y: 0x%01x\n",State.Y); + printf("N: 0x%01x\n",State.N); + printf("NN: 0x%02x\n",State.NN); + printf("NNN: 0x%03x\n",State.NNN); }