goobers
Member
Hi, I've got some code as below:
CODE
x = V[(opcode&0x0F00)>>8];
y = V[(opcode&0x00F0)>>4];
for (int yline=0;yline<(opcode&0x000F);yline++){
char data = memory[(indexReg+yline)];
for(int xpix=0;xpix<8;xpix++){
if ((data&(0x80>>xpix))==1){
if (screenBuf[x+xpix][y+yline]==1)V[0xF]=1;
screenBuf[x+xpix][y+yline]^=1;
}
}
}
I want the data in the screenBuf array to be either 1s or 0s, but for some reason when I dump out the values, they are all sorts of values, rarely 1s
Is there something simple that I'm missing here? I've been trying to sort this out for hours- Its the code that handles the screen drawing opcode for my Chip8 emulator, It is supposed to read in a byte from indexReg, extract all the bits and apply each one to a seperate x coordinate in screenBuf. It repeats this for each y line.
CODE
x = V[(opcode&0x0F00)>>8];
y = V[(opcode&0x00F0)>>4];
for (int yline=0;yline<(opcode&0x000F);yline++){
char data = memory[(indexReg+yline)];
for(int xpix=0;xpix<8;xpix++){
if ((data&(0x80>>xpix))==1){
if (screenBuf[x+xpix][y+yline]==1)V[0xF]=1;
screenBuf[x+xpix][y+yline]^=1;
}
}
}
I want the data in the screenBuf array to be either 1s or 0s, but for some reason when I dump out the values, they are all sorts of values, rarely 1s
Is there something simple that I'm missing here? I've been trying to sort this out for hours- Its the code that handles the screen drawing opcode for my Chip8 emulator, It is supposed to read in a byte from indexReg, extract all the bits and apply each one to a seperate x coordinate in screenBuf. It repeats this for each y line.