Example #1
0
void
piglit_init(int argc, char **argv)
{

	int rgb_tol = 0;
	int alpha_tol = 0;
	const char* blend_rgb_tol = getenv("PIGLIT_BLEND_RGB_TOLERANCE");
	const char* blend_alpha_tol = getenv("PIGLIT_BLEND_ALPHA_TOLERANCE");

	/* 
	 * Hack: Make driver tests on incorrect hardware feasible
	 * We want to be able to perform meaningful tests
	 * even when the blend unit of a GPU simply doesn't have
	 * sufficient precision.
	 */
	if (blend_rgb_tol)
	{
		rgb_tol = atoi(blend_rgb_tol);
		printf("Note: RGB tolerance changed to %i %s.\n", rgb_tol,
			rgb_tol == 1 ? "bit" : "bits");
	}
	if (blend_alpha_tol)
	{
		alpha_tol = atoi(blend_alpha_tol);
		printf("Note: Alpha tolerance changed to %i %s.\n", alpha_tol,
			alpha_tol == 1 ? "bit" : "bits");
	}
	/* A 0 passed in yields the default tolerance of 3.0/(1 << 8) ~= 0.01. */
	piglit_set_tolerance_for_bits(rgb_tol, rgb_tol, rgb_tol, alpha_tol);

	/* Initialize random images. */
	srand(0); 

	/* Fill src and dst with randomness. */
	dst_img.data = random_image_data();
	src_img.data = random_image_data();

	/* Fill exp_img with constant_color. */
	/* 
	 * You can use this as a check to make sure the test is working
	 * properly.
	 */
	exp_img.data = color_fill_data(constant_color[0],
				       constant_color[1],
				       constant_color[2],
				       constant_color[3]);

	image_init(&dst_img);
	image_init(&src_img);
	image_init(&exp_img);

} /* piglit_init */
Example #2
0
PyMODINIT_FUNC
init_spotify(void)
{
    PyObject *m;

    if (PyType_Ready(&SessionType) < 0)
        return;
    if (PyType_Ready(&ArtistType) < 0)
        return;
    if (PyType_Ready(&ArtistBrowserType) < 0)
        return;
    if (PyType_Ready(&LinkType) < 0)
        return;
    if (PyType_Ready(&PlaylistType) < 0)
        return;
    if (PyType_Ready(&PlaylistContainerType) < 0)
        return;
    if (PyType_Ready(&ResultsType) < 0)
        return;
    if (PyType_Ready(&ToplistBrowserType) < 0)
        return;
    if (PyType_Ready(&TrackType) < 0)
        return;
    if (PyType_Ready(&ImageType) < 0)
        return;
    if (PyType_Ready(&UserType) < 0)
        return;

    m = Py_InitModule("_spotify", module_methods);
    if (m == NULL)
        return;

    PyObject *spotify = PyImport_ImportModule("spotify");
    PyObject *d = PyModule_GetDict(spotify);
    PyObject *s = PyUnicode_FromString("SpotifyError");

    SpotifyError = PyDict_GetItem(d, s);
    Py_INCREF(SpotifyError);

    SpotifyApiVersion = Py_BuildValue("i", SPOTIFY_API_VERSION);
    Py_INCREF(SpotifyApiVersion);
    PyModule_AddObject(m, "api_version", SpotifyApiVersion);
    album_init(m);
    albumbrowser_init(m);
    artist_init(m);
    artistbrowser_init(m);
    link_init(m);
    playlist_init(m);
    playlistcontainer_init(m);
    session_init(m);
    search_init(m);
    toplistbrowser_init(m);
    track_init(m);
    image_init(m);
    user_init(m);
}
Example #3
0
/* initialize blue and opengl stuff */
void blue_gl_init(INITFUNC_ARGS){
    /* Blue type initialization */
    window_type = window_init(lib, Module);
    view_type   = view_init(lib, Module);
    layer_type  = layer_init(lib, Module);
    shape_type  = shape_init(lib, Module);
    image_type  = image_init(lib, Module);
    light_type  = light_init(lib, Module);
    text_type  = text_init(lib, Module);
}
Example #4
0
list_t * push_jobs(list_t * files, clinfo_t * clinfo
                   , Eina_Hash *map_histo)
{
    int code;
    list_t * job_waits = NULL;
    int count = 0;
    int histo_done = eina_hash_population(map_histo);
    int global = list_size(files);
    while(files != NULL) {
        char * filename = files->value;
        files = files->next;

        histogram_t *cached_elem = eina_hash_find(map_histo, filename);
        if(cached_elem)
            continue;

        image_t * image = image_init();
        image->path = filename;
        image = read_image(image);
        if (image == NULL) {
            continue;
        }
        if (image->size[0] > *clinfo->max_width
                || image->size[1] > *clinfo->max_heigth) {
            printf("Ignoring %s, width=%i, height=%i\n", filename
                   , image->size[0], image->size[1]);
            image_free(image);
            continue;
        }

        job_t * job = job_init();
        code = init_job_from_image(image, job);
        if(code == EXIT_FAILURE) {
            fprintf(stderr, "Could not init job from image %i\n"
                    , code);
            return NULL;
        }
        generate_histogram(clinfo, image, job);
        clFlush(clinfo->command_queue);
        count++;
        if ( count > 50 ) {
            histogram_t *histo = wait_and_fetch_histo_from_job(job);
            eina_hash_add(map_histo, strdup(histo->file), histo);
            histo_done++;
            count--;
            if(histo_done % 50 == 0) {
                printf("Processed %i / %i\n", histo_done, global);
                write_histogram_to_file(CACHE_FILE, map_histo);
            }
        } else {
            job_waits = list_append(job_waits, job);
        }
    }
    return job_waits;
}
Example #5
0
static int start(effect* e)
{
    mosaic_t * priv = e->priv;

    image_init(e);
    image_set_threshold_y(e, MAGIC_THRESHOLD);
    priv->bgIsSet = 0;

    priv->stat = 1;
    return 0;
}
Example #6
0
int gp_init() {
	if(common_init()) return -1; //armv6 works.
	if(cmd_init()) return -1;
	if(memory_init()) return -1;
	if(task_init()) return -1;
	if(bdev_init()) return -1;
	if(image_init()) return -1;
	if(nvram_init()) return -1;
	if(fs_init()) return -1;
	if(fb_init()) return -1;
	gGpHasInit = TRUE;
	return 0;
}
Example #7
0
int main(int argc, char **argv)
{
#ifdef HAVE_FT2
  const char *text = "Test text!";
  const char *font = "arial.ttf";
  const char *file = "ttftest.gif";
  const char *bg = "heading-yellow.gif";
  const char *color = "#000000";
  
  log_init(STDOUT_FILENO, LOG_ALL, L_warning);
  io_init_except(STDOUT_FILENO, STDOUT_FILENO, STDOUT_FILENO);
  mem_init();
  dlink_init();
  gif_init();
  image_init();
  ttf_init();
  
  ttftest_log = log_source_register("ttftest");
  
  log_level(LOG_ALL, L_verbose);
  
  if(argc > 1)
    text = argv[1];
  if(argc > 2)
    font = argv[2];
  if(argc > 3)
    file = argv[3];
  if(argc > 4)
    bg = argv[4];
  if(argc > 5)
    color = argv[5];

  ttftest_write(text, font, file, bg, color);

  log_level(LOG_ALL, L_warning);
  
  log_source_unregister(ttftest_log);
  
  ttf_shutdown();
  image_shutdown();
  gif_shutdown();
  dlink_shutdown();
  mem_shutdown();
  log_shutdown();
  io_shutdown();
#endif  
  return 0;
}
Example #8
0
void
image_read (Image* image, char* fn)
{
    FILE* fp;
    int i;
    char buf[1024];

    image_init (image);  /* Leaks if image previously used */
    fp = fopen (fn, "rb");
    if (!fp) return;

    if (fgets (buf, 1024, fp) == NULL) {
        printf ("Error reading pfm file\n");
        return;
    }
    if (strcmp (buf, "Pf\n")) {
        fclose (fp);
        printf ("Error reading pfm file\n");
        return;
    }

    if (fgets (buf, 1024, fp) == NULL) {
        printf ("Error reading pfm file\n");
        return;
    }
    if (sscanf (buf, "%d %d", &image->dims[0], &image->dims[1]) != 2) {
        fclose (fp);
        printf ("Error reading pfm file\n");
        return;
    }

    if (fgets (buf, 1024, fp) == NULL) {
        printf ("Error reading pfm file\n");
        return;
    }
    if (strcmp (buf, "-1\n")) {
        fclose (fp);
        printf ("Error reading pfm file\n");
        return;
    }
    image_malloc (image, image->dims);
    for (i = 0; i < image_size(image); i++) {
        float fv;
        fread (&fv, sizeof(float), 1, fp);
        image_data(image)[i] = (double) fv;
    }
    fclose (fp);
}
Example #9
0
/*------------------------------------------------- image_file_init -----
  |  Function image_file_init
  |
  |  Purpose:  Reads image data in from a file before a subsequent call to
  |            image_init
  |       
  |
  |  Parameters: image_file (IN) -- open FILE handle with image data
  |                
  |
  |  Returns:  Image instance
  *-------------------------------------------------------------------*/
