示例#1
0
文件: video.cpp 项目: Maka7879/Epiar
/**\brief Set crop rectangle.
 */
void Video::SetCropRect( int x, int y, int w, int h ){
	int xn,yn,wn,hn;
	if (cropRects.empty()){
		glEnable(GL_SCISSOR_TEST);
		xn=x;
		yn=y;
		wn=w;
		hn=h;
	}else{
		// Need to detect which part of crop rectangle is within previous rectangle
		// So we don't miss things that needs to be cropped.
		Rect prevrect = cropRects.top();
		int rightprev = TO_INT(prevrect.x+prevrect.w);
		int right = x+w;
		int botprev = TO_INT(prevrect.y+prevrect.h);
		int bot = y+h;
		xn = prevrect.x > x ? TO_INT(prevrect.x) : x;	// Left
		yn = prevrect.y > y ? TO_INT(prevrect.y) : y;	// Top
		wn = rightprev > right ? right-xn : rightprev-xn;// Right
		hn = botprev > bot ? bot-yn : botprev-yn;		// Bottom
	}

	cropRects.push(Rect( xn, yn, wn, hn ));
	// Need to convert top down y-axis
	glScissor( x, Video::h-(y+h), w, h );
}
示例#2
0
/*
 *eb:empty block
 *fb:full block
 */
