Exemplo n.º 1
0
static void wiz_exit(void)
{
	remove("frontend/mame.lst");
	sync();
	wiz_deinit();
	chdir("/usr/gp2x"); /*go to menu*/
      	execl("gp2xmenu", "gp2xmenu", NULL);
}
Exemplo n.º 2
0
int main (int argc, char **argv)
{
	int res, i, j = 0, game_index;
   	char *playbackname = NULL;
   	int use_cyclone=0;
   	int use_drz80=0;
    int use_drz80_snd=0;
   	extern int video_scale;
	extern int video_border;
	extern int video_aspect;
	extern int throttle;
	extern int wiz_ram_tweaks;
	extern int wiz_rotated_video;

	memset(&options,0,sizeof(options));

	/* these two are not available in mame.cfg */
	errorlog = 0;

	game_index = -1;

	for (i = 1;i < argc;i++) /* V.V_121997 */
	{
		if (strcasecmp(argv[i],"-log") == 0)
			errorlog = fopen("error.log","wa");
		if (strcasecmp(argv[i],"-cyclone") == 0)
			use_cyclone=1;
		if (strcasecmp(argv[i],"-drz80") == 0)
			use_drz80=1;
		if (strcasecmp(argv[i],"-drz80_snd") == 0)
			use_drz80_snd=1;
		if (strcasecmp(argv[i],"-scale") == 0)
			video_scale=1;
		if (strcasecmp(argv[i],"-border") == 0)
			video_border=1;
		if (strcasecmp(argv[i],"-aspect") == 0)
			video_aspect=1;
		if (strcasecmp(argv[i],"-nothrottle") == 0)
			throttle=0;
		if (strcasecmp(argv[i],"-ramtweaks") == 0)
			wiz_ram_tweaks=1;
		if ((strcasecmp(argv[i],"-clock") == 0) && (i<argc-1))
			wiz_clock=atoi(argv[i+1]);
		if (strcasecmp(argv[i],"-wiz_rotated_video") == 0)
			wiz_rotated_video=1;
        if (strcasecmp(argv[i],"-playback") == 0)
		{
			i++;
			if (i < argc)  /* point to inp file name */
				playbackname = argv[i];
        }
	}

	/* WIZ Initialization */
	wiz_init(8,22050,16,0);

	/* check for frontend options */
	res = frontend_help (argc, argv);

	/* if frontend options were used, return to DOS with the error code */
	if (res != 1234)
	{
	      	wiz_deinit();
	      	execl("mame.gpe", "mame.gpe", "cache", NULL);
		exit (res);
	}

    /* handle playback which is not available in mame.cfg */
	init_inpdir(); /* Init input directory for opening .inp for playback */

    if (playbackname != NULL)
        options.playback = osd_fopen(playbackname,0,OSD_FILETYPE_INPUTLOG,0);

    /* check for game name embedded in .inp header */
    if (options.playback)
    {
        INP_HEADER inp_header;

        /* read playback header */
        osd_fread(options.playback, &inp_header, sizeof(INP_HEADER));

        if (!isalnum(inp_header.name[0])) /* If first byte is not alpha-numeric */
            osd_fseek(options.playback, 0, SEEK_SET); /* old .inp file - no header */
        else
        {
            for (i = 0; (drivers[i] != 0); i++) /* find game and play it */
			{
                if (strcmp(drivers[i]->name, inp_header.name) == 0)
                {
                    game_index = i;
                    printf("Playing back previously recorded game %s (%s) [press return]\n",
                        drivers[game_index]->name,drivers[game_index]->description);
                    getchar();
                    break;
                }
            }
        }
    }

	/* If not playing back a new .inp file */
    if (game_index == -1)
    {
        /* take the first commandline argument without "-" as the game name */
        for (j = 1; j < argc; j++)
        {
            if (argv[j][0] != '-') break;
        }
        {
            for (i = 0; drivers[i] && (game_index == -1); i++)
            {
                if (strcasecmp(argv[j],drivers[i]->name) == 0)
                {
                    game_index = i;
                    break;
                }
            }

            /* educated guess on what the user wants to play */
            if (game_index == -1)
            {
                int fuzz = 9999; /* best fuzz factor so far */

                for (i = 0; (drivers[i] != 0); i++)
                {
                    int tmp;
                    tmp = fuzzycmp(argv[j], drivers[i]->description);
                    /* continue if the fuzz index is worse */
                    if (tmp > fuzz)
                        continue;

                    /* on equal fuzz index, we prefer working, original games */
                    if (tmp == fuzz)
                    {
						/* game is a clone */
						if (drivers[i]->clone_of != 0
								&& !(drivers[i]->clone_of->flags & NOT_A_DRIVER))
                        {
                            /* if the game we already found works, why bother. */
                            /* and broken clones aren't very helpful either */
                            if ((!drivers[game_index]->flags & GAME_NOT_WORKING) ||
                                (drivers[i]->flags & GAME_NOT_WORKING))
                                continue;
                        }
                        else continue;
                    }

                    /* we found a better match */
                    game_index = i;
                    fuzz = tmp;
                }

                if (game_index != -1)
                    printf("fuzzy name compare, running %s\n",drivers[game_index]->name);
            }
        }

        if (game_index == -1)
        {
            printf("Game \"%s\" not supported\n", argv[j]);
            return 1;
        }
    }

	/* parse generic (os-independent) options */
	parse_cmdline (argc, argv, game_index);

{	/* Mish:  I need sample rate initialised _before_ rom loading for optional rom regions */
	extern int soundcard;

	if (soundcard == 0) {    /* silence, this would be -1 if unknown in which case all roms are loaded */
		Machine->sample_rate = 0; /* update the Machine structure to show that sound is disabled */
		options.samplerate=0;
	}
}

	/* handle record which is not available in mame.cfg */
	for (i = 1; i < argc; i++)
	{
		if (strcasecmp(argv[i],"-record") == 0)
		{
            i++;
			if (i < argc)
				options.record = osd_fopen(argv[i],0,OSD_FILETYPE_INPUTLOG,1);
		}
	}

    if (options.record)
    {
        INP_HEADER inp_header;

        memset(&inp_header, '\0', sizeof(INP_HEADER));
        strcpy(inp_header.name, drivers[game_index]->name);
        /* MAME32 stores the MAME version numbers at bytes 9 - 11
         * MAME DOS keeps this information in a string, the
         * Windows code defines them in the Makefile.
         */
        /*
        inp_header.version[0] = 0;
        inp_header.version[1] = VERSION;
        inp_header.version[2] = BETA_VERSION;
        */
        osd_fwrite(options.record, &inp_header, sizeof(INP_HEADER));
    }

	/* Replace M68000 by CYCLONE */
	if (use_cyclone)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
            #ifdef NEOMAME
			if (((*type)&0xff)==CPU_M68000)
            #else
			if (((*type)&0xff)==CPU_M68000 || ((*type)&0xff)==CPU_M68010 )
            #endif
			{
				*type=((*type)&(~0xff))|CPU_CYCLONE;
			}
		}
	}

	/* Replace Z80 by DRZ80 */
	if (use_drz80)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_Z80)
			{
				*type=((*type)&(~0xff))|CPU_DRZ80;
			}
		}
	}

	/* Replace Z80 with DRZ80 only for sound CPUs */
	if (use_drz80_snd)
	{
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if ((((*type)&0xff)==CPU_Z80) && ((*type)&CPU_AUDIO_CPU))
			{
				*type=((*type)&(~0xff))|CPU_DRZ80;
			}
		}
	}

    /*
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_V30)
			{
				*type=((*type)&(~0xff))|CPU_ARMV30;
			}
		}
		for (i=0;i<MAX_CPU;i++)
		{
			int *type=(int*)&(drivers[game_index]->drv->cpu[i].cpu_type);
			if (((*type)&0xff)==CPU_V33)
			{
				*type=((*type)&(~0xff))|CPU_ARMV33;
			}
		}
    */
    
    // Remove the mouse usage for certain games
    if ( (strcasecmp(drivers[game_index]->name,"hbarrel")==0) || (strcasecmp(drivers[game_index]->name,"hbarrelw")==0) ||
         (strcasecmp(drivers[game_index]->name,"midres")==0) || (strcasecmp(drivers[game_index]->name,"midresu")==0) ||
         (strcasecmp(drivers[game_index]->name,"midresj")==0) || (strcasecmp(drivers[game_index]->name,"tnk3")==0) ||
         (strcasecmp(drivers[game_index]->name,"tnk3j")==0) || (strcasecmp(drivers[game_index]->name,"ikari")==0) ||
         (strcasecmp(drivers[game_index]->name,"ikarijp")==0) || (strcasecmp(drivers[game_index]->name,"ikarijpb")==0) ||
         (strcasecmp(drivers[game_index]->name,"victroad")==0) || (strcasecmp(drivers[game_index]->name,"dogosoke")==0) ||
         (strcasecmp(drivers[game_index]->name,"gwar")==0) || (strcasecmp(drivers[game_index]->name,"gwarj")==0) ||
         (strcasecmp(drivers[game_index]->name,"gwara")==0) || (strcasecmp(drivers[game_index]->name,"gwarb")==0) ||
         (strcasecmp(drivers[game_index]->name,"bermudat")==0) || (strcasecmp(drivers[game_index]->name,"bermudaj")==0) ||
         (strcasecmp(drivers[game_index]->name,"bermudaa")==0) || (strcasecmp(drivers[game_index]->name,"mplanets")==0) ||
         (strcasecmp(drivers[game_index]->name,"forgottn")==0) || (strcasecmp(drivers[game_index]->name,"lostwrld")==0) ||
         (strcasecmp(drivers[game_index]->name,"gondo")==0) || (strcasecmp(drivers[game_index]->name,"makyosen")==0) ||
         (strcasecmp(drivers[game_index]->name,"topgunr")==0) || (strcasecmp(drivers[game_index]->name,"topgunbl")==0) ||
         (strcasecmp(drivers[game_index]->name,"tron")==0) || (strcasecmp(drivers[game_index]->name,"tron2")==0) ||
         (strcasecmp(drivers[game_index]->name,"kroozr")==0) ||(strcasecmp(drivers[game_index]->name,"crater")==0) ||
         (strcasecmp(drivers[game_index]->name,"dotron")==0) || (strcasecmp(drivers[game_index]->name,"dotrone")==0) ||
         (strcasecmp(drivers[game_index]->name,"zwackery")==0) || (strcasecmp(drivers[game_index]->name,"ikari3")==0) ||
         (strcasecmp(drivers[game_index]->name,"searchar")==0) || (strcasecmp(drivers[game_index]->name,"sercharu")==0) ||
         (strcasecmp(drivers[game_index]->name,"timesold")==0) || (strcasecmp(drivers[game_index]->name,"timesol1")==0) ||
         (strcasecmp(drivers[game_index]->name,"btlfield")==0) || (strcasecmp(drivers[game_index]->name,"aztarac")==0))
    {
        extern int use_mouse;
        use_mouse=0;
    }

    /* go for it */
    printf ("%s (%s)...\n",drivers[game_index]->description,drivers[game_index]->name);
    res = run_game (game_index);

	/* close open files */
	if (errorlog) fclose (errorlog);
	if (options.playback) osd_fclose (options.playback);
	if (options.record)   osd_fclose (options.record);
	if (options.language_file) osd_fclose (options.language_file);

	if (res!=0)
	{
		/* wait a key press */
		wiz_video_flip_single();
		wiz_joystick_press(0);
	}

      	wiz_deinit();