Image * image_file_init(FILE * image_file) {
    Image * retval;
    char * header = (char *)malloc(sizeof(char) * BUFSIZ);
    char c;
    int pos = 0;
    while ((c = fgetc(image_file)) != EOF && c != '\n') {
        *(header + (pos * sizeof(char))) = c;
        pos++;
    }

    unsigned int rows = 0;
    unsigned int columns = 0;
    
    header_parse(header, &rows, &columns);

    unsigned int rowsize = sizeof(char) * (columns + 2);
    unsigned int row_mem_size = sizeof(char) * (columns + 1);
    unsigned int row_actual_size = row_mem_size + 8 - ((row_mem_size + 8) % 16);
    debug("Rowsize is %d\n", rowsize);
    
    char ** pixel_chars = malloc(sizeof(char *) * rows);

    unsigned int row;
    for (row = 0; row < rows; row++) {
        *(pixel_chars + (row * row_actual_size)) = (char *) malloc(row_actual_size);

        char * row_data = malloc(sizeof(char) * 1000);
        row_data = fgets(row_data, 1000, image_file);
          
        if (row_data == NULL || ferror(image_file)) {
            error("Image data invalid! Expected to read %d rows", rows);
            exit(EXIT_FAILURE);
        }

        *(row_data + columns) = '\0';
        *(pixel_chars + (row * row_actual_size)) = strcpy(*(pixel_chars + (row * row_actual_size)), row_data);

        debug("Allocated row %d at %u", row, *(pixel_chars + (row * row_actual_size)));
        debug("Allocated row %s", *(pixel_chars + (row * row_actual_size)));
    }
    
    retval = image_init(pixel_chars, rows, columns);
    free(header);
    free(pixel_chars);

    return retval;
}
Example #10
0
/*----------------------------------------------------------------------------*/
void video_init(my1video_t *video)
{
	image_init(&video->image);
	video->frame = 0x0; /* frame is pure pointer! */
	buffer_init(&video->vbuff);
	video->ppass = 0x0;
	video->count = -1; video->index = -1;
	video->width = 0; video->height = 0;
	video->flags = 0; /* reset flags */
	video->flags |= VIDEO_FLAG_LOOP; /* loop it! */
	video->flags |= VIDEO_FLAG_STEP; /* step it! */
	video->flags |= VIDEO_FLAG_NO_FILTER; /* do not filter initially */
	video->flags &= ~VIDEO_FLAG_DO_UPDATE; /* do not update initially */
	video->flags &= ~VIDEO_FLAG_NEW_FRAME; /* no new frame */
	video->flags &= ~VIDEO_FLAG_IS_PAUSED; /* NOT paused initially */
	video->flags &= ~VIDEO_FLAG_DO_GOBACK; /* disable reverse flag! */
	video->inkey = 0;
	video->capture = 0x0;
	video->display = 0x0;
	video->parent_ = 0x0;
}
Example #11
0
int main()
{
  printf("test\n");

  log_init(STDOUT_FILENO, LOG_ALL, L_status);
  io_init_except(STDOUT_FILENO, STDOUT_FILENO, STDOUT_FILENO);
  mem_init();
  dlink_init();
  gif_init();
  image_init();

  imagetest_write();

  image_shutdown();
  gif_shutdown();
  dlink_shutdown();
  mem_shutdown();
  log_shutdown();
  io_shutdown();

  return 0;
}
Example #12
0
int
main(int argc, char **argv )
{
    char ch;
    while ( (ch = getopt(argc, argv, "hi:c:s:")) != -1 )
    switch (ch) {
        case 'h':
            break;
        case 'i':
            image_filename = optarg;
            break;
        case 's':
            symbol_name = optarg;
            break;
        case 'c':
            c_filename = optarg;
            break;
        default:
            fprintf(stderr, "bad usage [%c]\n", ch);
            return EX_USAGE;
    }
    argc -= optind;
    argv += optind;
    if (argc != 1) {
        fprintf(stderr, "type root directory\n");
        return EX_USAGE;
    }
    if (!c_filename && !image_filename) {
        fprintf(stderr, "bad usage, use -i or -c, or both.\n");
        return EX_USAGE;
    }
    if (image_init() == -1) return EX_OSERR;
    if (c_init() == -1) return EX_OSERR;
    if (scan(argv[0]) == -1) return EX_OSERR;
    if (build(argv[0]) == -1) return EX_SOFTWARE;
    return EX_OK;
}
Example #13
0
int main()
{
  log_init(STDOUT_FILENO, LOG_ALL, L_status);
  io_init_except(STDOUT_FILENO, STDOUT_FILENO, STDOUT_FILENO);
  mem_init();
  dlink_init();
  gif_init();
  image_init();
  timer_init();
  graph_init();
  
  graphtest_write();

  graph_shutdown();
  timer_shutdown();
  image_shutdown();
  gif_shutdown();
  dlink_shutdown();
  mem_shutdown();
  log_shutdown();
  io_shutdown();
  
  return 0;
}
Example #14
0
void running_machine::start()
{
	// initialize basic can't-fail systems here
	config_init(*this);
	m_input = auto_alloc(*this, input_manager(*this));
	output_init(*this);
	palette_init(*this);
	m_render = auto_alloc(*this, render_manager(*this));
	generic_machine_init(*this);
	generic_sound_init(*this);

	// allocate a soft_reset timer
	m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this));

	// init the osd layer
	m_osd.init(*this);

	// create the video manager
	m_video = auto_alloc(*this, video_manager(*this));
	ui_init(*this);

	// initialize the base time (needed for doing record/playback)
	::time(&m_base_time);

	// initialize the input system and input ports for the game
	// this must be done before memory_init in order to allow specifying
	// callbacks based on input port tags
	time_t newbase = input_port_init(*this);
	if (newbase != 0)
		m_base_time = newbase;

	// intialize UI input
	ui_input_init(*this);

	// initialize the streams engine before the sound devices start
	m_sound = auto_alloc(*this, sound_manager(*this));

	// first load ROMs, then populate memory, and finally initialize CPUs
	// these operations must proceed in this order
	rom_init(*this);
	memory_init(*this);
	watchdog_init(*this);

	// must happen after memory_init because this relies on generic.spriteram
	generic_video_init(*this);

	// allocate the gfx elements prior to device initialization
	gfx_init(*this);

	// initialize natural keyboard support
	inputx_init(*this);

	// initialize image devices
	image_init(*this);
	tilemap_init(*this);
	crosshair_init(*this);

	// initialize the debugger
	if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
		debugger_init(*this);

	// call the game driver's init function
	// this is where decryption is done and memory maps are altered
	// so this location in the init order is important
	ui_set_startup_text(*this, "Initializing...", true);

	// start up the devices
	const_cast<device_list &>(devicelist()).start_all();

	// if we're coming in with a savegame request, process it now
	const char *savegame = options().state();
	if (savegame[0] != 0)
		schedule_load(savegame);

	// if we're in autosave mode, schedule a load
	else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0)
		schedule_load("auto");

	// set up the cheat engine
	m_cheat = auto_alloc(*this, cheat_manager(*this));

	// disallow save state registrations starting here
	m_save.allow_registration(false);
}
Example #15
0
void running_machine::start()
{
	/* initialize basic can't-fail systems here */
	fileio_init(this);
	config_init(this);
	input_init(this);
	output_init(this);
	state_init(this);
	state_save_allow_registration(this, true);
	palette_init(this);
	render_init(this);
	ui_init(this);
	generic_machine_init(this);
	generic_video_init(this);
	generic_sound_init(this);

	/* initialize the timers and allocate a soft_reset timer
	   this must be done before cpu_init so that CPU's can allocate timers */
	timer_init(this);
	m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL);

	/* init the osd layer */
	osd_init(this);

	/* initialize the base time (needed for doing record/playback) */
	time(&m_base_time);

	/* initialize the input system and input ports for the game
	   this must be done before memory_init in order to allow specifying
	   callbacks based on input port tags */
	time_t newbase = input_port_init(this, m_game.ipt);
	if (newbase != 0)
		m_base_time = newbase;

	/* intialize UI input */
	ui_input_init(this);

	/* initialize the streams engine before the sound devices start */
	streams_init(this);

	/* first load ROMs, then populate memory, and finally initialize CPUs
	   these operations must proceed in this order */
	rom_init(this);
	memory_init(this);
	watchdog_init(this);

	/* allocate the gfx elements prior to device initialization */
	gfx_init(this);

	/* initialize natural keyboard support */
	inputx_init(this);

	/* initialize image devices */
	image_init(this);

	/* start up the devices */
	m_devicelist.start_all();

	/* call the game driver's init function
	   this is where decryption is done and memory maps are altered
	   so this location in the init order is important */
	ui_set_startup_text(this, "Initializing...", true);
	if (m_game.driver_init != NULL)
		(*m_game.driver_init)(this);

	/* finish image devices init process */
	image_postdevice_init(this);

	/* start the video and audio hardware */
	video_init(this);
	tilemap_init(this);
	crosshair_init(this);

	sound_init(this);

	/* initialize the debugger */
	if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
		debugger_init(this);

	/* call the driver's _START callbacks */
	if (m_config.m_machine_start != NULL)
		(*m_config.m_machine_start)(this);
	if (m_config.m_sound_start != NULL)
		(*m_config.m_sound_start)(this);
	if (m_config.m_video_start != NULL)
		(*m_config.m_video_start)(this);

	/* set up the cheat engine */    
	cheat_init(this);
	/* set up the hiscore engine */    
    hiscore_init(this);

	/* disallow save state registrations starting here */
	state_save_allow_registration(this, false);
}
Example #16
0
void running_machine::start()
{
	// initialize basic can't-fail systems here
	fileio_init(this);
	config_init(this);
	input_init(this);
	output_init(this);
	state_init(this);
	state_save_allow_registration(this, true);
	palette_init(this);
	render_init(this);
	ui_init(this);
	generic_machine_init(this);
	generic_video_init(this);
	generic_sound_init(this);

	// initialize the timers and allocate a soft_reset timer
	// this must be done before cpu_init so that CPU's can allocate timers
	timer_init(this);
	m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL);

	// init the osd layer
	osd_init(this);

	// initialize the base time (needed for doing record/playback)
	time(&m_base_time);

	// initialize the input system and input ports for the game
	// this must be done before memory_init in order to allow specifying
	// callbacks based on input port tags
	time_t newbase = input_port_init(this, m_game.ipt);
	if (newbase != 0)
		m_base_time = newbase;

	// intialize UI input
	ui_input_init(this);

	// initialize the streams engine before the sound devices start
	streams_init(this);

	// first load ROMs, then populate memory, and finally initialize CPUs
	// these operations must proceed in this order
	rom_init(this);
	memory_init(this);
	watchdog_init(this);

	// allocate the gfx elements prior to device initialization
	gfx_init(this);

	// initialize natural keyboard support
	inputx_init(this);

	// initialize image devices
	image_init(this);

	// start up the devices
	m_devicelist.start_all();

	// call the game driver's init function
	// this is where decryption is done and memory maps are altered
	// so this location in the init order is important
	ui_set_startup_text(this, "Initializing...", true);
	if (m_game.driver_init != NULL)
		(*m_game.driver_init)(this);

	// finish image devices init process
	image_postdevice_init(this);

	// start the video and audio hardware
	video_init(this);
	tilemap_init(this);
	crosshair_init(this);

	sound_init(this);

	// initialize the debugger
	if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
		debugger_init(this);

	// call the driver's _START callbacks
	if (m_config.m_machine_start != NULL)
		(*m_config.m_machine_start)(this);
	if (m_config.m_sound_start != NULL)
		(*m_config.m_sound_start)(this);
	if (m_config.m_video_start != NULL)
		(*m_config.m_video_start)(this);

	// if we're coming in with a savegame request, process it now
	const char *savegame = options_get_string(&m_options, OPTION_STATE);
	if (savegame[0] != 0)
		schedule_load(savegame);

	// if we're in autosave mode, schedule a load
	else if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) != 0)
		schedule_load("auto");

	// set up the cheat engine
	if (options_get_bool(&m_options, OPTION_CHEAT))
		cheat_init(this);

	// disallow save state registrations starting here
	state_save_allow_registration(this, false);
}
Example #17
0
int main() {
  lua_State *lua = luaL_newstate();
  luaL_openlibs(lua);


  motor_Config config;
  l_motor_register(lua);
  l_audio_register(lua);
  l_graphics_register(lua);
  l_image_register(lua);
  l_keyboard_register(lua);
  l_mouse_register(lua);
  l_filesystem_register(lua);
  l_timer_register(lua);
  l_math_register(lua);
  l_event_register(lua);
  l_joystick_register(lua);

  chdir("/love");
  l_boot(lua, &config);

  if(config.identity) {
    filesystem_setIdentity(config.identity, false);
  }

  image_init();
  joystick_init();
  keyboard_init();
  graphics_init(config.window.width, config.window.height);
  audio_init();
  math_init();


  if(luaL_dofile(lua, "main.lua")) {
    printf("Error: %s\n", lua_tostring(lua, -1));
  }

  lua_pushcfunction(lua, errorhandler);
  lua_getglobal(lua, "love");
  lua_pushstring(lua, "load");
  lua_rawget(lua, -2);
  /*if(lua_pcall(lua, 0, 0, 1)) {
    printf("Error in love.load: %s\n", lua_tostring(lua, -1));
  }
  */
  pcall(lua, 0);
  lua_pop(lua, 1);

  lua_pushcfunction(lua, errorhandler);

  mainLoopData.luaState = lua;
  mainLoopData.errhand = luaL_ref(lua, LUA_REGISTRYINDEX);

  timer_init();
#ifdef EMSCRIPTEN
  emscripten_set_main_loop_arg(main_loop, &mainLoopData, 0, 1);
#else
  for(;;) {
    main_loop(&mainLoopData);
  }
#endif
}
Example #18
0
/* Parse image settings. */
static struct image *
parse_image_settings(struct data *data, xmlNodePtr node)
{
    struct image *img;

    g_assert(data != NULL);
    g_assert(node != NULL);

    g_debug("in parse_image_settings");

    /* find <settings> element's children node */
    while (node != NULL)
    {
        if ((!xmlStrcmp(node->name, (const xmlChar *) "settings")))
        {
            node = node->xmlChildrenNode;
            break;
        }
        node = node->next;
    }

    /* FIXME: invalid xml. Better error handling? */
    g_assert(node != NULL);

    img = image_init(data);

    /* find values */
    while (node != NULL) /* uri, text, gamma, rotate, nomod */
    {
        if (node->type != XML_ELEMENT_NODE)
        {
            node = node->next;
            continue;
        }
        if ((!xmlStrcmp(node->name, (const xmlChar *) "uri")))
        {   
            g_free(img->uri);
            img->uri = (gchar *)xmlNodeGetContent(node);
        }
        else if ((!xmlStrcmp(node->name, (const xmlChar *) "text")))
        {
            g_free(img->text);
            img->text = (gchar *)xmlNodeGetContent(node);
        }
        else if ((!xmlStrcmp(node->name, (const xmlChar *) "gamma")))
        {
            gchar *tmpstr = (gchar *)xmlNodeGetContent(node);
            img->gamma = (gfloat)g_ascii_strtod(tmpstr, NULL);
            xmlFree((xmlChar*)tmpstr);
        }
        else if ((!xmlStrcmp(node->name, (const xmlChar *) "rotate")))
        {
            gchar *tmpstr = (gchar *)xmlNodeGetContent(node);
            img->rotate = (gint)g_ascii_strtoull(tmpstr, NULL, 0);
            xmlFree((xmlChar*)tmpstr);
        }
        else if ((!xmlStrcmp(node->name, (const xmlChar *) "image_h")))
        {
            gchar *tmpstr = (gchar *)xmlNodeGetContent(node);
            img->image_h = (gint)g_ascii_strtoull(tmpstr, NULL, 0);
            xmlFree((xmlChar*)tmpstr);
        }
        else if ((!xmlStrcmp(node->name, (const xmlChar *) "nomodify")))
        {
            xmlChar *tmpstr = xmlNodeGetContent(node);
            if ((!xmlStrcmp(tmpstr, (const xmlChar *) "true")))
                img->nomodify = TRUE;
            else
                img->nomodify = FALSE;
            xmlFree((xmlChar*)tmpstr);
        }
        node = node->next;
    }

    return img;
}
Example #19
0
int main(int argc, char **argv)
{
    std::string fec_filename;
    std::string out_filename;
    std::vector<std::string> inp_filenames;
    int mode = MODE_ENCODE;
    image ctx;

    image_init(&ctx);
    ctx.roots = FEC_DEFAULT_ROOTS;

    while (1) {
        const static struct option long_options[] = {
            {"help", no_argument, 0, 'h'},
            {"encode", no_argument, 0, 'e'},
            {"decode", no_argument, 0, 'd'},
            {"sparse", no_argument, 0, 'S'},
            {"roots", required_argument, 0, 'r'},
            {"inplace", no_argument, 0, 'i'},
            {"mmap", no_argument, 0, 'm'},
            {"threads", required_argument, 0, 'j'},
            {"print-fec-size", required_argument, 0, 's'},
            {"get-ecc-start", required_argument, 0, 'E'},
            {"get-verity-start", required_argument, 0, 'V'},
            {"verbose", no_argument, 0, 'v'},
            {NULL, 0, 0, 0}
        };
        int c = getopt_long(argc, argv, "hedSr:imj:s:E:V:v", long_options, NULL);
        if (c < 0) {
            break;
        }

        switch (c) {
        case 'h':
            return usage();
        case 'S':
            ctx.sparse = true;
            break;
        case 'e':
            if (mode != MODE_ENCODE) {
                return usage();
            }
            break;
        case 'd':
            if (mode != MODE_ENCODE) {
                return usage();
            }
            mode = MODE_DECODE;
            break;
        case 'r':
            ctx.roots = (int)parse_arg(optarg, "roots", FEC_RSM);
            break;
        case 'i':
            ctx.inplace = true;
            break;
        case 'm':
            ctx.mmap = true;
            break;
        case 'j':
            ctx.threads = (int)parse_arg(optarg, "threads", IMAGE_MAX_THREADS);
            break;
        case 's':
            if (mode != MODE_ENCODE) {
                return usage();
            }
            mode = MODE_PRINTSIZE;
            ctx.inp_size = parse_arg(optarg, "print-fec-size", UINT64_MAX);
            break;
        case 'E':
            if (mode != MODE_ENCODE) {
                return usage();
            }
            mode = MODE_GETECCSTART;
            inp_filenames.push_back(optarg);
            break;
        case 'V':
            if (mode != MODE_ENCODE) {
                return usage();
            }
            mode = MODE_GETVERITYSTART;
            inp_filenames.push_back(optarg);
            break;
        case 'v':
            ctx.verbose = true;
            break;
        case '?':
            return usage();
        default:
            abort();
        }
    }

    argc -= optind;
    argv += optind;

    assert(ctx.roots > 0 && ctx.roots < FEC_RSM);

    /* check for input / output parameters */
    if (mode == MODE_ENCODE) {
        /* allow multiple input files */
        for (int i = 0; i < (argc - 1); ++i) {
            inp_filenames.push_back(argv[i]);
        }

        if (inp_filenames.empty()) {
            return usage();
        }

        /* the last one is the output file */
        fec_filename = argv[argc - 1];
    } else if (mode == MODE_DECODE) {
        if (argc < 2 || argc > 3) {
            return usage();
        } else if (argc == 3) {
            if (ctx.inplace) {
                return usage();
            }
            out_filename = argv[2];
        }

        inp_filenames.push_back(argv[0]);
        fec_filename = argv[1];
    }

    switch (mode) {
    case MODE_PRINTSIZE:
        return print_size(ctx);
    case MODE_GETECCSTART:
    case MODE_GETVERITYSTART:
        return get_start(mode, inp_filenames.front());
    case MODE_ENCODE:
        return encode(ctx, inp_filenames, fec_filename);
    case MODE_DECODE:
        return decode(ctx, inp_filenames, fec_filename, out_filename);
    default:
        abort();
    }

    return 1;
}
Example #20
0
void running_machine::start()
{
	// initialize basic can't-fail systems here
	config_init(*this);
	m_input = auto_alloc(*this, input_manager(*this));
	output_init(*this);
	palette_init(*this);
	m_render = auto_alloc(*this, render_manager(*this));
	generic_machine_init(*this);

	// allocate a soft_reset timer
	m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this));

	// init the osd layer
	m_osd.init(*this);

	// create the video manager
	m_video = auto_alloc(*this, video_manager(*this));
	ui_init(*this);

	// initialize the base time (needed for doing record/playback)
	::time(&m_base_time);

	// initialize the input system and input ports for the game
	// this must be done before memory_init in order to allow specifying
	// callbacks based on input port tags
	time_t newbase = m_ioport.initialize();
	if (newbase != 0)
		m_base_time = newbase;

	// intialize UI input
	ui_input_init(*this);

	// initialize the streams engine before the sound devices start
	m_sound = auto_alloc(*this, sound_manager(*this));

	// first load ROMs, then populate memory, and finally initialize CPUs
	// these operations must proceed in this order
	rom_init(*this);
	m_memory.initialize();

	// initialize the watchdog
	m_watchdog_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::watchdog_fired), this));
	if (config().m_watchdog_vblank_count != 0 && primary_screen != NULL)
		primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(running_machine::watchdog_vblank), this));
	save().save_item(NAME(m_watchdog_enabled));
	save().save_item(NAME(m_watchdog_counter));

	// allocate the gfx elements prior to device initialization
	gfx_init(*this);

	// initialize image devices
	image_init(*this);
	m_tilemap = auto_alloc(*this, tilemap_manager(*this));
	crosshair_init(*this);
	network_init(*this);

	// initialize the debugger
	if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
		debugger_init(*this);

	// call the game driver's init function
	// this is where decryption is done and memory maps are altered
	// so this location in the init order is important
	ui_set_startup_text(*this, "Initializing...", true);

	// register callbacks for the devices, then start them
	add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(running_machine::reset_all_devices), this));
	add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(running_machine::stop_all_devices), this));
	save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this));
	start_all_devices();
	save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this));

	// if we're coming in with a savegame request, process it now
	const char *savegame = options().state();
	if (savegame[0] != 0)
		schedule_load(savegame);

	// if we're in autosave mode, schedule a load
	else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0)
		schedule_load("auto");

	// set up the cheat engine
	m_cheat = auto_alloc(*this, cheat_manager(*this));

	// allocate autoboot timer
	m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this));

	// initialize lua
	m_lua_engine.initialize();

	// disallow save state registrations starting here
	m_save.allow_registration(false);
}