Minor changes
This commit is contained in:
parent
8fd3d27abe
commit
7642efad5a
7 changed files with 31 additions and 8 deletions
19
src/vcpu.c
19
src/vcpu.c
|
@ -8,6 +8,7 @@ VCPU_State State;
|
|||
|
||||
void VCPUInit(){
|
||||
State.PC=ADDR_ROM;
|
||||
State.S=0;
|
||||
}
|
||||
|
||||
void VCPUFetch(){
|
||||
|
@ -54,12 +55,26 @@ void VCPUExecute(){
|
|||
State.I=State.NNN;
|
||||
break
|
||||
;;
|
||||
case 0xD:
|
||||
case 0xD: // Draw a sprite
|
||||
int X=State.V[State.X]%63;
|
||||
int Y=State.V[State.Y]%31;
|
||||
State.V[REG_FLAG]=0; // Set flag to 0
|
||||
int width,height;
|
||||
ScreenWH(&width,&height);
|
||||
for(char row=0;row<State.N;row++){
|
||||
|
||||
// Stop if row out of screen
|
||||
if(Y+row>=height)
|
||||
break;
|
||||
char sprite;
|
||||
MemRead(&sprite,1,State.I+row); // Load sprite
|
||||
// Draw sprite
|
||||
for(int shift=0;shift<8;shift++){
|
||||
// Stop if column is out of screen
|
||||
if(X+shift >= width)
|
||||
break;
|
||||
if(ScreenPixelApply(X+shift,Y+row,(sprite>>(7-shift))&0x1))
|
||||
State.V[REG_FLAG]=1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue