Esempio n. 1
0
void game_screen() {
	alt_up_char_buffer_clear(char_buffer);

	char str1[50], str2[30], str3[50];

	sprintf(str1, "Player 1: $%d", dealer->players[0].total_money);
	alt_up_char_buffer_string(char_buffer, str1, 5, 5);

	sprintf(str1, "Player 2: $%d", dealer->players[1].total_money);
	alt_up_char_buffer_string(char_buffer, str1, 5, 10);

	Bitmap* flop_card0_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[0]));
	Bitmap* flop_card1_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[1]));
	Bitmap* flop_card2_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[2]));
	Bitmap* turn_card_bmp  = load_bitmap(card_bitmap_name(dealer->cards_on_table[3]));
	Bitmap* river_card_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[4]));

	draw_bitmap(flop_card0_bmp, 25, 60);
	draw_bitmap(flop_card1_bmp, 55, 60);
	draw_bitmap(flop_card2_bmp, 85, 60);
	draw_bitmap(turn_card_bmp, 115, 60);
	draw_bitmap(river_card_bmp, 145, 60);

	sprintf(str3, "Pot: $%d", dealer->pot);
	alt_up_char_buffer_string(char_buffer, str3, 5, 50);

	sprintf(str3, "Current Bet: $%d", dealer->current_bet);
	alt_up_char_buffer_string(char_buffer, str3, 5, 51);
	draw_to_screen();
}
Esempio n. 2
0
void clear_menu_text(alt_up_char_buffer_dev* char_buffer) {
	alt_up_char_buffer_string(char_buffer, "           ", 3, 5);
	alt_up_char_buffer_string(char_buffer, "      ", 23, 5);
	alt_up_char_buffer_string(char_buffer, "      ", 38, 5);
	alt_up_char_buffer_string(char_buffer, "        ", 53, 5);
	alt_up_char_buffer_string(char_buffer, "    ", 70, 5);
}
void heads_up_display_static(void){
	alt_up_char_buffer_dev *char_buffer_score;
	alt_up_pixel_buffer_dma_dev* pixel_buffer;

	char_buffer_score = alt_up_char_buffer_open_dev("/dev/char_drawer");
	alt_up_char_buffer_init(char_buffer_score); //initializes character buffer
	alt_up_char_buffer_clear(char_buffer_score); //clears the character buffer of an previous characters
	alt_up_char_buffer_string(char_buffer_score,"Score:", 5, 50); //updates score
	alt_up_char_buffer_string(char_buffer_score,"Milk:", 5, 52); //updates resources
	alt_up_char_buffer_string(char_buffer_score,"Level:", 5, 54); //updates level
	alt_up_char_buffer_string(char_buffer_score,"Time:", 5, 56); //updates time

	pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma");

	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,120,11,130,BLACK,0);//draws black baby's body
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,130,11,133,WHITE,0);//draws diaper

	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,150,11,160,BEIGE,0);//draws beige baby's body
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,160,11,163,WHITE,0);//draws diaper

	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,180,11,190,YELLOW,0);//draws yellow baby's body
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer,1,190,11,193,WHITE,0);//draws diaper

	//draws rectangle around indicator of tower choice
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer,0,119,12,134,ORANGE,0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer,0,149,12,164,ORANGE,0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer,0,179,12,194,ORANGE,0);
}
Esempio n. 4
0
void draw_menu_text(alt_up_char_buffer_dev* char_buffer) {
	alt_up_char_buffer_string(char_buffer, "HOW TO PLAY", 3, 5);
	alt_up_char_buffer_string(char_buffer, "TOWERS", 23, 5);
	alt_up_char_buffer_string(char_buffer, "SHARKS", 38, 5);
	alt_up_char_buffer_string(char_buffer, "CONTROLS", 53, 5);
	alt_up_char_buffer_string(char_buffer, "DEVS", 70, 5);
}
void prepareText(void){
	alt_up_char_buffer_clear(char_buffer_dev);
	//Chars for the vertical line (Vpp)
	alt_up_char_buffer_string(char_buffer_dev,"2.5",0,0);
	alt_up_char_buffer_string(char_buffer_dev," V ",0,29);
	alt_up_char_buffer_string(char_buffer_dev,"0.0",0,56);
	//Chars for the horizontal line (kHz) (soft, except for kHz)
	alt_up_char_buffer_string(char_buffer_dev,"kHz",37,58);
}
Esempio n. 6
0
void display_Input(int angle, int velocity )
{

	char buffer[11]; //stores string to print
	const float multipler_to_make_out_of_100 = 1.34;
	alt_up_char_buffer_string(char_buffer, "Angle: ", 0, 1);
	sprintf(buffer, "%d", angle); //convert int to string

	//To display 3 digits all the time, we need to add '0's in front if value is less than 3 digits
	if (angle < 10)
	{

		buffer[2] = buffer[0];
		buffer[1] = '0';
		buffer[0] = '0';

	}
	else if(angle < 100)
	{
		buffer[2] = buffer[1];
		buffer[1] = buffer[0];
		buffer[0] = '0';
	}

	buffer[3] ='\0';

	alt_up_char_buffer_string(char_buffer, buffer, 6, 1);
	sprintf(buffer, "%d", (int)(velocity * multipler_to_make_out_of_100));


	if (velocity * multipler_to_make_out_of_100 < 10)
	{

		buffer[2] = buffer[0];
		buffer[1] = '0';
		buffer[0] = '0';

	}
	else if(velocity * multipler_to_make_out_of_100 < 100)
	{
		buffer[2] = buffer[1];
		buffer[1] = buffer[0];
		buffer[0] = '0';
	}

	buffer[3] ='\0';

	alt_up_char_buffer_string(char_buffer, "Power: ", 11, 1);
	alt_up_char_buffer_string(char_buffer, buffer, 21, 1);

	//charge bar: top left is fixed, while bottom right is dependent on velocity
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x0_chargeBar, y0_chargeBar, (velocity) + x0_chargeBar, chargeBar_Width +  y0_chargeBar, 0xF800, 0);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, x0_chargeBar, y0_chargeBar, (velocity) + x0_chargeBar, chargeBar_Width +  y0_chargeBar, 0xF800, 1);

}
void heads_up_display_dynamic(int variable_type,int variable,alt_up_char_buffer_dev *char_buffer_time,char* int_buffer){

	switch(variable_type){

	case 0: //Change score
		alt_up_char_buffer_string(char_buffer_time,int_buffer, 12, 50);
	case 1: //Change resources
		alt_up_char_buffer_string(char_buffer_time,int_buffer, 11, 52);
	case 2: //Change level
		alt_up_char_buffer_string(char_buffer_time,int_buffer, 12, 54);
	case 3: //Change time
		alt_up_char_buffer_string(char_buffer_time,int_buffer, 11, 56);

	}

}
Esempio n. 8
0
void display_score()
{
	char* display_score_message[20];
	if(m == displayscore)
	{
		bluebackground(v.pixel_buffer);

		// Swap buffers
		alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer);
		while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer));

		alt_up_char_buffer_clear(v.char_buffer);
		sprintf( display_score_message, "FINAL SCORE: %d", rb.score );
		alt_up_char_buffer_string(v.char_buffer, "GAME OVER.", 36, 20);
		alt_up_char_buffer_string(v.char_buffer, display_score_message, 32, 30);
	}
}
void displayHorRange(int minval, int maxval){
	char tempstr[3];
	sprintf(tempstr,"%d",minval);
	int pos = 3;
	if (strlen(tempstr) > 1){
		pos--;
	} else {
		alt_up_char_buffer_string(char_buffer_dev," ", pos-1,57);
	}
	alt_up_char_buffer_string(char_buffer_dev,tempstr, pos,57);
	sprintf(tempstr,"%d",maxval);

	if (strlen(tempstr) < 3){
		alt_up_char_buffer_string(char_buffer_dev,"  ",80 - 3,57);
	} else 	if (strlen(tempstr) < 2){
		alt_up_char_buffer_string(char_buffer_dev," ",80 - 2,57);
	}
	alt_up_char_buffer_string(char_buffer_dev,tempstr,80 - strlen(tempstr),57);
}
//This is also an temp function
void displayFPS(void){
	frames++;
	time_t currentTime = time(NULL);
	if (currentTime > lastTime){
		char tempstr[5];
		sprintf(tempstr,"%d",frames);
		alt_up_char_buffer_string(char_buffer_dev,tempstr,80 - strlen(tempstr),0);
		lastTime = currentTime;
		frames = 0;
	}
}
Esempio n. 11
0
void VGA_task(void* pvParameters){

	while(1){
		alt_up_char_buffer_string(char_buf, "Hello World", 40, 30);
		//usleep(1000000);
		alt_up_char_buffer_draw(char_buf, '!', 51, 30);
		//usleep(1000000);
		alt_up_char_buffer_clear(char_buf);
		//usleep(1000000);
	}
}
Esempio n. 12
0
/*
 * An abstract function that allows to load all images with same prefix
 *	index is the number of characters that are prefix
 */
struct animation* loadSDImageSeq(char* filename, int index, int size) {
	int i = 0, j = 0;
	swap = 0;
	char temp[30],buffer[30];
	char buff[20];
	char* prefix = (char*)malloc(sizeof(char)*(index+1));
	prefix[index] = '\0';
	int* ptr = NULL;

	strncpy(prefix, filename, index);
	struct animation* a = NULL;
	struct animation* b = NULL;
	while(i < size) {
		strcpy(temp, prefix);
		buffer[0] = 0;
		sprintf(buffer, "%d.BMP ", i);
		if(i < 10) {
			strncat(temp, buffer, 5);
			strcpy(buff, temp);
			for(j = 0; j < i%5; j++) {
				buff[index+5+j] = '.';
			} buff[index+5+j] = ' ';buff[index+6+j] = ' ';buff[index+7+j] = ' ';buff[index+8+j] = ' ';buff[index+9+j] = '\0';
		}else {
			strncat(temp, buffer, 6);
			strcpy(buff, temp);
			for(j = 0; j < i%5; j++) {
				buff[index+6+j] = '.';
			}
			buff[index+6+j] = ' ';buff[index+6+j+1] = ' ';buff[index+6+j+2] = ' ';buff[index+9+j] = '\0';
		}
		if(info.start == 1) {
			alt_up_char_buffer_string(char_buffer, buff, 48, 30); //show reading file name because we are in loading page
		}
		while(!loadSDImage(temp, &ptr)){
			printf("Loading File Error: %s\n", temp);
		}
		if(i == 0) {
			a = initAnimation(ptr, 1);
			imageInDisk(a);
		}
		else {
			b = initAnimation(ptr, 0);
			imageInDisk(b);
			addImage(a, b);
		}
		i++;
	}
	free(prefix); prefix = NULL;
	return a;
}
Esempio n. 13
0
void draw_nothing()
{
	if(0) // Check if in waiting mode
	{
		bluebackground(v.pixel_buffer);
		alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer);
		while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer));
		if(v.blank_flag == FALSE)
		{
			alt_up_char_buffer_clear(v.char_buffer);
			alt_up_char_buffer_string(v.char_buffer, "Waiting for user input...", 27, 30);
			v.blank_flag = TRUE;
		}
	}
}
Esempio n. 14
0
void draw_developers_guide(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer){
	alt_up_char_buffer_clear(char_buffer);
	draw_menu_text(char_buffer);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 31, 320, 240, BLACK, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 195, 10, 260, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 260, 10, 319, 30, YELLOW, 0);
	alt_up_char_buffer_string(char_buffer, "D E V E L O P E R S", 31, 12);
	alt_up_char_buffer_string(char_buffer, "___________________", 31, 13);
	alt_up_char_buffer_string(char_buffer, "CYRIL CANONIZADO", 33, 19);
	alt_up_char_buffer_string(char_buffer, "DAVID LU", 37, 23);
	alt_up_char_buffer_string(char_buffer, "KEVAL SHAH", 36, 27);
	alt_up_char_buffer_string(char_buffer, "BRYCE TOWNS", 36, 31);
}
Esempio n. 15
0
//Audio selection screen and volume control
void select_bgm(char ** soundfiles, int numfiles)
{
	int init_y;
	int i;
	int y_index = 4;
	int temp,temp2;
	char ptr[] = "->";
	int cross;
	int crossptr = 36;

	if (onetime > 0)
	{
		free(bgm);	//If called again, clean up original file name for audio file
	}

	bgm = (char *)malloc(sizeof(char) * (MAX_NAME_LEN + direct_len));
	char vol_display[3];
	temp2 = sprintf(vol_display, "%d", ((int)(VOL_SET * 10)));

	alt_up_char_buffer_string(char_buffer, "Select BGM file",33, y_index);
	alt_up_char_buffer_string(char_buffer, "Use D-pad to scroll",31, 6);
	alt_up_char_buffer_string(char_buffer, "Use Left & Right to scroll to volume",25, 7);
	alt_up_char_buffer_string(char_buffer, "Press 'X' to select",31, 8);
	alt_up_char_buffer_string(char_buffer, "Volume Control",62, 21);
	alt_up_char_buffer_string(char_buffer, "+", 68, 26);
	alt_up_char_buffer_string(char_buffer, vol_display, 68, 30);
	alt_up_char_buffer_string(char_buffer, "-", 68, 34);

	y_index = 27;
	temp = numfiles;
	while (temp > 0) {
		y_index -= 2;
		temp--;
	}
	for(i = 0; i < numfiles; i++) {
		if (soundfiles[i] != NULL) {
			y_index += 3;					//Display soundfiles
			alt_up_char_buffer_string(char_buffer, soundfiles[i],36, y_index);
			if (i == 0) {
				arrow_y = y_index;
				init_y = arrow_y;
				if (arrow_x == 0) {
					alt_up_char_buffer_string(char_buffer, ptr,33, arrow_y);
				}
				else if (arrow_x == 1){
					arrow_y = 30;
					alt_up_char_buffer_string(char_buffer,"->",65, arrow_y);


				}
			}
		}
	}

	arrow_index = 0;

	while(1) {
		if(*keys == 7)
		{
			usleep(150000);
			if (((arrow_index) > 0) && (arrow_x == 0)) {
				alt_up_char_buffer_string(char_buffer,"  ",33, arrow_y);
				arrow_y -= 3;
				alt_up_char_buffer_string(char_buffer,ptr,33, arrow_y);
				arrow_index--;
			}
			else if (arrow_x == 1) {
				alt_up_char_buffer_string(char_buffer, " ", 68, 30);
				VOL_SET = VOL_SET + 0.1;		//Volume precision
				if (VOL_SET >= 2.0)
					VOL_SET = 2.0;	//Max volume
				temp2 = sprintf(vol_display, "%d", ((int)(VOL_SET * 10)));
				alt_up_char_buffer_string(char_buffer, vol_display, 68, 30);
			}
		}
		if(*keys == 11)
		{
			usleep(150000);
			if (((arrow_index) < (numfiles - 1)) && (arrow_x == 0)) {
				alt_up_char_buffer_string(char_buffer,"  ",33, arrow_y);
				arrow_y += 3;
				alt_up_char_buffer_string(char_buffer,ptr,33, arrow_y);
				arrow_index++;
			}
			else if (arrow_x == 1) {
				alt_up_char_buffer_string(char_buffer, "  ", 68, 30);
				VOL_SET = VOL_SET - 0.1;
				if (VOL_SET <= 0.0)
					VOL_SET = 0.0;
				temp2 = sprintf(vol_display, "%d", ((int)(VOL_SET * 10)));
				alt_up_char_buffer_string(char_buffer, vol_display, 68, 30);
			}
		}

		//Select button
		if(*switches == 1)
		{
			usleep(150000);
			if (arrow_x == 0) {
				cross = strlen(soundfiles[arrow_index]);
				for (i = 0; i < cross; i++) {
					alt_up_char_buffer_string(char_buffer,"-",crossptr, arrow_y);
					crossptr++;
				}
				strcpy(bgm, AUD_DIRECT);
				strcat(bgm, soundfiles[arrow_index]);
				alt_up_char_buffer_clear(char_buffer);
				alt_up_char_buffer_string(char_buffer,"Loading, Please Wait",31, 25);
				init_wav(bgm, VOL_SET, 0);
				alt_up_audio_enable_write_interrupt(audio);		//Resume audio
				alt_up_char_buffer_clear(char_buffer);
				return;
			}
		}
		if(*keys == 13)
		{
			usleep(150000);
			if (arrow_x == 0) {
				arrow_x = 1;
				alt_up_char_buffer_string(char_buffer,"  ",33, arrow_y);
				arrow_y = 30;
				alt_up_char_buffer_string(char_buffer,"->",65, arrow_y);
			}
		}
		if (arrow_x == 1) {
			arrow_x = 0;
			alt_up_char_buffer_string(char_buffer,"  ",65, arrow_y);
			arrow_y = init_y;
			alt_up_char_buffer_string(char_buffer,"->",33, arrow_y);
			arrow_index = 0;
		}

		/*
		else if (ps.b.sel == 1) {
			usleep(150000);
			alt_up_audio_enable_write_interrupt(audio);
			alt_up_char_buffer_clear(char_buffer);
			return;

		}
		 */
		usleep(150000);
	}

}
Esempio n. 16
0
void draw_towers_guide(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer){
	alt_up_char_buffer_clear(char_buffer);
	draw_menu_text(char_buffer);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 31, 320, 240, BLACK, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 0, 10, 70, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 140, 10, 190, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 70, 10, 140, 30, YELLOW, 0);

	/* Tower Row 1 Col 1 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 10, 40, 50, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 10, 82, 50, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 3, 22);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 3, 24);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 3, 26);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 3, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 3, 30);

	/* Tower Row 1 Col 2 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 40, 102, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 82, 102, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 16, 22);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 16, 24);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 16, 26);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 16, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 16, 30);

	/* Tower Row 1 Col 3 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 40, 154, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 82, 154, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 29, 22);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 29, 24);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 29, 26);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 29, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 29, 30);

	/* Tower Row 1 Col 4 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 40, 204, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 82, 204, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 42, 22);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 42, 24);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 42, 26);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 42, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 42, 30);

	/* Tower Row 1 Col 5 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 218, 40, 258, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 218, 82, 258, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 55, 22);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 55, 24);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 55, 26);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 55, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 55, 30);


	/* Tower Row 2 Col 1 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 10, 140, 50, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 10, 182, 50, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 3, 47);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 3, 49);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 3, 51);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 3, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 3, 55);

	/* Tower Row 2 Col 2 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 140, 102, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 182, 102, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 16, 47);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 16, 49);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 16, 51);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 16, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 16, 55);

	/* Tower Row 2 Col 3 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 140, 154, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 182, 154, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 29, 47);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 29, 49);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 29, 51);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 29, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 29, 55);

	/* Tower Row 2 Col 4 */
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 140, 204, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 182, 204, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 42, 47);
	alt_up_char_buffer_string(char_buffer, "COST: XXX", 42, 49);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 42, 51);
	alt_up_char_buffer_string(char_buffer, "F.RATE: X", 42, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 42, 55);
}
Esempio n. 17
0
void draw_sharks_guide(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer){
	alt_up_char_buffer_clear(char_buffer);
	draw_menu_text(char_buffer);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 31, 320, 240, BLACK, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 70, 10, 140, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 195, 10, 260, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 140, 10, 190, 30, YELLOW, 0);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 40, 102, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 62, 82, 102, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 16, 22);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 16, 24);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 16, 26);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 16, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 16, 30);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 40, 154, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 82, 154, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 29, 22);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 29, 24);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 29, 26);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 29, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 29, 30);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 40, 204, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 82, 204, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 42, 22);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 42, 24);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 42, 26);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 42, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 42, 30);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 218, 40, 258, 80, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 218, 82, 258, 132, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 55, 22);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 55, 24);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 55, 26);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 55, 28);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 55, 30);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 140, 154, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 114, 182, 154, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 29, 47);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 29, 49);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 29, 51);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 29, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 29, 55);

	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 140, 204, 180, RED, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 166, 182, 204, 232, WHITE, 0);
	alt_up_char_buffer_string(char_buffer, "HP: XXX", 42, 47);
	alt_up_char_buffer_string(char_buffer, "DMG: XXX", 42, 49);
	alt_up_char_buffer_string(char_buffer, "A.RATE: X", 42, 51);
	alt_up_char_buffer_string(char_buffer, "SPEED: XX", 42, 53);
	alt_up_char_buffer_string(char_buffer, "EFF: XXX", 42, 55);

}
Esempio n. 18
0
void draw_sheetmusic()
{
	// Symbolic constants
	int x_indent = 16;
	int y_indent = 100;
	int space_height = (240 - 2*y_indent)/4;

	// Declare variables
	int i;

	if(m == blank)
	{
		rb.background_flag = FALSE;
		if(v.blank_flag == FALSE)
		{
			alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 0, 0, 319, 239, 0xFFFF, 1); // White box to fill the back buffer
			for(i=0; i<5; i++) // Draw 5 horizontal lines of the musical staff to the back buffer
				alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, x_indent-2, 320-(x_indent-2), y_indent+space_height*i, 0x0000, 1);

			// Double bar line at the start
			alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, x_indent-4, y_indent, x_indent-2, 240-y_indent, 0x0000, 1);
			alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, x_indent, y_indent, 240-y_indent, 0x0000, 1);

			// Double bar line at the end
			alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 320-(x_indent-4), y_indent, 320-(x_indent-2), 240-y_indent, 0x0000, 1);
			alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, 320-x_indent, y_indent, 240-y_indent, 0x0000, 1);

			// Three bar lines to divide the staff into four measures
			alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, (160+x_indent)/2, y_indent, 240-y_indent, 0x0000, 1);
			alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, 160, y_indent, 240-y_indent, 0x0000, 1);
			alt_up_pixel_buffer_dma_draw_vline(v.pixel_buffer, (480-x_indent)/2, y_indent, 240-y_indent, 0x0000, 1);

			// Draw some notes: C major scale
			draw_qnote_on_sheetmusic(v.pixel_buffer, 0, 0);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 1, 1);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 2, 2);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 3, 3);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 4, 4);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 5, 5);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 6, 6);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 7, 7);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 7, 8);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 6, 9);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 5, 10);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 4, 11);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 3, 12);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 2, 13);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 1, 14);
			draw_qnote_on_sheetmusic(v.pixel_buffer, 0, 15);

			// Blue box and message near top of the screen
			alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 100, 26, 220, 40, 0x122B, 1);
			alt_up_char_buffer_clear(v.char_buffer);
			alt_up_char_buffer_string(v.char_buffer, "Waiting for user input...", 28, 8);
			v.blank_flag = TRUE;

			// Swap buffers
			alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer);
			while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer));


		}
	}
}
Esempio n. 19
0
void update_rb(int note_pressed)
// FUNCTION: Updates the RB_data struct and displays the new data on the moniter.
// REQUIRES: if no note has been pressed, note_pressed < 0
// 			 if a note has been pressed, 0 <= note_pressed <= 11
// RETURNS: None
{
	// Declare variables
	int i, j, difference;
	char* all_notes[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};

	if(m == notegame) // Check if in rockband mode
	{
		v.blank_flag = FALSE;

		if(rb.background_flag == FALSE)
		{

			// Clear char buffer
			alt_up_char_buffer_clear(v.char_buffer);
			for(j=0; j<12; j++)
				alt_up_char_buffer_string(v.char_buffer, all_notes[j], 10 + 5*j, 55 - rb.CORRECT_ZONE_HEIGHT/2); // Print the pitch at its corresponding location
			rb.background_flag = TRUE;
		}

			/*
			// Draw blue background and correct zone to back buffer

			bluebackground(v.pixel_buffer);

			alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, 0, 319, 220-4*rb.CORRECT_ZONE_HEIGHT, 0x0000, 1); // Top of the correct zone

			alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 0, 221-4*rb.CORRECT_ZONE_HEIGHT, 319, 219, 0xCCCC, 1);

			alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, 0, 319, 220, 0x0000, 1); // Bottom of the correct zone



			// Swap buffers
			alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer);

			while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer));

			*/

			// Draw blue background and correct zone to back buffer
			bluebackground(v.pixel_buffer);

			draw_correct_zone(v.pixel_buffer, rb.CORRECT_ZONE_HEIGHT);

			// Clear char buffer
			alt_up_char_buffer_clear(v.char_buffer);
			for(j=0; j<12; j++)
				alt_up_char_buffer_string(v.char_buffer, all_notes[j], 10 + 5*j, 55 - rb.CORRECT_ZONE_HEIGHT/2); // Print the pitch at its corresponding location

		// Clear char buffer
		// alt_up_char_buffer_clear(v.char_buffer);

		for(j=0; j<12; j++) rb.in_correct_zone[j] = FALSE; // Reset all entries at each update


		//rb.time = alt_timestamp() / (float) alt_timestamp_freq();
		// Time represents the amount of time passed since the game started, in seconds

		rb.count = rb.time / rb.RB_TIME_CONSTANT_S;
		// Count represents the number of time constants that have passed since the game started

		rb.count_difference = rb.count - rb.old_count;
		// Count_difference represents the number of time constants that have passed since the last time update_rb was called

		rb.old_count = rb.count;
		// Old_count represents the number of time constants passed from the start of the game to the last time update_rb was called

		rb.index = rb.count / 10;
		// Index represents the number of notes that are active
		// printf("Index:%d\n", rb.index);

		if(rb.index > rb.n + 6)
		{
			rb.finished = TRUE;
			m = displayscore;
		}

		rb.bottom_index = -1; // Initialise. This will be changed at some point in the for loop below, or after the for loop



		for(i=0; i<rb.index; i++)
		{
			difference = rb.index - i;
			rb.y_locations[i] = /* 4 + */ difference*10 + rb.count%10;

			// Check if there exists a note to be displayed and it is within range to be displayed on the screen
			if(rb.notes[i] != -1 && rb.y_locations[i] < 66)
			{
				// alt_up_char_buffer_string(v.char_buffer, rb.notes_char[i], rb.x_locations[i], rb.y_locations[i]); // Print the pitch at its corresponding location
				// eraser_rb(v.pixel_buffer, rb.y_locations[i] - rb.count_difference - 1, rb.x_locations[i], rb.CORRECT_ZONE_HEIGHT); // Erase the old note

				draw_rb_note_at(v.pixel_buffer, rb.y_locations[i], rb.x_locations[i]); // Draw new note

				if(rb.y_locations[i] >= 56 - rb.CORRECT_ZONE_HEIGHT && rb.y_locations[i] <= 55) // Check if the location is within the correct range
				{
					rb.in_correct_zone[rb.notes[i]] = TRUE; // Record that the pitch of note i is in the correct zone
					rb.bottom_index = i; // Since note i is in the correct zone
					{
						if(note_pressed == rb.notes[i]) // Check if the note in the correct zone matches the most recent piano key press
						{
							if(rb.already_counted[i] == FALSE)
							{
								rb.score++;
								rb.already_counted[i] = TRUE;
							}
							draw_rb_correct_note_at(v.pixel_buffer, rb.y_locations[i], rb.x_locations[i]);

						}
					}
				}
			}
		}

		if(rb.bottom_index == -1) // This means there was no note within the correct zone
		{
			while(rb.y_locations[i] < 56 - rb.CORRECT_ZONE_HEIGHT) i--;

			rb.bottom_index = i+1; // Set bottom_index to the index of the note closest to, and on top of, the correct zone
		}
		if(note_pressed >= 0) // Check if there has been a note pressed
		{
			if(rb.in_correct_zone[note_pressed] == TRUE) // Check if the note pressed is in the correct zone
			{
				draw_rb_correct_note_at(v.pixel_buffer, rb.y_locations[rb.bottom_index], rb.x_locations[rb.bottom_index]);
				rb.score++;
			}

			else
			{
				draw_rb_incorrect_note_at(v.pixel_buffer, rb.y_locations[rb.bottom_index], rb.x_locations[rb.bottom_index]);
				rb.score--;
			}

		}

		// Swap buffers
		alt_up_pixel_buffer_dma_swap_buffers(v.pixel_buffer);

		while (alt_up_pixel_buffer_dma_check_swap_buffers_status(v.pixel_buffer));


		// Draw blue background and correct zone to back buffer
		/*
		bluebackground(v.pixel_buffer);
		alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, 0, 319, 220-4*rb.CORRECT_ZONE_HEIGHT, 0x0000, 1); // Top of the correct zone
		alt_up_pixel_buffer_dma_draw_box(v.pixel_buffer, 0, 221-4*rb.CORRECT_ZONE_HEIGHT, 319, 219, 0xCCCC, 1);
		alt_up_pixel_buffer_dma_draw_hline(v.pixel_buffer, 0, 319, 220, 0x0000, 1); // Bottom of the correct zone
		*/
		// for(;;);
	}
}
Esempio n. 20
0
void draw_controls_guide(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer){
	alt_up_char_buffer_clear(char_buffer);
	draw_menu_text(char_buffer);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 31, 320, 240, BLACK, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 140, 10, 190, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 260, 10, 319, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 195, 10, 260, 30, YELLOW, 0);
	alt_up_char_buffer_string(char_buffer, "C O N T R O L S", 33, 12);
	alt_up_char_buffer_string(char_buffer, "_______________", 33, 13);
	alt_up_char_buffer_string(char_buffer, "UP ARROW ----- Move Cursor Up / Navigate Menus", 17, 19);
	alt_up_char_buffer_string(char_buffer, "DOWN ARROW --- Move Cursor Down / Navigate Menus", 17, 22);
	alt_up_char_buffer_string(char_buffer, "RIGHT ARROW -- Move Cursor Right / Navigate Menus", 17, 25);
	alt_up_char_buffer_string(char_buffer, "LEFT ARROW --- Move Cursor Left / Navigate Menus", 17, 28);
	alt_up_char_buffer_string(char_buffer, "A ------------ Move Resource Collecting Boat Left", 17, 31);
	alt_up_char_buffer_string(char_buffer, "D ------------ Move Resource Collecting Boat Right", 17, 34);
	alt_up_char_buffer_string(char_buffer, "(1 to 9) ----- Select Tower To Place", 17, 37);
	alt_up_char_buffer_string(char_buffer, "SPACEBAR ----- Place Tower On Current Grid ", 17, 40);
	alt_up_char_buffer_string(char_buffer, "ESC ---------- Pause Menu / Return To Previous Menu", 17, 43);
}
Esempio n. 21
0
int main() {

	//Print status message
	printf("Program Started...\n");
//===================================================================================================
//                              		INITIALIZE HARDWARE
//===================================================================================================

	initialize_hardware();

//	//Print Background
//	int i,j;
//	for (i=0; i<240; i++){
//		for (j=0; j<320; j++){
//			alt_up_pixel_buffer_dma_draw(pixel_buffer, world[i][j], j, i);
//		}
//	}

	//Draws the rectangle for the Game Grid (150 by 150)
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 149, 44, 300, 195, 0x3333, 0);

	alt_up_char_buffer_clear(char_buffer);
	alt_up_char_buffer_init(char_buffer);


//===================================================================================================
//===================================================================================================



//===================================================================================================
//                               Game Grid and other initialization
//===================================================================================================

	int GameGrid[GRID_WIDTH][GRID_HEIGHT] = {0};
	int UserHasQuit = 0;
	int GameStatus = 0;

	//===========================================================
	//Create Player 1 struct and initialize positions
	struct Player Player1;
	Player1.CurrentPositionX = 37;
	Player1.CurrentPositionY = 75;

	Player1.PreviousPositionX = 37;
	Player1.PreviousPositionY = 75;

	Player1.DirectionX = 1;
	Player1.DirectionY = 0;


	//===========================================================
	//Create Player 2 struct and initialize positions
	struct Player Player2;
	Player2.CurrentPositionX = 113;
	Player2.CurrentPositionY = 75;

	Player2.PreviousPositionX = 113;
	Player2.PreviousPositionY = 75;

	Player2.DirectionX = -1;
	Player2.DirectionY = 0;


	//===========================================================
	//  Sets the starting position as being filled
	GameGrid[Player1.CurrentPositionX][Player1.CurrentPositionY] = 1;
	GameGrid[Player2.CurrentPositionX][Player2.CurrentPositionY] = 1;

//===================================================================================================
//===================================================================================================



//===================================================================================================
//                               Controls
//===================================================================================================

	alt_up_char_buffer_string(char_buffer, "Press Enter to Start!", 4, 40);
	alt_up_char_buffer_string(char_buffer, "Press 'P' to Pause", 4, 42);

	alt_up_char_buffer_string(char_buffer, "Player 1: RED", 4, 46);
	alt_up_char_buffer_string(char_buffer, "W- Up", 8, 47);
	alt_up_char_buffer_string(char_buffer, "S- Down", 8, 48);
	alt_up_char_buffer_string(char_buffer, "A- Left", 8, 49);
	alt_up_char_buffer_string(char_buffer, "D- Right", 8, 50);


	alt_up_char_buffer_string(char_buffer, "Player 2: BLUE", 4, 53);
	alt_up_char_buffer_string(char_buffer, "Arrow Up- Up", 8, 54);
	alt_up_char_buffer_string(char_buffer, "Arrow Down - Down", 8, 55);
	alt_up_char_buffer_string(char_buffer, "Arrow Left- Left", 8, 56);
	alt_up_char_buffer_string(char_buffer, "Arrow Right- Right", 8, 57);


//===================================================================================================
//									START GAME
//===================================================================================================

	while(UserHasQuit != 1){


	// Function to read when user has pressed entered to start the game
	/*
	if( UserHasPressedEnter )
		GameStatus = 1;
	*/
	// This is the beginning of the game
		while( GameStatus != 1) {

			//Starts the timer to read keyboard inputs until we update the player positions and collisions
			UpdatePlayerMovement(&Player1, &Player2);

			//Updating the collision detection, movement, and screen
			//UpdateGame(&Player1, &Player2, &GameGrid, GameStatus, pixel_buffer);


		}


	}
	return 0;
}
Esempio n. 22
0
void draw_how_to_play_guide(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer) {
	alt_up_char_buffer_clear(char_buffer);
	draw_menu_text(char_buffer);
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 31, 320, 240, BLACK, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 70, 10, 140, 30, BLUE, 0);
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 0, 10, 70, 30, YELLOW, 0);
	alt_up_char_buffer_string(char_buffer, "O B J E C T I V E", 3, 12);
	alt_up_char_buffer_string(char_buffer, "_________________", 3, 13);
	alt_up_char_buffer_string(char_buffer, "In SHARKS VS. BABIES, players play as babies, trying to protect their", 3, 15);
	alt_up_char_buffer_string(char_buffer, "base against the enemy sharks. The player can purchase towers using the", 3, 17);
	alt_up_char_buffer_string(char_buffer, "resources currently avalable to them and place them on a grid in order to", 3, 19);
	alt_up_char_buffer_string(char_buffer, "fight the enemy sharks. Each tower is unique and has different attributes.", 3, 21);
	alt_up_char_buffer_string(char_buffer, "However, be wary that each type of shark has different attributes and some", 3, 23);
	alt_up_char_buffer_string(char_buffer, "towers may be more or less effective against the different types of sharks.", 3, 25);
	alt_up_char_buffer_string(char_buffer, "The objective of the game is to prevent the sharks from reaching the dock.", 3, 27);
	alt_up_char_buffer_string(char_buffer, "A C Q U I R I N G  R E S O U R C E S", 3, 32);
	alt_up_char_buffer_string(char_buffer, "____________________________________", 3, 33);
	alt_up_char_buffer_string(char_buffer, "Resources can be acquired in two ways:", 3, 35);
	alt_up_char_buffer_string(char_buffer, "1) Resources will periodically fall from the sky. The player can attempt to", 3, 38);
	alt_up_char_buffer_string(char_buffer, "obtain these resources by navigating a boat at the top of the screen.", 3, 40);
	alt_up_char_buffer_string(char_buffer, "There are three types of resources, each yielding a different amount.", 3, 42);
	alt_up_char_buffer_string(char_buffer, "2) The player can place a resource generating tower that slowly generates", 3, 45);
	alt_up_char_buffer_string(char_buffer, "resources for the player. Note that these towers cannot attack the enemies", 3, 47);
	alt_up_char_buffer_string(char_buffer, "and have low HP.", 3, 49);

}
Esempio n. 23
0
File: main.c Progetto: karfair/doge
int main(){
	printf("NEW GAME!\n\n");

	volatile int old_game_state = 0;
	int doge = 0; //animation counter

	//buffer init stuff
	pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma");
	char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer");

	//phil's stuff
	master* m = master_init();

	printf("NEW GAME!\n\n");

	// Set the 1st buffer address
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr1);
	// Swap buffers – we have to swap because there is only an API function
	// to set the address of the background buffer.
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));
	// Set the 2nd buffer address
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr2);

	printf("NEW GAME!\n\n");

	// Clear the screen
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

	alt_up_char_buffer_clear(char_buffer);
	//Write some text
	alt_up_char_buffer_string(char_buffer, "LOADING...", 0, 0);

	//load bitmap files
	title = read_bmp("title.bmp");
	alt_up_char_buffer_string(char_buffer, "title.bmp", 0, 2);

	menu = read_bmp("menu.bmp");
	alt_up_char_buffer_string(char_buffer, "MENU.BMP", 0, 3);

	selA = read_bmp("selA.bmp");
	alt_up_char_buffer_string(char_buffer, "selA.bmp", 0, 4);

	selB = read_bmp("selB.bmp");
	alt_up_char_buffer_string(char_buffer, "selB.bmp", 0, 5);

	selC = read_bmp("selC.bmp");
	alt_up_char_buffer_string(char_buffer, "selC.bmp", 0, 6);

	dead = read_bmp("dead.bmp");
	alt_up_char_buffer_string(char_buffer, "dead.bmp", 0, 7);



	bmp * b 	= read_bmp("para1.bmp");
	alt_up_char_buffer_string(char_buffer, "para.bmp", 0, 8);

	bmp * doge0 = read_bmp("doge0.bmp");
	alt_up_char_buffer_string(char_buffer, "doge0.bmp", 0, 9);

	bmp * doge1 = read_bmp("doge1.bmp");
	alt_up_char_buffer_string(char_buffer, "doge1.bmp", 0, 10);

	bmp * doge2 = read_bmp("doge2.bmp");
	alt_up_char_buffer_string(char_buffer, "doge2.bmp", 0, 11);

	bmp * doge3 = read_bmp("doge3.bmp");
	alt_up_char_buffer_string(char_buffer, "doge3.bmp", 0, 12);

	bmp * flat  = read_bmp("flat.bmp");
	alt_up_char_buffer_string(char_buffer, "flat.bmp", 0, 13);

	bmp * coin  = read_bmp("coin.bmp");
	alt_up_char_buffer_string(char_buffer, "coin.bmp", 0, 14);

	bmp * spike = read_bmp("spike.bmp");
	alt_up_char_buffer_string(char_buffer, "spike.bmp", 0, 15);

	bmp * box1  = read_bmp("box1.bmp");
	alt_up_char_buffer_string(char_buffer, "box1.bmp", 0, 16);

	bmp * box3  = read_bmp("box3.bmp");
	alt_up_char_buffer_string(char_buffer, "box3.bmp", 0, 17);

	bmp * low  = read_bmp("low.bmp");
	alt_up_char_buffer_string(char_buffer, "low.bmp", 0, 18);

	bmp * flatb = read_bmp("flatb.bmp");
	alt_up_char_buffer_string(char_buffer, "flatb.bmp", 0, 19);

	bmp * flatr = read_bmp("flatr.bmp");
	alt_up_char_buffer_string(char_buffer, "flatr.bmp", 0, 20);

	bmp * blue = read_bmp("bstar.bmp");
	alt_up_char_buffer_string(char_buffer, "blue.bmp", 0, 21);

	bmp * red = read_bmp("rstar.bmp");
	alt_up_char_buffer_string(char_buffer, "red.bmp", 0, 22);

	bmp * flag_img = read_bmp("flag.bmp");
	alt_up_char_buffer_string(char_buffer, "flag.bmp", 0, 23);

	name = read_bmp("name.bmp");
	alt_up_char_buffer_string(char_buffer, "name.bmp", 0, 24);

	instr = read_bmp("instr.bmp");
	alt_up_char_buffer_string(char_buffer, "instr.bmp", 0, 25);

	dcol = read_bmp("dcol.bmp");
	alt_up_char_buffer_string(char_buffer, "dcol.bmp", 0, 26);

	win = read_bmp("win.bmp");
	alt_up_char_buffer_string(char_buffer, "win.bmp", 0,27);



	alt_up_char_buffer_clear(char_buffer);



	printf("NEW GAME!\n\n");

	//interrupt init stuff (for object writing)
	//TIMERPERIOD
	int timer_period = 1 * 500000;
	IOWR_16DIRECT(TIMER_0_BASE, 8, timer_period & 0xFFFF); //writes the period to the hardware timer
	IOWR_16DIRECT(TIMER_0_BASE, 12, timer_period >> 16);
	IOWR_16DIRECT(TIMER_0_BASE, 4, 1 << 3); //stop timer
	alt_irq_register(TIMER_0_IRQ,NULL,(void*)handle_timer_interrupts);//registers function to a specific IRQ
	//IOWR_16DIRECT(TIMER_0_BASE, 4, 0x5); //start timer

	//SET UP KEYBOARD INTERRUPT//
	ps2 = alt_up_ps2_open_dev(KEYBOARD_NAME);
	alt_up_ps2_init(ps2);
	alt_up_ps2_clear_fifo(ps2);
	//void* keyboard_control_register_ptr = (void*) (PS2_0_BASE + 4);
	alt_irq_register(PS2_0_IRQ, m, keyboard_ISR);
	alt_up_ps2_enable_read_interrupt(ps2);

	char sw = 0;
	char p_sw = 0;


/////////////////////////////////////////////////////////////////////////
	printf("NEW GAME!\n\n");
	//SUPERDUPERLOOP
	while (1){

		printf("old state:%i\nnew state: %i\n\n",old_game_state, game_state);

		draw_menu(game_state);					//update screen

		while (old_game_state == game_state);

		printf("old state:%i\nnew state: %i\n\n",old_game_state, game_state);	//only when entering a new menu
		alt_up_char_buffer_clear(char_buffer);


		//ENTER GAME LOOP
		if (game_state == 5){

			printf("START GAME! LEVEL: %i\n\n", highlighted_level);
			alt_up_char_buffer_string(char_buffer, playername, 10, 4);

			if (highlighted_level == 1)
			{
				free_bmp(b);
				b = read_bmp("para1.bmp");
				game_start(m,b,"lvl/1.txt","song1.wav");
			}
			else if (highlighted_level == 2) {
				free_bmp(b);
				b = read_bmp("bg2.bmp");
				game_start(m,b,"lvl/2.txt","a/abcd.wav");
			}
			else{
				free_bmp(b);
				b = read_bmp("bg3.bmp");
				game_start(m,b,"lvl/2.txt","a/nyan1.wav");
			}


			//collision loop
			while(!m->c->collide && !m->c->win){
				alt_up_char_buffer_string(char_buffer, "POINTS: ", 50, 4);
				char str[15];
				sprintf(str, "%d", m->c->points);
				alt_up_char_buffer_string(char_buffer, str, 58, 4);

				sw = IORD_8DIRECT(SWITCHES_BASE,0);
				IOWR_8DIRECT(LEDS_BASE,0,sw);

				if(sw == 1 && p_sw == 0){
					//m->ab->sfx_flag = 1;
					m->c->jump_pressed = 1;
				}

				p_sw = sw;

				//boxes
				int i;
				for( i= 0 ; i < OBJECT_SIZE ; i++) {
					if(m->o->color[i] == -1)
						draw_object(pixel_buffer, box, flat, i);
					else if(m->o->color[i] == 0)
						draw_object(pixel_buffer, box, flatb, i);
					else if(m->o->color[i] == 1)
						draw_object(pixel_buffer, box, flatr, i);
					draw_object(pixel_buffer, co, coin, i );
					draw_object(pixel_buffer, spikes, spike, i);
					draw_object(pixel_buffer, box_3, box3, i);
					draw_object(pixel_buffer, box_1, box1, i);
//								if(m->color_gates->color[i] == 1)
//									draw_object(pixel_buffer,cgates, rgate,i);
//								else if (m->color_gates->color[i] == 0)
//									draw_object(pixel_buffer,cgates, bgate,i);
				}
				//draws the win flag
				draw_object(pixel_buffer, flag, flag_img, 0);

				//Draw Doge
				if (m->c->ducking)
					draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,low);
				else{
					doge++;
					if(doge == 37) doge = 0;

					if( doge <9)
						draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge0);
					else if (doge <18)
						draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge1);
					else if (doge <27)
						draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge2);
					else
						draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge3);
				}


				//Draw Color Indicator
				if(m->c->color == 0)
					draw_bmp(pixel_buffer, m->c->x- m->c->width + 5, m->c->y - m->c->height - 10, blue);
				else
					draw_bmp(pixel_buffer,m->c->x- m->c->width + 5, m->c->y - m->c->height - 10, red);

				p_counter++;
				if(p_counter == 3){
					p_shift++;
					alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
					while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer))
						refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer
					unrolled_parallax_draw(pixel_buffer, b);

				}else if(p_counter == 4){ //if(p_counter == 1){
					alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
					while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer))
						refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer
					unrolled_parallax_draw(pixel_buffer, b);
					p_counter = 0;


				}else{
//					alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
//					while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer))
//						refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer
//					unrolled_parallax_draw(pixel_buffer, b);

					alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
					while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer))
						refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer

					int j; for( j = 0 ; j < OBJECT_SIZE ; j++) {
						clear_object(pixel_buffer,  box,  b, j);
						clear_object(pixel_buffer,  co,  b, j);
						clear_object(pixel_buffer,  spikes,  b, j);
						clear_object(pixel_buffer,  box_3,  b, j);
						clear_object(pixel_buffer,  box_1,  b, j);
					}
					clear_object(pixel_buffer,flag,b,0);

					//clear doge
					clear_doge(pixel_buffer, m->c->x - m->c->width, m->c->y - m->c->height , b);
					//clear_loc(pixel_buffer,m->c->x- m->c->width + 5, m->c->y - m->c->height - 10,m->c->x- m->c->width + 5 - 10, m->c->y - m->c->height - 20,b);

				}





			}
			alt_up_char_buffer_string(char_buffer, "POINTS: ", 50, 4);
			char str[15];
			sprintf(str, "%d", m->c->points);
			alt_up_char_buffer_string(char_buffer, str, 58, 4);

			printf("game exited\n");
			if(m->c->win)
				game_state  = 7;
			else
				game_state  = 6;

			highlighted_item = 3;

			game_reset(m);
		}



		//exit game mode, restart superduperloop in main menu
		old_game_state = game_state;
	}

	return 0;
}
Esempio n. 24
0
/*
 * Main Game Loop
 */
int main()
{
	// Use the name of your pixel buffer DMA core
	pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0");

	initVGA();
	usleep(5000000);
	ps2 = alt_up_ps2_open_dev("/dev/ps2_0");
	ps2->timeout = 2000000;
		alt_up_ps2_clear_fifo(ps2);
		alt_up_ps2_init(ps2);

		unsigned char byte1;
		while(alt_up_ps2_read_data_byte(ps2, &byte1)!=0);

	char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0");
	alt_up_character_lcd_init (char_lcd_dev);

	char_buffer  = alt_up_char_buffer_open_dev("/dev/char_drawer");
	alt_up_char_buffer_init(char_buffer);

	alt_up_sd_card_dev *device_reference = NULL;
	struct Env* p = initEnv();
	initGameInfo();

	struct Collidable* collisionChecker = initCollidable();
	addCollisionToEnv(p, collisionChecker);

	promptSDcard(p, device_reference);

	usleep(1000);
	alt_up_char_buffer_string(char_buffer, "Loading ", 40, 30);

	  unsigned end_time, start_time;
	  int count = 0; lock = 0;

	struct animation* starAnimation = loadSDImageSeq("ST0.BMP", 2, 8);
	struct animation* star2Animation = loadSDImageSeq("ST00.BMP", 3, 7);
	struct animation* alien0 = loadSDImageSeq("A100.BMP", 2, 2); //2 images where first 2 characters are prefix
	struct animation* alien1 = loadSDImageSeq("A000.BMP", 2, 15);
	struct animation* ship0 = loadSDImageSeq("S00.BMP", 2, 16);
	struct animation* ship1 = loadSDImageSeq("S10.BMP", 2, 27);
	struct animation* bossAnimate = loadSDImageSeq("BO00.BMP", 2, 28);
	struct animation* ship2 = loadSDImageSeq("S20.BMP", 2, 35);
	struct animation* ship3 = loadSDImageSeq("S30.BMP", 2, 30);
	struct animation* ship4 = loadSDImageSeq("S40.BMP", 2, 10);

	struct animation* explode1 = initAnimation((int*)explode01, 1);
	addImage(explode1, initAnimation((int*)explode02, 0));
	addImage(explode1, initAnimation((int*)explode03, 0));
	addImage(explode1, initAnimation((int*)explode04, 0));
	addImage(explode1, initAnimation((int*)explode05, 0));

	struct animation** shipAnimationCollection = (struct animation**)malloc(sizeof(struct animation*)*5);
	shipAnimationCollection[0] = ship0;
	shipAnimationCollection[1] = ship1;
	shipAnimationCollection[2] = ship2;
	shipAnimationCollection[3] = ship3;
	shipAnimationCollection[4] = ship4;

	initWeapon(collisionChecker, p);

	struct Cursor* mouse = initCursor(p, collisionChecker);
	addToEnv(p, mouse->super);
	addObjToCollide(collisionChecker, mouse->super);
	setCursor(p, mouse);

	struct KeyController* keyController = initKeyController();
	struct SwitchController* switchController = initSwitchController();
	struct CursorController* ctrl = initCursorController(mouse->super, switchController, keyController);

	alt_up_char_buffer_string(char_buffer, "Loading Sounds            ", 30, 30);
	audioController = initAudioController();
	loadSound( audioController, LOOP_ONE );
	loadSound( audioController, LASER_SOUND );
	alt_irq_register(AUDIO_IRQ, audioController, (void*) audio_ISR);
	alt_irq_enable(AUDIO_IRQ);
	play_background_loop( audioController, LOOP_ONE );
	enableAudioController( audioController );

	printhex(info.score);

	mainMenu(mouse, ctrl, p);

	disableAudioController(audioController);
	stop_background_loop(audioController);
	unloadSoundById(audioController, LASER_SOUND);
	unloadSoundById(audioController, LOOP_ONE);
	alt_up_char_buffer_string(char_buffer, "Loading Sounds           ", 30, 30);
	//loadSound(audioController, WIN_SOUND);
	//loadSound(audioController, LOSE_SOUND);
	loadSound( audioController, TOWER_UPGRADE_SOUND );
	loadSound( audioController, LOOP_TWO );
	play_background_loop(audioController, LOOP_TWO);
	enableAudioController( audioController );
	alt_up_char_buffer_clear(char_buffer);
	//usleep(1000);
	struct Alien* testAlienCollection[60];
	gameSetup(p, shipAnimationCollection, mouse, starAnimation, star2Animation);

	usleep(500000); //time delay for panel to be drawn
//
	char LPS[50]; float lps_;

	int n = 0;

	for(n = 0; n < 20; n++) {
		testAlienCollection[n] =initAlien(n, 10*n, 10, alien0, explode1, "IdontKnow", 1.4, 150, 500, collisionChecker);
		addToEnvNR(p, testAlienCollection[n]->super);
	}
	for(n = 0; n < 20; n++) {
		testAlienCollection[n+20] =initAlien(10*n, n, 10, alien1, explode1, "whatName", 1.4, 190, 850, collisionChecker);
		addToEnvNR(p, testAlienCollection[n+20]->super);
	}
	for(n = 0; n < 20; n++) {
		testAlienCollection[n+40] =initAlien(10*n, n, 20, bossAnimate, explode1, "IamBoss", 1.6, 800, 1500, collisionChecker);
		testAlienCollection[n+40]->score = 300;
		addToEnvNR(p, testAlienCollection[n+40]->super);
	}
	int stage = 0;
	/*
	 * Game Starts!!!!!!
	 */
	alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p);

	int startTimer = 0;
	char second_row1[15];
	alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1);
	  sprintf(second_row1, "wave# %d  ", stage);
	  alt_up_character_lcd_string(char_lcd_dev, second_row1);

  while(1) {
	  alt_timestamp_start();
	  start_time = (unsigned)alt_timestamp();

/*-----------------------------------------------------------------------------------------------*/

	  checkCollision(collisionChecker); //a major function that check each collision happen between each object

	  updateCursorController(ctrl, 1);

	  count++;

	  if (startTimer > count)
		  info.startButton = false;
	  else {
		  if(stage == 7)
			info.isWin = true;
		  else if(startTimer == count){
			//play_background_loop(audioController, LOOP_TWO);
			enableAudioController( audioController );
		  }
	  }
	  if (info.startButton){
			disableAudioController(audioController);
			//stop_background_loop(audioController);
		    startTimer = count + 15000;
	  		checkStages(testAlienCollection, stage%7, collisionChecker);
			stage++;
			//if(stage > 6) stage = 0;
			info.startButton = false;
		  	  alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1);
		  	  sprintf(second_row1, "wave# %d  ", stage);
		  	  alt_up_character_lcd_string(char_lcd_dev, second_row1);
	  }

	  if(info.isEnd || info.isWin) {

			disableAudioController(audioController);
			stop_background_loop(audioController);
		  endGame(testAlienCollection, collisionChecker, p, mouse, ctrl, keyController);
	  }