void *mem_free(void *p)
{
	//开始释放
	if (TO_INT(p < 4) < 0)
	{
		return (void *)-1;
	}
	void *eb_head = p - 4;
	void *eb_tail = jump_to_tail(eb_head);
	int   eb_size = TO_INT(eb_head);

	//合并空块
	int *temp_head = (int *)(eb_head - 4);
	if (eb_head > pool_head && *temp_head < 0)
	{
		eb_head = jump_to_last(eb_head);
	}

	int *temp_tail = (int *)(eb_tail + 4);
	if (eb_tail < (pool_tail - 4) && *temp_tail < 0)
	{
		eb_tail = jump_to_next(eb_tail);
	}
	
	eb_size = (eb_tail - eb_head) + 4;
	TO_INT(eb_head) = -1 * eb_size;
	TO_INT(eb_tail) = -1 * eb_size;
}
示例#3
0
// -------------------------------------------------------------
void ViewPainter::map(int x1, int y1, int& x, int& y)
{
  float z;
  z = float(x1)*Scale + DX;
  x = TO_INT(z);
  z = float(y1)*Scale + DY;
  y = TO_INT(z);
}
示例#4
0
// -------------------------------------------------------------
// Draw little resize rectangles with center x1/y1 and size independent
// of zoom factor.
void ViewPainter::drawResizeRect(int x1, int y1)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  Painter->drawRect(x1-5, y1-5, 10, 10);
}
示例#5
0
// -------------------------------------------------------------
void ViewPainter::drawPoint(int x1, int y1)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  Painter->drawPoint(x1, y1);
}
示例#6
0
// -------------------------------------------------------------
void ViewPainter::eraseRect(int x1, int y1, int dx, int dy)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  Painter->eraseRect(x1, y1, dx, dy);
}
示例#7
0
void init_luts()
{
#ifndef WINDOWS_NT
   word indexPort, dataPort;
#else
   PUCHAR indexPort, dataPort;
#endif
   byte colorTab[256][3];
   word i, j;
   dword tmp;

   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         colorTab[i][j] = (byte)i;

   indexPort = encBaseAddr + DAC_LUT_CTRL_WR;
   dataPort  = encBaseAddr + DAC_LUT_DATA;

   outp (indexPort, 0);
   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         {
         tmp = TO_INT((dword)colorTab[i][j] * gain);
         if (tmp > 0xff) tmp = 0xff;
         outp (dataPort, (byte)tmp);
         }

   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         {

         tmp =  TO_INT( (((dword)colorTab[i][j] * (dword)220 * gain) / (dword)256)
                                  +  TO_FLOAT(16) + (TO_FLOAT(1) / 2)
                                 );

         if ( tmp > 0xeb )
            colorTab[i][j] = 0xeb;
         else
            colorTab[i][j] = (byte)tmp;
         }

//         colorTab[i][j] = (double)(colorTab[i][j]*220.0/256.0)
//                                    + 16.0 + 0.5;

   indexPort = encBaseAddr + DENC_CLUT_CTRL_WR;
   dataPort  = encBaseAddr + DENC_CLUT_DATA;

   outp (indexPort, 0);
   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         outp (dataPort, colorTab[i][j]);

   inp (encBaseAddr + DENC_DATA_CTRL);     /* To activate the CLUT */
}
示例#8
0
// -------------------------------------------------------------
// Returns width of text (and height if pointer is not null).
int ViewPainter::drawText(const QString& Text, int x1i, int y1i, int *Height)
{
  float x1, y1;
  x1= float(x1i)*Scale + DX;
  y1 = float(y1i)*Scale + DY;

  QRectF rf;
  rf = Painter->boundingRect(QRectF(x1, y1, 0, 0), Qt::TextDontClip, Text);
  Painter->drawText(QRectF(x1, y1, 0, 0), Qt::TextDontClip, Text);

  if(Height)  *Height = TO_INT(rf.height());
  return TO_INT(rf.width());
}
示例#9
0
// -------------------------------------------------------------
void ViewPainter::drawLine(int x1, int y1, int x2, int y2)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);
  z = float(x2)*Scale + DX;
  x2 = TO_INT(z);
  z = float(y2)*Scale + DY;
  y2 = TO_INT(z);

  Painter->drawLine(x1, y1, x2, y2);
}
示例#10
0
bool addCheat (const char *str)
{
    int len;
    int i = numCheats;

    if (i == MAX_CHEATS)
        return false;

    // Clear all flags
    cheats[i].flags = 0;
    cheats[i].patchedBanks = std::vector<int>();
    cheats[i].patchedValues = std::vector<int>();

    len = strlen(str);
    strncpy(cheats[i].cheatString, str, 12);

    // GameGenie AAA-BBB-CCC
    if (len == 11) {
        cheats[i].flags |= FLAG_GAMEGENIE;
        
        cheats[i].data = TO_INT(str[0]) << 4 | TO_INT(str[1]);
        cheats[i].address = TO_INT(str[6]) << 12 | TO_INT(str[2]) << 8 | 
            TO_INT(str[4]) << 4 | TO_INT(str[5]);
        cheats[i].compare = TO_INT(str[8]) << 4 | TO_INT(str[10]);

        cheats[i].address ^= 0xf000;
        cheats[i].compare = (cheats[i].compare >> 2) | (cheats[i].compare&0x3) << 6;
        cheats[i].compare ^= 0xba;

        printLog("GG %04x / %02x -> %02x\n", cheats[i].address, cheats[i].data, cheats[i].compare);
    }
示例#11
0
// -------------------------------------------------------------
// Returns width of text (and height if pointer is not null).
int ViewPainter::drawText(const QString& Text, int x1, int y1, int *Height)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  QRect r;
  Painter->drawText(x1, y1, 0, 0, Qt::DontClip, Text, -1, &r);

  if(Height)  *Height = r.height();
  return r.width();
}
示例#12
0
// -------------------------------------------------------------
void ViewPainter::drawEllipse(int x1, int y1, int dx, int dy)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);
  z = float(dx)*Scale;
  dx = TO_INT(z);
  z = float(dy)*Scale;
  dy = TO_INT(z);

  Painter->drawEllipse(x1, y1, dx, dy);
}
示例#13
0
文件: video.cpp 项目: Maka7879/Epiar
/**\brief Unset the previous crop rectangle after use.
 */
