Beispiel #1
0
tetris::tetris()
{
  file	f;

  f.save("sound/music.path");
  _music_path = f.get_line(0);
  _music_path.erase(_music_path.size() - 1);
  f.save("sound/gameover.path");
  _gameover_path = f.get_line(0);
  _gameover_path.erase(_gameover_path.size() - 1);
  load_objects();
  srand(time(NULL));
  _game_over = false;
  _music.load(_music_path);
  _music.set_repeat(-1);
  _music.play();
  _event_ok = true;
  _score = 0;
  _level = 1;
  _touch = false;
  _fall = true;
  for(int i = 0; i < 5; i++)
    _case[i] = false;
  clean(_world);
  _pause = -1;
}
Scene *load_scene(const char *fname) {

	Lib3dsFile *file;
	if(!(file = lib3ds_file_load(fname))) {
		error("%s: could not load %s", __func__, fname);
		return 0;
	}
	lib3ds_file_eval(file, 0);

	Scene *scene = new Scene;

	load_objects(file, scene);
	load_lights(file, scene);
	load_cameras(file, scene);

	construct_hierarchy(file, scene);

	/*
	std::list<Object*> *obj_list = scene->get_objects_list();
	std::list<Object*>::iterator iter = obj_list->begin();
	while(iter != obj_list->end()) {
		fix_hierarchy(*iter++);
	}
	*/
	
	lib3ds_file_free(file);

	return scene;
}
void CLevelSpawnConstructor::Execute							()
{
	load_objects						();
//	fill_spawn_groups					();

	init								();
	
	correct_objects						();
	generate_artefact_spawn_positions	();
	correct_level_changers				();
	verify_space_restrictors			();
	
	xr_delete							(m_level_graph);
	m_cross_table						= 0;
	xr_delete							(m_graph_engine);
}
	ObjMeshExample(void)
	 : gl()
	 , objects(load_objects())
	 , depth_prog()
	 , draw_prog()
	 , depth_vao(objects.VAOForProgram(depth_prog))
	 , draw_vao(objects.VAOForProgram(draw_prog))
	{
		UniformSampler(draw_prog, "DepthTex").Set(0);
		Texture::Active(0);
		depth_tex.Bind(Texture::Target::Rectangle);

		gl.ClearColor(0.8f, 0.8f, 0.7f, 0.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::CullFace);
	}
int zbx_module_init()
{
    int ret_code = ZBX_MODULE_OK;

    log(LOG_INFO, "Initializing (zabbix_%s, python %s)...",
            MODULE_TYPE, PY_VERSION);

    if (!set_after_fork_handler()) {
        goto on_error;
    }

    if (!load_python_lib()) {
        goto on_error;
    }

    Py_SetProgramName(program_name);
    Py_Initialize();

    if (!load_objects()) {
        goto on_error;
    }

    if (!set_module_constants()) {
        goto on_error;
    }

    if (!call_init_fn(&ret_code)) {
        goto on_error;
    }

    if (ret_code == ZBX_MODULE_OK) {
        log(LOG_INFO, "Initialization finished successfully");
    } else {
        log(LOG_ERR, "Initialization failed");
    }

on_exit:
    return ret_code;

on_error:
    ret_code = ZBX_MODULE_FAIL;
    unload_objects();
    Py_Finalize();
    unload_python_lib();
    goto on_exit;
}
TriMesh *load_mesh(const char *fname, const char *name) {
	TriMesh *mesh = 0;
	
	Lib3dsFile *file = lib3ds_file_load(fname);
	if(file && name) {
		Scene *scene = new Scene;
		load_objects(file, scene);

		Object *obj = scene->get_object(name);
		if(obj) {
			mesh = new TriMesh;
			*mesh = obj->get_mesh();
		}
		lib3ds_file_free(file);
		return mesh;
	}

	mesh = load_mesh_ply(fname);
	return mesh;
}
void ObjectsDialog::set_dirs(const QStringList &dirs)
{
	el_gl_widget->set_dirs(dirs);

	try
	{
		load_objects();
	}
	catch (const boost::exception &exception)
	{
//		LOG_EXCEPTION(exception);
		QMessageBox::critical(0, "boost::exception",
			boost::diagnostic_information(
				exception).c_str());
	}
	catch (const std::exception &exception)
	{
//		LOG_EXCEPTION(exception);
		QMessageBox::critical(0, "std::exception",
			exception.what());
	}
}
 void onInit()
 {
   sys::info << "app::COGLDev02App::onInit()" << sys::endl;
   
   pCamera = new app::CCamera(50.0f, mConfig.mRatio, 0.1f, 100.0f);
   pCamera->setPosition(math::vec3(0.0f, -1.0f, 0.0f));
   
   load_programs();
   
   load_textures();
   
   load_objects();
   
   oDirectionalLight.vColor     = math::vec3(1.0f, 1.0f, 1.0f);
   oDirectionalLight.vDirection = math::vec3(1.0f, 0.0f, 0.0f);
   oDirectionalLight.fAmbientIntensity = 0.20f;
   oDirectionalLight.fDiffuseIntensity = 0.60;
   
   glFrontFace(GL_CCW);
   glCullFace(GL_BACK);
   glEnable(GL_CULL_FACE);
   glEnable(GL_DEPTH_TEST);
   glDepthFunc(GL_LEQUAL);
 }  
