All pastes #746282 Raw Edit

Something

public text v1 · immutable
·published 2007-10-23 03:13 UTC
rendered paste body
#include <tigcclib.h>
#define LCD_BYTES_COLS	20
#define LCD_ROW_BYTES	30
#define LCD_BOTTOM_ROW (void *)0x579A

unsigned long blocks = 0;
char spacing_count = 39, max_spacing = 40, max_spacing_count = 0, platform_row = 4;

char ball_x = 77, ball_y = 64;
unsigned char ball[] = {0x78,0x9C,0xBC,0xFC,0xFC,0x78};

void delay(int len) {
	int i, randnum;
	for (i = 0; i < len; i++) {
		randnum = random(0xFF);
	}
}

void scroll_up() {
	memcpy(LCD_MEM, LCD_MEM + LCD_ROW_BYTES, LCD_ROW_BYTES * LCD_HEIGHT);
}

void draw_platform() {
	if (platform_row == 4) {   // If we have drawn all four lines of a platform
		spacing_count++;  // Increase our count of the space between each platform
		if (spacing_count == max_spacing) {  // If it is time to draw a new block...
			platform_row = 0;  
			randomize();
			blocks = ((long)random(0xFFFF) << 16) | ((long)random(0xFFFF));  // Generate a new random platform 
			spacing_count = 0;   // Reset the spacing count
			max_spacing_count++;  // And add one to max spacing count
			if (max_spacing_count == 5) {   // Its time to decrease the spacing between platforms
				max_spacing--; 
				if (max_spacing <= 8) {  // Unless the spacing is too thin, then dont change it
					max_spacing = 8;
				} 
				max_spacing_count = 0;
			}
		}
	} else {
		int i;
		unsigned long bits = 0x00080000;
		char *lcd = LCD_BOTTOM_ROW;
		for (i = 0; i < 20; i++){
			if (blocks & bits) {
				if (platform_row == 0 || platform_row == 3) {
					lcd[i] = 0xFF;  // Fill ones with lines
				} else {
					lcd[i] = random(0xFF);  // or with randomness
				}
			}
			bits >>= 1;
		}
		platform_row++;
	}
}

void move_up() {
	//printf("UP\n");
	ball_y--; 
}

void move_down() {
//	printf("DOWN\n");
	Sprite8(ball_x, ball_y - 1, 6, ball, LCD_MEM, SPRT_XOR);
	unsigned char *check = LCD_MEM + (LCD_ROW_BYTES * (ball_y + 6)) + (ball_x / 8);
	if (ball_x % 8 < 2) {
		if (!*check) { 
			ball_y++;
		} 
	} else {
		if (!(check[0] | check[1])) {
			ball_y++;
		} 
	}
	Sprite8(ball_x, ball_y, 6, ball, LCD_MEM, SPRT_XOR);	
}

void move_ball() {
	// Gravitty
	unsigned char *check = LCD_MEM + (LCD_ROW_BYTES * (ball_y + 7)) + (ball_x / 8);
//	*check = 0x02;
	if (ball_x % 8 < 2) {
		if (!*check) { 
			move_down();
		} else {
			move_up();
		}
	} else {
		if (!(check[0] | check[1])) {
			move_down();
		} else {
			move_up();
		}
	}
}

void _main(void) {
	ClrScr();
//	for (i = 0; i < 100; i++) {
//		scroll_up();
//	}
	Sprite8(ball_x, ball_y, 6, ball, LCD_MEM, SPRT_XOR);
	unsigned char *check = 0x550F;
	*check = 0x02;

	int i;
	for (i = 0; i < 20; i++) {
//	Sprite8(ball_x, ball_y - 1, 6, ball, LCD_MEM, SPRT_XOR);
//		ball_y++;	
//		Sprite8(ball_x, ball_y, 6, ball, LCD_MEM, SPRT_XOR);
		delay(10000);
		scroll_up();
		move_ball();
		delay(10000);
	}
//		move_ball();
//		delay(5000);
//	}
/*	while (!kbhit()) {
//		move_ball();
//		draw_platform();
		scroll_up();
		delay(400);
	}
*/
	ngetchx();
}