Beispiel #1
0
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
    int nx;
    unsigned char *dst;
    unsigned mask, mask_right;
    lcd_blockfunc_type *bfunc;

    /* direction flip */
    if (x2 < x1)
    {
        nx = x1;
        x1 = x2;
        x2 = nx;
    }
    
    /******************** In viewport clipping **********************/
    /* nothing to draw? */
    if (((unsigned)y >= (unsigned)current_vp->height) || (x1 >= current_vp->width) 
        || (x2 < 0))
        return;  
        
    if (x1 < 0)
        x1 = 0;
    if (x2 >= current_vp->width)
        x2 = current_vp->width-1;

    /* adjust to viewport */
    x1 += current_vp->x;
    x2 += current_vp->x;
    y += current_vp->y;
    
#if defined(HAVE_VIEWPORT_CLIP)
    /********************* Viewport on screen clipping ********************/
    /* nothing to draw? */
    if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
        || (x2 < 0))
        return;  
    
    /* clipping */
    if (x1 < 0)
        x1 = 0;
    if (x2 >= LCD_WIDTH)
        x2 = LCD_WIDTH-1;
#endif

    bfunc = lcd_blockfuncs[current_vp->drawmode];
    dst   = FBADDR(x1>>2,y);
    nx    = x2 - (x1 & ~3);
    mask  = 0xFFu >> (2 * (x1 & 3));
    mask_right = 0xFFu << (2 * (~nx & 3));
    
    for (; nx >= 4; nx -= 4)
    {
        bfunc(dst++, mask, 0xFFu);
        mask = 0xFFu;
    }
    mask &= mask_right;
    bfunc(dst, mask, 0xFFu);
}
Beispiel #2
0
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y)
{
    switch (key) {
    case 'a':
	afunc();
	break;
    case 'b':
	bfunc();
	break;
    case 'h':
	help();
	break;
    case 't':
	tfunc();
	break;
    case 'e':
	explode();
	break;
    case '\033':
	exit(EXIT_SUCCESS);
	break;
    default:
	break;
    }
    glutPostRedisplay();
}
Beispiel #3
0
/* Draw a vertical line (optimised) */
void lcd_vline(int x, int y1, int y2)
{
    int y;
    unsigned char *dst, *dst_end;
    unsigned mask;
    lcd_blockfunc_type *bfunc;

    /* direction flip */
    if (y2 < y1)
    {
        y = y1;
        y1 = y2;
        y2 = y;
    }

    /******************** In viewport clipping **********************/
    /* nothing to draw? */
    if (((unsigned)x >= (unsigned)current_vp->width) || (y1 >= current_vp->height)
        || (y2 < 0))
        return;  
        
    if (y1 < 0)
        y1 = 0;
    if (y2 >= current_vp->height)
        y2 = current_vp->height-1;

    /* adjust for viewport */
    y1 += current_vp->y;
    y2 += current_vp->y;
    x += current_vp->x;
    
#if defined(HAVE_VIEWPORT_CLIP)
    /********************* Viewport on screen clipping ********************/
    /* nothing to draw? */
    if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT) 
        || (y2 < 0))
        return;
    
    /* clipping */
    if (y1 < 0)
        y1 = 0;
    if (y2 >= LCD_HEIGHT)
        y2 = LCD_HEIGHT-1;