Beispiel #9
0
/*
 * Big mama top level function.
 */
void boot_db( void )
{
    /*
     * Init some data space stuff.
     */
    {
	if ( ( string_space = calloc( 1, MAX_STRING ) ) == NULL )
	{
	    bug( "Boot_db: can't alloc %d string space.", MAX_STRING );
	    exit( 1 );
	}
	top_string	= string_space;
	fBootDb		= TRUE;
    }

    /*
     * Init random number generator.
     */
    {
	init_mm( );
    }

    /*
     * Set time and weather.
     */
    {
	long lhour, lday, lmonth;

	lhour		= (current_time - 650336715)
			/ (PULSE_TICK / PULSE_PER_SECOND);
	time_info.hour	= lhour  % 24;
	lday		= lhour  / 24;
	time_info.day	= lday   % 35;
	lmonth		= lday   / 35;
	time_info.month	= lmonth % 17;
	time_info.year	= lmonth / 17;

	     if ( time_info.hour <  5 ) weather_info.sunlight = SUN_DARK;
	else if ( time_info.hour <  6 ) weather_info.sunlight = SUN_RISE;
	else if ( time_info.hour < 19 ) weather_info.sunlight = SUN_LIGHT;
	else if ( time_info.hour < 20 ) weather_info.sunlight = SUN_SET;
	else                            weather_info.sunlight = SUN_DARK;

	weather_info.change	= 0;
	weather_info.mmhg	= 960;
	if ( time_info.month >= 7 && time_info.month <=12 )
	    weather_info.mmhg += number_range( 1, 50 );
	else
	    weather_info.mmhg += number_range( 1, 80 );

	     if ( weather_info.mmhg <=  980 ) weather_info.sky = SKY_LIGHTNING;
	else if ( weather_info.mmhg <= 1000 ) weather_info.sky = SKY_RAINING;
	else if ( weather_info.mmhg <= 1020 ) weather_info.sky = SKY_CLOUDY;
	else                                  weather_info.sky = SKY_CLOUDLESS;

    }

    /*
     * Assign gsn's for skills which have them.
     */
    {
	int sn;

	for ( sn = 0; sn < MAX_SKILL; sn++ )
	{
	    if ( skill_table[sn].pgsn != NULL )
		*skill_table[sn].pgsn = sn;
	}
    }

    /*
     * Read in all the area files.
     */
    {
	FILE *fpList;

	if ( ( fpList = fopen( AREA_LIST, "r" ) ) == NULL )
	{
	    perror( AREA_LIST );
	    exit( 1 );
	}

	for ( ; ; )
	{
	    strcpy( strArea, fread_word( fpList ) );
	    if ( strArea[0] == '$' )
		break;

	    if ( strArea[0] == '-' )
	    {
		fpArea = stdin;
	    }
	    else
	    {
		if ( ( fpArea = fopen( strArea, "r" ) ) == NULL )
		{
		    perror( strArea );
		    exit( 1 );
		}
	    }

	    for ( ; ; )
	    {
		char *word;

		if ( fread_letter( fpArea ) != '#' )
		{
		    bug( "Boot_db: # not found.", 0 );
		    exit( 1 );
		}

		word = fread_word( fpArea );

		     if ( word[0] == '$'               )                 break;
		else if ( !str_cmp( word, "AREA"     ) ) load_area    (fpArea);
		else if ( !str_cmp( word, "HELPS"    ) ) load_helps   (fpArea);
		else if ( !str_cmp( word, "MOBILES"  ) ) load_mobiles (fpArea);
		else if ( !str_cmp( word, "OBJECTS"  ) ) load_objects (fpArea);
		else if ( !str_cmp( word, "RESETS"   ) ) load_resets  (fpArea);
		else if ( !str_cmp( word, "ROOMS"    ) ) load_rooms   (fpArea);
		else if ( !str_cmp( word, "SHOPS"    ) ) load_shops   (fpArea);
		else if ( !str_cmp( word, "SPECIALS" ) ) load_specials(fpArea);
		else
		{
		    bug( "Boot_db: bad section name.", 0 );
		    exit( 1 );
		}
	    }

	    if ( fpArea != stdin )
		fclose( fpArea );
	    fpArea = NULL;
	}
	fclose( fpList );
    }

    /*
     * Fix up exits.
     * Declare db booting over.
     * Reset all areas once.
     * Load up the notes file.
     */
    {
	fix_exits( );
	fBootDb	= FALSE;
	area_update( );
	load_notes( );
    }

    return;
}
Beispiel #10
0
/** main() */
int main(int argc, char *argv[])
{
  const char * fname[2] =
    { NULL, NULL };

  FILE * fp[2] =
    { NULL, NULL };

  compression_t compression[2] =
    { compression_unknown, compression_unknown };

  int rc[2] =
    { -1, -1 };

  int dc[2] =
    { -1, -1 };

  int ru[2] =
    { radians, radians };

  int du[2] =
    { radians, radians };

  ccarray_t * list[2] =
    { NULL, NULL };

  size_t capacity[2] =
    { 15000000, 15000000 };

  char head[2][MAX_HEADER_LENGTH];

  int beverbose = 0;
  int invert_match = 0;

  double r = -1;

  int i;
  size_t size1, size2, pos1, pos2;
  const obj_t * obj1, * obj2;
  //double rcd;

  /* parse command line */

  for ( i = 1; i < argc; ++i )
  {
    if ( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-help") == 0 ) {
      show_usage(stdout, argc, argv);
      return 0;
    }

    if ( strncmp(argv[i], "rc1=", 4) == 0 )
    {
      if ( sscanf(argv[i] + 4, "%d", &rc[0]) != 1 || rc[0] < 1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "rc2=", 4) == 0 )
    {
      if ( sscanf(argv[i] + 4, "%d", &rc[1]) != 1 || rc[1] < 1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "dc1=", 4) == 0 )
    {
      if ( sscanf(argv[i] + 4, "%d", &dc[0]) != 1 || dc[0] < 1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "dc2=", 4) == 0 )
    {
      if ( sscanf(argv[i] + 4, "%d", &dc[1]) != 1 || dc[1] < 1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "ru1=", 4) == 0 )
    {
      if ( (ru[0] = parse_unit(argv[i] + 4)) == -1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "ru2=", 4) == 0 )
    {
      if ( (ru[1] = parse_unit(argv[i] + 4)) == -1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "du1=", 4) == 0 )
    {
      if ( (du[0] = parse_unit(argv[i] + 4)) == -1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "du2=", 4) == 0 )
    {
      if ( (du[1] = parse_unit(argv[i] + 4)) == -1 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strncmp(argv[i], "r=", 2) == 0 )
    {
      if ( sscanf(argv[i] + 2, "%lf", &r) != 1 || r <= 0 ) {
        fprintf(stderr,"Invalid value of %s\n", argv[i]);
        return -1;
      }
    }
    else if ( strcmp(argv[i], "-i") == 0 ) {
      invert_match = 1;
    }
    else if ( strcmp(argv[i], "-v") == 0 ) {
      beverbose = 1;
    }
    else if ( !fname[0] ) {
      fname[0] = argv[i];
    }
    else if ( !fname[1] ) {
      fname[1] = argv[i];
    }
    else {
      fprintf(stderr, "Invalid argument '%s'. Note that only 2 input files are allowed\n", argv[i]);
      return -1;
    }
  }



  /* check command line inputs */

  if ( !fname[0] || !fname[1] ) {
    fprintf(stderr,"Two input file names expected\n");
    show_usage(stderr, argc, argv);
    return -1;
  }

  if ( rc[0] < 1 ) {
    fprintf(stderr,"rc1 argument is mandatory\n");
    show_usage(stderr, argc, argv);
    return -1;
  }

  if ( rc[1] < 1 ) {
    fprintf(stderr,"rc2 argument is mandatory\n");
    show_usage(stderr, argc, argv);
    return -1;
  }

  if ( dc[0] < 1 ) {
    fprintf(stderr,"dc1 argument is mandatory\n");
    show_usage(stderr, argc, argv);
    return -1;
  }

  if ( dc[1] < 1 ) {
    fprintf(stderr,"dc2 argument is mandatory\n");
    show_usage(stderr, argc, argv);
    return -1;
  }

  if ( (r *= (PI / (180 * 3600))) <= 0 ) {
    fprintf(stderr,"r argument is mandatory\n");
    show_usage(stderr, argc, argv);
    return -1;
  }




  /* check if input files are readable */
  for ( i = 0; i < 2; ++i )
  {
    if ( access(fname[i], R_OK) != 0 ) {
      fprintf(stderr, "Can't read %s: %s\n", fname[i], strerror(errno));
      return -1;
    }
  }


  /* allocate memory storage */
  for ( i = 0; i < 2; ++i )
  {
    if ( !(list[i] = ccarray_create(capacity[i], sizeof(obj_t))) ) {
      fprintf(stderr, "ccarray_create(capacity=%zu) fails: %s\n", capacity[i], strerror(errno));
      return -1;
    }
  }


  /* load input files */
  for ( i = 0; i < 2; ++i )
  {
    if ( beverbose ) {
      fprintf(stderr,"loading %s....\n", fname[i]);
    }

    if ( !(fp[i] = open_file(fname[i], &compression[i])) ) {
      fprintf(stderr, "Can't read '%s': %s\n", fname[i], strerror(errno));
      return -1;
    }
    if ( load_objects(fp[i], rc[i], dc[i], ru[i], du[i], head[i], list[i]) != 0 ) {
      fprintf(stderr, "Can't load %s\n", fname[i]);
      return -1;
    }
    close_file( fp[i], compression[i] );

    if ( beverbose ) {
      fprintf(stderr,"%s: %zu objects\n", fname[i], ccarray_size(list[i]));
    }

    if ( ccarray_size(list[i]) == capacity[i] && !feof(fp[i]) ) {
      fprintf(stderr, "load_objects() fails for %s: Too many objects. Try increase capacity1 (currently %zu)\n",
          fname[i], capacity[i]);
      return -1;
    }
  }


  /* sort lists */
  for ( i = 0; i < 2; ++i )
  {
    if ( beverbose ) {
      fprintf(stderr, "sort %s....\n", fname[i]);
    }
    //ccarray_sort(list[i], 0, ccarray_size(list[i]), cmpradec);
    ccarray_sort(list[i], 0, ccarray_size(list[i]), cmpdecra);
  }


  /* search pairs */
  if ( beverbose ) {
    fprintf(stderr,"search pairs...\n");
  }

  printf("%s\t%s\tdra\tddec\n", head[0], head[1]);

  size1 = ccarray_size(list[0]);
  size2 = ccarray_size(list[1]);


  double dra_closest=0;
  double ddec_closest=0;

  size_t imin=0;
  size_t imax=size2;

  for ( pos1 = 0; pos1 < size1; ++pos1 )
  {
	char line_closest [MAX_INPUT_LINE_LENGTH];
	line_closest[MAX_INPUT_LINE_LENGTH-1]=0;

    double decmin, decmax, dra, ddec;
    int objcount = 0;

    obj1 = ccarray_peek(list[0], pos1);

    decmin = obj1->dec - r;
    decmax = obj1->dec + r;

    get_index(list[1],&imin,&imax,size2,decmin,decmax);

    double rmin=r;
    double dr;

    for ( pos2=imin; pos2 < imax; ++pos2 )
    {
      obj2 = ccarray_peek(list[1], pos2);

      dra = (obj2->ra - obj1->ra) * cos((obj1->dec + obj2->dec) / 2);
      ddec = (obj2->dec - obj1->dec);

      dr=hypot(dra, ddec);
      if (  dr< rmin )
      {
    	  rmin=dr;

    	  dra_closest=dra;
    	  ddec_closest=ddec;

    	  strcpy(line_closest,obj2->line);

    	  if ( line_closest[MAX_INPUT_LINE_LENGTH - 1] != 0 ) {
    	  	        fprintf(stderr,"too long input line in this file\n");
    	  	        return -1;
    	  	      }

    	  ++objcount;
      }
    }
    if ( !invert_match && objcount>0) {
                printf("%s\t%s\t%+9.3f\t%+9.3f\n", obj1->line, line_closest, dra_closest * 180 * 3600 / PI, ddec_closest * 180 * 3600 / PI);
       }

    if ( invert_match && objcount == 0 ) {
      printf("%s\n", obj1->line);
    }
  }


  return 0;
}
Beispiel #11
0
int main(int argc, char *argv[]) {

  int i, x, y, q, inz;
  struct section *s;
  float f;

  if (sizeof(double) != 8) {
    fprintf(stderr, "MAIN: sizeof(double) == %d != 8. WLALINK will not work properly.\n", (int)(sizeof(double)));
    return -1;
  }

  atexit(procedures_at_exit);

  i = SUCCEEDED;

  if (argc > 2)
    x = parse_flags(argv, argc);
  else
    x = FAILED;

  if (load_file_failed == YES)
    return 0;

  if (x == FAILED) {
    printf("\nWLALINK GB-Z80/Z80/6502/65C02/6510/65816/HUC6280/SPC-700 WLA Macro Assembler Linker v5.8b\n");
    printf("Written by Ville Helin in 2000-2008 - In GitHub since 2014: https://github.com/vhelin/wla-dx\n");
    printf("USAGE: %s [OPTIONS] <OBJECT FILES> <OUTPUT FILE>\n\n", argv[0]);
    printf("Options:\n");
    printf("-b  Program file output\n");
    printf("-d  Discard unreferenced sections\n");
    printf("-i  Write list files\n");
    printf("-r  ROM file output (default)\n");
    printf("-s  Write also a NO$GMB symbol file\n");
    printf("-S  Write also a WLA symbol file\n");
    printf("-v  Verbose messages\n");
    printf("-l  LIBNAME\n");
    printf("    Search for library LIBNAME\n");
    printf("-L  DIRECTORY\n");
    printf("    Add DIRECTORY to library search path\n\n");
    return 0;
  }

  global_unique_label_map = hashmap_new();
  namespace_map = hashmap_new();

  /* load objects */
  if (load_objects(argv, argc) == FAILED)
    return 1;

  /* check file types */
  if (check_file_types() == FAILED)
    return 1;

  /* check object headers */
  if (check_headers() == FAILED)
    return 1;

  /* obtain the amount of rom banks */
  if (obtain_rombanks() == FAILED)
    return 1;

  banksizes = malloc(sizeof(int) * rombanks);
  if (banksizes == NULL) {
    fprintf(stderr, "MAIN: Out of memory error.\n");
    return 1;
  }
  bankaddress = malloc(sizeof(int) * rombanks);
  if (bankaddress == NULL) {
    fprintf(stderr, "MAIN: Out of memory error.\n");
    return 1;
  }

  /* obtain rom bank map and check the project integrity */
  if (obtain_rombankmap() == FAILED)
    return 1;

  /* obtain memory map and check the project integrity */
  if (obtain_memorymap() == FAILED)
    return 1;

  /* calculate romsize */
  for (romsize = 0, x = 0; x < rombanks; x++)
    romsize += banksizes[x];

  /* obtain source file names used in compiling */
  if (obtain_source_file_names() == FAILED)
    return 1;

  /* collect all defines, labels, outside references and pending (stack) calculations */
  if (collect_dlr() == FAILED)
    return 1;

  /* take rom size and allocate memory */
  if (allocate_rom() == FAILED)
    return 1;

  /* parse data blocks */
  if (parse_data_blocks() == FAILED)
    return 1;

  /* clean up the structures */
  if (clean_up_dlr() == FAILED)
    return 1;

  /* associate labels with their sections */
  if (fix_label_sections() == FAILED)
    return 1;

  /* drop all unreferenced sections */
  if (discard_unreferenced_sections == ON) {
    if (discard_unused_sections() == FAILED)
      return 1;
    /* remove dropped labels */
    discard_drop_labels();
  }

  /* correct 65816 library section addresses */
  if (cpu_65816 != 0) {
    if (correct_65816_library_sections() == FAILED)
      return 1;
  }

  /* if ROM size < 32KBs, correct SDSC tag sections' addresses */
  if (smstag_defined != 0 && romsize < 0x8000) {
    struct section *s = sec_first;
    int sub = 0x4000; /* assume 16KB ROM size */
    if (romsize < 0x4000)
      sub = 0x6000; /* assume 8KB ROM size */
    
    while (s != NULL) {
      if (strcmp(s->name, "!__WLA_SDSCTAG_STRINGS") == 0 ||
	  strcmp(s->name, "!__WLA_SDSCTAG_TIMEDATE") == 0) {
	/* these sections would originally go to 0x7Fnm, but as we now
	   assume that the ROM is smaller, we'll bring them down */
	s->address -= sub;
      }

      s = s->next;
    }
  }

#ifdef WLALINK_DEBUG
  printf("\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("*** LOADED LOADED LOADED LOADED LOADED LOADED LOADED LOADED LOADED ***\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  
  if (labels_first != NULL) {
    struct label *l = labels_first;

    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                         LABELS                                 ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");

    while (l != NULL) {
      debug_print_label(l);
      l = l->next;
    }
  }

  if (stacks_first != NULL) {
    struct stack *s = stacks_first;

    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                    (STACK) CALCULATIONS                        ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");

    while (s != NULL) {
      printf("----------------------------------------------------------------------\n");
      {
	int z;
	
	for (z = 0; z < s->stacksize; z++) {
	  struct stackitem *si = &s->stack[z];
	  printf(get_stack_item_description(si));
	}
      }
      printf("id: %d file: %s line: %d type: %d bank: %d position: %d\n", s->id, get_file_name(s->file_id), s->linenumber, s->type, s->bank, s->position);
      s = s->next;
    }
    printf("----------------------------------------------------------------------\n");
  }
#endif

  /* reserve the bytes the checksummers will use, so no (free type) sections will be placed there */
  reserve_checksum_bytes();
  
#ifdef WLALINK_DEBUG
  printf("\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("*** RESOLVED RESOLVED RESOLVED RESOLVED RESOLVED RESOLVED RESOLVED ***\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
  printf("**********************************************************************\n");
    
  if (sec_first != NULL) {
    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                         SECTIONS                               ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");
  }
#endif

  /* insert sections */
  if (insert_sections() == FAILED)
    return 1;

#ifdef WLALINK_DEBUG
  if (sec_first != NULL) {
    struct section *s = sec_first;
    while (s != NULL) {
      printf("----------------------------------------------------------------------\n");
      printf("name: \"%s\" file: %s\n", s->name, get_file_name(s->file_id));
      printf("id   : %d\n", s->id);
      printf("addr : %d\n", s->address);
      printf("stat : %d\n", s->status);
      printf("bank : %d\n", s->bank);
      printf("slot : %d\n", s->slot);
      printf("size : %d\n", s->size);
      printf("align: %d\n", s->alignment);
      s = s->next;
    }
    printf("----------------------------------------------------------------------\n");
  }

  if (labels_first != NULL) {
    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                         LABELS                                 ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");
  }
#endif

  /* compute the labels' addresses */
  if (fix_label_addresses() == FAILED)
    return 1;

#ifdef WLALINK_DEBUG
  if (labels_first != NULL) {
    struct label *l = labels_first;
    while (l != NULL) {
      debug_print_label(l);
      l = l->next;
    }
  }

  if (stacks_first != NULL) {
    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                    (STACK) CALCULATIONS                        ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");
  }
#endif
  
  /* compute pending calculations */
  if (compute_pending_calculations() == FAILED)
    return 1;

#ifdef WLALINK_DEBUG
  if (stacks_first != NULL) {
    struct stack *s = stacks_first;
    while (s != NULL) {
      printf("----------------------------------------------------------------------\n");
      {
	int z;
	
	for (z = 0; z < s->stacksize; z++) {
	  struct stackitem *si = &s->stack[z];
	  printf(get_stack_item_description(si));
	}
      }
      printf("id: %d file: %s line: %d type: %d bank: %d position: %d result: %d/$%x\n", s->id, get_file_name(s->file_id), s->linenumber, s->type, s->bank, s->position, s->result, s->result);
      s = s->next;
    }
    printf("----------------------------------------------------------------------\n");
  }

  if (reference_first != NULL) {
    printf("\n");
    printf("----------------------------------------------------------------------\n");
    printf("---                          REFERENCES                            ---\n");
    printf("----------------------------------------------------------------------\n");
    printf("\n");
  }
#endif

  /* transform computation stack definitions to ordinary definitions */
  if (transform_stack_definitions() == FAILED)
    return 1;

  /* fix references */
  if (fix_references() == FAILED)
    return 1;

#ifdef WLALINK_DEBUG
  if (reference_first != NULL) {
    struct reference *r = reference_first;
    while (r != NULL) {
      printf("name: \"%s\" file: %s\n", r->name, get_file_name(r->file_id));
      r = r->next;
    }
  }
#endif

  /* write checksums and other last minute data */
  if (compute_checksums() == FAILED)
    return 1;

  /* write rom file */
  if (write_rom_file(argv[argc - 1]) == FAILED)
    return 1;

  /* export symbolic information file */
  if (symbol_mode != SYMBOL_MODE_NONE) {
    if (write_symbol_file(argv[argc - 1], symbol_mode) == FAILED)
      return FAILED;
  }

  /* write list files */
  if (listfile_data == YES) {
    if (listfile_write_listfiles(sec_first) == FAILED)
      return FAILED;
  }

  /* show rom information */
  y = 0;
  if (verbose_mode == ON) {
    x = 0;
    for (i = 0; i < romsize; i++) {
      if (rom_usage[i] == 0 && x == 0) {
	x = 1;
	y = i;
      }
      else if (rom_usage[i] != 0 && x == 1) {
	if (y == (i - 1))
	  fprintf(stderr, "Free space at $%.4x.\n", y);
	else
	  fprintf(stderr, "Free space at $%.4x-$%.4x.\n", y, i - 1);
	x = 0;
      }
    }

    if (x == 1) {
      if (y == (i - 1))
	fprintf(stderr, "Free space at $%.4x.\n", y);
      else
	fprintf(stderr, "Free space at $%.4x-$%.4x.\n", y, i - 1);
    }

    for (y = 0, q = 0; y < romsize; q++) {
      for (x = 0, inz = 0; inz < banksizes[q]; inz++) {
	if (rom_usage[y++] == 0)
	  x++;
      }
      f = (((float)x)/banksizes[q]) * 100.0f;
      if (f == 100.0f)
	fprintf(stderr, "Bank %.2d has %.5d bytes (%.1f%%) free.\n", q, x, f);
      else
	fprintf(stderr, "Bank %.2d has %.5d bytes (%.2f%%) free.\n", q, x, f);
    }

    /* ROM data */
    if (output_mode == OUTPUT_ROM) {
      for (i = 0, y = 0; i < romsize; i++) {
	if (rom_usage[i] == 0)
	  y++;
      }

      fprintf(stderr, "%d unused bytes of total %d.\n", y, romsize);
      q = romsize;
    }
    /* program file data */
    else {
      for (i = program_start, y = 0; i < program_end; i++) {
	if (rom_usage[i] == 0)
	  y++;
      }

      q = program_end - program_start + 1;
      fprintf(stderr, "%d unused bytes (%.2f%%) of total %d.\n", y, (((double)y) / q) * 100, q);
    }

    if (file_header_size != 0)
      fprintf(stderr, "File header size %d.\n", file_header_size);
    if (file_footer_size != 0)
      fprintf(stderr, "File footer size %d.\n", file_footer_size);

    if (smc_status != 0) {
      fprintf(stderr, "512 additional bytes from the SMC ROM header.\n");
      i = file_header_size + file_footer_size + 512;
    }
    else
      i = file_header_size + file_footer_size;

    s = sec_hd_first;
    while (s != NULL) {
      fprintf(stderr, "Bank %d header section size %d.\n", s->bank, s->size);
      i += s->size;
      s = s->next;
    }

    if (i != 0) {
      fprintf(stderr, "Total %d additional bytes (from headers and footers).\n", i);
      fprintf(stderr, "Total size %d bytes.\n", i + q);
    }
  }

  return 0;
}