void Video::UnsetCropRect( void ){
	if (!cropRects.empty()) // Shouldn't be empty
		cropRects.pop();
	else
		LogMsg(WARN,"You unset the crop rect too many times.");

	if ( cropRects.empty() )
		glDisable(GL_SCISSOR_TEST);
	else{	//Set's the previous crop rectangle.
		Rect prevrect = cropRects.top();
		glScissor( TO_INT(prevrect.x), TO_INT(prevrect.y), 
				TO_INT(prevrect.w), TO_INT(prevrect.h) );
	}
}
示例#14
0
// -------------------------------------------------------------
// Returns width of text (and height if pointer is not null).
void ViewPainter::drawArc(int x1, int y1, int w, int h, int Angle, int ArcLen)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  // Width and height get a different treatment due to some alaising artefacts.
  // The following procedure was found empirically.
  w = int(float(w)*Scale);
  h = int(float(h)*Scale);
  Painter->drawArc(x1, y1, w+1, h+1, Angle, ArcLen);
}
示例#15
0
// -------------------------------------------------------------
void ViewPainter::fillRect(int x1, int y1, int dx, int dy, const QColor& Color)
{
  float z;
  z = float(x1)*Scale + DX;
  x1 = TO_INT(z);
  z = float(y1)*Scale + DY;
  y1 = TO_INT(z);

  z = float(dx)*Scale;
  dx = TO_INT(z);
  z = float(dy)*Scale;
  dy = TO_INT(z);

  Painter->fillRect(x1, y1, dx, dy, QBrush(Color));
}
示例#16
0
/**\brief Internal rendering function.*/
int Font::RenderInternal( int x, int y, const string& text, int h, XPos xpos, YPos ypos) {
    int xn = 0;
    int yn = 0;

    switch( xpos ) {
    case LEFT:
        xn = x;
        break;
    case CENTER:
        xn = x - this->TextWidth(text) / 2;
        break;
    case RIGHT:
        xn=x-this->TextWidth(text);
        break;
    default:
        LogMsg(ERR, "Invalid xpos");
        assert(0);
    }

    // Y coordinates are flipped
    switch( ypos ) {
    case TOP:
        yn = -y - h - TO_INT(floor(this->font->Descender()));
        break;
    case MIDDLE:
        yn = -y - h / 2 - TO_INT(floor(this->font->Descender()));
        break;
    case BOTTOM:
        yn = -y - TO_INT(floor(this->font->Descender()));
        break;
    default:
        LogMsg(ERR, "Invalid ypos");
        assert(0);
    }

    glColor4f( r, g, b, a );
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glPushMatrix(); // to save the current matrix
    glScalef(1, -1, 1);
    FTPoint newpoint = this->font->Render( text.c_str(), -1, FTPoint( xn, yn, 1) );
    glPopMatrix(); // restore the previous matrix
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    return TO_INT(ceil(newpoint.Xf())) - x;
}
示例#17
0
/**\brief Returns the complete height of the font, including Ascend and Descend.
 * \details
 * Use Outer height to get the tight fitting height of the font.
 */
