예제 #1
0
파일: Register.c 프로젝트: dvelazquez/Coco
void Proceed()
{
    /* This is a transition effect */
    int ScreenWide;
    RLE_SPRITE *rle0, *rle1;

    strcpy(FName, "logs/");
    strcat(FName, Name);
    strcat(FName, " - ");
    strcat(FName, Number);
    strcat(FName, ".log");
    outfile = fopen(FName,"w");

    if(Option=='A')
    {
        system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
        rest(5);
        rle0= get_rle_sprite(Screen1);
        rle1= get_rle_sprite(Screen2);

        for(ScreenWide=0; ScreenWide<=1024; ScreenWide=ScreenWide+10)
        {
            draw_rle_sprite(screen, rle0, ScreenWide, 0);
            draw_rle_sprite(screen, rle1, -1024+ScreenWide, 0);
        }
        destroy_rle_sprite(rle0);
        release_screen();
        Automatic();
    }
    if(Option=='M')
    {
        system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
        rest(5);
        rle0= get_rle_sprite(Screen1);
        rle1= get_rle_sprite(Screen2);

        for(ScreenWide=0; ScreenWide<=1024; ScreenWide=ScreenWide+10)
        {
            draw_rle_sprite(screen, rle0, ScreenWide, 0);
            draw_rle_sprite(screen, rle1, -1024+ScreenWide, 0);
        }
        destroy_rle_sprite(rle0);
        destroy_rle_sprite(rle1);
        destroy_bitmap(Screen1);
        destroy_bitmap(Screen2);
        release_screen();
        Manual();
    }

    release_screen();
}
예제 #2
0
void rle_masked_image::set_image(BITMAP* _image)
{
  if (_image)
  {  
    if (rle_image) destroy_rle_sprite(rle_image);
    if (image) rle_image = get_rle_sprite(image); else rle_image = 0;
  
    resize(image->w - 1, image->h - 1);
  } else
  {
    if (rle_image) destroy_rle_sprite(rle_image);
    rle_image = 0;
  }
}
예제 #3
0
파일: datitype.c 프로젝트: Yurand/tw-light
/* worker function for changing the type of an image */
static int do_changetype(DATAFILE *dat, int *param, int type)
{
   BITMAP *bmp;
   RLE_SPRITE *spr;
   int x, y, c, r, g, b;

   if ((dat->type != DAT_BITMAP) && (dat->type != DAT_RLE_SPRITE) &&
       (dat->type != DAT_C_SPRITE) && (dat->type != DAT_XC_SPRITE)) {
      (*param)++;
      return D_O_K;
   }

   if (dat->type == type)
      return D_O_K;

   if (dat->type == DAT_RLE_SPRITE) {
      spr = (RLE_SPRITE *)dat->dat;
      bmp = create_bitmap_ex(spr->color_depth, spr->w, spr->h);
      clear_to_color(bmp, bmp->vtable->mask_color);
      draw_rle_sprite(bmp, spr, 0, 0);
      dat->dat = bmp;
      destroy_rle_sprite(spr);
   }
   else if (type == DAT_RLE_SPRITE) {
      bmp = (BITMAP *)dat->dat;
      spr = get_rle_sprite(bmp);
      dat->dat = spr;
      destroy_bitmap(bmp);
   }
   else if ((type == DAT_C_SPRITE) || (type == DAT_XC_SPRITE)) {
      bmp = (BITMAP *)dat->dat;
      if (bitmap_color_depth(bmp) == 32) {
	 for (y=0; y<bmp->h; y++) {
	    for (x=0; x<bmp->w; x++) {
	       c = getpixel(bmp, x, y);
	       r = getr32(c);
	       g = getg32(c);
	       b = getb32(c);
	       putpixel(bmp, x, y, makecol32(r, g, b));
	    }
	 }
      }
   }

   dat->type = type;

   return D_REDRAW;
}
예제 #4
0
파일: ccsprite.c 프로젝트: Skiles/aseprite
/* get_compiled_sprite:
 *  Creates a compiled sprite based on the specified bitmap.
 */
