Minor changes

This commit is contained in:
Loïc Guégan 2023-12-25 09:11:45 +01:00
parent 14e9dd9258
commit 16f7128a0c
7 changed files with 48 additions and 11 deletions

View file

@ -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);
}