示例#1
0
/*
 * this function clear the screen and set up pixel buffers for graphics
 */
void initVGA() {

	  // Set the background buffer address � Although we don�t use thebackground,
	  // they only provide a function to change the background buffer address, so
	  // we must set that, and then swap it to the foreground.
	  unsigned int pixel_buffer_addr1 = PIXEL_BUFFER_BASE;
	  unsigned int pixel_buffer_addr2 = PIXEL_BUFFER_BASE + (320*240*2);

	  alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr1);
	  // Swap background and foreground buffers
	  alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	  // Wait for the swap to complete
	  while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

	  alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr2);
	  // Clear the screen
	  alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
	  alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);

	 // alt_up_pixel_buffer_dma_draw_line(pixel_buffer, 0, 0, 320, 240, 0xFFFF,1);
	   //Swap background and foreground buffers
	  	  alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	  	   //Wait for the swap to complete
	  	  while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));
	  //	  return pixel_buffer;
}
示例#2
0
//alt_up_pixel_buffer_dma_dev *pixel_buffer = init_pixel_stuff("/dev/pixel_buffer_dma");
alt_up_pixel_buffer_dma_dev *init_pixel_stuff(char *location){
    //Pixel Buffer
    alt_up_pixel_buffer_dma_dev *pixel_buffer;

    //Opens the pixel buffer device specified by /dev/pixel_buffer_dma
    pixel_buffer = alt_up_pixel_buffer_dma_open_dev(location);

    unsigned int pixel_buffer_addr1 = PIXEL_BUFFER_BASE;
    unsigned int pixel_buffer_addr2 = PIXEL_BUFFER_BASE + PIXEL_BUFFER_SPAN / 2;

    //Change the 1st buffer's start address
    alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer, pixel_buffer_addr1);

    //Swap background and foreground buffers
    alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);

    //Wait for the swap to complete
    while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

    //Change the 1st buffer's start address
    alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer, pixel_buffer_addr2);

    //Clear the screen
    alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
    alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);

    return pixel_buffer;
}
示例#3
0
/*
* this function clear the screen and set up pixel buffers for graphics
*/
void initVGA() {
	// Use the name of your pixel buffer DMA core
	pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0");

	//text on screen initialization
	char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer");
	alt_up_char_buffer_init(char_buffer);

	// Set the background buffer address � Although we don�t use thebackground,
	// they only provide a function to change the background buffer address, so
	// we must set that, and then swap it to the foreground.
	unsigned int pixel_buffer_addr1 = PIXEL_BUFFER_BASE;
	unsigned int pixel_buffer_addr2 = PIXEL_BUFFER_BASE + (320*240*2);

	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr1);
	// Swap background and foreground buffers
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	// Wait for the swap to complete
	while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr2);
	// Clear the screen
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);

	//Swap background and foreground buffers
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);
	//Wait for the swap to complete
	while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

}
示例#4
0
alt_up_pixel_buffer_dma_dev * initialise_pixel()
// PURPOSE:	to set up the VGA adapter
// RETURNS:	nothing
{
	alt_up_pixel_buffer_dma_dev * pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/video_pixel_buffer_dma_0");

	unsigned int pixel_buffer_addr1 = 0x80000;
	unsigned int pixel_buffer_addr2 = 0x80000 + (320 * 240 * 2);

	// 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);
	// Clear both buffers (this makes all pixels black)
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);

	return pixel_buffer;
}
void prepareBackground(void){
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer_dev, backbuffer);  //Clear the backbuffer
	//Main lines
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer_dev, 0, 0, 319, 239, BACKGROUNDCOLOR, backbuffer); //Make the backbuffer the correct color
	alt_up_pixel_buffer_dma_draw_hline(pixel_buffer_dev, 12,  319, 226,SYSLINECOLOR, backbuffer); //Draw the horizontal sysline to the backbuffer
	alt_up_pixel_buffer_dma_draw_vline(pixel_buffer_dev, 12, 0, 226,SYSLINECOLOR, backbuffer); //Draw the vertical line
}
示例#6
0
/* Initializes all hardware before loading the game - VGA, LEDs, PS/2, etc.
*/
void initialize_hardware(void){

	// Use the name of your pixel buffer DMA core
	pixel_buffer = alt_up_pixel_buffer_dma_open_dev(BUFFER_DMA_NAME);

	// Set the background buffer address – Although we don’t use the background,
	// they only provide a function to change the background buffer address, so
	// we must set that, and then swap it to the foreground.
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer, PIXEL_BUFFER_BASE);

	// Swap background and foreground buffers
	alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer);

	// Wait for the swap to complete while
	(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer));

	// Initialize character buffer
	char_buffer = alt_up_char_buffer_open_dev("/dev/character_buffer");

	// Clear the screen
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);

	//Initialize the PS2 controller
	ps2_dev = alt_up_ps2_open_dev(PS2_0_NAME);

}
示例#7
0
void draw_help_menu(alt_up_pixel_buffer_dma_dev* pixel_buffer, alt_up_char_buffer_dev* char_buffer, alt_up_ps2_dev *ps2_kb, KB_CODE_TYPE  decode_mode) {
	int count = 0;
	int exit_flag = 0;
	int current_menu = HOW_TO_PLAY_MENU;
	alt_u8 data;
	char ascii;
	alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 0, 10, 319, 30, BLUE, 0);
	draw_menu_text(char_buffer);
	draw_how_to_play_guide(pixel_buffer, char_buffer);
	while(exit_flag == 0) {
		if (decode_scancode(ps2_kb, &decode_mode, &data, &ascii) == 0) {
			if(data == LEFT || data == RIGHT || data == ESC) count++;
			if(data == LEFT && count >= 2) {
				if(current_menu != HOW_TO_PLAY_MENU) current_menu--;
				draw_current_menu(pixel_buffer, char_buffer, current_menu);
				count = 0;
			}
			if(data == RIGHT && count >= 2) {
				if(current_menu != DEVS_MENU) current_menu++;
				draw_current_menu(pixel_buffer, char_buffer, current_menu);
				count = 0;
			}
			if(data == ESC && count >= 2) {
				exit_flag = 1;
			}
		}

	}
	alt_up_char_buffer_clear(char_buffer);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
}
示例#8
0
int main()
{
	alt_up_pixel_buffer_dma_dev* pixel_buffer;
	pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/video_pixel_buffer_dma_0");
	if (pixel_buffer == 0) {
		printf("error initializing pixel buffer (check name in alt_up_pixel_buffer_dma_open_dev)\n");
	}
	alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer, PIXEL_BUFFER_BASE);
	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, 0);

	int hw = 0;
	if (hw) {
           IOWR_32DIRECT(drawer_base,0,10); // Set x1
           IOWR_32DIRECT(drawer_base,4,20); // Set y1
           IOWR_32DIRECT(drawer_base,8,50); // Set x2
           IOWR_32DIRECT(drawer_base,12,60); // Set y2
           IOWR_32DIRECT(drawer_base,16,0xFFFF);  // Set colour
           IOWR_32DIRECT(drawer_base,20,1);  // Start drawing
           while(IORD_32DIRECT(drawer_base,20)==0); // wait until done
 	} else {
           alt_up_pixel_buffer_dma_draw_box(pixel_buffer, 10,20,50,60,0xFFFF,0);
 	}
    return 0;
}
示例#9
0
void promptSDcard(struct Env* p, alt_up_sd_card_dev* device_reference) {
	/*
	 * Loading Screen if SD card is not presented
	 */

	int frame = 25;
	struct animation* b = initAnimation((int*)pacman01, 1);
	addImage(b, initAnimation((int*)pacman02, 0));
	addImage(b, initAnimation((int*)pacman03, 0));
	addImage(b, initAnimation((int*)pacman04, 0));
	struct Object *face;
	face= initObject(80, 120, 10, b, NULL);
	addToEnv(p, face);

	alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p);


	while(!loadSDCard(device_reference)) {
		displayString("Please insert the SD card to start", frame, 30);
		frame++;
		setXY(face, face->x+4, face->y);
		if(face->x >245) face->x = 0;
		if(frame > 61) frame = 0;

		usleep(300000);
	}alt_up_char_buffer_clear(char_buffer);
	killAnimation(b);
	removeFromEnv(p, face);
	alt_alarm_stop(&alarm);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
}
示例#10
0
/* Initialze the character and pixel buffers for writing */
void initBuffers(void)
{
	// Use the name of your pixel buffer DMA core
	pixel_buffer =	alt_up_pixel_buffer_dma_open_dev(PIXEL_BUFFER_DMA_NAME);
	unsigned int pixel_buffer_addr1 = PIXEL_BUFFER_BASE;
	unsigned int pixel_buffer_addr2 = PIXEL_BUFFER_BASE + (320 * 240 * 2);
	// 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);
	// Clear both buffers (this makes all pixels black)
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);

	char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer");
	alt_up_char_buffer_init(char_buffer);
	alt_up_char_buffer_clear(char_buffer);
}
示例#11
0
void initVGA(void){
	//reset the display

		pixel_buf = alt_up_pixel_buffer_dma_open_dev(VIDEO_PIXEL_BUFFER_DMA_NAME);
		if(pixel_buf == NULL){
			printf("Cannot find pixel buffer device\n");
		}
		alt_up_pixel_buffer_dma_clear_screen(pixel_buf, 0);

		//initialize character buffer

		char_buf = alt_up_char_buffer_open_dev("/dev/video_character_buffer_with_dma");
		if(char_buf == NULL){
			printf("can't find char buffer device\n");
		}
		alt_up_char_buffer_clear(char_buf);
}
示例#12
0
void clearBackground()
{
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1);
}
示例#13
0
void clearForeground()
{
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
}
示例#14
0
int main()
{
	//SD device initialization
	up_dev.device_reference = NULL;
	while(!loadSDCard(up_dev.device_reference)) {
		printf("SD card is not connected.\n");
	}

	initVGA();
	initAudioDeviceController();
	initSoundMixer();

	struct CmdScheduler* scheduler = initCmdScheduler();

	//Serial device initialization
	com = initRS232(scheduler);

	initPushKeyController();

	initDatabase();
	initMemory();

	//sync database
	update();

	//Test VGA Output
	/*struct Image* testImg;
	while((testImg = loadSDImage("TEST.BMP")) == NULL);
	draw(35, 35, testImg);
	killImage(testImg);*/
	//alt_up_char_buffer_string(char_buffer, "Initialization Completed", 27, 5);


	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
	alt_up_char_buffer_clear(char_buffer);

	//graphicTester();

	struct Frame* mainFrame = initMainFrame();
	mainFrame->drawFrame(mainFrame);


	//Test End
	mouse = initCursor(10, 100, mainFrame);
	//graphicTester();

	//drawAllSongsInList(2);
	//drawAllSongsInList(2);
	/*int i;
	struct Frame* b;
	for (i = 0; i < 5000; i++){
		drawAllSongsInList(2);
		//b = initSongInListPanel(mainFrame, 2);
		//killSongInListPanel(&b);
		printf("Iteration %d\n", i);
	}*/

	initAudioBuffer();
	initAnimate(mouse);

	int i = 2;

	syncPlay(1, 100, 0);

	while(1) {
		cmdProcessing(scheduler);

		i = soundTester(i);

	}


	return 0;
}
示例#15
0
文件: main.c 项目: 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;
}
示例#16
0
int update_eq_sinc(int amplitude, int green)
// FUNCTION: Updates the equaliser for pretty graphics and swaps the pixel buffer
// REQUIRES: Initialised pixel buffer
// RETURNS: New green value
{
	// Declare variables
	int i, j, red, blue, height, y_value, original_top, x_axis, x_value;
	float period = ((rand() % 200) + 600.0) / 100.0; // Randomly generate period between 6.0 and 8.0
	uint16_t colour;
	int random_amplitude;
	float random_period;

	if(/* alt_timestamp()/(float) alt_timestamp_freq() > EQ_TIME_CONSTANT_S && */ m == eq)
	{
		v.blank_flag = FALSE;
		rb.background_flag = FALSE;
		alt_up_char_buffer_clear(v.char_buffer);
		random_amplitude = (rand() % 50) + 50;
		random_period = ((rand() % 200) + 600.0) / 100.0;
		printf("Random amplitude: %d\n", random_amplitude);
		if(rand() % 1 == 0)
		{
			if(green < 251) green += 5;
		}
		else if(green > 5) green -= 5;
		alt_up_pixel_buffer_dma_clear_screen(v.pixel_buffer, 1); // Clear back buffer
		x_axis = 190;
		original_top = x_axis - x_axis*amplitude/MAX_AMPLITUDE;


		for(x_value=0; x_value < 160; x_value++) // Draw two-sided sinc function, almost to each side of the screen
		{
			red = 255*(160-x_value)/160; // red will increase towards the middle of the screen

			// Calculate value of the sinc function for x-coordinate x_value
			if(x_value>0) height = (x_axis*amplitude/MAX_AMPLITUDE)*sin(x_value/period) /(x_value/period);
			else height = x_axis*amplitude/MAX_AMPLITUDE;

			y_value = x_axis - height;
			if(height>0) // This means the sinc function is above the x-axis
			{
				for(j=y_value; j<=x_axis; j++) // j is the y-coordinate
				{
					blue = 255*(j - original_top)/(x_axis*amplitude/MAX_AMPLITUDE); // blue will increase towards the x_axis of the screen
					colour = drawRGB24toRGB565(red, green, blue);
					i=160-x_value; // i is the x-coordinate
					alt_up_pixel_buffer_dma_draw(v.pixel_buffer, colour, i, j);
					i=160+x_value; // i is the x-coordinate
					alt_up_pixel_buffer_dma_draw(v.pixel_buffer, colour, i, j);
				}
			}
			else // This means the sinc function is on or below the x-axis
			{
				for(j=y_value; j>=x_axis; j--) // j is the y-coordinate
				{
					blue = 255*(2*x_axis-j - original_top)/(x_axis*amplitude/MAX_AMPLITUDE); // blue will increase towards the x_axis of the screen
					colour = drawRGB24toRGB565(red, green, blue);
					i=160-x_value; // i is the x-coordinate
					alt_up_pixel_buffer_dma_draw(v.pixel_buffer, colour, i, j);
					i=160+x_value; // i is the x-coordinate
					alt_up_pixel_buffer_dma_draw(v.pixel_buffer, colour, i, j);
				}
			}
		}
		// 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_timestamp_start();
	}
	return green;
}
示例#17
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);
		}
	}
}
示例#18
0
文件: vga.c 项目: roadmapper/cinebox
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;
}
示例#19
0
/**
 * @brief This function clears the screen or the back buffer.
 *
 * @param pixel_buffer -- the pointer to the VGA structure
 * @param backbuffer -- set to 1 to clear the back buffer, otherwise set to 0 to clear the current screen.
 *
 * @return 0 if complete, 1 if still processing
 **/
void Video_clearScreen(VideoBuffer *video_buffer, int backbuffer)
{
	alt_up_pixel_buffer_dma_clear_screen(video_buffer -> pixel_buffer, backbuffer);
}