示例#1
0
文件: tty.c 项目: cosmos72/twin
/* WARNING: fwd_copy() doesn't call dirty_tty(), you must call it manually! */
static void fwd_copy(hwattr *s, hwattr *d, ldat len) {
    ldat l;
    
    while (s >= Split) s -= Split - Base;
    while (d >= Split) d -= Split - Base;
    
    while (len > 0) {
	l = Min2(len, Split - s); l = Min2(l, Split - d);
	MoveMem(s, d, l * sizeof(hwattr)); // s and d can overlap!
	s += l; d += l; len -= l;
	if (s == Split) s = Base;
	if (d == Split) d = Base;
    }
}
示例#2
0
void gpuDrawT(void)
{
	s32 xmin, xmax;
	s32 ymin, ymax;
	s32 x0, y0;
	s32 x1, y1;

	x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0];
  y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1];
  x1+= PacketBuffer.S2[4];
  y1+= PacketBuffer.S2[5];

	xmin = DrawingArea[0];	xmax = DrawingArea[2];
	ymin = DrawingArea[1];	ymax = DrawingArea[3];

  int rx0 = Max2(xmin,Min2(x0,x1));
  int ry0 = Max2(ymin,Min2(y0,y1));
  int rx1 = Min2(xmax,Max2(x0,x1));
  int ry1 = Min2(ymax,Max2(y0,y1));
  if(rx0>=rx1 || ry0>=ry1)
    return;

  //AddDirtyArea(rx0,ry0,rx1,ry1);
  if(isSkip) return;

	PixelData = GPU_RGB16(PacketBuffer.U4[0]);

	if (y0 < ymin)
		y0 = ymin;
	if (y1 > ymax)
		y1 = ymax;

	if (x0 < xmin)
		x0 = xmin;
	if (x1 > xmax)
		x1 = xmax;

  x1 -= x0;
	if (x1 < 0)
		x1 = 0;
	Pixel = &((u16*)GPU_FrameBuffer)[FRAME_OFFSET(x0, y0)];
	for (; y0<y1; ++y0)
  {
    PixelEnd = Pixel+x1; 
    if( 0 == (y0&linesInterlace) )
      gpuSpriteSpanDriver();
    Pixel += FRAME_WIDTH;
	}
}
示例#3
0
文件: tty.c 项目: cosmos72/twin
/* WARNING: rev_copy() doesn't call dirty_tty(), you must call it manually! */
static void rev_copy(hwattr *s, hwattr *d, ldat len) {
    ldat l;

    s += len; d += len;
    while (s > Split) s -= Split - Base;
    while (d > Split) d -= Split - Base;
    
    while (len > 0) {
	l = Min2(len, s - Base); l = Min2(l, d - Base);
	s -= l; d -= l; len -= l;
	MoveMem(s, d, l * sizeof(hwattr));
	if (s == Base) s = Split;
	if (d == Base) d = Split;
    }
}
示例#4
0
文件: hw_multi.c 项目: Mirppc/twin
static void warn_NoHW(TW_CONST byte *arg, uldat len) {
    printk("twin: all display drivers failed");
    if (arg)
        printk(" for `%.*s\'\n", Min2((int)len,TW_SMALLBUFF), arg);
    else
        printk(".\n");
}
示例#5
0
文件: hw_multi.c 项目: Mirppc/twin
display_hw AttachDisplayHW(uldat len, CONST byte *arg, uldat slot, byte flags) {
    display_hw D_HW = NULL;

    if ((len && len <= 4) || CmpMem("-hw=", arg, Min2(len,4))) {
	printk("twin: specified `%.*s\' is not a known option.\n"
               "      try `twin --help' for usage summary.\n",
	       Min2((int)len,TW_SMALLBUFF), arg);
	return D_HW;
    }
    
    if (All->ExclusiveHW) {
	printk("twin: exclusive display in use, permission to display denied!\n");
	return D_HW;
    }
    
    if (IsValidHW(len, arg) && (D_HW = Do(Create,DisplayHW)(FnDisplayHW, len, arg))) {
	D_HW->AttachSlot = slot;
	if (Act(Init,D_HW)(D_HW)) {
	    
	    if (flags & TW_ATTACH_HW_EXCLUSIVE) {
		/* started exclusive display, kill all others */
		display_hw s_HW, n_HW;
		
		All->ExclusiveHW = D_HW;
		
		for (s_HW = All->FirstDisplayHW; s_HW; s_HW = n_HW) {
		    n_HW = s_HW->Next;
		    if (s_HW != D_HW)
			Delete(s_HW);
		}
	    }

	    if (ResizeDisplay()) {
		QueuedDrawArea2FullScreen = TRUE;
	    }
	    return D_HW;
	}
	/* failed, clean up without calling RunNoHW() or KillSlot() */
	D_HW->Quitted = TRUE;
	D_HW->AttachSlot = NOSLOT;
	D_HW->QuitHW = NoOp;
	Delete(D_HW);
	D_HW = NULL;
    }
    return D_HW;
}
示例#6
0
文件: tty.c 项目: cosmos72/twin
/* WARNING: fill() doesn't call dirty_tty(), you must call it manually! */
static void fill(hwattr *s, hwattr c, ldat len) {
    ldat l;
    
    while (s >= Split) s -= Split - Base;

    while (len > 0) {
	l = Min2(len, Split - s);
	len -= l;
	while (l--)
	    *s++ = c;
	if (s == Split) s = Base;
    }
}
示例#7
0
文件: tty.c 项目: cosmos72/twin
/*
 * for better cleannes, dirty_tty()
 * should be used *before* actually touching Win->Contents[]
 */
static void dirty_tty(dat x1, dat y1, dat x2, dat y2) {
    byte i;
    ldat S[2] = {0, 0};
    dat xy[2][4];
    
    if (dirtyN == TW_MAXBYTE || x1 > x2 || x1 >= SizeX || y1 > y2 || y1 >= SizeY)
	return;

    x2 = Min2(x2, SizeX-1);
    y2 = Min2(y2, SizeY-1);

    for (i=0; i<dirtyN; i++) {
	xy[i][0] = Min2(dirty[i][0], x1);
	xy[i][1] = Min2(dirty[i][1], y1);
	xy[i][2] = Max2(dirty[i][2], x2);
	xy[i][3] = Max2(dirty[i][3], y2);
	S[i] += (xy[0][2] - xy[0][0] + 1) * (xy[0][3] - xy[0][1] + 1);
	S[!i] += dirtyS[i];
    }
    if (dirtyN < 2)
	S[dirtyN] += (x2-x1+1)*(y2-y1+1);
    
    i = dirtyN && S[0] > S[1];

    if (S[i] >= SizeX*SizeY*3/4) {
	dirtyN = TW_MAXBYTE;
	return;
    } else if (i < dirtyN) {
	CopyMem(xy[i], dirty[i], 4*sizeof(dat));
    } else {
	dirtyN++;
	dirty[i][0] = x1;
	dirty[i][1] = y1;
	dirty[i][2] = x2;
	dirty[i][3] = y2;
    }
    dirtyS[i] = (dirty[i][2]-dirty[i][0]+1)*(dirty[i][3]-dirty[i][1]+1);
}
/*
----------
  Read
  Чтение нескольких блоков
----------
*/
size_t MemoryReader::Read( void *dest, size_t length, size_t numBlocks )
{
  size_t realLen = Min2( length * numBlocks, this->curLength - this->curPos );
  size_t ret;
  if( realLen < length * numBlocks )
    ret = size_t( realLen / length );
  else
    ret = numBlocks;

  memcpy( dest, this->curData + this->curPos, realLen );
  this->curPos += realLen;

  return ret;
}//Read
示例#9
0
void gpuDrawScreen(void)
{
	if (GP1 & 0x00800000)
		return;

	static s16 old_res_horz, old_res_vert, old_rgb24;
	s16 h0, x0, y0, w0, h1;

	x0 = DisplayArea[0];
	y0 = DisplayArea[1];

	w0 = DisplayArea[2];
	h0 = DisplayArea[3];  // video mode

	h1 = DisplayArea[7] - DisplayArea[5]; // display needed
	if (h0 == 480)
		h1 = Min2(h1*2,480);

#ifdef ZAURUS
	if(SDL_MUSTLOCK(gp2x_sdlwrapper_screen)) SDL_LockSurface(gp2x_sdlwrapper_screen);
#endif

	u16* dest_screen16 = gp2x_screen16;
	u16* src_screen16  = &((u16*)FrameBuffer)[FRAME_OFFSET(x0,y0)];
	u32 isRGB24 = (GP1 & 0x00200000 ? 32 : 0);
	/* Clear the screen if resolution changed to prevent interlacing and clipping to clash */
	if( (w0 != old_res_horz || h1 != old_res_vert || (s16)isRGB24 != old_rgb24) )
	{
		// Update old resolution
		old_res_horz = w0;
		old_res_vert = h1;
		old_rgb24 = (s16)isRGB24;
		// Finally, clear the screen for this special case
		gp2x_video_RGB_clearscreen16();
	}

	//  Height centering
  int sizeShift = 1;
  if(h0==256)
    h0 = 240;
  else
  if(h0==480)
    sizeShift = 2;

  if(h1>h0)
  {
		src_screen16  += ((h1-h0)>>sizeShift)*1024;
    h1 = h0;
  }
示例#10
0
文件: tty.c 项目: cosmos72/twin
static void csi_X(int vpar) /* erase the following vpar positions */
{					  /* not vt100? */
    hwattr *start = Pos;
    
    if (!vpar)
	vpar++;
    vpar = Min2(vpar, SizeX - X);
    
    dirty_tty(X, Y, X+vpar-1, Y);
    
    while (vpar--)
	*start++ = HWATTR(ColText, ' ');
    
    *Flags &= ~TTY_NEEDWRAP;
}
示例#11
0
文件: hw_tty.c 项目: Mirppc/twin
static void stdin_CheckResize(dat *x, dat *y) {
    *x = Min2(*x, HW->X);
    *y = Min2(*y, HW->Y);
}
示例#12
0
void Reassign_Weight() {
  int i,j;
  int is,id;
  double sumprob,maxprob,minprob;

  for (i=1;i<(nbin+1);i++) {
    if (tmpnpar[i]!=0) {
      sumprob=0;
      for (j=1;j<(tmpnpar[i]+1);j++) {
        sumprob+=tmppar[i][j].prob;
      }
      if (sumprob!=0) {
        maxprob=sumprob/npar[i]*sqrt(mmratio);
        minprob=sumprob/npar[i]/sqrt(mmratio);
        Min1(i);
        while (tmppar[i][tmpnpar[i]].prob<minprob) {
          Min2(i);
          COMB(i);
          Min1(i);
        }
        Max(i);
        while (tmppar[i][1].prob>maxprob) {
          SPLIT(i);
          Max(i);
        }
        while (tmpnpar[i]>npar[i]) {
          Min1(i);
          Min2(i);
          COMB(i);
        }
        while (tmpnpar[i]<npar[i]) {
          Max(i);
          SPLIT(i);
        }
        for (j=1;j<(npar[i]+1);j++) {
          par[i][j].prob=tmppar[i][j].prob;
          par[i][j].coord=tmppar[i][j].coord;
          par[i][j].numb=tmppar[i][j].numb;
          par[i][j].tb0=tmppar[i][j].tb0;
          par[i][j].distA=tmppar[i][j].distA;
          par[i][j].distB=tmppar[i][j].distB;
        }
      }
    }
    else {
      for (j=1;j<(npar[i]+1);j++) {
        if (Fava[0]!=0) {
          par[i][j].numb=Fava[Fava[0]];
          Fava[0]-=1;
        }
        else {
          Fexc[0].i+=1;
          Fexc[0].j+=1;
          Fexc[Fexc[0].i].i=i;
          Fexc[Fexc[0].i].j=j;
          par[i][j].numb=Fexc[0].i+nallpar;
        }
       }
      Make_Ghost(i);
    }
  }

  while(Fexc[0].i!=0) {
    if (Fexc[0].i!=Fava[0]) {
      printf("Fava=%d\tFexc=%d!\n",Fava[0],Fexc[0].i);
      for (j=1;j<(Fava[0]+1);j++) {
        printf("Fava[%d]=%d\n",j,Fava[j]);
      }
      printf("Something is wrong!\n");
      exit(1);
    }
    is=Fexc[0].i;
    id=Fava[is];
    par[Fexc[is].i][Fexc[is].j].numb=id;
    is+=nallpar;
    free(rx_states[id-1]);
    rx_states[id-1]=(int *)malloc(nspecies*sizeof(int));
    memcpy(rx_states[id-1],rx_states[is-1],nspecies*sizeof(int));
    free(rx_states[is-1]);
    rx_states[is-1]=(int *)malloc(nspecies*sizeof(int));

    Fexc[0].i-=1;
    Fexc[0].j-=1;
    Fava[0]-=1;
  }
  return;
}
示例#13
0
文件: common.c 项目: cosmos72/twin
static byte X11_InitHW(void) {
    char *arg = HW->Name;
    int xscreen;
    unsigned int xdepth;
    XSetWindowAttributes xattr;
    XColor xcolor;
    XSizeHints *xhints;
    XEvent event;
    Visual *xvisual;
    Colormap colormap;
    byte *s, *xdisplay_ = NULL, *xdisplay0 = NULL,
        *fontname = NULL, *fontname0 = NULL,
        *charset = NULL, *charset0 = NULL,
        title[X11_TITLE_MAXLEN];
    int i, nskip;
    udat fontwidth = 8, fontheight = 16;
    byte drag = tfalse, noinput = tfalse;
    unsigned long xcreategc_mask = GCForeground|GCBackground|GCGraphicsExposures;
    
    if (!(HW->Private = (struct x11_data *)AllocMem(sizeof(struct x11_data)))) {
	printk("      X11_InitHW(): Out of memory!\n");
	return tfalse;
    }
    WriteMem(HW->Private, 0, sizeof(struct x11_data));

    /* default: show the whole screen */
    xhw_view = xhw_startx = xhw_starty = xhw_endx = xhw_endy = 0;

    /* not yet opened */
    xdisplay = NULL;
    
    if (arg && *arg && ((nskip = check_hw_name(arg)) > 0)) {
        arg += nskip;

	if (*arg == '@') {
	    if ((s = strchr(xdisplay_ = ++arg, ','))) {
		*(xdisplay0 = s) = '\0';
		arg = s + 1;
	    } else
		arg = NULL;
	}

	while (arg && *arg) {
	    /* parse options */
	    if (*arg == ',') {
		arg++;
		continue;
	    }
	    if (!strncmp(arg, "font=", 5)) {
		fontname = arg += 5;
		s = strchr(arg, ',');
		if (s) *(fontname0 = s++) = '\0';
		arg = s;
            } else if (!strncmp(arg, "fontsize=", 9)) {
                int n1 = atoi(arg += 9), n2 = 0;
                byte ch;
                if (n1 > 0) {
                    while ((ch = (byte)*++arg) && ch != ',') {
                        if (ch == 'x') {
                            n2 = atoi(arg+1);
                            break;
                        }
                    }
                    fontwidth  = Min2(TW_MAXUDAT, n2 > 0 ? n1 : n1 / 2);
                    fontheight = Min2(TW_MAXUDAT, n2 > 0 ? n2 : n1);
                }
	    } else if (!strncmp(arg, "charset=", 8)) {
		charset = arg += 8;
		s = strchr(arg, ',');
		if (s) *(charset0 = s++) = '\0';
		arg = s;
	    } else if (!strncmp(arg, "view=", 5)) {
		xhw_view = 1;
		xhw_endx = strtol(arg+5, &arg, 0);
		xhw_endy = strtol(arg+1, &arg, 0);
		xhw_startx = strtol(arg+1, &arg, 0);
		xhw_starty = strtol(arg+1, &arg, 0);
		xhw_endx += xhw_startx;
		xhw_endy += xhw_starty;
	    } else if (!strncmp(arg, "drag", 4)) {
		arg += 4;
		drag = ttrue;
	    } else if (!strncmp(arg, "noinput", 7)) {
		arg += 7;
		noinput = ttrue;
	    } else
		arg = strchr(arg, ',');
	}
    }

    xsfont = NULL; xhints = NULL;
    xwindow = None; xgc = None;
    xReqCount = XReqCount = 0;
    HW->keyboard_slot = NOSLOT;
    
    if ((xdisplay = XOpenDisplay(xdisplay_))) do {
	
	(void)XSetIOErrorHandler(X11_Die);

	if (!X11_CheckRemapKeys())
	    break;

	xscreen = DefaultScreen(xdisplay);
	xdepth  = DefaultDepth(xdisplay, xscreen);
        xvisual = DefaultVisual(xdisplay, xscreen);
        colormap = DefaultColormap(xdisplay, xscreen);
	
	for (i = 0; i <= MAXCOL; i++) {
	    xcolor.red   = 257 * (udat)Palette[i].Red;
	    xcolor.green = 257 * (udat)Palette[i].Green;
	    xcolor.blue  = 257 * (udat)Palette[i].Blue;
            if (!X11_AllocColor(xdisplay, xvisual, colormap, &xcolor, &xcol[i], i)) {
                printk("      X11_InitHW() failed to allocate colors\n");
                break;
            }
	}
	if (i <= MAXCOL)
	    break;
	
	xattr.background_pixel = xcol[0];
	xattr.event_mask = ExposureMask | VisibilityChangeMask |
	    StructureNotifyMask | SubstructureNotifyMask |
	    KeyPressMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask;

	if (!X11_LoadFont(fontname, fontwidth, fontheight))
	    break;
	
	if (xhw_view && xhw_startx >= 0 && xhw_starty >= 0 && xhw_endx > xhw_startx && xhw_endy > xhw_starty) {
	    /* a valid view was specified */
	    
	    xwidth  = xwfont * (ldat)(xhw_endx - xhw_startx);
	    xheight = xhfont * (ldat)(xhw_endy - xhw_starty);
	} else {
	    xhw_view = xhw_startx = xhw_starty = 0;
	    xhw_endx = HW->X;
	    xhw_endy = HW->Y;
	}
	
	if ((xwindow = XCreateWindow(xdisplay, DefaultRootWindow(xdisplay), 0, 0,
				     xwidth, xheight, 0, xdepth, InputOutput,
				     xvisual, CWBackPixel | CWEventMask, &xattr)) &&

	    (xsgc.foreground = xsgc.background = xcol[0],
	     xsgc.graphics_exposures = False,
#if HW_X_DRIVER == HW_X11
	     xsgc.font = xsfont->fid,
             xcreategc_mask = xcreategc_mask|GCFont,
#elif HW_X_DRIVER == HW_XFT
             xforeground = xbackground = xftcolors[0],
#endif
	     xgc = XCreateGC(xdisplay, xwindow, xcreategc_mask, &xsgc)) &&

	    (xhints = XAllocSizeHints()))
        {
	    
            static XComposeStatus static_xcompose;
            xcompose = static_xcompose;

#if HW_X_DRIVER == HW_XFT
            xftdraw = XftDrawCreate(xdisplay,xwindow,xvisual,colormap);
#endif

#ifdef TW_FEATURE_X11_XIM_XIC
            xim = XOpenIM(xdisplay, NULL, NULL, NULL);
            if (xim != NULL) {
                xic = XCreateIC(xim, XNInputStyle, XIMStatusNothing|XIMPreeditNothing,
                                XNClientWindow, xwindow, XNFocusWindow, xwindow, NULL);
                if (xic == NULL) {
                    XCloseIM(xim);
                    xim = NULL;
                }
            } else
                xic = NULL;
#endif
            X11_FillWindowTitle(title, sizeof(title));
	    XStoreName(xdisplay, xwindow, title);


	    if (!(xUTF_32_to_charset = X11_UTF_32_to_charset_function(charset)))
		xUTF_32_to_charset = X11_UTF_32_to_UCS_2;
	    /*
	     * ask ICCCM-compliant window manager to tell us when close window
	     * has been chosen, rather than just killing us
	     */
	    xWM_PROTOCOLS = XInternAtom(xdisplay, "WM_PROTOCOLS", False);
	    xWM_DELETE_WINDOW = XInternAtom(xdisplay, "WM_DELETE_WINDOW", False);
	    xTARGETS = XInternAtom(xdisplay, "TARGETS", False);

	    XChangeProperty(xdisplay, xwindow, xWM_PROTOCOLS, XA_ATOM, 32, PropModeReplace,
			    (unsigned char *) &xWM_DELETE_WINDOW, 1);

	    if (xhw_view) {
		xhints->flags = PMinSize|PMaxSize;
		xhints->min_width = xhints->max_width = xwidth;
		xhints->min_height = xhints->max_height = xheight;
	    } else {
		xhints->flags = PResizeInc;
		xhints->width_inc  = xwfont;
		xhints->height_inc = xhfont;
	    }
	    XSetWMNormalHints(xdisplay, xwindow, xhints);
	    
	    XMapWindow(xdisplay, xwindow);
	    
	    do {
		XNextEvent(xdisplay, &event);
	    } while (event.type != MapNotify);
	    
	    XFree(xhints); xhints = NULL;
	    
	    HW->mouse_slot = NOSLOT;
	    HW->keyboard_slot = RegisterRemote(i = XConnectionNumber(xdisplay), (obj)HW,
					       X11_KeyboardEvent);
	    if (HW->keyboard_slot == NOSLOT)
		break;
	    fcntl(i, F_SETFD, FD_CLOEXEC);
	    
	    HW->FlushVideo = X11_FlushVideo;
	    HW->FlushHW = X11_FlushHW;
	    
	    HW->KeyboardEvent = X11_KeyboardEvent;
	    HW->MouseEvent = (void *)NoOp; /* mouse events handled by X11_KeyboardEvent */
	    
	    HW->XY[0] = HW->XY[1] = 0;
	    HW->TT = NOCURSOR;
	    
	    HW->ShowMouse = NoOp;
	    HW->HideMouse = NoOp;
	    HW->UpdateMouseAndCursor = NoOp;
	    HW->MouseState.x = HW->MouseState.y = HW->MouseState.keys = 0;
	    
	    HW->DetectSize  = X11_DetectSize;
	    HW->CheckResize = X11_CheckResize;
	    HW->Resize      = X11_Resize;
	    
	    HW->HWSelectionImport  = X11_SelectionImport_X11;
	    HW->HWSelectionExport  = X11_SelectionExport_X11;
	    HW->HWSelectionRequest = X11_SelectionRequest_X11;
	    HW->HWSelectionNotify  = X11_SelectionNotify_X11;
	    HW->HWSelectionPrivate = 0;
	    
	    if (drag) {
		HW->CanDragArea = X11_CanDragArea;
		HW->DragArea    = X11_DragArea;
	    } else
		HW->CanDragArea = NULL;
	    
	    HW->Beep = X11_Beep;
	    HW->Configure = X11_Configure;
	    HW->SetPalette = (void *)NoOp;
	    HW->ResetPalette = NoOp;
	    
	    HW->QuitHW = X11_QuitHW;
	    HW->QuitKeyboard  = NoOp;
	    HW->QuitMouse = NoOp;
	    HW->QuitVideo = NoOp;
	    
	    HW->DisplayIsCTTY = tfalse;
	    HW->FlagsHW &= ~FlHWSoftMouse; /* mouse pointer handled by X11 server */
	    
	    HW->FlagsHW |= FlHWNeedOldVideo;
	    HW->FlagsHW |= FlHWExpensiveFlushVideo;
	    if (noinput)
		HW->FlagsHW |= FlHWNoInput;
	    
	    HW->NeedHW = 0;
	    HW->CanResize = ttrue;
	    HW->merge_Threshold = 0;
	    
	    /*
	     * we must draw everything on our new shiny window
	     * without forcing all other displays
	     * to redraw everything too.
	     */
	    HW->RedrawVideo = tfalse;
	    NeedRedrawVideo(0, 0, HW->X - 1, HW->Y - 1);
	    
	    if (xdisplay0) *xdisplay0 = ',';
	    if (fontname0) *fontname0 = ',';
	    if (charset0) *charset0 = ',';
	    
	    return ttrue;
	}
    } while (0); else {
	if (xdisplay_ || (xdisplay_ = getenv("DISPLAY")))
	    printk("      X11_InitHW() failed to open display %."STR(TW_SMALLBUFF)"s\n", HW->Name);
	else
	    printk("      X11_InitHW() failed: DISPLAY is not set\n");
    }

fail:
    if (xdisplay0) *xdisplay0 = ',';
    if (fontname0) *fontname0 = ',';
    if (charset0) *charset0 = ',';
	
    if (xdisplay)
	X11_QuitHW();

    FreeMem(HW->Private);
    HW->Private = NULL;
    
    return tfalse;
}
float Min3(float in1,float in2,float in3){
	return Min2(in3,Min2(in1,in2));
}
示例#15
0
文件: hw_multi.c 项目: Mirppc/twin
static byte IsValidHW(uldat len, CONST byte *arg) {
    uldat i;
    byte b;
    if (len >= 4 && !CmpMem(arg, "-hw=", 4))
        arg += 4, len -=4;

    for (i = 0; i < len; i++) {
        b = arg[i];
        if (b == '@' || b == ',')
            /* the rest are options - validated by each display HW */
            break;
        if ((b < '0' || b > '9') && (b < 'A' || b > 'Z') && (b < 'a' || b > 'z') && b != '_') {
            printk("twin: invalid non-alphanumeric character `%c' in display HW name `%.*s'\n", (int)b, Min2((int)len,TW_SMALLBUFF), arg);
            return FALSE;
        }
    }
    return TRUE;
}
示例#16
0
void gpuDrawS(void)
{
	s32 temp;
	s32 xmin, xmax;
	s32 ymin, ymax;
	s32 x0, x1;
	s32 y0, y1;
	s32 u0;
	s32 v0;

	x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0];
  y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1];
  x1+= PacketBuffer.S2[6];
  y1+= PacketBuffer.S2[7];

	xmin = DrawingArea[0];	xmax = DrawingArea[2];
	ymin = DrawingArea[1];	ymax = DrawingArea[3];

	//TODO: Symbian minmax
	
  int rx0 = Max2(xmin,Min2(x0,x1));
  int ry0 = Max2(ymin,Min2(y0,y1));
  int rx1 = Min2(xmax,Max2(x0,x1));
  int ry1 = Min2(ymax,Max2(y0,y1));
  if( rx0>=rx1 || ry0>=ry1)
    return;

  //AddDirtyArea(rx0,ry0,rx1,ry1);
  if(isSkip) return;

  u0 = PacketBuffer.U1[8];
  v0 = PacketBuffer.U1[9];

  r4 = s32(PacketBuffer.U1[0]);
  g4 = s32(PacketBuffer.U1[1]);
  b4 = s32(PacketBuffer.U1[2]);

	temp = ymin - y0;
	if (temp > 0) {
		y0 = ymin;
		v0 += temp;
	}
	if (y1 > ymax)
		y1 = ymax;

	temp = xmin - x0;
	if (temp > 0) {
		x0 = xmin;
		u0 += temp;
	}
	if (x1 > xmax)
		x1 = xmax;
  x1 -= x0;
	if (x1 < 0)
		x1 = 0;
	
	Pixel = &((u16*)GPU_FrameBuffer)[FRAME_OFFSET(x0, y0)];
  v4    = v0;
	for (;y0<y1;++y0)
  {
    u4  = u0;
    PixelEnd = Pixel+x1; 
    if( 0 == (y0&linesInterlace) )
      gpuSpriteSpanDriver();
    Pixel += FRAME_WIDTH;
  	v4 = (++v4)&MaskV;
	}

}