Exemplo n.º 1
0
static void mem_upload_fini() {
  DisableOsd();

  // do we really still need these if it's within a function?
  SPIN(); SPIN(); 
  SPIN(); SPIN();
}
Exemplo n.º 2
0
static void
test_threads_conditionvar(void *arg)
{
  cv_testinfo_t *ti=NULL;
  const struct timeval msec100 = { 0, 100*1000 };
  const int timeout = !strcmp(arg, "tv");

  ti = cv_testinfo_new();
  if (timeout) {
    ti->tv = &msec100;
  }
  spawn_func(cv_test_thr_fn_, ti);
  spawn_func(cv_test_thr_fn_, ti);
  spawn_func(cv_test_thr_fn_, ti);
  spawn_func(cv_test_thr_fn_, ti);

  tor_mutex_acquire(ti->mutex);
  ti->addend = 7;
  ti->shutdown = 1;
  tor_cond_signal_one(ti->cond);
  tor_mutex_release(ti->mutex);

#define SPIN()                                  \
  while (1) {                                   \
    tor_mutex_acquire(ti->mutex);               \
    if (ti->addend == 0) {                      \
      break;                                    \
    }                                           \
    tor_mutex_release(ti->mutex);               \
  }

  SPIN();

  ti->addend = 30;
  ti->shutdown = 1;
  tor_cond_signal_all(ti->cond);
  tor_mutex_release(ti->mutex);
  SPIN();

  ti->addend = 1000;
  if (! timeout) ti->shutdown = 1;
  tor_cond_signal_one(ti->cond);
  tor_mutex_release(ti->mutex);
  SPIN();
  ti->addend = 300;
  if (! timeout) ti->shutdown = 1;
  tor_cond_signal_all(ti->cond);
  tor_mutex_release(ti->mutex);

  SPIN();
  tor_mutex_release(ti->mutex);

  tt_int_op(ti->value, ==, 1337);
  if (!timeout) {
    tt_int_op(ti->n_shutdown, ==, 4);
  } else {
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *coglbox;
  
  clutter_init(&argc, &argv);
  
  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 400, 400);
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Test");
  
  coglbox = test_coglbox_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);

  clutter_actor_set_rotation (coglbox, CLUTTER_Y_AXIS, -30, 200, 0, 0);
  clutter_actor_set_position (coglbox, 0, 100);
  
  clutter_actor_show_all (stage);
  
  while (1)
    {
      clutter_actor_hide (coglbox);
      clutter_actor_show (coglbox);
      SPIN();
    }
  
  return 0;
}
Exemplo n.º 4
0
// SendFileV2 (for minimig_v2)
void SendFileV2(RAFile* file, unsigned char* key, int keysize, int address, int size)
{
  int i,j;
  unsigned int keyidx=0;
  iprintf("File size: %dkB\r", size>>1);
  iprintf("[");
  if (keysize) {
    // read header
    RARead(file, sector_buffer, 0xb);
  }
  for (i=0; i<size; i++) {
    if (!(i&31)) iprintf("*");
    RARead(file, sector_buffer, 512);
    if (keysize) {
      // decrypt ROM
      for (j=0; j<512; j++) {
        sector_buffer[j] ^= key[keyidx++];
        if(keyidx >= keysize) keyidx -= keysize;
      }
    }
    EnableOsd();
    unsigned int adr = address + i*512;
    SPI(OSD_CMD_WR);
    SPIN(); SPIN(); SPIN(); SPIN();
    SPI(adr&0xff); adr = adr>>8;
    SPI(adr&0xff); adr = adr>>8;
    SPIN(); SPIN(); SPIN(); SPIN();
    SPI(adr&0xff); adr = adr>>8;
    SPI(adr&0xff); adr = adr>>8;
    SPIN(); SPIN(); SPIN(); SPIN();
    for (j=0; j<512; j=j+4) {
      SPI(sector_buffer[j+0]);
      SPI(sector_buffer[j+1]);
      SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
      SPI(sector_buffer[j+2]);
      SPI(sector_buffer[j+3]);
      SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
    }
    DisableOsd();
  }
  iprintf("]\r");
}
Exemplo n.º 5
0
//// UploadKickstart() ////
char UploadKickstart(char *name)
{
  int keysize=0;
  char filename[12];

  strncpy(filename, name, 8); // copy base name
  strcpy(&filename[8], "ROM"); // add extension

  BootPrint("Checking for Amiga Forever key file:");
  if(FileOpen(&file,"ROM     KEY")) {
    keysize=file.size;
    if(file.size<sizeof(romkey)) {
      int c=0;
      while(c<keysize) {
        FileRead(&file, &romkey[c]);
        c+=512;
        FileNextSector(&file);
      }
      BootPrint("Loaded Amiga Forever key file");
    } else {
      BootPrint("Amiga Forever keyfile is too large!");
    }
  }
  BootPrint("Loading file: ");
  BootPrint(filename);

  if(minimig_v1()) {
    if (RAOpen(&romfile, filename)) {
      if (romfile.size == 0x80000) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x08);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x8000b) && keysize) {
        // 512KB Kickstart ROM
        BootPrint("Uploading 512 KB Kickstart (Probably Amiga Forever encrypted...)");
        PrepareBootUpload(0xF8, 0x08);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else if (romfile.size == 0x40000) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart...");
        PrepareBootUpload(0xF8, 0x04);
        SendFile(&romfile);
        return(1);
      } else if ((romfile.size == 0x4000b) && keysize) {
        // 256KB Kickstart ROM
        BootPrint("Uploading 256 KB Kickstart (Probably Amiga Forever encrypted...");
        PrepareBootUpload(0xF8, 0x04);
        SendFileEncrypted(&romfile,romkey,keysize);
        return(1);
      } else {
        BootPrint("Unsupported ROM file size!");
      }
    } else {
      siprintf(s, "No \"%s\" file!", filename);
      BootPrint(s);
    }
  } else {
    if (RAOpen(&romfile, filename)) {
      int i,j;
      unsigned int adr, size, base=0x180000, offset=0xc00000, data;
      puts("Uploading 512KB Kickstart ...");
      size = ((romfile.file.size)+511)>>9;
      iprintf("File size: %d.%01dkB\r", romfile.file.size>>10, romfile.file.size&0x3ff);
      iprintf("[");
      for (i=0; i<size; i++) {
        if (!(i&31)) iprintf("*");
        RARead(&romfile,sector_buffer,512);
        EnableOsd();
        adr = 0xf80000 + i*512;
        SPI(OSD_CMD_WR);
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        SPI(adr&0xff); adr = adr>>8;
        SPI(adr&0xff); adr = adr>>8;
        SPIN(); SPIN(); SPIN(); SPIN();
        for (j=0; j<512; j=j+4) {
          SPI(sector_buffer[j+0]);
          SPI(sector_buffer[j+1]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
          SPI(sector_buffer[j+2]);
          SPI(sector_buffer[j+3]);
          SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN(); SPIN();
        }
        DisableOsd();
      }
      iprintf("]\r");
      return(1);
    }
  }
Exemplo n.º 6
0
G_MODULE_EXPORT int
test_textures_main (int argc, char *argv[])
{
  ClutterActor    *texture;
  ClutterActor    *stage;
  gint             i, j;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_actor_show_all (CLUTTER_ACTOR (stage));
  g_signal_connect (stage, "destroy", G_CALLBACK (exit_on_destroy), NULL);

  SPIN();

  for (i=100; i<=5000; i += 100)
    for (j=0; j<4; j++)
      {
        const int width = i+j;
        const int height = i+j;
        const gboolean has_alpha = TRUE;
        const int bpp = has_alpha ? 4 : 3;
        int rowstride;
        guchar *pixels;

        pixels = make_rgba_data (width, height, bpp, has_alpha, &rowstride);
        if (!pixels)
          g_error("No memory for %ix%i RGBA data failed", width, height);

        printf("o %ix%i texture... ", width, height);

        texture = clutter_texture_new ();
        if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (texture),
                                                pixels,
                                                has_alpha,
                                                width,
                                                height,
                                                rowstride,
                                                bpp,
                                                0, NULL))
          g_error("texture creation failed");
        g_free(pixels);
	
	printf("uploaded to texture...\n");
	
	clutter_container_add (CLUTTER_CONTAINER (stage), texture, NULL);
	clutter_actor_set_size (texture, 400, 400);
	clutter_actor_show (texture);

	/* Hide & show to unreaise then realise the texture */
	clutter_actor_hide (texture);
	clutter_actor_show (texture);	

	SPIN();

        clutter_container_remove (CLUTTER_CONTAINER (stage), texture, NULL);
    }

  return EXIT_SUCCESS;
}