Example #1
0
void CGamePolePlayer::setValue( int x, int y, char v )
{
   if( x<0 || x>=GAME_POLE_SIZE || y<0 || y>=GAME_POLE_SIZE ) return;
   switch( v )
   {
   case EMPTY_SHOOTED: setChar( x*2+1, y*2+1, EMPTY_SHOOTED_CHAR ); break;
   case SHIP_NON_SHOOTED: setChar( x*2+1, y*2+1, PLAYER_SHIP_NON_SHOOTED_CHAR ); break;
   case SHIP_SHOOTED: setChar( x*2+1, y*2+1, SHIP_SHOOTED_CHAR ); break;
   }   
}
Example #2
0
void VirtualValue::setTo(const Variant& value, StringCache& stringcache)
{
   if ( value.isInt() )
   {
      setNumber(value.asInt());
   }
   else if ( value.isReal() )
   {
      setReal(value.asReal());
   }
   else if ( value.isBool() )
   {
      setBoolean(value.asBool());
   }
   else if ( value.isChar() )
   {
      setChar(value.asChar());
   }
   else if ( value.isString() )
   {
      setString(stringcache.lookup(value.asString()));
   }
   else
   {
      mKind = eEmpty;
   }
}
Example #3
0
void StringData::setChar(int offset, CStrRef substring) {
  ASSERT(!isStatic());
  if (offset >= 0) {
    int len = size();
    if (len == 0) {
      // PHP will treat data as an array and we don't want to follow that.
      throw OffsetOutOfRangeException();
    }

    if (offset < len) {
      if (!substring.empty()) {
        setChar(offset, substring.data()[0]);
      } else {
        removeChar(offset);
      }
    } else if (offset > RuntimeOption::StringOffsetLimit) {
      throw OffsetOutOfRangeException();
    } else {
      int newlen = offset + 1;
      char *buf = (char *)Util::safe_malloc(newlen + 1);
      memset(buf, ' ', newlen);
      buf[newlen] = 0;
      memcpy(buf, data(), len);
      if (!substring.empty()) buf[offset] = substring.data()[0];
      assign(buf, newlen, AttachString);
    }
  }
}
Example #4
0
size_t TM1628::write(byte chr){
	if(_curpos<0x07) {
		setChar(_curpos, chr);
		_curpos++;
	}
	
}
Example #5
0
void DisplayBuffer::backspace()
{
    if (m_cursor_x > 0)
    {
        m_cursor_x --;
        setChar(m_cursor_x, m_cursor_y, ' ', m_cursorColor);
    }
}
Example #6
0
void MAX7219::setNumber(uint32_t number, int addr) {
	// number = number % (uint32_t) pow(10, maxDevices);
	for (uint8_t i = 0; i < 8; i++) {
		if (number == 0 && i > 0) {
			setChar(i, ' ', addr);
		} else {
			setDigit(i, number % 10, addr);
			number = number / 10;
		}
	}
}
Example #7
0
Coin::Coin() {
    switch(rand() % 3) {
        case 0:
            setChar('.');
            setValue(25);
            break;
        case 1:
            setChar('o');
            setValue(100);
            break;
        case 2:
            setChar('O');
            setValue(250);
            break;
    }

    setType("Coin");
    init_pair(2, COLOR_YELLOW, -1);
    setColo(COLOR_PAIR(2));
    setPosRand();
}
Example #8
0
void
MyString::compressSpaces( void )
{
	if( Len == 0 ) {
		return;
	}
	for ( int i = 0, j = 0; i <= Length(); ++i, ++j ) {
		if ( isspace ( Data[i] ) ) {
			i++;
		}
		setChar ( j, Data[i] );
	}
}
Example #9
0
Player::Player() : Actor() {
    init_pair(0, COLOR_WHITE, -1);
    setColo(COLOR_PAIR(0));
    setChar('@');
    setType("Player");
    setName("Noop");

    // Init Luck and Defense 0 to 3
    attr.LCK = (rand() % 3);
    attr.DEF = (rand() % 3);

    setPosRand();
}
void LCDShield::setStr(char *pString, uint8_t x, uint8_t y, int fColor, int bColor)
{
	x = x + 16;
	y = y + 8;
	// loop until null-terminator is seen
	while (*pString != 0x00) {
		// draw the character
		setChar(*pString++, x, y, fColor, bColor);
		// advance the y position
		y = y + 8;
		// bail out if y exceeds 131
		if (y > 131) break;
	}
}
Example #11
0
void Settings::storeDefaultValues(void)
{
    Debug::out(LOG_DEBUG, "Settings::storeDefaultValues() - storing default settings, because it seems we miss those setting...");
    
    char key[32];
    for(int id=0; id<8; id++) {							// read the list of device types from settings
        sprintf(key, "ACSI_DEVTYPE_%d", id);			// create settings KEY, e.g. ACSI_DEVTYPE_0
		
		if(id == 1) {									// ACSI id 0 enaled by defaul
			setInt(key, DEVTYPE_TRANSLATED);
		} else {										// other ACSI id's disabled
			setInt(key, DEVTYPE_OFF);
		}
	}
	
	setChar("DRIVELETTER_FIRST",      'C');
    setChar("DRIVELETTER_SHARED",     'P');
    setChar("DRIVELETTER_CONFDRIVE",  'O');

	setBool("MOUNT_RAW_NOT_TRANS",     false);
	
	setBool("SHARED_ENABLED",			false);
	setBool("SHARED_NFS_NOT_SAMBA",	false);
}
void Itoa(int num, char *str)
{
    int p = 0, q = 0, r = 0;
    int i = 0;
    //printf("IsPalindrome str = %d\n",str);
    
    while(num)
    {
        p = (num/10)*10;
        q = num - p;
        setChar(q, str, i); // put q converted to character in str[i]
        num = num/10;
        i++;
    }
    str[i] = '\0';
}
Example #13
0
int AscFile::load(char *filename) {
	FILE *fp;

	fp = fopen(filename, "r");

	if(fp == NULL) {
		return -1;
	}

	float version;
	fscanf(fp, "ASCII-Paint v%g", &version);

	fscanf(fp, "%i %i", &width, &height);

	setSize(width, height);

	// Scan until we hit #(the marker for the start of image data)
	while(fgetc(fp) != '#');

	for(int x = 0; x < width; x++) {
		for(int y = 0; y < height; y++) {
			char c = fgetc(fp);
			int fr = fgetc(fp);
			int fg = fgetc(fp);
			int fb = fgetc(fp);
			int br = fgetc(fp);
			int bg = fgetc(fp);
			int bb = fgetc(fp);
			int solid = fgetc(fp);
			int walkable = fgetc(fp);
			setChar(x, y, c);
			setFore(x, y, fr, fg, fb);
			setBack(x, y, br, bg, bb);
			setSolid(x, y, solid);
			setSolid(x, y, walkable);
		}
	}
	fclose(fp);

	return 1;

}
Example #14
0
size_t DisplayBuffer::write(uint8_t c, bool ignoreNewlines)
{
    if(!ignoreNewlines && c == '\n') 
    {
        m_cursor_x = 0;
        m_cursor_y ++;
        resolveCursor();
    } 
    else if(!ignoreNewlines && c == '\r') 
    {
        // skip
    } 
    else 
    {
        resolveCursor();
        setChar(m_cursor_x, m_cursor_y, c, m_cursorColor);
        m_cursor_x ++;
        resolveCursor();
    }
}
Example #15
0
CGamePolePlayer::CGamePolePlayer( CSeaFightApp & host ) :
   CGamePoleBase( host, GAME_POLE_INTERVAL, GAME_POLE_INTERVAL )
{
   for( int y = 0; y <= GAME_POLE_SIZE*2; y++ )
   {
      for( int x = 0; x <= GAME_POLE_SIZE*2; x++ )
      {
         if( !(x%2) && (y%2) )                                    setChar(x, y, 0x2502);
         else if( (x%2) && !(y%2) )                               setChar( x, y, 0x2500 );
         else if( !(x%2) && !(y%2) && x>0 && x<GAME_POLE_SIZE*2 && y>0 && y<GAME_POLE_SIZE*2 )
                                                                  setChar(x, y, 0x253C);
         else if( !x && !(y%2) && y>0 && y<GAME_POLE_SIZE*2 )     setChar( x, y, 0x251C );
         else if( x==GAME_POLE_SIZE*2 && !(y%2) && y>0 && y<GAME_POLE_SIZE*2 )
                                                                  setChar( x, y, 0x2524 );
         else if( !y && !(x%2) && x>0 && x<GAME_POLE_SIZE*2 )     setChar( x, y, 0x252C );
         else if( y==GAME_POLE_SIZE*2 && !(x%2) && x>0 && x<GAME_POLE_SIZE*2 )
                                                                  setChar( x, y, 0x2534 );
         else if( !x && !y )                                      setChar( x, y, 0x250C );
         else if( !x && y==GAME_POLE_SIZE*2 )                     setChar( x, y, 0x2514 );
         else if( x==GAME_POLE_SIZE*2 && !y )                     setChar( x, y, 0x2510 );
         else if( x==GAME_POLE_SIZE*2 && y==GAME_POLE_SIZE*2 )    setChar( x, y, 0x2518 );
         else                                                     setChar( x, y, EMPTY_NON_SHOOTED );
      }
   }
}
Example #16
0
Queen::Queen(int num){
	setPlayer(num);
	setChar('q' - num * 32);
	setValue( 9);
}
Example #17
0
King::King(int num){
	setPlayer(num);
	setChar('k' - num * 32);
	setValue(3);
}
Example #18
0
Bishop::Bishop(int num){
	setPlayer(num);
	setChar('b' - num * 32);
	setValue( 3.5);
}
Example #19
0
Castle::Castle(int num){
	setPlayer(num);
	setChar('c' - num * 32);
	setValue( 5);
}
Example #20
0
Null::Null(int num){
	setPlayer(num);
	setChar(32);
	setValue(0);
}
Example #21
0
void Console::setString(std::string str, int xStart, int yStart) {
    for(int i = 0; i < str.length();i++) {
        setChar(str.c_str()[i],xStart+i,yStart);
    }
}
Example #22
0
File: r86.c Project: crgimenes/r86
void run(const char *s) {
    unsigned char v;
    unsigned char par_count=0;

    unsigned char ah;
    unsigned char al;
    int16_t cx;
    int16_t bx;
    int16_t dx;

    unsigned char lbyte;
    unsigned char hbyte;

    for (unsigned int c=0; c<1024; c++) {
        v = (unsigned char)(*(s+c));
        if(print_asm==1) printf("%04xh %02x ",c,v);
        if(par_count>0) {
            par_count--;
            printf("%02xh ",v);
        } else {
            switch (v) {
            case 0xB0:
                c++;
                v = (unsigned char)(*(s+c));
                al = v;
                if(print_asm==1) printf("mov al, %4Xh",al);
                break;
            case 0xB4:
                c++;
                v = (unsigned char)(*(s+c));
                ah = v;
                if(print_asm==1) printf("mov ah, %4Xh",ah);
                break;
            case 0xB9:
                c++;
                lbyte = (unsigned char)(*(s+c));
                c++;
                hbyte = (unsigned char)(*(s+c));
                cx = (int16_t)(hbyte << 8 | lbyte);
                if(print_asm==1) printf("mov cx, %4Xh",cx);
                break;
            case 0xBA:
                c++;
                lbyte = (unsigned char)(*(s+c));
                c++;
                hbyte = (unsigned char)(*(s+c));
                dx = (int16_t)(hbyte << 8 | lbyte);
                if(print_asm==1) printf("mov dx, %4Xh",dx);
                break;
            case 0xBB:
                c++;
                lbyte = (unsigned char)(*(s+c));
                c++;
                hbyte = (unsigned char)(*(s+c));
                bx = (int16_t)(hbyte << 8 | lbyte);
                if(print_asm==1) printf("mov bx, %4Xh",bx);
                break;
            case 0xCC:
                printf("int 3 debug...");
                par_count=2;
                break;
            case 0xCD:
                c++;
                v = (unsigned char)(*(s+c));
                if(print_asm==1) printf("int %2Xh",v);
                if(v==0x20) { // return to "DOS" :D
                    exit(0);
                }
                if(v==0x21) { // DOS
                    if(ah == 0x4C) { // exit program
                        printf("\r\n");
                        exit(al);
                    }
                    if(ah == 0x40) { // write to a file or device
                        /*
                        BX = file handle
                        CX = number of bytes to write
                        DS:DX -> data to write
                        */

                        for(int i=0; i<cx; i++) {
                            v = (unsigned char)(*(s+(dx-0x100)+i));
                            if (use_curses) {
                                setChar(v);
                                cursor_x++;
                            } else {
                                printf("%c",v);
                            }

                        }
                    }
                }
                break;
            default:
                printf("%02xh",v);
                if (v>=32) {
                    printf(" \"%c\"",v);
                }
                break;
            }
        }

        if(print_asm==1) printf("\r\n");
    }
}
Example #23
0
void Surface::initCharset()
{
	setChar(0, ":ooo:", "o:::o", "ooooo", "o:::o", "o:::o");
	setChar(1, "oooo:", "o:::o", "oooo:", "o:::o", "oooo:");
	setChar(2, ":oooo", "o::::", "o::::", "o::::", ":oooo");
	setChar(3, "oooo:", "o:::o", "o:::o", "o:::o", "oooo:");
	setChar(4, "ooooo", "o::::", "oooo:", "o::::", "ooooo");
	setChar(5, "ooooo", "o::::", "ooo::", "o::::", "o::::");
	setChar(6, ":oooo", "o::::", "o:ooo", "o:::o", ":ooo:");
	setChar(7, "o:::o", "o:::o", "ooooo", "o:::o", "o:::o");
	setChar(8, "::o::", "::o::", "::o::", "::o::", "::o::");
	setChar(9, ":::o:", ":::o:", ":::o:", ":::o:", "ooo::");
	setChar(10, "o::o:", "o:o::", "oo:::", "o:o::", "o::o:");
	setChar(11, "o::::", "o::::", "o::::", "o::::", "ooooo");
	setChar(12, "oo:o:", "o:o:o", "o:o:o", "o:::o", "o:::o");
	setChar(13, "o:::o", "oo::o", "o:o:o", "o::oo", "o:::o");
	setChar(14, ":ooo:", "o:::o", "o:::o", "o:::o", ":ooo:");
	setChar(15, "oooo:", "o:::o", "oooo:", "o::::", "o::::");
	setChar(16, ":ooo:", "o:::o", "o:::o", "o::oo", ":oooo");
	setChar(17, "oooo:", "o:::o", "oooo:", "o:o::", "o::o:");
	setChar(18, ":oooo", "o::::", ":ooo:", "::::o", "oooo:");
	setChar(19, "ooooo", "::o::", "::o::", "::o::", "::o::");
	setChar(20, "o:::o", "o:::o", "o:::o", "o:::o", ":oooo");
	setChar(21, "o:::o", "o:::o", ":o:o:", ":o:o:", "::o::");
	setChar(22, "o:::o", "o:::o", "o:o:o", "o:o:o", ":o:o:");
	setChar(23, "o:::o", ":o:o:", "::o::", ":o:o:", "o:::o");
	setChar(24, "o:::o", "o:::o", ":oooo", "::::o", ":ooo:");
	setChar(25, "ooooo", ":::o:", "::o::", ":o:::", "ooooo");
	setChar(26, ":ooo:", "o::oo", "o:o:o", "oo::o", ":ooo:");
	setChar(27, "::o::", ":oo::", "::o::", "::o::", ":ooo:");
	setChar(28, ":ooo:", "o:::o", "::oo:", ":o:::", "ooooo");
	setChar(29, "oooo:", "::::o", "::oo:", "::::o", "oooo:");
	setChar(30, "o::::", "o::o:", "ooooo", ":::o:", ":::o:");
	setChar(31, "ooooo", "o::::", "oooo:", "::::o", "oooo:");
	setChar(32, ":oooo", "o::::", "oooo:", "o:::o", ":ooo:");
	setChar(33, "ooooo", "::::o", ":::o:", "::o::", "::o::");
	setChar(34, ":ooo:", "o:::o", ":ooo:", "o:::o", ":ooo:");
	setChar(35, ":ooo:", "o:::o", ":oooo", "::::o", ":ooo:");
	setChar(36, "::o::", "::o::", "::o::", ":::::", "::o::");
	setChar(37, ":ooo:", "::::o", ":::o:", ":::::", "::o::");
	setChar(38, ":::::", ":::::", "::o::", ":::::", "::o::");
	setChar(39, ":::::", ":::::", ":ooo:", ":::::", ":ooo:");
	setChar(40, ":::::", ":::::", ":::::", ":::o:", "::o::");
	setChar(41, ":::::", ":::::", ":::::", ":::::", "::o::");
	setChar(42, ":::::", ":::::", ":ooo:", ":::::", ":::::");
	setChar(43, ":::o:", "::o::", "::o::", "::o::", ":::o:");
	setChar(44, "::o::", ":::o:", ":::o:", ":::o:", "::o::");
	setChar(45, ":::::", ":::::", ":::::", ":::::", ":::::");
	setChar(46, "ooooo", "ooooo", "ooooo", "ooooo", "ooooo");
	setChar(47, "::o::", "::o::", ":::::", ":::::", ":::::");
	setChar(48, "o:o:o", ":ooo:", "ooooo", ":ooo:", "o:o:o");
	setChar(49, "::::o", ":::o:", "::o::", ":o:::", "o::::");
	char c[] = "abcdefghijklmnopqrstuvwxyz0123456789!?:=,.-() #'*/";
	int i;
	for (i = 0; i < 256; i++)
		transl[i] = 45;
	for (i = 0; i < 50; i++)
		transl[(int)c[i]] = i;
}
Example #24
0
			Variant(char value)
			{
				setChar(value);
			}