#endif
        
    bfunc = lcd_blockfuncs[current_vp->drawmode];
    dst   = FBADDR(x>>2,y1);
    mask  = pixmask[x & 3];
    
    dst_end = dst + (y2 - y1) * LCD_FBWIDTH;
    do
    {
        bfunc(dst, mask, 0xFFu);
        dst += LCD_FBWIDTH;
    }
    while (dst <= dst_end);
}
Beispiel #4
0
/*ARGSUSED1*/
void key (unsigned char key, int x, int y) {
    switch (key) {
    case 'b': bfunc(); break;
    case 'c': cfunc(); break;
    case 'l': lfunc(); break;
    case 't': tfunc(); break;
    case 'f': ffunc(); break;
    case 'n': nfunc(); break;
    case 'u': ufunc(); break;
    case 'U': Ufunc(); break;
    case 'p': pfunc(); break;
    case 'P': Pfunc(); break;
    case 'w': wfunc(); break;
    case 'x': xfunc(); break;
    case 'X': Xfunc(); break;
    case 'y': yfunc(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
}
Beispiel #5
0
nemo_main()
{
    stream instr, outstr;
    real   tsnap, mscale;
    Body  *btab = NULL, *bp;
    int i, j, n, nbody, nbodymass, bits, bitsmass, seed;
    rproc  bfunc, btrtrans();

    instr = stropen(getparam("in"), "r");
    outstr = hasvalue("out") ? stropen(getparam("out"),"w") : NULL;

    n = getiparam("iter");

    get_history(instr);
    if (!get_tag_ok(instr, SnapShotTag)) 
      error("not a snapshot");
    get_snap(instr, &btab, &nbody, &tsnap, &bits);

    if (getbparam("bodytrans")) {
      dprintf(0,"bodytrans scaling, iter=%d\n",n);
      bfunc = btrtrans(getparam("mass"));     /* use bodytrans expression */

      for (j=0; j<n; j++)
	for (bp=btab, i=0; i<nbody; bp++,i++)
	  Mass(bp) = bfunc(bp, tsnap, i);
    } else {
      dprintf(0,"simple inline scaling, iter=%d\n",n);
      mscale = getdparam("mass");
      for (j=0; j<n; j++)
	for (bp=btab, i=0; i<nbody; bp++,i++)
	  Mass(bp) = mscale*Mass(bp);
    }

    strclose(instr);
    if (outstr) { 
      put_history(outstr);
      put_snap(outstr, &btab, &nbody, &tsnap, &bits);
      strclose(outstr);
    }
}
Beispiel #6
0
int
show(void)
{
    char *p;
    void (*cfunc)(int);
    void (*sfunc)(int);
    void (*bfunc)(int);
    struct natstr *natp;
    int tlev;
    char buf[1024];
    int rlev;

again:
    p = getstarg(player->argp[1], "Show what ('?' to list options)? ", buf);
    if (!p || !*p)
	return RET_SYN;
    if (*p == '?') {
	pr("bridge, item, land, news, nuke, plane, sect, ship, product, tower, updates\n");
	goto again;
    }

    natp = getnatp(player->cnum);
    rlev = (int)(1.25 * natp->nat_level[NAT_RLEV]);

    if (!player->argp[3]) {
	tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
	if (player->god)
	    tlev = 1000;
    } else {
	tlev = (int)atoi(player->argp[3]);
	if (tlev > (int)(1.25 * natp->nat_level[NAT_TLEV]) && !player->god)
	    tlev = (int)(1.25 * natp->nat_level[NAT_TLEV]);
    }
    if (player->god)
	rlev = 1000;
    switch (*p) {
    case 'b':
	show_bridge(99999);
	return RET_OK;
    case 't':
	show_tower(99999);
	return RET_OK;
    case 'i':
	show_item(99999);
	return RET_OK;
    case 'n':
	if (*(p + 1) == 'e') {
	    show_news(99999);
	    return RET_OK;
	}
	if (drnuke_const > MIN_DRNUKE_CONST)
	    tlev = ((rlev / drnuke_const) > tlev ? tlev :
		    (rlev / drnuke_const));
	bfunc = show_nuke_build;
	cfunc = show_nuke_capab;
	sfunc = show_nuke_stats;
	break;
    case 'l':
	bfunc = show_land_build;
	sfunc = show_land_stats;
	cfunc = show_land_capab;
	break;
    case 'p':
	if (p[1] == 'r') {
	    show_product(99999);
	    return RET_OK;
	}
	bfunc = show_plane_build;
	sfunc = show_plane_stats;
	cfunc = show_plane_capab;
	break;
    case 's':
	if (*(p + 1) == 'e') {
	    bfunc = show_sect_build;
	    sfunc = show_sect_stats;
	    cfunc = show_sect_capab;
	} else {
	    bfunc = show_ship_build;
	    sfunc = show_ship_stats;
	    cfunc = show_ship_capab;
	}
	break;
    case 'u':
	show_updates(player->argp[2] ? atoi(player->argp[2]) : 8);
	return RET_OK;
    default:
	return RET_SYN;
    }

    p = getstarg(player->argp[2],
		 "Build, stats, or capability data (b,s,c)? ", buf);
    if (!p || !*p)
	return RET_SYN;
    pr("Printing for tech level '%d'\n", tlev);
    if (*p == 'B' || *p == 'b')
	bfunc(tlev);
    else if (*p == 'C' || *p == 'c')
	cfunc(tlev);
    else if (*p == 'S' || *p == 's')
	sfunc(tlev);
    else
	return RET_SYN;
    return RET_OK;
}
Beispiel #7
0
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
    int nx;
    unsigned char *dst, *dst_end;
    unsigned mask, mask_right;
    lcd_blockfunc_type *bfunc;

    /******************** In viewport clipping **********************/
    /* nothing to draw? */
    if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || (y >= current_vp->height)
        || (x + width <= 0) || (y + height <= 0))
        return;

    if (x < 0)
    {
        width += x;
        x = 0;
    }
    if (y < 0)
    {
        height += y;
        y = 0;
    }
    if (x + width > current_vp->width)
        width = current_vp->width - x;
    if (y + height > current_vp->height)
        height = current_vp->height - y;

    /* adjust for viewport */
    x += current_vp->x;
    y += current_vp->y;
    
#if defined(HAVE_VIEWPORT_CLIP)
    /********************* Viewport on screen clipping ********************/
    /* nothing to draw? */
    if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) 
        || (x + width <= 0) || (y + height <= 0))
        return;
    
    /* clip image in viewport in screen */
    if (x < 0)
    {
        width += x;
        x = 0;
    }
    if (y < 0)
    {
        height += y;
        y = 0;
    }
    if (x + width > LCD_WIDTH)
        width = LCD_WIDTH - x;
    if (y + height > LCD_HEIGHT)
        height = LCD_HEIGHT - y;
