Esempio n. 1
0
void Main (Closure_clp self)
{
    FB_st *st;
    IOEntryMod_clp emod;

    int i;
    
    TRC(printf("FB/MGA: entered\n"));
 
    st = (FB_st *)Heap$Malloc(Pvs(heap), 
			      sizeof(FB_st));
    if (st == NULL) 
	RAISE_Heap$NoMemory();

    memset(st, 0, sizeof(FB_st));

    CL_INIT(st->cl, &fb_ms, st);


    /* Before we do anything, see if we can find a framebuffer device
       that we understand. */

    st->cardbase = (Pixel_t *) MGAInit(FB_WIDTH, FB_HEIGHT, FB_DEPTH, FB_MODE);

    TRC(printf("st->cardbase = %p\n", st->cardbase));

    if(!st->cardbase) {
	fprintf(stderr, "Failed to initialise MGA device\n");

	Heap$Free(Pvs(heap), st);

	return;
    }

#ifdef TEST_CARD
    test_card16a( (uint16_t *) st->cardbase );
#else
    memset((uchar_t *) st->cardbase, 0, 
	   FB_WIDTH * FB_HEIGHT * (FB_DEPTH/8) );
#endif	

    /* Init state */
    st->qosleft = 100;
    st->cursched = 0;
    st->schedndx = 0;
    for (i = 0; i < FB_SCHEDLEN; i++) {
	st->sched[0][i] = st->sched[1][i] = 0;
    }
    
    /* Initialise window DS */
    for (i = 0 ; i < FB_MAX_WINDOWS; i++) {
	FB_Window *w = &st->window[i];
	w->wid  = i;
	w->free = True;
	w->tagword = w->tag  = w->wid;

	/* extend the tag to be a full word (32 or 64 bits) wide */
	w->tagword |= (w->tagword<<8);
	w->tagword |= (w->tagword<<16);
	/* Generates harmless overflow warning on 32bit architectures */
	w->tagword |= (w->tagword<<32);

    }
    
    /* Initialise stream DS */
    for (i = 0 ; i < FB_MAX_STREAMS; i++) {
	FB_Stream *s = &st->stream[i];
	s->sid  = i;
	s->free = True;
	s->qos  = 0;
    }

    TRC(printf("About to create an entry...\n"));

    /* Create an entry*/
    emod = NAME_FIND ("modules>IOEntryMod", IOEntryMod_clp);
    st->fbentry = IOEntryMod$New (emod, Pvs(actf), Pvs(vp),
				  VP$NumChannels (Pvs(vp)));    
    

    TRC(printf("About to grab stretches for FB and CLIP\n"));

    /* Grab stretches for FB and CLIP */
    {

	Stretch_clp           str;
	Stretch_Size          size;

	/* Get a stretch for clip RAM. Allocate a spare line of tiles
           at the start and end in case we need to blit over the edges */

	str    = STR_NEW(sizeof(tag_t)*FB_WIDTH*(FB_HEIGHT+16));
	if (!str) {
	    fprintf(stderr,"Couldn't get stretch");
	}
	st->clipstr = str;
	st->clipbase = (tag_t *) STR_RANGE(str, &size);
	st->clip = st->clipbase + (FB_WIDTH * 8);

	if (!st->clip || size < (FB_WIDTH*(FB_HEIGHT+16))) {
	    fprintf(stderr,"Stretch bogus\n");
	}
	TRC(fprintf(stderr,"FB: Clip RAM at %p size %lx\n", st->clip, size));	
    }
    TRC(printf("About to init clip RAM\n"));

    /* Initialise the clip RAM */
    InitClipRAM(&st->cl);

    TRC(printf("About to add dev>fblite to namespace\n"));
    CX_ADD("dev>fblite", st->cardbase, addr_t);

    TRC(printf("About to init blitting code\n"));
    /* Init the blitting code */
    blit_init(st);

    /* Turn on cursor */
    TRC(printf("About to turn on cursor\n"));
    MGALoadCursor(st->cardbase, CURSOR_IDX, CURSOR_BITS);
    MGAMoveCursor(st->cardbase, CURSOR_IDX, CURSOR_INITX, CURSOR_INITY);

    /* Export management interface */
    TRC(printf("About to export management interface\n"));
    IDC_EXPORT ("dev>FB", FB_clp, &st->cl);
    /* Go into a loop to service all the clients */


    /* Launch WSSvr */

    TRC(printf("Trying to launch wssvr\n"));
    TRY {
	Closure_clp wssvr;

	wssvr = NAME_FIND("modules>WSSvr", Closure_clp);
	
	Threads$Fork(Pvs(thds), wssvr->op->Apply, wssvr->st, 0);

	st->wssvr_shares_domain = True;
    } CATCH_ALL {
	printf("Couldn't launch WSSvr - exception %s\n",
	       exn_ctx.cur_exception);
    } ENDTRY;

    TRC(printf("FB/MGA: Init Done. (%ix%i %ibpp mode %i)\n",
	       FB_WIDTH,FB_HEIGHT,FB_DEPTH,FB_MODE));
    blit_loop(st);
}
Esempio n. 2
0
void cloud_tick (int display)
{
    double w = game.video_gl_width;
    double h = game.video_gl_height;

    double cloud_w = w / 30.0;
    double cloud_h = w / 40.0;
    static double wind = 0.3;

    static tilep tile;
    if (!tile) {
        tile = tile_find("snow_mound5");
    }

    fpoint tl, br;

    blit_init();

    cloud *f;
    cloud *f_eo = clouds + nclouds;

    f = clouds;

    while (f < f_eo) {
        if (!f->active) {
            f->active = true;

            f->x = myrand() % (int)w;
            f->y = myrand() % (int)h;
            f->scale = gauss(1.5, 0.2);
        }

        double dw = cloud_w * (f->scale + 0.2);
        double dh = cloud_h * (f->scale + 0.2);

        tl.x = f->x - dw;
        tl.y = f->y - dh;
        br.x = f->x + dw;
        br.y = f->y + dh;

        color c = BLACK;
        c.a = 100.0;
        glcolor(c);
        tl.x += w / 20;
        tl.y += w / 12;
        br.x += w / 20;
        br.y += w / 12;

        if (display) {
            tile_blit_fat(0, tile, 0, &tl, &br);
        }

        f++;
    }

    f = clouds;

    while (f < f_eo) {
        double dw = cloud_w * f->scale;
        double dh = cloud_h * f->scale;

        tl.x = f->x - dw;
        tl.y = f->y - dh;
        br.x = f->x + dw;
        br.y = f->y + dh;

        f->x += wind;

        color c = WHITE;
        c.a = 150.0;
        glcolor(c);

        if (display) {
            tile_blit_fat(0, tile, 0, &tl, &br);
        }

        f++;
    }

    blit_flush();

    cloud_move(false);
}