clib.c (550B)
1 unsigned char* pixels; 2 unsigned char* input; 3 4 unsigned char x = 128, y = 128; 5 6 unsigned iter; 7 8 char color(int i){ 9 return (char) ((i%128)*8/128)<<5 | (((i/256)*16/256)%8)<<2 | (i%256 < 128 ? 0:1) | (i/256 < 128 ? 0:2); 10 } 11 12 void init(unsigned char* pixels_ptr, unsigned char* input_ptr){ 13 pixels = pixels_ptr; 14 input = input_ptr; 15 16 for(int i = 0 ; i < 256*256 ; i++){ 17 pixels[i] = color(i); 18 } 19 } 20 21 void loop(){ 22 if(*input & 2) 23 x++; 24 if(*input & 1) 25 x--; 26 if(*input & 4) 27 y--; 28 if(*input & 8) 29 y++; 30 31 pixels[x+y*256] = color(256*256-(x+y*256)); 32 } 33