void *fb_routine(void *ptr)
{
    fb_init();
    INFO("Feamebuffer Init - OK");

    unsigned char rr, gg, bb;

    srand(time(NULL));

    INFO("  width=%d\n  height=%d", fb_dev.width, fb_dev.height);

    while(1)
    {
        switch (cmd)
        {
            case DRAW:
                page_flip(r, g, b);

                break;
            case RANDOM_COLOR:

                rr = rand() % 0xFF;
                gg = rand() % 0xFF;
                bb = rand() % 0xFF;

                page_flip(rr, gg, bb);

                break;

            case DPMS_ON:
            case DPMS_OFF:
            case DPMS_SUSPEND:
            case DPMS_STANDBY:

                DPMS_set(cmd);

                cmd = DEFAULT;

                break;

            case REINIT:

                fb_init();
                cmd = 0;

                break;

            default:

                sleep(1);
                printf("default");

                break;
        }
    }

    close(fb_dev.fb_fd);

    return NULL;
}
Ejemplo n.º 2
0
int title(void) {

	int result;

	soft_switch(LORES);
        soft_switch(TXTCLR);
        soft_switch(MIXSET);

	ram[DRAW_PAGE]=PAGE0;
	clear_bottom();
	ram[DRAW_PAGE]=PAGE1;
	clear_bottom();
	ram[DRAW_PAGE]=PAGE2;
	clear_bottom();

	grsim_unrle(title_rle,0xc00);

	ram[DRAW_PAGE]=PAGE0;
	gr_copy_to_current(0xc00);
	ram[DRAW_PAGE]=PAGE1;
	gr_copy_to_current(0xc00);
	page_flip();

//	page_flip();
//	page_flip();

//	grsim_update();

	result=select_menu(12, 22, 3, title_menu);

	return result;
}
Ejemplo n.º 3
0
static void
sna_present_unflip(ScreenPtr screen, uint64_t event_id)
{
	struct sna *sna = to_sna_from_screen(screen);
	struct kgem_bo *bo;

	DBG(("%s(event=%lld)\n", __FUNCTION__, (long long)event_id));
	if (sna->mode.front_active == 0 || sna->mode.shadow_active) {
		const struct ust_msc *swap;

		DBG(("%s: no CRTC active, perform no-op flip\n", __FUNCTION__));

notify:
		swap = sna_crtc_last_swap(sna_mode_first_crtc(sna));
		DBG(("%s: pipe=%d, tv=%d.%06d msc %lld, event %lld complete\n", __FUNCTION__,
		     -1,
		     swap->tv_sec, swap->tv_usec, (long long)swap->msc,
		     (long long)event_id));
		present_event_notify(event_id,
				     ust64(swap->tv_sec, swap->tv_usec),
				     swap->msc);
		return;
	}

	bo = get_flip_bo(screen->GetScreenPixmap(screen));
	if (bo == NULL || !page_flip(screen, NULL, event_id, bo)) {
		DBG(("%s: failed, trying to restore original mode\n", __FUNCTION__));
		xf86SetDesiredModes(sna->scrn);
		goto notify;
	}
}
Ejemplo n.º 4
0
static Bool
sna_present_flip(RRCrtcPtr crtc,
		 uint64_t event_id,
		 uint64_t target_msc,
		 PixmapPtr pixmap,
		 Bool sync_flip)
{
	struct kgem_bo *bo;

	DBG(("%s(pipe=%d, event=%lld, msc=%lld, pixmap=%ld, sync?=%d)\n",
	     __FUNCTION__,
	     pipe_from_crtc(crtc),
	     (long long)event_id,
	     (long long)target_msc,
	     pixmap->drawable.serialNumber, sync_flip));

	if (!check_flip__crtc(to_sna_from_pixmap(pixmap), crtc)) {
		DBG(("%s: flip invalid for CRTC\n", __FUNCTION__));
		return FALSE;
	}

	bo = get_flip_bo(pixmap);
	if (bo == NULL) {
		DBG(("%s: flip invalid bo\n", __FUNCTION__));
		return FALSE;
	}

	if (sync_flip)
		return page_flip(crtc->pScreen, crtc, event_id, bo);
	else
		return page_flip__async(crtc, event_id, target_msc, bo);
}
Ejemplo n.º 5
0
static void page_flip_cb(void *ptr)
{
	struct page_flip_data *data = ptr;

	while (!alarm_received) {
		page_flip();
		wait_vblanks(data->n_vblanks);
	}
}
Ejemplo n.º 6
0
static void draw_and_flip_cb(void *ptr)
{
	struct draw_data *data = ptr;
	int i, ops;

	for (i = 0; !alarm_received; i++) {
		for (ops = 0; ops < data->ops_per_vblank; ops++)
			draw_rect(back_fb, data->method, i << 8);

		page_flip();
		wait_vblanks(1);
	}
}
Ejemplo n.º 7
0
int player_select(void) {

	int which_player=0;
	int ch,saved;

	saved=ram[DRAW_PAGE];
	ram[DRAW_PAGE]=8;
	clear_top_a(0);
	ram[DRAW_PAGE]=saved;

	while(1) {

		gr_copy_to_current(0xc00);

		color_equals(COLOR_AQUA);
		vlin(6+(which_player*16),22+(which_player*16),15);
		vlin(6+(which_player*16),22+(which_player*16),22);

		grsim_put_sprite(tfv_walk_right,17,8);

		grsim_put_sprite(tfg_walk_right,17,24);

		ram[CH]=13;
		ram[CV]=21;
		move_and_print("SELECT PLAYER");

		page_flip();

		ch=grsim_input();
		if (ch==13) break;

		if ((ch==APPLE_UP) || (ch==APPLE_DOWN) ||
			(ch==APPLE_RIGHT) || (ch==APPLE_LEFT)) {
			which_player=!which_player;
		}

		usleep(100000);

	}

	return which_player;
}
Ejemplo n.º 8
0
int flying(void) {

	unsigned char ch;
	int shipy;
	int turning=0;
	int draw_splash=0,splash_count=0;
	int zint;



	/************************************************/
	/* Flying					*/
	/************************************************/

	gr();
	ram[DRAW_PAGE]=PAGE0;
	clear_bottom();
	ram[DRAW_PAGE]=PAGE1;
	clear_bottom();

	shipy=20;

	while(1) {
		if (splash_count>0) splash_count--;

		ch=grsim_input();

		if ((ch=='q') || (ch==27))  break;

#if 0
		if (ch=='g') {
			BETA+=0.1;
			printf("Horizon=%lf\n",BETA);
		}
		if (ch=='h') {
			BETA-=0.1;
			printf("Horizon=%lf\n",BETA);
		}

		if (ch=='s') {
			scale_x++;
			scale_y++;
			printf("Scale=%lf\n",scale_x);
		}
#endif

		if ((ch=='w') || (ch==APPLE_UP)) {
			if (shipy>16) {
				shipy-=2;
				space_z.i++;

			}
			splash_count=0;

//			printf("Z=%lf\n",space_z);
		}
		if ((ch=='s') || (ch==APPLE_DOWN)) {
			if (shipy<28) {
				shipy+=2;
				space_z.i--;
			}
			else {
				splash_count=10;
			}
//			printf("Z=%lf\n",space_z);
		}
		if ((ch=='a') || (ch==APPLE_LEFT)) {
			if (turning>0) {
				turning=0;
			}
			else {
				turning=-20;

				angle-=1;
				if (angle<0) angle+=ANGLE_STEPS;
			}
		}
		if ((ch=='d') || (ch==APPLE_RIGHT)) {
			if (turning<0) {
				turning=0;
			}
			else {
				turning=20;
				angle+=1;
				if (angle>=ANGLE_STEPS) angle-=ANGLE_STEPS;
			}

		}

		/* Used to be able to go backwards */
		if (ch=='z') {
			if (speed<3) speed++;
		}

		if (ch=='x') {
			if (speed>0) speed--;
		}

		if (ch==' ') {
			speed=SPEED_STOPPED;
		}

		if (ch=='h') {
			print_help();
		}

		/* Ending */
		if (ch==13) {
			int landing_color,tx,ty;
			tx=cx.i;	ty=cy.i;

			landing_color=lookup_map(tx,ty);
			printf("Trying to land at %d %d\n",tx,ty);
			printf("Color=%d\n",landing_color);
			if (landing_color==12) {
				int loop;

				zint=space_z.i;

				/* Land the ship */
				for(loop=zint;loop>0;loop--) {

					draw_background_mode7();
					grsim_put_sprite(shadow_forward,SHIPX+3,31+zint);
					grsim_put_sprite(ship_forward,SHIPX,shipy);
					page_flip();
					usleep(200000);

					space_z.i--;


				}

				return 0;
			}
			else {
				htab(11);
				vtab(22);
				move_cursor();
				print_both_pages("NEED TO LAND ON GRASS!");
			}
		}



		if (speed!=SPEED_STOPPED) {

			int ii;

			dx.i = fixed_sin_scale[(angle+4)&0xf].i;        // cos
			dx.f = fixed_sin_scale[(angle+4)&0xf].f;        // cos
			dy.i = fixed_sin_scale[angle&0xf].i;
			dy.f = fixed_sin_scale[angle&0xf].f;

			for(ii=0;ii<speed;ii++) {
				fixed_add(&cx,&dx,&cx);
				fixed_add(&cy,&dy,&cy);
			}

		}

		draw_background_mode7();

		zint=space_z.i;

		draw_splash=0;


		if (speed>0) {

			if ((shipy>25) && (turning!=0)) {
				splash_count=1;
			}

			if ((over_water) && (splash_count)) {
				draw_splash=1;
			}
		}

//		printf("VMW: %d %d\n",draw_splash,splash_count);

		if (turning==0) {
			if (draw_splash) {
				grsim_put_sprite(splash_forward,
					SHIPX+1,shipy+9);
			}
			grsim_put_sprite(shadow_forward,SHIPX+3,31+zint);
			grsim_put_sprite(ship_forward,SHIPX,shipy);
		}
		if (turning<0) {

			if (draw_splash) {
				grsim_put_sprite(splash_left,
						SHIPX+1,36);
			}
			grsim_put_sprite(shadow_left,SHIPX+3,31+zint);
			grsim_put_sprite(ship_left,SHIPX,shipy);
			turning++;
		}
		if (turning>0) {

			if (draw_splash) {
				grsim_put_sprite(splash_right,
						SHIPX+1,36);
			}
			grsim_put_sprite(shadow_right,SHIPX+3,31+zint);
			grsim_put_sprite(ship_right,SHIPX,shipy);
			turning--;
		}

		page_flip();

		usleep(20000);

	}
	return 0;
}