コード例 #1
0
ファイル: File.cpp プロジェクト: yoantie/baselib
bool CFile::ReadPart(void *data, UInt32 size, UInt32& processedSize)
{
	if (size > kChunkSizeMax)
		size = kChunkSizeMax;
	
	return Read1(data, size, processedSize);
}
コード例 #2
0
ファイル: RoboClaw.cpp プロジェクト: Aleyha/TeamFabulous
bool RoboClaw::GetPWMMode(uint8_t address, uint8_t &mode){
	bool valid;
	uint8_t value = Read1(address,GETPWMMODE,&valid);
	if(valid){
		mode = value;
	}
	return valid;
}
コード例 #3
0
ファイル: serial.c プロジェクト: MikulasZelinka/glulxe
static glui32 read_stackstate(dest_t *dest, glui32 chunklen, int portable)
{
  glui32 res;
  glui32 frameend, frm, frm2, frm3, locpos, frlen, numlocals;

  if (chunklen > stacksize)
    return 1;

  stackptr = chunklen;
  frameptr = 0;
  valstackbase = 0;
  localsbase = 0;

  if (!portable) {
    res = read_buffer(dest, stack, stackptr);
    if (res)
      return res;
    return 0;
  }

  /* This isn't going to be pleasant; we're going to read the data in
     as a block, and then convert it in-place. */
  res = read_buffer(dest, stack, stackptr);
  if (res)
    return res;

  frameend = stackptr;
  while (frameend != 0) {
    /* Read the beginning-of-frame pointer. Remember, right now, the
       whole frame is stored big-endian. So we have to read with the
       Read*() macros, and then write with the StkW*() macros. */
    frm = Read4(stack+(frameend-4));

    frm2 = frm;

    frlen = Read4(stack+frm2);
    StkW4(frm2, frlen);
    frm2 += 4;
    locpos = Read4(stack+frm2);
    StkW4(frm2, locpos);
    frm2 += 4;

    /* The locals-format list is in bytes, so we don't have to convert it. */
    frm3 = frm2;
    frm2 = frm+locpos;

    numlocals = 0;

    while (1) {
      unsigned char loctype, loccount;
      loctype = Read1(stack+frm3);
      frm3 += 1;
      loccount = Read1(stack+frm3);
      frm3 += 1;

      if (loctype == 0 && loccount == 0)
        break;

      /* Skip up to 0, 1, or 3 bytes of padding, depending on loctype. */
      while (frm2 & (loctype-1)) {
        StkW1(frm2, 0);
        frm2++;
      }
      
      /* Convert this set of locals. */
      switch (loctype) {
        
      case 1:
        do {
          /* Don't need to convert bytes. */
          frm2 += 1;
          loccount--;
        } while (loccount);
        break;

      case 2:
        do {
          glui16 loc = Read2(stack+frm2);
          StkW2(frm2, loc);
          frm2 += 2;
          loccount--;
        } while (loccount);
        break;

      case 4:
        do {
          glui32 loc = Read4(stack+frm2);
          StkW4(frm2, loc);
          frm2 += 4;
          loccount--;
        } while (loccount);
        break;

      }

      numlocals++;
    }

    if ((numlocals & 1) == 0) {
      StkW1(frm3, 0);
      frm3++;
      StkW1(frm3, 0);
      frm3++;
    }

    if (frm3 != frm+locpos) {
      return 1;
    }

    while (frm2 & 3) {
      StkW1(frm2, 0);
      frm2++;
    }

    if (frm2 != frm+frlen) {
      return 1;
    }

    /* Now, the values pushed on the stack after the call frame itself.
       This includes the stub. */
    while (frm2 < frameend) {
      glui32 loc = Read4(stack+frm2);
      StkW4(frm2, loc);
      frm2 += 4;
    }

    frameend = frm;
  }

  return 0;
}
コード例 #4
0
//从二维数组ch1中读信息,并根据ch1中的各个值输出相应的符号。
int main()
{
	char ch1[9][24];
	int a,b;
	Read(ch1);
	Read1(ch1,&a,&b);
	char m;
	while(!kbhit())
		{
			getch();
			char m=getch();//3是空格  2是人  1是墙 
			switch(m)
			{
				case up:
					{
						if(ch1[a-1][b]==3)
						{
							char t=ch1[a][b];
							ch1[a][b]=ch1[a-1][b];
							ch1[a-1][b]=t;
							system("cls");
							Read1(ch1,&a,&b);
						}
						break;
					}
				case down:
					{
						if(ch1[a+1][b]==3)
						{
							char t=ch1[a][b];
							ch1[a][b]=ch1[a+1][b];
							ch1[a+1][b]=t;
							system("cls");
							Read1(ch1,&a,&b);
						}
						break;
					}
				case left:
					{
						if(ch1[a][b-1]==3)
						{
							char t=ch1[a][b-1];
							ch1[a][b-1]=ch1[a][b];
							ch1[a][b]=t;
							system("cls");
							Read1(ch1,&a,&b);
						}
						break;					
					}	
				case right:
					{
						if(ch1[a][b+1]==3)
							{
								char t=ch1[a][b+1];
								ch1[a][b+1]=ch1[a][b];
								ch1[a][b]=t;
								system("cls");
								Read1(ch1,&a,&b);
							}	
						break;
					}
			}
		}
	return 0;
}