#ifndef PROFILE_GENERATE
      	execl("mame.gpe", "mame.gpe", "cache", NULL);
#endif
	exit (res);
}
Exemplo n.º 3
0
void execute_game (char *playemu, char *playgame)
{
	char *args[255];
	char str[8][64];
	int n=0;
	int i=0;
	
	/* executable */
	args[n]=playemu; n++;

	/* playgame */
	args[n]=playgame; n++;

	/* wiz_freq */
	args[n]="-clock"; n++;
	sprintf(str[i],"%d",wiz_freq);
	args[n]=str[i]; i++; n++;

	/* wiz_video_depth */
	if (wiz_video_depth==8)
	{
		args[n]="-depth"; n++;
		args[n]="8"; n++;
	}
	if (wiz_video_depth==16)
	{
		args[n]="-depth"; n++;
		args[n]="16"; n++;
	}

	/* wiz_video_aspect */
	if ((wiz_video_aspect==1) || (wiz_video_aspect==3) || (wiz_video_aspect==5) || (wiz_video_aspect==7) ||
		(wiz_video_aspect==9) || (wiz_video_aspect==11) || (wiz_video_aspect==13) || (wiz_video_aspect==15) ||
		(wiz_video_aspect==17) || (wiz_video_aspect==19) || (wiz_video_aspect==21) || (wiz_video_aspect==23))
	{
		args[n]="-scale"; n++;
	}
	if ((wiz_video_aspect==2) || (wiz_video_aspect==3) || (wiz_video_aspect==6) || (wiz_video_aspect==7) ||
		(wiz_video_aspect==10) || (wiz_video_aspect==11) || (wiz_video_aspect==14) || (wiz_video_aspect==15) ||
		(wiz_video_aspect==18) || (wiz_video_aspect==19) || (wiz_video_aspect==22) || (wiz_video_aspect==23))
	{
		args[n]="-aspect"; n++;
	}
	if ((wiz_video_aspect==4) || (wiz_video_aspect==5) || (wiz_video_aspect==6) || (wiz_video_aspect==7) ||
		(wiz_video_aspect==12) || (wiz_video_aspect==13) || (wiz_video_aspect==14) || (wiz_video_aspect==15) ||
		(wiz_video_aspect==20) || (wiz_video_aspect==21) || (wiz_video_aspect==22) || (wiz_video_aspect==23))
	{
		args[n]="-border"; n++;
	}
  	if ((wiz_video_aspect>=8) && (wiz_video_aspect<=23))
   	{
    		args[n]="-ror"; n++;
   	}
	if ((wiz_video_aspect>=8) && (wiz_video_aspect<=15))
	{
		args[n]="-rotatecontrols"; n++;
	}
	
	/* wiz_video_sync */
	if (wiz_video_sync==1)
	{
		args[n]="-nodirty"; n++;
		args[n]="-waitvsync"; n++;
	}
	else if ((wiz_video_sync==2) || (wiz_video_aspect==1) || (wiz_video_aspect==9))
	{
		args[n]="-nodirty"; n++;
	}
	if (wiz_video_sync==-1)
	{
		args[n]="-nothrottle"; n++;
	}
	
	/* wiz_frameskip */
	if (wiz_frameskip>=0)
	{
		args[n]="-frameskip"; n++;
		sprintf(str[i],"%d",wiz_frameskip);
		args[n]=str[i]; i++; n++;
	}

	/* wiz_sound */
	if (wiz_sound==0)
	{
		args[n]="-soundcard"; n++;
		args[n]="0"; n++;
	}
	if ((wiz_sound==1) || (wiz_sound==6) || (wiz_sound==11))
	{
		args[n]="-samplerate"; n++;
		args[n]="15000"; n++;
	}
	if ((wiz_sound==2) || (wiz_sound==7) || (wiz_sound==12))
	{
		args[n]="-samplerate"; n++;
		args[n]="22050"; n++;
	}
	if ((wiz_sound==3) || (wiz_sound==8) || (wiz_sound==13))
	{
		args[n]="-samplerate"; n++;
		args[n]="32000"; n++;
	}
	if ((wiz_sound==4) || (wiz_sound==9) || (wiz_sound==14))
	{
		args[n]="-samplerate"; n++;
		args[n]="44100"; n++;
	}
	if ((wiz_sound==5) || (wiz_sound==10) || (wiz_sound==15))
	{
		args[n]="-samplerate"; n++;
		args[n]="11025"; n++;
	}
	if ((wiz_sound>=1) && (wiz_sound<=5))
	{
		args[n]="-fastsound"; n++;
	}
	if (wiz_sound>=11)
	{
		args[n]="-stereo"; n++;
	}

	/* wiz_clock_cpu */
	if (wiz_clock_cpu!=100)
	{
		args[n]="-uclock"; n++;
		sprintf(str[i],"%d",100-wiz_clock_cpu);
		args[n]=str[i]; i++; n++;
	}

	/* wiz_clock_sound */
	if (wiz_clock_cpu!=100)
	{
		args[n]="-uclocks"; n++;
		sprintf(str[i],"%d",100-wiz_clock_sound);
		args[n]=str[i]; i++; n++;
	}
	
	/* wiz_cpu_cores */
	if ((wiz_cpu_cores==1) || (wiz_cpu_cores==3))
	{
		args[n]="-cyclone"; n++;
	}
	if ((wiz_cpu_cores==2) || (wiz_cpu_cores==3))
	{
		args[n]="-drz80"; n++;
	}

	if (wiz_ramtweaks)
	{
		args[n]="-ramtweaks"; n++;
	}
	
	if (wiz_cheat)
	{
		args[n]="-cheat"; n++;
	}

	if (wiz_video_aspect==24)
	{
		args[n]="-wiz_rotated_video"; n++;
    	args[n]="-rol"; n++;
	}
    if (wiz_video_aspect==25)
    {
		args[n]="-wiz_rotated_video"; n++;
		args[n]="-rotatecontrols"; n++;
    }
    
	args[n]=NULL;
	
	for (i=0; i<n; i++)
	{
		printf("%s ",args[i]);
	}
	printf("\n");
	
	wiz_deinit();
	execv(args[0], args); 
}