• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PEEK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PEEK函数的典型用法代码示例。如果您正苦于以下问题:C++ PEEK函数的具体用法?C++ PEEK怎么用?C++ PEEK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PEEK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: p_b_term

/*
 - p_b_term - parse one term of a bracketed character list
 */
static void
p_b_term(struct parse *p, cset *cs)
{
	char c;
	char start, finish;
	int i;

	/* classify what we've got */
	switch ((MORE()) ? PEEK() : '\0') {
	case '[':
		c = (MORE2()) ? PEEK2() : '\0';
		break;
	case '-':
		SETERROR(REG_ERANGE);
		return;			/* NOTE RETURN */
		break;
	default:
		c = '\0';
		break;
	}

	switch (c) {
	case ':':		/* character class */
		NEXT2();
		REQUIRE(MORE(), REG_EBRACK);
		c = PEEK();
		REQUIRE(c != '-' && c != ']', REG_ECTYPE);
		p_b_cclass(p, cs);
		REQUIRE(MORE(), REG_EBRACK);
		REQUIRE(EATTWO(':', ']'), REG_ECTYPE);
		break;
	case '=':		/* equivalence class */
		NEXT2();
		REQUIRE(MORE(), REG_EBRACK);
		c = PEEK();
		REQUIRE(c != '-' && c != ']', REG_ECOLLATE);
		p_b_eclass(p, cs);
		REQUIRE(MORE(), REG_EBRACK);
		REQUIRE(EATTWO('=', ']'), REG_ECOLLATE);
		break;
	default:		/* symbol, ordinary character, or range */
/* xxx revision needed for multichar stuff */
		start = p_b_symbol(p);
		if (SEE('-') && MORE2() && PEEK2() != ']') {
			/* range */
			NEXT();
			if (EAT('-'))
				finish = '-';
			else
				finish = p_b_symbol(p);
		} else
			finish = start;
/* xxx what about signed chars here... */
		REQUIRE(start <= finish, REG_ERANGE);
		for (i = start; i <= finish; i++)
			CHadd(cs, i);
		break;
	}
}
开发者ID:OPSF,项目名称:uClinux,代码行数:62,代码来源:regcomp.c


示例2: cputc

/* Output one character at the current cursor position */
void __fastcall__ cputc( char c )
{
	unsigned char x;
	unsigned char y;
	unsigned char i;
	
	// FIXME: Call MMU to the make sure screen is the enabled device......
	
	// Set or unset reverse video bit, if needed.
	if( __conio_reverseVideo )
		c += 128;
	
	// Read the current cursor position.
	x = PEEK( 0x301 );
	y = PEEK( 0x302 );
	
	// Set the display memory window to the line the cursor is on.
	POKE( 0x300, y );

	// Write the character the the column the cursor is in, within the display
	//	memory window.
	if ( c != '\n')
		POKE( 0x310+x, c );
	
	// Advance the cursor, moving to the next line and scrolling the screen
	//	if needed.
	++x;
	if( x > 79 || c == '\n' )
	{
		x = 0;
		if( y >= 49 )
		{
			// Scroll...
			blit_shift(0,1,0,0,80,49);

			for (i = 0; i<80; i++)
				POKE( 0x310 + i, 0x20 );
				
		}
		else
		{	// no need to set if Y was 49. 
			++y;
			POKE( 0x302, y );
			POKE( 0x300, y );	// set row too
		}
	}
	
	// Set the cursor to the new position.
	POKE( 0x301, x );
}
开发者ID:Arkuda,项目名称:rpc8e-cc65,代码行数:51,代码来源:conio.c


示例3: line_mingle

/* readline()s mingled with other operations: buffering tests. */
static int line_mingle(void)
{
    ne_socket *sock;
    DECL(oneline, "alpha\nbeta\ndelta\ngamma\n");

    CALL(begin(&sock, serve_sstring, &oneline));
    
    READ("a"); LINE("lpha\n");
    READ("beta"); LINE("\n");
    PEEK("d"); PEEK("delt");
    LINE("delta\n");
    READ("gam"); LINE("ma\n");
    
    return finish(sock, 1);
}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:16,代码来源:socket.c


示例4: p_b_cclass

/*
 - p_b_cclass - parse a character-class name and deal with it
 */
