diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2023-12-25 09:11:45 +0100 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2023-12-25 09:11:45 +0100 |
| commit | 16f7128a0c81a508940ee1a8e8d1b8fe36f83259 (patch) | |
| tree | 690523d91c2b66d804e9db98143ff716ef1bba89 /src/vcpu.c | |
| parent | 14e9dd9258eaf62dba3867bb6edc9cd8687125c4 (diff) | |
Minor changes
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); +} |
