예제 #1
0
파일: MacGraph.c 프로젝트: rolk/ug
static void MacintoshDrawText (const char *s, INT mode)
{
  Str255 pstr;

  switch(mode)
  {
  case TEXT_REGULAR : TextMode(srcOr); break;
  case TEXT_INVERSE : TextMode(srcXor); break;
  default : return;
  }
  CopyCStringToPascal(s,pstr);
  DrawString(pstr);
  TextMode(srcOr);
}
예제 #2
0
/////////////////////////////////////////////////////////////
//
// DrawString
//
void
nsPluginInstance::DrawString(const unsigned char* text, 
                             short width, 
                             short height, 
                             short centerX, 
                             Rect drawRect)
{
	short length, textHeight, textWidth;
 
	if(text == NULL)
		return;
	
	length = strlen((char*)text);
	TextFont(1);
	TextFace(bold);
	TextMode(srcCopy);
	TextSize(12);
	
	FontInfo fontInfo;
	GetFontInfo(&fontInfo);

	textHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
	textWidth = TextWidth(text, 0, length);
		
	if (width > textWidth && height > textHeight)
	{
		MoveTo(centerX - (textWidth >> 1), height >> 1);
		DrawText(text, 0, length);
	}		
예제 #3
0
파일: mprinter.cpp 프로젝트: PNCG/neuron
// for scaling text
void MacPrinterCanvas::flush()
{
	// ---- check if there is anything to do ----
	//int nchars = (int) (text_ptr_ - text_buff_);
	//if ((nchars == 0) || (lg_font_ == nil))
	//	return;
		
	// ---- render the text ----
	if (text_item_.count > 0) {
		//set font
		FontRep* fr = lg_font_->rep(nil);
		TextFont(fr->font_);
		TextFace(fr->face_);
		float a00, a01, a10, a11, a20, a21;
		transformer().matrix(a00, a01, a10, a11, a20, a21);
		int size = int(double(fr->size_)*sqrt(a00*a00 + a01*a01) +.01);
		TextSize(size);
		TextMode(fr->mode_);
//if (printing) debugfile("flush %d %d\n",toPixelX(text_item_.x), toPixelY(text_item_.y)); 		
        MoveTo(toPixelX(text_item_.x), toPixelY(text_item_.y));
        DrawText(text_item_.buffer, 0, text_item_.count);
// text_item_.buffer[text_item_.count] = '\0';
// debugfile("|%s|\n", text_item_.buffer);
    }
    text_item_.count = 0;	
	
	return;
}
예제 #4
0
void drawBackground()
{
	Rect		rect;
	RGBColor	color;
	Rect		tempRect1;
	
	color.red = color.green = color.blue = 8700;
	
	RGBForeColor( &color );
	PaintRect( GetPortBounds(GetWindowPort(gWindow), &tempRect1));
	
	TextFont( kFontIDTimes );
	TextMode( srcOr );
	TextSize( 24 );
	
	drawName( 85, 22, "\pSource Image" );
	drawName( GetPortBounds(GetWindowPort(gWindow), &tempRect1)->right - 215, 22, "\pNew Image" );
	
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	SetRect( &rect, 15, tempRect1.bottom - 180, tempRect1.right - 15, tempRect1.bottom - 30);
	drawDeepBox( &rect );
	
	TextSize( 12 );
	
	drawName( tItem[0].rect.left, tItem[0].rect.top - 8, "\pTransfer Mode" );
	drawName( aItem[0].rect.left, aItem[0].rect.top - 8, "\pArithmetic Mode" );
	drawName( cItem[0].rect.left, cItem[0].rect.top - 8, "\pColorization" );
	drawName( dItem[0].rect.left, dItem[0].rect.top - 8, "\pDither" );
	drawName( mItem[0].rect.left, mItem[0].rect.top - 8, "\pColor Mapping" );
	drawName( bItem[0].rect.left, bItem[0].rect.top - 8, "\pDestination" );
	drawName( pItem[0].rect.left, pItem[0].rect.top - 8, "\pPaint Bucket" );
	drawName( lItem[0].rect.left, lItem[0].rect.top - 8, "\pLasso Tool" );
}
예제 #5
0
파일: MacGraph.c 프로젝트: rolk/ug
static void MacCenteredText (SHORT_POINT point, const char *s, INT mode)
{
  short ts,w;
  Str255 pstr;

  ts = currgw->textSize;

  switch(mode)
  {
  case TEXT_REGULAR : TextMode(srcOr); break;
  case TEXT_INVERSE : TextMode(srcXor); break;
  default : return;
  }
  CopyCStringToPascal(s,pstr);
  w = StringWidth(pstr);
  MoveTo(point.x-w/2,point.y+ts/2);
  DrawString(pstr);
  TextMode(srcOr);
}
예제 #6
0
void main(void)
  {
  register int  j;
  char          name[31];            // user name
  char          num[12];             // serial number string for f f
  char          cnum[12];            // check sum string for fake file
  FILE          *fp;
  char          done=0;

  clrbox(0,1,79,23,1);
  drawbox (27,5,51,7,1,2,8);
  writestr(29,6,2,"GM "GMVER" Registration");
  name[0]=0; num[0]=0; cnum[0]=0;
  if ((!qwindow(5,14,30,"Enter your name (Exactly as on card): ",name))||(name[0]==0))
    {
    errorbox("ABORTING REGISTRATION","(O)k");
    done = 1;
    }
  else                          // zero the rest of the name.
    {
    j=0;                                
    while (name[j]!=0) j++;
    while (j<30) { name[j]=0; j++; }
    name[29]=0;
    }

  if (!done)
    {
    unsigned long int temp=GetMoreData();
    if (temp==0)
      {
      errorbox("Please run this program from","your GameMaker directory.");
      done=TRUE;
      }
    sprintf(num,"%lu",temp);
    }
  if (!done)
    {
    if ((!qwindow(13,14,12,"Enter registration number from card: ",cnum))||(cnum[0] == 0))
      {
      errorbox("ABORTING REGISTRATION","(O)k");
      done = 1;
      }
    }
  if (!done)
    {
    fp=fopen("playgame.reg","wt");
    fprintf(fp,"%s\n%s\n%s\n",name,num,cnum);
    fclose(fp);
//    errorbox("REGISTRATION   COMPLETE","Hit any key to start GM");
    TextMode();
    printf("Registration Finished\n");
    }
  }
예제 #7
0
void RestoreQDDrawingState( QDDrawingState *inDrawingState, const Boolean inDisposeNow )
{//	PixPatHandle	tempPixPat;

#if !(ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM )
	#pragma unused( inDisposeNow )	// Eliminate compiler warnings in 68K targets because PixPatHandle stuff is screwed up!
#endif

	Assert( inDrawingState != nil );

	// Restore the pen/foreground state.
/*	if ( !inDisposeNow && inDrawingState->penPixPatH != nil ) {
		// Make a copy of the penPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->penPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	PenPixPat( inDrawingState->penPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBForeColor( &inDrawingState->foreColor );
	SetPenState( &inDrawingState->penState );

	// Restore the background state.
/*	if ( !inDisposeNow && inDrawingState->backPixPatH != nil ) {
		// Make a copy of the backPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->backPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	BackPixPat( inDrawingState->backPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBBackColor( &inDrawingState->backColor );

	// Optionally restore the text state.
	if ( inDrawingState->haveTextState ) {
		TextFont( inDrawingState->textStyle.tsFont );
		TextFace( inDrawingState->textStyle.tsFace );
		TextSize( inDrawingState->textStyle.tsSize );
		TextMode( inDrawingState->textMode );
	}

#if ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM
	// If we're running under CFM and have Appearance Mgr 1.1 or later, use the ThemeDrawingState routines.
	if ( inDrawingState->haveThemeState ) {
		SetThemeDrawingState( inDrawingState->themeState, inDisposeNow );
		if ( inDisposeNow )
			inDrawingState->themeState = nil;
	}
#endif
}
예제 #8
0
void Error (char *error, ...)
{
	va_list argptr;

#if !defined(UNIX) && !defined(RISCOS) && !defined(MSDOS)
	if ( *(byte *)0x449 == 0x13)
		TextMode ();
#endif

	va_start (argptr,error);
	vprintf (error,argptr);
	va_end (argptr);
	printf ("\n");
	exit (1);
}
예제 #9
0
void mac_ctl_reset_trc()
{
	int i;
	
    for(i = 0; i < MAX_CHANNELS; i++)
    {
		instr_comment[i].last_note_on = 0.0;
		instr_comment[i].comm =""; // channel_instrum_name(i);
		clear_bitset(channel_program_flags + i, 0, 128);
    }
	SetPortWindowPort(win.ref);
	TextMode(srcCopy);
	TextSize(9);
	mac_ctl_refresh_trc();
	current_voices=0;
}
예제 #10
0
파일: fb.c 프로젝트: shanewfx/vlc-arib
static void TtyExit(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;

    /* Reset the terminal */
    ioctl(sys->tty, VT_SETMODE, &sys->vt_mode);

    /* Remove signal handlers */
    sigaction(SIGUSR1, &sys->sig_usr1, NULL);
    sigaction(SIGUSR2, &sys->sig_usr2, NULL);

    /* Reset the keyboard state */
    tcsetattr(0, 0, &sys->old_termios);

    /* Return to text mode */
    TextMode(sys->tty);
}
예제 #11
0
void dev_draw_text_gmode(PixMapHandle pixmap, int x, int y, const char* s, int len,
		int pmask, int mode, int fgcolor, int bgcolor, int ton_mode)
{			//pixmap must be already locked
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	int		color, trans, width;
	Rect		rect= {0,0,16,32},
			destrect;
	
	GetGWorld(&oldGW, &oldGD);
	LockPixels(charbufWorld->portPixMap);
	SetGWorld(charbufWorld,0);
		trans=0;
		if( fgcolor==trans ) trans++;
		if( bgcolor==trans ) trans++;
		if( fgcolor==trans ) trans++;
		
		color= ( (mode&2)? bgcolor:trans );
		dev_box(charbufWorld->portPixMap, rect, color, 0xFF);
		
		color= ( (mode&1)? fgcolor:trans );
		charbufWorld->fgColor= color;
		TextMode(srcOr);
		MoveTo(0,13);
		DrawText(s,0,len);
		if( ton_mode==2 ){
			expand_horizontality(charbufWorld->portPixMap, len*8, 16);
		}
		
		width= len*8;
		if( ton_mode==2 ) width*=2;
		
		rect.right=width;
		destrect.left=x; destrect.top=y;
		destrect.right=x+width; destrect.bottom=destrect.top+16;
		
		MyCopyBits(charbufWorld->portPixMap, pixmap,
			rect, destrect, 0x11/*trans*/, trans, pmask,
			0, 0, NULL);
		
		
	SetGWorld(oldGW, oldGD);
	UnlockPixels(charbufWorld->portPixMap);
}
예제 #12
0
PRBool
SimplePluginInstance::StartDraw(nsPluginWindow* window)
{
    NP_Port* port;
    Rect clipRect;
    RGBColor  col;
	
    if (window == NULL)
        return FALSE;
    port = (NP_Port*) window->window;
    if (window->clipRect.left < window->clipRect.right)
    {
	/* Preserve the old port */
        GetPort((GrafPtr*)&gOldPort);
        SetPort((GrafPtr)port->port);
	/* Preserve the old drawing environment */
        gSavePort.portRect = port->port->portRect;
        gSavePort.txFont = port->port->txFont;
        gSavePort.txFace = port->port->txFace;
        gSavePort.txMode = port->port->txMode;
        gSavePort.rgbFgColor = port->port->rgbFgColor;
        gSavePort.rgbBkColor = port->port->rgbBkColor;
        GetClip(gSavePort.clipRgn);
	/* Setup our drawing environment */
        clipRect.top = window->clipRect.top + port->porty;
        clipRect.left = window->clipRect.left + port->portx;
        clipRect.bottom = window->clipRect.bottom + port->porty;
        clipRect.right = window->clipRect.right + port->portx;
        SetOrigin(port->portx,port->porty);
        ClipRect(&clipRect);
        clipRect.top = clipRect.left = 0;
        TextSize(12);
        TextFont(geneva);
        TextMode(srcCopy);
        col.red = col.green = col.blue = 0;
        RGBForeColor(&col);
        col.red = col.green = col.blue = 65000;
        RGBBackColor(&col);
        return TRUE;
    }
    else
        return FALSE;
}
예제 #13
0
void _HYPlatformGraphicPane::_StartDraw	 (void)
{	
	_HYGraphicPane * parent = (_HYGraphicPane*)this;
	GetGWorld (&savedPort,&savedDevice);
	::GetForeColor (&saveFG);
	::GetBackColor (&saveBG);
	SetGWorld (thePane,nil);
	LockPixels (GetGWorldPixMap(thePane));
	RGBColor c  = {256*parent->bColor.R,256*parent->bColor.G,256*parent->bColor.B};
	if (parent->bColor.R+parent->bColor.B+(long)parent->bColor.G==765)
		c = (RGBColor){0xffff,0xffff,0xffff};
	RGBBackColor (&c);
	c = (RGBColor){256*parent->color.R,256*parent->color.G,256*parent->color.B};
	RGBForeColor (&c);
	//if (parent->depth>1)
		TextMode 	 (srcOr);
	//else
		//TextMode 	 (srcCopy);
}
예제 #14
0
void main(int argc,char *argv[])
  {
  FLI* f[20];
  FLIHeader *Head;

  int          ModeNum=4;
  char         Driver[51]="stlth64.drv";
  VideoDriver *Drvr;
  int FliCount=0;

  f[0] = new FLI;
  if (f[0]==NULL) { printf("NO memory!\n"); return; }
  printf("ARGC %d",argc);
  for (int i=1;i<argc;i++)
    {
    printf("File: %s\n",argv[i]);
    if (!f[FliCount]->File.Open(argv[i])) { printf("Cannot open %s.\n",argv[1]); }
    else
      {
      f[FliCount]->Pos.x=(FliCount%3)*340;
      f[FliCount]->Pos.y=(FliCount/3)*220;

      FliCount++;
      f[FliCount]=new FLI;
      if (f[FliCount]==NULL) break;
      }
    }
  delete f[FliCount];

  if ((Drvr=LoadVideoDriver(Driver))==NULL) { printf("Error Loading Driver.\n"); return; }


  for (i=0;i<FliCount;i++)
    {
    f[i]->Vid=Drvr->GetMode(ModeNum);
    f[i]->StepInit();
    }
  f[0]->Vid->SetMode(f[0]->Vid);

  while (!bioskey(1)) for (i=0;i<FliCount;i++) f[i]->Step();
  TextMode();
  }
예제 #15
0
파일: Declare.cpp 프로젝트: kwtskran/XCSoar
bool
FlarmDevice::Declare(const Declaration &declaration,
                     gcc_unused const Waypoint *home,
                     OperationEnvironment &env)
{
  if (!TextMode(env))
    return false;

  if (!DeclareInternal(declaration, env)) {
    mode = Mode::UNKNOWN;
    return false;
  }

  // TODO bug: JMW, FLARM Declaration checks
  // Only works on IGC approved devices
  // Total data size must not surpass 183 bytes
  // probably will issue PFLAC,ERROR if a problem?

  return true;
}
예제 #16
0
void createWindow()
{
	Rect rect;
	
	BitMap	bitMap;
	int	top, left;
	
	GetQDGlobalsScreenBits(&bitMap);
	
	top = (((bitMap.bounds.bottom - bitMap.bounds.top) - WHEIGHT) / 2);
	left = (((bitMap.bounds.right - bitMap.bounds.left) - WWIDTH) / 2);
	
	//SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &rect, left, top, left + WWIDTH, top + WHEIGHT );
	
	gWindow = NewCWindow( 0L, &rect, "\pMyDeviceLoop", true, documentProc,
							(WindowPtr)-1L, true, 0L );						
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
	
	TextFont( kFontIDTimes );
	TextSize( 48 );
	TextMode( srcCopy );
}
void createWindow()
{
	Rect		rect;
	BitMap		bitMap;
	Rect		tempRect1;
	int			top, left;
	
	GetQDGlobalsScreenBits(&bitMap);
	tempRect1 = bitMap.bounds;
	
	left = (((tempRect1.right - tempRect1.left) - WWIDTH) / 2);
	top = (((tempRect1.bottom - tempRect1.top) - WHEIGHT) / 2);

	//SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &rect, left, top, left + WWIDTH, top + WHEIGHT );
	gWindow = NewCWindow( 0L, &rect, "\pDirect Pixel Access", true, documentProc,
							(WindowPtr)-1L, true, 0L );						
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
	
	TextFont( kFontIDGeneva );
	TextSize( 9 );
	TextMode( srcXor );
}
예제 #18
0
파일: Display.cpp 프로젝트: sevico/MyVM
// 每当显示模式改变的时候,重新设置一些全局变量
int DispModeChanged()
{
	CurLine=0;CurRow=0;(*CurPage)=0;
	switch((*DispMode))
	{
	case 0:
		TextMode(40,25,false);
		break;
	case 1:
		TextMode(40,25,true);
		break;
	case 2:
		TextMode(80,25,false);
		break;
	case 3:
		TextMode(80,25,true);
		break;
	case 4:
		VgaMode(320,200,4);
		break;
	case 5:
		VgaMode(320,200,2);
		break;
	case 6:
		VgaMode(640,200,2);
		break;
	case 7:
		TextMode(80,25,false);
		break;
	case 8:
		VgaMode(160,200,16);
		break;
	case 9:
		VgaMode(320,200,16);
		break;
	case 0xa:
		VgaMode(640,200,4);
		break;
	case 0xd:
		VgaMode(320,200,16);
		break;
	case 0xe:
		VgaMode(640,200,16);
		break;
	case 0xf:
		VgaMode(640,350,2);
		break;
	case 0x10:
		VgaMode(640,350,16);
		break;
	case 0x11:
		VgaMode(640,480,2);
		break;
	case 0x12:
		VgaMode(640,480,16);
		break;
	case 0x13:
		VgaMode(320,200,256);
		break;		
	}
	*(short *)(MemoryStart+0x44c)=ModeBufSize[(*DispMode)];	
	InvalidateRect(hMyWnd,&rect,true);
	return 0;
}
예제 #19
0
static gx_xfont *
mac_lookup_font(gx_device *dev, const byte *fname, uint len,
				int encoding_index, const gs_uid *puid,
				const gs_matrix *pmat, gs_memory_t *mem)
{
#pragma unused(encoding_index,puid)
	mac_xfont		*macxf;
	
	CGrafPort		*currentPort;
	int				txFont, txSize, txMode;
	StyleField		txFace;
	Fixed			spExtra;
	
	/* are XFonts enabled? */
	if (((gx_device_macos*) dev)->useXFonts == false)
		return NULL;
	
	/* we can handle only requests from these encodings */
	if (encoding_index != ENCODING_INDEX_MACROMAN && encoding_index != ENCODING_INDEX_ISOLATIN1 &&
			encoding_index != ENCODING_INDEX_STANDARD)
		return NULL;
	
	/* Don't render very small fonts */
	if (fabs(pmat->xx * 1000.0) < 3.0)
		return NULL;
	
	/* Only handle simple cases for now (no transformations). */
	if (fabs(pmat->xy) > 0.0001 || fabs(pmat->yx) > 0.0001 || pmat->xx <= 0)
		return NULL;
	
	/* allocate memory for gx_xfont */
	macxf = gs_alloc_struct(mem, mac_xfont, &st_mac_xfont, "mac_lookup_font");
	if (macxf == NULL) {
		return NULL;
	}
	
	/* set default values */
	macxf->common.procs = &mac_xfont_procs;
	macxf->dev = dev;
	
	/* find the specified font */
	mac_find_font_family(fname, len, &(macxf->fontID), &(macxf->fontFace));
	
	/* no font found */
	if (macxf->fontID == 0)
		return NULL;

	FMGetFontFamilyName(macxf->fontID, macxf->fontName);
	macxf->fontSize = (short)(pmat->xx * 1000.0);
	macxf->fontEncoding = mac_get_font_encoding(macxf);
	
	/* we can handle only fonts with these encodings for now (all original Mac fonts have MacRoman encoding!) */
	if (macxf->fontEncoding != ENCODING_INDEX_MACROMAN && macxf->fontEncoding != ENCODING_INDEX_ISOLATIN1)
		return NULL;
	
	/* get font metrics */
	
	/* save current GrafPort's font information */
	GetPort(&((GrafPort*) currentPort));
	txFont  = currentPort->txFont;
	txSize  = currentPort->txSize;
	txFace  = currentPort->txFace;
	txMode  = currentPort->txMode;
	spExtra = currentPort->spExtra;
	
	/* set values for measuring */
	TextFont(macxf->fontID);
	TextSize(macxf->fontSize);
	TextFace(macxf->fontFace);
	TextMode(srcOr);
	SpaceExtra(0);
	
	/* measure font */
	FontMetrics(&(macxf->fontMetrics));
	
	/* restore current GrafPort's font information */
	currentPort->txFont  = txFont;
	currentPort->txSize  = txSize;
	currentPort->txFace  = txFace;
	currentPort->txMode  = txMode;
	currentPort->spExtra = spExtra;
	
	return (gx_xfont*) macxf;
}
예제 #20
0
int main()
{
	WindowPtr win;
	
#if !TARGET_API_MAC_CARBON
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    InitMenus();

	Rect r = qd.screenBits.bounds;
#else
	BitMap bm;
	GetQDGlobalsScreenBits(&bm);
	Rect r = bm.bounds;
#endif    
    SetRect(&r, r.left + 5, r.top + 45, r.right - 5, r.bottom -5);
	win = NewWindow(NULL, &r, "\pRaytracer (C Version)", true, 0, (WindowPtr)-1, false, 0);
    
#if !TARGET_API_MAC_CARBON	
	SetPort(win);
	r = win->portRect;
#else
	SetPortWindowPort(win);
	GetPortBounds(GetWindowPort(win), &r);
#endif
    EraseRect(&r);
	float accum = 0.0f;
	short cx = r.right /2;
	short cy = r.bottom / 2;
	int x,y;

	lenl = 1.0f / sqrtf(lx*lx + ly*ly + lz*lz);
	lxn = lx*lenl, lyn = ly*lenl, lzn = lz*lenl;

	long startTime = TickCount();
	float *accumV = calloc(sizeof(float), r.right);
	for(y = 0; y < r.bottom; y++)
	{
		for(x = 0; x < r.right; x++)
		{
			float pixel;
			
			// cam = (0,0,0)
			// ray = t * (x-r.right/2, - (y-r.bottom/2), -1)
			// plane: y = -2
			
			float dx = x - cx;
			float dy = - (y - cy);
			float dz = -cx;
			float n1 = 1.0f / sqrtf(dx*dx + dy*dy + dz*dz);
			
			pixel = ray(1,0,0,0,n1*dx,n1*dy,n1*dz);
			
#if 0
			accum += pixel;
			if(accum >= 0.5f)
				accum -= 1.0f;
			else
			{
				MoveTo(x,y);
				Line(0,0);
			}
#elif 0
			accum += pixel;
			accum += accumV[x];
			if(accum >= 0.5f)
				accum -= 1.0f;
			else
			{
				MoveTo(x,y);
				Line(0,0);
			}
			accumV[x] = accum = accum / 2;
#elif 0			
			//if(pixel < Random() / 32767.0)
			if(pixel < (float)std::rand() / (32767.0f * 65536.0f))
			{
				MoveTo(x,y);
				Line(0,0);
			}
#else
			float thresh = (float)rand() / (32767.0f * 65536.0f);
			thresh = 0.5f + 0.4f * (thresh - 0.5f);
			accum += pixel;
			accum += accumV[x];
			if(accum >= thresh)
				accum -= 1.0f;
			else
			{
				MoveTo(x,y);
				Line(0,0);
			}
			accumV[x] = accum = accum / 2;			
#endif
		}
		if(Button())
			return 0;
#if TARGET_API_MAC_CARBON
		QDFlushPortBuffer(GetWindowPort(win),NULL);
#endif
	}
	long endTime = TickCount();
	
	char buf[256];
	unsigned char* pstr = (unsigned char*)buf;
	sprintf(buf+1, "pps = %d", (int)( (float)r.right * r.bottom / (endTime - startTime) * 60.0f ));
	buf[0] = strlen(buf+1);
	
	SetRect(&r, 10, 10, 10 + StringWidth(pstr) + 10, 30);
	PaintRect(&r);
	PenMode(patXor);
	FrameRect(&r);
	MoveTo(15,25);
	TextMode(srcBic);
	DrawString(pstr);
#if TARGET_API_MAC_CARBON
	QDFlushPortBuffer(GetWindowPort(win),NULL);
#endif
	
	while(!Button())
		;
	FlushEvents(everyEvent, -1);
	return 0;
}
예제 #21
0
/* following functions are local */
static int TtyInit(vout_display_t *vd)
{
    vout_display_sys_t *sys = vd->sys;

    struct termios new_termios;

    GfxMode(sys->tty);

    /* Set keyboard settings */
    if (tcgetattr(0, &sys->old_termios) == -1) {
        msg_Err(vd, "tcgetattr failed");
    }

    if (tcgetattr(0, &new_termios) == -1) {
        msg_Err(vd, "tcgetattr failed");
    }

    /* new_termios.c_lflag &= ~ (ICANON | ISIG);
    new_termios.c_lflag |= (ECHO | ECHOCTL); */
    new_termios.c_lflag &= ~ (ICANON);
    new_termios.c_lflag &= ~(ECHO | ECHOCTL);
    new_termios.c_iflag = 0;
    new_termios.c_cc[VMIN] = 1;
    new_termios.c_cc[VTIME] = 0;

    if (tcsetattr(0, TCSAFLUSH, &new_termios) == -1) {
        msg_Err(vd, "tcsetattr failed");
    }

    ioctl(sys->tty, VT_RELDISP, VT_ACKACQ);

#if 0
    /* Set-up tty signal handler to be aware of tty changes */
    struct sigaction sig_tty;
    memset(&sig_tty, 0, sizeof(sig_tty));
    sig_tty.sa_handler = SwitchDisplay;
    sigemptyset(&sig_tty.sa_mask);
    if (sigaction(SIGUSR1, &sig_tty, &sys->sig_usr1) ||
            sigaction(SIGUSR2, &sig_tty, &sys->sig_usr2)) {
        msg_Err(vd, "cannot set signal handler (%s)", vlc_strerror_c(errno));
        /* FIXME SIGUSR1 could have succeed */
        goto error_signal;
    }
#endif

    /* Set-up tty according to new signal handler */
    if (-1 == ioctl(sys->tty, VT_GETMODE, &sys->vt_mode)) {
        msg_Err(vd, "cannot get terminal mode (%s)", vlc_strerror_c(errno));
        goto error;
    }
    struct vt_mode vt_mode = sys->vt_mode;
    vt_mode.mode   = VT_PROCESS;
    vt_mode.waitv  = 0;
    vt_mode.relsig = SIGUSR1;
    vt_mode.acqsig = SIGUSR2;

    if (-1 == ioctl(sys->tty, VT_SETMODE, &vt_mode)) {
        msg_Err(vd, "cannot set terminal mode (%s)", vlc_strerror_c(errno));
        goto error;
    }
    return VLC_SUCCESS;

error:
#if 0
    sigaction(SIGUSR1, &sys->sig_usr1, NULL);
    sigaction(SIGUSR2, &sys->sig_usr2, NULL);
error_signal:
#endif
    tcsetattr(0, 0, &sys->old_termios);
    TextMode(sys->tty);
    return VLC_EGENERIC;
}
예제 #22
0
void main(void)
  {
  Pixel Data[500];
  Pixel DataIn[500];

  Vid=&Scrn;
  SetVESAMode(Vid);
  bioskey(0);
  Coord2d Pos(0,0);
/*
  for (;Pos.x<Vid->Size.x;Pos.x++)
    for (Pos.y=0;Pos.y<Vid->Size.y;Pos.y++)
      Point(Pos,Pos.x+Pos.y,Vid);
*/
/*  for (Pos.x=0;Pos.x<Vid->Size.x;Pos.x++)
    for (Pos.y=0;Pos.y<Vid->Size.y;Pos.y++)
      if (GetCol(Pos,Vid)!=((Pos.y+Pos.x)&255))
        {
        TextMode();
        printf("GetCol Incorrect at (%d,%d),%d",Pos.x,Pos.y,GetCol(Pos,Vid));
        return;
        }
*/
/*  Pos.x=100; Pos.y=100;
  for (int i=0;i<500;i++) Data[i]=1;
  GetCols(Pos,200,Data,Vid);
*/
/*  for (Pos.x=100;Pos.x<300;Pos.x++)
    {
    if (Data[Pos.x-100]!=((100+Pos.x)&255) )
      {
      TextMode();
      printf("GetCols Incorrect at (%d,%d) Should be:%d. is:%d. ",Pos.x,Pos.y,((Pos.y+Pos.x)&255),Data[Pos.x-100]);
      printf("%d %d %d %d %d",Data[0],Data[1],Data[2],Data[3],Data[4]);
      return;
      }
    }
*/

//  Point(MakeCoord(90,100),110,Vid);
  for (Pos.x=0,Pos.y=306;Pos.y<320;Pos.y++)
    Rep1Col(Pos,Pos.y,Pos.y,Vid);
//  Clear(6,Vid);
  bioskey(0);

  // RepCols over a page boundary.
  Pos.x=0; Pos.y=307;
  RepCols(Pos,306,Data,Vid);
  GetCols(Pos,306,DataIn,Vid);
  for (Pos.x=0;Pos.x<306;Pos.x++)
    {
    if (Data[Pos.x]!=DataIn[Pos.x])
      {
      TextMode();
      printf("GetCols Incorrect at (%d,%d) Should be:%d. is:%d. ",Pos.x,Pos.y,Data[Pos.x],DataIn[Pos.x]);
      printf("%d %d %d %d %d",Data[0],Data[1],Data[2],Data[3],Data[4]);
      return;
      }
    }

//  bioskey(0);
//  Clear(18,Vid);
  Coord2d zero(0,0);
/*  for (Pos.x=0;Pos.x<320;Pos.x+=20)
    for (Pos.y=0;Pos.y<200;Pos.y+=10)
      Line(zero,Pos,Pos.x+Pos.y,Vid);
  bioskey(0);
  for (Pos.x=0;Pos.x<320;Pos.x+=20)
    for (Pos.y=0;Pos.y<200;Pos.y+=20)
      BoxFill(Pos,Pos+20,Pos.x+(Pos.y/20),Vid);
*/
  bioskey(0);
  TextMode();
  }