Ejemplo n.º 1
0
static lisp_cell_t *subr_isinf(lisp_t *l, lisp_cell_t *args)
{
	UNUSED(l);
	return isinf(get_float(car(args))) ? gsym_tee() : gsym_nil();
}
Ejemplo n.º 2
0
 virtual float getYPixelsPerEm() const
 {
     return get_float("getYPixelsPerEm");
 }
Ejemplo n.º 3
0
static void check_default(struct conf **c, enum conf_opt o)
{
	switch(o)
	{
		case OPT_BURP_MODE:
			fail_unless(get_e_burp_mode(c[o])==BURP_MODE_UNSET);
			break;
		case OPT_LOCKFILE:
		case OPT_PIDFILE:
		case OPT_SSL_CERT_CA:
		case OPT_SSL_CERT:
		case OPT_SSL_KEY:
		case OPT_SSL_KEY_PASSWORD:
		case OPT_SSL_PEER_CN:
		case OPT_SSL_CIPHERS:
		case OPT_SSL_DHFILE:
		case OPT_CA_CONF:
		case OPT_CA_NAME:
		case OPT_CA_SERVER_NAME:
		case OPT_CA_BURP_CA:
		case OPT_CA_CSR_DIR:
		case OPT_CA_CRL:
		case OPT_PEER_VERSION:
		case OPT_CLIENT_LOCKDIR:
		case OPT_MONITOR_LOGFILE:
		case OPT_CNAME:
		case OPT_PASSWORD:
		case OPT_PASSWD:
		case OPT_SERVER:
		case OPT_ENCRYPTION_PASSWORD:
		case OPT_AUTOUPGRADE_OS:
		case OPT_AUTOUPGRADE_DIR:
		case OPT_BACKUP:
		case OPT_BACKUP2:
		case OPT_RESTOREPREFIX:
		case OPT_STRIP_FROM_PATH:
		case OPT_BROWSEFILE:
		case OPT_BROWSEDIR:
		case OPT_B_SCRIPT_PRE:
		case OPT_B_SCRIPT_POST:
		case OPT_R_SCRIPT_PRE:
		case OPT_R_SCRIPT_POST:
		case OPT_B_SCRIPT:
		case OPT_R_SCRIPT:
		case OPT_RESTORE_PATH:
		case OPT_ORIG_CLIENT:
		case OPT_CONFFILE:
		case OPT_USER:
		case OPT_GROUP:
		case OPT_DIRECTORY:
		case OPT_TIMESTAMP_FORMAT:
		case OPT_CLIENTCONFDIR:
		case OPT_S_SCRIPT_PRE:
		case OPT_S_SCRIPT_POST:
		case OPT_MANUAL_DELETE:
		case OPT_S_SCRIPT:
		case OPT_TIMER_SCRIPT:
		case OPT_N_SUCCESS_SCRIPT:
		case OPT_N_FAILURE_SCRIPT:
		case OPT_DEDUP_GROUP:
		case OPT_VSS_DRIVES:
		case OPT_REGEX:
		case OPT_SUPER_CLIENT:
		case OPT_MONITOR_EXE:
			fail_unless(get_string(c[o])==NULL);
			break;
		case OPT_RATELIMIT:
			fail_unless(get_float(c[o])==0);
			break;
		case OPT_CLIENT_IS_WINDOWS:
		case OPT_RANDOMISE:
		case OPT_B_SCRIPT_POST_RUN_ON_FAIL:
		case OPT_R_SCRIPT_POST_RUN_ON_FAIL:
		case OPT_SEND_CLIENT_CNTR:
		case OPT_BREAKPOINT:
		case OPT_SYSLOG:
		case OPT_PROGRESS_COUNTER:
		case OPT_MONITOR_BROWSE_CACHE:
		case OPT_S_SCRIPT_PRE_NOTIFY:
		case OPT_S_SCRIPT_POST_RUN_ON_FAIL:
		case OPT_S_SCRIPT_POST_NOTIFY:
		case OPT_S_SCRIPT_NOTIFY:
		case OPT_HARDLINKED_ARCHIVE:
		case OPT_N_SUCCESS_WARNINGS_ONLY:
		case OPT_N_SUCCESS_CHANGES_ONLY:
		case OPT_CROSS_ALL_FILESYSTEMS:
		case OPT_READ_ALL_FIFOS:
		case OPT_READ_ALL_BLOCKDEVS:
		case OPT_SPLIT_VSS:
		case OPT_STRIP_VSS:
		case OPT_ATIME:
		case OPT_SCAN_PROBLEM_RAISES_ERROR:
		case OPT_OVERWRITE:
		case OPT_CNAME_LOWERCASE:
		case OPT_STRIP:
		case OPT_MESSAGE:
		case OPT_CA_CRL_CHECK:
		case OPT_PORT_BACKUP:
		case OPT_PORT_RESTORE:
		case OPT_PORT_VERIFY:
		case OPT_PORT_LIST:
		case OPT_PORT_DELETE:
		case OPT_MAX_RESUME_ATTEMPTS:
		case OPT_FAIL_ON_WARNING:
		case OPT_SSL_VERIFY_PEER_EARLY:
		case OPT_FAILOVER_ON_BACKUP_ERROR:
		case OPT_BACKUP_FAILOVERS_LEFT:
			fail_unless(get_int(c[o])==0);
			break;
		case OPT_DAEMON:
		case OPT_STDOUT:
		case OPT_FORK:
		case OPT_ENABLED:
		case OPT_DIRECTORY_TREE:
		case OPT_PASSWORD_CHECK:
		case OPT_LIBRSYNC:
		case OPT_VERSION_WARN:
		case OPT_PATH_LENGTH_WARN:
		case OPT_CNAME_FQDN:
		case OPT_CLIENT_CAN_DELETE:
		case OPT_CLIENT_CAN_DIFF:
		case OPT_CLIENT_CAN_FORCE_BACKUP:
		case OPT_CLIENT_CAN_LIST:
		case OPT_CLIENT_CAN_MONITOR:
		case OPT_CLIENT_CAN_RESTORE:
		case OPT_CLIENT_CAN_VERIFY:
		case OPT_SERVER_CAN_RESTORE:
		case OPT_SERVER_CAN_OVERRIDE_INCLUDES:
		case OPT_B_SCRIPT_RESERVED_ARGS:
		case OPT_R_SCRIPT_RESERVED_ARGS:
		case OPT_GLOB_AFTER_SCRIPT_PRE:
		case OPT_ACL:
		case OPT_XATTR:
		case OPT_N_FAILURE_BACKUP_FAILOVERS_LEFT:
			fail_unless(get_int(c[o])==1);
			break;
		case OPT_NETWORK_TIMEOUT:
			fail_unless(get_int(c[o])==60*60*2);
			break;
		case OPT_SSL_COMPRESSION:
			fail_unless(get_int(c[o])==5);
			break;
        	case OPT_COMPRESSION:
			fail_unless(get_int(c[o])==9);
			break;
		case OPT_MAX_STORAGE_SUBDIRS:
			fail_unless(get_int(c[o])==30000);
			break;
		case OPT_MAX_HARDLINKS:
			fail_unless(get_int(c[o])==10000);
			break;
		case OPT_UMASK:
			fail_unless(get_mode_t(c[o])==0022);
			break;
		case OPT_STARTDIR:
		case OPT_B_SCRIPT_PRE_ARG:
		case OPT_B_SCRIPT_POST_ARG:
		case OPT_R_SCRIPT_PRE_ARG:
		case OPT_R_SCRIPT_POST_ARG:
		case OPT_B_SCRIPT_ARG:
		case OPT_R_SCRIPT_ARG:
		case OPT_S_SCRIPT_PRE_ARG:
		case OPT_S_SCRIPT_POST_ARG:
		case OPT_S_SCRIPT_ARG:
		case OPT_TIMER_ARG:
		case OPT_N_SUCCESS_ARG:
		case OPT_N_FAILURE_ARG:
		case OPT_RESTORE_CLIENTS:
		case OPT_SUPER_CLIENTS:
		case OPT_KEEP:
		case OPT_INCEXCDIR:
		case OPT_INCLUDE:
		case OPT_EXCLUDE:
		case OPT_FSCHGDIR:
		case OPT_NOBACKUP:
		case OPT_INCEXT:
		case OPT_EXCEXT:
		case OPT_INCREG:
		case OPT_EXCREG:
		case OPT_INCLOGIC:
		case OPT_EXCLOGIC:
		case OPT_EXCFS:
		case OPT_INCFS:
		case OPT_EXCOM:
		case OPT_INCGLOB:
		case OPT_FIFOS:
		case OPT_BLOCKDEVS:
		case OPT_LABEL:
		case OPT_PORT:
		case OPT_STATUS_PORT:
		case OPT_LISTEN:
		case OPT_LISTEN_STATUS:
		case OPT_MAX_CHILDREN:
		case OPT_MAX_STATUS_CHILDREN:
		case OPT_SERVER_FAILOVER:
			fail_unless(get_strlist(c[o])==NULL);
			break;
		case OPT_PROTOCOL:
			fail_unless(get_e_protocol(c[o])==PROTO_AUTO);
			break;
		case OPT_HARD_QUOTA:
		case OPT_SOFT_QUOTA:
		case OPT_MIN_FILE_SIZE:
		case OPT_MAX_FILE_SIZE:
		case OPT_LIBRSYNC_MAX_SIZE:
			fail_unless(get_uint64_t(c[o])==0);
			break;
		case OPT_RBLK_MEMORY_MAX:
			fail_unless(get_uint64_t(c[o])==256*1024*1024);
			break;
		case OPT_WORKING_DIR_RECOVERY_METHOD:
			fail_unless(get_e_recovery_method(c[o])==
				RECOVERY_METHOD_DELETE);
			break;
		case OPT_RSHASH:
			fail_unless(get_e_rshash(c[o])==RSHASH_UNSET);
			break;
		case OPT_CNTR:
			fail_unless(get_cntr(c)==NULL);
			break;
		case OPT_MAX:
			break;
		// No default, so we get compiler warnings if something was
		// missed.
	}
}
Ejemplo n.º 4
0
static bool ObtainCacheParticleData(Mesh *mesh,
                                    BL::Mesh *b_mesh,
                                    BL::Object *b_ob,
                                    ParticleCurveData *CData,
                                    bool background)
{
	int curvenum = 0;
	int keyno = 0;

	if(!(mesh && b_mesh && b_ob && CData))
		return false;

	Transform tfm = get_transform(b_ob->matrix_world());
	Transform itfm = transform_quick_inverse(tfm);

	BL::Object::modifiers_iterator b_mod;
	for(b_ob->modifiers.begin(b_mod); b_mod != b_ob->modifiers.end(); ++b_mod) {
		if((b_mod->type() == b_mod->type_PARTICLE_SYSTEM) && (background ? b_mod->show_render() : b_mod->show_viewport())) {
			BL::ParticleSystemModifier psmd((const PointerRNA)b_mod->ptr);
			BL::ParticleSystem b_psys((const PointerRNA)psmd.particle_system().ptr);
			BL::ParticleSettings b_part((const PointerRNA)b_psys.settings().ptr);

			if((b_part.render_type() == BL::ParticleSettings::render_type_PATH) && (b_part.type() == BL::ParticleSettings::type_HAIR)) {
				int shader = clamp(b_part.material()-1, 0, mesh->used_shaders.size()-1);
				int draw_step = background ? b_part.render_step() : b_part.draw_step();
				int totparts = b_psys.particles.length();
				int totchild = background ? b_psys.child_particles.length() : (int)((float)b_psys.child_particles.length() * (float)b_part.draw_percentage() / 100.0f);
				int totcurves = totchild;

				if(b_part.child_type() == 0 || totchild == 0)
					totcurves += totparts;

				if(totcurves == 0)
					continue;

				int ren_step = (1 << draw_step) + 1;
				if(b_part.kink() == BL::ParticleSettings::kink_SPIRAL)
					ren_step += b_part.kink_extra_steps();

				PointerRNA cpsys = RNA_pointer_get(&b_part.ptr, "cycles");

				CData->psys_firstcurve.push_back_slow(curvenum);
				CData->psys_curvenum.push_back_slow(totcurves);
				CData->psys_shader.push_back_slow(shader);

				float radius = get_float(cpsys, "radius_scale") * 0.5f;

				CData->psys_rootradius.push_back_slow(radius * get_float(cpsys, "root_width"));
				CData->psys_tipradius.push_back_slow(radius * get_float(cpsys, "tip_width"));
				CData->psys_shape.push_back_slow(get_float(cpsys, "shape"));
				CData->psys_closetip.push_back_slow(get_boolean(cpsys, "use_closetip"));

				int pa_no = 0;
				if(!(b_part.child_type() == 0) && totchild != 0)
					pa_no = totparts;

				int num_add = (totparts+totchild - pa_no);
				CData->curve_firstkey.reserve(CData->curve_firstkey.size() + num_add);
				CData->curve_keynum.reserve(CData->curve_keynum.size() + num_add);
				CData->curve_length.reserve(CData->curve_length.size() + num_add);
				CData->curvekey_co.reserve(CData->curvekey_co.size() + num_add*ren_step);
				CData->curvekey_time.reserve(CData->curvekey_time.size() + num_add*ren_step);

				for(; pa_no < totparts+totchild; pa_no++) {
					int keynum = 0;
					CData->curve_firstkey.push_back_slow(keyno);

					float curve_length = 0.0f;
					float3 pcKey;
					for(int step_no = 0; step_no < ren_step; step_no++) {
						float nco[3];
						b_psys.co_hair(*b_ob, pa_no, step_no, nco);
						float3 cKey = make_float3(nco[0], nco[1], nco[2]);
						cKey = transform_point(&itfm, cKey);
						if(step_no > 0) {
							float step_length = len(cKey - pcKey);
							if(step_length == 0.0f)
								continue;
							curve_length += step_length;
						}
						CData->curvekey_co.push_back_slow(cKey);
						CData->curvekey_time.push_back_slow(curve_length);
						pcKey = cKey;
						keynum++;
					}
					keyno += keynum;

					CData->curve_keynum.push_back_slow(keynum);
					CData->curve_length.push_back_slow(curve_length);
					curvenum++;
				}
			}
		}
	}

	return true;
}
Ejemplo n.º 5
0
void material_type::load( JsonObject &jsobj, const std::string & )
{
    mandatory( jsobj, was_loaded, "name", _name );

    mandatory( jsobj, was_loaded, "bash_resist", _bash_resist );
    mandatory( jsobj, was_loaded, "cut_resist", _cut_resist );
    mandatory( jsobj, was_loaded, "acid_resist", _acid_resist );
    mandatory( jsobj, was_loaded, "elec_resist", _elec_resist );
    mandatory( jsobj, was_loaded, "fire_resist", _fire_resist );
    mandatory( jsobj, was_loaded, "chip_resist", _chip_resist );
    mandatory( jsobj, was_loaded, "density", _density );

    assign( jsobj, "salvaged_into", _salvaged_into );
    optional( jsobj, was_loaded, "repaired_with", _repaired_with, "null" );
    optional( jsobj, was_loaded, "edible", _edible, false );
    optional( jsobj, was_loaded, "soft", _soft, false );

    auto arr = jsobj.get_array( "vitamins" );
    while( arr.has_more() ) {
        auto pair = arr.next_array();
        _vitamins.emplace( vitamin_id( pair.get_string( 0 ) ), pair.get_float( 1 ) );
    }

    mandatory( jsobj, was_loaded, "bash_dmg_verb", _bash_dmg_verb );
    mandatory( jsobj, was_loaded, "cut_dmg_verb", _cut_dmg_verb );

    JsonArray jsarr = jsobj.get_array( "dmg_adj" );
    while( jsarr.has_more() ) {
        _dmg_adj.push_back( jsarr.next_string() );
    }

    JsonArray burn_data_array = jsobj.get_array( "burn_data" );
    for( size_t intensity = 0; intensity < MAX_FIELD_DENSITY; intensity++ ) {
        if( burn_data_array.has_more() ) {
            JsonObject brn = burn_data_array.next_object();
            _burn_data[ intensity ] = load_mat_burn_data( brn );
        } else {
            // If not specified, supply default
            bool flammable = _fire_resist <= static_cast<int>( intensity );
            mat_burn_data mbd;
            if( flammable ) {
                mbd.burn = 1;
            }

            _burn_data[ intensity ] = mbd;
        }
    }
    auto bp_array = jsobj.get_array( "burn_products" );
    while( bp_array.has_more( ) ) {
        auto pair = bp_array.next_array();
        _burn_products.emplace_back( pair.get_string( 0 ), static_cast< float >( pair.get_float( 1 ) ) );
    }

    auto compactor_in_array = jsobj.get_array( "compact_accepts" );
    while( compactor_in_array.has_more( ) ) {
        _compact_accepts.emplace_back( compactor_in_array.next_string() );
    }
    auto compactor_out_array = jsobj.get_array( "compacts_into" );
    while( compactor_out_array.has_more( ) ) {
        _compacts_into.emplace_back( compactor_out_array.next_string() );
    }
}
Ejemplo n.º 6
0
void parse_cmdline (int argc, char **argv, int game_index)
{
    static float f_beam, f_flicker;
    char *resolution;
    char *joyname;
    char tmpres[10];
    int i;
    char *tmpstr;

    mame_argc = argc;
    mame_argv = argv;
    game = game_index;

    /* read graphic configuration */
    options.use_artwork = get_bool   ("config", "artwork",	NULL,  1);
    options.use_samples = get_bool   ("config", "samples",	NULL,  1);
    video_sync  = get_bool   ("config", "vsync",        NULL,  0);
    wait_vsync  = get_bool   ("config", "waitvsync",    NULL,  0);
    use_dirty	= get_bool	 ("config", "dirty",	NULL,	-1);
    options.antialias   = get_bool   ("config", "antialias",    NULL,  1);
    options.translucency = get_bool    ("config", "translucency", NULL, 1);

    tmpstr             = get_string ("config", "depth", NULL, "auto");
    options.color_depth = atoi(tmpstr);
    if (options.color_depth != 8 && options.color_depth != 16) options.color_depth = 0;	/* auto */

    skiplines   = get_int    ("config", "skiplines",    NULL, 0);
    skipcolumns = get_int    ("config", "skipcolumns",  NULL, 0);
    f_beam      = get_float  ("config", "beam",         NULL, 1.0);
    if (f_beam < 1.0) f_beam = 1.0;
    if (f_beam > 16.0) f_beam = 16.0;
    f_flicker   = get_float  ("config", "flicker",      NULL, 0.0);
    if (f_flicker < 0.0) f_flicker = 0.0;
    if (f_flicker > 100.0) f_flicker = 100.0;
    osd_gamma_correction = get_float ("config", "gamma",   NULL, 1.0);
    if (osd_gamma_correction < 0.5) osd_gamma_correction = 0.5;
    if (osd_gamma_correction > 2.0) osd_gamma_correction = 2.0;

    tmpstr = get_string ("config", "frameskip", "fs", "auto");
    if (!strcasecmp(tmpstr,"auto"))
    {
        frameskip = 0;
        autoframeskip = 1;
    }
    else
    {
        frameskip = atoi(tmpstr);
        autoframeskip = 0;
    }
    options.norotate  = get_bool ("config", "norotate",  NULL, 0);
    options.ror       = get_bool ("config", "ror",       NULL, 0);
    options.rol       = get_bool ("config", "rol",       NULL, 0);
    options.flipx     = get_bool ("config", "flipx",     NULL, 0);
    options.flipy     = get_bool ("config", "flipy",     NULL, 0);

    /* read sound configuration */
    soundcard           = get_int  ("config", "soundcard",  NULL, -1);
    options.use_emulated_ym3812 = !get_bool ("config", "ym3812opl",  NULL,  0);
    options.samplerate = get_int  ("config", "samplerate", "sr", 22050);
    if (options.samplerate < 5000) options.samplerate = 5000;
    if (options.samplerate > 44100) options.samplerate = 44100;
    usestereo           = get_bool ("config", "stereo",  NULL,  0);
    attenuation         = get_int  ("config", "volume",  NULL,  0);
    if (attenuation < -32) attenuation = -32;
    if (attenuation > 0) attenuation = 0;

    /* read input configuration */
    use_mouse = get_bool   ("config", "mouse",   NULL,  1);
    joyname   = get_string ("config", "joystick", "joy", "standard");

    /* misc configuration */
    options.cheat      = get_bool ("config", "cheat", NULL, 0);
    options.mame_debug = get_bool ("config", "debug", NULL, 0);

    cheatfile  = get_string ("config", "cheatfile", "cf", "cheat.dat");

    history_filename  = get_string ("config", "historyfile", NULL, "history.dat");    /* JCK 980917 */

    mameinfo_filename  = get_string ("config", "mameinfofile", NULL, "mameinfo.dat");    /* JCK 980917 */

    /* get resolution */
    resolution  = get_string ("config", "resolution", NULL, "auto");

    /* set default subdirectories */
    nvdir      = get_string ("directory", "nvram",   NULL, "nvram");
    hidir      = get_string ("directory", "hi",      NULL, "hi");
    cfgdir     = get_string ("directory", "cfg",     NULL, "cfg");
    screenshotdir = get_string ("directory", "snap",     NULL, "snap");
    memcarddir = get_string ("directory", "memcard", NULL, "memcard");
    stadir     = get_string ("directory", "sta",     NULL, "sta");
    artworkdir = get_string ("directory", "artwork", NULL, "artwork");

    cheatdir = get_string ("directory", "cheat", NULL, ".");

    logerror("cheatfile = %s - cheatdir = %s\n",cheatfile,cheatdir);

    tmpstr = get_string ("config", "language", NULL, "english");
    options.language_file = osd_fopen(0,tmpstr,OSD_FILETYPE_LANGUAGE,0);

    /* this is handled externally cause the audit stuff needs it, too */
    get_rom_sample_path (argc, argv, game_index);

    /* process some parameters */
    options.beam = (int)(f_beam * 0x00010000);
    if (options.beam < 0x00010000)
        options.beam = 0x00010000;
    if (options.beam > 0x00100000)
        options.beam = 0x00100000;

    options.flicker = (int)(f_flicker * 2.55);
    if (options.flicker < 0)
        options.flicker = 0;
    if (options.flicker > 255)
        options.flicker = 255;

    /* any option that starts with a digit is taken as a resolution option */
    /* this is to handle the old "-wxh" commandline option. */
    for (i = 1; i < argc; i++)
    {
        if (argv[i][0] == '-' && isdigit(argv[i][1]) &&
                (strstr(argv[i],"x") || strstr(argv[i],"X")))
            resolution = &argv[i][1];
    }

    /* break up resolution into gfx_width and gfx_height */
    gfx_height = gfx_width = 0;
    if (strcasecmp (resolution, "auto") != 0)
    {
        char *tmp;
        strncpy (tmpres, resolution, 10);
        tmp = strtok (tmpres, "xX");
        gfx_width = atoi (tmp);
        tmp = strtok (0, "xX");
        if (tmp)
            gfx_height = atoi (tmp);

        options.vector_width = gfx_width;
        options.vector_height = gfx_height;
    }

    /* convert joystick name into an Allegro-compliant joystick signature */
    joystick = -2; /* default to invalid value */

    for (i = 0; joy_table[i].name != NULL; i++)
    {
        if (strcasecmp (joy_table[i].name, joyname) == 0)
        {
            joystick = joy_table[i].id;
            logerror("using joystick %s = %08x\n",
                     joyname,joy_table[i].id);
            break;
        }
    }

    if (joystick == -2)
    {
        logerror("%s is not a valid entry for a joystick\n",
                 joyname);
        joystick = JOY_TYPE_NONE;
    }

    /* Underclock settings */
    underclock_sound = get_int ("config", "uclocks",   NULL, 0);
    underclock_cpu   = get_int ("config", "uclock",    NULL, 0);

    /* Fast sound setting */
    fast_sound       = get_bool("config", "fastsound", NULL, 0);

    /* Rotate controls */
    rotate_controls       = get_bool("config", "rotatecontrols", NULL, 0);
}
Ejemplo n.º 7
0
TILED_MAP* tiled_load_tmx_file (const char *filename)
{
    TILED_MAP *map;
    xmlDoc *doc;
    xmlNode *root;
    char *str;

    if (!filename)
        return NULL;

    LIBXML_TEST_VERSION

    doc = xmlReadFile (filename, NULL, 0);
    if (!doc)
        return NULL;

    ALLEGRO_PATH *mapdir = al_create_path (filename);
    al_set_path_filename (mapdir, NULL);

    if (!al_change_directory (al_path_cstr (mapdir, ALLEGRO_NATIVE_PATH_SEP))) {
        printf ("Failed to change directory.");
    }

    al_destroy_path (mapdir);

    root = xmlDocGetRootElement (doc);

    map = al_malloc (sizeof (TILED_MAP));
    map->width = get_int (root, "width", 0);
    map->height = get_int (root, "height", 0);
    map->tile_width = get_int (root, "tilewidth", 0);
    map->tile_height = get_int (root, "tileheight", 0);
    map->strings = _al_list_create ();
    map->properties = get_properties (root, map);
    map->tiles = NULL;

    str = get_xml_attribute (root, "orientation");
    if (!strcmp (str, "orthogonal"))
        map->orientation = ORIENTATION_ORTHOGONAL;
    else if (!strcmp (str, "isometric"))
        map->orientation = ORIENTATION_ISOMETRIC;
    else if (!strcmp (str, "staggered"))
        map->orientation = ORIENTATION_STAGGERED;
    else
        map->orientation = ORIENTATION_UNKNOWN;

    // Tilesets
    LIST *tileset_nodes = get_children_for_name (root, 1, "tileset");
    map->tilesets = create_list (_al_list_size (tileset_nodes));

    LIST_ITEM *tileset_item = _al_list_front (tileset_nodes);
    while (tileset_item) {
        xmlNode *tileset_node = _al_list_item_data (tileset_item);
        TILED_TILESET *tileset = al_malloc (sizeof (TILED_TILESET));
        tileset->first_gid = get_int (tileset_node, "firstgid", 1);
        tileset->tile_width = get_int (tileset_node, "tilewidth", 0);
        tileset->tile_height = get_int (tileset_node, "tileheight", 0);
        tileset->name = get_str (tileset_node, "name");
        tileset->properties = get_properties (tileset_node, map);

        xmlNode *image_node = get_first_child_for_name (tileset_node, "image");
        tileset->image_width = get_int (image_node, "width", 0);
        tileset->image_height = get_int (image_node, "height", 0);
        tileset->image_source = get_str (image_node, "source");
        tileset->bitmap = al_load_bitmap (tileset->image_source);

        LIST *tile_nodes = get_children_for_name (tileset_node, 1, "tile");

        int tiles_per_row = tileset->image_width / tileset->tile_width;
        tileset->num_tiles = (tileset->image_width * tileset->image_height) /
                             (tileset->tile_width * tileset->tile_height);

        TILED_TILE *tile;
        tileset->tiles = al_malloc (tileset->num_tiles * sizeof (TILED_TILE));
        for (int i = 0; i < tileset->num_tiles; i++) {
            tile = &tileset->tiles[i];
            tile->id = i;
            tile->gid = i + tileset->first_gid;
            tile->tileset = tileset;
            tile->properties = NULL;

            int x = (i % tiles_per_row) * tileset->tile_width;
            int y = (i / tiles_per_row) * tileset->tile_height;
            tile->bitmap = al_create_sub_bitmap(tileset->bitmap, x, y,
                                                tileset->tile_width,
                                                tileset->tile_height);

            map->tiles = aa_insert (map->tiles, &tile->gid, tile, intcmp);
        }

		LIST_ITEM *tile_item = _al_list_front (tile_nodes);
		while (tile_item) {
			xmlNode *tile_node = (xmlNode*)_al_list_item_data (tile_item);
            int id = get_int (tile_node, "id", 0);

            tile = &tileset->tiles[id];
            tile->properties = get_properties (tile_node, map);

			tile_item = _al_list_next (tile_nodes, tile_item);
		}

		_al_list_destroy (tile_nodes);
		_al_list_push_back_ex (map->tilesets, tileset, dtor_tileset);
		tileset_item = _al_list_next (tileset_nodes, tileset_item);
    }

    _al_list_destroy (tileset_nodes);

    // Layers
    LIST *layer_nodes = get_children_for_name (root, 2, "layer", "objectgroup");
    map->layers = create_list (_al_list_size (layer_nodes));
    map->layers_fore = _al_list_create ();
    map->layers_back = _al_list_create ();

    LIST_ITEM *layer_item = _al_list_front (layer_nodes);
    while (layer_item) {
        xmlNode *layer_node = _al_list_item_data (layer_item);
        TILED_LAYER *layer = NULL;

        const char* type_str = (const char *)layer_node->name;
        if (!strcmp (type_str, "layer")) {
            layer = al_malloc (sizeof (TILED_LAYER_TILE));
            layer->type = LAYER_TYPE_TILE;
        }
        else if (!strcmp (type_str, "objectgroup")) {
            layer = al_malloc (sizeof (TILED_LAYER_OBJECT));
            layer->type = LAYER_TYPE_OBJECT;
        }

        layer->name = get_str (layer_node, "name");
        layer->width = get_int (layer_node, "width", 0);
        layer->height = get_int (layer_node, "height", 0);
        layer->opacity = get_float (layer_node, "opacity", 1.0);
        layer->map = map;
        layer->properties = get_properties (layer_node, map);

        char *order = aa_search (layer->properties, "order", charcmp);

        if (layer->type == LAYER_TYPE_TILE) {
            TILED_LAYER_TILE *tile_layer = (TILED_LAYER_TILE *)layer;
            tile_layer->tiles = al_malloc (layer->height * sizeof (TILED_TILE*));

            xmlNode *data_node = get_first_child_for_name (layer_node, "data");
            LIST *tile_nodes = get_children_for_name (data_node, 1, "tile");

            LIST_ITEM *tile_item = _al_list_front (tile_nodes);
            for (int j = 0; j < layer->height; j++) {
                tile_layer->tiles[j] = al_malloc (layer->width * sizeof (TILED_TILE*));
                for (int k = 0; k < layer->width; k++) {
                    xmlNode *tile_node = (xmlNode*)_al_list_item_data (tile_item);
                    int id = get_int (tile_node, "gid", 0);

                    if (id == 0) {
                        tile_layer->tiles[j][k] = NULL;
                    } else {
                        TILED_TILE *tile = aa_search (map->tiles, &id, intcmp);
                        tile_layer->tiles[j][k] = tile;
                    }

                    tile_item = _al_list_next (tile_nodes, tile_item);
                }
            }
            _al_list_destroy (tile_nodes);
        } else if (layer->type == LAYER_TYPE_OBJECT) {
            TILED_LAYER_OBJECT *object_layer = (TILED_LAYER_OBJECT *)layer;

            object_layer->objects = _al_list_create ();
            LIST *object_nodes = get_children_for_name (layer_node, 1, "object");

            LIST_ITEM *object_item = _al_list_front (object_nodes);
            while (object_item) {
                xmlNode *object_node = (xmlNode*)_al_list_item_data (object_item);
                TILED_OBJECT *cobj = NULL;

                int width = get_int (object_node, "width", 0);
                int gid = get_int (object_node, "gid", 0);
                int px = get_int (object_node, "x", 0);
                int py = get_int (object_node, "y", 0);

                if (width > 0) {
                    TILED_OBJECT_RECT *obj = al_malloc (sizeof (TILED_OBJECT_RECT));
                    obj->object.type = OBJECT_TYPE_RECT;
                    obj->width = width;
                    obj->height = get_int (object_node, "height", 0);

                    cobj = (TILED_OBJECT *) obj;
                } else if (gid > 0) {
                    TILED_OBJECT_TILE *obj = al_malloc (sizeof (TILED_OBJECT_TILE));
                    obj->object.type = OBJECT_TYPE_TILE;
                    obj->tile = aa_search (map->tiles, &gid, intcmp);

                    cobj = (TILED_OBJECT *) obj;
                } else {
                    TILED_OBJECT_GEOM *obj = al_malloc (sizeof (TILED_OBJECT_GEOM));
                    obj->object.type = OBJECT_TYPE_GEOM;

                    xmlNode *poly_node = get_first_child_for_name (object_node, "polyline");
                    if (poly_node) {
                        obj->points = get_float_points (poly_node, "points", &obj->num_points);
                        offset_points (px, py, obj->points, obj->num_points);
                    } else {
                        poly_node = get_first_child_for_name (object_node, "polygon");
                        if (poly_node)
                            obj->points = get_float_points (poly_node, "points", &obj->num_points);
                            offset_points (px, py, obj->points, obj->num_points);
                    }
                    cobj = (TILED_OBJECT *) obj;
                }

                cobj->x = px;
                cobj->y = py;
                cobj->name = get_str (object_node, "name");
                cobj->type_str = get_str (object_node, "type");
                cobj->properties = get_properties (object_node, map);

                _al_list_push_back_ex (object_layer->objects, cobj, dtor_object);
                object_item = _al_list_next (object_nodes, object_item);
            }
            _al_list_destroy (object_nodes);
        }

		layer_item = _al_list_next (layer_nodes, layer_item);
        _al_list_push_back_ex (map->layers, layer, dtor_layer);
        if (order && !strcmp (order, "fore"))
            _al_list_push_back (map->layers_fore, layer);
        else
            _al_list_push_back (map->layers_back, layer);
    }
    _al_list_destroy (layer_nodes);

    xmlFreeDoc (doc);
    xmlCleanupParser ();

    ALLEGRO_PATH *respath = al_get_standard_path (ALLEGRO_RESOURCES_PATH);
    al_change_directory (al_path_cstr (respath, ALLEGRO_NATIVE_PATH_SEP));
    al_destroy_path (respath);

    return map;
}
Ejemplo n.º 8
0
void parse_cmdline (int argc, char **argv, int game_index)
{
	static float f_beam, f_flicker;
	char *resolution;
	char *vesamode;
	char *joyname;
	char tmpres[10];
	int i;
	char *tmpstr;
	char *monitorname;

	mame_argc = argc;
	mame_argv = argv;
	game = game_index;


	/* force third mouse button emulation to "no" otherwise Allegro will default to "yes" */
	set_config_string(0,"emulate_three","no");

	/* read graphic configuration */
	scanlines   = get_bool   ("config", "scanlines",    NULL,  1);
	stretch     = get_bool   ("config", "stretch",		NULL,  1);
	options.use_artwork = get_bool   ("config", "artwork",	NULL,  1);
	options.use_samples = get_bool   ("config", "samples",	NULL,  1);
	video_sync  = get_bool   ("config", "vsync",        NULL,  0);
	wait_vsync  = get_bool   ("config", "waitvsync",    NULL,  0);
	use_triplebuf = get_bool ("config", "triplebuffer",	NULL,  0);
	use_tweaked = get_bool   ("config", "tweak",		NULL,  0);
	vesamode    = get_string ("config", "vesamode",	NULL,	"vesa3");
	use_mmx		= get_bool   ("config", "mmx", 		NULL,	-1);
	use_dirty	= get_bool	 ("config", "dirty",	NULL,	-1);
	options.antialias   = get_bool   ("config", "antialias",    NULL,  1);
	options.translucency = get_bool    ("config", "translucency", NULL, 1);

	vgafreq     = get_int    ("config", "vgafreq",      NULL,  -1);
	always_synced = get_bool ("config", "alwayssynced", NULL, 0);

	tmpstr             = get_string ("config", "depth", NULL, "auto");
	options.color_depth = atoi(tmpstr);
	if (options.color_depth != 8 && options.color_depth != 16) options.color_depth = 0;	/* auto */

	skiplines   = get_int    ("config", "skiplines",    NULL, 0);
	skipcolumns = get_int    ("config", "skipcolumns",  NULL, 0);
	f_beam      = get_float  ("config", "beam",         NULL, 1.0);
	if (f_beam < 1.0) f_beam = 1.0;
	if (f_beam > 16.0) f_beam = 16.0;
	f_flicker   = get_float  ("config", "flicker",      NULL, 0.0);
	if (f_flicker < 0.0) f_flicker = 0.0;
	if (f_flicker > 100.0) f_flicker = 100.0;
	osd_gamma_correction = get_float ("config", "gamma",   NULL, 1.0);
	if (osd_gamma_correction < 0.5) osd_gamma_correction = 0.5;
	if (osd_gamma_correction > 2.0) osd_gamma_correction = 2.0;

	tmpstr             = get_string ("config", "frameskip", "fs", "auto");
	if (!stricmp(tmpstr,"auto"))
	{
		frameskip = 0;
		autoframeskip = 1;
	}
	else
	{
		frameskip = atoi(tmpstr);
		autoframeskip = 0;
	}
	options.norotate  = get_bool ("config", "norotate",  NULL, 0);
	options.ror       = get_bool ("config", "ror",       NULL, 0);
	options.rol       = get_bool ("config", "rol",       NULL, 0);
	options.flipx     = get_bool ("config", "flipx",     NULL, 0);
	options.flipy     = get_bool ("config", "flipy",     NULL, 0);

	/* read sound configuration */
	soundcard           = get_int  ("config", "soundcard",  NULL, -1);
	options.use_emulated_ym3812 = !get_bool ("config", "ym3812opl",  NULL,  0);
	options.samplerate = get_int  ("config", "samplerate", "sr", 22050);
	if (options.samplerate < 5000) options.samplerate = 5000;
	if (options.samplerate > 50000) options.samplerate = 50000;
	usestereo           = get_bool ("config", "stereo",  NULL,  1);
	attenuation         = get_int  ("config", "volume",  NULL,  0);
	if (attenuation < -32) attenuation = -32;
	if (attenuation > 0) attenuation = 0;

	/* read input configuration */
	use_mouse = get_bool   ("config", "mouse",   NULL,  1);
	joyname   = get_string ("config", "joystick", "joy", "none");
	use_hotrod = 0;
	if (get_bool  ("config", "hotrod",   NULL,  0)) use_hotrod = 1;
	if (get_bool  ("config", "hotrodse",   NULL,  0)) use_hotrod = 2;

	/* misc configuration */
	options.cheat      = get_bool ("config", "cheat", NULL, 0);
	options.mame_debug = get_bool ("config", "debug", NULL, 0);
	cheatfile  = get_string ("config", "cheatfile", "cf", "CHEAT.DAT");    /* JCK 980917 */

 	#ifndef MESS
 	history_filename  = get_string ("config", "historyfile", NULL, "HISTORY.DAT");    /* JCK 980917 */
 	#else
 	history_filename  = get_string ("config", "historyfile", NULL, "SYSINFO.DAT");
 	#endif

	mameinfo_filename  = get_string ("config", "mameinfofile", NULL, "MAMEINFO.DAT");    /* JCK 980917 */

	/* get resolution */
	resolution  = get_string ("config", "resolution", NULL, "auto");

	/* set default subdirectories */
	nvdir      = get_string ("directory", "nvram",   NULL, "NVRAM");
	hidir      = get_string ("directory", "hi",      NULL, "HI");
	cfgdir     = get_string ("directory", "cfg",     NULL, "CFG");
	screenshotdir = get_string ("directory", "snap",     NULL, "SNAP");
	memcarddir = get_string ("directory", "memcard", NULL, "MEMCARD");
	stadir     = get_string ("directory", "sta",     NULL, "STA");
	artworkdir = get_string ("directory", "artwork", NULL, "ARTWORK");
 	#ifdef MESS
 		crcdir = get_string ("directory", "crc", NULL, "CRC");
 	#endif

	/* get tweaked modes info */
	tw224x288_h			= get_int ("tweaked", "224x288_h",              NULL, 0x5f);
	tw224x288_v     	= get_int ("tweaked", "224x288_v",              NULL, 0x54);
	tw240x256_h     = get_int ("tweaked", "240x256_h",              NULL, 0x67);
	tw240x256_v     = get_int ("tweaked", "240x256_v",              NULL, 0x23);
	tw256x240_h     = get_int ("tweaked", "256x240_h",              NULL, 0x55);
	tw256x240_v     = get_int ("tweaked", "256x240_v",              NULL, 0x43);
	tw256x256_h     = get_int ("tweaked", "256x256_h",              NULL, 0x6c);
	tw256x256_v     = get_int ("tweaked", "256x256_v",              NULL, 0x23);
	tw256x256_hor_h = get_int ("tweaked", "256x256_hor_h",  NULL, 0x55);
	tw256x256_hor_v = get_int ("tweaked", "256x256_hor_v",  NULL, 0x60);
	tw288x224_h     = get_int ("tweaked", "288x224_h",              NULL, 0x5f);
	tw288x224_v     = get_int ("tweaked", "288x224_v",              NULL, 0x0c);
	tw240x320_h             = get_int ("tweaked", "240x320_h",              NULL, 0x5a);
	tw240x320_v             = get_int ("tweaked", "240x320_v",              NULL, 0x8c);
	tw320x240_h             = get_int ("tweaked", "320x240_h",              NULL, 0x5f);
	tw320x240_v             = get_int ("tweaked", "320x240_v",              NULL, 0x0c);
	tw336x240_h             = get_int ("tweaked", "336x240_h",              NULL, 0x5f);
	tw336x240_v             = get_int ("tweaked", "336x240_v",              NULL, 0x0c);
	tw384x224_h             = get_int ("tweaked", "384x224_h",              NULL, 0x6c);
	tw384x224_v             = get_int ("tweaked", "384x224_v",              NULL, 0x0c);
	tw384x240_h             = get_int ("tweaked", "384x240_h",              NULL, 0x6c);
	tw384x240_v             = get_int ("tweaked", "384x240_v",              NULL, 0x0c);
	tw384x256_h             = get_int ("tweaked", "384x256_h",              NULL, 0x6c);
	tw384x256_v             = get_int ("tweaked", "384x256_v",              NULL, 0x23);

	/* Get 15.75KHz tweak values */
	tw224x288arc_h          = get_int ("tweaked", "224x288arc_h",   NULL, 0x5d);
	tw224x288arc_v          = get_int ("tweaked", "224x288arc_v",   NULL, 0x38);
	tw288x224arc_h          = get_int ("tweaked", "288x224arc_h",   NULL, 0x5d);
	tw288x224arc_v          = get_int ("tweaked", "288x224arc_v",   NULL, 0x09);
	tw256x240arc_h          = get_int ("tweaked", "256x240arc_h",   NULL, 0x5d);
	tw256x240arc_v          = get_int ("tweaked", "256x240arc_v",   NULL, 0x09);
	tw256x256arc_h          = get_int ("tweaked", "256x256arc_h",   NULL, 0x5d);
	tw256x256arc_v          = get_int ("tweaked", "256x256arc_v",   NULL, 0x17);
	tw320x240arc_h          = get_int ("tweaked", "320x240arc_h",   NULL, 0x69);
	tw320x240arc_v          = get_int ("tweaked", "320x240arc_v",   NULL, 0x09);
	tw320x256arc_h          = get_int ("tweaked", "320x256arc_h",   NULL, 0x69);
	tw320x256arc_v          = get_int ("tweaked", "320x256arc_v",   NULL, 0x17);
	tw352x240arc_h          = get_int ("tweaked", "352x240arc_h",   NULL, 0x6a);
	tw352x240arc_v          = get_int ("tweaked", "352x240arc_v",   NULL, 0x09);
	tw352x256arc_h          = get_int ("tweaked", "352x256arc_h",   NULL, 0x6a);
	tw352x256arc_v          = get_int ("tweaked", "352x256arc_v",   NULL, 0x17);
	tw368x224arc_h          = get_int ("tweaked", "368x224arc_h",   NULL, 0x6a);
	tw368x224arc_v          = get_int ("tweaked", "368x224arc_v",   NULL, 0x09);
	tw368x240arc_h          = get_int ("tweaked", "368x240arc_h",   NULL, 0x6a);
	tw368x240arc_v          = get_int ("tweaked", "368x240arc_v",   NULL, 0x09);
	tw368x256arc_h          = get_int ("tweaked", "368x256arc_h",   NULL, 0x6a);
	tw368x256arc_v          = get_int ("tweaked", "368x256arc_v",   NULL, 0x17);
	tw512x224arc_h          = get_int ("tweaked", "512x224arc_h",   NULL, 0xbf);
	tw512x224arc_v          = get_int ("tweaked", "512x224arc_v",   NULL, 0x09);
	tw512x256arc_h          = get_int ("tweaked", "512x256arc_h",   NULL, 0xbf);
	tw512x256arc_v          = get_int ("tweaked", "512x256arc_v",   NULL, 0x17);
	tw512x448arc_h          = get_int ("tweaked", "512x448arc_h",   NULL, 0xbf);
	tw512x448arc_v          = get_int ("tweaked", "512x448arc_v",   NULL, 0x09);
	tw512x512arc_h          = get_int ("tweaked", "512x512arc_h",   NULL, 0xbf);
	tw512x512arc_v          = get_int ("tweaked", "512x512arc_v",   NULL, 0x17);
	tw640x480arc_h          = get_int ("tweaked", "640x480arc_h",   NULL, 0xc1);
	tw640x480arc_v          = get_int ("tweaked", "640x480arc_v",   NULL, 0x09);

	/* this is handled externally cause the audit stuff needs it, too */
	get_rom_sample_path (argc, argv, game_index);

	/* get the monitor type */
	monitorname = get_string ("config", "monitor", NULL, "standard");
	/* get -centerx */
	center_x = get_int ("config", "centerx", NULL,  0);
	/* get -centery */
	center_y = get_int ("config", "centery", NULL,  0);
	/* get -waitinterlace */
	wait_interlace = get_bool ("config", "waitinterlace", NULL,  0);

	/* process some parameters */
	options.beam = (int)(f_beam * 0x00010000);
	if (options.beam < 0x00010000)
		options.beam = 0x00010000;
	if (options.beam > 0x00100000)
		options.beam = 0x00100000;

	options.flicker = (int)(f_flicker * 2.55);
	if (options.flicker < 0)
		options.flicker = 0;
	if (options.flicker > 255)
		options.flicker = 255;

	if (stricmp (vesamode, "vesa1") == 0)
		gfx_mode = GFX_VESA1;
	else if (stricmp (vesamode, "vesa2b") == 0)
		gfx_mode = GFX_VESA2B;
	else if (stricmp (vesamode, "vesa2l") == 0)
		gfx_mode = GFX_VESA2L;
	else if (stricmp (vesamode, "vesa3") == 0)
		gfx_mode = GFX_VESA3;
	else
	{
		if (errorlog)
			fprintf (errorlog, "%s is not a valid entry for vesamode\n",
					vesamode);
		gfx_mode = GFX_VESA3; /* default to VESA2L */
	}

	/* any option that starts with a digit is taken as a resolution option */
	/* this is to handle the old "-wxh" commandline option. */
	for (i = 1; i < argc; i++)
	{
		if (argv[i][0] == '-' && isdigit(argv[i][1]) &&
				(strstr(argv[i],"x") || strstr(argv[i],"X")))
			resolution = &argv[i][1];
	}

	/* break up resolution into gfx_width and gfx_height */
	gfx_height = gfx_width = 0;
	if (stricmp (resolution, "auto") != 0)
	{
		char *tmp;
		strncpy (tmpres, resolution, 10);
		tmp = strtok (tmpres, "xX");
		gfx_width = atoi (tmp);
		tmp = strtok (0, "xX");
		if (tmp)
			gfx_height = atoi (tmp);
	}

	/* convert joystick name into an Allegro-compliant joystick signature */
	joystick = -2; /* default to invalid value */

	for (i = 0; joy_table[i].name != NULL; i++)
	{
		if (stricmp (joy_table[i].name, joyname) == 0)
		{
			joystick = joy_table[i].id;
			if (errorlog)
				fprintf (errorlog, "using joystick %s = %08x\n",
						joyname,joy_table[i].id);
			break;
		}
	}

	if (joystick == -2)
	{
		if (errorlog)
			fprintf (errorlog, "%s is not a valid entry for a joystick\n",
					joyname);
		joystick = JOY_TYPE_NONE;
	}

	/* get monitor type from supplied name */
	monitor_type = MONITOR_TYPE_STANDARD; /* default to PC monitor */

	for (i = 0; monitor_table[i].name != NULL; i++)
	{
		if ((stricmp (monitor_table[i].name, monitorname) == 0))
		{
			monitor_type = monitor_table[i].id;
			break;
		}
	}
}
Ejemplo n.º 9
0
void KeyframeAnim::loadBinary(Common::SeekableReadStream *data) {
	// First four bytes are the FYEK Keyframe identifier code
	// Next 36 bytes are the filename
	Debug::debug(Debug::Keyframes, "Loading Keyframe '%s'.", _fname.c_str());
	// Next four bytes are the flags
	data->seek(40, SEEK_SET);
	_flags = data->readUint32LE();
	// Next four bytes are a duplicate of _numJoints (?)
	// Next four bytes are the type
	data->readUint32LE();
	_type = data->readUint32LE();
	// Next four bytes are the frames per second
	// The fps value seems to be ignored and causes the animation the first time manny
	// enters the kitchen of the Blue Casket to go out of sync. So we force it to 15.
//  _fps = get_float(data + 52);
	_fps = 15.;
	// Next four bytes are the number of frames
	data->seek(56, SEEK_SET);
	_numFrames = data->readUint32LE();
	// Next four bytes are the number of joints
	_numJoints = data->readUint32LE();
	// Next four bytes are unknown (?)
	// Next four bytes are the number of markers
	data->readUint32LE();
	_numMarkers = data->readUint32LE();
	_markers = new Marker[_numMarkers];
	data->seek(72, SEEK_SET);
	for (int i = 0; i < _numMarkers; i++) {
		char f[4];
		data->read(f, 4);
		_markers[i].frame = get_float(f);
	}

	data->seek(104, SEEK_SET);
	for (int i = 0; i < _numMarkers; i++)
		_markers[i].val = data->readUint32LE();

	_nodes = new KeyframeNode *[_numJoints];
	// The first 136 bytes are for the header, this was originally
	// listed as 180 bytes since the first operation is usually a
	// "null" key, however ma_card_hold.key showed that this is
	// not always the case so we should not skip this operation
	data->seek(136, SEEK_SET);
	for (int i = 0; i < _numJoints; i++) {
		_nodes[i] = nullptr;
		int nodeNum;
		// The first 32 bytes (of a keyframe) are the name handle
		char nameHandle[32];
		data->read(nameHandle, 32);
		// If the name handle is entirely null (like ma_rest.key)
		// then we shouldn't try to set the name
		if (nameHandle[0] == 0)
			memcpy(nameHandle, "(null)", 7);

		// The next four bytes are the node number identifier
		nodeNum = data->readUint32LE();

		// Because of the issue above ma_card_hold.key used to crash
		// at this part without checking to make sure nodeNum is a
		// valid number, we'll leave this in just in case something
		// else is still wrong but it should now load correctly in
		// all cases
		if (nodeNum >= _numJoints) {
			Debug::warning(Debug::Keyframes, "A node number was greater than the maximum number of nodes (%d/%d)", nodeNum, _numJoints);
			return;
		}
		if (_nodes[nodeNum]) {
			// Null node. Usually 7, 13 and 27 are null nodes.
			data->seek(8, SEEK_CUR);
			continue;
		}
		_nodes[nodeNum] = new KeyframeNode();
		_nodes[nodeNum]->loadBinary(data, nameHandle);
	}
}
Ejemplo n.º 10
0
static int can_parse_opt(struct link_util *lu, int argc, char **argv,
			 struct nlmsghdr *n)
{
	struct can_bittiming bt;
	struct can_ctrlmode cm = {0, 0};