/*-----------------------------------------------------------------------------------------------*/



	  end_time = (unsigned)alt_timestamp();
	  lps_ = (float)alt_timestamp_freq()/(float)(end_time - start_time);

	  sprintf(LPS, "The current LPS is %.2f", lps_);
	  alt_up_char_buffer_string(char_buffer, LPS, 3, 2);
  }
  return 0;
}
Esempio n. 25
0
int main(void) {

	alt_up_char_buffer_dev * char_buf_dev;

	char_buf_dev = alt_up_char_buffer_open_dev("/dev/char_buffer");
	// open the Char Buffer port
	if (char_buf_dev == NULL)
		alt_printf("Error: could not open char buffer device \n");
	else
		alt_printf("Opened char buffer device \n");
	alt_up_char_buffer_clear(char_buf_dev);
	alt_up_char_buffer_string(char_buf_dev, "ECE4440 Team MSB", 5, 5);
	alt_up_char_buffer_string(char_buf_dev, "Video Demo", 5, 10);
	alt_up_char_buffer_string(char_buf_dev, "Blue", 15, 20);
	alt_up_char_buffer_string(char_buf_dev, "Red", 40, 20);
	alt_up_char_buffer_string(char_buf_dev, "Green", 40, 40);
	alt_up_char_buffer_string(char_buf_dev, "Purple", 15, 40);


	alt_up_pixel_buffer_dma_dev * pixel_buf_dev;
	// open the Pixel Buffer port
	pixel_buf_dev = alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer");
	if (pixel_buf_dev == NULL)
		alt_printf("Error: could not open pixel buffer device \n");
	else
		alt_printf("Opened pixel buffer device \n");
	//Clear and draw a blue box on the screen
	alt_up_pixel_buffer_dma_clear_screen(pixel_buf_dev, 0);
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buf_dev);
	alt_up_pixel_buffer_dma_draw_box(pixel_buf_dev, 0, 0, 200, 200, 0x3FF, 0); //blue box
	alt_up_pixel_buffer_dma_draw_box(pixel_buf_dev, 200, 200, 400, 400, 0xFFC00, 1); //green box
	alt_up_pixel_buffer_dma_draw_box(pixel_buf_dev, 200, 0, 400, 200, 0x3FF00000, 0); //red box
	alt_up_pixel_buffer_dma_draw_box(pixel_buf_dev, 0, 200, 200, 400, 0x3FF003FF, 1); //light blue box
	int image[60][60] = {{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,0,0,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,255,255,255,255,255,0,0,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,0,255,0,255,255,255,255,0,255,255,255,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,0,255,255,0,255,255,255,255,0,0,255,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,0,255,255,255,255,0,0,255,255,0,0,255,255,255,255,0,0,0,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,0,255,255,255,255,0,0,0,0,0,0,0,255,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,0,255,255,255,255,0,0,0,255,255,0,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,0,255,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,0,0,0,0,0,0,0,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,204,0,204,204,204,204,255,204,204,204,204,255,204,204,204,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,0,255,255,255,255,255,255,0,255,255,204,255,204,255,255,255,255,255,255,204,204,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,204,255,255,255,255,255,255,204,255,255,0,255,204,255,255,255,255,255,255,204,204,204,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,0,0,0,0,255,255,255,255,255,255,255,204,204,0,204,204,255,255,0,204,204,204,255,204,255,255,255,255,255,204,255,255,204,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,255,255,255,255,255,255,204,255,255,255,255,255,255,204,255,255,255,255,0,255,204,204,255,255,204,255,255,204,204,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,0,255,255,255,255,204,255,255,204,255,255,204,204,0,204,0,255,255},
			{255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,204,255,255,255,255,255,255,204,255,255,255,255,204,204,204,0,255,0,204,255,255,255,204,255,255},
			{255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,204,255,255,255,255,204,255,255},
			{255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,0,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255},
			{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}};

	int i, j;
	for (i = 0; i < 60; i++){
		for (j = 0; j < 60; j++){
			if (image[i][j] < 255)
				alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x0, 100+i, 100+j);
			else
				alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0xFFFFFFFF, 100+i, 100+j);
		}
	}

	/*alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 100, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 101, 101);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 102, 102);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 103, 103);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 104, 102);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 105, 101);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 106, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 105, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 104, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 103, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 102, 100);
	alt_up_pixel_buffer_dma_draw(pixel_buf_dev, 0x3FF003FF, 101, 100);*/


	return 0;
}
Esempio n. 26
0
/********************************************************************************
 * This program demonstrates use of the character and pixel buffer HAL code for
 * the DE2 Media computer. It:
 * 	-- places a blue box on the VGA display, and places a text string inside the box.
 *		-- draws a big A on the screen, for ALTERA
 *		-- "bounces" a colored box around the screen 
********************************************************************************/
int main(void)
{
	alt_up_pixel_buffer_dma_dev *pixel_buffer_dev;
	alt_up_char_buffer_dev *char_buffer_dev;

	/* used for drawing coordinates */
	int x1, y1, x2, y2, deltax_1, deltax_2, deltay_1, deltay_2, delay = 0;

	/* create a message to be displayed on the VGA display */
	char text_top_row[40] = "Altera DE2\0";
	char text_bottom_row[40] = "Media Computer\0";

	/* initialize the pixel buffer HAL */
	pixel_buffer_dev = alt_up_pixel_buffer_dma_open_dev ("/dev/VGA_Pixel_Buffer");
	if ( pixel_buffer_dev == NULL)
		alt_printf ("Error: could not open VGA pixel buffer device\n");
	else
		alt_printf ("Opened character VGA pixel buffer device\n");
	/* clear the graphics screen */
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer_dev, 0);

	/* output text message in the middle of the VGA monitor */
	char_buffer_dev = alt_up_char_buffer_open_dev ("/dev/VGA_Char_Buffer");
	if (char_buffer_dev == NULL)
	{
		alt_printf ("Error: could not open character buffer device\n");
		return -1;
	}
	else
		alt_printf ("Opened character buffer device\n");
	alt_up_char_buffer_string (char_buffer_dev, text_top_row, 35, 29);
	alt_up_char_buffer_string (char_buffer_dev, text_bottom_row, 35, 30);

	/* now draw a background box for the text */
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer_dev, 34*4, 28*4, 50*4, 32*4, 0x187F, 0);

	/* now draw a big A for ALTERA */
	draw_big_A (pixel_buffer_dev);

	/* now draw a red rectangle with diagonal green lines */
	x1 = 20; y1 = 20;
	x2 = 50; y2 = 50;
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer_dev, x1, y1, x2, y2, 0xF800, 0);
	alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y1, x2, y2, 0x07e0, 0);
	alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y2, x2, y1, 0x07e0, 0);
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer_dev);

	/* set the direction in which the box will move */
	deltax_1 = deltax_2 = deltay_1 = deltay_2 = 1;

	while(1)
	{
		if (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer_dev) == 0)
		{
			/* If the screen has been drawn completely then we can draw a new image. This 
			 * section of the code will only be entered once every 60th of a second, because 
			 * this is how long it take the VGA controller to copy the image from memory to 
			 * the screen. */
			delay = 1 - delay;

			if (delay == 0)
			{
				/* The delay is inserted to slow down the animation from 60 frames per second 
				 * to 30. Every other refresh cycle the code below will execute. We first erase 
				 * the box with Erase Rectangle */
				alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer_dev, x1, y1, x2, y2, 0, 0);
				alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y1, x2, y2, 0, 0);
				alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y2, x2, y1, 0, 0);

				// move the rectangle
				x1 = x1 + deltax_1;
				x2 = x2 + deltax_2;
				y1 = y1 + deltay_1;
				y2 = y2 + deltay_2;
				if ((deltax_1 > 0) && (x1 >= alt_up_pixel_buffer_dma_x_res(pixel_buffer_dev) - 1))
				{
					x1 = alt_up_pixel_buffer_dma_x_res(pixel_buffer_dev) - 1;
					deltax_1 = -deltax_1;
				}
				else if ((deltax_1 < 0) && (x1 <= 0))
				{
					x1 = 0;
					deltax_1 = -deltax_1;
				}
				if ((deltax_2 > 0) && (x2 >= alt_up_pixel_buffer_dma_x_res(pixel_buffer_dev) - 1))
				{
					x2 = alt_up_pixel_buffer_dma_x_res(pixel_buffer_dev) - 1;
					deltax_2 = -deltax_2;
				}
				else if ((deltax_2 < 0) && (x2 <= 0))
				{
					x2 = 0;
					deltax_2 = -deltax_2;
				}
				if ((deltay_1 > 0) && (y1 >= alt_up_pixel_buffer_dma_y_res(pixel_buffer_dev) - 1))
				{
					y1 = alt_up_pixel_buffer_dma_y_res(pixel_buffer_dev) - 1;
					deltay_1 = -deltay_1;
				}
				else if ((deltay_1 < 0) && (y1 <= 0))
				{
					y1 = 0;
					deltay_1 = -deltay_1;
				}
				if ((deltay_2 > 0) && (y2 >= alt_up_pixel_buffer_dma_y_res(pixel_buffer_dev) - 1))
				{
					y2 = alt_up_pixel_buffer_dma_y_res(pixel_buffer_dev) - 1;
					deltay_2 = -deltay_2;
				}
				else if ((deltay_2 < 0) && (y2 <= 0))
				{
					y2 = 0;
					deltay_2 = -deltay_2;
				}

				// redraw Rectangle with diagonal lines
				alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer_dev, x1, y1, x2, y2, 0xF800, 0);
				alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y1, x2, y2, 0x07e0, 0);
				alt_up_pixel_buffer_dma_draw_line(pixel_buffer_dev, x1, y2, x2, y1, 0x07e0, 0);

				// redraw the box in the foreground
				alt_up_pixel_buffer_dma_draw_box(pixel_buffer_dev, 34*4, 28*4, 50*4, 32*4, 0x187F, 0);

				draw_big_A (pixel_buffer_dev);
			}

			/* Execute a swap buffer command. This will allow us to check if the screen has 
			 * been redrawn before generating a new animation frame. */
			alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer_dev);
		}
	}
}
Esempio n. 27
0
/**
 * @brief Draw a NULL-terminated text string at the location specified by <em>(x, y)</em>
 *
 * @param ch -- the character to draw
 * @param x	-- the \em x coordinate
 * @param y	-- the \em y coordinate
 *
 * @return 0 for success, -1 for error (such as out of bounds)
 **/
int Char_printString(CharBuffer *char_buffer, const char *ptr, unsigned int x, unsigned int y)
{
	return alt_up_char_buffer_string(char_buffer->char_buffer, ptr, x, y);
}
Esempio n. 28
0
/*
 * Helper method that will print the string on the display
 */
void displayString(char* string, int x, int y) {
	alt_up_char_buffer_clear(char_buffer);
	alt_up_char_buffer_string(char_buffer, string, x, y);
}
Esempio n. 29
0
/* Writes a character string to the given xy coordinates */
void writeString(char* string, int x, int y)
{
	// Write some text
	if(alt_up_char_buffer_string(char_buffer, string, x, y) != 0)
		printf("Character Buffer Print Fail/n");
}