Exemplo n.º 1
0
static void vc20_prg_open(mess_image *img, mame_file *fp)
{
	const char *name;
	int i;

	prg.length = mame_fsize (fp);
	if ((prg.prg = (UINT8 *) malloc (prg.length)) == NULL)
	{
		logerror("tape %s could not be loaded\n", image_filename(img));
		return;
	}
	mame_fread (fp, prg.prg, prg.length);
	logerror("tape %s loaded\n", image_filename(img));

	name = image_filename(img);
    for (i = 0; name[i] != 0; i++)
		prg.name[i] = toupper (name[i]);
	for (; i < 16; i++)
		prg.name[i] = ' ';

	prg.img = img;
	prg.stateblock = 0;
	prg.stateheader = 0;
	prg.statebyte = 0;
	prg.statebit = 0;
	tape.type = TAPE_PRG;
	tape.on = 1;
	prg.state = 2;
	prg.pos = 0;
	prg.timer = prg.prg_timer;
}
Exemplo n.º 2
0
ROM_END

/* System Configuration */

DEVICE_LOAD( studio2_cart ) {
	UINT8	*ptr = NULL;
	UINT8	header[ST2_HEADER_SIZE];
	int	filesize;

	filesize = image_length( image );
	if ( filesize <= ST2_HEADER_SIZE ) {
		logerror( "Error loading cartridge: Invalid ROM file: %s.\n", image_filename( image ) );
		return INIT_FAIL;
	}

	/* read ST2 header */
	if ( image_fread(image, header, ST2_HEADER_SIZE ) != ST2_HEADER_SIZE ) {
		logerror( "Error loading cartridge: Unable to read header from file: %s.\n", image_filename( image ) );
		return INIT_FAIL;
	}
	filesize -= ST2_HEADER_SIZE;
	/* Read ST2 cartridge contents */
	ptr = ((UINT8 *)memory_region( REGION_CPU1 ) ) + 0x0400;
	if ( image_fread(image, ptr, filesize ) != filesize ) {
		logerror( "Error loading cartridge: Unable to read contents from file: %s.\n", image_filename( image ) );
		return INIT_FAIL;
	}
	return INIT_PASS;
}
Exemplo n.º 3
0
static void vc20_wav_open(mess_image *img, mame_file *fp)
{
	if ((wav.sample = vc20_read_wav_sample (fp)) == NULL)
	{
		logerror("tape %s could not be loaded\n", image_filename(img));
		return;
	}
	logerror("tape %s loaded\n", image_filename(img));

	tape.type = TAPE_WAV;
	wav.img = img;
	wav.pos = 0;
	tape.on = 1;
	wav.state = 2;
}
Exemplo n.º 4
0
boost::optional<boost::shared_ptr<Error> > TitleScene::SceneInitialize(void) {
	next_scene.reset();
	OPT_ERROR(AddWindow(script_window, 0, 0, 0, 0));

	boost::shared_ptr<const std::wstring> image_filename(new std::wstring(L"data/scene/title.png"));
	OPT_ERROR(AddImageUI(image_filename, uis::UIBase::MOVE_MODE_CENTER_FREE, 0, 50));

	std::vector<boost::tuple<boost::shared_ptr<const std::wstring>, boost::shared_ptr<void> > > ui_list;
	const wchar_t *text_list[] = {
		L"NewGame",
		L"LoadGame",
		L"Exit"
	};
	boost::shared_ptr<void> next_list[] = {
		boost::shared_ptr<void>(new NEXT(NEXT_NEW_GAME)),
		boost::shared_ptr<void>(new NEXT(NEXT_LOAD_GAME)),
		boost::shared_ptr<void>(new NEXT(NEXT_EXIT))
	};
	for(unsigned int i = 0; i < 3; i++) {
		boost::shared_ptr<const std::wstring> text(new std::wstring(text_list[i]));
		boost::shared_ptr<void> next(next_list[i]);
		ui_list.push_back(make_tuple(text, next));
	}
	OPT_ERROR(AddSelectorWindow(ui_list, 1, boost::none, 250, 300, 140, 80));
	return boost::none;
}
Exemplo n.º 5
0
const char *image_filetype(mess_image *img)
{
	const char *s;
	s = image_filename(img);
	if (s)
		s = strrchr(s, '.');
	return s ? s+1 : NULL;
}
Exemplo n.º 6
0
static void command_verify_image(void)
{
	const UINT8 *verify_data;
	size_t verify_data_size;
	size_t offset, offset_start, offset_end;
	const char *filename;
	mess_image *image;
	FILE *f;
	UINT8 c;
	char filename_buf[512];

	verify_data = (const UINT8 *) current_command->u.verify_args.verify_data;
	verify_data_size = current_command->u.verify_args.verify_data_size;

	image = image_from_devtype_and_index(current_command->u.verify_args.device_type, current_command->u.verify_args.device_slot);
	filename = image_filename(image);
	if (!filename)
	{
		state = STATE_ABORTED;
		report_message(MSG_FAILURE, "Failed verification: Device Not Loaded");
		return;
	}

	/* very dirty hack - we unload the image because we cannot access it
	 * because the file is locked */
	strcpy(filename_buf, filename);
	image_unload(image);
	filename = filename_buf;

	f = fopen(filename, "r");
	if (!f)
	{
		state = STATE_ABORTED;
		report_message(MSG_FAILURE, "Failed verification: Cannot open image to verify");
		return;
	}

	offset_start = 0;
	offset_end = verify_data_size - 1;

	for (offset = offset_start; offset <= offset_end; offset++)
	{
		fseek(f, offset, SEEK_SET);
		c = (UINT8) fgetc(f);

		if (c != verify_data[offset])
		{
			state = STATE_ABORTED;
			report_message(MSG_FAILURE, "Failed verification step (%s; 0x%x-0x%x)",
				filename, offset_start, offset_end);
			break;
		}
	}
	fclose(f);
}
Exemplo n.º 7
0
Error GDMonoAssembly::load(MonoDomain *p_domain) {

	ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE);

	uint64_t last_modified_time = FileAccess::get_modified_time(path);

	Vector<uint8_t> data = FileAccess::get_file_as_array(path);
	ERR_FAIL_COND_V(data.empty(), ERR_FILE_CANT_READ);

	String image_filename(path);

	MonoImageOpenStatus status;

	image = mono_image_open_from_data_with_name(
			(char *)&data[0], data.size(),
			true, &status, false,
			image_filename.utf8().get_data());

	ERR_FAIL_COND_V(status != MONO_IMAGE_OK || image == NULL, ERR_FILE_CANT_OPEN);

#ifdef DEBUG_ENABLED
	String pdb_path(path + ".pdb");

	if (!FileAccess::exists(pdb_path)) {
		pdb_path = path.get_basename() + ".pdb"; // without .dll

		if (!FileAccess::exists(pdb_path))
			goto no_pdb;
	}

	pdb_data.clear();
	pdb_data = FileAccess::get_file_as_array(pdb_path);
	mono_debug_open_image_from_memory(image, &pdb_data[0], pdb_data.size());

no_pdb:

#endif

	assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, false);

	ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN);

	if (p_domain && mono_image_get_entry_point(image)) {
		// TODO should this be removed? do we want to call main? what other effects does this have?
		mono_jit_exec(p_domain, assembly, 0, NULL);
	}

	loaded = true;
	modified_time = last_modified_time;

	return OK;
}
Exemplo n.º 8
0
static int vc20_rom_id(mess_image *image)
{
	unsigned char magic[] =
	{0x41, 0x30, 0x20, 0xc3, 0xc2, 0xcd};	/* A0 CBM at 0xa004 (module offset 4) */
	unsigned char buffer[sizeof (magic)];
	const char *cp;
	int retval;

	logerror("vc20_rom_id %s\n", image_filename(image));

	retval = 0;

	image_fseek (image, 4, SEEK_SET);
	image_fread (image, buffer, sizeof (magic));

	if (!memcmp (buffer, magic, sizeof (magic)))
		retval = 1;

	cp = image_filetype(image);
	if (cp)
	{
		if ((mame_stricmp (cp, "a0") == 0)
			|| (mame_stricmp (cp, "20") == 0)
			|| (mame_stricmp (cp, "40") == 0)
			|| (mame_stricmp (cp, "60") == 0)
			|| (mame_stricmp (cp, "bin") == 0)
			|| (mame_stricmp (cp, "rom") == 0)
			|| (mame_stricmp (cp, "prg") == 0))
			retval = 1;
	}

		if (retval)
			logerror("rom %s recognized\n", image_filename(image));
		else
			logerror("rom %s not recognized\n", image_filename(image));

	return retval;
}
Exemplo n.º 9
0
void vc20_tape_status (char *text, int size)
{
	text[0] = 0;
	switch (tape.type)
	{
	case TAPE_WAV:
		switch (wav.state)
		{
		case 4:
			snprintf (text, size, "Tape saving");
			break;
		case 3:
			/* NPW 28-Feb-2005 - this code sucks */
#if 0
			snprintf (text, size, "Tape (%s) loading %d/%dsec",
					  image_filename(wav.img),
					  wav.pos / wav.sample->smpfreq,
					  wav.sample->length / wav.sample->smpfreq);
#endif
			break;
		}
		break;
	case TAPE_PRG:
		switch (prg.state)
		{
		case 4:
			snprintf (text, size, "Tape saving");
			break;
		case 3:
			snprintf (text, size, "Tape (%s) loading %d",
				image_filename(prg.img), prg.pos);
			break;
		}
		break;
	}
}
Exemplo n.º 10
0
int ui_sprintf_image_info(char *buf)
{
    char *dst = buf;
    const struct IODevice *dev;
    int id;

    dst += sprintf(dst, "%s\n\n", Machine->gamedrv->description);

    if (options.ram)
    {
        char buf2[RAM_STRING_BUFLEN];
        dst += sprintf(dst, "RAM: %s\n\n", ram_string(buf2, options.ram));
    }

    for (dev = Machine->devices; dev->type < IO_COUNT; dev++)
    {
        for (id = 0; id < dev->count; id++)
        {
            mess_image *img = image_from_device_and_index(dev, id);
            const char *name = image_filename(img);
            if( name )
            {
                const char *base_filename;
                const char *info;
                char *base_filename_noextension;

                base_filename = image_basename(img);
                base_filename_noextension = strip_extension((char *) base_filename);

                /* display device type and filename */
                dst += sprintf(dst,"%s: %s\n", image_typename_id(img), base_filename);

                /* display long filename, if present and doesn't correspond to name */
                info = image_longname(img);
                if (info && (!base_filename_noextension || mame_stricmp(info, base_filename_noextension)))
                    dst += sprintf(dst,"%s\n", info);

                /* display manufacturer, if available */
                info = image_manufacturer(img);
                if (info)
                {
                    dst += sprintf(dst,"%s", info);
                    info = stripspace(image_year(img));
                    if (info && *info)
                        dst += sprintf(dst,", %s", info);
                    dst += sprintf(dst,"\n");
                }

                /* display playable information, if available */
                info = image_playable(img);
                if (info)
                    dst += sprintf(dst,"%s\n", info);

                if (base_filename_noextension)
                    free(base_filename_noextension);
            }
            else
            {
                dst += sprintf(dst,"%s: ---\n", image_typename_id(img));
            }
        }
    }
    return dst - buf;
}
Exemplo n.º 11
0
static DEVICE_LOAD(cbm_rom)
{
	int i;
	int size, j, read_;
	const char *filetype;
	int adr = 0;
	const struct IODevice *dev;

	for (i=0; (i<sizeof(cbm_rom) / sizeof(cbm_rom[0])) && (cbm_rom[i].size!=0); i++)
		;
	if (i >= sizeof(cbm_rom) / sizeof(cbm_rom[0]))
		return INIT_FAIL;

	dev = cbm_rom_find_device();

	size = image_length(image);

	filetype = image_filetype(image);
	if (filetype && !mame_stricmp(filetype, "prg"))
	{
		unsigned short in;

		image_fread (image, &in, 2);
		in = LITTLE_ENDIANIZE_INT16(in);
		logerror("rom prg %.4x\n", in);
		size -= 2;

		logerror("loading rom %s at %.4x size:%.4x\n", image_filename(image), in, size);

		cbm_rom[i].chip = (UINT8 *) image_malloc(image, size);
		if (!cbm_rom[i].chip)
			return INIT_FAIL;

		cbm_rom[i].addr=in;
		cbm_rom[i].size=size;
		read_ = image_fread (image, cbm_rom[i].chip, size);
		if (read_ != size)
			return INIT_FAIL;
	}
	else if (filetype && !mame_stricmp (filetype, "crt"))
	{
		unsigned short in;
		image_fseek(image, 0x18, SEEK_SET);
		image_fread(image, &cbm_c64_exrom, 1);
		image_fread(image, &cbm_c64_game, 1);
		image_fseek(image, 64, SEEK_SET);
		j = 64;

		logerror("loading rom %s size:%.4x\n", image_filename(image), size);

		while (j < size)
		{
			unsigned short segsize;
			unsigned char buffer[10], number;

			image_fread(image, buffer, 6);
			image_fread(image, &segsize, 2);
			segsize = BIG_ENDIANIZE_INT16(segsize);
			image_fread(image, buffer + 6, 3);
			image_fread(image, &number, 1);
			image_fread(image, &adr, 2);
			adr = BIG_ENDIANIZE_INT16(adr);
			image_fread(image, &in, 2);
			in = BIG_ENDIANIZE_INT16(in);
			logerror("%.4s %.2x %.2x %.4x %.2x %.2x %.2x %.2x %.4x:%.4x\n",
				buffer, buffer[4], buffer[5], segsize,
				buffer[6], buffer[7], buffer[8], number,
				adr, in);
			logerror("loading chip at %.4x size:%.4x\n", adr, in);

			cbm_rom[i].chip = (UINT8*) image_malloc(image, size);
			if (!cbm_rom[i].chip)
				return INIT_FAIL;

			cbm_rom[i].addr=adr;
			cbm_rom[i].size=in;
			read_ = image_fread(image, cbm_rom[i].chip, in);
			i++;
			if (read_ != in)
				return INIT_FAIL;

			j += 16 + in;
		}
	}
	else if (filetype)
	{
		if (mame_stricmp(filetype, "lo") == 0)
			adr = CBM_ROM_ADDR_LO;
		else if (mame_stricmp (filetype, "hi") == 0)
			adr = CBM_ROM_ADDR_HI;
		else if (mame_stricmp (filetype, "10") == 0)
			adr = 0x1000;
		else if (mame_stricmp (filetype, "20") == 0)
			adr = 0x2000;
		else if (mame_stricmp (filetype, "30") == 0)
			adr = 0x3000;
		else if (mame_stricmp (filetype, "40") == 0)
			adr = 0x4000;
		else if (mame_stricmp (filetype, "50") == 0)
			adr = 0x5000;
		else if (mame_stricmp (filetype, "60") == 0)
			adr = 0x6000;
		else if (mame_stricmp (filetype, "70") == 0)
			adr = 0x7000;
		else if (mame_stricmp (filetype, "80") == 0)
			adr = 0x8000;
		else if (mame_stricmp (filetype, "90") == 0)
			adr = 0x9000;
		else if (mame_stricmp (filetype, "a0") == 0)
			adr = 0xa000;
		else if (mame_stricmp (filetype, "b0") == 0)
			adr = 0xb000;
		else if (mame_stricmp (filetype, "e0") == 0)
			adr = 0xe000;
		else if (mame_stricmp (filetype, "f0") == 0)
			adr = 0xf000;
		else
			adr = CBM_ROM_ADDR_UNKNOWN;

		logerror("loading %s rom at %.4x size:%.4x\n",
				image_filename(image), adr, size);

		cbm_rom[i].chip = (UINT8*) image_malloc(image, size);
		if (!cbm_rom[i].chip)
			return INIT_FAIL;

		cbm_rom[i].addr=adr;
		cbm_rom[i].size=size;
		read_ = image_fread(image, cbm_rom[i].chip, size);

		if (read_ != size)
			return INIT_FAIL;
	}
	return INIT_PASS;
}
Exemplo n.º 12
0
const char *image_basename(mess_image *img)
{
	return osd_basename((char *) image_filename(img));
}
Exemplo n.º 13
0
int image_exists(mess_image *img)
{
	return image_filename(img) != NULL;
}
Exemplo n.º 14
0
static char *battery_nvramfilename(mess_image *img)
{
	const char *filename;
	filename = image_filename(img);
	return strip_extension(osd_basename((char *) filename));
}