	memset(&bt, 0, sizeof(bt));
	while (argc > 0) {
		if (matches(*argv, "bitrate") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.bitrate, *argv, 0))
				invarg("invalid \"bitrate\" value\n", *argv);
		} else if (matches(*argv, "sample-point") == 0) {
			float sp;

			NEXT_ARG();
			if (get_float(&sp, *argv))
				invarg("invalid \"sample-point\" value\n",
				       *argv);
			bt.sample_point = (__u32)(sp * 1000);
		} else if (matches(*argv, "tq") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.tq, *argv, 0))
				invarg("invalid \"tq\" value\n", *argv);
		} else if (matches(*argv, "prop-seg") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.prop_seg, *argv, 0))
				invarg("invalid \"prop-seg\" value\n", *argv);
		} else if (matches(*argv, "phase-seg1") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.phase_seg1, *argv, 0))
				invarg("invalid \"phase-seg1\" value\n", *argv);
		} else if (matches(*argv, "phase-seg2") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.phase_seg2, *argv, 0))
				invarg("invalid \"phase-seg2\" value\n", *argv);
		} else if (matches(*argv, "sjw") == 0) {
			NEXT_ARG();
			if (get_u32(&bt.sjw, *argv, 0))
				invarg("invalid \"sjw\" value\n", *argv);
		} else if (matches(*argv, "loopback") == 0) {
			NEXT_ARG();
			set_ctrlmode("loopback", *argv, &cm,
				     CAN_CTRLMODE_LOOPBACK);
		} else if (matches(*argv, "listen-only") == 0) {
			NEXT_ARG();
			set_ctrlmode("listen-only", *argv, &cm,
				     CAN_CTRLMODE_LISTENONLY);
		} else if (matches(*argv, "triple-sampling") == 0) {
			NEXT_ARG();
			set_ctrlmode("triple-sampling", *argv, &cm,
				     CAN_CTRLMODE_3_SAMPLES);
		} else if (matches(*argv, "one-shot") == 0) {
			NEXT_ARG();
			set_ctrlmode("one-shot", *argv, &cm,
				     CAN_CTRLMODE_ONE_SHOT);
		} else if (matches(*argv, "berr-reporting") == 0) {
			NEXT_ARG();
			set_ctrlmode("berr-reporting", *argv, &cm,
				     CAN_CTRLMODE_BERR_REPORTING);
		} else if (matches(*argv, "restart") == 0) {
			__u32 val = 1;

			addattr32(n, 1024, IFLA_CAN_RESTART, val);
		} else if (matches(*argv, "restart-ms") == 0) {
			__u32 val;

			NEXT_ARG();
			if (get_u32(&val, *argv, 0))
				invarg("invalid \"restart-ms\" value\n", *argv);
			addattr32(n, 1024, IFLA_CAN_RESTART_MS, val);
		} else if (matches(*argv, "help") == 0) {
			usage();
			return -1;
		} else {
			fprintf(stderr, "can: unknown option \"%s\"\n", *argv);
			usage();
			return -1;
		}
		argc--, argv++;
	}

	if (bt.bitrate || bt.tq)
		addattr_l(n, 1024, IFLA_CAN_BITTIMING, &bt, sizeof(bt));
	if (cm.mask)
		addattr_l(n, 1024, IFLA_CAN_CTRLMODE, &cm, sizeof(cm));

	return 0;
}
Ejemplo n.º 11
0
// funcion main 
int main (){
       
        int x, i; 
	init_input("input"); 

// test factorial entero    
        print_string("Factorial Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;         
            aux=get_int(); // lee los datos para invocar a la funcion
            aux = factorial(aux);
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");
		
// test factorial real 
		print_string("Factorial Reales----------------------------------");
        x=get_int();  
        i = 0;
        while (i<x){
            float aux;
            aux=get_float();
            aux = factorialF(aux);
            print_float(aux); 
            i++;
	    }
		print_string("---------------------------------------------------------");

// test factorial array entero    
        print_string("Factorial Array Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;         
            aux=get_int(); // lee los datos para invocar a la funcion
            aux = factorialArray(aux);
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");

// test nthprime entero    
        print_string("Nthprime Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;         
            aux=get_int(); // lee los datos para invocar a la funcion
            aux = nthprime(aux);
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");

// test nthprime array entero    
        print_string("Nthprime Array Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;         
            aux=get_int(); // lee los datos para invocar a la funcion
            aux = nthprimeArray(aux);
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");

// test int2bin entero    
        print_string("Int2Bin Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;         
            aux=get_int(); // lee los datos para invocar a la funcion
            aux = int2bin(aux);
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");

// test gcd entero    
        print_string("GCD Enteros----------------------------------");    
        x=get_int(); // lee la cantidad de veces que ejecutara la funcion  
        i = 0;        
        while (i<x){              
            int aux;// lee los datos para invocar a la funcion
            aux = gcd(get_int(),get_int());
            print_int(aux);             
            i++;
	    }
		print_string("---------------------------------------------------------");

// test test    
        print_string("test----------------------------------");    
        test();
		print_string("---------------------------------------------------------");


// test test1    
        print_string("test1----------------------------------");    
        test1();
		print_string("---------------------------------------------------------");



        close_input();
        return 1;   
}
Ejemplo n.º 12
0
/* Errechnen des zu plottenden Teilbereichs des gesamten Berechnungsgebiets */
void
init_plot_area(struct state* state, struct trajectory* current) { 

	double x, y, dx, dy;
	unsigned col;
	unsigned row;

	/* Errechnen der Grenzen des Plotbereichs */
	if (current->plot_size > 0) {
		/* Rangechecking des Plotmittelpunkts */
		if ((get_float(MIDLA) < state->la_min) || 
		    (get_float(MIDLA) > state->la_max) ||
		    (get_float(MIDLO) < state->lo_min) || 
		    (get_float(MIDLO) > state->lo_max)) {

			printf("Error: midpoint of plot out of range ");
			printf("(%5.2f %5.2f | %5.2f %5.2f)\n",
			    state->lo_min, state->la_min, state->lo_max, 
			    state->la_max);
			exit(1);
		}
    
		/* Wenn Elementanzahl ungerade -> mache gerade */
		if ((current->plot_size % 2) == 1)
			current->plot_size++;

		y = state->la_min;
		row = 0;

		/* Errechnen der Netzelementbreite in y-Richtung
		 * (konstant) */
		dy = get_int(RES) / DEGDISTANCE;

		/* Zeilenindex row und Breitengrad y der
		 * aktuellen Mittelpunktposition berechnen
		 */
		if (get_float(MIDLA) > y) {
			row = rad2idx(get_float(MIDLA) - y, dy);
			y += row * dy;
		}

		/* Gehe zum ersten Netzelement in x-Richtung */
		x = state->lo_min;
		col = 0;

		/* Errechnen der Netzelementbreite in x-Richtung (abhaengig
		 * vom Breitengrad
		 */
		dx = get_int(RES) / (DEGDISTANCE * cos(deg2rad(y)));

		/* Spaltenindex col und Laengengrad x der
		 * aktuellen Mittelpunktposition berechnen
		 */
		if (get_float(MIDLO) > x) {
			col = rad2idx(get_float(MIDLO) - x, dx);
			x += col * dx;
		}
	
		/* Da jeweils ein Schritt zu weit gegangen wird -> zurueck 
		 * auf Netzelement in dem aktueller Mittelpunkt liegt
		 */
		col--;
		row--;
		
		/* Speichern der Grenzen des Plotbereichs */
		current->x_plot_min = col - current->plot_size / 2;
		current->x_plot_max = col + current->plot_size / 2;
		current->y_plot_min = row - current->plot_size / 2;
		current->y_plot_max = row + current->plot_size / 2;
    
		/* Rangechecking des Plotbereichs */
		if (current->x_plot_min < 0) {
			
			current->x_plot_min = 0;
		}
		if (current->x_plot_max > state->x_field) {
			
			current->x_plot_max = state->x_field;
		}
		if (current->y_plot_min < 0) {
			
			current->y_plot_min = 0;
		}
		if (current->y_plot_max > state->y_field) {
			
			current->y_plot_max = state->y_field;
		}
		printf("%i %i %i %i | %i %i\n", 
		    current->x_plot_min, current->y_plot_min, 
		    current->x_plot_max, current->y_plot_max,
		    state->x_field, state->y_field);
	}
	else { /* Wenn keine Plotbereich angegeben, dann plotte alles */
		
		current->x_plot_min = 0;
		current->x_plot_max = state->x_field;
		current->y_plot_min = 0;
		current->y_plot_max = state->y_field;
	}
}
Ejemplo n.º 13
0
/* Einlesen und abbilden der Trajektorie auf der lokalen Berechnungsnetz-
 * matrix
 */
void
read_trajectory(struct trajectory* current, struct state* state, 
    double* plot_field)
{
	char buf[MAXLINE];
	int  ch;
	int  j = 0;
	
	/* Einlesen bis Trennzeichen zwischen Laengen- 
	 * und Breitengradangabe erreicht ist oder neue 
	 * Zeile beginnt
	 */
	while ((ch = fgetc(current->fh)) != EOF) {

		if ((ch != SEPARATOR) && (ch != '\n')) {
			buf[j++] = (char)ch;
			buf[j] = '\0';
		}
		else if (ch == SEPARATOR) { /* Wenn Trennzeichen 
					     * erreicht ist -> 
					     * Laengengrad 
					     */

			/* Laengengrad speichern */
			current->x_new = atof(buf);
			j = 0;
		}
		else if (ch == '\n') { /* Wenn Zeilenende erreicht 
					* ist -> Breitengrad 
					*/

			/* Breitengrad speichern */
			current->y_new = atof(buf);
			j = 0;
			
			/* Koordinaten in Grad umrechnen */
			current->x_new = rad2deg(current->x_new);
			current->y_new = rad2deg(current->y_new);
			
			/* Trajektorienaufpunkt in KML-Datei schreiben (fuer 
			 * Trajektoriendarstellung)
			 */
			fprintf(state->fh, "%10.6f, %9.6f, 0\n", 
			    current->x_new + get_float(OFFLO), 
			    current->y_new + get_float(OFFLA));
			
			/* Mittelpunkt zwischen vorherigem und aktuellem 
			 * Aufpunkt fuer die Trajektoriendichteberechnung 
			 * errechnen 
			 */
			current->x_midpoint = (current->x_old + 
			    current->x_new) / 2;
			current->y_midpoint = (current->y_old + 
			    current->y_new) / 2;
			
			/* Errechenen der momentanen Wichtung und abbilden
			 * aller Trajektorienaufpunkte im Plotbereich 
                         * zwischen dem letzten und dem aktuellen Punkt auf 
			 * der lokalen Abbildungsmatrix `plot_field'
			 */
			plot_to_next_point(plot_field, current, state); 

			/* Speichern des letzten Aufpunkts */
			current->x_old = current->x_new;
			current->y_old = current->y_new;
		}
	}
}
Ejemplo n.º 14
0
void get_geometry_options(char_t operation[], geometry_options *image_geometry,
                          rotate_options *image_rotate) {
   
  int16_t not_finished, response;
  not_finished = 1;
  while (not_finished){

    printf("\nThe geomety options are:");
    printf("\n\t1. Operation is %s", operation);
    printf("\n\t2. Angle is %f", image_geometry->x_angle);
    printf("\n\t3. x-displace=%d y-displace=%d", image_geometry->x_displace, image_geometry->y_displace);
    printf("\n\t4. x-stretch=%f y-stretch=%f", image_geometry->x_stretch, image_geometry->y_stretch);
    printf("\n\t5. x-cross=%f y-cross=%f", image_geometry->x_cross, image_geometry->y_cross);
    printf("\n\t6. bilinear = %d", image_geometry->bilinear);
    printf("\n\t7. rotation points m=%d n=%d", image_rotate->m, image_rotate->n);
    printf("\n\nExamples:");
    printf("\ngeometry needs: angle");
    printf(" x-displace y-displace");
    printf(" x-stretch y-stretch");
    printf("\n                x-cross y-cross");
    printf(" bilinear (1 or 0)");
    printf("\nrotate needs: angle m n");
    printf(" bilinear (1 or 0)");
    printf("\n\nEnter choice (0 = no change) _\b");
    get_integer(&response);

    if (response == 0) {
      not_finished = 0;
    }

    if (response == 1) {
      printf("\nEnter operation:");
      gets(operation);
    }  /* ends if 1 */

    if (response == 2) {
      printf("\nEnter angle: ___\b\b\b");
      get_float(image_geometry->x_angle);
      get_float(image_rotate->angle);
    }  /* ends if 2 */

    if (response == 3) {
      printf("\nEnter x-displace: ___\b\b\b");
      get_integer(image_geometry->x_displace);
      printf("\nEnter y-displace: ___\b\b\b");
      get_integer(image_geometry->y_displace);
    }  /* ends if 3 */

    if (response == 4) {
      printf("\nEnter x-stretch: ___\b\b\b");
      get_float(image_geometry->x_stretch);
      printf("\nEnter y-stretch: ___\b\b\b");
      get_float(image_geometry->y_stretch);
    }  /* ends if 4 */

    if (response == 5) {
      printf("\nEnter x-cross: ___\b\b\b");
      get_float(image_geometry->x_cross);
      printf("\nEnter y-cross: ___\b\b\b");
      get_float(image_geometry->y_cross);
    }  /* ends if 5 */

    if (response == 6) {
      printf("\nEnter bilinear: _\b");
      get_integer(image_geometry->bilinear);
      get_integer(image_rotate->bilinear);
    }  /* ends if 6 */

    if (response == 7) {
      printf("\nEnter rotation point m: _\b");
      get_integer(image_rotate->m);
      printf("\nEnter rotation point n: _\b");
      get_integer(image_rotate->n);
    }  /* ends if 7 */

  }  /* ends while not_finished */

}  /* ends get_geometry_options */
Ejemplo n.º 15
0
bool BitmapData::loadTile(Common::SeekableReadStream *o) {
	_x = 0;
	_y = 0;
	_format = 1;
	o->seek(0, SEEK_SET);

	/*uint32 id = */o->readUint32LE();
	// Should check that we actually HAVE a TIL
	uint32 bmoffset = o->readUint32LE();
	_numCoords = o->readUint32LE();
	_numLayers = o->readUint32LE();
	_numVerts = o->readUint32LE();

	// skip some 0
	o->seek(16, SEEK_CUR);
	_texc = new float[_numCoords * 4];

	for (uint32 i = 0; i < _numCoords * 4; ++i) {
		char f[4];
		o->read(f, 4);
		_texc[i] = get_float(f);
	}

	_layers = new Layer[_numLayers];
	for (uint32 i = 0; i < _numLayers; ++i) {
		_layers[i]._offset = o->readUint32LE();
		_layers[i]._numImages = o->readUint32LE();
	}

	_verts = new Vert[_numVerts];
	for (uint32 i = 0; i < _numVerts; ++i) {
		_verts[i]._texid = o->readUint32LE();
		_verts[i]._pos = o->readUint32LE();
		_verts[i]._verts = o->readUint32LE();
	}

	o->seek(16, SEEK_CUR);
	int numSubImages = o->readUint32LE();
	if (numSubImages < 5)
		error("Can not handle a tile with less than 5 sub images");

	char **data = new char *[numSubImages];

	o->seek(16, SEEK_CUR);
	_bpp = o->readUint32LE();

	o->seek(bmoffset + 128);

	_width = o->readUint32LE();
	_height = o->readUint32LE();
	o->seek(-8, SEEK_CUR);

	int size = _bpp / 8 * _width * _height;
	for (int i = 0; i < numSubImages; ++i) {
		data[i] = new char[size];
		o->seek(8, SEEK_CUR);
		o->read(data[i], size);
	}

	Graphics::PixelFormat pixelFormat;
	if (_bpp == 16) {
		_colorFormat = BM_RGB1555;
		pixelFormat = Graphics::createPixelFormat<1555>();
		//convertToColorFormat(0, BM_RGBA);
	} else {
		pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24);
		_colorFormat = BM_RGBA;
	}

	_width = 256;
	_height = 256;
	_numImages = numSubImages;
	_data = new Graphics::PixelBuffer[_numImages];
	for (int i = 0; i < _numImages; ++i) {
		_data[i].create(pixelFormat, _width * _height, DisposeAfterUse::YES);
		_data[i].set(pixelFormat, (byte *)data[i]);
	}

	delete[] data;

	g_driver->createBitmap(this);
	return true;
}
Ejemplo n.º 16
0
static void PrintCode (Byte *code, Byte *end)
{
 Byte *p = code;
 printf ("\n\nCODE\n");
 while (p != end)
 {
  switch ((OpCode)*p)
  {
   case PUSHNIL:	printf ("%d    PUSHNIL\n", (p++)-code); break;
   case PUSH0: case PUSH1: case PUSH2:
    			printf ("%d    PUSH%c\n", p-code, *p-PUSH0+'0');
    			p++;
   			break;
   case PUSHBYTE:
    			printf ("%d    PUSHBYTE   %d\n", p-code, *(++p));
    			p++;
   			break;
   case PUSHWORD:
                        {
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    PUSHWORD   %d\n", n, c.w);
			}
   			break;
   case PUSHFLOAT:
			{
			 CodeFloat c;
			 int n = p-code;
			 p++;
			 get_float(c,p);
    			 printf ("%d    PUSHFLOAT  %f\n", n, c.f);
			}
   			break;
   case PUSHSTRING:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    PUSHSTRING   %d\n", n, c.w);
			}
   			break;
   case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: case PUSHLOCAL3:
   case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7:
   case PUSHLOCAL8: case PUSHLOCAL9:
    			printf ("%d    PUSHLOCAL%c\n", p-code, *p-PUSHLOCAL0+'0');
    			p++;
   			break;
   case PUSHLOCAL:	printf ("%d    PUSHLOCAL   %d\n", p-code, *(++p));
    			p++;
   			break;
   case PUSHGLOBAL:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    PUSHGLOBAL   %d\n", n, c.w);
			}
   			break;
   case PUSHINDEXED:    printf ("%d    PUSHINDEXED\n", (p++)-code); break;
   case PUSHMARK:       printf ("%d    PUSHMARK\n", (p++)-code); break;
   case PUSHOBJECT:     printf ("%d    PUSHOBJECT\n", (p++)-code); break;
   case STORELOCAL0: case STORELOCAL1: case STORELOCAL2: case STORELOCAL3:
   case STORELOCAL4: case STORELOCAL5: case STORELOCAL6: case STORELOCAL7:
   case STORELOCAL8: case STORELOCAL9:
    			printf ("%d    STORELOCAL%c\n", p-code, *p-STORELOCAL0+'0');
    			p++;
   			break;
   case STORELOCAL:
    			printf ("%d    STORELOCAL   %d\n", p-code, *(++p));
    			p++;
   			break;
   case STOREGLOBAL:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    STOREGLOBAL   %d\n", n, c.w);
			}
   			break;
   case STOREINDEXED0:  printf ("%d    STOREINDEXED0\n", (p++)-code); break;
   case STOREINDEXED:   printf ("%d    STOREINDEXED   %d\n", p-code, *(++p));
    			p++;
   			break;
   case STORELIST0:
	printf("%d      STORELIST0  %d\n", p-code, *(++p));
        p++;
        break;
   case STORELIST:
	printf("%d      STORELIST  %d %d\n", p-code, *(p+1), *(p+2));
        p+=3;
        break;
   case STORERECORD:
       printf("%d      STORERECORD  %d\n", p-code, *(++p));
       p += *p*sizeof(Word) + 1;
       break;
   case ADJUST:
    			printf ("%d    ADJUST   %d\n", p-code, *(++p));
    			p++;
   			break;
   case CREATEARRAY:	printf ("%d    CREATEARRAY\n", (p++)-code); break;
   case EQOP:       	printf ("%d    EQOP\n", (p++)-code); break;
   case LTOP:       	printf ("%d    LTOP\n", (p++)-code); break;
   case LEOP:       	printf ("%d    LEOP\n", (p++)-code); break;
   case ADDOP:       	printf ("%d    ADDOP\n", (p++)-code); break;
   case SUBOP:       	printf ("%d    SUBOP\n", (p++)-code); break;
   case MULTOP:      	printf ("%d    MULTOP\n", (p++)-code); break;
   case DIVOP:       	printf ("%d    DIVOP\n", (p++)-code); break;
   case CONCOP:       	printf ("%d    CONCOP\n", (p++)-code); break;
   case MINUSOP:       	printf ("%d    MINUSOP\n", (p++)-code); break;
   case NOTOP:       	printf ("%d    NOTOP\n", (p++)-code); break;
   case ONTJMP:	   
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    ONTJMP  %d\n", n, c.w);
			}
   			break;
   case ONFJMP:	   
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    ONFJMP  %d\n", n, c.w);
			}
   			break;
   case JMP:	   
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    JMP  %d\n", n, c.w);
			}
   			break;
   case UPJMP:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    UPJMP  %d\n", n, c.w);
			}
   			break;
   case IFFJMP:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    IFFJMP  %d\n", n, c.w);
			}
   			break;
   case IFFUPJMP:
    			{
			 CodeWord c;
			 int n = p-code;
			 p++;
			 get_word(c,p);
    			 printf ("%d    IFFUPJMP  %d\n", n, c.w);
			}
   			break;
   case POP:       	printf ("%d    POP\n", (p++)-code); break;
   case CALLFUNC:	printf ("%d    CALLFUNC\n", (p++)-code); break;
   case RETCODE:
    			printf ("%d    RETCODE   %d\n", p-code, *(++p));
    			p++;
   			break;
   case HALT:		printf ("%d    HALT\n", (p++)-code); break;
   case SETFUNCTION:
                        {
                         CodeWord c1, c2;
                         int n = p-code;
                         p++;
                         get_word(c1,p);
                         get_word(c2,p);
                         printf ("%d    SETFUNCTION  %d  %d\n", n, c1.w, c2.w);
                        }
                        break;
   case SETLINE:
                        {
                         CodeWord c;
                         int n = p-code;
                         p++;
                         get_word(c,p);
                         printf ("%d    SETLINE  %d\n", n, c.w);
                        }
                        break;

   case RESET:		printf ("%d    RESET\n", (p++)-code); break;
   default:		printf ("%d    Cannot happen: code %d\n", (p++)-code, *(p-1)); break;
  }
 }
}
Ejemplo n.º 17
0
graphStruct *
makeGraphFromSpadData(void)
{
  
  graphStruct     *graphData;
  pointListStruct *pL;
  pointStruct     *p;
  int i,j;

  if (!(graphData = (graphStruct *)malloc(sizeof(graphStruct)))) {
    fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (graphStruct).\n");
    exit(-1);
  }

  graphData->xmin = get_float(spadSock);   /* after everything is normalized */
  graphData->xmax = get_float(spadSock);
  graphData->ymin = get_float(spadSock);   /* view2D */
  graphData->ymax = get_float(spadSock);

  graphData->xNorm = 1/(graphData->xmax - graphData->xmin);
  graphData->yNorm = 1/(graphData->ymax - graphData->ymin);

  graphData->spadUnitX = get_float(spadSock);
  graphData->spadUnitY = get_float(spadSock);

  graphData->unitX = graphData->spadUnitX * graphData->xNorm;
  graphData->unitY = graphData->spadUnitY * graphData->yNorm;

  graphData->originX = -graphData->xmin * graphData->xNorm - 0.5;
  graphData->originY = -graphData->ymin * graphData->yNorm - 0.5;


  graphData->numberOfLists = get_int(spadSock);
  if (!(pL = (pointListStruct *)malloc(graphData->numberOfLists * sizeof(pointListStruct)))) {
    fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointListStruct).\n");
    exit(-1);
  }
  graphData->listOfListsOfPoints = pL;

  for (i=0; i<graphData->numberOfLists; i++) {

    pL->numberOfPoints = get_int(spadSock);
    if (!(p = (pointStruct *)malloc(pL->numberOfPoints * sizeof(pointStruct)))) {
      fprintf(stderr,"The viewport manager ran out of memory trying to create a new graph (pointStruct).\n");
      exit(-1);
    }
    pL->listOfPoints = p;             /** point to current point list **/

    for (j=0; j<pL->numberOfPoints; j++) {
      p->x     = get_float(spadSock);         /* get numbers from OpenAxiom */
      p->y     = get_float(spadSock);
      p->hue   = get_float(spadSock) - 1;     /* make zero based */
      p->shade = get_float(spadSock) - 1;
        /* normalize to range [-0.5..0.5] */
      p->x = (p->x - graphData->xmin) * graphData->xNorm - 0.5;
      p->y = (p->y - graphData->ymin) * graphData->yNorm - 0.5;
      p++;
    }
        /* for now, getting hue, shade - do hue * totalHues + shade */
    pL->pointColor = get_int(spadSock);
    pL->lineColor = get_int(spadSock);
    pL->pointSize = get_int(spadSock);
    pL++;                          /** advance to next point list **/
  }


  graphData->key = graphKey++;
  
  send_int(spadSock,(graphKey-1));          /* acknowledge to spad */


  return(graphData);

}
Ejemplo n.º 18
0
/**
 * Decode Bink Audio block
 * @param[out] out Output buffer (must contain s->block_size elements)
 * @return 0 on success, negative error code on failure
 */
static int decode_block(BinkAudioContext *s, float **out, int use_dct)
{
    int ch, i, j, k;
    float q, quant[25];
    int width, coeff;
    GetBitContext *gb = &s->gb;

    if (use_dct)
        skip_bits(gb, 2);

    for (ch = 0; ch < s->channels; ch++) {
        FFTSample *coeffs = out[ch];

        if (s->version_b) {
            if (get_bits_left(gb) < 64)
                return AVERROR_INVALIDDATA;
            coeffs[0] = av_int2float(get_bits_long(gb, 32)) * s->root;
            coeffs[1] = av_int2float(get_bits_long(gb, 32)) * s->root;
        } else {
            if (get_bits_left(gb) < 58)
                return AVERROR_INVALIDDATA;
            coeffs[0] = get_float(gb) * s->root;
            coeffs[1] = get_float(gb) * s->root;
        }

        if (get_bits_left(gb) < s->num_bands * 8)
            return AVERROR_INVALIDDATA;
        for (i = 0; i < s->num_bands; i++) {
            int value = get_bits(gb, 8);
            quant[i]  = quant_table[FFMIN(value, 95)];
        }

        k = 0;
        q = quant[0];

        // parse coefficients
        i = 2;
        while (i < s->frame_len) {
            if (s->version_b) {
                j = i + 16;
            } else {
                int v = get_bits1(gb);
                if (v) {
                    v = get_bits(gb, 4);
                    j = i + rle_length_tab[v] * 8;
                } else {
                    j = i + 8;
                }
            }

            j = FFMIN(j, s->frame_len);

            width = get_bits(gb, 4);
            if (width == 0) {
                memset(coeffs + i, 0, (j - i) * sizeof(*coeffs));
                i = j;
                while (s->bands[k] < i)
                    q = quant[k++];
            } else {
                while (i < j) {
                    if (s->bands[k] == i)
                        q = quant[k++];
                    coeff = get_bits(gb, width);
                    if (coeff) {
                        int v;
                        v = get_bits1(gb);
                        if (v)
                            coeffs[i] = -q * coeff;
                        else
                            coeffs[i] =  q * coeff;
                    } else {
                        coeffs[i] = 0.0f;
                    }
                    i++;
                }
            }
        }

        if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
            coeffs[0] /= 0.5;
            s->trans.dct.dct_calc(&s->trans.dct,  coeffs);
        }
        else if (CONFIG_BINKAUDIO_RDFT_DECODER)
            s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs);
    }

    for (ch = 0; ch < s->channels; ch++) {
        int j;
        int count = s->overlap_len * s->channels;
        if (!s->first) {
            j = ch;
            for (i = 0; i < s->overlap_len; i++, j += s->channels)
                out[ch][i] = (s->previous[ch][i] * (count - j) +
                                      out[ch][i] *          j) / count;
        }
        memcpy(s->previous[ch], &out[ch][s->frame_len - s->overlap_len],
               s->overlap_len * sizeof(*s->previous[ch]));
    }

    s->first = 0;

    return 0;
}
Ejemplo n.º 19
0
Archivo: main.c Proyecto: EmisFR/burp
static int run_child(int *cfd, SSL_CTX *ctx, struct sockaddr_storage *addr,
	int status_wfd, int status_rfd, const char *conffile, int forking)
{
	int ret=-1;
	int ca_ret=0;
	SSL *ssl=NULL;
	BIO *sbio=NULL;
	struct conf **confs=NULL;
	struct conf **cconfs=NULL;
	struct cntr *cntr=NULL;
	struct async *as=NULL;
	const char *cname=NULL;
	struct asfd *asfd=NULL;
	int is_status_server=0;

	if(!(confs=confs_alloc())
	  || !(cconfs=confs_alloc()))
		goto end;

	set_peer_env_vars(addr);

	// Reload global config, in case things have changed. This means that
	// the server does not need to be restarted for most conf changes.
	confs_init(confs);
	confs_init(cconfs);
	if(conf_load_global_only(conffile, confs)) goto end;

	// Hack to keep forking turned off if it was specified as off on the
	// command line.
	if(!forking) set_int(confs[OPT_FORK], 0);

	if(!(sbio=BIO_new_socket(*cfd, BIO_NOCLOSE))
	  || !(ssl=SSL_new(ctx)))
	{
		logp("There was a problem joining ssl to the socket\n");
		goto end;
	}
	SSL_set_bio(ssl, sbio, sbio);

	/* Do not try to check peer certificate straight away.
	   Clients can send a certificate signing request when they have
	   no certificate. */
	SSL_set_verify(ssl, SSL_VERIFY_PEER
		/* | SSL_VERIFY_FAIL_IF_NO_PEER_CERT */, 0);

	if(ssl_do_accept(ssl))
		goto end;
	if(!(as=async_alloc())
	  || as->init(as, 0)
	  || !(asfd=setup_asfd_ssl(as, "main socket", cfd, ssl)))
		goto end;
	asfd->set_timeout(asfd, get_int(confs[OPT_NETWORK_TIMEOUT]));
	asfd->ratelimit=get_float(confs[OPT_RATELIMIT]);

	if(authorise_server(as->asfd, confs, cconfs)
	  || !(cname=get_string(cconfs[OPT_CNAME])) || !*cname)
	{
		// Add an annoying delay in case they are tempted to
		// try repeatedly.
		log_and_send(as->asfd, "unable to authorise on server");
		sleep(1);
		goto end;
	}

	if(!get_int(cconfs[OPT_ENABLED]))
	{
		log_and_send(as->asfd, "client not enabled on server");
		sleep(1);
		goto end;
	}

	// Set up counters. Have to wait until here to get cname.
	if(!(cntr=cntr_alloc())
	  || cntr_init(cntr, cname))
		goto end;
	set_cntr(confs[OPT_CNTR], cntr);
	set_cntr(cconfs[OPT_CNTR], cntr);

	/* At this point, the client might want to get a new certificate
	   signed. Clients on 1.3.2 or newer can do this. */
	if((ca_ret=ca_server_maybe_sign_client_cert(as->asfd, confs, cconfs))<0)
	{
		logp("Error signing client certificate request for %s\n",
			cname);
		goto end;
	}
	else if(ca_ret>0)
	{
		// Certificate signed and sent back.
		// Everything is OK, but we will close this instance
		// so that the client can start again with a new
		// connection and its new certificates.
		logp("Signed and returned client certificate request for %s\n",
			cname);
		ret=0;
		goto end;
	}

	/* Now it is time to check the certificate. */
	if(ssl_check_cert(ssl, confs, cconfs))
	{
		log_and_send(as->asfd, "check cert failed on server");
		goto end;
	}

	if(status_rfd>=0)
	{
		is_status_server=1;
		if(!setup_asfd(as, "status server parent socket", &status_rfd))
			goto end;
	}

	ret=child(as, is_status_server, status_wfd, confs, cconfs);
end:
	*cfd=-1;
	if(as && asfd_flush_asio(as->asfd))
		ret=-1;
	async_asfd_free_all(&as); // This closes cfd for us.
	logp("exit child\n");
	if(cntr) cntr_free(&cntr);
	if(confs)
	{
		set_cntr(confs[OPT_CNTR], NULL);
		confs_free(&confs);
	}
	if(cconfs)
	{
		set_cntr(cconfs[OPT_CNTR], NULL);
		confs_free(&cconfs);
	}
	return ret;
}
Ejemplo n.º 20
0
/*
 *----------------------------------------------------------------------
 *
 * fcgi_config_set_config --
 *
 *      Implements the FastCGI FCGIConfig configuration directive.
 *      This command adds routines to control the execution of the
 *      dynamic FastCGI processes.
 *
 *
 *----------------------------------------------------------------------
 */
