Example #1
0
static int sdl_create_buffers(void)
{
	mame_printf_verbose("sdl_create_buffers: creating stream buffer of %u bytes\n", stream_buffer_size);

	stream_buffer = global_alloc_array_clear(INT8, stream_buffer_size);
	stream_playpos = 0;
	buf_locked = 0;
	return 0;
}
Example #2
0
legacy_device_base::legacy_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, UINT32 clock, device_get_config_func get_config)
	: device_t(mconfig, type, "Legacy Device", tag, owner, clock),
	  m_get_config_func(get_config),
	  m_inline_config(NULL),
	  m_token(NULL)
{
	// allocate a buffer for the inline configuration
	UINT32 configlen = (UINT32)get_legacy_int(DEVINFO_INT_INLINE_CONFIG_BYTES);
	if (configlen != 0)
		m_inline_config = global_alloc_array_clear(UINT8, configlen);

	// set the proper name
	m_name = get_legacy_string(DEVINFO_STR_NAME);
	m_shortname = get_legacy_string(DEVINFO_STR_SHORTNAME);
	m_searchpath = m_shortname;

	// create the token
	int tokenbytes = get_legacy_int(DEVINFO_INT_TOKEN_BYTES);
	if (tokenbytes != 0)
		m_token = global_alloc_array_clear(UINT8, tokenbytes);
}
Example #3
0
legacy_device_config_base::legacy_device_config_base(const machine_config &mconfig, device_type type, const char *tag, const device_config *owner, UINT32 clock, device_get_config_func get_config)
	: device_config(mconfig, type, "Legacy Device", tag, owner, clock),
	  m_get_config_func(get_config),
	  m_inline_config(NULL)
{
	// allocate a buffer for the inline configuration
	UINT32 configlen = (UINT32)get_legacy_config_int(DEVINFO_INT_INLINE_CONFIG_BYTES);
	if (configlen != 0)
		m_inline_config = global_alloc_array_clear(UINT8, configlen);

	// set the proper name
	m_name = get_legacy_config_string(DEVINFO_STR_NAME);
}
Example #4
0
void info_xml_creator::output(FILE *out)
{
	m_output = out;

	// output the DTD
	fprintf(m_output, "<?xml version=\"1.0\"?>\n");
	astring dtd(s_dtd_string);
	dtd.replace(0,"__XML_ROOT__", emulator_info::get_xml_root());
	dtd.replace(0,"__XML_TOP__", emulator_info::get_xml_top());
	
	fprintf(m_output, "%s\n\n", dtd.cstr());

	// top-level tag
	fprintf(m_output, "<%s build=\"%s\" debug=\""
#ifdef MAME_DEBUG
		"yes"
#else
		"no"
#endif
		"\" mameconfig=\"%d\">\n",
		emulator_info::get_xml_root(),
		xml_normalize_string(build_version),
		CONFIG_VERSION
	);

	m_device_used = global_alloc_array_clear(UINT8, m_device_count);

	// iterate through the drivers, outputting one at a time
	while (m_drivlist.next())
		output_one();

	// iterate through the devices, and output their roms 
	output_devices();
	
	global_free(m_device_used);
	
	// close the top level tag
	fprintf(m_output, "</%s>\n",emulator_info::get_xml_root());
}
Example #5
0
int cli_info_listbrothers(core_options *options, const char *gamename)
{
	UINT8 *didit = global_alloc_array_clear(UINT8, driver_list_get_count(drivers));
	int drvindex, count = 0;
	astring filename;

	/* iterate over drivers */
	for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
		if (!didit[drvindex] && mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
		{
			int matchindex;

			didit[drvindex] = TRUE;
			if (count > 0)
				mame_printf_info("\n");
			mame_printf_info("%s ... other drivers in %s:\n", drivers[drvindex]->name, core_filename_extract_base(&filename, drivers[drvindex]->source_file, FALSE)->cstr());

			/* now iterate again over drivers, finding those with the same source file */
			for (matchindex = 0; drivers[matchindex]; matchindex++)
				if (matchindex != drvindex && strcmp(drivers[drvindex]->source_file, drivers[matchindex]->source_file) == 0)
				{
					const char *matchstring = (mame_strwildcmp(gamename, drivers[matchindex]->name) == 0) ? "-> " : "   ";
					const game_driver *clone_of = driver_get_clone(drivers[matchindex]);

					if (clone_of != NULL && (clone_of->flags & GAME_IS_BIOS_ROOT) == 0)
						mame_printf_info("%s%-16s [%s]\n", matchstring, drivers[matchindex]->name, clone_of->name);
					else
						mame_printf_info("%s%s\n", matchstring, drivers[matchindex]->name);
					didit[matchindex] = TRUE;
				}

			count++;
		}

	/* return an error if none found */
	global_free(didit);
	return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
}
Example #6
0
bool g64_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
{
    UINT64 size = io_generic_size(io);
    UINT8 *img = global_alloc_array(UINT8, size);
    io_generic_read(io, img, 0, size);

    int version = img[0x08];
    if (version)
        throw emu_fatalerror("g64_format: Unsupported version %u", version);

    int track_count = img[0x09];

    int pos = 0x0c;
    int track_offset[84*2];
    for(int track = 0; track < track_count; track++) {
        track_offset[track] = pick_integer_le(img, pos, 4);
        pos += 4;
    }

    int speed_zone_offset[84*2];
    for(int track = 0; track < track_count; track++) {
        speed_zone_offset[track] = pick_integer_le(img, pos, 4);
        pos += 4;
    }

    for(int track = 0; track < track_count; track++) {
        int track_size = 0;
        pos = track_offset[track];
        if (pos > 0) {
            track_size = pick_integer_le(img, pos, 2);
            pos +=2;

            if (speed_zone_offset[track] > 3)
                throw emu_fatalerror("g64_format: Unsupported variable speed zones on track %d", track);

            UINT32 cell_size = c1541_cell_size[speed_zone_offset[track]];
            int total_size = 200000000/cell_size;
            UINT32 *buffer = global_alloc_array_clear(UINT32, total_size);
            int offset = 0;

            for (int i=0; i<track_size; i++, pos++) {
                for (int bit=7; bit>=0; bit--) {
                    bit_w(buffer, offset++, BIT(img[pos], bit), cell_size);
                    if (offset == total_size) break;
                }
            }

            if (offset < total_size) {
                // pad the remainder of the track with sync
                int count = (total_size-offset);
                for (int i=0; i<count; i++) {
                    bit_w(buffer, offset++, 1, cell_size);
                }
            }

            int physical_track = track >= 84 ? track - 84 : track;
            int head = track >= 84;

            generate_track_from_levels(physical_track, head, buffer, total_size, 0, image);
            global_free(buffer);
        }
    }

    image->set_variant(floppy_image::SSSD);

    return true;
}
Example #7
0
s2636_sound_device::s2636_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, S2636_SOUND, "S2636", tag, owner, clock),
	  device_sound_interface(mconfig, *this)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(s2636_sound));
}
Example #8
0
filter_volume_device::filter_volume_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, FILTER_VOLUME, "Volume Filter", tag, owner, clock),
	  device_sound_interface(mconfig, *this)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(filter_volume_state));
}
Example #9
0
int audit_images(core_options *options, const game_driver *gamedrv, UINT32 validation, audit_record **audit)
{
	machine_config *config = global_alloc(machine_config(gamedrv->machine_config));
	const rom_entry *region, *rom;
	const rom_source *source;
	audit_record *record;
	int anyfound = FALSE;
	int anyrequired = FALSE;
	int allshared = TRUE;
	int records;

	/* determine the number of records we will generate */
	records = 0;
	for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
	{
		int source_is_gamedrv = rom_source_is_gamedrv(gamedrv, source);
		for (region = rom_first_region(gamedrv, source); region != NULL; region = rom_next_region(region))
			for (rom = rom_first_file(region); rom != NULL; rom = rom_next_file(rom))
				if (ROMREGION_ISROMDATA(region) || ROMREGION_ISDISKDATA(region))
				{
					if (source_is_gamedrv && !ROM_ISOPTIONAL(rom) && !ROM_NOGOODDUMP(rom))
					{
						anyrequired = TRUE;

						if (allshared && !rom_used_by_parent(gamedrv, rom, NULL))
							allshared = FALSE;
					}
					records++;
				}
	}

	if (records > 0)
	{
		/* allocate memory for the records */
		*audit = global_alloc_array_clear(audit_record, records);
		record = *audit;

		/* iterate over ROM sources and regions */
		for (source = rom_first_source(gamedrv, config); source != NULL; source = rom_next_source(gamedrv, config, source))
		{
			int source_is_gamedrv = rom_source_is_gamedrv(gamedrv, source);
			for (region = rom_first_region(gamedrv, source); region != NULL; region = rom_next_region(region))
			{
				const char *regiontag = ROMREGION_ISLOADBYNAME(region) ? ROM_GETNAME(region) : NULL;
				for (rom = rom_first_file(region); rom; rom = rom_next_file(rom))
				{
					/* audit a file */
					if (ROMREGION_ISROMDATA(region))
					{
						audit_one_rom(options, rom, regiontag, gamedrv, validation, record);
					}

					/* audit a disk */
					else if (ROMREGION_ISDISKDATA(region))
					{
						audit_one_disk(options, rom, gamedrv, validation, record);
					}

					else
					{
						continue;
					}

					if (source_is_gamedrv && record->status != AUDIT_STATUS_NOT_FOUND && (allshared || !rom_used_by_parent(gamedrv, rom, NULL)))
						anyfound = TRUE;

					record++;
				}
			}
		}
	}

	/* if we found nothing, we don't have the set at all */
	if (!anyfound && anyrequired)
	{
		global_free(*audit);
		*audit = NULL;
		records = 0;
	}

	global_free(config);
	return records;
}
Example #10
0
int audit_samples(core_options *options, const game_driver *gamedrv, audit_record **audit)
{
	machine_config *config = global_alloc(machine_config(gamedrv->machine_config));
	audit_record *record;
	int records = 0;
	int sampnum;

	/* count the number of sample records attached to this driver */
	const device_config_sound_interface *sound = NULL;
	for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
		if (sound->devconfig().type() == SOUND_SAMPLES)
		{
			const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config();

			if (intf->samplenames != NULL)
			{
				/* iterate over samples in this entry */
				for (sampnum = 0; intf->samplenames[sampnum] != NULL; sampnum++)
					if (intf->samplenames[sampnum][0] != '*')
						records++;
			}
		}

	/* if no records, just quit now */
	if (records == 0)
		goto skip;

	/* allocate memory for the records */
	*audit = global_alloc_array_clear(audit_record, records);
	record = *audit;

	/* now iterate over sample entries */
	for (bool gotone = config->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
		if (sound->devconfig().type() == SOUND_SAMPLES)
		{
			const samples_interface *intf = (const samples_interface *)sound->devconfig().static_config();
			const char *sharedname = NULL;

			if (intf->samplenames != NULL)
			{
				/* iterate over samples in this entry */
				for (sampnum = 0; intf->samplenames[sampnum] != NULL; sampnum++)
					if (intf->samplenames[sampnum][0] == '*')
						sharedname = &intf->samplenames[sampnum][1];
					else
					{
						file_error filerr;
						mame_file *file;

						/* attempt to access the file from the game driver name */
						astring fname(gamedrv->name, PATH_SEPARATOR, intf->samplenames[sampnum]);
						filerr = mame_fopen_options(options, samplepath, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);

						/* attempt to access the file from the shared driver name */
						if (filerr != FILERR_NONE && sharedname != NULL)
						{
							fname.cpy(sharedname).cat(PATH_SEPARATOR).cat(intf->samplenames[sampnum]);
							filerr = mame_fopen_options(options, samplepath, fname, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD, &file);
						}

						/* fill in the record */
						record->type = AUDIT_FILE_SAMPLE;
						record->name = intf->samplenames[sampnum];
						if (filerr == FILERR_NONE)
						{
							set_status(record++, AUDIT_STATUS_GOOD, SUBSTATUS_GOOD);
							mame_fclose(file);
						}
						else
							set_status(record++, AUDIT_STATUS_NOT_FOUND, SUBSTATUS_NOT_FOUND);
					}
			}
		}

skip:
	global_free(config);
	return records;
}
Example #11
0
sid6581_device::sid6581_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, type, name, tag, owner, clock),
	  device_sound_interface(mconfig, *this)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(SID6581));
}
Example #12
0
void ti99_datamux_device::device_reset(void)
{
    const datamux_config *conf = reinterpret_cast<const datamux_config *>(static_config());

    const dmux_device_list_entry *list = conf->devlist;

    m_cpu = machine().device("maincpu");
    // m_space = &m_cpu->memory().space(AS_PROGRAM);

    m_devices.reset(); // clear the list
    m_use32k = (ioport("RAM")->read()==1);

    // better use a region?
    if (m_ram16b==NULL)
    {
        m_ram16b = global_alloc_array_clear(UINT16, 32768/2);
    }

    // Now building the list of active devices at this databus multiplex.
    // We allow for turning off devices according to configuration switch settings.
    // In particular, the HSGPL card cannot function unless the console GROMs are
    // removed.
    if ( list != NULL )
    {
        bool done = false;
        for (int i=0; !done; i++)
        {
            if (list[i].name == NULL)
            {
                done = true;
            }
            else
            {
                UINT32 set = 0;
                bool active_device = true;
                if (list[i].setting!=NULL)
                {
                    set = ioport(list[i].setting)->read();
                    active_device = ((set & list[i].set)==list[i].set) && ((set & list[i].unset)==0);
                }
                if (active_device)
                {
                    device_t *dev = machine().device(list[i].name);
                    if (dev != NULL)
                    {
                        attached_device *ad = new attached_device(dev, list[i]);
                        m_devices.append(*ad);
                        if (TRACE_SETUP) logerror("datamux: Device %s mounted at index %d.\n", list[i].name, i);
                    }
                    else
                    {
                        if (TRACE_SETUP) logerror("datamux: Device %s not found.\n", list[i].name);
                    }
                }
                else
                {
                    if (TRACE_SETUP) logerror("datamux: Device %s not mounted due to configuration setting %s.\n", list[i].name, list[i].setting);
                }
            }
        }
    }
    if (TRACE_SETUP) logerror("datamux: Device count = %d\n", m_devices.count());

    m_sysready = ASSERT_LINE;
    m_muxready = ASSERT_LINE;
    ready_join();

    m_waitcount = 0;
    m_latch = 0;

    m_read_mode = true;
}
Example #13
0
static void *expat_realloc(void *ptr, size_t size)
{
	if (ptr) global_free(ptr);
	return global_alloc_array_clear(UINT8,size);
}
Example #14
0
static void *expat_malloc(size_t size)
{
	return global_alloc_array_clear(UINT8,size);
}
Example #15
0
ym2608_device::ym2608_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, YM2608, "YM2608", tag, owner, clock),
	  device_sound_interface(mconfig, *this)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(ym2608_state));
}
Example #16
0
s3c2440_device::s3c2440_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
       : device_t(mconfig, S3C2440, "Samsung S3C2440", tag, owner, clock)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(s3c24xx_t));
}
Example #17
0
ttl74148_device::ttl74148_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
	: device_t(mconfig, TTL74148, "74148", tag, owner, clock)
{
	m_token = global_alloc_array_clear(UINT8, sizeof(ttl74148_state));
}