Esempio n. 1
0
void ms_tick(void)
{
	DrawScene();
	draw_banner();
	
	if (ms.state == MS_EXPANDING)
	{
		ms.expandframe++;
		
		if (ms.expandframe > EXPAND_LENGTH)
			ms.state = MS_DISPLAYED;
		else
			draw_expand();
	}
	
	if (ms.state == MS_DISPLAYED)
	{
		// scan down effect
		if (ms.current_row < map.ysize)
		{
			draw_row(ms.current_row++);
			
			if (ms.current_row < map.ysize)
				draw_row(ms.current_row++);
		}
		
		// draw map
		DrawRect(ms.x - 1, ms.y - 1, ms.x + ms.w, ms.y + ms.h, DK_BLUE);
		DrawSurface(ms.sfc, ms.x, ms.y);
		
		// you-are-here dot
		if (++ms.timer & 8)
			draw_sprite(ms.px, ms.py, SPR_MAP_PIXELS, 4);
		
		// dismissal
		if (ms.lastbuttondown)
		{
			if (!buttondown())
				ms.lastbuttondown = false;
		}
		else if (buttondown())
		{
			ms.state = MS_CONTRACTING;
		}
	}
	else if (ms.state == MS_CONTRACTING)
	{
		ms.expandframe--;
		
		if (ms.expandframe <= 0)
		{
			int param = (ms.return_gm == GM_INVENTORY) ? 1 : 0;
			game.setmode(ms.return_gm, param);
		}
		else
		{
			draw_expand();
		}
	}
}
Esempio n. 2
0
    void onDraw(SkCanvas* canvas) override {
        SkScalar x = SkIntToScalar(10);
        SkScalar y = SkIntToScalar(10);

        canvas->translate(x, y);
        y = draw_row(canvas, fBM4444);
        canvas->translate(0, y);
        y = draw_row(canvas, fBM16);
        canvas->translate(0, y);
        draw_row(canvas, fBM32);
    }
 virtual void onDrawContent(SkCanvas* canvas) {
     SkScalar x = SkIntToScalar(10);
     SkScalar y = SkIntToScalar(10);
     
     canvas->translate(x, y);
     y = draw_row(canvas, fBM8);
     canvas->translate(0, y);
     y = draw_row(canvas, fBM4444);
     canvas->translate(0, y);
     y = draw_row(canvas, fBM16);
     canvas->translate(0, y);
     draw_row(canvas, fBM32);
 }
    virtual void onDrawContent(SkCanvas* canvas) {        
		SkScalar x = SkIntToScalar(10);
        SkScalar y = SkIntToScalar(10);
        
        /*依次用四种格式的bitmap画四行, 一行6个方块*/
        //平移到(10, 10)开始画.
        //y依次下移
        canvas->translate(x, y);
        y = draw_row(canvas, fBM8);
        canvas->translate(0, y);
        y = draw_row(canvas, fBM4444);
        canvas->translate(0, y);
        y = draw_row(canvas, fBM16);
        canvas->translate(0, y);
        draw_row(canvas, fBM32);
    }
Esempio n. 5
0
    void onDraw(SkCanvas* canvas) override {
        canvas->translate(10, 10);
        for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) {
            SkSize size = computeSize(fBM, fMatrix[i]);
            size.fWidth += 20;
            size.fHeight += 20;

            draw_row(canvas, fBM, fMatrix[i], size.fWidth);
            canvas->translate(0, size.fHeight);
        }
    }
Esempio n. 6
0
//=== Drawing ===========================================================
void Rainbowduino::draw(byte level) {
  if(num_frames == 0) return; //no frames available
  off = current_frame_nr * NUM_ROWS + current_row;
  draw_row(current_row / 3, level, frame_buffer[off++], frame_buffer[off++], frame_buffer[off++]);
  if(current_row >= NUM_ROWS - 1) {
    current_row =  0;
    current_level = (current_level >= NUM_LEVEL - 1) ? 0 : current_level+1;    
  }
  else {
    current_row = current_row + 3;
  }
}
Esempio n. 7
0
void display_3d(void)
{
  glMatrixMode(GL_MODELVIEW);
  /* Update viewer position in modelview matrix */

  glLoadIdentity();
  set_viewpoint();
  glTranslatef(-1,0,0);

  glColor3f(0.5, 0.5, 0.5);
  int r = 0;
  std::for_each(maze->begin(), maze->end(), std::bind2nd(draw_row(), &r));
  draw_rat(walker->position(), true);
  draw_floor();
}
Esempio n. 8
0
static void draw_menu(int sel, int top, int edit_line)
{
    int x, y;
    int sbtop = 0, sbbot = 0;
    const char *tabmsg;
    int tabmsg_len;

    if (cm->nentries > MENU_ROWS) {
	int sblen = max(MENU_ROWS * MENU_ROWS / cm->nentries, 1);
	sbtop = ((MENU_ROWS - sblen + 1) * top /
	    (cm->nentries - MENU_ROWS + 1)) + VSHIFT;
	sbbot = sbtop + sblen - 1;
	sbtop += 4;
	sbbot += 4;		/* Starting row of scrollbar */
    }

    printf("\033[%d;%dH\1#1\016l", VSHIFT + 1, HSHIFT + MARGIN + 1);
    for (x = 2 + HSHIFT; x <= (WIDTH - 2 * MARGIN - 1) + HSHIFT; x++)
	putchar('q');

    printf("k\033[%d;%dH\1#1x\017\1#2 %s \1#1\016x",
	   VSHIFT + 2,
	   HSHIFT + MARGIN + 1, pad_line(cm->title, 1, WIDTH - 2 * MARGIN - 4));

    printf("\033[%d;%dH\1#1t", VSHIFT + 3, HSHIFT + MARGIN + 1);
    for (x = 2 + HSHIFT; x <= (WIDTH - 2 * MARGIN - 1) + HSHIFT; x++)
	putchar('q');
    fputs("u\017", stdout);

    for (y = 4 + VSHIFT; y < 4 + VSHIFT + MENU_ROWS; y++)
	draw_row(y, sel, top, sbtop, sbbot);

    printf("\033[%d;%dH\1#1\016m", y, HSHIFT + MARGIN + 1);
    for (x = 2 + HSHIFT; x <= (WIDTH - 2 * MARGIN - 1) + HSHIFT; x++)
	putchar('q');
    fputs("j\017", stdout);

    if (edit_line && cm->allowedit && !cm->menu_master_passwd)
	tabmsg = cm->messages[MSG_TAB];
    else
	tabmsg = cm->messages[MSG_NOTAB];

    tabmsg_len = strlen(tabmsg);

    printf("\1#8\033[%d;%dH%s",
	   TABMSG_ROW, 1 + HSHIFT + ((WIDTH - tabmsg_len) >> 1), tabmsg);
    printf("\1#0\033[%d;1H", END_ROW);
}
Esempio n. 9
0
static void
render				(vbi_page *		pg,
				 int			row)
{
	/* ushort *canvas = ximgdata + 48 + 45 * DISP_WIDTH; */

	if (shift > 0) {
		bump(shift, FALSE);
		draw_video (48, 45 + sh_last * CELL_HEIGHT,
			    DISP_WIDTH - 48, CELL_HEIGHT);
	}

	draw_row (ximgdata + 48 + (45 + row * CELL_HEIGHT) * DISP_WIDTH,
		  pg, row);

	XPutImage (display, window, gc, ximage,
		   0, 0, 0, 0, DISP_WIDTH, DISP_HEIGHT);
}
Esempio n. 10
0
void
update_frame(const GameState *game)
{
    init_video_buffer();

    // Draw puzzle
    int nr_block = game->nr_block_h * game->nr_block_v;
    for (int i = 0; i < nr_block; i++) {
        int block_index = game->block[i];
        // Draw a block
        int scr_x = (i % game->nr_block_h) * game->block_w;
        int scr_y = (i / game->nr_block_h) * game->block_h;
        int pic_x = (block_index % game->nr_block_h) * game->block_w;
        int pic_y = (block_index / game->nr_block_h) * game->block_h;
        for (int off_y = 0; off_y < game->block_h; off_y++) {
            for (int off_x = 0; off_x < game->block_w; off_x++) {
                draw_pixel(scr_x + off_x, scr_y + off_y,
                        get_color(game->image, pic_x + off_x, pic_y + off_y, game->image_w, game->image_h));
            }
        }
    }

    // Draw frame
    for (int i = 0; i < game->nr_block_h + 1; i++) {
        int scr_x = i * game->block_w;
        draw_column(scr_x, 0, 6, get_scr_h(), 0);
    }
    for (int i = 0; i < game->nr_block_v + 1; i++) {
        int scr_y = i * game->block_h;
        draw_row(0, scr_y, 6, get_scr_w(), 0);
    }

    draw_border(game->block_x * game->block_w, game->block_y * game->block_h,
                game->block_w, game->block_h, 3, 0x000000ff);

    if (game->select == 1) {
        draw_border(game->select_block_x * game->block_w, game->select_block_y * game->block_h,
                    game->block_w, game->block_h, 3, 0x00ff0000);
    }

    update_screen();
}
Esempio n. 11
0
static const char *run_menu(void)
{
    int key;
    int done = 0;
    volatile int entry = cm->curentry;
    int prev_entry = -1;
    volatile int top = cm->curtop;
    int prev_top = -1;
    int clear = 1, to_clear;
    const char *cmdline = NULL;
    volatile clock_t key_timeout, timeout_left, this_timeout;
    const struct menu_entry *me;
    bool hotkey = false;

    /* Note: for both key_timeout and timeout == 0 means no limit */
    timeout_left = key_timeout = cm->timeout;

    /* If we're in shiftkey mode, exit immediately unless a shift key
       is pressed */
    if (shiftkey && !shift_is_held()) {
	return cm->menu_entries[cm->defentry]->cmdline;
    } else {
	shiftkey = 0;
    }

    /* Do this before hiddenmenu handling, so we show the background */
    prepare_screen_for_menu();

    /* Handle hiddenmenu */
    if (hiddenmenu) {
	cmdline = do_hidden_menu();
	if (cmdline)
	    return cmdline;

	/* Otherwise display the menu now; the timeout has already been
	   cancelled, since the user pressed a key. */
	hiddenmenu = 0;
	key_timeout = 0;
    }

    /* Handle both local and global timeout */
    if (setjmp(timeout_jump)) {
	entry = cm->defentry;

	if (top < 0 || top < entry - MENU_ROWS + 1)
	    top = max(0, entry - MENU_ROWS + 1);
	else if (top > entry || top > max(0, cm->nentries - MENU_ROWS))
	    top = min(entry, max(0, cm->nentries - MENU_ROWS));

	draw_menu(cm->ontimeout ? -1 : entry, top, 1);
	cmdline =
	    cm->ontimeout ? cm->ontimeout : cm->menu_entries[entry]->cmdline;
	done = 1;
    }

    while (!done) {
	if (entry <= 0) {
	    entry = 0;
	    while (entry < cm->nentries && is_disabled(cm->menu_entries[entry]))
		entry++;
	}
	if (entry >= cm->nentries - 1) {
	    entry = cm->nentries - 1;
	    while (entry > 0 && is_disabled(cm->menu_entries[entry]))
		entry--;
	}

	me = cm->menu_entries[entry];

	if (top < 0 || top < entry - MENU_ROWS + 1)
	    top = max(0, entry - MENU_ROWS + 1);
	else if (top > entry || top > max(0, cm->nentries - MENU_ROWS))
	    top = min(entry, max(0, cm->nentries - MENU_ROWS));

	/* Start with a clear screen */
	if (clear) {
	    /* Clear and redraw whole screen */
	    /* Enable ASCII on G0 and DEC VT on G1; do it in this order
	       to avoid confusing the Linux console */
	    if (clear >= 2)
		prepare_screen_for_menu();
	    clear_screen();
	    clear = 0;
	    prev_entry = prev_top = -1;
	}

	if (top != prev_top) {
	    draw_menu(entry, top, 1);
	    display_help(me->helptext);
	} else if (entry != prev_entry) {
	    draw_row(prev_entry - top + 4 + VSHIFT, entry, top, 0, 0);
	    draw_row(entry - top + 4 + VSHIFT, entry, top, 0, 0);
	    display_help(me->helptext);
	}

	prev_entry = entry;
	prev_top = top;
	cm->curentry = entry;
	cm->curtop = top;

	/* Cursor movement cancels timeout */
	if (entry != cm->defentry)
	    key_timeout = 0;

	if (key_timeout) {
	    int tol = timeout_left / CLK_TCK;
	    print_timeout_message(tol, TIMEOUT_ROW, cm->messages[MSG_AUTOBOOT]);
	    to_clear = 1;
	} else {
	    to_clear = 0;
	}

	if (hotkey && me->immediate) {
	    /* If the hotkey was flagged immediate, simulate pressing ENTER */
	    key = KEY_ENTER;
	} else {
	    this_timeout = min(min(key_timeout, timeout_left),
			       (clock_t) CLK_TCK);
	    key = mygetkey(this_timeout);

	    if (key != KEY_NONE) {
		timeout_left = key_timeout;
		if (to_clear)
		    printf("\033[%d;1H\1#0\033[K", TIMEOUT_ROW);
	    }
	}

	hotkey = false;

	switch (key) {
	case KEY_NONE:		/* Timeout */
	    /* This is somewhat hacky, but this at least lets the user
	       know what's going on, and still deals with "phantom inputs"
	       e.g. on serial ports.

	       Warning: a timeout will boot the default entry without any
	       password! */
	    if (key_timeout) {
		if (timeout_left <= this_timeout)
		    longjmp(timeout_jump, 1);

		timeout_left -= this_timeout;
	    }
	    break;

	case KEY_CTRL('L'):
	    clear = 1;
	    break;

	case KEY_ENTER:
	case KEY_CTRL('J'):
	    key_timeout = 0;	/* Cancels timeout */
	    if (me->passwd) {
		clear = 1;
		done = ask_passwd(me->passwd);
	    } else {
		done = 1;
	    }
	    cmdline = NULL;
	    if (done) {
		switch (me->action) {
		case MA_CMD:
		    cmdline = me->cmdline;
		    break;
		case MA_SUBMENU:
		case MA_GOTO:
		case MA_EXIT:
		    done = 0;
		    clear = 2;
		    cm = me->submenu;
		    entry = cm->curentry;
		    top = cm->curtop;
		    break;
		case MA_QUIT:
		    /* Quit menu system */
		    done = 1;
		    clear = 1;
		    draw_row(entry - top + 4 + VSHIFT, -1, top, 0, 0);
		    break;
		case MA_HELP:
		    key = show_message_file(me->cmdline, me->background);
		    /* If the exit was an F-key, display that help screen */
		    show_fkey(key);
		    done = 0;
		    clear = 1;
		    break;
		default:
		    done = 0;
		    break;
		}
	    }
	    if (done && !me->passwd) {
		/* Only save a new default if we don't have a password... */
		if (me->save && me->label) {
		    syslinux_setadv(ADV_MENUSAVE, strlen(me->label), me->label);
		    syslinux_adv_write();
		}
	    }
	    break;

	case KEY_UP:
	case KEY_CTRL('P'):
	    while (entry > 0) {
		entry--;
		if (entry < top)
		    top -= MENU_ROWS;
		if (!is_disabled(cm->menu_entries[entry]))
		    break;
	    }
	    break;

	case KEY_DOWN:
	case KEY_CTRL('N'):
	    while (entry < cm->nentries - 1) {
		entry++;
		if (entry >= top + MENU_ROWS)
		    top += MENU_ROWS;
		if (!is_disabled(cm->menu_entries[entry]))
		    break;
	    }
	    break;

	case KEY_PGUP:
	case KEY_LEFT:
	case KEY_CTRL('B'):
	case '<':
	    entry -= MENU_ROWS;
	    top -= MENU_ROWS;
	    while (entry > 0 && is_disabled(cm->menu_entries[entry])) {
		entry--;
		if (entry < top)
		    top -= MENU_ROWS;
	    }
	    break;

	case KEY_PGDN:
	case KEY_RIGHT:
	case KEY_CTRL('F'):
	case '>':
	case ' ':
	    entry += MENU_ROWS;
	    top += MENU_ROWS;
	    while (entry < cm->nentries - 1
		   && is_disabled(cm->menu_entries[entry])) {
		entry++;
		if (entry >= top + MENU_ROWS)
		    top += MENU_ROWS;
	    }
	    break;

	case '-':
	    while (entry > 0) {
		entry--;
		top--;
		if (!is_disabled(cm->menu_entries[entry]))
		    break;
	    }
	    break;

	case '+':
	    while (entry < cm->nentries - 1) {
		entry++;
		top++;
		if (!is_disabled(cm->menu_entries[entry]))
		    break;
	    }
	    break;

	case KEY_CTRL('A'):
	case KEY_HOME:
	    top = entry = 0;
	    break;

	case KEY_CTRL('E'):
	case KEY_END:
	    entry = cm->nentries - 1;
	    top = max(0, cm->nentries - MENU_ROWS);
	    break;

	case KEY_F1:
	case KEY_F2:
	case KEY_F3:
	case KEY_F4:
	case KEY_F5:
	case KEY_F6:
	case KEY_F7:
	case KEY_F8:
	case KEY_F9:
	case KEY_F10:
	case KEY_F11:
	case KEY_F12:
	    show_fkey(key);
	    clear = 1;
	    break;

	case KEY_TAB:
	    if (cm->allowedit && me->action == MA_CMD) {
		int ok = 1;

		key_timeout = 0;	/* Cancels timeout */
		draw_row(entry - top + 4 + VSHIFT, -1, top, 0, 0);

		if (cm->menu_master_passwd) {
		    ok = ask_passwd(NULL);
		    clear_screen();
		    draw_menu(-1, top, 0);
		} else {
		    /* Erase [Tab] message and help text */
		    printf("\033[%d;1H\1#0\033[K", TABMSG_ROW);
		    display_help(NULL);
		}

		if (ok) {
		    cmdline = edit_cmdline(me->cmdline, top);
		    done = !!cmdline;
		    clear = 1;	/* In case we hit [Esc] and done is null */
		} else {
		    draw_row(entry - top + 4 + VSHIFT, entry, top, 0, 0);
		}
	    }
	    break;
	case KEY_CTRL('C'):	/* Ctrl-C */
	case KEY_ESC:		/* Esc */
	    if (cm->parent) {
		cm = cm->parent;
		clear = 2;
		entry = cm->curentry;
		top = cm->curtop;
	    } else if (cm->allowedit) {
		done = 1;
		clear = 1;
		key_timeout = 0;

		draw_row(entry - top + 4 + VSHIFT, -1, top, 0, 0);

		if (cm->menu_master_passwd)
		    done = ask_passwd(NULL);
	    }
	    break;
	default:
	    if (key > 0 && key < 0xFF) {
		key &= ~0x20;	/* Upper case */
		if (cm->menu_hotkeys[key]) {
		    key_timeout = 0;
		    entry = cm->menu_hotkeys[key]->entry;
		    /* Should we commit at this point? */
		    hotkey = true;
		}
	    }
	    break;
	}
    }

    printf("\033[?25h");	/* Show cursor */

    /* Return the label name so localboot and ipappend work */
    return cmdline;
}
Esempio n. 12
0
int spupng_export_png(struct spupng_t *sp, struct eia608_screen* data)
{
	png_structp png_ptr;
	png_infop info_ptr;
	png_bytep *row_pointer;
	png_bytep image;
	int ww, wh, rowstride, row_adv;
	int row;

	assert ((sizeof(png_byte) == sizeof(uint8_t))
			&& (sizeof(*image) == sizeof(uint8_t)));

	// Allow space at beginning and end of each row for a padding space
	ww = CCW * (COLUMNS+2);
	wh = CCH * ROWS;
	row_adv = (COLUMNS+2) * CCW * CCH;

	rowstride = ww * sizeof(*image);

	if (!(row_pointer = (png_bytep*)malloc(sizeof(*row_pointer) * wh))) {
		mprint("Unable to allocate %d byte buffer.\n",
				sizeof(*row_pointer) * wh);
		return 0;
	}

	if (!(image = (png_bytep)malloc(wh * ww * sizeof(*image)))) {
		mprint("Unable to allocate %d KB image buffer.",
				wh * ww * sizeof(*image) / 1024);
		free(row_pointer);
		return 0;
	}
	// Initialize image to transparent
	memset(image, COL_TRANSPARENT, wh * ww * sizeof(*image));

	/* draw the image */

	for (row = 0; row < ROWS; row++) {
		if (data->row_used[row])
			draw_row(data, row, image + row * row_adv, rowstride);
	}

	/* Now save the image */

	if (!(png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
					NULL, NULL, NULL)))
		goto unknown_error;

	if (!(info_ptr = png_create_info_struct(png_ptr))) {
		png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
		goto unknown_error;
	}

	if (!spupng_write_png (sp, data, png_ptr, info_ptr, image, row_pointer, ww, wh)) {
		png_destroy_write_struct (&png_ptr, &info_ptr);
		goto write_error;
	}

	png_destroy_write_struct (&png_ptr, &info_ptr);

	free (row_pointer);

	free (image);

	return 1;

write_error:

unknown_error:
	free (row_pointer);

	free (image);

	return 0;
}
Esempio n. 13
0
//==============================================================
void Rainbowduino::draw() {
  off = current_frame_nr * num_rows + current_row;
  draw_row(current_row / 3, 31, frame_buffer[off++], frame_buffer[off++], frame_buffer[off++]);
  current_row = (current_row >= num_rows - 1) ? 0 : current_row+3;  
}