COMPILED_SPRITE *get_compiled_sprite(BITMAP *bitmap, int planar)
{
   ASSERT(bitmap);
   return get_rle_sprite(bitmap);
}
예제 #5
0
파일: test.cpp 프로젝트: Fomka/ufo2000
int main(int argc, char *argv[])
{
    int i, idx, color_depth = -1;
    if (argc >= 2) color_depth = atoi(argv[1]);
    if (color_depth != 16 && color_depth != 24 && color_depth != 32) {
        printf("Usage: test [color_depth]\n");
        return -1;
    }

    allegro_init();
    install_keyboard();
    set_color_depth(color_depth);
    if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0) != 0) return -1;
    backbuffer = create_bitmap(SCREEN_W, SCREEN_H);
    BITMAP *backbuffer1 = create_bitmap(SCREEN_W, SCREEN_H);
    BITMAP *backbuffer2 = create_bitmap(SCREEN_W, SCREEN_H);

    // Load fire sprites (alpha transparency used)
    fire_ex = load_bitmap_alpha("fire.tga", true);
    for (int idx = 0; idx < SPRITE_COUNT; idx++) {
        i = idx % 8;
        fire_ex_bitmaps[idx] = create_sub_bitmap(fire_ex, (i % 4) * 33, (i / 4) * 41, 32, 40);
        fire_ex_rle_sprites[idx] = get_rle_sprite(fire_ex_bitmaps[i]);
        fire_ex_alpha_sprites[idx] = get_alpha_sprite(fire_ex_bitmaps[i]);
    }

    // Load fire sprites (no alpha transparency used)
    fire = load_bitmap_alpha("fire.tga", false);
    for (int idx = 0; idx < SPRITE_COUNT; idx++) {
        i = idx % 8;
        fire_bitmaps[idx] = create_sub_bitmap(fire, (i % 4) * 33, (i / 4) * 41, 32, 40);
        fire_rle_sprites[idx] = get_rle_sprite(fire_bitmaps[i]);
        fire_alpha_sprites[idx] = get_alpha_sprite(fire_bitmaps[i]);
    }

    // Load explosion sprites (alpha transparency used)
    explosion = load_bitmap_alpha("explosion.tga", true);
    for (i = 0; i < 10; i++) {
        explosion_bitmaps[i] = create_sub_bitmap(explosion, 0, 179 * i, 256, 178);
        explosion_rle_sprites[i] = get_rle_sprite(explosion_bitmaps[i]);
        explosion_alpha_sprites[i] = get_alpha_sprite(explosion_bitmaps[i]);
    }

    printf("---\n");
    printf("explosion sprites per second (spritelib)      = %.1lf\n", run_test(backbuffer1, test_explosion_spritelib));
    printf("explosion sprites per second (allegro rle)    = %.1lf\n", run_test(backbuffer2, test_explosion_allegro_rle));
    printf("explosion sprites per second (allegro bitmap) = %.1lf\n", run_test(backbuffer2, test_explosion_allegro));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    TESTS_COUNT = 500000;
    printf("---\n");
    printf("normal fire sprites per second (spritelib)    = %.1lf\n", run_test(backbuffer1, test_fire_spritelib));
    printf("normal fire sprites per second (allegro rle)  = %.1lf\n", run_test(backbuffer2, test_fire_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    printf("---\n");
    printf("lit fire sprites per second (spritelib)       = %.1lf\n", run_test(backbuffer1, test_fire_lit_spritelib));
    printf("lit fire sprites per second (allegro rle)     = %.1lf\n", run_test(backbuffer2, test_fire_lit_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");
    printf("---\n");
    printf("alpha fire sprites per second (spritelib)     = %.1lf\n", run_test(backbuffer1, test_fire_alpha_spritelib));
    printf("alpha fire sprites per second (allegro rle)   = %.1lf\n", run_test(backbuffer2, test_fire_alpha_allegro_rle));
    if (!compare_bitmaps(backbuffer1, backbuffer2)) printf("Error: results do not match!\n");

    i = 0;
    while (true) {
        if (keypressed()) {
            int scancode;
            ureadkey(&scancode);
            if (scancode == KEY_ESC) break;
        }
        clear_to_color(backbuffer, makecol(64, 64, 64));
        int brightness = (i % 512) - 256;
        if (brightness < 0) brightness = -brightness;
        draw_alpha_sprite(backbuffer, explosion_alpha_sprites[i % 10], 0, 0, brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[i % 4], 300, 0, brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[(i % 4) + 4], 300, 50, 256 - brightness);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[i % 4], 300, 100, 250);
        draw_alpha_sprite(backbuffer, fire_alpha_sprites[(i % 4) + 4], 300, 150, 250);
        blit(backbuffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
        rest(100);
        i++;
    }

    destroy_bitmap(backbuffer);
    destroy_bitmap(backbuffer1);
    destroy_bitmap(backbuffer2);

    for (idx = 0; idx < SPRITE_COUNT; idx++) {
        destroy_bitmap(fire_ex_bitmaps[idx]);
        destroy_rle_sprite(fire_ex_rle_sprites[idx]);
        destroy_alpha_sprite(fire_ex_alpha_sprites[idx]);
        destroy_bitmap(fire_bitmaps[idx]);
        destroy_rle_sprite(fire_rle_sprites[idx]);
        destroy_alpha_sprite(fire_alpha_sprites[idx]);
    }
    destroy_bitmap(fire_ex);
    destroy_bitmap(fire);

    // Load explosion sprites (alpha transparency used)
    for (i = 0; i < 10; i++) {
        destroy_bitmap(explosion_bitmaps[i]);
        destroy_rle_sprite(explosion_rle_sprites[i]);
        destroy_alpha_sprite(explosion_alpha_sprites[i]);
    }
    destroy_bitmap(explosion);

    allegro_exit();

    return 0;
}
예제 #6
0
파일: Manual.c 프로젝트: dvelazquez/Coco
int Manual()
{
  int PVi, k;
        K= uatof(Gain);
  /* Things will be drawn more quickly if you always acquire the screen before
     trying to draw onto it. */
  acquire_screen();
  
  Graphics();	/* Call to graphics from a different function to avoid messy code */
  
  int dir = 1;   //since we are receiving data, direction should be 1
  int mode = IEEE1284_MODE_COMPAT; // parameter to set mode 'receive'
  RLE_SPRITE *rle;
  
  /* Set the direction for reception */
  ioctl(fd, PPDATADIR, &dir);
  ioctl(fd, PPWDATA, 0);
  
  PVi= 0;  k= 100;  M=0;
  while (!key[KEY_ESC])	/* Only pressing ESC can Exit */
    {
      M++;
      /* Check if user needs some help */
      if(key[KEY_F1])
	Help();

      k++;
      i= 897;
      
      Captura = create_sub_bitmap(screen, 72, 350, 898, 368);
      rle = get_rle_sprite(Captura);
      destroy_bitmap(Captura);
      draw_rle_sprite(screen, rle, 71, 350);
      destroy_rle_sprite(rle);
      
      /* This line reads data from the interfase which is
	 the process variable(measured variable) of the system */
      ioctl(fd, PPRDATA, &PVi);
      PV= PVi;
      
      if(PV<=40)
	{
	  PV= 51;
	  system("festival --tts Messages/Disconnected&");
	  blit(Disconnected, screen, 0, 0, 70, 290, 887, 52);   
	}
      
      if(PV<=48)
        PVi= 51;
      
      PV= 1.794117647*(PVi-51);
      SP= PV;
      
      if(key[KEY_RIGHT])
	{
          fd = close("/dev/parport0");	
	  Simulator();
        }
      if(key[KEY_PGUP])
	OP= (OP+46);
      
      if(key[KEY_PGDN])
	OP= (OP-46);
      
      if(key[KEY_UP])
	OP= (OP+3.66);
      
      if(key[KEY_DOWN])
	{
	  if(OP>=1)
	    OP= (OP-3.66);
	}
      
      if(key[KEY_PRTSCR])
	{
          Captura = create_sub_bitmap(screen, 0, 0, 1024, 768);
          save_bitmap("images/User/Captura.pcx", Captura, pal);
          destroy_bitmap(Captura);
        }
      
      Timer++;
      
      if(OP<=0)
	OP= 0;
      
      
      if (PV>=40)
	{
	  textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100);	// Medición
	  textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100);	// SP
	  textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100);	// Controlador
	}
      
      if(k>=100)
	{
 	  k= 0;
	  vline(screen, 967, 351, 717, GRAY);
          blit(Clean, screen, 0, 0, 968, 350, 2, 368);
	}
      
      int Recorder;
      Recorder++;
      if(Recorder>=900)
	{
 	  Recorder= 0;
	  Captura = create_sub_bitmap(screen, 258, 350, 715, 368);
	}
      
      Captura = create_sub_bitmap(screen, 248, 350, 705, 368);
      
      
      if(PV>=362) PV= 365;
      if(OP>=367) OP= 365;
      
      if(PV<=0) PV= 0;
      if(OP<=0) OP= 0;
      
      /* Draw the behaviour of the PV, SP and OP over time */
      line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED);	
      PVj= PV;    /* Flag for line y2 as a precedent state */
      line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE);	
      OPj= OP;    /* Flag for line y2 as a precedent state */
      
      fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100));
      rest(Delay);
    }
  int ScreenWide;
  RLE_SPRITE *rle0, *rle1;
  BITMAP *Screen3;

  Screen3 = load_bitmap("images/Close/Base.pcx", pal);
  system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
  rest(5);

  rle0= get_rle_sprite(Screen2);
  rle1= get_rle_sprite(Screen3);
  
  for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5)
    {
      draw_rle_sprite(screen, rle0, 0, 768);
      draw_rle_sprite(screen, rle1, 0, -768+ScreenWide);
    }

  destroy_rle_sprite(rle0);  
  destroy_rle_sprite(rle1);    
  destroy_bitmap(Screen2);
  destroy_bitmap(Screen3);
  destroy_bitmap(Clean);
  destroy_bitmap(Disconnected);
  release_screen();
  Close();
  exit(0);
} 
예제 #7
0
파일: Manual.c 프로젝트: dvelazquez/Coco
int Manual(int argc, unsigned char **argv)
{
  /* Serial port initialization */

  fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd == -1) {
    perror("open_port: Unable to open /dev/ttyS0 - ");
    return 1;
  } else {
    fcntl(fd, F_SETFL, 0);
  }
  getbaud(fd);

  initport(fd);

  int PVi, k;
        K= uatof(Gain);
  /* Things will be drawn more quickly if you always acquire the screen before
     trying to draw onto it. */
  acquire_screen();
  
  Graphics();	/* Call to graphics from a different function to avoid messy code */
  
  RLE_SPRITE *rle;
 
            sCmd[0]= 'C';
            writeport(fd, sCmd);

  PVi= 0;  k= 100;  M=0;
  while (!key[KEY_ESC])	/* Only pressing ESC can Exit */
    {
	char ValveState;
	if(ValveState=='O')
	{
            sCmd[0]= 'A';
            writeport(fd, sCmd);
	}
	if(ValveState=='C')
	{
            sCmd[0]= 'C';
            writeport(fd, sCmd);
	}
	


      M++;
      /* Check if user needs some help */
      if(key[KEY_F1])
	Help();

      k++;
      i= 897;
      
      Captura = create_sub_bitmap(screen, 72, 350, 898, 368);
      rle = get_rle_sprite(Captura);
      destroy_bitmap(Captura);
      draw_rle_sprite(screen, rle, 71, 350);
      destroy_rle_sprite(rle);

      /* This line reads data from the interfase which is
	 the process variable(measured variable) of the system */
          fcntl(fd, F_SETFL, FNDELAY); // don't block serial read
	  readport(fd,sResult);
	  PVi= (int) *sResult;
	  PV= PVi;      
/*
      if(PVi<=40)
	{
	  PV= 51;
	  system("festival --tts Messages/Disconnected&");
	  blit(Disconnected, screen, 0, 0, 70, 290, 887, 52);   
	}
   */   
      if(PV<=48)
        PVi= 51;
      
      PV= 1.794117647*(PVi-51);
      SP= PV;
      
      if(key[KEY_RIGHT])
	{
          //fd = close("/dev/parport0");	
	  Simulator();
        }
      if(key[KEY_PGUP])
	OP= (OP+46);
      
      if(key[KEY_PGDN])
	OP= (OP-46);
      
      if(key[KEY_UP])
	{
	    OP=162; //(OP+3.66);
            sCmd[0]= 'A';
            writeport(fd, sCmd);
	    ValveState='O';
	}

      if(key[KEY_DOWN])
	{
	  if(OP>=1)
	    OP= 0;//(OP-3.66);
            sCmd[0]= 'C';
            writeport(fd, sCmd);
	    ValveState='C';
	}
      
      if(key[KEY_PRTSCR])
	{
          Captura = create_sub_bitmap(screen, 0, 0, 1024, 768);
          save_bitmap("images/User/Captura.pcx", Captura, pal);
          destroy_bitmap(Captura);
        }
      
      Timer++;
      
      if(OP<=0)
	OP= 0;
      
      
//      if (PV>=40)
//	{
	  textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100);	// Medición
	  textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100);	// SP
	  textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100);	// Controlador
