Minor changes
This commit is contained in:
parent
3924115080
commit
475996af26
9 changed files with 146 additions and 4 deletions
52
src/vcpu.c
Normal file
52
src/vcpu.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include "vcpu.h"
|
||||
#include "mem.h"
|
||||
#include "screen.h"
|
||||
|
||||
// Program Counter (16 bits but only 12 bits used (4096 memory addresses))
|
||||
unsigned short PC;
|
||||
|
||||
// Index register (16 bits but only 12 bits used (4096 memory addresses))
|
||||
unsigned short I;
|
||||
|
||||
// Stack register (16 bits)
|
||||
unsigned short S;
|
||||
|
||||
// General purpose registers (8 bits each)
|
||||
// Note last one often used as a flag register
|
||||
unsigned char R[16];
|
||||
|
||||
// Delay timer (8 bits)
|
||||
unsigned char DT;
|
||||
|
||||
// Sound timer (8 bits)
|
||||
unsigned char ST;
|
||||
|
||||
// Current VCPU state
|
||||
VCPU_State State;
|
||||
|
||||
void VCPUInit(){
|
||||
PC=ADDR_ROM;
|
||||
}
|
||||
|
||||
void VCPUFetch(){
|
||||
MemRead((char *)&(State.opcode),2,PC);
|
||||
PC+=2;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void VCPUExecute(){
|
||||
switch(State.opcode){
|
||||
case 0x00E0:
|
||||
ScreenClear();
|
||||
break
|
||||
;;
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue