Ejemplo n.º 1
0
void favorite_manager::apply_running_machine(running_machine &machine, T &&action)
{
	bool done(false);

	// TODO: this should be changed - it interacts poorly with cartslots on arcade systems
	if ((machine.system().flags & machine_flags::MASK_TYPE) == machine_flags::TYPE_ARCADE)
	{
		action(machine.system(), nullptr, nullptr, done);
	}
	else
	{
		bool have_software(false);
		for (device_image_interface &image_dev : image_interface_iterator(machine.root_device()))
		{
			software_info const *const sw(image_dev.software_entry());
			if (image_dev.exists() && image_dev.loaded_through_softlist() && sw)
			{
				assert(image_dev.software_list_name());

				have_software = true;
				action(machine.system(), &image_dev, sw, done);
				if (done)
					return;
			}
		}

		if (!have_software)
			action(machine.system(), nullptr, nullptr, done);
	}
}
Ejemplo n.º 2
0
void mini_osd_interface::init(running_machine &machine)
{
	int gamRot=0;

	osd_interface::init(machine);
	our_target = machine.render().target_alloc();

	initInput(machine);

	write_log("machine screen orientation: %s \n", (
		machine.system().flags & ORIENTATION_SWAP_XY) ? "VERTICAL" : "HORIZONTAL"
	);

        orient  = (machine.system().flags & ORIENTATION_MASK);
	vertical = (machine.system().flags & ORIENTATION_SWAP_XY);
        
        gamRot = (ROT270 == orient) ? 1 : gamRot;
        gamRot = (ROT180 == orient) ? 2 : gamRot;
        gamRot = (ROT90  == orient) ? 3 : gamRot;
        
	//prep_retro_rotation(gamRot);
	our_target->compute_minimum_size(rtwi, rthe);
	topw=rtwi;
	//Equivalent to rtaspect=our_target->view_by_index((our_target->view()))->effective_aspect(render_layer_config layer_config())
	int width,height;
	our_target->compute_visible_area(1000,1000,1,ROT0,width,height);
	rtaspect=(float)width/(float)height;
	write_log("W:%d H:%d , aspect ratio %d/%d=%f\n",rtwi,rthe,width,height,rtaspect);
	NEWGAME_FROM_OSD=1;
	write_log("osd init done\n");
	co_switch(mainThread);
}
Ejemplo n.º 3
0
void ui_menu_image_info::image_info_astring(running_machine &machine, astring &string)
{
	string.printf("%s\n\n", machine.system().description);

#if 0
	if (mess_ram_size > 0)
	{
		char buf2[RAM_STRING_BUFLEN];
		string.catprintf("RAM: %s\n\n", ram_string(buf2, mess_ram_size));
	}
#endif

	image_interface_iterator iter(machine.root_device());
	for (device_image_interface *image = iter.first(); image != NULL; image = iter.next())
	{
		const char *name = image->filename();
		if (name != NULL)
		{
			const char *base_filename;
			const char *info;
			char *base_filename_noextension;

			base_filename = image->basename();
			base_filename_noextension = strip_extension(base_filename);

			// display device type and filename
			string.catprintf("%s: %s\n", image->device().name(), base_filename);

			// display long filename, if present and doesn't correspond to name
			info = image->longname();
			if (info && (!base_filename_noextension || core_stricmp(info, base_filename_noextension)))
				string.catprintf("%s\n", info);

			// display manufacturer, if available
			info = image->manufacturer();
			if (info != NULL)
			{
				string.catprintf("%s", info);
				info = stripspace(image->year());
				if (info && *info)
					string.catprintf(", %s", info);
				string.catprintf("\n");
			}

			// display supported information, if available
			switch(image->supported()) {
				case SOFTWARE_SUPPORTED_NO : string.catprintf("Not supported\n"); break;
				case SOFTWARE_SUPPORTED_PARTIAL : string.catprintf("Partially supported\n"); break;
				default : break;
			}

			if (base_filename_noextension != NULL)
				free(base_filename_noextension);
		}
		else
		{
			string.catprintf("%s: ---\n", image->device().name());
		}
	}
}
Ejemplo n.º 4
0
void ui_gfx_init(running_machine &machine)
{
	ui_gfx_state *state = &ui_gfx;
	uint8_t rotate = machine.system().flags & machine_flags::MASK_ORIENTATION;

	// make sure we clean up after ourselves
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&ui_gfx_exit, &machine));

	// initialize our global state
	memset(state, 0, sizeof(*state));

	// set up the palette state
	state->palette.columns = 16;

	// set up the graphics state
	for (uint8_t i = 0; i < MAX_GFX_DECODERS; i++)
		for (uint8_t j = 0; j < MAX_GFX_ELEMENTS; j++)
		{
			state->gfxdev[i].rotate[j] = rotate;
			state->gfxdev[i].columns[j] = 16;
		}

	// set up the tilemap state
	state->tilemap.rotate = rotate;
	state->tilemap.flags = TILEMAP_DRAW_ALL_CATEGORIES;
}
Ejemplo n.º 5
0
void ui_gfx_init(running_machine &machine)
{
	ui_gfx_state *state = &ui_gfx;
	UINT8 rotate = machine.system().flags & ORIENTATION_MASK;

	// make sure we clean up after ourselves
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_gfx_exit), &machine));

	// initialize our global state
	memset(state, 0, sizeof(*state));

	// set up the palette state
	state->palette.columns = 16;

	// set up the graphics state
	for (UINT8 i = 0; i < MAX_GFX_DECODERS; i++)
		for (UINT8 j = 0; j < MAX_GFX_ELEMENTS; j++)
		{
			state->gfxdev[i].rotate[j] = rotate;
			state->gfxdev[i].columns[j] = 16;
		}

	// set up the tilemap state
	state->tilemap.rotate = rotate;
}
Ejemplo n.º 6
0
void a600xl_mmu(running_machine &machine, UINT8 new_mmu)
{
	/* check if self-test ROM changed */
	if ( new_mmu & 0x80 )
	{
		logerror("%s MMU SELFTEST RAM\n", machine.system().name);
		machine.device("maincpu")->memory().space(AS_PROGRAM).nop_readwrite(0x5000, 0x57ff);
	}
	else
	{
		logerror("%s MMU SELFTEST ROM\n", machine.system().name);
		machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(0x5000, 0x57ff, "bank2");
		machine.device("maincpu")->memory().space(AS_PROGRAM).unmap_write(0x5000, 0x57ff);
		machine.root_device().membank("bank2")->set_base(machine.root_device().memregion("maincpu")->base() + 0x5000);
	}
}
Ejemplo n.º 7
0
/* safe_to_load checks the start and end values of each memory range */
static int safe_to_load (running_machine &machine)
{
	memory_range *mem_range = state.mem_range;
	address_space *srcspace;
	if (strstr(machine.system().source_file,"cinemat.c") > 0)
	{
		srcspace = machine.cpu[mem_range->cpu]->memory().space(AS_DATA);
	}
	else
	{
		srcspace = machine.cpu[mem_range->cpu]->memory().space(AS_PROGRAM);
	}
	while (mem_range)
	{
		if (srcspace->read_byte(mem_range->addr) != mem_range->start_value)
		{
			return 0;
		}
		if (srcspace->read_byte(mem_range->addr + mem_range->num_bytes - 1) != mem_range->end_value)
		{
			return 0;
		}
		mem_range = mem_range->next;
	}
	return 1;
}
Ejemplo n.º 8
0
static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id)
{
	copydata_id_string *temp;
	COPYDATASTRUCT copydata;
	const char *name;
	int datalen;

	// id 0 is the name of the game
	if (id == 0)
		name = machine.system().name;
	else
		name = output_id_to_name(id);

	// a NULL name is an empty string
	if (name == NULL)
		name = "";

	// allocate memory for the message
	datalen = sizeof(*temp) + strlen(name);
	temp = (copydata_id_string *)global_alloc_array(UINT8, datalen);
	temp->id = id;
	strcpy(temp->string, name);

	// reply by using SendMessage with WM_COPYDATA
	copydata.dwData = COPYDATA_MESSAGE_ID_STRING;
	copydata.cbData = datalen;
	copydata.lpData = temp;
	SendMessage(hwnd, WM_COPYDATA, (WPARAM)output_hwnd, (LPARAM)&copydata);

	// free the data
	global_free(temp);
	return 0;
}
Ejemplo n.º 9
0
static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id)
{
	COPYDATASTRUCT copydata;
	const char *name;
	int datalen;

	// id 0 is the name of the game
	if (id == 0)
		name = machine.system().name;
	else
		name = machine.output().id_to_name(id);

	// a NULL name is an empty string
	if (name == nullptr)
		name = "";

	// allocate memory for the message
	datalen = sizeof(copydata_id_string) + strlen(name) + 1;
	dynamic_buffer buffer(datalen);
	copydata_id_string *temp = (copydata_id_string *)&buffer[0];
	temp->id = id;
	strcpy(temp->string, name);

	// reply by using SendMessage with WM_COPYDATA
	copydata.dwData = COPYDATA_MESSAGE_ID_STRING;
	copydata.cbData = datalen;
	copydata.lpData = temp;
	SendMessage(hwnd, WM_COPYDATA, (WPARAM)output_hwnd, (LPARAM)&copydata);

	return 0;
}
Ejemplo n.º 10
0
void gottlieb_knocker(running_machine &machine)
{
	device_t *samples = space->machine().device("samples");
	if (!strcmp(machine.system().name,"reactor"))	/* reactor */
	{
	}
	else if (samples != NULL)	/* qbert */
		sample_start(samples, 0,44,0);
}
Ejemplo n.º 11
0
static void sdloutput_exit(running_machine &machine)
{
    if (output != NULL)
    {
        fprintf(output, "MAME " PID_FMT " STOP %s\n", osd_getpid(), machine.system().name);
        fflush(output);
        fclose(output);
        output = NULL;
        mame_printf_verbose("ouput: closed output notifier file\n");
    }
}
Ejemplo n.º 12
0
static void create_bitmap(running_machine &machine, int player)
{
	int x, y;
	char filename[20];
	rgb_t color = crosshair_colors[player];

	/* if we have a bitmap and texture for this player, kill it */
	if (global.bitmap[player] == NULL)
		global.bitmap[player] = global_alloc(bitmap_argb32);
	machine.render().texture_free(global.texture[player]);

	emu_file crossfile(machine.options().crosshair_path(), OPEN_FLAG_READ);
	if (global.name[player][0] != 0)
	{
		/* look for user specified file */
		sprintf(filename, "%s.png", global.name[player]);
		render_load_png(*global.bitmap[player], crossfile, NULL, filename);
	}
	else
	{
		/* look for default cross?.png in crsshair\game dir */
		sprintf(filename, "cross%d.png", player + 1);
		render_load_png(*global.bitmap[player], crossfile, machine.system().name, filename);

		/* look for default cross?.png in crsshair dir */
		if (!global.bitmap[player]->valid())
			render_load_png(*global.bitmap[player], crossfile, NULL, filename);
	}

	/* if that didn't work, use the built-in one */
	if (!global.bitmap[player]->valid())
	{
		/* allocate a blank bitmap to start with */
		global.bitmap[player]->allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
		global.bitmap[player]->fill(MAKE_ARGB(0x00,0xff,0xff,0xff));

		/* extract the raw source data to it */
		for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
		{
			/* assume it is mirrored vertically */
			UINT32 *dest0 = &global.bitmap[player]->pix32(y);
			UINT32 *dest1 = &global.bitmap[player]->pix32(CROSSHAIR_RAW_SIZE - 1 - y);

			/* extract to two rows simultaneously */
			for (x = 0; x < CROSSHAIR_RAW_SIZE; x++)
				if ((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80)
					dest0[x] = dest1[x] = MAKE_ARGB(0xff,0x00,0x00,0x00) | color;
		}
	}

	/* create a texture to reference the bitmap */
	global.texture[player] = machine.render().texture_alloc(render_texture::hq_scale);
	global.texture[player]->set_bitmap(*global.bitmap[player], global.bitmap[player]->cliprect(), TEXFORMAT_ARGB32);
}
Ejemplo n.º 13
0
Archivo: sgi.c Proyecto: poliva/mame-rr
void sgi_mc_init(running_machine &machine)
{
	pMC = auto_alloc_clear(machine, MC_t);

	// if Indigo2, ID appropriately
	if (!strcmp(machine.system().name, "ip244415"))
	{
		pMC->nSysID = 0x11;	// rev. B MC, EISA bus present
	}

	sgi_mc_timer_init(machine);
}
Ejemplo n.º 14
0
void dump_decrypted(running_machine& machine, UINT8* decrypt)
{
	FILE *fp;
	char filename[256];
	sprintf(filename,"dat_%s", machine.system().name);
	fp=fopen(filename, "w+b");
	if (fp)
	{
		fwrite(decrypt, 0x10000, 1, fp);
		fclose(fp);
	}
}
Ejemplo n.º 15
0
static void copy_from_memory (running_machine &machine, int cpu, int addr, UINT8 *dest, int num_bytes)
{
	address_space *targetspace;

	if (strstr(machine.system().source_file,"cinemat.c") > 0)
		targetspace = &machine.cpu[cpu]->memory().space(AS_DATA);
	else
		targetspace = &machine.cpu[cpu]->memory().space(AS_PROGRAM);

	for (int i = 0; i < num_bytes; i++)
	{
		dest[i] = targetspace->read_byte(addr+i);
	}
}
Ejemplo n.º 16
0
Archivo: sgi.c Proyecto: cdenix/psmame
void sgi_mc_init(running_machine &machine)
{
	nMC_CPUControl0 = 0;
	nMC_CPUControl1 = 0;
	nMC_Watchdog = 0;
	nMC_SysID = 0;
	nMC_RPSSDiv = 0;
	nMC_RefCntPreload = 0;
	nMC_RefCnt = 0;
	nMC_GIO64ArbParam = 0;
	nMC_ArbCPUTime = 0;
	nMC_ArbBurstTime = 0;
	nMC_MemCfg0 = 0;
	nMC_MemCfg1 = 0;
	nMC_CPUMemAccCfg = 0;
	nMC_GIOMemAccCfg = 0;
	nMC_CPUErrorAddr = 0;
	nMC_CPUErrorStatus = 0;
	nMC_GIOErrorAddr = 0;
	nMC_GIOErrorStatus = 0;
	nMC_SysSemaphore = 0;
	nMC_GIOLock = 0;
	nMC_EISALock = 0;
	nMC_GIO64TransMask = 0;
	nMC_GIO64Subst = 0;
	nMC_DMAIntrCause = 0;
	nMC_DMAControl = 0;
	nMC_DMATLBEntry0Hi = 0;
	nMC_DMATLBEntry0Lo = 0;
	nMC_DMATLBEntry1Hi = 0;
	nMC_DMATLBEntry1Lo = 0;
	nMC_DMATLBEntry2Hi = 0;
	nMC_DMATLBEntry2Lo = 0;
	nMC_DMATLBEntry3Hi = 0;
	nMC_DMATLBEntry3Lo = 0;
	nMC_RPSSCounter = 0;
	nMC_DMAMemAddr = 0;
	nMC_DMAMemAddr = 0;
	nMC_DMALineCntWidth = 0;
	nMC_DMALineZoomStride = 0;
	nMC_DMAGIO64Addr = 0;
	nMC_DMAMode = 0;
	nMC_DMAZoomByteCnt = 0;

	// if Indigo2, ID appropriately
	if (!strcmp(machine.system().name, "ip244415"))
	{
		nMC_SysID = 0x11;	// rev. B MC, EISA bus present
	}
}
Ejemplo n.º 17
0
void ui_gfx_init(running_machine &machine)
{
	ui_gfx_state *state = &ui_gfx;
	int gfx;

	/* make sure we clean up after ourselves */
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(ui_gfx_exit), &machine));

	/* initialize our global state */
	memset(state, 0, sizeof(*state));

	/* set up the palette state */
	state->palette.count = 16;

	/* set up the graphics state */
	for (gfx = 0; gfx < MAX_GFX_ELEMENTS; gfx++)
	{
		state->gfxset.rotate[gfx] = machine.system().flags & ORIENTATION_MASK;
		state->gfxset.count[gfx] = 16;
	}

	/* set up the tilemap state */
	state->tilemap.rotate = machine.system().flags & ORIENTATION_MASK;
}
Ejemplo n.º 18
0
void mini_osd_interface::init(running_machine &machine)
{
	int gamRot=0;

	osd_interface::init(machine);
	our_target = machine.render().target_alloc();

	initInput(machine);

	write_log("machine screen orientation: %s \n", (
		machine.system().flags & ORIENTATION_SWAP_XY) ? "VERTICAL" : "HORIZONTAL"
	);

        orient  = (machine.system().flags & ORIENTATION_MASK);
	vertical = (machine.system().flags & ORIENTATION_SWAP_XY);
        
        gamRot = (ROT270 == orient) ? 1 : gamRot;
        gamRot = (ROT180 == orient) ? 2 : gamRot;
        gamRot = (ROT90  == orient) ? 3 : gamRot;
        
	prep_retro_rotation(gamRot);

	write_log("osd init done\n");
}
Ejemplo n.º 19
0
static void write_board( running_machine &machine, UINT8 data)
{

	Line18_REED=data;

	if (read_board_flag && !strcmp(machine.system().name,"glasgow") ) //HACK
		Line18_LED = 0;
	else
		Line18_LED = data;

	 read_board_flag = FALSE;

	if (data == 0xff)
		mboard_key_selector = 0;
}
Ejemplo n.º 20
0
ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, ui_software_info *swinfo, const game_driver *driver) : ui_menu(machine, container)
{
	m_list = swinfo->listname;
	m_short = swinfo->shortname;
	m_long = swinfo->longname;
	m_parent = swinfo->parentname;
	m_driver = (driver == nullptr) ? &machine.system() : driver;
	m_swinfo = swinfo;

	issoft = true;

	if (machine.datfile().has_software(m_list, m_short, m_parent))
		m_items_list.emplace_back(_("Software History"), UI_HISTORY_LOAD, machine.datfile().rev_history());
	if (swinfo && !swinfo->usage.empty())
		m_items_list.emplace_back(_("Software Usage"), 0, "");
}
Ejemplo n.º 21
0
void init_eolith_speedup(running_machine &machine)
{
	int n_game = 0;
	eolith_speedup_address = 0;
	eolith_speedup_resume_scanline = 0;

	while( eolith_speedup_table[ n_game ].s_name != NULL )
	{
		if( strcmp( machine.system().name, eolith_speedup_table[ n_game ].s_name ) == 0 )
		{
			eolith_speedup_address = eolith_speedup_table[ n_game ].speedup_address;
			eolith_speedup_address2 = eolith_speedup_table[ n_game ].speedup_address2;
			eolith_speedup_resume_scanline = eolith_speedup_table[ n_game ].speedup_resume_scanline;
		}
		n_game++;
	}
}
Ejemplo n.º 22
0
ui_menu_dats_view::ui_menu_dats_view(running_machine &machine, render_container *container, const game_driver *driver) : ui_menu(machine, container)
{
	image_interface_iterator iter(machine.root_device());
	for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
	{
		if (image->filename())
		{
			m_list = strensure(image->software_list_name());
			m_short = strensure(image->software_entry()->shortname());
			m_long = strensure(image->software_entry()->longname());
			m_parent = strensure(image->software_entry()->parentname());
		}
	}
	m_driver = (driver == nullptr) ? &machine.system() : driver;

	init_items();
}
Ejemplo n.º 23
0
static void copy_to_memory (running_machine &machine, int cpu, int addr, const UINT8 *source, int num_bytes)
{
	int i;
	address_space *targetspace;
	if (strstr(machine.system().source_file,"cinemat.c") > 0)
	{
		 targetspace = machine.cpu[cpu]->memory().space(AS_DATA);
	}
	else
	{
		 targetspace = machine.cpu[cpu]->memory().space(AS_PROGRAM);
	}

	for (i=0; i<num_bytes; i++)
	{
    targetspace->write_byte(addr+i, source[i]);
	}
}
Ejemplo n.º 24
0
void debug_console_init(running_machine &machine)
{
	/* allocate text buffers */
	console_textbuf = text_buffer_alloc(CONSOLE_BUF_SIZE, CONSOLE_MAX_LINES);
	if (!console_textbuf)
		return;

	errorlog_textbuf = text_buffer_alloc(ERRORLOG_BUF_SIZE, ERRORLOG_MAX_LINES);
	if (!errorlog_textbuf)
		return;

	/* print the opening lines */
	debug_console_printf(machine, "%s debugger version %s\n", emulator_info::get_appname(), build_version);
	debug_console_printf(machine, "Currently targeting %s (%s)\n", machine.system().name, machine.system().description);

	/* request callback upon exiting */
	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_console_exit), &machine));
}
Ejemplo n.º 25
0
void sdloutput_init(running_machine &machine)
{
    int fildes;

    machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(sdloutput_exit), &machine));

    fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK);

    if (fildes < 0)
    {
        output = NULL;
        mame_printf_verbose("ouput: unable to open output notifier file %s\n", SDLMAME_OUTPUT);
    }
    else
    {
        output = fdopen(fildes, "w");

        mame_printf_verbose("ouput: opened output notifier file %s\n", SDLMAME_OUTPUT);
        fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine.system().name);
        fflush(output);
    }

    output_set_notifier(NULL, notifier_callback, NULL);
}
Ejemplo n.º 26
0
static void image_options_extract(running_machine &machine)
{
	/* only extract the device options if we've added them
       no need to assert in case they are missing */
	{
		int index = 0;
		device_image_interface *image = NULL;

		for (bool gotone = machine.devicelist().first(image); gotone; gotone = image->next(image))
		{
			const char *filename = image->filename();

			/* and set the option */
			astring error;
			machine.options().set_value(image->instance_name(), filename ? filename : "", OPTION_PRIORITY_CMDLINE, error);

			index++;
		}
	}

	/* write the config, if appropriate */
	if (machine.options().write_config())
		write_config(machine.options(), NULL, &machine.system());
}
Ejemplo n.º 27
0
ROM_END



/*************************************
 *
 *  Low byte ROM decoding
 *
 *************************************/

INLINE void generic_decode(running_machine &machine, const char *tag, int bit7, int bit6, int bit5, int bit4, int bit3, int bit2, int bit1, int bit0)
{
    UINT16 *rom = (UINT16 *)machine.region(tag)->base();
    int i;

    /* only the low byte of ROMs are encrypted in these games */
    for (i = 0; i < 0x20000/2; i++)
        rom[i] = BITSWAP16(rom[i], 15,14,13,12,11,10,9,8, bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0);

#if 0
    {
        UINT8 *ROM = machine.region(tag)->base();
        int size = machine.region(tag)->bytes();

        FILE *fp;
        char filename[256];
        sprintf(filename,"decrypted_%s", machine.system().name);
        fp=fopen(filename, "w+b");
        if (fp)
        {
            fwrite(ROM, size, 1, fp);
            fclose(fp);
        }
    }
#endif
}
Ejemplo n.º 28
0
/* call hiscore_open once after loading a game */
void hiscore_init (running_machine &machine)
{
	memory_range *mem_range = state.mem_range;
	file_error filerr;
	const char *db_filename = machine.options().value(OPTION_HISCORE_FILE); /* high score definition file */
    const char *name = machine.system().name;
	state.hiscores_have_been_loaded = 0;

	while (mem_range)
	{

		if (strstr(machine.system().source_file,"cinemat.c") > 0)
		{
			machine.cpu[mem_range->cpu]->memory().space(AS_DATA)->write_byte(mem_range->addr, ~mem_range->start_value);
			machine.cpu[mem_range->cpu]->memory().space(AS_DATA)->write_byte(mem_range->addr + mem_range->num_bytes-1, ~mem_range->end_value);
			mem_range = mem_range->next;
		}
		else
		{
			machine.cpu[mem_range->cpu]->memory().space(AS_PROGRAM)->write_byte(mem_range->addr, ~mem_range->start_value);
			machine.cpu[mem_range->cpu]->memory().space(AS_PROGRAM)->write_byte(mem_range->addr + mem_range->num_bytes-1,~mem_range->end_value);
			mem_range = mem_range->next;
		}
	}

	state.mem_range = NULL;
	emu_file f = emu_file(OPEN_FLAG_READ);
	filerr = f.open(db_filename);
	if (filerr == FILERR_NONE)
	{
		char buffer[MAX_CONFIG_LINE_SIZE];
		enum { FIND_NAME, FIND_DATA, FETCH_DATA } mode;
		mode = FIND_NAME;

		while (f.gets (buffer, MAX_CONFIG_LINE_SIZE))
		{
			if (mode==FIND_NAME)
			{
				if (matching_game_name (buffer, name))
				{
					mode = FIND_DATA;
					LOG(("hs config found!\n"));
				}
			}
			else if (is_mem_range (buffer))
			{
				const char *pBuf = buffer;
				mem_range = global_alloc_array(memory_range, sizeof(memory_range));
				if (mem_range)
				{
					mem_range->cpu = hexstr2num (&pBuf);
					mem_range->addr = hexstr2num (&pBuf);
					mem_range->num_bytes = hexstr2num (&pBuf);
					mem_range->start_value = hexstr2num (&pBuf);
					mem_range->end_value = hexstr2num (&pBuf);

					mem_range->next = NULL;
					{
						memory_range *last = state.mem_range;
						while (last && last->next) last = last->next;
						if (last == NULL)
						{
							state.mem_range = mem_range;
						}
						else
						{
							last->next = mem_range;
						}
					}

					mode = FETCH_DATA;
				}
				else
				{
					hiscore_free();
					break;
				}
			}
			else
			{
				/* line is a game name */
				if (mode == FETCH_DATA) break;
			}
		}
		f.close ();
	}

	timer = machine.scheduler().timer_alloc(FUNC(hiscore_periodic), NULL);
	timer->adjust(machine.primary_screen->frame_period(), 0, machine.primary_screen->frame_period());

	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(hiscore_close), &machine));
}
Ejemplo n.º 29
0
/* call hiscore_open once after loading a game */
void hiscore_init (running_machine &machine)
{
	memory_range *mem_range = state.mem_range;
	address_space *initspace;
	file_error filerr;
  	const char *name = machine.system().name;
	state.hiscores_have_been_loaded = 0;

	while (mem_range)
	{
		if (strstr(machine.system().source_file,"cinemat.c") > 0)
		{
			initspace = &machine.cpu[mem_range->cpu]->memory().space(AS_DATA);
			initspace->write_byte(mem_range->addr, ~mem_range->start_value);
			initspace->write_byte(mem_range->addr + mem_range->num_bytes-1, ~mem_range->end_value);
			mem_range = mem_range->next;
		}
		else
		{
			initspace = &machine.cpu[mem_range->cpu]->memory().space(AS_PROGRAM);
			initspace->write_byte(mem_range->addr, ~mem_range->start_value);
		  	initspace->write_byte(mem_range->addr + mem_range->num_bytes-1, ~mem_range->end_value);
			mem_range = mem_range->next;
		}
	}

	state.mem_range = nullptr;
	emu_file f(machine.options().high_path(), OPEN_FLAG_READ);
  	filerr = f.open("hiscore.dat");

	if (filerr == FILERR_NONE)
	{
		char buffer[MAX_CONFIG_LINE_SIZE];
		enum { FIND_NAME, FIND_DATA, FETCH_DATA } mode;
		mode = FIND_NAME;

		while (f.gets(buffer, MAX_CONFIG_LINE_SIZE))
		{
			if (mode == FIND_NAME)
			{
				if (matching_game_name (buffer, name))
					mode = FIND_DATA;
			}
			else if (is_mem_range (buffer))
			{
				const char *pBuf = buffer;
				mem_range = (memory_range *)malloc(sizeof(memory_range));

				if (mem_range)
				{
					mem_range->cpu = hexstr2num (&pBuf);
					mem_range->addr = hexstr2num (&pBuf);
					mem_range->num_bytes = hexstr2num (&pBuf);
					mem_range->start_value = hexstr2num (&pBuf);
					mem_range->end_value = hexstr2num (&pBuf);

					mem_range->next = nullptr;
					{
						memory_range *last = state.mem_range;
						while (last && last->next) last = last->next;

						if (last == nullptr)
							state.mem_range = mem_range;
						else
							last->next = mem_range;
					}

					mode = FETCH_DATA;
				}
				else
				{
					hiscore_free();
					break;
				}
			}
			else
			{
				/* line is a game name */
				if (mode == FETCH_DATA) 
					break;
			}
		}
		
		f.close();
	}
	
	timer = machine.scheduler().timer_alloc(FUNC(hiscore_periodic));
	timer->adjust(machine.first_screen()->frame_period(), 0, machine.first_screen()->frame_period());

	machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(hiscore_close), &machine));
}
Ejemplo n.º 30
0
Archivo: window.c Proyecto: clobber/UME
int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config)
{
	sdl_window_info *window;
	worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param));
	int result;

	ASSERT_MAIN_THREAD();

	clear_worker_param(wp);

	// allocate a new window object
	window = global_alloc_clear(sdl_window_info);
	window->maxwidth = config->width;
	window->maxheight = config->height;
	window->depth = config->depth;
	window->refresh = config->refresh;
	window->monitor = monitor;
	window->m_machine = &machine;
	window->index = index;

	//FIXME: these should be per_window in config-> or even better a bit set
	window->fullscreen = !video_config.windowed;
	window->prescale = video_config.prescale;

	// set the initial maximized state
	// FIXME: Does not belong here
	sdl_options &options = downcast<sdl_options &>(machine.options());
	window->startmaximized = options.maximize();

	if (!window->fullscreen)
	{
		window->windowed_width = config->width;
		window->windowed_height = config->height;
	}
	window->totalColors = config->totalColors;

	// add us to the list
	*last_window_ptr = window;
	last_window_ptr = &window->next;

	draw.attach(&draw, window);

	// create an event that we can use to skip blitting
	window->rendered_event = osd_event_alloc(FALSE, TRUE);

	// load the layout
	window->target = machine.render().target_alloc();

	// set the specific view
	set_starting_view(machine, index, window, options.view(), options.view(index));

	// make the window title
	if (video_config.numscreens == 1)
		sprintf(window->title, "%s: %s [%s]", emulator_info::get_appname(), machine.system().description, machine.system().name);
	else
		sprintf(window->title, "%s: %s [%s] - Screen %d", emulator_info::get_appname(), machine.system().description, machine.system().name, index);

	wp->window = window;

	if (multithreading_enabled)
	{
		osd_work_item *wi;

		wi = osd_work_item_queue(work_queue, &complete_create_wt, (void *) wp, 0);
		sdlwindow_sync();
		result = *((int *) (osd_work_item_result)(wi));
		osd_work_item_release(wi);
	}
	else
		result = *((int *) complete_create_wt((void *) wp, 0));

	// handle error conditions
	if (result == 1)
		goto error;

	return 0;

error:
	sdlwindow_video_window_destroy(machine, window);
	return 1;
}