sprite method
void
sprite(
- int opcode
)
Implementation
void sprite(int opcode) {
var xLocation = registers.v[_rxIndex(opcode)];
var yLocation = registers.v[_ryIndex(opcode)];
var height = opcode & 0x000F;
registers.v[0xF] = 0;
for (int y = 0; y < height; y++) {
var pixel = memory[registers.index + y];
for (int x = 0; x < 8; x++) {
if ((pixel & (0x80 >> x)) != 0) {
var xPos = (xLocation + x) % 64;
var yPos = (yLocation + y) % 32;
if (display[yPos][xPos] == 1) registers.v[0xF] = 0x1;
display[yPos][xPos] ^= 1;
}
}
}
}