#endif

    bfunc = lcd_blockfuncs[current_vp->drawmode];
    dst   = FBADDR(x>>2,y);
    nx    = width - 1 + (x & 3);
    mask  = 0xFFu >> (2 * (x & 3));
    mask_right = 0xFFu << (2 * (~nx & 3));
    
    for (; nx >= 4; nx -= 4)
    {
        unsigned char *dst_col = dst;

        dst_end = dst_col + height * LCD_FBWIDTH;
        do
        {
            bfunc(dst_col, mask, 0xFFu);
            dst_col += LCD_FBWIDTH;
        }
        while (dst_col < dst_end);

        dst++;
        mask = 0xFFu;
    }
    mask &= mask_right;

    dst_end = dst + height * LCD_FBWIDTH;
    do
    {
        bfunc(dst, mask, 0xFFu);
        dst += LCD_FBWIDTH;
    }
    while (dst < dst_end);
}
Beispiel #8
0
/* Draw a column of pattern pat into the bitmap bmp inside the given rectangle.
 */
static inline void
blit_column (BITMAP *bmp, struct ABMAP *pat, int x, int y, int w, int h, enum COLUMN_TYPE f)
{
	int ct = bmp->ct, cb = bmp->cb;
	int oy;
	int j;
	int pat_h = pat->bmp->h - pat->bt - pat->bb;

	void (*bfunc) (BITMAP *, BITMAP *, int, int, int, int, int, int, int,
		int) = masked_non_stretched_blit;
	int bx = 0;
	int bw = pat->bmp->w;
	int x2 = x;
	int w2;

	if (pat->flags & ABMAP_ALIGN_V)
		oy = (y / pat_h) * pat_h - y;
	else
		oy = centered_offset (h, pat_h);

	if (pat_h < 1)
		return;

	if (f == COLUMN_MIDDLE)
		bx = pat->bl;
	if (f == COLUMN_RIGHT)
		bx = pat->bmp->w - pat->br;

	if (f == COLUMN_LEFT)
		bw = pat->bl;
	if (f == COLUMN_MIDDLE)
		bw = w;
	if (f == COLUMN_RIGHT)
		bw = pat->br;

	if (f == COLUMN_CENTER)
		x2 = x + w / 2 - pat->bmp->w / 2;
	if (f == COLUMN_RIGHT)
		x2 = x + w - pat->br;

	w2 = bw;

	if (f == COLUMN_STRETCH) {
		w2 = w;
		bfunc = masked_stretch_blit;
	}

	if (pat->flags & ABMAP_CENTER_V) {
		bfunc (pat->bmp, bmp, bx, 0, bw, pat->bmp->h, x2,
			y + h / 2 - pat->bmp->h / 2, w2, pat->bmp->h);
	}
	else if (pat->flags & ABMAP_STRETCH_V) {
		masked_stretch_blit (pat->bmp, bmp, bx, 0, bw, pat->bmp->h, x2, y, w2,
			h);
	} else {
		/* top */
		if (pat->bt) {
			bmp->ct = MAX (ct, y);
			bmp->cb = MIN (cb, MIN (y + h, y + pat->bt));
			bfunc (pat->bmp, bmp, bx, 0, bw, pat->bt, x2, y, w2, pat->bt);
		}
		/* middle */
		bmp->ct = MAX (ct, MIN (y + h, y + pat->bt));
		bmp->cb = MIN (cb, MAX (y, y + h - pat->bb));
		for (j = oy + y; j < y + h; j += pat->bmp->h - pat->bt - pat->bb) {
			bfunc (pat->bmp, bmp, bx, pat->bt, bw, pat_h, x2, j, w2, pat_h);
		}
		/* bottom */
		if (pat->bt) {
			bmp->ct = MAX (ct, MAX (y, y + h - pat->bb));
			bmp->cb = MIN (cb, y + h);
			bfunc (pat->bmp, bmp, bx, pat->bmp->h - pat->bb, bw, pat->bb, x2,
				y + h - pat->bb, w2, pat->bb);
		}
	}
	bmp->ct = ct;
	bmp->cb = cb;
}