All pastes #53052 Raw Edit

Unnamed

public text v1 · immutable
#53052 ·published 2006-05-03 00:42 UTC
rendered paste body
#include <stdio.h>

#define X_SIZE  40
#define Y_SIZE 60

//THESE WORK
#define SET_BIT(x,y) coordinate[(x) / 8][y] |= (0x80 >> ((x) % 8))
#define CLEAR_BIT(x,y) coordinate[(x) / 8][y] &= (0x0 >> ((x) % 8))

//DOESNT WORK
#define TEST_BIT(x,y) coordinate[(x) / 8][y] |= (0x80 >> ((x) % 8))
//ANY SPOT WITHIN 8 TESTS POSITIVE

char coordinate[X_SIZE / 8][Y_SIZE];  //the bitmap

//***************************************************

int main(){
//  skip a bunch of stuff

//  DRAW A DIAGONAL LINE
for (spot = 0; spot < X_SIZE; ++spot)
	SET_BIT(spot, spot);

//  CLEAR THAT LINE
for (spot = 0; spot < X_SIZE; ++spot)
	CLEAR_BIT(spot, spot);	

//  DOESN'T WORK.  IS THAT BIT SET?  DOESN'T WORK.
if (TEST_BIT(test_x,test_y) == 1)
        printf("Yup.\n");


return(0);
}


void print_graph(void){
int x = 0;
int y = 0;
unsigned int bit;

for (y = 0; y < Y_SIZE; y++){
	for (x = 0; x < X_SIZE / 8; x++){
		for (bit = 0x80; bit > 0; bit = bit >> 1){
			if ((bit & coordinate[x][y]) == 0) 
				printf(" . ");
			else
				printf(" X ");
			}	
		}
	printf("New line\n");
	}
}