Example #25
0
void StringData::set(CVarRef key, CStrRef v) {
  setChar(key.toInt32(), v);
}
Example #26
0
Pawn::Pawn(int num){
	setPlayer(num);
	setChar('p' - num * 32);
	setValue( 1);
}
Example #27
0
Knight::Knight(int num){
	setPlayer(num);
	setChar('n' - num * 32);
	setValue( 3);
}
Example #28
0
void TM1638::setChars(const char* value, uint8_t offset)
{
    while (*value)
        setChar(offset++, *value++);
}
Example #29
0
size_t Variant::deserialize(const unsigned char *buffer, size_t size)
{
    if (buffer != NULL && size > 0)
    {
        Variant::Type type = static_cast<Variant::Type>(*buffer);
        ++buffer;

        switch (type)
        {
            case UINT8:
            {
                typedef uint8_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint8(static_cast<Type>(*buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT8:
            {
                typedef uint8_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt8(static_cast<Type>(*buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT16:
            {
                typedef uint16_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint16(ntohs(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT16:
            {
                typedef int16_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt16(ntohs(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT32:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint32(ntohl(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT32:
            {
                typedef int32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt32(ntohl(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case UINT64:
            {
                typedef uint64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setUint64(ntohll(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case INT64:
            {
                typedef int64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setInt64(ntohll(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case FLOAT:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setFloat(ntohf(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case DOUBLE:
            {
                typedef uint64_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setDouble(ntohd(*reinterpret_cast<const Type *>(buffer)));
                    size = sizeof(Type) + 1;
                }
                break;
            }

            case BOOL:
            {
                typedef bool Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setBool(*reinterpret_cast<const Type *>(buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case CHAR:
            {
                typedef char Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    setChar(*reinterpret_cast<const Type *>(buffer));
                    size = sizeof(Type) + 1;
                }

                break;
            }

            case STRING:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    Type len = ntohl(*reinterpret_cast<const Type *>(buffer));

                    if (len > 0 && len <= ((size - 1) - sizeof(Type)))
                        setString(reinterpret_cast<const char *>(buffer + sizeof(Type)), len);

                    size = sizeof(Type) + 1 + len;
                }

                break;
            }

            case BINARY:
            {
                typedef uint32_t Type;

                if ((size - 1) < sizeof(Type))
                    return 0;
                else
                {
                    Type len = ntohl(*reinterpret_cast<const Type *>(buffer));

                    if (len > 0 && len <= ((size - 1) - sizeof(Type)))
                        setBinary(reinterpret_cast<const unsigned char *>(buffer + sizeof(Type)), len);

                    size = sizeof(Type) + 1 + len;
                }

                break;
            }
        }

        return size;
    }

    return 0;
}