Beispiel #1
0
static int gc3355_get_data(struct cgpu_info *gridseed, unsigned char *buf, int size)
{
	unsigned char *p;
	int readcount;
	int err, amount;

	readcount = size;
	p = buf;
	while(readcount > 0) {
		err = usb_read_once(gridseed, p, readcount, &amount, C_GETRESULTS);
		if (err && err != LIBUSB_ERROR_TIMEOUT)
			return err;
		readcount -= amount;
		p += amount;
	}
#if 1
	if (!opt_quiet && opt_debug && buf[1] != 0xaa) {
		int i;
#ifndef WIN32
		printf(" <<< %d : ", size);
#else
		set_text_color(FOREGROUND_RED);
		printf(" <<< %d : ", size);
		set_text_color(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#endif
		for(i=0; i<size; i++) {
			printf("%02x", buf[i]);
			if ((i+1) % 4 == 0)
			printf(" ");
		}
		printf("\n");
	}
#endif
	return 0;
}
Beispiel #2
0
static int gc3355_write_data(struct cgpu_info *gridseed, unsigned char *data, int size)
{
	int err, wrote;

#if 1
	if (!opt_quiet && opt_debug) {
		int i;
#ifndef WIN32
		printf(" >>> %d : ", size);
#else
		set_text_color(FOREGROUND_RED|FOREGROUND_GREEN);
		printf(" >>> %d : ", size);
		set_text_color(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#endif
		for(i=0; i<size; i++) {
			printf("%02x", data[i]);
			if (i==3)
				printf(" ");
		}
		printf("\n");
	}
#endif
	err = usb_write(gridseed, data, size, &wrote, C_SENDWORK);
	if (err != LIBUSB_SUCCESS || wrote != size)
		return -1;
	return 0;
}
Beispiel #3
0
// Initialize the GDT
void gdt_init() {

	// Tasks setup
	for (int i = 0; i < tasks_nb; i++)
		setup_task(i);
		
	// Set the address and the size of the GDT in the pointer
	gdt_ptr.limit = sizeof(gdt);
	gdt_ptr.base = (uint32_t) &gdt;
	
	// Initializing the three segment descriptors in the GDT : NULL, code segment, data segment
	gdt[0] = null_segment();
	gdt[1] = code_segment(0, 1048575, DPL_KERNEL);
	gdt[2] = data_segment(0, 1048575, DPL_KERNEL);
	
	// gdt[3] : entry for initial kernel TSS (CPU state of first task saved there)
	static uint8_t initial_tss_kernel_stack[65536];  // 64KB of stack
	static tss_t initial_tss;
	gdt[3] = gdt_make_tss(&initial_tss, DPL_KERNEL);
	memset(&initial_tss, 0, sizeof(tss_t));
	initial_tss.ss0 = GDT_KERNEL_DATA_SELECTOR;
	initial_tss.esp0 = ((uint32_t) initial_tss_kernel_stack) + sizeof(initial_tss_kernel_stack);

	// Load the GDT
    gdt_flush(&gdt_ptr);
	
	// Load the task register to point to the initial TSS selector
	load_task_register(gdt_entry_to_selector(&gdt[3]));
	
	// Confirmation message
	set_text_color(LIGHT_GREEN);
	printf("OK\n");
	set_text_color(WHITE);
	
}
Beispiel #4
0
void CTEXTAREA_set_foreground(void *_object)
{
	THIS->no_change = TRUE;
	
	QTextCursor oldCursor = WIDGET->textCursor();
	
	WIDGET->selectAll();
	
	WIDGET->setTextColor(Qt::black);
	set_text_color(THIS);
	
	WIDGET->setTextCursor(oldCursor);
	
	set_text_color(THIS);
	
	THIS->no_change = FALSE;
}
Beispiel #5
0
/**
 * \brief Creates a text to draw with the default properties.
 *
 * The default properties are:
 * - font: the default font defined in file text/fonts.dat
 * - horizontal alignment: left
 * - vertical alignment: middle
 * - rendering mode: solid
 * - text color: white
 *
 * \param x x position of the text on the destination surface
 * \param y y position of the text on the destination surface
 */
TextSurface::TextSurface(int x, int y):
    Drawable(),
    font_id(default_font_id),
    horizontal_alignment(ALIGN_LEFT),
    vertical_alignment(ALIGN_MIDDLE),
    rendering_mode(TEXT_SOLID),
    surface(NULL) {

    text = "";
    set_text_color(Color::get_white());
    set_position(x, y);
}
Beispiel #6
0
static int gc3355_get_data(struct cgpu_info *gridseed, unsigned char *buf, int size)
{
	unsigned char *p;
	int readcount;
	int err = 0, amount;

	readcount = size;
	p = buf;
	while(readcount > 0) {
		err = usb_read_once(gridseed, p, readcount, &amount, C_GETRESULTS);
		if (err) {
			if (readcount != size)
				applog(LOG_ERR, "Timed out after receiving partial data from %i",
						gridseed->sgminer_id);
			break;
		}
		readcount -= amount;
		p += amount;
	}
#if 1
	if (!opt_quiet && opt_debug && (size-readcount) > 0) {
		int i;
#ifndef WIN32
		printf(" <<< %d : ", size);
#else
		set_text_color(FOREGROUND_RED);
		printf(" <<< %d : ", (size-readcount));
		set_text_color(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#endif
		for(i=0; i<(size-readcount); i++) {
			printf("%02x", buf[i]);
			if ((i+1) % 4 == 0)
			printf(" ");
		}
		printf("\n");
	}
#endif
	return err;
}
Beispiel #7
0
/**
 * \brief Creates a text to draw with the specified alignment properties.
 * \param x x position of the text on the destination surface
 * \param y y position of the text on the destination surface
 * \param horizontal_alignment horizontal alignment of the text: ALIGN_LEFT,
 * ALIGN_CENTER or ALIGN_RIGHT
 * \param vertical_alignment vertical alignment of the text: ALIGN_TOP,
 * ALIGN_MIDDLE or ALIGN_BOTTOM
 */
TextSurface::TextSurface(int x, int y,
                         TextSurface::HorizontalAlignment horizontal_alignment,
                         TextSurface::VerticalAlignment vertical_alignment):
    Drawable(),
    font_id(default_font_id),
    horizontal_alignment(horizontal_alignment),
    vertical_alignment(vertical_alignment),
    rendering_mode(TEXT_SOLID),
    surface(NULL) {

    text = "";
    set_text_color(Color::get_white());
    set_position(x, y);
}
Beispiel #8
0
inline void TextFormatter::set_text_color(util::PackedTRGB trgb)
{
    math::Vec4F rgba;
    trgb.unpack_rgba(rgba);
    set_text_color(rgba);
}
Beispiel #9
0
void Edit::set_text_color(const Vector4& color)
{
	set_text_color(color.x, color.y, color.z, color.w);
}
Beispiel #10
0
void Edit::set_text_color(const Vector3& color)
{
	set_text_color(color.x, color.y, color.z);
}
Beispiel #11
0
int main(int argc, char *argv[])
{
	puts("conlib测试程序:");
	T(conlib_init(),"初始化控制台库");
	 
	T(gotoxy(5,5),"现在光标在这里了");
	T(hide_cursor(),"光标不见了"); 
	T(show_cursor(50),"显示一半光标"); 
	T(show_cursor(100),"显示完整光标"); 
	T(settitle("conlib test program"),"设置标题");
	T(set_text_color(ConRed),"设置文字颜色");
	T(set_background_color(ConWhite),"设置背景颜色");
	
	clrscr();
	
	const ConKey* ck;
	const ConMouse* cm;
	const ConControlKeyState *cks; 

	char spaceLine[80] = {[0 ... 78] = ' ',[79] = '\0'};

	

	puts("按键测试:");
	hide_cursor();
#define Tand(v,t)	if(v & t)printf(#t "  ");
#define Teq(v,t)	if(v == t)printf(#t "  ");
	while(1)
	{
		gotoxy(12,0);
		printf("clock: %d\t", (int)clock()); 
		
		ck = getkey();
		cm = getmouse();
		cks = NULL; 
		gotoxy(0,1);
		printf("key value: %p", ck);
		gotoxy(0,2);
		printf("mouse value: %p", cm);
		
		gotoxy(0,3);
		if(ck != NULL)
		{
			cks = ck->ctrl_key_state;
			printf("key code: %d is %s", ck->key, ck->state? "按下": "释放");			
		}
			
		gotoxy(0,4);
		if(cm != NULL)
		{
			cks = cm->ctrl_key_state;
			printf("mouse position: %2d, %2d\n", cm->x, cm->y);
			printf(spaceLine);
			printf(spaceLine);
			printf(spaceLine);
			printf(spaceLine);
			gotoxy(0,5);
			if(cm->event != ConMOUSE_WHEELED && cm->event != ConMOUSE_HWHEELED)
			{
				Tand(cm->button,ConMOUSE_1ST_BUTTON);
				Tand(cm->button,ConMOUSE_2ND_BUTTON);
				Tand(cm->button,ConMOUSE_3RD_BUTTON);
				Tand(cm->button,ConMOUSE_4TH_BUTTON);
				Tand(cm->button,ConMOUSE_RIGHT_BUTTON);
				printf(" 被 按下了\n");
			}else
				printf("鼠标向 [%s] 滚\n", cm->button > 0? "前":"后");
			Teq(cm->event,ConMOUSE_CLICK);
			Teq(cm->event,ConMOUSE_DBCLICK);
			Teq(cm->event,ConMOUSE_MOVED);
			Teq(cm->event,ConMOUSE_WHEELED);
			Teq(cm->event,ConMOUSE_HWHEELED);
			printf(" 被 触发了\n");
		}

		gotoxy(0,10);
#define S(c)	(c? "ON": "OFF")

		if(cks != NULL)
			printf("NUM[%3s]  SCROLL[%3s]  CAPS[%3s]\n"
					"LCTRL[%3s]  LALT[%3s]  RALT[%3s]  RCTRL[%3s]\n"
					"SHIFT[%3s]  ENHANCED[%3s]"
					, S(cks->numlock), S(cks->scrolllock), S(cks->capslock)
					, S(cks->left_ctrl), S(cks->left_alt), S(cks->right_alt), S(cks->right_ctrl)
					, S(cks->shift), S(cks->enhanced));
		console_test();
	}	
	
return EXIT_SUCCESS;
}
Beispiel #12
0
void Console::reset_text_color(
    const Device    device)
{
    set_text_color(device, DefaultColor);
}
Beispiel #13
0
/****************************************************************************
 *
 *  ROUTINE       : xprintf
 *
 *  INPUTS        : const PB_INSTANCE *ppbi : Pointer to decoder instance.
 *                  long n_pixel             : Offset into buffer to write text.
 *                  const char *format      : Format string for print.
 *                  ...                     : Variable length argument list.
 *
 *  OUTPUTS       : None.
 *
 *  RETURNS       : int: Size (in bytes) of the formatted text.
 *
 *  FUNCTION      : Display a printf style message on the current video frame.
 *
 *  SPECIAL NOTES : None.
 *
 ****************************************************************************/
int onyx_xprintf(unsigned char *ppbuffer, long n_pixel, long n_size, long n_stride, const char *format, ...)
{
    BOOL b_rc;
    va_list arglist;
    HFONT hfont, hfonto;

    int rc = 0;
    char sz_formatted[256] = "";
    unsigned char *p_dest = &ppbuffer[n_pixel];

#ifdef _WIN32_WCE
    //  Set up temporary bitmap
    HDC hdc_memory   = NULL;
    HBITMAP hbm_temp = NULL;
    HBITMAP hbm_orig = NULL;

    RECT rect;

    //  Copy bitmap to video frame
    long x;
    long y;

    //  Format text
    va_start(arglist, format);
    _vsnprintf(sz_formatted, sizeof(sz_formatted), format, arglist);
    va_end(arglist);

    rect.left   = 0;
    rect.top    = 0;
    rect.right  = 8 * strlen(sz_formatted);
    rect.bottom = 8;

    hdc_memory = create_compatible_dc(NULL);

    if (hdc_memory == NULL)
        goto Exit;

    hbm_temp = create_bitmap(rect.right, rect.bottom, 1, 1, NULL);

    if (hbm_temp == NULL)
        goto Exit;

    hbm_orig = (HBITMAP)(select_object(hdc_memory, hbm_temp));

    if (!hbm_orig)
        goto Exit;

    //  Write text into bitmap
    //  font?
    hfont = create_font(8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, VARIABLE_PITCH | FF_SWISS, "");

    if (hfont == NULL)
        goto Exit;

    hfonto = (HFONT)(select_object(hdc_memory, hbm_temp));

    if (!hfonto)
        goto Exit;

    select_object(hdc_memory, hfont);
    set_text_color(hdc_memory, 1);
    set_bk_color(hdc_memory, 0);
    set_bk_mode(hdc_memory, TRANSPARENT);

    b_rc = bit_blt(hdc_memory, rect.left, rect.top, rect.right, rect.bottom, hdc_memory, rect.left, rect.top, BLACKNESS);

    if (!b_rc)
        goto Exit;

    b_rc = ext_text_out(hdc_memory, 0, 0, ETO_CLIPPED, &rect, sz_formatted, strlen(sz_formatted), NULL);

    if (!b_rc)
        goto Exit;

    for (y = rect.top; y < rect.bottom; ++y)
    {
        for (x = rect.left; x < rect.right; ++x)
        {
            if (get_pixel(hdc_memory, x, rect.bottom - 1 - y))
                p_dest[x] = 255;
        }

        p_dest += n_stride;
    }

    rc = strlen(sz_formatted);

Exit:

    if (hbm_temp != NULL)
    {
        if (hbm_orig != NULL)
        {
            select_object(hdc_memory, hbm_orig);
        }

        delete_object(hbm_temp);
    }

    if (hfont != NULL)
    {
        if (hfonto != NULL)
            select_object(hdc_memory, hfonto);

        delete_object(hfont);
    }

    if (hdc_memory != NULL)
        delete_dc(hdc_memory);

    hdc_memory = 0;

#endif

    return rc;
}
Beispiel #14
0
Datei: Sinfo.c Projekt: AZed/cdo
void *Sinfo(void *argument)
{
  enum {func_generic, func_param, func_name, func_code};
  int operatorID;
  int operfunc, lensemble;
  int indf;
  int varID;
  int gridsize = 0;
  int gridID, zaxisID, code, tabnum, param;
  int vdate, vtime;
  int nvars, ntsteps;
  int levelsize;
  int tsteptype, taxisID;
  char tmpname[CDI_MAX_NAME];
  char varname[CDI_MAX_NAME];
  char paramstr[32];
  char vdatestr[32], vtimestr[32];
  const char *modelptr, *instptr;
  int streamID = 0;
  int vlistID;
  int datatype;
  char pstr[4];

  cdoInitialize(argument);

  cdoOperatorAdd("sinfo",   func_generic, 0, NULL);
  cdoOperatorAdd("sinfop",  func_param,   0, NULL);
  cdoOperatorAdd("sinfon",  func_name,    0, NULL);
  cdoOperatorAdd("sinfoc",  func_code,    0, NULL);
  cdoOperatorAdd("seinfo",  func_generic, 1, NULL);
  cdoOperatorAdd("seinfop", func_param,   1, NULL);
  cdoOperatorAdd("seinfon", func_name,    1, NULL);
  cdoOperatorAdd("seinfoc", func_code,    1, NULL);

  operatorID = cdoOperatorID();

  operfunc  = cdoOperatorF1(operatorID);
  lensemble = cdoOperatorF2(operatorID);

  for ( indf = 0; indf < cdoStreamCnt(); indf++ )
    {
      streamID = streamOpenRead(cdoStreamName(indf));

      vlistID = streamInqVlist(streamID);

      set_text_color(stdout, BRIGHT, BLACK);
      fprintf(stdout, "   File format");
      reset_text_color(stdout);
      fprintf(stdout, " : ");
      printFiletype(streamID, vlistID);

      set_text_color(stdout, BRIGHT, BLACK);
      if ( lensemble )
	fprintf(stdout, "%6d : Institut Source   Ttype    Einfo Levels Num    Points Num Dtype : ",  -(indf+1));
      else
	fprintf(stdout, "%6d : Institut Source   Ttype    Levels Num    Points Num Dtype : ",  -(indf+1));

      if      ( operfunc == func_name ) fprintf(stdout, "Parameter name");
      else if ( operfunc == func_code ) fprintf(stdout, "Table Code");
      else                              fprintf(stdout, "Parameter ID");

      if ( cdoVerbose ) fprintf(stdout, " : Extra" );              
      reset_text_color(stdout);
      fprintf(stdout, "\n" );              

      nvars = vlistNvars(vlistID);

      for ( varID = 0; varID < nvars; varID++ )
	{
	  param   = vlistInqVarParam(vlistID, varID);
	  code    = vlistInqVarCode(vlistID, varID);
	  tabnum  = tableInqNum(vlistInqVarTable(vlistID, varID));
	  gridID  = vlistInqVarGrid(vlistID, varID);
	  zaxisID = vlistInqVarZaxis(vlistID, varID);

	  set_text_color(stdout, BRIGHT, BLACK);
	  fprintf(stdout, "%6d", varID+1);
	  reset_text_color(stdout);
	  set_text_color(stdout, RESET, BLACK);
	  fprintf(stdout, " : ");
	  reset_text_color(stdout);
	      
	  set_text_color(stdout, RESET, BLUE);
	  /* institute info */
	  instptr = institutInqNamePtr(vlistInqVarInstitut(vlistID, varID));
	  strcpy(tmpname, "unknown");
	  if ( instptr ) strncpy(tmpname, instptr, CDI_MAX_NAME);
	  limit_string_length(tmpname, CDI_MAX_NAME);
	  fprintf(stdout, "%-8s ", tmpname);

	  /* source info */
	  modelptr = modelInqNamePtr(vlistInqVarModel(vlistID, varID));
	  strcpy(tmpname, "unknown");
	  if ( modelptr ) strncpy(tmpname, modelptr, CDI_MAX_NAME);
	  limit_string_length(tmpname, CDI_MAX_NAME);
	  fprintf(stdout, "%-8s ", tmpname);

	  /* tsteptype */
	  tsteptype = vlistInqVarTsteptype(vlistID, varID);
	  if      ( tsteptype == TSTEP_CONSTANT ) fprintf(stdout, "%-8s ", "constant");
	  else if ( tsteptype == TSTEP_INSTANT  ) fprintf(stdout, "%-8s ", "instant");
	  else if ( tsteptype == TSTEP_INSTANT2 ) fprintf(stdout, "%-8s ", "instant");
	  else if ( tsteptype == TSTEP_INSTANT3 ) fprintf(stdout, "%-8s ", "instant");
	  else if ( tsteptype == TSTEP_MIN      ) fprintf(stdout, "%-8s ", "min");
	  else if ( tsteptype == TSTEP_MAX      ) fprintf(stdout, "%-8s ", "max");
	  else if ( tsteptype == TSTEP_AVG      ) fprintf(stdout, "%-8s ", "avg");
	  else if ( tsteptype == TSTEP_ACCUM    ) fprintf(stdout, "%-8s ", "accum");
	  else if ( tsteptype == TSTEP_RANGE    ) fprintf(stdout, "%-8s ", "range");
	  else if ( tsteptype == TSTEP_DIFF     ) fprintf(stdout, "%-8s ", "diff");
	  else                                    fprintf(stdout, "%-8s ", "unknown");

	  /* ensemble information */
	  if ( lensemble )
	    {
	      int ensID, ensCount, forecast_type;
	      if ( vlistInqVarEnsemble(vlistID, varID, &ensID, &ensCount, &forecast_type) )
		fprintf(stdout, "%2d/%-2d ", ensID, ensCount);
	      else
		fprintf(stdout, "--/-- ");
	    }

	  /* layer info */
	  levelsize = zaxisInqSize(zaxisID);
	  fprintf(stdout, "%6d ", levelsize);
	  fprintf(stdout, "%3d ", vlistZaxisIndex(vlistID, zaxisID) + 1);

	  /* grid info */
	  gridsize = gridInqSize(gridID);
	  fprintf(stdout, "%9d ", gridsize);
	  fprintf(stdout, "%3d ", vlistGridIndex(vlistID, gridID) + 1);

	  /* datatype */
	  datatype = vlistInqVarDatatype(vlistID, varID);
	  datatype2str(datatype, pstr);

	  fprintf(stdout, " %-3s", pstr);

	  if ( vlistInqVarCompType(vlistID, varID) == COMPRESS_NONE )
	    fprintf(stdout, "  ");
	  else
	    fprintf(stdout, "z ");

	  reset_text_color(stdout);
	      
	  set_text_color(stdout, RESET, BLACK);
	  fprintf(stdout, ": ");
	  reset_text_color(stdout);

	  /* parameter info */
	  cdiParamToString(param, paramstr, sizeof(paramstr));

	  if ( operfunc == func_name ) vlistInqVarName(vlistID, varID, varname);

	  set_text_color(stdout, BRIGHT, GREEN);
	  if ( operfunc == func_name )
	    fprintf(stdout, "%-14s", varname);
	  else if ( operfunc == func_code )
	    fprintf(stdout, "%4d %4d   ", tabnum, code);
	  else
	    fprintf(stdout, "%-14s", paramstr);
	  reset_text_color(stdout);

	  if ( cdoVerbose )
	    {
	      char varextra[CDI_MAX_NAME];
	      vlistInqVarExtra(vlistID, varID, varextra);
	      fprintf(stdout, " : %s", varextra );              
	    }

	  fprintf(stdout, "\n");
	}

      set_text_color(stdout, BRIGHT, BLACK);
      fprintf(stdout, "   Grid coordinates");
      reset_text_color(stdout);
      fprintf(stdout, " :\n");

      printGridInfo(vlistID);

      set_text_color(stdout, BRIGHT, BLACK);
      fprintf(stdout, "   Vertical coordinates");
      reset_text_color(stdout);
      fprintf(stdout, " :\n");

      printZaxisInfo(vlistID);

      taxisID = vlistInqTaxis(vlistID);
      ntsteps = vlistNtsteps(vlistID);

      if ( ntsteps != 0 )
	{
	  set_text_color(stdout, BRIGHT, BLACK);
	  fprintf(stdout, "   Time coordinate");
	  reset_text_color(stdout);
	  if ( ntsteps == CDI_UNDEFID )
	    fprintf(stdout, " :  unlimited steps\n");
	  else
	    fprintf(stdout, " :  %d step%s\n", ntsteps, ntsteps == 1 ? "" : "s");

	  if ( taxisID != CDI_UNDEFID )
	    {
	      if ( taxisInqType(taxisID) != TAXIS_ABSOLUTE )
		{
		  vdate = taxisInqRdate(taxisID);
		  vtime = taxisInqRtime(taxisID);

		  date2str(vdate, vdatestr, sizeof(vdatestr));
		  time2str(vtime, vtimestr, sizeof(vtimestr));

		  fprintf(stdout, "     RefTime = %s %s", vdatestr, vtimestr);
		      
		  int tunits = taxisInqTunit(taxisID);
		  if ( tunits != CDI_UNDEFID )  fprintf(stdout, "  Units = %s", tunit2str(tunits));
	      
		  int calendar = taxisInqCalendar(taxisID);
		  if ( calendar != CDI_UNDEFID )  fprintf(stdout, "  Calendar = %s", calendar2str(calendar));

		  if ( taxisHasBounds(taxisID) )
		    fprintf(stdout, "  Bounds = true");

		  fprintf(stdout, "\n");

		  if ( taxisInqType(taxisID) == TAXIS_FORECAST )
		    {
		      vdate = taxisInqFdate(taxisID);
		      vtime = taxisInqFtime(taxisID);

		      date2str(vdate, vdatestr, sizeof(vdatestr));
		      time2str(vtime, vtimestr, sizeof(vtimestr));

		      fprintf(stdout, "     ForecastRefTime = %s %s", vdatestr, vtimestr);
		      fprintf(stdout, "\n");
		    }
		}
	    }

	  fprintf(stdout, "  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss\n");

	  set_text_color(stdout, RESET, MAGENTA);

	  printTimesteps(streamID, taxisID, cdoVerbose);

	  reset_text_color(stdout);
	  fprintf(stdout, "\n");
	}

      streamClose(streamID);
    }

  cdoFinish();

  return (0);
}
Beispiel #15
0
void
Canvas::run(uint8_t ix, const void_P* tab, uint8_t max)
{
    if (ix >= max) return;
    const uint8_t* ip = (const uint8_t*) pgm_read_word(tab + ix);
    uint8_t x, y, r, g, b, w, h, s;
    int8_t dx, dy;
    char c;
    while (1) {
        switch (pgm_read_byte(ip++)) {
        case END_SCRIPT:
            return;
        case CALL_SCRIPT:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            run(ix, tab, max);
            break;
        case SET_CANVAS_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_canvas_color(color(r, b, g));
            break;
        case SET_PEN_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_pen_color(color(r, g, b));
            break;
        case SET_TEXT_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_text_color(color(r, g, b));
            break;
        case SET_TEXT_SCALE:
            set_text_scale(pgm_read_byte(ip++));
            break;
        case SET_TEXT_FONT:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            set_text_font((Font*) pgm_read_word(tab + ix));
            break;
        case SET_CURSOR:
            x = pgm_read_byte(ip++);
            y = pgm_read_byte(ip++);
            set_cursor(x, y);
            break;
        case MOVE_CURSOR:
            dx = pgm_read_byte(ip++);
            dy = pgm_read_byte(ip++);
            move_cursor(dx, dy);
            break;
        case DRAW_BITMAP:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            s = pgm_read_byte(ip++);
            draw_bitmap((const uint8_t*) pgm_read_word(tab + ix), w, h, s);
            break;
        case DRAW_ICON:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_icon((const uint8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_PIXEL:
            draw_pixel();
            break;
        case DRAW_LINE:
            x = pgm_read_byte(ip++);
            y = pgm_read_byte(ip++);
            draw_line(x, y);
            break;
        case DRAW_POLY:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_poly_P((const int8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_STROKE:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_stroke_P((const int8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_RECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            draw_rect(w, h);
            break;
        case FILL_RECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            fill_rect(w, h);
            break;
        case DRAW_ROUNDRECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            r = pgm_read_byte(ip++);
            draw_roundrect(w, h, r);
            break;
        case FILL_ROUNDRECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            r = pgm_read_byte(ip++);
            fill_roundrect(w, h, r);
            break;
        case DRAW_CIRCLE:
            r = pgm_read_byte(ip++);
            draw_circle(r);
            break;
        case FILL_CIRCLE:
            r = pgm_read_byte(ip++);
            fill_circle(r);
            break;
        case DRAW_CHAR:
            c = pgm_read_byte(ip++);
            draw_char(c);
            break;
        case DRAW_STRING:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            draw_string_P((const char*) pgm_read_word(tab + ix));
            break;
        case FILL_SCREEN:
            fill_screen();
            break;
        default:
            return;
        }
    }
}
Beispiel #16
0
void Tooltip::set_text_color(const Vector4& color)
{
	set_text_color(color.x, color.y, color.z, color.w);
}