Example #1
0
static void print_game_switch(FILE* out, const game_driver* game)
{
	const input_port_entry* input;

	begin_resource_tracking();

	input = input_port_allocate(game->construct_ipt, NULL);

	while (input->type != IPT_END)
	{
		if (input->type==IPT_DIPSWITCH_NAME)
		{
			int def = input->default_value;

			fprintf(out, "\t\t<dipswitch");

			fprintf(out, " name=\"%s\"", normalize_string(input->name));
			++input;

			fprintf(out, ">\n");

			while (input->type==IPT_DIPSWITCH_SETTING)
			{
				fprintf(out, "\t\t\t<dipvalue");
				fprintf(out, " name=\"%s\"", normalize_string(input->name));
				if (def == input->default_value)
					fprintf(out, " default=\"yes\"");

				fprintf(out, "/>\n");

				++input;
			}

			fprintf(out, "\t\t</dipswitch>\n");
		}
		else
			++input;
	}

	end_resource_tracking();
}
Example #2
0
/***************************************************************************

  Initialize the emulated machine (load the roms, initialize the various
  subsystems...). Returns 0 if successful.

***************************************************************************/
int init_machine(void)
{
	int i;

	/* LBO 042400 start */
	if (uistring_init (options.language_file) != 0)
		goto out;
	/* LBO 042400 end */

	if (code_init() != 0)
		goto out;

	for (i = 0;i < MAX_MEMORY_REGIONS;i++)
	{
		Machine->memory_region[i] = 0;
		Machine->memory_region_length[i] = 0;
		Machine->memory_region_type[i] = 0;
	}

	if (gamedrv->input_ports)
	{
		Machine->input_ports = input_port_allocate(gamedrv->input_ports);
		if (!Machine->input_ports)
			goto out_code;
		Machine->input_ports_default = input_port_allocate(gamedrv->input_ports);
		if (!Machine->input_ports_default)
		{
			input_port_free(Machine->input_ports);
			Machine->input_ports = 0;
			goto out_code;
		}
	}

    #ifdef MESS
	if (!gamedrv->rom)
	{
		logerror("Going to load_next tag\n");
		goto load_next;
	}
    #endif

	if (readroms() != 0)
		goto out_free;

	#ifdef MESS
	load_next:
		if (init_devices(gamedrv))
			goto out_free;
	#endif

	/* Mish:  Multi-session safety - set spriteram size to zero before memory map is set up */
	spriteram_size=spriteram_2_size=0;

	/* first of all initialize the memory handlers, which could be used by the */
	/* other initialization routines */
	cpu_init();

	/* load input ports settings (keys, dip switches, and so on) */
	settingsloaded = load_input_port_settings();

	if( !memory_init() )
		goto out_free;

	if (gamedrv->driver_init) (*gamedrv->driver_init)();

	return 0;

out_free:
	input_port_free(Machine->input_ports);
	Machine->input_ports = 0;
	input_port_free(Machine->input_ports_default);
	Machine->input_ports_default = 0;
out_code:
	code_close();
out:
	return 1;
}
Example #3
0
static void print_game_input(FILE* out, const game_driver* game)
{
	const input_port_entry* input;
	int nplayer = 0;
	const char* control = 0;
	int nbutton = 0;
	int ncoin = 0;
	const char* service = 0;
	const char* tilt = 0;

	begin_resource_tracking();

	input = input_port_allocate(game->construct_ipt, NULL);

	while (input->type != IPT_END)
	{
		if (nplayer < input->player+1)
			nplayer = input->player+1;

		switch (input->type)
		{
			case IPT_JOYSTICK_LEFT:
			case IPT_JOYSTICK_RIGHT:

				/* if control not defined, start it off as horizontal 2-way */
				if (!control)
					control = "joy2way";
				else if (strcmp(control,"joy2way") == 0)
					;
				/* if already defined as vertical, make it 4 or 8 way */
				else if (strcmp(control,"vjoy2way") == 0)
				{
					if (input->four_way)
						control = "joy4way";
					else
						control = "joy8way";
				}
				break;

			case IPT_JOYSTICK_UP:
			case IPT_JOYSTICK_DOWN:

				/* if control not defined, start it off as vertical 2-way */
				if (!control)
					control= "vjoy2way";
				else if (strcmp(control,"vjoy2way") == 0)
					;
				/* if already defined as horiz, make it 4 or 8way */
				else if (strcmp(control,"joy2way")==0)
				{
					if (input->four_way)
						control = "joy4way";
					else
						control = "joy8way";
				}
				break;

			case IPT_JOYSTICKRIGHT_UP:
			case IPT_JOYSTICKRIGHT_DOWN:
			case IPT_JOYSTICKLEFT_UP:
			case IPT_JOYSTICKLEFT_DOWN:

				/* if control not defined, start it off as vertical 2way */
				if (!control)
					control= "vdoublejoy2way";
				else if (strcmp(control,"vdoublejoy2way") == 0)
					;
				/* if already defined as horiz, make it 4 or 8 way */
				else if (strcmp(control,"doublejoy2way") == 0)
				{
					if (input->four_way)
						control = "doublejoy4way";
					else
						control = "doublejoy8way";
				}
				break;

			case IPT_JOYSTICKRIGHT_LEFT:
			case IPT_JOYSTICKRIGHT_RIGHT:
			case IPT_JOYSTICKLEFT_LEFT:
			case IPT_JOYSTICKLEFT_RIGHT:

				/* if control not defined, start it off as horiz 2-way */
				if (!control)
					control="doublejoy2way";
				else if (strcmp(control,"doublejoy2way") == 0)
					;
				/* if already defined as vertical, make it 4 or 8 way */
				else if (strcmp(control,"vdoublejoy2way") == 0)
				{
					if (input->four_way)
						control = "doublejoy4way";
					else
						control = "doublejoy8way";
				}
				break;

			case IPT_BUTTON1:
				if (nbutton<1) nbutton = 1;
				break;
			case IPT_BUTTON2:
				if (nbutton<2) nbutton = 2;
				break;
			case IPT_BUTTON3:
				if (nbutton<3) nbutton = 3;
				break;
			case IPT_BUTTON4:
				if (nbutton<4) nbutton = 4;
				break;
			case IPT_BUTTON5:
				if (nbutton<5) nbutton = 5;
				break;
			case IPT_BUTTON6:
				if (nbutton<6) nbutton = 6;
				break;
			case IPT_BUTTON7:
				if (nbutton<7) nbutton = 7;
				break;
			case IPT_BUTTON8:
				if (nbutton<8) nbutton = 8;
				break;
			case IPT_BUTTON9:
				if (nbutton<9) nbutton = 9;
				break;
			case IPT_BUTTON10:
				if (nbutton<10) nbutton = 10;
				break;
			case IPT_PADDLE:
				control = "paddle";
				break;
			case IPT_DIAL:
				control = "dial";
				break;
			case IPT_TRACKBALL_X:
			case IPT_TRACKBALL_Y:
				control = "trackball";
				break;
			case IPT_AD_STICK_X:
			case IPT_AD_STICK_Y:
				control = "stick";
				break;
			case IPT_LIGHTGUN_X:
			case IPT_LIGHTGUN_Y:
				control = "lightgun";
				break;
			case IPT_COIN1:
				if (ncoin < 1) ncoin = 1;
				break;
			case IPT_COIN2:
				if (ncoin < 2) ncoin = 2;
				break;
			case IPT_COIN3:
				if (ncoin < 3) ncoin = 3;
				break;
			case IPT_COIN4:
				if (ncoin < 4) ncoin = 4;
				break;
			case IPT_COIN5:
				if (ncoin < 5) ncoin = 5;
				break;
			case IPT_COIN6:
				if (ncoin < 6) ncoin = 6;
				break;
			case IPT_COIN7:
				if (ncoin < 7) ncoin = 7;
				break;
			case IPT_COIN8:
				if (ncoin < 8) ncoin = 8;
				break;
			case IPT_SERVICE :
				service = "yes";
				break;
			case IPT_TILT :
				tilt = "yes";
				break;
		}
		++input;
	}

	fprintf(out, "\t\t<input");
	fprintf(out, " players=\"%d\"", nplayer );
	if (control)
		fprintf(out, " control=\"%s\"", normalize_string(control) );
	if (nbutton)
		fprintf(out, " buttons=\"%d\"", nbutton );
	if (ncoin)
		fprintf(out, " coins=\"%d\"", ncoin );
	if (service)
		fprintf(out, " service=\"%s\"", normalize_string(service) );
	if (tilt)
		fprintf(out, " tilt=\"%s\"", normalize_string(tilt) );
	fprintf(out, "/>\n");

	end_resource_tracking();
}
Example #4
0
int inputx_validitycheck(const game_driver *gamedrv, input_port_entry **memory)
{
	char buf[CODE_BUFFER_SIZE];
	struct InputCode *codes;
	const input_port_entry *input_ports;
	const input_port_entry *ipt;
	int port_count, i, j;
	int error = 0;
	unicode_char_t last_char = 0;
	const struct CharInfo *ci;

	if (gamedrv)
	{
		if (gamedrv->flags & GAME_COMPUTER)
		{
			codes = (struct InputCode *) buf;

			/* allocate the input ports */
			*memory = input_port_allocate(gamedrv->construct_ipt, *memory);
			input_ports = *memory;

			build_codes(input_ports, codes, FALSE);

			port_count = 0;
			for (ipt = input_ports; ipt->type != IPT_END; ipt++)
			{
				if (ipt->type == IPT_PORT)
					port_count++;
			}

			if (port_count > 0)
			{
				for (i = 0; i < NUM_CODES; i++)
				{
					for (j = 0; j < NUM_SIMUL_KEYS; j++)
					{
						if (codes[i].port[j] >= port_count)
						{
							printf("%s: invalid inputx translation for code %i port %i\n", gamedrv->name, i, j);
							error = 1;
						}
					}
				}
			}
		}
	}
	else
	{
		/* check to make sure that charinfo is in order */
		for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++)
		{
			if (last_char >= charinfo[i].ch)
			{
				printf("inputx: charinfo is out of order; 0x%08x should be higher than 0x%08x\n", charinfo[i].ch, last_char);
				error = 1;
			}
			last_char = charinfo[i].ch;
		}

		/* check to make sure that I can look up everything on alternate_charmap */
		for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++)
		{
			ci = find_charinfo(charinfo[i].ch);
			if (ci != &charinfo[i])
			{
				printf("inputx: expected find_charinfo(0x%08x) to work properly\n", charinfo[i].ch);
				error = 1;
			}
		}
	}
	return error;
}