static void
p_b_cclass(struct parse *p, cset *cs)
{
	char *sp = p->next;
	struct cclass *cp;
	size_t len;
	const char *u;
	char c;

	while (MORE() && isalpha(PEEK()))
		NEXT();
	len = p->next - sp;
	for (cp = cclasses; cp->name != NULL; cp++)
		if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0')
			break;
	if (cp->name == NULL) {
		/* oops, didn't find it */
		SETERROR(REG_ECTYPE);
		return;
	}

	u = cp->chars;
	while ((c = *u++) != '\0')
		CHadd(cs, c);
	for (u = cp->multis; *u != '\0'; u += strlen(u) + 1)
		MCadd(p, cs, u);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:30,代码来源:regcomp.c


示例5: blocking

static int blocking(void)
{
    ne_socket *sock;
    int ret;
    
    CALL(begin(&sock, echo_server, NULL));
    CALL(expect_block_timeout(sock, 1, "with non-zero timeout"));
         
    WRITEL("Hello, world.\n");
    
    /* poll for data */
    do {
        ret = ne_sock_block(sock, 1);
    } while (ret == NE_SOCK_TIMEOUT);

    ONV(ret != 0, ("ne_sock_block never got data: %d", ret));

    PEEK("Hello,");
    ret = ne_sock_block(sock, 1);
    ONV(ret != 0, ("ne_sock_block failed after peek: %d", ret));

    LINE("Hello, world.\n");

    return finish(sock, 0);
}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:25,代码来源:socket.c


示例6: get_argument

NODE *
get_argument(int i)
{
	NODE *t;
	int arg_count, pcount;
	INSTRUCTION *pc;
	
	pc = TOP()->code_ptr;		/* Op_ext_builtin instruction */
	pcount = (pc + 1)->expr_count;	/* max # of arguments */
	arg_count = pc->expr_count;	/* # of arguments supplied */

	if (i < 0 || i >= pcount || i >= arg_count)
		return NULL;

	t = PEEK(arg_count - i);
	if (t->type == Node_param_list)
		t = GET_PARAM(t->param_cnt);

	if (t->type == Node_array_ref) {
		if (t->orig_array->type == Node_var) {
			/* already a scalar, can no longer use it as array */ 
			t->type = Node_var;
			t->var_value = Nnull_string;
			return t;
		}
		return t->orig_array; 	/* Node_var_new or Node_var_array */
	}
	if (t->type == Node_var)	/* See Case Node_var in setup_frame(), eval.c */
		return Nnull_string;
	/* Node_var_new, Node_var_array or Node_val */
	return t;
}
开发者ID:infoburp,项目名称:gawk,代码行数:32,代码来源:ext.c


示例7: summaryScreen

void __fastcall__ summaryScreen(void)
{
  // display kills, items, secrets, time
  // like this
  // MAP NAME
  // FINISHED
  // KILLS %
  // ITEMS %
  // SECRET %
  // TIME 00:00
  // PAR 00:00
  
  char kills = p_enemy_getKillPercentage();
  char items = getItemPercentage();
  char secret = (100*getNumVisitedSecrets())/getNumSecrets();
  int time = getMapTime();
  int par = getParTime();

  // clear screen
  clearScreen();
  
  textcolor(1);
  printCentered(caLevelNames[level-1], 1);
  textcolor(2);
  printCentered("finished", 2);
  cputsxy(4, 5, "kills");
  cputsxy(4, 7, "items");
  cputsxy(4, 9, "secret");
  cputsxy(4, 12, "time");
  cputsxy(4, 14, "par");

  setTextColor(2);
  POKE(198, 0);
  rollInPercentage(kills, 0x1000+22*5+14);
  waitASecond();
  rollInPercentage(items, 0x1000+22*7+14);
  waitASecond();
  rollInPercentage(secret, 0x1000+22*9+14);
  waitASecond();
  if (time > 10*60-1)
  {
    cputsxy(13,12,"sucks");
    playSound(SOUND_PISTOL);
  }
  else
  {
    rollInTime(time, 0x1000+22*12+13);
  }
  waitASecond();
  rollInTime(par, 0x1000+22*14+13);
  waitASecond();
  printCentered("press a key", 20);
  POKE(198, 0);
  while (PEEK(198) == 0) ;

  // clear screen
  clearScreen();
}
开发者ID:Kweepa,项目名称:vicdoom,代码行数:58,代码来源:summary.c


示例8: cgetc

/* Return a character from the keyboard. If there is no character available,
 * the function waits until the user does press a key. If cursor is set to
 * 1 (see below), a blinking cursor is displayed while waiting.
 */
char cgetc( void )
{
        unsigned char key;
	unsigned char pos;

	while (!kbhit())
	{
		// WAI
	}

	key = PEEK(0x306);
	pos = PEEK(0x304)+1;
	if (pos > 0x10)
		pos = 0;
	POKE(0x304,pos);
	
	return key;
}
开发者ID:Arkuda,项目名称:rpc8e-cc65,代码行数:22,代码来源:conio.c


示例9: cursor

/* If onoff is 1, a cursor is displayed when waiting for keyboard input. If
 * onoff is 0, the cursor is hidden when waiting for keyboard input. The
 * function returns the old cursor setting.
 */
unsigned char __fastcall__ cursor( unsigned char onoff )
{
	// FIXME: Call MMU to the make sure screen is the enabled device......
	unsigned char oldStatus = PEEK( 0x303 );
	if( onoff )
		POKE( 0x303, 2 );
	else
		POKE( 0x303, 0 );
	return oldStatus;
}
开发者ID:Arkuda,项目名称:rpc8e-cc65,代码行数:14,代码来源:conio.c


示例10: waitASecond

void __fastcall__ waitASecond(void)
{
  char i = 60;
  do
  {
	  if (PEEK(198) == 0)
	  {
		  waitForRaster(1);
	  }
  	--i;
  }
  while (i > 0);
}
开发者ID:Kweepa,项目名称:vicdoom,代码行数:13,代码来源:summary.c


示例11: p_count

/*
 - p_count - parse a repetition count
 */
static int			/* the value */
p_count(struct parse *p)
{
	int count = 0;
	int ndigits = 0;

	while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) {
		count = count*10 + (GETNEXT() - '0');
		ndigits++;
	}

	REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR);
	return(count);
}
开发者ID:OPSF,项目名称:uClinux,代码行数:17,代码来源:regcomp.c