//	}
      
      if(k>=100)
	{
 	  k= 0;
	  vline(screen, 967, 351, 717, GRAY);
          blit(Clean, screen, 0, 0, 968, 350, 2, 368);
	}
      
      int Recorder;
      Recorder++;
      if(Recorder>=900)
	{
 	  Recorder= 0;
	  Captura = create_sub_bitmap(screen, 258, 350, 715, 368);
	}
      
      Captura = create_sub_bitmap(screen, 248, 350, 705, 368);
      
      
      if(PV>=362) PV= 365;
      if(OP>=367) OP= 365;
      
      if(PV<=0) PV= 0;
      if(OP<=0)
	 OP= 1;
/*
      OPi= fixtoi(itofix((OP*0.69234783)/255*100));
      sCmd[0]= (unsigned char)OPi+50;
      sCmd[0]= sCmd[0]+0.00;
      writeport(fd, sCmd);
*/
//     textprintf_ex(screen, font, 30, 297, BLACK, WHITE, "%i - %s - %3.1f", PVi, sResult, PV);	// Medición      

      /* Draw the behaviour of the PV, SP and OP over time */
      line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED);	
      PVj= PV;    /* Flag for line y2 as a precedent state */
      line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE);	
      OPj= OP;    /* Flag for line y2 as a precedent state */
      
      fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100));
      rest(Delay);
    }
  int ScreenWide;
  RLE_SPRITE *rle0, *rle1;
  BITMAP *Screen3;

  Screen3 = load_bitmap("images/Close/Base.pcx", pal);
  system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
  rest(5);

  rle0= get_rle_sprite(Screen2);
  rle1= get_rle_sprite(Screen3);
  
  for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5)
    {
      draw_rle_sprite(screen, rle0, 0, 768);
      draw_rle_sprite(screen, rle1, 0, -768+ScreenWide);
    }

  destroy_rle_sprite(rle0);  
  destroy_rle_sprite(rle1);    
  destroy_bitmap(Screen2);
  destroy_bitmap(Screen3);
  destroy_bitmap(Clean);
  destroy_bitmap(Disconnected);
  release_screen();
  Close();
  exit(0);
} 
예제 #8
0
파일: datitype.c 프로젝트: Yurand/tw-light
/* worker function for changing the color depth of bitmap data */
static int do_changedepth(DATAFILE *dat, int *param, int depth)
{
   BITMAP *bmp, *bmp2;
   RLE_SPRITE *spr;
   RGB tmprgb = datedit_current_palette[0];

   if ((dat->type != DAT_BITMAP) && (dat->type != DAT_RLE_SPRITE) &&
       (dat->type != DAT_C_SPRITE) && (dat->type != DAT_XC_SPRITE)) {
      (*param)++;
      return D_O_K;
   }

   if (dat->type == DAT_RLE_SPRITE) {
      spr = (RLE_SPRITE *)dat->dat;
      if (spr->color_depth == depth)
	 return D_O_K;

      bmp = create_bitmap_ex(spr->color_depth, spr->w, spr->h);
      clear_to_color(bmp, bmp->vtable->mask_color);
      draw_rle_sprite(bmp, spr, 0, 0);
      bmp2 = create_bitmap_ex(depth, bmp->w, bmp->h);

      datedit_current_palette[0].r = 63;
      datedit_current_palette[0].g = 0;
      datedit_current_palette[0].b = 63;
      select_palette(datedit_current_palette);

      blit(bmp, bmp2, 0, 0, 0, 0, bmp->w, bmp->h);

      unselect_palette();
      datedit_current_palette[0] = tmprgb;

      dat->dat = get_rle_sprite(bmp2);
      destroy_bitmap(bmp);
      destroy_bitmap(bmp2);
      destroy_rle_sprite(spr);
   }
   else {
      bmp = (BITMAP *)dat->dat;
      if (bitmap_color_depth(bmp) == depth)
	 return D_O_K;
      bmp2 = create_bitmap_ex(depth, bmp->w, bmp->h);

      if ((dat->type == DAT_C_SPRITE) || (dat->type == DAT_XC_SPRITE)) {
	 datedit_current_palette[0].r = 63;
	 datedit_current_palette[0].g = 0;
	 datedit_current_palette[0].b = 63;
      }
      select_palette(datedit_current_palette);

      blit(bmp, bmp2, 0, 0, 0, 0, bmp->w, bmp->h);

      unselect_palette();
      datedit_current_palette[0] = tmprgb;

      dat->dat = bmp2;
      destroy_bitmap(bmp);
   }

   return D_REDRAW;
}