Exemple #1
0
void    CreateBlock(BlockDesc* block)
{
    int rnd = Rand16();
    int color = Rand16()&0x0F;
    int i;
    rnd &= 7;
    if(rnd>=PATTEN_CNT){
        rnd = Rand16()&3;
    }
    block->patten = pattens + rnd*4;
    block->rotate = Rand16()&3;
    block->x = 3;
    block->y = 0;
    block->color = 1;color;
    rnd = 1;
    for(i=0;i<4;i++){
        unsigned char pat = block->patten[block->rotate][i];
        block->raw32[i] = BitExtend[pat]*(color+1);
        if(pat && rnd){
            block->y -= i;
            rnd = 0;
        }
    }
    if(rnd){
        printf("Error!");
    }
}
Exemple #2
0
/* comefrom: MapScan */
DoFlood(void)
{
  static short Dx[4] = { 0, 1, 0,-1};
  static short Dy[4] = {-1, 0, 1, 0};
  register short z, c, xx, yy, t;

  if (FloodCnt)
    for (z = 0; z < 4; z++) {
      if (!(Rand16() & 7)) {
	xx = SMapX + Dx[z];
	yy = SMapY + Dy[z];
	if (TestBounds(xx, yy)) {
	  c = Map[xx][yy];
	  t = c & LOMASK;
	  /* TILE_IS_FLOODABLE2(c) */
	  if ((c & BURNBIT) ||
	      (c == 0) ||
	      ((t >= WOODS5 /* XXX */) && (t < FLOOD))) {
	    if (c & ZONEBIT)
	      FireZone(xx, yy, c);
	    Map[xx][yy] = FLOOD + Rand(2);
	  }
	}
      }
    }
  else
    if (!(Rand16() & 15))
      Map[SMapX][SMapY] = 0;
}
Exemple #3
0
/* comefrom: DoDisasters ScenarioDisaster */
MakeEarthquake(void)
{
  register short x, y, z;
  short time;

  DoEarthQuake();

  SendMesAt(-23, CCx, CCy);
  time = Rand(700) + 300;
  for (z = 0; z < time; z++)  {
    x = Rand(WORLD_X - 1);
    y = Rand(WORLD_Y - 1);
    if ((x < 0) || (x > (WORLD_X - 1)) ||
	(y < 0) || (y > (WORLD_Y - 1)))
      continue;
    /* TILE_IS_VULNERABLE(Map[x][y]) */
    if (Vunerable(Map[x][y])) {
      if (z & 0x3)
	Map[x][y] = (RUBBLE + BULLBIT) + (Rand16() & 3);
      else
	Map[x][y] = (FIRE + ANIMBIT) + (Rand16() & 7);
    }
  }
}
Exemple #4
0
/* comefrom: DoDisasters */
SetFire(void)
{
  register short x, y, z;

  x = Rand(WORLD_X - 1);
  y = Rand(WORLD_Y - 1);
  z = Map[x][y];
  /* TILE_IS_ARSONABLE(z) */
  if (!(z & ZONEBIT)) {
    z = z & LOMASK;
    if ((z > LHTHR) && (z < LASTZONE)) {
      Map[x][y] = FIRE + ANIMBIT + (Rand16() & 7);
      CrashX = x; CrashY = y;
      SendMesAt(-20, x, y);
    }
  }
}
Exemple #5
0
/* comefrom: DoDisasters */
MakeFire(void)
{
  short t, x, y, z;
  for (t = 0; t < 40; t++)  {
    x = Rand(WORLD_X - 1);
    y = Rand(WORLD_Y - 1);
    z = Map[x][y];
    /* !(z & BURNBIT) && TILE_IS_ARSONABLE(z) */
    if ((!(z & ZONEBIT)) && (z & BURNBIT)) {
      z = z & LOMASK;
      if ((z > 21) && (z < LASTZONE)) {
	Map[x][y] = FIRE + ANIMBIT + (Rand16() & 7);
	SendMesAt(20, x, y);
	return;
      }
    }
  }
}
Exemple #6
0
ditherMap(SimView *view)
{
  int i, x, y, width, height;
  int err, pixel1, pixel8;
  int line_bytes1 = view->line_bytes;
  int line_bytes8 = view->line_bytes8;
  unsigned char *image1 = view->data;
  unsigned char *image8 = view->data8;
  int *errors;

  width = view->m_width; height = view->m_height;

  errors = (int *)malloc(sizeof(int) * (width));

  for (i = 0; i < width; i++)
    errors[i] = (Rand16() & 15) - 7;

  err = (Rand16() & 15) - 7;

  for (y = 0; y < height; y += 2) {
    unsigned char *i1 = image1; 
    unsigned char *i8 = image8;

    image1 += line_bytes1;
    image8 += line_bytes8;

    for (x = 0; x < width; x += 8) {
      pixel1 = 0;
      for (i = 0; i < 8; i++) {
	pixel1 <<= 1;
	pixel8 = *(i8++) + err + errors[x + i];
	if (pixel8 > 127) {
	  err = pixel8 - 255;
	} else {
	  pixel1 |= 1;
	  err = pixel8;
	}
	errors[x + i] = err/2;
	err = err/2;
      }
      *(i1++) = pixel1;
    }

    i1 = image1 + (width / 8) - 1;
    i8 = image8 + width - 1;

    image1 += line_bytes1;
    image8 += line_bytes8;

    for (x = width - 8; x >= 0; x -= 8) {
      pixel1 = 0;
      for (i = 7; i >= 0; i--) {
	pixel1 >>= 1;
	pixel8 = *(i8--) + err + errors[x + i];
	if (pixel8 > 127) {
	  err = pixel8 - 255;
	} else {
	  pixel1 |= 128;
	  err = pixel8;
	}
	errors[x + i] = err/2;
	err = err/2;
      }
      *(i1--) = pixel1;
    }
  }

  free(errors);
}