示例12: p_ere

/*
 - p_ere - ERE parser top level, concatenation and alternation
 == static void p_ere(struct parse *p, int stop, size_t reclimit);
 */
static void
p_ere(
    struct parse *p,
    int stop,			/* character this ERE should end at */
    size_t reclimit)
{
	char c;
	sopno prevback = 0;	/* pacify gcc */
	sopno prevfwd = 0; 	/* pacify gcc */
	sopno conc;
	int first = 1;		/* is this the first alternative? */

	_DIAGASSERT(p != NULL);

	if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) {
		p->error = REG_ESPACE;
		return;
	}

	for (;;) {
		/* do a bunch of concatenated expressions */
		conc = HERE();
		while (MORE() && (c = PEEK()) != '|' && c != stop)
			p_ere_exp(p, reclimit);
		REQUIRE(HERE() != conc, REG_EMPTY);	/* require nonempty */

		if (!EAT('|'))
			break;		/* NOTE BREAK OUT */

		if (first) {
			INSERT(OCH_, conc);	/* offset is wrong */
			prevfwd = conc;
			prevback = conc;
			first = 0;
		}
		ASTERN(OOR1, prevback);
		prevback = THERE();
		AHEAD(prevfwd);			/* fix previous offset */
		prevfwd = HERE();
		EMIT(OOR2, 0);			/* offset is very wrong */
	}

	if (!first) {		/* tail-end fixups */
		AHEAD(prevfwd);
		ASTERN(O_CH, prevback);
	}

	assert(!MORE() || SEE(stop));
}
开发者ID:0omega,项目名称:platform_bionic,代码行数:53,代码来源:regcomp.c


示例13: init_usage

