Exemplo n.º 1
0
/**
 * How is the color components represented for 16, 24 and 32 bit color depth
 * 
 * RGB 565
 * ------------
 *  Red   = 0xf800 >> 11
 *  Green = 0x07e0 >> 5
 *  Blue  = 0x001f >> 0
 * 
 * ARGB 8888
 * ------------
 *  Alpha = 0xff000000 >> 24
 *  Red   = 0x00ff0000 >> 16
 *  Green = 0x0000ff00 >> 8
 *  Blue  = 0x000000ff >> 0
 *
 * RGB 888
 * ---------
 *  Red   = 0x00ff0000 >> 16
 *  Green = 0x0000ff00 >> 8
 *  Blue  = 0x000000ff >> 0
 *
 */
int main(void)
{
  uint32_t width = 1920;
  uint32_t height = 1200;
  uint32_t depth = 32;

  uart_init();
  uart_puts("InitializeFrameBuffer\r\n");
  struct FrameBufferInfo* fb_info = InitializeFrameBuffer(width, height, depth);

  uint32_t seed = 0;
  uart_puts("Painting\r\n");

  SetFrameBufferInfo(fb_info);
  while (true) {
    uint32_t x0 = NextRandom(fb_info->width);
    uint32_t y0 = NextRandom(fb_info->height);
    uint32_t x1 = NextRandom(fb_info->width);
    uint32_t y1 = NextRandom(fb_info->height);
    uint32_t color = NextRandom(0x00ffffff) | 0xff000000;
    SetColor(color);
    DrawLine(x0, y0, x1, y1);
  }

}
Exemplo n.º 2
0
void NextTurn(Game* game)
{   if(game == NULL) return;
    int cell_count = game->board->rows * game->board->cols;
    int* is = malloc(sizeof(int) * cell_count);
    if(is == NULL)
    {   game->status = GAME_STATUS_ERROR;
        return;
    }
    int n = 0, i;
    for(i = 0; i < cell_count; i++)
    {   if(game->board->cells[i] == 0)
        {   is[n] = i;
            n++;
        }
    }
    if(n > 0)
    {   if(game->status == GAME_STATUS_NEW) game->status = GAME_STATUS_PLAYING;
        game->random = NextRandom(game->random);
        int celli = game->random % n;
        game->random = NextRandom(game->random);
        int cellpow = (game->random % game->random_max_level) + 1;
        game->board->cells[is[celli]] = 1 << cellpow;
    } else if(game->status != GAME_STATUS_WON)
        game->status = GAME_STATUS_LOST;
    free(is);
}
Exemplo n.º 3
0
bool Playback::Order::Prev( int & iCur, int iMax )
{
	switch( iCurOrder )
	{
	case ORDER_SINGLE:          return false;
	case ORDER_SINGLE_REPEAT:   return true;
	case ORDER_NORMAL:          return NextInverse( iCur, iMax );
	case ORDER_NORMAL_REPEAT:   return NextInverseRepeat( iCur, iMax );
	case ORDER_INVERSE:         return NextNormal( iCur, iMax );
	case ORDER_INVERSE_REPEAT:  return NextNormalRepeat( iCur, iMax );
	case ORDER_RANDOM:          return NextRandom( iCur, iMax );
	default:                    return false;
	}
}
Exemplo n.º 4
0
void Y_random(int nArgs)
{
  Symbol *stack= sp-nArgs+1;
  double *random;
  long n;
  if (nArgs==1 && !YNotNil(stack)) {
    /* return scalar result */
    PushDoubleValue(0.0);
    random= &sp->value.d;
    n= 1;
  } else {
    /* return array result */
    Array *array;
    BuildDimList(stack, nArgs);
    array= PushDataBlock(NewArray(&doubleStruct, tmpDims));
    random= array->value.d;
    n= array->type.number;
  }
  NextRandom(random, n);
}