Example #1
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 #2
0
void YourHighPriorityISRCode()
{
	#if	defined(USB_INTERRUPT)
		USBDeviceTasks();
	#endif

#if	USE_PS2KEYBOARD		// PS/2キーボードI/F を使用する.
	#if	PS2KBD_USE_INTERRUPT
		// INT0割り込みは Highプライオリティのみ.
		kbd_handler();
	#endif
#endif
}	//This return will be a	"retfie fast", since this is in	a #pragma interrupt	section
Example #3
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;
	
}