int Font::TightHeight( void ) {
    float asc = this->font->Ascender();
    float dsc = this->font->Descender();
    int height = TO_INT(ceil(asc-dsc));

    return height;
}
示例#18
0
void GlobalEntry::eventHandler(ostream& os) {
    vector<EventEntry*> event_l;
    EventEntry *event;
    vector<Type*>* argtype_l;

    // Store all EventEntry definitions
    vector<RuleNode*>::const_iterator it; 
    for (it = rules_.begin(); it != rules_.end(); ++it) {
        if ((*it)->pat()->kind() == BasePatNode::PatNodeKind::PRIMITIVE) {
            event_l.push_back(((PrimitivePatNode*)(*it)->pat())->event());
        }
    }

    os << "JMP begin" << endl;
    // Generate code to input event parameter
    for (unsigned int ii = 0; ii < event_l.size(); ii++) {
        event = event_l[ii];
        os << S_PREFIX << event->name() << ": ";
        
        argtype_l = event->type()->argTypes();

        os << "MOVL " << S_EVENT_END << R_PARAM << endl;
        os << "STI" << R_PARAM << RSP << C_PUSH_RET << endl;
        os << "SUB" << RSP << " 4" << RSP << endl;
        
        if (argtype_l) {
            std::vector<Type*>::iterator type_it = argtype_l->begin();
            for (int i = 1; type_it != argtype_l->end(); ++type_it, ++i) {

                os << "PRTS\"Enter Param " << i << ": \"" << endl;
                if ((*type_it)->tag() == Type::DOUBLE) {
                    os << "INF" << F_PARAM << C_IN_EPARAM << endl;
                    os << "STF" << F_PARAM << RSP << C_APARAM << endl;
                } else {
                    os << "INI" << R_PARAM << C_IN_EPARAM << endl;
                    os << "STI" << R_PARAM << RSP << C_APARAM << endl;
                }
                os << "SUB" << RSP << " 4" << RSP << endl;
            }
        }

        os << "JMP " << E_PREFIX << event->name() << endl;
        os << endl;
    }

    os << S_EVENT_END << ": ";
    os << "IN" << R_PARAM << C_DUMMY_INP << endl;
    os << S_START << ": ";
    os << "PRTS " << "\"\\nEnter Event Name ('0' for exit): \"" << endl;
    os << "IN" << R_PARAM << endl;

    // Generate code to select appropriate event
    for (unsigned int ii = 0; ii < event_l.size(); ii++) {
        event = event_l[ii];
        os << "JMPC EQ" << R_PARAM << " " << TO_INT(event->name()) << " " << S_PREFIX << event->name() << endl;
    }
    os << "JMPC EQ" << R_PARAM << " " << (int)'0' << " " << S_EXIT << endl;
    os << "PRTS " << "\"Invalid Event Name\\n\"" << endl;
    os << "JMP " << S_EVENT_END << endl << endl;
}
示例#19
0
// -------------------------------------------------------------
void ViewPainter::drawStarSymbols(int x0, int y0, float *pp)
{
  int x3, x1, x2, y1, y2;
  float z, DX_, DY_;
  if(*pp < 0)
    pp++;

  DX_ = DX + float(x0)*Scale;
  DY_ = DY + float(y0)*Scale;

  while(*pp > GRAPHEND) {
    if(*pp >= 0) {
      z = DX_ + (*(pp++))*Scale;
      x0 = TO_INT(z-5.0*Scale);
      x3 = TO_INT(z+5.0*Scale);
      x1 = TO_INT(z-4.0*Scale);
      x2 = TO_INT(z+4.0*Scale);
      z = DY_ - (*(pp++))*Scale;
      y0 = TO_INT(z);
      y1 = TO_INT(z-4.0*Scale);
      y2 = TO_INT(z+4.0*Scale);
      Painter->drawLine(x0, y0, x3, y0); // horizontal line
      Painter->drawLine(x1, y2, x2, y1); // upper left to lower right
      Painter->drawLine(x2, y2, x1, y1); // upper right to lower left
    }
    else  pp++;
  }
}
示例#20
0
void en_encoder (bool state,PUCHAR encBaseAddr)
#endif
{
#ifndef WINDOWS_NT
 word indexPort, dataPort;
#else
    PUCHAR indexPort, dataPort;
#endif

 byte colorTab[256][3];
 word i, j;
 if (state)
   init_luts(); 
 else
 {
   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
            colorTab[i][j] = 0;

   indexPort = encBaseAddr + 0x10 + 0x00;
   dataPort  = encBaseAddr + 0x10 + 0x01;

   outp (indexPort, 0);
   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         outp (dataPort, colorTab[i][j]);

   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         {
         colorTab[i][j] =  (byte)TO_INT((colorTab[i][j] * TO_FLOAT(220) / 256)
                                  +  TO_FLOAT(16) + (TO_FLOAT(1) / 2)
                                 );

// ((double)(colorTab[i][j]*220.0/256.0)+ 16.0 + 0.5) );
         }



   indexPort = encBaseAddr + 0x04 + 0x00;
   dataPort  = encBaseAddr + 0x04 + 0x01;

   outp (indexPort, 0);
   for (i = 0; i < 256; i++)
      for (j = 0; j < 3; j++)
         outp (dataPort, colorTab[i][j]);

#ifndef WINDOWS_NT
   inp (encBaseAddr + 0x04 + 0x03);     /* To activate the CLUT */
#else
        inp ((PUCHAR)(encBaseAddr + 0x04 + 0x03));  /* To activate the CLUT */
#endif
 }
}
示例#21
0
文件: rng-usleep.c 项目: 007/rngutils
int main(int argc, char *argv[]) {

	options opts = { { NULL }, NULL, 0 };
	argp_parse(&argp, argc, argv, 0, 0, &opts);

	int length = 0, sleep_i = 40;
	TO_INT(opts.args[0], length, "LENGTH");
	TO_INT(opts.sleep_i, sleep_i, "TIME");

	char *len_str, *pad_str;
	len_str = (length)? opts.args[0]: "";
	pad_str = (length)? " ": "";

	fprintf(stderr, "generating %s%srandom bytes @ %d+c us/bit\n",
	  len_str, pad_str, sleep_i);

	generate_random(length, sleep_i, stdout);
	return EXIT_SUCCESS;

}
示例#22
0
/**\brief Calculates the marker position from pixel offset.
 */
int Scrollbar::MarkerPixelToPos( int xr, int yr ){
	int effectivelen;
	int newpos;
	int marksize = this->GetMarkerSize();
	int effectivestart = bitmaps[2]->GetHeight() + marksize / 2;

	effectivelen = this->h - marksize - bitmaps[1]->GetHeight() - bitmaps[2]->GetHeight();
	newpos = TO_INT(TO_FLOAT(yr - effectivestart) / TO_FLOAT(effectivelen) * (maxpos - h));

	return newpos;
}
示例#23
0
/**\brief Calculates the marker position from pixel offset.
 */