const char *fcgi_config_set_config(cmd_parms *cmd, void *dummy, const char *arg)
{
    pool * const p = cmd->pool;
    pool * const tp = cmd->temp_pool;
    const char *err, *option;
    const char * const name = cmd->cmd->name;

    /* Allocate temp storage for an initial environment */
    unsigned int envc = 0;
    char **envp = (char **)ap_pcalloc(tp, sizeof(char *) * (MAX_INIT_ENV_VARS + 3));

    err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
    if (err)
    {
        return err;
    }

    /* Parse the directive arguments */
    while (*arg) {
        option = ap_getword_conf(tp, &arg);

        if (strcasecmp(option, "-maxProcesses") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicMaxProcs, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-minProcesses") == 0) {
            if ((err = get_int(tp, &arg, &dynamicMinProcs, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-maxClassProcesses") == 0) {
            if ((err = get_int(tp, &arg, &dynamicMaxClassProcs, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-killInterval") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicKillInterval, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-updateInterval") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicUpdateInterval, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-gainValue") == 0) {
            if ((err = get_float(tp, &arg, &dynamicGain, 0.0, 1.0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if ((strcasecmp(option, "-singleThreshold") == 0)
		    || (strcasecmp(option, "-singleThreshhold") == 0)) 
        {
            if ((err = get_int(tp, &arg, &dynamicThreshold1, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if ((strcasecmp(option, "-multiThreshold") == 0)
		    || (strcasecmp(option, "-multiThreshhold") == 0)) 
        {
            if ((err = get_int(tp, &arg, &dynamicThresholdN, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-startDelay") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicPleaseStartDelay, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-initial-env") == 0) {
            if ((err = get_env_var(p, &arg, envp, &envc)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-pass-header") == 0) {
            if ((err = get_pass_header(p, &arg, &dynamic_pass_headers)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-appConnTimeout") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicAppConnectTimeout, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-idle-timeout") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamic_idle_timeout, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-listen-queue-depth") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicListenQueueDepth, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-min-server-life") == 0) {
            if ((err = get_int(tp, &arg, &dynamicMinServerLife, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-restart-delay") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicRestartDelay, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-init-start-delay") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicInitStartDelay, 0)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-processSlack") == 0) {
            if ((err = get_u_int(tp, &arg, &dynamicProcessSlack, 1)))
                return invalid_value(tp, name, NULL, option, err);
        }
        else if (strcasecmp(option, "-restart") == 0) {
            dynamicAutoRestart = 1;
        }
        else if (strcasecmp(option, "-autoUpdate") == 0) {
            dynamicAutoUpdate = 1;
		}
        else if (strcasecmp(option, "-flush") == 0) {
            dynamicFlush = TRUE;
        }
        else {
            return ap_psprintf(tp, "%s: invalid option: %s", name, option);
        }
    } /* while */

    if (dynamicProcessSlack >= dynamicMaxProcs + 1) {
	    /* the kill policy would work unexpectedly */
    	return ap_psprintf(tp, 
            "%s: processSlack (%u) must be less than maxProcesses (%u) + 1", 
        	name, dynamicProcessSlack, dynamicMaxProcs);
    }

    /* Move env array to a surviving pool, leave 2 extra slots for 
     * WIN32 _FCGI_MUTEX_ and _FCGI_SHUTDOWN_EVENT_ */
    dynamicEnvp = (char **)ap_pcalloc(p, sizeof(char *) * (envc + 4));
    memcpy(dynamicEnvp, envp, sizeof(char *) * envc);

    return NULL;
}
Ejemplo n.º 21
0
    std::vector<value> parse(Range &r, parse_flag_t flags, unsigned n = ~0) {
      std::vector<value> ret;
      for(; n != 0; --n) {
        type_t const t = get_type(r);
        switch(t) {
        case SMALL_INTEGER_EXT:
          ret.push_back(value(t, get_small_integer(r)));
          break;
        case INTEGER_EXT:
          ret.push_back(value(t, get_integer(r)));
          break;
        case FLOAT_EXT:
          ret.push_back(value(t, get_float(r)));
          break;
        case ATOM_EXT:
          ret.push_back(value(t, get_atom(r)));
          break;
        case SMALL_TUPLE_EXT: {
          if(flags & parse_complex) {
            // TODO
          }
          byte_t const size = get_small_tuple_size(r);
          ret.push_back(value(t, parse(r, flags, size)));
        }
          break;
        case LARGE_TUPLE_EXT: {
          if(flags & parse_complex) {
            // TODO
          }
          boost::uint32_t const size = get_large_tuple_size(r);
          ret.push_back(value(t, parse(r, flags, size)));
        }
          break;
        case NIL_EXT:
          ret.push_back(value());
          break;
        case STRING_EXT:
          ret.push_back(value(t, get_string(r)));
          break;
        case LIST_EXT: {
          // TODO handle Tail!
          boost::uint32_t const size = get_list_size(r);
          /* not optimal: collecting into a vector and then constructing a list
             from that */
          std::vector<value> tmp = parse(r, flags, size);
          ret.push_back(value(t, std::list<value>(tmp.begin(), tmp.end())));
        }
          break;
        case BINARY_EXT:
          ret.push_back(value(t, get_binary(r)));
          break;
#ifndef LIBBERT_NO_EXTENSION
        case X_NEW_FLOAT_EXT:
          ret.push_back(value(FLOAT_EXT, x_get_new_float(r)));
          break;
#endif
        default:
          throw bert_exception("unkown type");
        };
      }
      return ret;
    }
Ejemplo n.º 22
0
void FATR hgh_parse_
#if defined(USE_FCD)
(Integer *debug_ptr,
 Integer *lmax_ptr,
 Integer *locp_ptr,
 double  *rlocal_ptr,
 const _fcd fcd_sdir_name,
 Integer *n9,
 const _fcd fcd_dir_name,
 Integer *n0,
 const _fcd fcd_in_filename,
 Integer *n1,
 const _fcd fcd_out_filename,
 Integer *n2)
{
    char *sdir_name    = _fcdtocp(fcd_sdir_name);
    char *dir_name     = _fcdtocp(fcd_dir_name);
    char *in_filename  = _fcdtocp(fcd_in_filename);
    char *out_filename = _fcdtocp(fcd_out_filename);

#else
(debug_ptr,lmax_ptr,locp_ptr,rlocal_ptr,
 sdir_name,n9,dir_name,n0,in_filename,n1,out_filename,n2)
Integer	*debug_ptr;
Integer	*lmax_ptr;
Integer	*locp_ptr;
double 	*rlocal_ptr;
char	sdir_name[];
Integer	*n9;
char	dir_name[];
Integer	*n0;
char	in_filename[];
Integer	*n1;
char	out_filename[];
Integer	*n2;
{

#endif

    int      debug,done;
    int      lmax_out,locp_out;
    double   rlocal_out;

    int      lmax;
    int      nmax_l[4];

    char     atom[10];

    int      Zion;                  /* local psp parameters          */
    double   rloc,C1,C2,C3,C4;

    double   r[4];                  /* projector radii               */

    double   H[3][4];               /* diagonal overlap coefficients */
    double   K[3][4];               /* diagonal overlap coefficients */

    int    i,p,p1;
    char   *w,*tc;
    FILE   *fp;

    char     comment[255];
    char     line[255];
    int      argc,value;
    char     words[20][80];



    int		m9 = ((int) (*n9));
    int		m0 = ((int) (*n0));
    int		m1 = ((int) (*n1));
    int		m2 = ((int) (*n2));
    char *infile  = (char *) malloc(m9+m1+5);
    char *outfile = (char *) malloc(m0+m2+5);

    char *full_filename = (char *) malloc(m9+25+5);


    debug = *debug_ptr;
    lmax_out   = *lmax_ptr;
    locp_out   = *locp_ptr;
    rlocal_out = *rlocal_ptr;

    (void) strncpy(infile, sdir_name, m9);
    infile[m9] = '\0';
    strcat(infile,"/");
    infile[m9+1] = '\0';
    strncat(infile,in_filename,m1);
    infile[m9+m1+1] = '\0';

    (void) strncpy(outfile, dir_name, m0);
    outfile[m0] = '\0';
    strcat(outfile,"/");
    outfile[m0+1] = '\0';
    strncat(outfile,out_filename,m2);
    outfile[m0+m2+1] = '\0';

    Zion = 0;
    rloc = 0.0;
    C1   = 0.0;
    C2   = 0.0;
    C3   = 0.0;
    C4   = 0.0;


    r[0] = 0.0;
    r[1] = 0.0;
    r[2] = 0.0;
    r[3] = 0.0;

    H[0][0] = 0.0;  /*s*/
    H[1][0] = 0.0;
    H[2][0] = 0.0;

    H[0][1] = 0.0;  /*p*/
    H[1][1] = 0.0;
    H[2][1] = 0.0;

    H[0][2] = 0.0;  /*d*/
    H[1][2] = 0.0;
    H[2][2] = 0.0;

    H[0][3] = 0.0;  /*f*/
    H[1][3] = 0.0;
    H[2][3] = 0.0;

    K[0][0] = 0.0;  /*s*/
    K[1][0] = 0.0;
    K[2][0] = 0.0;

    K[0][1] = 0.0;  /*p*/
    K[1][1] = 0.0;
    K[2][1] = 0.0;

    K[0][2] = 0.0; /*d*/
    K[1][2] = 0.0;
    K[2][2] = 0.0;

    K[0][3] = 0.0;  /*f*/
    K[1][3] = 0.0;
    K[2][3] = 0.0;

    /* find the comment */
    strcpy(comment,"Hartwigsen, Goedecker and Hutter pseudopotential");
    fp = fopen(infile,"r+");
    w = get_word(fp);
    while ((w!=NIL) && (strcmp("<comment>",w)!=0))
        w = get_word(fp);

    if (w!=NIL)
    {
        w = get_word(fp);
        p  = 0;
        tc = comment;
        while ((w!=NIL)&&(strcmp("<end>",w) != 0))
        {
            p = (strlen(w));
            strcpy(tc, w);
            for (p1=0;p1<p; ++p1) ++tc;
            strcpy(tc, " ");
            ++tc;

            w = get_word(fp);
        }
    }
    fclose(fp);

    /* Read HGH psp */
    fp = fopen(infile,"r+");
    w = get_word(fp);
    while ((w!=NIL) && (strcmp("<HGH>",w)!=0))
        w = get_word(fp);

    /* Error occured */
    if (w==NIL)
    {
        printf("Error: <HGH> section not found\n");
        fclose(fp);
        exit(99);
    }

    argc = to_eoln(fp);

    if (!get_string(fp,atom)) printf("NO ATOM NAME\n");
    if (!get_int(fp,&Zion)) printf("NO ZION\n");

    if (!get_float(fp,&rloc)) printf("NO rlocN\n");
    if (!get_float(fp,&C1)) C1 = 0.0;
    if (!get_float(fp,&C2)) C2 = 0.0;
    if (!get_float(fp,&C3)) C3 = 0.0;
    if (!get_float(fp,&C4)) C4 = 0.0;

    argc = to_eoln(fp);
    done = get_end(fp);
    i = 0;
    if (!done)
    {
        if (!get_float(fp,&(r[i])))    r[i]    = 0.0;
        if (!get_float(fp,&(H[0][i]))) H[0][i] = 0.0;
        if (!get_float(fp,&(H[1][i]))) H[1][i] = 0.0;
        if (!get_float(fp,&(H[2][i]))) H[2][i] = 0.0;
        argc = to_eoln(fp);
        done = get_end(fp);
        ++i;
        while (!done)
        {
            if (!get_float(fp,&(r[i])))    r[i]    = 0.0;
            if (!get_float(fp,&(H[0][i]))) H[0][i] = 0.0;
            if (!get_float(fp,&(H[1][i]))) H[1][i] = 0.0;
            if (!get_float(fp,&(H[2][i]))) H[2][i] = 0.0;
            argc = to_eoln(fp);
            done = get_end(fp);
            if (!done)
            {
                if (!get_float(fp,&(K[0][i]))) K[0][i] = 0.0;
                if (!get_float(fp,&(K[1][i]))) K[1][i] = 0.0;
                if (!get_float(fp,&(K[2][i]))) K[2][i] = 0.0;
                argc = to_eoln(fp);
                done = get_end(fp);
            }
            ++i;
        }
    }
    lmax = i-1;
    fclose(fp);


    /* write outfile */
    fp = fopen(outfile,"w+");
    fprintf(fp,"%d\n",1);  /* set psp_type */
    fprintf(fp,"%s\n",atom);
    fprintf(fp,"%d\n",Zion);
    if (lmax<0) fprintf(fp,"%d",0);
    else fprintf(fp,"%d\n",lmax);
    fprintf(fp,"%lf  %lf %lf %lf %lf\n",rloc,C1,C2,C3,C4);

    if (lmax>=0)
    {
        fprintf(fp,"%lf  %lf %lf %lf\n",r[0],H[0][0],H[1][0],H[2][0]);
        for (i=1; i<=lmax; ++i)
        {
            fprintf(fp,"%lf %lf %lf %lf\n",r[i],H[0][i],H[1][i],H[2][i]);
            fprintf(fp,"%lf %lf %lf\n",         K[0][i],K[1][i],K[2][i]);
        }
    }
    fprintf(fp,"%s\n",comment);
    fclose(fp);


    if (debug)
    {
        printf("HGH pseudopotential Parameters\n\n");
        printf("atom : %s\n",atom);
        printf("Zion : %d\n",Zion);
        printf(" lmax: %d\n\n",lmax);
        printf(" vloc: %lf    %lf %lf %lf %lf\n\n",rloc,C1,C2,C3,C4);

        if (lmax>=0)
        {
            printf("l=%d   r=%lf \t H= %lf %lf %lf\n\n",0,r[0],H[0][0],H[1][0],H[2][0]);
            for (i=1; i<=lmax; ++i)
            {
                printf("l=%d   r=%lf \t H= %lf %lf %lf\n",i,r[i],H[0][i],H[1][i],H[2][i]);
                printf("           \t\t K= %lf %lf %lf\n\n",     K[0][i],K[1][i],K[2][i]);
            }
        }
    }

    /* free malloc memory */
    free(infile);
    free(outfile);
    free(full_filename);

    fflush(stdout);
    return;

} /* main */
Ejemplo n.º 23
0
void BlenderSync::sync_curve_settings()
{
	PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves");

	CurveSystemManager *curve_system_manager = scene->curve_system_manager;
	CurveSystemManager prev_curve_system_manager = *curve_system_manager;

	curve_system_manager->use_curves = get_boolean(csscene, "use_curves");
	curve_system_manager->minimum_width = get_float(csscene, "minimum_width");
	curve_system_manager->maximum_width = get_float(csscene, "maximum_width");

	curve_system_manager->primitive =
	        (CurvePrimitiveType)get_enum(csscene,
	                                     "primitive",
	                                     CURVE_NUM_PRIMITIVE_TYPES,
	                                     CURVE_LINE_SEGMENTS);
	curve_system_manager->curve_shape =
	        (CurveShapeType)get_enum(csscene,
	                                 "shape",
	                                 CURVE_NUM_SHAPE_TYPES,
	                                 CURVE_THICK);
	curve_system_manager->resolution = get_int(csscene, "resolution");
	curve_system_manager->subdivisions = get_int(csscene, "subdivisions");
	curve_system_manager->use_backfacing = !get_boolean(csscene, "cull_backfacing");

	/* Triangles */
	if(curve_system_manager->primitive == CURVE_TRIANGLES) {
		/* camera facing planes */
		if(curve_system_manager->curve_shape == CURVE_RIBBON) {
			curve_system_manager->triangle_method = CURVE_CAMERA_TRIANGLES;
			curve_system_manager->resolution = 1;
		}
		else if(curve_system_manager->curve_shape == CURVE_THICK) {
			curve_system_manager->triangle_method = CURVE_TESSELATED_TRIANGLES;
		}
	}
	/* Line Segments */
	else if(curve_system_manager->primitive == CURVE_LINE_SEGMENTS) {
		if(curve_system_manager->curve_shape == CURVE_RIBBON) {
			/* tangent shading */
			curve_system_manager->line_method = CURVE_UNCORRECTED;
			curve_system_manager->use_encasing = true;
			curve_system_manager->use_backfacing = false;
			curve_system_manager->use_tangent_normal_geometry = true;
		}
		else if(curve_system_manager->curve_shape == CURVE_THICK) {
			curve_system_manager->line_method = CURVE_ACCURATE;
			curve_system_manager->use_encasing = false;
			curve_system_manager->use_tangent_normal_geometry = false;
		}
	}
	/* Curve Segments */
	else if(curve_system_manager->primitive == CURVE_SEGMENTS) {
		if(curve_system_manager->curve_shape == CURVE_RIBBON) {
			curve_system_manager->primitive = CURVE_RIBBONS;
			curve_system_manager->use_backfacing = false;
		}
	}

	if(curve_system_manager->modified_mesh(prev_curve_system_manager)) {
		BL::BlendData::objects_iterator b_ob;

		for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
			if(object_is_mesh(*b_ob)) {
				BL::Object::particle_systems_iterator b_psys;
				for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys) {
					if((b_psys->settings().render_type()==BL::ParticleSettings::render_type_PATH)&&(b_psys->settings().type()==BL::ParticleSettings::type_HAIR)) {
						BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data();
						mesh_map.set_recalc(key);
						object_map.set_recalc(*b_ob);
					}
				}
			}
		}
	}

	if(curve_system_manager->modified(prev_curve_system_manager))
		curve_system_manager->tag_update(scene);
}
Ejemplo n.º 24
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get Octane render passes settings.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BlenderSync::sync_passes(BL::RenderLayer *layer) {
    PointerRNA oct_scene = RNA_pointer_get(&b_scene.ptr, "octane");

    PointerRNA rlayer;
    if(layer)
        rlayer = layer->ptr;
    else {
        BL::RenderLayer b_rlay = static_cast<BL::RenderLayer>(b_scene.render().layers.active());
        rlayer = b_rlay.ptr;
    }

    Passes *passes      = scene->passes;
    Passes prevpasses   = *passes;

    passes->oct_node->bUsePasses = get_boolean(oct_scene, "use_passes");
    if(passes->oct_node->bUsePasses) {
        passes->oct_node->curPassType = Passes::pass_type_translator[RNA_enum_get(&oct_scene, "cur_pass_type")];

        passes->oct_node->iMaxSamples           = get_int(oct_scene, "pass_max_samples");
        passes->oct_node->iSamplingMode         = RNA_enum_get(&oct_scene, "pass_sampling_mode");
        passes->oct_node->fZdepthMax            = get_float(oct_scene, "pass_z_depth_max");
        passes->oct_node->fUVMax                = get_float(oct_scene, "pass_uv_max");
        passes->oct_node->fMaxSpeed             = get_float(oct_scene, "pass_max_speed");
        passes->oct_node->fAODistance           = get_float(oct_scene, "pass_ao_distance");
        passes->oct_node->bAoAlphaShadows       = get_boolean(oct_scene, "pass_alpha_shadows");
        passes->oct_node->bPassesRaw            = get_boolean(oct_scene, "pass_raw");
        passes->oct_node->bPostProcEnvironment  = get_boolean(oct_scene, "pass_pp_env");
        passes->oct_node->bBump                 = get_boolean(oct_scene, "pass_bump");
        passes->oct_node->fOpacityThreshold     = get_float(oct_scene, "pass_opacity_threshold");

        if(!interactive) {
            passes->oct_node->bBeautyPass             = get_boolean(rlayer, "use_pass_combined");
            passes->oct_node->bEmittersPass           = get_boolean(rlayer, "use_pass_emit");
            passes->oct_node->bEnvironmentPass        = get_boolean(rlayer, "use_pass_environment");
            passes->oct_node->bDiffuseDirectPass      = get_boolean(rlayer, "use_pass_diffuse_direct");
            passes->oct_node->bDiffuseIndirectPass    = get_boolean(rlayer, "use_pass_diffuse_indirect");

            bool cur_use = get_boolean(rlayer, "use_pass_reflection");
            int  subtype = RNA_enum_get(&oct_scene, "reflection_pass_subtype");
            passes->oct_node->bReflectionDirectPass   = cur_use && (subtype == 0);
            passes->oct_node->bReflectionIndirectPass = cur_use && (subtype == 1);
            passes->oct_node->bLayerReflectionsPass   = cur_use && (subtype == 1);

            passes->oct_node->bRefractionPass         = get_boolean(rlayer, "use_pass_refraction");
            passes->oct_node->bTransmissionPass       = get_boolean(rlayer, "use_pass_transmission_color");
            passes->oct_node->bSubsurfScatteringPass  = get_boolean(rlayer, "use_pass_subsurface_color");
            passes->oct_node->bPostProcessingPass     = false;

            cur_use = get_boolean(rlayer, "use_pass_normal");
            subtype = RNA_enum_get(&oct_scene, "normal_pass_subtype");
            passes->oct_node->bGeomNormalsPass    = cur_use && (subtype == 0);
            passes->oct_node->bShadingNormalsPass = cur_use && (subtype == 1);
            passes->oct_node->bVertexNormalsPass  = cur_use && (subtype == 2);

            passes->oct_node->bPositionPass       = false;
            passes->oct_node->bZdepthPass         = get_boolean(rlayer, "use_pass_z");
            passes->oct_node->bMaterialIdPass     = get_boolean(rlayer, "use_pass_material_index");
            passes->oct_node->bUVCoordinatesPass  = get_boolean(rlayer, "use_pass_uv");
            passes->oct_node->bTangentsPass       = false;
            passes->oct_node->bWireframePass      = false;
            passes->oct_node->bObjectIdPass       = get_boolean(rlayer, "use_pass_object_index");
            passes->oct_node->bAOPass             = get_boolean(rlayer, "use_pass_ambient_occlusion");
            passes->oct_node->bMotionVectorPass   = false;

            cur_use = get_boolean(rlayer, "use_pass_shadow");
            subtype = RNA_enum_get(&oct_scene, "shadows_pass_subtype");
            passes->oct_node->bLayerShadowsPass       = cur_use && (subtype == 0);
            passes->oct_node->bLayerBlackShadowsPass  = cur_use && (subtype == 1);
            passes->oct_node->bLayerColorShadowsPass  = cur_use && (subtype == 2);

            passes->oct_node->bLayerIdPass            = false;
            passes->oct_node->bLayerMaskPass          = false;
            passes->oct_node->bLightPassIdPass        = false;

            passes->oct_node->bAmbientLightPass       = false;
            passes->oct_node->bSunlightPass           = false;
            passes->oct_node->bLight1Pass             = false;
            passes->oct_node->bLight2Pass             = false;
            passes->oct_node->bLight3Pass             = false;
            passes->oct_node->bLight4Pass             = false;
            passes->oct_node->bLight5Pass             = false;
            passes->oct_node->bLight6Pass             = false;
            passes->oct_node->bLight7Pass             = false;
            passes->oct_node->bLight8Pass             = false;
        }
        else {
            passes->oct_node->bBeautyPass             = false;

            passes->oct_node->bEmittersPass           = false;
            passes->oct_node->bEnvironmentPass        = false;
            passes->oct_node->bDiffuseDirectPass      = false;
            passes->oct_node->bDiffuseIndirectPass    = false;
            passes->oct_node->bReflectionDirectPass   = false;
            passes->oct_node->bReflectionIndirectPass = false;
            passes->oct_node->bRefractionPass         = false;
            passes->oct_node->bTransmissionPass       = false;
            passes->oct_node->bSubsurfScatteringPass  = false;
            passes->oct_node->bPostProcessingPass     = false;

            passes->oct_node->bLayerShadowsPass       = false;
            passes->oct_node->bLayerBlackShadowsPass  = false;
            passes->oct_node->bLayerColorShadowsPass  = false;
            passes->oct_node->bLayerReflectionsPass   = false;

            passes->oct_node->bAmbientLightPass       = false;
            passes->oct_node->bSunlightPass           = false;
            passes->oct_node->bLight1Pass             = false;
            passes->oct_node->bLight2Pass             = false;
            passes->oct_node->bLight3Pass             = false;
            passes->oct_node->bLight4Pass             = false;
            passes->oct_node->bLight5Pass             = false;
            passes->oct_node->bLight6Pass             = false;
            passes->oct_node->bLight7Pass             = false;
            passes->oct_node->bLight8Pass             = false;

            passes->oct_node->bGeomNormalsPass        = false;
            passes->oct_node->bShadingNormalsPass     = false;
            passes->oct_node->bVertexNormalsPass      = false;
            passes->oct_node->bPositionPass           = false;
            passes->oct_node->bZdepthPass             = false;
            passes->oct_node->bMaterialIdPass         = false;
            passes->oct_node->bUVCoordinatesPass      = false;
            passes->oct_node->bTangentsPass           = false;
            passes->oct_node->bWireframePass          = false;
            passes->oct_node->bMotionVectorPass       = false;
            passes->oct_node->bObjectIdPass           = false;
            passes->oct_node->bLayerIdPass            = false;
            passes->oct_node->bLayerMaskPass          = false;
            passes->oct_node->bLightPassIdPass        = false;

            passes->oct_node->bAOPass                 = false;

            switch(passes->oct_node->curPassType) {
            case ::Octane::RenderPassId::RENDER_PASS_BEAUTY:
                passes->oct_node->bBeautyPass = true;
                break;

            case ::Octane::RenderPassId::RENDER_PASS_EMIT:
                passes->oct_node->bEmittersPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_ENVIRONMENT:
                passes->oct_node->bEnvironmentPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_DIFFUSE_DIRECT:
                passes->oct_node->bDiffuseDirectPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_DIFFUSE_INDIRECT:
                passes->oct_node->bDiffuseIndirectPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_REFLECTION_DIRECT:
                passes->oct_node->bReflectionDirectPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_REFLECTION_INDIRECT:
                passes->oct_node->bReflectionIndirectPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_REFRACTION:
                passes->oct_node->bRefractionPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_TRANSMISSION:
                passes->oct_node->bTransmissionPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_SSS:
                passes->oct_node->bSubsurfScatteringPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_POST_PROC:
                passes->oct_node->bPostProcessingPass = true;
                break;

            case ::Octane::RenderPassId::RENDER_PASS_LAYER_SHADOWS:
                passes->oct_node->bLayerShadowsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LAYER_BLACK_SHADOWS:
                passes->oct_node->bLayerBlackShadowsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LAYER_COLOR_SHADOWS:
                passes->oct_node->bLayerColorShadowsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LAYER_REFLECTIONS:
                passes->oct_node->bLayerReflectionsPass = true;
                break;

            case ::Octane::RenderPassId::RENDER_PASS_AMBIENT_LIGHT:
                passes->oct_node->bAmbientLightPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_SUNLIGHT:
                passes->oct_node->bSunlightPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_1:
                passes->oct_node->bLight1Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_2:
                passes->oct_node->bLight2Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_3:
                passes->oct_node->bLight3Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_4:
                passes->oct_node->bLight4Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_5:
                passes->oct_node->bLight5Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_6:
                passes->oct_node->bLight6Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_7:
                passes->oct_node->bLight7Pass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_8:
                passes->oct_node->bLight8Pass = true;
                break;

            case ::Octane::RenderPassId::RENDER_PASS_GEOMETRIC_NORMAL:
                passes->oct_node->bGeomNormalsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_SHADING_NORMAL:
                passes->oct_node->bShadingNormalsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_VERTEX_NORMAL:
                passes->oct_node->bVertexNormalsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_POSITION:
                passes->oct_node->bPositionPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_Z_DEPTH:
                passes->oct_node->bZdepthPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_MATERIAL_ID:
                passes->oct_node->bMaterialIdPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_UV_COORD:
                passes->oct_node->bUVCoordinatesPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_TANGENT_U:
                passes->oct_node->bTangentsPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_WIREFRAME:
                passes->oct_node->bWireframePass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_OBJECT_ID:
                passes->oct_node->bObjectIdPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_MOTION_VECTOR:
                passes->oct_node->bMotionVectorPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_RENDER_LAYER_ID:
                passes->oct_node->bLayerIdPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_RENDER_LAYER_MASK:
                passes->oct_node->bLayerMaskPass = true;
                break;
            case ::Octane::RenderPassId::RENDER_PASS_LIGHT_PASS_ID:
                passes->oct_node->bLightPassIdPass = true;
                break;

            case ::Octane::RenderPassId::RENDER_PASS_AMBIENT_OCCLUSION:
                passes->oct_node->bAOPass = true;
                break;

            default:
                passes->oct_node->bBeautyPass = true;
                break;
            }
        }
    } //if(passes->oct_node->use_passes)
    
    if(passes->modified(prevpasses)) passes->tag_update();
} //sync_passes()
Ejemplo n.º 25
0
/*
** Execute the given opcode, until a RET. Parameters are between
** [stack+base,top). Returns n such that the the results are between
** [stack+n,top).
*/
static StkId lua_execute (Byte *pc, StkId base)
{
  if (lua_callhook)
    callHook (base, LUA_T_MARK, 0);
 while (1)
 {
  OpCode opcode;
  switch (opcode = (OpCode)*pc++)
  {
   case PUSHNIL: ttype(top) = LUA_T_NIL; incr_top; break;

   case PUSH0: case PUSH1: case PUSH2:
     ttype(top) = LUA_T_NUMBER;
     nvalue(top) = opcode-PUSH0;
     incr_top;
     break;

   case PUSHBYTE: 
     ttype(top) = LUA_T_NUMBER; nvalue(top) = *pc++; incr_top; break;

   case PUSHWORD:
   {
    Word w;
    get_word(w,pc);
    ttype(top) = LUA_T_NUMBER; nvalue(top) = w;
    incr_top;
   }
   break;

   case PUSHFLOAT:
   {
    real num;
    get_float(num,pc);
    ttype(top) = LUA_T_NUMBER; nvalue(top) = num;
    incr_top;
   }
   break;

   case PUSHSTRING:
   {
    Word w;
    get_word(w,pc);
    ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];
    incr_top;
   }
   break;

   case PUSHFUNCTION:
   {
    TFunc *f;
    get_code(f,pc);
    luaI_insertfunction(f);  /* may take part in GC */
    top->ttype = LUA_T_FUNCTION;
    top->value.tf = f;
    incr_top;
   }
   break;

   case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2:
   case PUSHLOCAL3: case PUSHLOCAL4: case PUSHLOCAL5:
   case PUSHLOCAL6: case PUSHLOCAL7: case PUSHLOCAL8:
   case PUSHLOCAL9: 
     *top = *((stack+base) + (int)(opcode-PUSHLOCAL0)); incr_top; break;

   case PUSHLOCAL: *top = *((stack+base) + (*pc++)); incr_top; break;

   case PUSHGLOBAL:
   {
    Word w;
    get_word(w,pc);
    getglobal(w);
   }
   break;

   case PUSHINDEXED:
    pushsubscript();
    break;

   case PUSHSELF:
   {
     TObject receiver = *(top-1);
     Word w;
     get_word(w,pc);
     ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];
     incr_top;
     pushsubscript();
     *top = receiver;
     incr_top;
     break;
   }

   case STORELOCAL0: case STORELOCAL1: case STORELOCAL2:
   case STORELOCAL3: case STORELOCAL4: case STORELOCAL5:
   case STORELOCAL6: case STORELOCAL7: case STORELOCAL8:
   case STORELOCAL9:
     *((stack+base) + (int)(opcode-STORELOCAL0)) = *(--top);
     break;

   case STORELOCAL: *((stack+base) + (*pc++)) = *(--top); break;

   case STOREGLOBAL:
   {
    Word w;
    get_word(w,pc);
    setglobal(w);
   }
   break;

   case STOREINDEXED0:
    storesubscript(top-3, 1);
    break;

   case STOREINDEXED: {
     int n = *pc++;
     storesubscript(top-3-n, 2);
     break;
   }

   case STORELIST0:
   case STORELIST:
   {
    int m, n;
    TObject *arr;
    if (opcode == STORELIST0) m = 0;
    else m = *(pc++) * FIELDS_PER_FLUSH;
    n = *(pc++);
    arr = top-n-1;
    while (n)
    {
     ttype(top) = LUA_T_NUMBER; nvalue(top) = n+m;
     *(lua_hashdefine (avalue(arr), top)) = *(top-1);
     top--;
     n--;
    }
   }
   break;

   case STORERECORD:  /* opcode obsolete: supersed by STOREMAP */
   {
    int n = *(pc++);
    TObject *arr = top-n-1;
    while (n)
    {
     Word w;
     get_word(w,pc);
     ttype(top) = LUA_T_STRING; tsvalue(top) = lua_constant[w];
     *(lua_hashdefine (avalue(arr), top)) = *(top-1);
     top--;
     n--;
    }
   }
   break;

   case STOREMAP: {
     int n = *(pc++);
     TObject *arr = top-(2*n)-1;
     while (n--) {
       *(lua_hashdefine (avalue(arr), top-2)) = *(top-1);
       top-=2;
     }
   }
   break;

   case ADJUST0:
     adjust_top(base);
     break;

   case ADJUST: {
     StkId newtop = base + *(pc++);
     adjust_top(newtop);
     break;
   }

   case VARARGS:
     adjust_varargs(base + *(pc++));
     break;

   case CREATEARRAY:
   {
    Word size;
    get_word(size,pc);
    avalue(top) = lua_createarray(size);
    ttype(top) = LUA_T_ARRAY;
    incr_top;
   }
   break;

   case EQOP:
   {
    int res = lua_equalObj(top-2, top-1);
    --top;
    ttype(top-1) = res ? LUA_T_NUMBER : LUA_T_NIL;
    nvalue(top-1) = 1;
   }
   break;

    case LTOP:
      comparison(LUA_T_NUMBER, LUA_T_NIL, LUA_T_NIL, IM_LT);
      break;

   case LEOP:
      comparison(LUA_T_NUMBER, LUA_T_NUMBER, LUA_T_NIL, IM_LE);
      break;

   case GTOP:
      comparison(LUA_T_NIL, LUA_T_NIL, LUA_T_NUMBER, IM_GT);
      break;

   case GEOP:
      comparison(LUA_T_NIL, LUA_T_NUMBER, LUA_T_NUMBER, IM_GE);
      break;

   case ADDOP:
   {
    TObject *l = top-2;
    TObject *r = top-1;
    if (tonumber(r) || tonumber(l))
      call_arith(IM_ADD);
    else
    {
      nvalue(l) += nvalue(r);
      --top;
    }
   }
   break;

   case SUBOP:
   {
    TObject *l = top-2;
    TObject *r = top-1;
    if (tonumber(r) || tonumber(l))
      call_arith(IM_SUB);
    else
    {
      nvalue(l) -= nvalue(r);
      --top;
    }
   }
   break;

   case MULTOP:
   {
    TObject *l = top-2;
    TObject *r = top-1;
    if (tonumber(r) || tonumber(l))
      call_arith(IM_MUL);
    else
    {
      nvalue(l) *= nvalue(r);
      --top;
    }
   }
   break;

   case DIVOP:
   {
    TObject *l = top-2;
    TObject *r = top-1;
    if (tonumber(r) || tonumber(l))
      call_arith(IM_DIV);
    else
    {
      nvalue(l) /= nvalue(r);
      --top;
    }
   }
   break;

   case POWOP:
    call_arith(IM_POW);
    break;

   case CONCOP: {
     TObject *l = top-2;
     TObject *r = top-1;
     if (tostring(l) || tostring(r))
       call_binTM(IM_CONCAT, "unexpected type for concatenation");
     else {
       tsvalue(l) = lua_createstring(lua_strconc(svalue(l),svalue(r)));
       --top;
     }
   }
   break;

   case MINUSOP:
    if (tonumber(top-1))
    {
      ttype(top) = LUA_T_NIL;
      incr_top;
      call_arith(IM_UNM);
    }
    else
      nvalue(top-1) = - nvalue(top-1);
   break;

   case NOTOP:
    ttype(top-1) = (ttype(top-1) == LUA_T_NIL) ? LUA_T_NUMBER : LUA_T_NIL;
    nvalue(top-1) = 1;
   break;

   case ONTJMP:
   {
    Word w;
    get_word(w,pc);
    if (ttype(top-1) != LUA_T_NIL) pc += w;
   }
   break;

   case ONFJMP:
   {
    Word w;
    get_word(w,pc);
    if (ttype(top-1) == LUA_T_NIL) pc += w;
   }
   break;

   case JMP:
   {
    Word w;
    get_word(w,pc);
    pc += w;
   }
   break;

   case UPJMP:
   {
    Word w;
    get_word(w,pc);
    pc -= w;
   }
   break;

   case IFFJMP:
   {
    Word w;
    get_word(w,pc);
    top--;
    if (ttype(top) == LUA_T_NIL) pc += w;
   }
   break;

   case IFFUPJMP:
   {
    Word w;
    get_word(w,pc);
    top--;
    if (ttype(top) == LUA_T_NIL) pc -= w;
   }
   break;

   case POP: --top; break;

   case CALLFUNC:
   {
     int nParams = *(pc++);
     int nResults = *(pc++);
     StkId newBase = (top-stack)-nParams;
     do_call(newBase, nResults);
   }
   break;

   case RETCODE0:
   case RETCODE:
     if (lua_callhook)
       callHook (base, LUA_T_MARK, 1);
     return (base + ((opcode==RETCODE0) ? 0 : *pc));

   case SETLINE:
   {
    Word line;
    get_word(line,pc);
    if ((stack+base-1)->ttype != LUA_T_LINE)
    {
      /* open space for LINE value */
      open_stack((top-stack)-base);
      base++;
      (stack+base-1)->ttype = LUA_T_LINE;
    }
    (stack+base-1)->value.i = line;
    if (lua_linehook)
      lineHook (line);
    break;
   }

   default:
    lua_error ("internal error - opcode doesn't match");
  }
 }
}
Ejemplo n.º 26
0
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get additional Octane scene settings.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void BlenderSync::sync_kernel() {
    PointerRNA oct_scene = RNA_pointer_get(&b_scene.ptr, "octane");

    Kernel *kernel = scene->kernel;
    Kernel prevkernel = *kernel;

    BL::RenderSettings r = b_scene.render();
    if(r.use_motion_blur()) {
        float fps                                           = (float)b_scene.render().fps() / b_scene.render().fps_base();
        float shuttertime                                   = r.motion_blur_shutter();
        BlenderSession::MotionBlurType mb_type              = static_cast<BlenderSession::MotionBlurType>(RNA_enum_get(&oct_scene, "mb_type"));
        float mb_frame_time_sampling                        = mb_type == BlenderSession::INTERNAL ? 1.0f / fps : 0.0f;
        kernel->oct_node->fShutterTime                      = mb_frame_time_sampling != 0.0f ? shuttertime / mb_frame_time_sampling : 0.0f;
        BlenderSession::MotionBlurDirection mb_direction    = static_cast<BlenderSession::MotionBlurDirection>(RNA_enum_get(&oct_scene, "mb_direction"));
        switch(mb_direction) {
            case BlenderSession::BEFORE:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::BEFORE;
                break;
            case BlenderSession::AFTER:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::AFTER;
                break;
            case BlenderSession::SYMMETRIC:
                kernel->oct_node->mbAlignment = ::OctaneEngine::Kernel::SYMMETRIC;
                break;
            default:
                break;
        }
    }
    else kernel->oct_node->fShutterTime = 0.0f;

    kernel->oct_node->type = static_cast< ::OctaneEngine::Kernel::KernelType>(RNA_enum_get(&oct_scene, "kernel_type"));
    kernel->oct_node->infoChannelType = channel_translator[RNA_enum_get(&oct_scene, "info_channel_type")];

    ::Octane::RenderPassId cur_pass_type = Passes::pass_type_translator[RNA_enum_get(&oct_scene, "cur_pass_type")];
    if(cur_pass_type == ::Octane::RenderPassId::RENDER_PASS_BEAUTY) {
        kernel->oct_node->iMaxSamples = interactive ? get_int(oct_scene, "max_preview_samples") : get_int(oct_scene, "max_samples");
        //kernel->oct_node->iMaxPreviewSamples = get_int(oct_scene, "max_preview_samples");
        //if(kernel->oct_node->iMaxPreviewSamples == 0) kernel->oct_node->iMaxPreviewSamples = 16000;
    }
    else if(cur_pass_type == ::Octane::RenderPassId::RENDER_PASS_AMBIENT_OCCLUSION) {
        kernel->oct_node->iMaxSamples = get_int(oct_scene, "pass_ao_max_samples");
        //kernel->oct_node->iMaxPreviewSamples = kernel->oct_node->iMaxSamples;
    }
    else {
        kernel->oct_node->iMaxSamples = get_int(oct_scene, "pass_max_samples");
        //kernel->oct_node->iMaxPreviewSamples = kernel->oct_node->iMaxSamples;
    }
    if(scene->session->b_session && scene->session->b_session->motion_blur && scene->session->b_session->mb_type == BlenderSession::SUBFRAME && scene->session->b_session->mb_samples > 1)
        kernel->oct_node->iMaxSamples = kernel->oct_node->iMaxSamples / scene->session->b_session->mb_samples;
    if(kernel->oct_node->iMaxSamples < 1) kernel->oct_node->iMaxSamples = 1;

    kernel->oct_node->fFilterSize = get_float(oct_scene, "filter_size");
    kernel->oct_node->fRayEpsilon = get_float(oct_scene, "ray_epsilon");
    kernel->oct_node->bAlphaChannel = get_boolean(oct_scene, "alpha_channel");
    kernel->oct_node->bAlphaShadows = get_boolean(oct_scene, "alpha_shadows");
    kernel->oct_node->bBumpNormalMapping = get_boolean(oct_scene, "bump_normal_mapping");
    kernel->oct_node->bBkFaceHighlight = get_boolean(oct_scene, "wf_bkface_hl");
    kernel->oct_node->fPathTermPower = get_float(oct_scene, "path_term_power");

    kernel->oct_node->bKeepEnvironment = get_boolean(oct_scene, "keep_environment");

    kernel->oct_node->fCausticBlur = get_float(oct_scene, "caustic_blur");
    kernel->oct_node->iMaxDiffuseDepth = get_int(oct_scene, "max_diffuse_depth");
    kernel->oct_node->iMaxGlossyDepth = get_int(oct_scene, "max_glossy_depth");

    kernel->oct_node->fCoherentRatio = get_float(oct_scene, "coherent_ratio");
    kernel->oct_node->bStaticNoise = get_boolean(oct_scene, "static_noise");

    kernel->oct_node->iSpecularDepth = get_int(oct_scene, "specular_depth");
    kernel->oct_node->iGlossyDepth = get_int(oct_scene, "glossy_depth");
    kernel->oct_node->fAODist = get_float(oct_scene, "ao_dist");
    kernel->oct_node->GIMode = static_cast< ::OctaneEngine::Kernel::DirectLightMode>(RNA_enum_get(&oct_scene, "gi_mode"));
    kernel->oct_node->iDiffuseDepth = get_int(oct_scene, "diffuse_depth");
    kernel->oct_node->sAoTexture = get_string(oct_scene, "ao_texture");

    kernel->oct_node->fExploration = get_float(oct_scene, "exploration");
    kernel->oct_node->fGIClamp = get_float(oct_scene, "gi_clamp");
    kernel->oct_node->fDLImportance = get_float(oct_scene, "direct_light_importance");
    kernel->oct_node->iMaxRejects = get_int(oct_scene, "max_rejects");
    kernel->oct_node->iParallelism = get_int(oct_scene, "parallelism");

    kernel->oct_node->fZdepthMax = get_float(oct_scene, "zdepth_max");
    kernel->oct_node->fUVMax = get_float(oct_scene, "uv_max");
    kernel->oct_node->iSamplingMode = RNA_enum_get(&oct_scene, "sampling_mode");
    kernel->oct_node->fMaxSpeed = get_float(oct_scene, "max_speed");

    kernel->oct_node->bLayersEnable = get_boolean(oct_scene, "layers_enable");
    kernel->oct_node->iLayersCurrent = get_int(oct_scene, "layers_current");
    kernel->oct_node->bLayersInvert = get_boolean(oct_scene, "layers_invert");
    kernel->oct_node->layersMode = static_cast< ::OctaneEngine::Kernel::LayersMode>(RNA_enum_get(&oct_scene, "layers_mode"));

    kernel->oct_node->iParallelSamples = get_int(oct_scene, "parallel_samples");
    kernel->oct_node->iMaxTileSamples = get_int(oct_scene, "max_tile_samples");
    kernel->oct_node->bMinimizeNetTraffic = get_boolean(oct_scene, "minimize_net_traffic");
    kernel->oct_node->bDeepImageEnable = get_boolean(oct_scene, "deep_image");
    kernel->oct_node->iMaxDepthSamples = get_int(oct_scene, "max_depth_samples");
    kernel->oct_node->fDepthTolerance = get_float(oct_scene, "depth_tolerance");
    kernel->oct_node->iWorkChunkSize = get_int(oct_scene, "work_chunk_size");
    kernel->oct_node->bAoAlphaShadows = get_boolean(oct_scene, "ao_alpha_shadows");
    kernel->oct_node->fOpacityThreshold = get_float(oct_scene, "opacity_threshold");

    if(kernel->modified(prevkernel)) kernel->tag_update();

    // GPUs
    int iValues[8] = {0, 0, 0, 0, 0, 0, 0, 0};
    RNA_boolean_get_array(&oct_scene, "devices", iValues);
    kernel->uiGPUs = 0;
    for(int i = 0; i < 8; ++i)
        if(iValues[i]) kernel->uiGPUs |= 0x01 << i;

    if(kernel->uiGPUs != prevkernel.uiGPUs) kernel->tag_updateGPUs();
} //sync_kernel()
Ejemplo n.º 27
0
 virtual float getScaleFactorY() const
 {
     return get_float("getScaleFactorY");
 }
Ejemplo n.º 28
0
int main(int argc, char *argv[])
{
    
    GSList *proces = NULL;
    Processor *processor = NULL;
    FILE *cpuinfo;
    gchar buffer[256];
    gint processor_number = 0;
    gchar *str1;

    cpuinfo = fopen("/proc/cpuinfo", "r");
    if (!cpuinfo)
    {
        return FALSE;
    }
    //
    while (fgets(buffer, 256, cpuinfo))
    {
        gchar **tmp = g_strsplit(buffer, ":", 2);

        if (g_str_has_prefix(tmp[0], "processor"))
        {
            if (processor)
            {
                gint family = processor->family;
                gint model = processor->model;
                processor->strmodel = g_strdup("Pentium II/Plel");
                proces = g_slist_append(proces, processor);
            }
            processor = g_new0(Processor, 1);
            processor_number++;
        }

        if (tmp[0] && tmp[1])
        {
            // 去除前面和后面的空格.
            tmp[0] = g_strstrip(tmp[0]);
            tmp[1] = g_strstrip(tmp[1]);
            // 获取cpu的信息.
            get_str("model name",   processor->model_name);
            get_str("vendor_id",    processor->vendor_id);
            get_str("flags",        processor->flags);
            get_int("cache size",   processor->cache_size);
            get_float("cpu MHz",    processor->cpu_mhz);
            get_float("bogomips",   processor->bogomips);
            //
            get_str("fpu", processor->has_fpu);
            //
            get_str("fdiv_bug", processor->fdiv_bug);
            get_str("hlt_bug",  processor->hlt_bug);
            get_str("f00f_bug", processor->f00f_bug);
            get_str("coma_bug", processor->coma_bug);
            //
            get_int("processor", processor->id);
        }
        g_strfreev(tmp);
    }

    if (processor)
    {
        proces = g_slist_append(proces, processor);
    }
    //
    fclose(cpuinfo);
    puts("================输出cpu信息========================");
    printf("cpu个数:%d\n", processor_number);
    GSList *temp_proces = NULL;
    for (temp_proces = proces; temp_proces != NULL ; temp_proces = temp_proces->next)
    {
        puts("---------------------------------------------------");
        printf("id:%d\n", ((Processor*)temp_proces->data)->id);
        printf("model name:%s\n", ((Processor*)temp_proces->data)->model_name);
        printf("cache_size:%d\n", ((Processor*)temp_proces->data)->cache_size);
        printf("bogomips:%.2f\n", ((Processor*)temp_proces->data)->bogomips);
    }
    return TRUE;
}
Ejemplo n.º 29
0
int JsonIn::get_int()
{
    // get float value and then convert to int,
    // because "1.359e3" is technically a valid integer.
    return (int)get_float();
}
Ejemplo n.º 30
0
static lisp_cell_t *subr_unordered(lisp_t *l, lisp_cell_t *args)
{
	UNUSED(l);
	double a = get_float(car(args)), b = get_float(CADR(args));
	return isunordered(a, b) ? gsym_tee() : gsym_nil();
}