コード例 #1
0
ファイル: rawchar.c プロジェクト: dank101/4.2BSD
rawchar()
{
	char c;

	sync();
	escseq(NONE);
	fflush(stdout);
	if (_pb_front && _on2648) {
		c = *_pb_front++;
#ifdef TRACE
		if (trace)
			fprintf(trace, "%s from queue, front=%d, back=%d\n", rdchar(c), _pb_front-_pushback, _pb_back-_pushback);
#endif
		if (_pb_front > _pb_back) {
			_pb_front = _pb_back = NULL;
#ifdef TRACE
			if (trace)
				fprintf(trace, "reset pushback to null\n");
#endif
		}
		return (c);
	}
	_outcount = 0;
	c = getchar();
#ifdef TRACE
	if (trace)
		fprintf(trace, "rawchar '%s'\n", rdchar(c));
#endif
	return (c);
}
コード例 #2
0
ファイル: tline.cpp プロジェクト: HaikuArchives/Gloom3D
// loads the line from the current file
bool Tline::load()
{
  Tmap_item::load();
  // reads first and second ends
  v1 = rdlong();
  v2 = rdlong();

  // reads all the walls
  int n = rdlong();
  if (n==0) return false;
#ifndef EDITOR
  walls = (Twall **)malloc( n*sizeof(Twall*) );
#else
  walls = (Twall **)malloc( sizeof(Twall*) );
#endif
  if (!walls) return false;
  Twall **w;
  int i;
  for (i=0,w=walls;i<n;i++,NEXTWALL(w)) {
    byte kind = rdchar();
    // create the walls
    switch (kind) {
      case wtWALL:
        (*w) = new Twall();
        break;
      case wtHOLE:
        (*w) = new Thole();
        break;
      case wtPORTAL:
        (*w) = new Tportal();
        break;
    }
    if (!(*w)->load()) {
#ifndef EDITOR
      for (;w>=walls;w--)
        delete *w;
#else
      Twall *w0,*n;
      for (w0=*walls;w0;w0=n) {
        n=w0->next;
        delete w0;
      }
#endif      
      free(walls);
      return false;
    }
  }
  wallsnum=n;
  return true;
}
コード例 #3
0
ファイル: parsestreams.c プロジェクト: ajinkya93/netbsd-src
/*
 * convert incoming data
 */