int Scrollbar::MarkerPixelToPos( int xr, int yr ){
	int effectivelen;
	int screenlen;
	int newpos;
	int marksize = this->GetMarkerSize();
	int effectivestart = SCROLLBAR_BTN+marksize/2;
	if ( type == HORIZONTAL ){
		effectivelen = this->w-2*SCROLLBAR_BTN-marksize;
		screenlen = this->w+2*SCROLLBAR_PAD;
		newpos = TO_INT(TO_FLOAT(xr - effectivestart)
			/TO_FLOAT(effectivelen)
			*(maxpos-screenlen));
	}else{
		effectivelen = this->h-2*SCROLLBAR_BTN-marksize;
		screenlen = this->h+2*SCROLLBAR_PAD;
		newpos = TO_INT(TO_FLOAT(yr - effectivestart)
			/TO_FLOAT(effectivelen)
			*(maxpos-screenlen));
	}
	return newpos;
}
示例#24
0
// -------------------------------------------------------------
void ViewPainter::drawArrowSymbols(int x0, int y0, float *pp)
{
  int x1, x2, y1, y2;
  float z, DX_, DY_;
  if(*pp < 0)
    pp++;

  DX_ = DX + float(x0)*Scale;
  DY_ = DY + float(y0)*Scale;
  y2 = TO_INT(DY_);

  while(*pp > GRAPHEND) {
    if(*pp >= 0) {
      z = DX_ + (*(pp++))*Scale;
      x0 = TO_INT(z);
      x1 = TO_INT(z-4.0*Scale);
      x2 = TO_INT(z+4.0*Scale);
      z = DY_ - (*(pp++))*Scale;
      y0 = TO_INT(z);
      y1 = TO_INT(z+7.0*Scale);
      Painter->drawLine(x0, y0, x0, y2);
      Painter->drawLine(x1, y1, x0, y0);
      Painter->drawLine(x2, y1, x0, y0);
    }
    else  pp++;
  }
}
示例#25
0
//Score text based on ngram frequencies
double evaluate(const std::string& text)
{
    double score = 0;

    switch(LENGTH)
    {
    case 2:
        for(unsigned i = 0; i < text.length() - 1; ++i)
        {
            if (text[i] == '#' || text[i + 1] == '#')
                score -= 9;
            else
                score += bigram_freq[TO_INT(text[i]) * 26 +
                                     TO_INT(text[i + 1])];
        }
        break;

    case 3:
        for(unsigned i = 0; i < text.length() - 2; ++i)
        {
            if (text[i] == '#' || text[i + 1] == '#' || text[i + 2] == '#')
                score -= 10;
            else
                score += trigram_freq[TO_INT(text[i]) * 676 +
                                      TO_INT(text[i + 1]) * 26 +
                                      TO_INT(text[i + 2])];
        }
        break;

    case 4:
        for(unsigned i = 0; i < text.length() - 3; ++i)
        {
            if (text[i] == '#' || text[i + 1] == '#' || text[i + 2] == '#' || text[i + 3] == '#')
                score -= 13;
            else
                score += quadgram_freq[TO_INT(text[i]) * 17576 +
                                       TO_INT(text[i + 1]) * 676 +
                                       TO_INT(text[i + 2]) * 26 +
                                       TO_INT(text[i + 3])];
        }
        break;
    }
    return score;
}
示例#26
0
// -------------------------------------------------------------
void ViewPainter::drawCircleSymbols(int x0, int y0, float *pp)
{
  int d;
  float z, DX_, DY_;
  if(*pp < 0)
    pp++;

  z = 8.0*Scale;
  d = TO_INT(z);
  DX_ = DX + float(x0)*Scale;
  DY_ = DY + float(y0)*Scale;

  while(*pp > GRAPHEND) {
    if(*pp >= 0) {
      z = DX_ + (*(pp++)-4.0)*Scale;
      x0 = TO_INT(z);
      z = DY_ - (*(pp++)+4.0)*Scale;
      y0 = TO_INT(z);
      Painter->drawEllipse(x0, y0, d, d);
    }
    else  pp++;
  }
}
示例#27
0
// -------------------------------------------------------------
void ViewPainter::drawLines(int x0, int y0, float *pp)
{
  float z, DX_, DY_;
  int x1, x2, y1, y2;
  if(*pp < 0)
    pp++;

  DX_ = DX + float(x0)*Scale;
  DY_ = DY + float(y0)*Scale;

  while(*pp > GRAPHEND) {
    if(*pp >= 0) {
      z = DX_ + (*pp)*Scale;
      x1 = TO_INT(z);
      z = DY_ - (*(pp+1))*Scale;
      y1 = TO_INT(z);
      Painter->drawPoint(x1, y1);
    }
    while(*pp > BRANCHEND) {   // until end of branch
      z = DX_ + (*pp)*Scale;
      x1 = TO_INT(z);
      z = DY_ - (*(pp+1))*Scale;
      y1 = TO_INT(z);
      pp += 2;
      while(*pp > STROKEEND) { // until end of stroke
        z = DX_ + (*pp)*Scale;
        x2 = TO_INT(z);
        z = DY_ - (*(pp+1))*Scale;
        y2 = TO_INT(z);
        Painter->drawLine(x1, y1, x2, y2);
        pp += 2;
        if(*pp <= STROKEEND)  break;

        z = DX_ + (*pp)*Scale;
        x1 = TO_INT(z);
        z = DY_ - (*(pp+1))*Scale;
        y1 = TO_INT(z);
        Painter->drawLine(x2, y2, x1, y1);
        pp += 2;
      }
      if(*pp <= BRANCHEND)  break;   // end of line ?
      pp++;
    }
    pp++;
  }
}
示例#28
0
void CCBuffer::moveRight(unsigned int u_len)
{
	BEGIN_IF(LE(_u_content_size, 0))
	DO_RETURN;
	END_IF
	_reallocBufferSizeInChanged(u_len);
	BEGIN_FOR(DO_ASSIGN(int i, CS(_u_content_size, 1)), LDE(i, 0), SSI(i))
	DO_ASSIGN(QV(CA(CA(_p_buffer, i), TO_INT(u_len))), QV(CA(_p_buffer, i)));
	DO_ASSIGN(QV(CA(_p_buffer, i)), 0);
	END_FOR
	AA(_u_write_pos, u_len);
	AA(_u_read_pos, u_len);
	AA(_u_mark_pos, u_len);
	AA(_u_content_size, u_len);
}
示例#29
0
void print_form(uptr_t form) {

  if (IS_NIL(form)) {
    printf_P(PSTR("()"));
  } else if (IS_REG(form)) {
    printf_P(PSTR("R:%p"), TO_PTR(form));
  } else if (IS_INT(form)) {
    printf_P(PSTR("%d"), TO_INT(form));
  } else if (IS_SYM(form)) {
    char buf[7];
    memset(buf, 0, 7);
    unhash_sym(buf, form);
    printf_P(PSTR("%s"), buf);
  } else {
    printf_P(PSTR("("));
    print_list(form);
    printf_P(PSTR(")"));
  }

}
示例#30
0
void CCBuffer::moveLeft(unsigned int u_len)
{
	BEGIN_IF(LE(_u_content_size, 0))
	DO_RETURN;
	END_IF
	DO_ASSERT(LNE(u_len, 0), "LNE(u_len, 0)");
	BEGIN_IF(LDE(u_len, _u_content_size)) clear();
	BEGIN_ELSE
	BEGIN_FOR(DO_ASSIGN(unsigned int i, u_len), LX(i, _u_content_size), AAI(i))
	DO_ASSIGN(QV(CA(_p_buffer, CS(i, u_len))), QV(CA(_p_buffer, i)));
	DO_ASSIGN(QV(CA(_p_buffer, i)), 0);
	END_FOR
	DO_ASSIGN(_u_write_pos, TO_UINT(MAX(0, CS(TO_INT(_u_write_pos), TO_INT(u_len)))));
	DO_ASSIGN(_u_read_pos, TO_UINT(MAX(0, CS(TO_INT(_u_read_pos), TO_INT(u_len)))));
	DO_ASSIGN(_u_mark_pos, TO_UINT(MAX(0, CS(TO_INT(_u_mark_pos), TO_INT(u_len)))));
	DO_ASSIGN(_u_content_size, CS(_u_content_size, u_len));
	END_IF
}