Example #1
0
int objstore_init(void)
{
	int ret;

	vol_cache = umem_cache_create("vol", sizeof(struct objstore_vol),
				      0, NULL, NULL, NULL, NULL, NULL, 0);
	if (!vol_cache)
		return ENOMEM;

	ret = vg_init();
	if (ret)
		goto err;

	ret = load_backend(&mem_backend, "mem");
	if (ret)
		goto err;

	backend = &mem_backend;

	return 0;

err:
	umem_cache_destroy(vol_cache);

	return ret;
}
Example #2
0
int test_line(unsigned short xi, unsigned short yi, unsigned short xf,
		unsigned short yf, unsigned long color) {
	if (vg_init(VBE_VIDEO_MODE) == NULL)
		return 1;

	if(xi > xf && yi > yf){
		unsigned short tmp = xf;
		xf = xi;
		xi = tmp;

		tmp = yf;
		yf = yi;
		yi = tmp;
	}

	if (vg_draw_line(xi, yi, xf, yf, color) != 0) {
		vg_exit();
		return 1;
	}

	vg_update_screen();

	kbd_test_scan(0);

	return vg_exit();
}
Example #3
0
int test_square(unsigned short x, unsigned short y, unsigned short size, unsigned long color) {
	vg_init(GRAPHIC_MODE);

	int ipc_status;
	message msg;
	int request;
	int irq_set;

	irq_set = subscribe_kbd();

	while (scanCode != EXIT_MAKE_CODE) {
		request = driver_receive(ANY, &msg, &ipc_status);
		if (request != 0) {
			printf("driver_receive failed with: %d", request);
			continue;
		}
		if (is_ipc_notify(ipc_status)) {
			switch (_ENDPOINT_P(msg.m_source)) {
			case HARDWARE:
				if (msg.NOTIFY_ARG & irq_set) {
					kbd_handler();
				}
				vg_draw_rectangle(x,y,size,size,color);
				break;
			default:
				break;
			}
		}
		else {
		}
	}
	unsubscribe_kbd();
	vg_exit();
	return 0;
}
Example #4
0
int load_menu() {
	vg_init(0x117);
	vg_fill(0xff);
	vg_draw("/usr/src/drivers/proj/images/image_title.mg", 156, 413, 279, 107);
	vg_draw("/usr/src/drivers/proj/images/image_play.mg", 83, 460, 45, 350);
	vg_draw("/usr/src/drivers/proj/images/image_exit.mg", 90, 378, 45, 470);
	drawDate();
}
Example #5
0
int start() {
	unsigned short character = 0x00;
	int ipc_status;
	message msg;
	int irq_set_kb = kb_subscribe_int();
	int irq_set_timer = timer_subscribe_int();
	int irq_set_mouse = mouse_subscribe_int();
	int r;
	unsigned char packet[3];
	unsigned short counter = 0;

	space_invaders_font = font_init("spaceinvader_font_transparent.bmp");
	srand(1);
	options_load();
	mouse_init();
	init_state();
	highscore_load();
	vg_init(VBE_VIDEO_MODE);

	while (1) { //TODO change condition
		/* Get a request message. */
		if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
			printf("driver_receive failed with: %d", r);
			continue;
		}
		if (is_ipc_notify(ipc_status)) { /* received notification */
			switch (_ENDPOINT_P(msg.m_source)) {
			case HARDWARE: /* hardware interrupt notification */
				if (msg.NOTIFY_ARG & irq_set_kb) { /* keyboard interrupt */
					character = kb_int_handler();
					if (character != KB_2BYTE_SCODE)
						kb_event_handler(character);
				}
				if (msg.NOTIFY_ARG & irq_set_mouse){ /* mouse interrupt */
					mouse_int_handler(counter, packet);
					if(packet[0] != MOUSE_ACK && (packet[0] & BIT(3)))
						counter++;
					if(counter == 3){
						counter = 0;
						mouse_event_handler(packet);
					}

				}
				if (msg.NOTIFY_ARG & irq_set_timer){ /* timer interrupt */
					timer_int_handler();
				}
				break;
			default:
				break; /* no other notifications expected: do nothing */
			}
		}
		else { /* received a standard message, not a notification */
			/* no standard messages expected: do nothing */
		}
	}

	return 0;
}
Example #6
0
int test_line(unsigned short xi, unsigned short yi, 
		           unsigned short xf, unsigned short yf, unsigned long color) {
	
	char* video_mem = NULL;
	int failure =0;
	if((video_mem=(char *)vg_init(VBE_MODE_RES_1024x768)) == NULL)
	{
		printf("test_line(): vg_init() failed");
		return 1;
	}
	draw_line(video_mem,xi,yi, xf,yf,color);
	int kbd_irq_set = 0;
	if((kbd_irq_set = kbd_subscribe_int(0)) < 0){//subscribe kbd interrupts
		printf("test_line(): kbd_subscribe_int() failed \n");
		failure = 1;
	}
	int ipc_status;
	message msg;
	int r;
	if(!failure){
		do{
			/* Get a request message. */
			if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) {
				printf("driver_receive failed with: %d", r);
				continue;
			}
			if (is_ipc_notify(ipc_status)) { /* received notification */
				switch (_ENDPOINT_P(msg.m_source)) {
				case HARDWARE: /* hardware interrupt notification */
					if (msg.NOTIFY_ARG & kbd_irq_set) { /* subscribed kbd interrupt */
						if(kbd_int_handler())
							failure = 1;
					}
					break;
				default:
					break; /* no other notifications expected: do nothing */
				}
			} else {/* received a standard message, not a notification */
				/* no standard messages expected: do nothing */
			}
		} while(get_scancode() != ESC_BREAK && !failure);
	}
	if(kbd_unsubscribe_int()){//unsubscribe interrupts
		printf("test_square(): kbd_unsubscribe_int() failed\n");
		failure = 1;
	}
	printf("Done\n");

	if(vg_exit()){
		printf("test_line(): vg_exit() failed");
		return 1;
	}
	return failure;
	
}
Example #7
0
int main(int argc, char** argv) {
	sef_startup();
	vg_init(GRAPHIC_MODE);
	MouseMaze* maze = (MouseMaze*)startMouseMaze();
	while(!maze->validation){
		updateMouseMaze(maze);
	}
	stopMouseMaze(maze);
	vg_exit();
	return 0;
}
Example #8
0
int main(int argc, char **argv) {
	srand(time(NULL));
	sef_startup();

	Whack* whack = startWhack();
	vg_init(0x114);
	int done = 0; //whack->done;
	//Bitmap* board = loadBitmap("/home/lcom/lcom1415-t3g15/projeto/res/board.bmp");
	//Bitmap* bt = loadBitmap("/home/lcom/lcom1415-t3g15/projeto/res/exit-button.bmp");
	//drawBitmapWithoutBg(board, 0, 0, ALIGN_LEFT);
	//drawBitmapWithoutBg(bt, 200, 120, ALIGN_LEFT);

	//MainMenu* teste = createMainMenu();
	//drawMainMenu(teste);

	//deleteMainMenu(teste);

	/*Game* teste = createGame();
	//OptionsMenu* teste = createOptionsMenu(0, 0);
		drawGame(teste);
	flipMouse();
					drawMouse();
					flipDisplay();

		sleep(10);

	deleteGame(teste);*/

	while (!whack->done) {
		updateWhack(whack);
		if (get_counter(whack->timer) % 4 == 0){
			if (!whack->done && whack->draw) {
				drawWhack(whack);
			}

			if (getMouse()->draw) {
				flipMouse();
				drawMouse();
				flipDisplay();
			}
		}
	}
	stopWhack(whack);


	vg_exit();



	printf("\nTerminated\n");

	return 0;
}
Example #9
0
void *test_init(unsigned short mode, unsigned short delay) {
	void* video_mem = NULL;
	if((video_mem=vg_init(mode)) == NULL)
	{
		printf("test_init(): vg_init() failed");
		return NULL;
	}
	int failure=0;
	int timer_irq_set=0;
	if((timer_irq_set = timer_subscribe_int()) < 0){//subscribe timer 0 interrupts
		printf("test_move(): timer_subscribe_int() failed \n");
		failure = 1;
	}
	int ipc_status;
	message msg;
	int r;
	//unsigned long ticks=0;
	if(!failure){
		do{
			/* Get a request message. */
			if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) {
				printf("driver_receive failed with: %d", r);
				continue;
			}
			if (is_ipc_notify(ipc_status)) { /* received notification */
				switch (_ENDPOINT_P(msg.m_source)) {
				case HARDWARE: /* hardware interrupt notification */
					if(msg.NOTIFY_ARG & timer_irq_set){
						timer_int_handler();
					}
					break;
				default:
					break; /* no other notifications expected: do nothing */
				}
			} else {/* received a standard message, not a notification */
				/* no standard messages expected: do nothing */
			}
		} while(get_ticks() < delay * 60);
	}
	if(timer_unsubscribe_int()){//unsubscribe interrupts
		printf("test_move(): timer_unsubscribe_int() failed\n");
		failure = 1;
	}
	if(vg_exit()){
		printf("test_init(): vg_exit() failed");
		return NULL;
	}
	printf("Physical Address of VRAM: 0x%X\n", get_vram_phys_addr());
	return (void*)get_video_mem();
}
Example #10
0
int test_xpm(unsigned short xi, unsigned short yi, char *xpm[]) {
	if (vg_init(VBE_VIDEO_MODE) == NULL)
		return 1;

	if (vg_draw_xpm(xi, yi, xpm) != 0) {
		vg_exit();
		return 1;
	}

	vg_update_screen();

	kbd_test_scan(0);

	return vg_exit();
}
Example #11
0
int test_square(unsigned short x, unsigned short y, unsigned short size,
		unsigned long color) {
	if (vg_init(VBE_VIDEO_MODE) == NULL)
		return 1;

	if (vg_draw_frame(x, y, size, size, color) != 0) {
		vg_exit();
		return 1;
	}

	vg_update_screen();

	kbd_test_scan(0);

	return vg_exit();
}
Example #12
0
void *test_init(unsigned short mode, unsigned short delay) {

	char *video_mem;
	vbe_mode_info_t vbe;
	video_mem = vg_init(mode);

	if (vbe_get_mode_info(mode, &vbe) == 1) {
		printf("Failed vbe_get_mode_info().\n");
		return;
	}

	timer_test_int(delay);

	if (vg_exit() == 1) {
		printf("Failed vg_exit().\n");
		return;
	}

	printf("Physical Adress VRAM: 0x%x",vbe.PhysBasePtr);
	return video_mem;
}
Example #13
0
void *test_init(unsigned short mode, unsigned short delay) {
	void *ret;
	vbe_mode_info_t vmi_p;

	if ((ret = vg_init(mode)) == NULL)
		return NULL;

	timer_test_int(delay);

	if (vbe_get_mode_info(mode, &vmi_p) != 0)
		return NULL;

	if (vg_exit() != 0)
		return NULL;

	//test to see if vbe_get_mode_info is working
	printf("X res: %d\nY res: %d\nBits per pixel: %d\nPhysical Address: %x",
			vmi_p.XResolution, vmi_p.YResolution, vmi_p.BitsPerPixel,
			vmi_p.PhysBasePtr);

	return ret;
}
Example #14
0
File: main.c Project: JoEsteves/lcm
int main()
{
	//permite ao programa usar a memoria
	sef_startup();
	/* Change to video mode */
	vg_init(0x105);
	vg_fill(0x16);


	//quadrados ftw
	int a=100,b=100,c=200,d=200;

	vg_draw_square(100,100,200,200, 0x14);

	scan_kb(&a,&b,&c,&d, 0x14);

	sleep(5);
	/*  for WAIT_TIME_S (5) seconds */
	vg_exit();

	return 0;
}
Example #15
0
int main(int argc, char **argv) {

	/* Initialize service */

	sef_startup();

	char *video_mem;
	video_mem = vg_init(VBE_105_MODE);

	while (1) {
		if (menu(video_mem) == -1) {
			break;
		}

		int n_seconds_player1 = game(video_mem, 1, -1);
		if (n_seconds_player1 == -1) {
			break;
		}

		int n_seconds_player2 = game(video_mem, 2, n_seconds_player1);
		if (n_seconds_player2 == -1) {
			break;
		}

		if (n_seconds_player1 > n_seconds_player2) {
			player_wins(video_mem, 2);
		}
		else {
			player_wins(video_mem, 1);
		}
	}

	vg_exit();


	return 0;

}
Example #16
0
int test_move(unsigned short xi, unsigned short yi, char *xpm[],
		unsigned short hor, short delta, unsigned short time) {

	if (vg_init(MODE_105) == NULL) {
		printf("Failed vg_init().\n");
		return 1;
	}

	if (move_xpm(xi, yi, xpm, hor, delta, time) == 1) {
		if (vg_exit() == 1) {
			printf("Failed vg_exit().\n");
		}
		printf("Wrong coordinates.\n");
		return 1;

	}
	if (wait_for_ESC() == 1) {
		printf("Failed wait_for_ESC().\n");
		return 1;
	}

	return 0;
}
Example #17
0
int test_line(unsigned short xi, unsigned short yi, unsigned short xf, unsigned short yf, unsigned long color) {
	if(vg_init(MODE_105)==NULL)
	{
		printf("Failed vg_init().\n");
		return 1;
	}

	if(print_line(xi,yi,xf,yf,color)==1)
		{
			if(vg_exit()==1)
			{
				printf("Failed vg_exit().\n");
			}
			printf("Wrong coordinates.\n");
			return 1;
		}

	if (wait_for_ESC() ==1) {
			printf("Failed wait_for_ESC().\n");
			return 1;
		}
		return 0;
}
Example #18
0
void *test_init(unsigned short mode, unsigned short delay) {
	vg_init(mode);

	int ipc_status;
	message msg;
	int request;
	int irq_set;
	counter = 0;

	irq_set = subscribe_timer();

	while (counter < delay*60) {
		request = driver_receive(ANY, &msg, &ipc_status);
		if (request != 0) {
			printf("driver_receive failed with: %d", request);
			continue;
		}
		if (is_ipc_notify(ipc_status)) {
			switch (_ENDPOINT_P(msg.m_source)) {
			case HARDWARE:
				if (msg.NOTIFY_ARG & irq_set) {
					timer_handler();
				}
				break;
			default:
				break;
			}
		}
		else {
		}
	}
	unsubscribe_timer();
	vg_exit();
	printf("VRAM physical address: 0x%x\n",vram_phisical_address);
	return 0;
	
}
Example #19
0
int test_xpm(unsigned short xi, unsigned short yi, char *xpm[]) {

	if(vg_init(MODE_105)==NULL)
	{
		printf("Failed vg_init().\n");
		return 1;
	}
	if(print_xpm(xi,yi,xpm)==1)
		{
			if(vg_exit()==1)
			{
				printf("Failed vg_exit().\n");
			}
			printf("Wrong coordinates.\n");
			return 1;
		}

	if (wait_for_ESC() ==1) {
			printf("Failed wait_for_ESC().\n");
			return 1;
		}
		return 0;

}
Example #20
0
int test_square(unsigned short x, unsigned short y, unsigned short size,
		unsigned long color) {

	if (vg_init(MODE_105) == NULL) {
		printf("Failed vg_init().\n");
		return 1;
	}

	if(print_square(x, y, size, color)==1)
	{
		if(vg_exit()==1)
		{
			printf("Failed vg_exit().\n");
		}
		printf("Wrong coordinates.\n");
		return 1;
	}

	if (wait_for_ESC() ==1) {
		printf("Failed wait_for_ESC().\n");
		return 1;
	}
	return 0;
}
Example #21
0
int window_init(window_t* window) { LOG

    int error;
    int i;

    if (window->draw) {
        /* initialize video */
        if (!vg_init(window->video_mode)) {
            printf("window_init: vg_init failed.\n");
            return -1;
        }
    }

    window->redraw = 0;
    window->done = 0;

    /* init font system */
    error = vg_init_FreeType();
    if (error) {
        printf("window_init: vg_init_FreeType failed with error code %d.\n", error);
        return error;
    }

    error = window_set_title(window, "cnix %s", "0.2");
    if (error) {
        printf("window_init: window_set_title failed with error code %d.\n", error);
        return error;
    }
    
    error = window_set_log_message(window, "");
    if (error) {
        printf("window_init: window_set_log_message failed with error code %d.\n", error);
        return error;
    }

    error = window_set_size(window, window->draw ? vg_get_h_res() : 1024, window->draw ? vg_get_v_res() : 768);
    if (error) {
        printf("window_init: window_set_size failed with error code %d.\n", error);
        return error;
    }

    /* set up tabs */
    window->current_tab = -1;
    for (i = 0; i < TAB_COUNT; ++i)
        window->tabs[i] = NULL;

    //window->tabs[0]  = tab_create("#1");
    //window->tabs[1]  = tab_create("#2");
    //window->tabs[2]  = tab_create("#3");
    //window->tabs[3]  = tab_create("#4");
    //window->tabs[4]  = tab_create("#5");
    //window->tabs[5]  = tab_create("#6");
    //window->tabs[6]  = tab_create("#7");
    //window->tabs[7]  = tab_create("#8");
    //window->tabs[8]  = tab_create("#9");
    //window->tabs[9]  = tab_create("#10");
    //window->tabs[10] = tab_create("#11");
    window->tabs[11] = tab_create("#console");
    window->current_tab = TAB_CONSOLE;
    window->prev_current_tab = window->current_tab;

    window->date = NULL;

    /* initialize interrupt handlers */
    int_init();

    /* install mouse */
    error = window_install_mouse(window);
    if (error) {
        printf("window_init: window_install_mouse failed with error code %d.\n", error);
        return error;
    }
    printf("window_install: mouse installed with success.\n");

    /* install keyboard */
    error = keyboard_install();
    if (error) {
        printf("window_init: keyboard_install failed with error code %d.\n", error);
        return error;
    }
    printf("window_init: keyboard installed with success.\n");

    /* set up buttons */
    new_btn = new_button(869, 5, 20, 20, new_btn_draw, new_btn_click, 1, window);
    open_btn = new_button(894, 5, 20, 20, open_btn_draw, open_btn_click, 1, window);
    save_btn = new_button(919, 5, 20, 20, save_btn_draw, save_btn_click, 1, window);
    make_btn = new_button(944, 5, 20, 20, make_btn_draw, make_btn_click, 1, window);
    run_btn = new_button(969, 5, 20, 20, run_btn_draw, run_btn_click, 1, window);
    close_btn = new_button(994, 5, 20, 20, close_btn_draw, close_btn_click, 1, window);

    window->state = WIN_STATE_NORMAL;
    return 0;
}
Example #22
0
int racinix_start()
{
	//vg_exit(); // Fix darker colors first time the mode is changed.
	vg_init(RACINIX_VIDEO_MODE);
	vbe_get_mode_info(RACINIX_VIDEO_MODE, &vmi);

	mouse_position = vectorCreate(vmi.XResolution / 2, vmi.YResolution / 2);

	// Initialize pointers to NULL so that in case of error the program is terminated properly.
	race = NULL;
	bitmap_background = NULL;
	bitmap_mouse_cursor = NULL;
	bitmap_red_car = NULL;
	bitmap_blue_car = NULL;
	bitmap_credits = NULL;
	bitmap_speedometer = NULL;
	font_impact = NULL;
	ad = NULL;

	bitmap_background = bitmap_load(RACINIX_FOLDER_IMAGES "background.bmp");
	if (bitmap_background == NULL)
	{
		return 1;
	}
	bitmap_mouse_cursor = bitmap_load(RACINIX_FOLDER_IMAGES "cursor.bmp");
	if (bitmap_mouse_cursor == NULL)
	{
		return 1;
	}
	bitmap_red_car = bitmap_load(RACINIX_FOLDER_IMAGES "red_car.bmp");
	if (bitmap_red_car == NULL)
	{
		return 1;
	}
	bitmap_blue_car = bitmap_load(RACINIX_FOLDER_IMAGES "blue_car.bmp");
	if (bitmap_blue_car == NULL)
	{
		return 1;
	}
	bitmap_credits = bitmap_load(RACINIX_FOLDER_IMAGES "credits.bmp");
	if (bitmap_credits == NULL)
	{
		return 1;
	}
	bitmap_speedometer = bitmap_load(RACINIX_FOLDER_IMAGES "speedometer.bmp");
	if (bitmap_speedometer == NULL)
	{
		return 1;
	}
	font_impact = font_load(RACINIX_FOLDER_FONTS "impact");
	if (font_impact == NULL)
	{
		return 1;
	}

	if ((ad = ad_create(RACINIX_FILE_ADS, 120, font_impact, RACINIX_COLOR_ORANGE)) == NULL)
	{
		return 1;
	}

	vehicle_keys[0].accelerate = KEY_W;
	vehicle_keys[0].brake = KEY_S;
	vehicle_keys[0].turn_left = KEY_A;
	vehicle_keys[0].turn_right = KEY_D;

	vehicle_keys[1].accelerate = KEY_ARR_UP;
	vehicle_keys[1].brake = KEY_ARR_DOWN;
	vehicle_keys[1].turn_left = KEY_ARR_LEFT;
	vehicle_keys[1].turn_right = KEY_ARR_RIGHT;

	vehicle_colors[0] = VIDEO_GR_RED;
	vehicle_colors[1] = VIDEO_GR_BLUE;

	vehicle_bitmaps[0] = bitmap_red_car;
	vehicle_bitmaps[1] = bitmap_blue_car;
	if (racinix_dispatcher())
	{
		return 1;
	}
	return 0;
}
Example #23
0
int test_move(unsigned short xi, unsigned short yi, char *xpm[], 
				unsigned short hor, short delta, unsigned short time) {

	int ipc_status;
	message msg;
	int request;
	int irq_set1,irq_set2;
	vg_init(GRAPHIC_MODE);
	Sprite*sprite = create_sprite(xpm);
	if(!hor){
		sprite->xspeed = ((double)delta/(double)time)/FPS;
		sprite->yspeed = 0;
	}
	else{
		sprite->xspeed = 0;
		sprite->yspeed =  ((double)delta/(double)time)/FPS;
	}
	sprite->x = xi;
	sprite->y = yi;

	draw_sprite(sprite);

	counter = 0;
	irq_set1 = subscribe_kbd();
	irq_set2 = subscribe_timer();


	while (scanCode != EXIT_MAKE_CODE) {
		request = driver_receive(ANY, &msg, &ipc_status);
		if (request != 0) {
			printf("driver_receive failed with: %d", request);
			continue;
		}
		if (is_ipc_notify(ipc_status)) {
			switch (_ENDPOINT_P(msg.m_source)) {
			case HARDWARE:
				if (msg.NOTIFY_ARG & irq_set1) {
					kbd_handler();
				}
				if (msg.NOTIFY_ARG & irq_set2) {
					if(counter % (int)(60/FPS) == 0){

						update_sprite(sprite);
						draw_sprite(sprite);
					}
					if(counter == time * 60){
						unsubscribe_timer();
					}
					timer_handler();
				}
				break;
			default:
				break;
			}
		}
		else {
		}
	}
	unsubscribe_timer();
	unsubscribe_kbd();
	vg_exit();
	return 0;
	
}
Example #24
0
int test_move(unsigned short xi, unsigned short yi, char *xpm[], 
				unsigned short hor, short delta, unsigned short time1)
{
	if(xpm == NULL)
		return 1;
	char* video_mem = NULL;
	int failure =0;
	int width, height;
	char* pix = NULL;
	if((pix = (char*) read_xpm(xpm, &width, &height)) == NULL)
		return 1;
	if((video_mem=(char *)vg_init(VBE_MODE_RES_1024x768)) == NULL)
	{
		printf("test_move(): vg_init() failed");
		return 1;
	}
	int kbd_irq_set = 0;
	int timer_irq_set=0;
	if((kbd_irq_set = kbd_subscribe_int(0)) < 0){//subscribe kbd interrupts
		printf("test_move(): kbd_subscribe_int() failed \n");
		failure = 1;
	}
	if((timer_irq_set = timer_subscribe_int()) < 0){//subscribe timer 0 interrupts
		printf("test_move(): timer_subscribe_int() failed \n");
		failure = 1;
	}
	int ipc_status;
	message msg;
	int r;
	double step = (double)delta/(time1*60);
	double xfp = xi;
	double yfp = yi;
	if(!failure){
		do{
			/* Get a request message. */
			if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) {
				printf("driver_receive failed with: %d", r);
				continue;
			}
			if (is_ipc_notify(ipc_status)) { /* received notification */
				switch (_ENDPOINT_P(msg.m_source)) {
				case HARDWARE: /* hardware interrupt notification */
					if (msg.NOTIFY_ARG & kbd_irq_set)  /* subscribed kbd interrupt */
						if(kbd_int_handler())
							failure = 1;
					if(msg.NOTIFY_ARG & timer_irq_set){
						if(get_ticks() < time1 * 60){//enquanto tempo desjado nao passou
							timer_int_handler();
							blank_secondary_buf();//clear buffer
							draw_pixmap(get_secondary_buf(),(int) xfp, (int) yfp, height, width, pix);
							commit_to_video_mem();
							if(hor)
								xfp += step;//se movimento horizontal incrementar x
							else yfp +=step;//senao incrementar y
						}
					}
					break;
				default:
					break; /* no other notifications expected: do nothing */
				}
			} else {/* received a standard message, not a notification */
				/* no standard messages expected: do nothing */
			}
		} while(get_scancode() != ESC_BREAK && !failure);
	}
	if(timer_unsubscribe_int()){//unsubscribe interrupts
		printf("test_move(): timer_unsubscribe_int() failed\n");
		failure = 1;
	}
	if(kbd_unsubscribe_int()){//unsubscribe interrupts
		printf("test_move(): kbd_unsubscribe_int() failed\n");
		failure = 1;
	}
	printf("Done\n");
	if(vg_exit()){
		printf("test_move(): vg_exit() failed");
		return 1;
	}
	return failure;
}					
Example #25
0
int test_move(unsigned short xi, unsigned short yi, char *xpm[],
		unsigned short hor, short delta, unsigned short time) {
	int width, height;
	char* pixmap;
	int ipc_status;
	message msg;
	int irq_set_timer = timer_subscribe_int();
	int irq_set_keyboard = kb_subscribe_int();
	int r;
	unsigned short counter = 0;
	long character;
	float pixmap_speed, next_position;

	if (vg_init(VBE_VIDEO_MODE) == NULL)
		return 1;

	if ((pixmap = (char*) read_xpm(xpm, &width, &height)) == NULL)
		return 1;

	pixmap_speed = (float) (delta) / (time * 60); //TODO encontrar TICKS_PER_SEC; nao existe

	if (irq_set_timer >= 0)
		irq_set_timer = BIT(irq_set_timer);
	else
		irq_set_timer = 0;

	if (irq_set_keyboard >= 0)
		irq_set_keyboard = BIT(irq_set_keyboard);
	else
		irq_set_keyboard = 0;

	next_position = 0;

	while (counter < time && character != ESC_BREAKCODE) { /* You may want to use a different condition */
		/* Get a request message. */
		if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
			printf("driver_receive failed with: %d", r);
			continue;
		}
		if (is_ipc_notify(ipc_status)) { /* received notification */
			switch (_ENDPOINT_P(msg.m_source)) {
			case HARDWARE: /* hardware interrupt notification */
				if (msg.NOTIFY_ARG & irq_set_timer) { /* subscribed interrupt */
					timed_scan_int_handler(&counter);
					vg_move_pixmap(xi, yi, width, height, pixmap, hor, next_position);
					vg_update_screen();
					next_position += pixmap_speed;
				}
				if (msg.NOTIFY_ARG & irq_set_keyboard) { /* subscribed interrupt */
					character = kb_int_handler();
				}
				break;
			default:
				break; /* no other notifications expected: do nothing */
			}
		} else { /* received a standard message, not a notification */
			/* no standard messages expected: do nothing */
		}
	}

	free(pixmap);
	return vg_exit();
}