Beispiel #1
0
rom_load_manager::rom_load_manager(running_machine &machine)
	: m_machine(machine)
{
	/* figure out which BIOS we are using */
	device_iterator deviter(machine.config().root_device());
	for (device_t *device = deviter.first(); device != nullptr; device = deviter.next()) {
		if (device->rom_region()) {
			std::string specbios;
			if (device->owner() == nullptr) {
				specbios.assign(machine.options().bios());
			} else {
				specbios = machine.options().sub_value(std::string(device->owner()->tag()).c_str()+1,"bios");
				if (specbios.empty()) {
					specbios = device->default_bios_tag();
				}
			}
			determine_bios_rom(device, specbios.c_str());
		}
	}

	/* count the total number of ROMs */
	count_roms();

	/* reset the disk list */
	m_chd_list.clear();

	/* process the ROM entries we were passed */
	process_region_list();

	/* display the results and exit */
	display_rom_load_results(FALSE);
}
Beispiel #2
0
void rom_init(running_machine &machine)
{
	rom_load_data *romdata;

	/* allocate private data */
	machine.romload_data = romdata = auto_alloc_clear(machine, romload_private);

	/* make sure we get called back on the way out */
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(rom_exit), &machine));

	/* reset the romdata struct */
	romdata->m_machine = &machine;

	/* figure out which BIOS we are using */
	determine_bios_rom(romdata);

	/* count the total number of ROMs */
	count_roms(romdata);

	/* reset the disk list */
	romdata->chd_list.reset();

	/* process the ROM entries we were passed */
	process_region_list(romdata);

	/* display the results and exit */
	display_rom_load_results(romdata);
}
Beispiel #3
0
void rom_init(running_machine &machine)
{
	romload_private *romdata;

	/* allocate private data */
	machine.romload_data = romdata = auto_alloc_clear(machine, romload_private);

	/* make sure we get called back on the way out */
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(rom_exit), &machine));

	/* reset the romdata struct */
	romdata->m_machine = &machine;

	/* figure out which BIOS we are using */
	device_iterator deviter(romdata->machine().config().root_device());
	for (device_t *device = deviter.first(); device != NULL; device = deviter.next()) {
		if (device->rom_region()) {
			const char *specbios;
			astring temp;
			if (strcmp(device->tag(),":")==0) {
				specbios = romdata->machine().options().bios();
			} else {
				specbios = romdata->machine().options().sub_value(temp,device->owner()->tag()+1,"bios");
				if (strlen(specbios) == 0) {
					specbios = device->default_bios_tag().cstr();
				}
			}
			determine_bios_rom(romdata, device, specbios);
		}
	}

	/* count the total number of ROMs */
	count_roms(romdata);

	/* reset the disk list */
	romdata->chd_list.reset();

	/* process the ROM entries we were passed */
	process_region_list(romdata);

	/* display the results and exit */
	display_rom_load_results(romdata, FALSE);
}
Beispiel #4
0
int process_file(FILE *ifp)
{
  char *ibuf, *config = NULL;
  byte **rom = NULL;       /* pointers to ROM images */
  byte *data = NULL;      /* data accumulators      */
  int line = 0, first = 1, nroms = 0, abits = 0, length = 0, res = 0;
  int ix;

  /* Allocate space to read strings into */
  if((ibuf = calloc(MAXLINE + 1, sizeof(char))) == NULL) {
    fprintf(stderr, "Insufficient memory to process file\n");
    return 1; /* out of memory */
  }

  /* Read strings from the input file */
  while(read_line(ifp, ibuf, MAXLINE)) {
    ++line;
    strip_comment(ibuf);

    /* Blank lines are skipped in all cases */
    if(is_blank(ibuf))
      continue;

    strip_whitespace(ibuf);

    /*
      When we see the first line, we need to accumulate some other
      info we're going to need later.  This includes the number of
      address bits (abits), and the number of ROMs (nroms).  We also
      need to save a copy of the configuration line for later, since
      ibuf will be overwritten with each line that is consumed.

      We also range-check the values of abits and nroms, and allocate
      memory for the ROM images we will build during the reading of
      the rest of the file.  We save the length of the configuration
      line (length) so that we can syntax check subsequent lines in
      an efficent manner.
     */
    if(first) {

      /* Check structural validity of configuration line */
      if(!valid_string(ibuf, "0123456789Aa")) {
        fprintf(stderr,
                "Line %d: invalid character in configuration\n",
                line);
        res = 1;
        goto CLEANUP;
      }

      /* Count number of ROM cells and address (state) bits */
      nroms = count_roms(ibuf);
      abits = count_addr(ibuf);

      /* Complain if we didn't get at least 1 ROM, or if we got too many */
      if(nroms < 1) {
        fprintf(stderr, "Line %d: must specify at least 1 ROM number\n",
                line);
        res = 2;
        goto CLEANUP;
      } else if(nroms > NUM_ROMS) {
        fprintf(stderr, "Line %d: cannot specify more than %d ROMs\n",
                line, NUM_ROMS);
        res = 2;
        goto CLEANUP;
      }

      /* Complain if we got no address bits, or more than MAXBITS */
      if(abits < 1 || abits > MAXBITS) {
        fprintf(stderr, "Line %d: must have between 1-%d state bits\n",
                line, MAXBITS);
        res = 3;
        goto CLEANUP;
      }

      /* Okay, the config is alright, save it for later ... */
      if((config = copy_string(ibuf)) == NULL) {
        fprintf(stderr, "Insufficient memory to process file\n");
        res = 1;
        goto CLEANUP;
      }

      /* Hang onto the length, we'll need it later */
      length = strlen(config);

      /* Allocate space for the ROMs and their accumulators */
      if(!alloc_roms(&rom, nroms, config, abits)) {
        fprintf(stderr, "Insufficient memory to process file\n");
        res = 1;
        goto CLEANUP;
      }
      if((data = calloc(nroms, sizeof(byte))) == NULL) {
        fprintf(stderr, "Insufficient memory to process file\n");
        res = 1;
        goto CLEANUP;
      }

      first = 0;
      continue;
    } /* end if(first) */

    /* Translate output "don't care" values to regular bits */
    translate(ibuf, OUTPUT_DC, g_odcv);

    /* Anything bad left in the string? */
    if(!valid_string(ibuf, "01Xx")) {
      fprintf(stderr, "Line %d: invalid character in data\n", line);
      res = 1;
      goto CLEANUP;
    }

    /* Make sure we got enough fields to satisfy the template */
    if(strlen(ibuf) != length) {
      fprintf(stderr,
              "Line %d: wrong number of fields (wanted %u, got %u)\n",
              line, (unsigned) length, (unsigned) strlen(ibuf));
      res = 4;
      goto CLEANUP;
    }

    /* Grab all the data out of the line, escaping on error */
    if(!parse_data(ibuf, line, config, abits, data)) {
      res = 5;
      goto CLEANUP;
    }

    /* Write the data into the ROM images.  We know which ROMs
       to use by checking the pointers in the ROM image array,
       and the accumulator is already set to go
     */
    for(ix = 0; ix < nroms; ix++) {
      if(rom[ix]) {
        write_range(rom[ix], ibuf, abits, data[ix]);
      }
    }

    /* Clear out accumulators for the next round */
    memset(data, 0, nroms);

  } /* end while(read_line(...)) */

  /* If we didn't get a first line at all, the file was logically
     empty (i.e., not even a configuration!) */
  if(first) {
    fprintf(stderr, "No configuration line was found\n");
    res = 7;

  } else {

    /* Having accumulated all the data into the ROM images, we now
       will dump them out into the appropriate files */
    if(!dump_roms(rom, nroms, abits, g_fmt))
      res = 6;
  }

 CLEANUP:
  free(ibuf);

  if(config)
    free(config);

  if(rom) {
    free_roms(rom, nroms);
    free(rom);
  }

  if(data)
    free(data);

  return res;

} /* end process_file() */
Beispiel #5
0
int rom_load(const struct RomModule *romp)
{
	const struct RomModule *regionlist[REGION_MAX];
	const struct RomModule *region;
	static struct rom_load_data romdata;
	int regnum;

	/* reset the region list */
	for (regnum = 0;regnum < REGION_MAX;regnum++)
		regionlist[regnum] = NULL;

	/* reset the romdata struct */
	memset(&romdata, 0, sizeof(romdata));
	romdata.romstotal = count_roms(romp);

	/* reset the disk list */
	memset(disk_handle, 0, sizeof(disk_handle));

	/* determine the correct biosset to load based on options.bios string */
	system_bios = determine_bios_rom(Machine->gamedrv->bios);

	/* loop until we hit the end */
	for (region = romp, regnum = 0; region; region = rom_next_region(region), regnum++)
	{
		int regiontype = ROMREGION_GETTYPE(region);

		debugload("Processing region %02X (length=%X)\n", regiontype, ROMREGION_GETLENGTH(region));

		/* the first entry must be a region */
		if (!ROMENTRY_ISREGION(region))
		{
			printf("Error: missing ROM_REGION header\n");
			return 1;
		}

		/* if sound is disabled and it's a sound-only region, skip it */
		if (Machine->sample_rate == 0 && ROMREGION_ISSOUNDONLY(region))
			continue;

		/* allocate memory for the region */
		if (new_memory_region(regiontype, ROMREGION_GETLENGTH(region), ROMREGION_GETFLAGS(region)))
		{
			printf("Error: unable to allocate memory for region %d\n", regiontype);
			return 1;
		}

		/* remember the base and length */
		romdata.regionlength = memory_region_length(regiontype);
		romdata.regionbase = memory_region(regiontype);
		debugload("Allocated %X bytes @ %08X\n", romdata.regionlength, (int)romdata.regionbase);

		/* clear the region if it's requested */
		if (ROMREGION_ISERASE(region))
			memset(romdata.regionbase, ROMREGION_GETERASEVAL(region), romdata.regionlength);

		/* or if it's sufficiently small (<= 4MB) */
		else if (romdata.regionlength <= 0x400000)
			memset(romdata.regionbase, 0, romdata.regionlength);

#ifdef MAME_DEBUG
		/* if we're debugging, fill region with random data to catch errors */
		else
			fill_random(romdata.regionbase, romdata.regionlength);
#endif

		/* now process the entries in the region */
		if (ROMREGION_ISROMDATA(region))
		{
			if (!process_rom_entries(&romdata, region + 1))
				return 1;
		}
		else if (ROMREGION_ISDISKDATA(region))
		{
			if (!process_disk_entries(&romdata, region + 1))
				return 1;
		}

		/* add this region to the list */
		if (regiontype < REGION_MAX)
			regionlist[regiontype] = region;
	}

	/* post-process the regions */
	for (regnum = 0; regnum < REGION_MAX; regnum++)
		if (regionlist[regnum])
		{
			debugload("Post-processing region %02X\n", regnum);
			romdata.regionlength = memory_region_length(regnum);
			romdata.regionbase = memory_region(regnum);
			region_post_process(&romdata, regionlist[regnum]);
		}

	/* display the results and exit */
	return display_rom_load_results(&romdata);
}
Beispiel #6
0
void rom_init(running_machine *machine, const rom_entry *romp)
{
	const rom_entry *regionlist[REGION_MAX];
	const rom_entry *region;
	static rom_load_data romdata;
	int regnum;

	/* if no roms, bail */
	if (romp == NULL)
		return;

	/* make sure we get called back on the way out */
	add_exit_callback(machine, rom_exit);

	/* reset the region list */
	memset((void *)regionlist, 0, sizeof(regionlist));

	/* reset the romdata struct */
	memset(&romdata, 0, sizeof(romdata));
	romdata.romstotal = count_roms(romp);

	/* reset the disk list */
	memset(disk_handle, 0, sizeof(disk_handle));

	/* determine the correct biosset to load based on options.bios string */
	system_bios = determine_bios_rom(Machine->gamedrv->bios);

	/* loop until we hit the end */
	for (region = romp, regnum = 0; region; region = rom_next_region(region), regnum++)
	{
		int regiontype = ROMREGION_GETTYPE(region);

		debugload("Processing region %02X (length=%X)\n", regiontype, ROMREGION_GETLENGTH(region));

		/* the first entry must be a region */
		assert(ROMENTRY_ISREGION(region));

		/* remember the base and length */
		romdata.regionbase = new_memory_region(machine, regiontype, ROMREGION_GETLENGTH(region), ROMREGION_GETFLAGS(region));
		romdata.regionlength = ROMREGION_GETLENGTH(region);
		debugload("Allocated %X bytes @ %08X\n", romdata.regionlength, (int)romdata.regionbase);

		/* clear the region if it's requested */
		if (ROMREGION_ISERASE(region))
			memset(romdata.regionbase, ROMREGION_GETERASEVAL(region), romdata.regionlength);

		/* or if it's sufficiently small (<= 4MB) */
		else if (romdata.regionlength <= 0x400000)
			memset(romdata.regionbase, 0, romdata.regionlength);

#ifdef MAME_DEBUG
		/* if we're debugging, fill region with random data to catch errors */
		else
			fill_random(romdata.regionbase, romdata.regionlength);
#endif

		/* now process the entries in the region */
		if (ROMREGION_ISROMDATA(region))
			process_rom_entries(&romdata, region + 1);
		else if (ROMREGION_ISDISKDATA(region))
			process_disk_entries(&romdata, region + 1);

		/* add this region to the list */
		if (regiontype < REGION_MAX)
			regionlist[regiontype] = region;
	}

	/* post-process the regions */
	for (regnum = 0; regnum < REGION_MAX; regnum++)
		if (regionlist[regnum])
		{
			debugload("Post-processing region %02X\n", regnum);
			romdata.regionlength = memory_region_length(regnum);
			romdata.regionbase = memory_region(regnum);
			region_post_process(&romdata, regionlist[regnum]);
		}

	/* display the results and exit */
	total_rom_load_warnings = romdata.warnings;

	display_rom_load_results(&romdata);
}