Pages

Saturday, December 12, 2009



Well I finally got the sprites to work OK. At least the little play I've had today. Problem has been how to get the rules for black-white dots for the four different cases and just what is a collision. The key is to concentrate on the white dots in the sprite, that is the 1's. A 1 onto a 1 gives a zero, a black dot and a 1 onto a 0 gives a white dot. The others stay the same. I don't have an EXOR function in the Processing language so had to bit-twiddle.

Here's some code that took a while:

void drawSpriteByte2(int x, int y, byte sprite) { // put byte at scrn x,y
int v15 =0, pixIndex=0, change=0;
color colorOfPixel,newPix=black;
loadPixels();

for (int i = 0;i<8;i++) {
change=0; //don't flick pixels unless we have to
pixIndex = y*width+x+i; //Might have to change to long later
colorOfPixel=pixels[pixIndex]; //current pixel, might change
if((colorOfPixel == black) && (bit(7-i,sprite) == 1)) {
newPix = white; change = 1;
// println("Drawn a white dot on black x,y pixPos "+ x + " " +y +" " +y*width+x+i+ " "+ pixIndex);
}
if((colorOfPixel == white) && (bit(7-i,sprite) == 1)) {
newPix = black;
change = 1; v15 =1;
// println("Drawn a black dot on black x,y pixPos ");
// v15 = 1;
}
if(change==1){
pixels[pixIndex] = newPix;
// println("Putting in colour-->at "+hex(newPix)+" "+ pixIndex);
}
}
//pixels[pixIndex] = white;
//pixels[1930] = white;
updatePixels();
}

void test_drawSpriteByte2() {
drawSpriteByte2(28,25,byte(0x22));
}

Thursday, December 10, 2009


Had another go at some old-fashioned Chip8 programs today. Tried to get chip8.exe emulator going again. Never had much luck in the past. This time I managed to get screens like the one above. I never really saw that much of the screen as it was a buzzing, jerky mess with not much response to key presses. Still, considering the way computers have changed since 1998 it's amazing to get something almost working.

Wednesday, December 9, 2009

First posting


<

Where's all the news about Chip8? Someone's just got to address this.