static int
parserput(
	queue_t *q,
	mblk_t *mp
	)
{
	unsigned char type;

	switch (type = mp->b_datap->db_type)
	{
	    default:
		/*
		 * anything we don't know will be put on queue
		 * the service routine will move it to the next one
		 */
		parseprintf(DD_RPUT,("parse: parserput - forward type 0x%x\n", type));
		if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
		{
			putnext(q, mp);
		}
		else
		    putq(q, mp);
		break;

	    case M_BREAK:
	    case M_DATA:
		    {
			    register parsestream_t * parse = (parsestream_t *)(void *)q->q_ptr;
			    register mblk_t *nmp;
			    register unsigned long ch;
			    timestamp_t ctime;

			    /*
			     * get time on packet delivery
			     */
			    uniqtime(&ctime.tv);

			    if (!(parse->parse_status & PARSE_ENABLE))
			    {
				    parseprintf(DD_RPUT,("parse: parserput - parser disabled - forward type 0x%x\n", type));
				    if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
				    {
					    putnext(q, mp);
				    }
				    else
					putq(q, mp);
			    }
			    else
			    {
				    parseprintf(DD_RPUT,("parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK"));

				    if (type == M_DATA)
				    {
					    /*
					     * parse packet looking for start an end characters
					     */
					    while (mp != (mblk_t *)NULL)
					    {
						    ch = rdchar(&mp);
						    if (ch != ~0 && parse_ioread(&parse->parse_io, (unsigned int)ch, &ctime))
						    {
							    /*
							     * up up and away (hopefully ...)
							     * don't press it if resources are tight or nobody wants it
							     */
							    nmp = (mblk_t *)NULL;
							    if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
							    {
								    bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
								    nmp->b_wptr += sizeof(parsetime_t);
								    putnext(parse->parse_queue, nmp);
							    }
							    else
								if (nmp) freemsg(nmp);
							    parse_iodone(&parse->parse_io);
						    }
					    }
				    }
				    else
				    {
					    if (parse_ioread(&parse->parse_io, (unsigned int)0, &ctime))
					    {
						    /*
						     * up up and away (hopefully ...)
						     * don't press it if resources are tight or nobody wants it
						     */
						    nmp = (mblk_t *)NULL;
						    if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
						    {
							    bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
							    nmp->b_wptr += sizeof(parsetime_t);
							    putnext(parse->parse_queue, nmp);
						    }
						    else
							if (nmp) freemsg(nmp);
						    parse_iodone(&parse->parse_io);
					    }
					    freemsg(mp);
				    }
				    break;
			    }
		    }

		    /*
		     * CD PPS support for non direct ISR hack
		     */
	    case M_HANGUP:
	    case M_UNHANGUP:
		    {
			    register parsestream_t * parse = (parsestream_t *)(void *)q->q_ptr;
			    timestamp_t ctime;
			    register mblk_t *nmp;
			    register int status = cd_invert ^ (type == M_UNHANGUP);

			    uniqtime(&ctime.tv);

			    parseprintf(DD_RPUT,("parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN"));

			    if ((parse->parse_status & PARSE_ENABLE) &&
				parse_iopps(&parse->parse_io, (int)(status ? SYNC_ONE : SYNC_ZERO), &ctime))
			    {
				    nmp = (mblk_t *)NULL;
				    if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
				    {
					    bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
					    nmp->b_wptr += sizeof(parsetime_t);
					    putnext(parse->parse_queue, nmp);
				    }
				    else
					if (nmp) freemsg(nmp);
				    parse_iodone(&parse->parse_io);
				    freemsg(mp);
			    }
			    else
				if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
				{
					putnext(q, mp);
				}
				else
				    putq(q, mp);

			    if (status)
			    {
				    parse->parse_ppsclockev.tv = ctime.tv;
				    ++(parse->parse_ppsclockev.serial);
			    }
		    }
	}
	return 0;
}
コード例 #4
0
ファイル: FrameTable.c プロジェクト: CultOfSkaro/CultOfSkaro
/** Initiate a camera core frame capture into the specified FTE
	The FT_StartCapture() function is called at the end of the 
	FT_InterruptHandlerFrameTable() interrupt handler and will configure the 
	camera core to write the various frames to those pointed to by the 
	FrameTable[0] entry. And it will then initiate a new frame capture.

	
	STEPS:
	-# Check in any Static Buffer frames that are still in the FTE
	-# Determine which Frames need to be saved to memory
	-# Checkout the buffers for those frames
	-# Write save options to the Camera Core (of the succesfully checkout buffers)
	-# Write Frame memory addresses to camera core
	-# Write various other options to the camera core
	-# Initiate Camera Capture	
	-# Apply camera chip settings
*/
void FT_StartCapture(FrameTableEntry* fte)
{	
	uint32 save_options;
	
	if(fte == NULL)
		return;

	
	// STEP: check in any Static Buffer frames that are still in the FTE
	{
		int i;
		for(i = 0 ; i < VISION_MAX_NUM_FRAMES ; i++)
			BSCheckIn(&fte->frame_address[i]);							
		
	}


	// STEP: Determine which Frames need to be saved to memory
	save_options =   rdhex(X_CAM_SAVE_OPTIONS_BASE) 
	               | rdhex(X_CAM_SAVE_OPTIONS_EXTENDED) 
	    		   | rdhex(X_STATIC_BUFFER_OPTIONS);

	save_options = 0x2;
	/* STEP: Checkout the buffers for those frames
			 In this step, we look at the local save_options variable. Each 
			 bit represents whether the frame at that index should be saved or
			 not. If the (save_options & 0x01) bit is a 1 then we save the frame 
			 at index 0x01, otherwise we do not save the frame at index 0x01.

			 To do this we use a bit mask. We loop through all of the 16 possible 
			 frame indexes (the camera core can only support up to 16 frames) and 
			 test if each one has been #requested# to be saved. If the frame at 
			 a particular bit index has been requested to be saved then we find out 
			 what Camera Frame Type that frame is. If the frame at that index turns
			 out to be unavailavle then we don't save it and we clear the bit in the
			 save_options since we cannot save a frame that doesn't exist. That situation
			 would be a rare occurance. Normally the frame type will one of the possible 
			 image or lists and delineated in plb_camera.h. Once we have found the type
			 of frame we are going to capture, then we determine what type of Buffer
			 from the BufferStore needs to be checked out to put that frame in. If
			 the checked out buffer turns out to be NULL, then we have hit an error 
			 some where and the BufferStore doesn't know what type of Buffer corresponds 
			 with that kind of Camera Frame. Again, if we cannot checkout a buffer for 
			 that frame then we need to clear the bit in the save_options because we 
			 cannot save that frame since we do not have a place in memory to write it to.
	*/
	{
		int i;
		for(i = 0 ; i < VISION_MAX_NUM_FRAMES ; i++)
		{
			uint32 mask;

			//Initially set the address to 0
			fte->frame_address[i] = NULL;

			mask = 0x01 << i;
			if(save_options & mask)
			{
				uint32 type = camera0.frame_type[i]; // i.e. type = VISION_FRAME_RGB565

				if(type != VISION_FRAME_NOT_AVAILABLE)
				{
					Buffer* buf = BSCheckOut(BSCamType2BufferType(type));
					
					if(buf != NULL) // The buffer was sucessfully checked out...
						fte->frame_address[i] = buf;
					else 
					{	// The buffer was NOT successfuly checked out so don't try and save the frame...					
						//HeliosSetLED2(!HeliosReadLED2());
						save_options &= (~mask);
					}
				} else 
				{
				  // The buffer was NOT successfuly checked out so don't try and save the frame...				
				  save_options &= (~mask);
				}
			}		
		}
	}


	// STEP: Write save options to the Camera Core 
	//SetFrameSaveOptions(camera0.base_address, save_options);					

	/* STEP:	Write Frame memory addresses to camera core
				The Camera Core uses DMA to transfer incomming image data 
				directly to main memory. So the Camera Core needs to be 
				told the 32-bit memory addres where it can write the image 
				data. Here we write the 32-bit memory addresses to the 
				Camera Core 
	*/
	{
		int i;
		for(i = 0 ; i < VISION_MAX_NUM_FRAMES ; i++)
		{
			uint32 ptr = 0;

			if(fte->frame_address[i] != NULL)
				ptr = (uint32)fte->frame_address[i]->data.voidptr;
			SetFrameAddress(i, ptr);
		}
	}


	// STEP: 5: Write various other options to the camera core

	
	// STEP 6: Initiate Camera Capture
	StartFrameCapture();
	fte->status		= FT_STATUS_ACQUIRING;
	g_capture_fte	= fte;	


	// STEP 7: Apply camera chip settings
	// 1: Exposure
	// 2: Gain
#if DAUGHTER_BOARD == DAUGHTER_BOARD_AVT
	{
		uint32 mask;

		mask = (rdchar(C_ENABLE_AUTO_GAIN) << 1) | rdchar(C_ENABLE_AUTO_EXPOSURE);
		mask = mask & 0x03;
		
		WriteCameraRegister(0xAF, mask);
		WriteCameraRegister(0x0B, rduint(U_MANUAL_EXPOSURE));
		WriteCameraRegister(0x35, rduint(U_MANUAL_GAIN));
	}
#endif
}
コード例 #5
0
ファイル: Tmapitem.cpp プロジェクト: willy9561/Boom2
// loads the map item from the current file
bool Tmap_item::load()
{
  options = rdchar();
  return true;
}