/* Mark resource as initialized */
static void
init_usage( ldap_debug_usage_info_t *usage, const char *msg )
{
	if( !options_done )
		get_options();
	if( !nomem ) {
		if( !noreinit ) {
			MEMERROR_IF( debug_already_initialized( usage ), msg, {
				/* Provoke malloc debuggers */
				unsigned char *dummy = DUMMY_ADDR( usage );
				PEEK( dummy );
				free( dummy );
				free( dummy );
			} );
		}
开发者ID:Dan-McGee,项目名称:lightwave,代码行数:16,代码来源:thr_debug.c


示例14: randomize

/*
 * create a bunch of random live cells in the requested
 * graphics page
 */
void randomize(uint16_t baseaddr[], uint16_t count)
{
    uint16_t r;
    uint8_t  row, col;
    static uint8_t resetcount = 0;

    // The Apple zero page has some semi-random garbage
    // suitable for seeding our PRNG
    uint16_t seed = PEEK(RSEED1) + PEEK(RSEED2) * 256;
    ++resetcount;
    srand(resetcount + seed);
    lo_clear(gr_page[0], TGI_COLOR_BLACK);

    while (count--) {
        r = rand();
        // use the high bit to determine which nibble we turn on
        row = r & ROWRANDMASK;
        col = (r & COLRANDMASK) >> 8;
        row %= MAXROWCNT;
        col %= MAXCOLCNT;
        //printf("turning on %d,%d with %04x\n", row, col, r);
        lo_plot(baseaddr, row, col, 0xf);
    }
}
开发者ID:boblaublaw,项目名称:a2conway,代码行数:28,代码来源:a2conway.c


示例15: line_overflow

static int line_overflow(void)
{
    ne_socket *sock;
    ssize_t ret;
    DECL_LONG(line, 'A', OVERLEN);

    CALL(begin(&sock, serve_sstring, &line));

    PEEK("A"); /* fill the read buffer */
    ret = ne_sock_readline(sock, buffer, OVERLEN);
    ONV(ret != NE_SOCK_ERROR,
        ("readline should fail on overlong line: %" NE_FMT_SSIZE_T, ret));

    ne_free(line.data);
    return finish(sock, 0);
}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:16,代码来源:socket.c


示例16: rollInPercentage

void __fastcall__ rollInPercentage(char pc, int scr)
{
  signed char i = -4;
  POKE(scr + 3,'%');
  do
  {
    i += 4;
    if (i > pc) i = pc;
    print3DigitNumToScreen(i, scr);
    playSound(SOUND_PISTOL);
    if (PEEK(198) == 0)
    {
		  waitForRaster(2);
    }
  }
  while (i < pc);
}
开发者ID:Kweepa,项目名称:vicdoom,代码行数:17,代码来源:summary.c


示例17: blit_shift

void blit_shift(unsigned char sx, unsigned char sy, unsigned char dx, unsigned char dy, unsigned char width, unsigned char height)
{
	// FIXME: Call MMU to the make sure screen is the enabled device......

	POKE( 0x30a, dx);
	POKE( 0x30b, dy);
	
	POKE( 0x308, sx );
	POKE( 0x309, sy );

	POKE( 0x30c, width );
	POKE( 0x30d, height );

	POKE( 0x307, 3 );		// blitter SHIFT command
	while ( PEEK( 0x307 ) == 3 )
	{
		// WAI
	}
	
}
开发者ID:Arkuda,项目名称:rpc8e-cc65,代码行数:20,代码来源:conio.c


示例18: OGWriteSector

//---------------------------------------------------------------------------
void OGWriteSector(int Side,int Track,int Sector,int Bytes)
{
  FILE *f=fopen(WriteDir+SLASH+"hiscores","r+b");
  if (f==NULL) return;

  int SavePos;
  for(;;){
    int SavedSide=-1,SavedTrack=-1,SavedSector=-1,SavedBytes=-1;
    SavePos=ftell(f);
    fread(&SavedSide,1,sizeof(int),f);
    fread(&SavedTrack,1,sizeof(int),f);
    fread(&SavedSector,1,sizeof(int),f);
    fread(&SavedBytes,1,sizeof(int),f);
    if (SavedSide==-1 || SavedTrack==-1 || SavedSector==-1 || SavedBytes==-1) break;
    if (SavedSide==Side && SavedTrack==Track && SavedSector==Sector){
      if (SavedBytes==Bytes){
        // Can save over here
        break;
      }else{
        fseek(f,SavePos+sizeof(int)*2,SEEK_SET);
        SavedSector=256; // Clear this one
        fwrite(&SavedSector,1,sizeof(int),f);
        fseek(f,SavePos+sizeof(int)*4+SavedBytes,SEEK_SET);
      }
    }else{
      fseek(f,SavedBytes,SEEK_CUR);
    }
  }
  fseek(f,SavePos,SEEK_SET);
  fwrite(&Side,1,sizeof(int),f);
  fwrite(&Track,1,sizeof(int),f);
  fwrite(&Sector,1,sizeof(int),f);
  fwrite(&Bytes,1,sizeof(int),f);
  for (int n=0;n<Bytes;n++){
    if (dma_address+n < mem_len){
      BYTE b=PEEK(dma_address+n);
      fwrite(&b,1,1,f);
    }
  }
  fclose(f);
}
开发者ID:gbouthenot,项目名称:Steem-Engine,代码行数:42,代码来源:onegame.cpp


示例19: rollInTime

void __fastcall__ rollInTime(int t, int scr)
{
  int i = -5;
  char ih, il;
  POKE(scr + 2,':');
  do
  {
    i += 5;
    if (i > t) i = t;
    ih = i / 60;
    il = i - 60 * ih;
    print2DigitNumToScreen(ih, scr);
    print2DigitNumToScreen(il, scr + 3);
    playSound(SOUND_PISTOL);
    if (PEEK(198) == 0)
    {
		  waitForRaster(2);
    }
  }
  while (i < t);
}
开发者ID:Kweepa,项目名称:vicdoom,代码行数:21,代码来源:summary.c


示例20: read_and_peek

/* Stress out the read buffer handling a little. */
static int read_and_peek(void)
{
    ne_socket *sock;
    DECL(hello, STR);

    CALL(begin(&sock, serve_sstring, &hello));

    PEEK("Hello");
    PEEK("Hell");
    PEEK(STR);
    READ("He");
    PEEK("llo, ");
    READ("l");
    PEEK("lo, World.");
    READ("lo, Worl");
    PEEK("d."); PEEK("d");
    READ("d.");

    return finish(sock, 1);
}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:21,代码来源:socket.c



注:本文中的PEEK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PEEK_TOKEN函数代码示例发布时间:2022-05-30
下一篇:
C++ PED_BE32_TO_CPU函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap