Ejemplo n.º 1
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    InitUSB();
    init_oc();

    init_display(&i2c3, 0x70, 0x71);
    init_game(&timer1, &timer2, &A[0], &disp1, &disp2);
    init_gun(&D[13], &A[1], &A[2], &timer3);
    init_launcher(&D[5], &D[8], &D[3], &D[4]);
    init_shooter(&D[6], &D[9], &D[1], &D[2], &D[7], &D[0], &oc3, &oc4);
    init_baller(&D[10], &oc2, &timer4, &shooter, &launcher);
    init_pix(&D[11], &timer5, 30, 0.05);
    init_audio(&D[12]);

    uint8_t level = 0;
    uint8_t hit_flag = 0;
    while (1) {
        ServiceUSB(); // usb times out if not checked fast enough :/
        level = run_game(hit_flag);
        ServiceUSB();
        hit_flag = run_gun(level);
        ServiceUSB();
        run_baller(level);
    }
}
Ejemplo n.º 2
0
int main() {
  init_ncurses();

  run_game();

  endwin();
}
Ejemplo n.º 3
0
/*
 * Deze functie wordt in het begin, eens het veld geïnitialiseerd is, aangeroepen.
 * Eens deze functie is aangeroepen moet het spel in beurten verdergaan tot de speler gewonnen of verloren heeft.
 * Na elke beurt moet het hele veld automatisch geprint worden, via de functie print_grid uit printer.h,
 * en moet er geprint worden hoeveel vlaggen nog beschikbaar zijn voor de speler.
 */
void run_game()
{

/*
 * Leest de input van de gebruiker via de console in, en roept daarna de juiste functie op.
 * De gebruiker kan 3 soorten inputs geven:*/
 handle_input();

 /*
 *
 * 1)
 * F x y
 * Wordt gebruikt om een vlag te plaatsen op positie (x,y) in het veld. X en y zijn hier integers.
 * handle_input roept hierna de functie flag_coordinate op.
 *
 * 2)
 * R x y
 * Wordt gebruikt om het vakje met positie (x,y) te onthullen. X en y zijn hier integers.
 * handle_input roept hierna de functie reveal_coordinate op.
 *
 * 3)
 * P
 * Print het hele, onthulde veld.
 * handle_input roept hierna de functie print_grid_uncovered op.
 *
 *
 * Elk van deze functies (flag_coordinate, reveal_coordinate en print_grid_uncovered) moeten
 * nog door jullie geïmplementeerd worden.
 *
 */
 run_game();
 }
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
  MapProto.init = Hall_init;
  Map *game = NEW(Map, "The Hall of the Minotaur.");

  run_game(game);
  return 0;
}
Ejemplo n.º 5
0
	Menu::Menu(Player& p) : player(p) {
		std::function<bool()> f = [this]() { return run_game(); };
		inputcalls['1'] = f;
		f = [this]() {
			return load_quicksave(); //TODO Test if valid save-file
		};
		inputcalls['2'] = f;
	}
Ejemplo n.º 6
0
void main_game_loop(nstate *state)
{
	wait_for_start(state);
	while(state->state != STATE_EXIT) {
		if(state->state == STATE_RUNNING) run_game(state);
		if(state->state == STATE_STOPPED) wait_for_start(state);
		if(state->state != STATE_EXIT) new_game(state);
	}
}
Ejemplo n.º 7
0
int main (int argc, char *argv[])
{
    init();
    //switch (run_menu()){

    //}
    run_game();
    SDL_Quit();
	return 0;
}
Ejemplo n.º 8
0
/*######## CONTINUE GAME ####################################*/
void continue_game(int no_of_players)
    {
   // edittext.c
    BITMAP *uname;
    //BITMAP* buffer6;
    //char name[20];
    int caret = 0;
    uname = load_bitmap("images/menu/username.pcx", NULL);
    
    for( i = 0 ; i <= no_of_players ; i++)
    
    masked_blit(uname, screen, 0, 0, 90, 80 + ( no_of_players * 100), uname->w, uname->h);
    
    while(1)
    {
        if(keypressed())
        {
            int newkey = readkey();
            char ASCII = newkey &0xff;
            char scancode = newkey >> 8;
 
            /* a character key was pressed; add it to the string */
            if(ASCII >= 32 && ASCII <= 126)
            {
                if(caret < 19)
                {
                    name[no_of_players][caret] = ASCII;
                    caret++;
                    name[no_of_players][caret] = '\0';
                }
            }
            else if(scancode == KEY_BACKSPACE)
            {
                if (caret > 0) 
                  
                   name[no_of_players][caret] = '\0';
                    caret--;
            }
        }
        
        /* all drawing goes here */
        //text_mode(15);
        textout(screen, font, name[no_of_players], 120, 123 + (no_of_players * 100), makecol(255, 20, 200));
      
        if(key[KEY_ENTER])
        {
            destroy_bitmap(uname);
           
            clear(screen);
            run_game();
            break;
            //gameStart();
        }
    }
}
Ejemplo n.º 9
0
gint key_press(GtkWidget *widget,
	       GdkEvent  *event)
{
  GdkEventKey    *kevent;

  timeout_restart();

  kevent = (GdkEventKey *) event;
  switch (kevent->keyval)
    {
    case GDK_Escape:
      /*      system("(~/xv&sleep 10;killall xv)&"); */
      /* exit(-2); */
      flynn_exit(-2);
      break;

    case GDK_Down:
      if (flynn_state.gy < (num_games+COLUMNS-1)/COLUMNS -1)
	flynn_state.gy++;
      break;

    case GDK_Up:
      if (flynn_state.gy > 0)
	flynn_state.gy--;
      break;

    case GDK_Left:
      if (flynn_state.gx > 0)
	flynn_state.gx--;
      break;

    case GDK_Right:
      if (flynn_state.gx < COLUMNS-1)
	flynn_state.gx++;
      break;

    case GDK_Shift_L:
    case GDK_Control_L:
    case GDK_Alt_L:
    case GDK_space:
    case GDK_z:
    case GDK_x:
    case GDK_1:
    case GDK_2:
    case GDK_5:
    case GDK_6:
    default:
      arg0 = "";
      run_game();
      break;
    }

  return FALSE;
}
Ejemplo n.º 10
0
int main(void)
{
    if (TESTING) {
        return testrun();
    }
    int status = run_game();
    if (!status) {
        printf("Program exitted with error code %d\n", status);
    }
    printf("End of program\n");
    return 0;
}
Ejemplo n.º 11
0
int main(void) {
    srand(time(NULL));

    init_ui();

    while(1) {
        main_menu();
        run_game();
    }

    return 0;
}
Ejemplo n.º 12
0
Archivo: mora.c Proyecto: yydaor/LCUI
/* 玩家选择布 */
static void 
select_cloth( LCUI_Widget *widget, LCUI_WidgetEvent *unused )
{
	if(!Graph_IsValid(&left_cloth)) {
		Graph_HorizFlip( &cloth, &left_cloth );
	}
	PictureBox_SetImage( me_pic_box, &left_cloth ); 
	Widget_Disable( btn_j );
	Widget_Disable( btn_s );
	Widget_Disable( btn_b );
	Widget_Enable( btn_next );
	run_game(2);
}
Ejemplo n.º 13
0
void run_game() {

  // Create player 1
  std::list<Link> player1;
  Link p1start = {5, MAX_BOARD_Y / 2, 'X', 1};
  player1.push_back(p1start);

  // Create player 2
  std::list<Link> player2;
  Link p2start = {MAX_BOARD_X - 5, MAX_BOARD_Y / 2, 'O', 2};
  player2.push_back(p2start);

  clear();
  print_board();
  print_snake(player1);
  print_snake(player2);

  // Wait for initial direction input
  int p1direction;
  int p2direction;
  bool p1sel = false;
  bool p2sel = false;
  while(!(p1sel && p2sel)) {
    if (kbhit()) {
      int input = getch();
      if (!p1sel) {
        p1sel = get_init_dir(p1direction, input, 1);
      }
      if (!p2sel) {
        p2sel = get_init_dir(p2direction, input, 2);
      }
    }
  }

  int loser = 0;
  while(loser == 0) {
    game_frame(player1, p1direction, player2, p2direction);
    loser = check_collisions(player1, player2);
    if (loser == 0) {
      loser = check_collisions(player2, player1);
    }
  }
  if (!play_again(loser)) {
    return;
  }
  else {
    run_game();
  }
}
Ejemplo n.º 14
0
/* Hides the title image, and starts a new game */
void cb_new_game(GtkWidget *widget, gpointer data) {
	GuiInfo *gui;
	gui = (GuiInfo *) data;

	/* Hide the title */
        /*gnome_canvas_item_hide(gui->title_image);
        gnome_canvas_item_show(gui->background);
        gnome_canvas_update_now(gui->canvas);*/

	if(gui->game->state != STATE_STOPPED) {
		end_game(gui->game, ENDGAME_MENU);
	}

	run_game(gui->game);
}
Ejemplo n.º 15
0
Code game(SDL_Renderer *renderer, CommandTable *table) {
  char name[MAXIMUM_PLAYER_NAME_SIZE];
  Player player;
  Game game;
  Code code;
  code = read_player_name(name, MAXIMUM_PLAYER_NAME_SIZE, renderer);
  if (code == CODE_QUIT || code == CODE_CLOSE) {
    return code;
  }
  player = create_player(name, table);
  game = create_game(&player);
  code = run_game(&game, renderer);
  destroy_game(&game);
  return code;
}
Ejemplo n.º 16
0
Archivo: mora.c Proyecto: yydaor/LCUI
/* 玩家选择石头 */
static void
select_stone( LCUI_Widget *widget, LCUI_WidgetEvent *unused )
{
	/* 如果没有存储已水平翻转的图像,就进行水平翻转 */
	if(!Graph_IsValid(&left_stone)) {
		Graph_HorizFlip(&stone, &left_stone);
	}
	/* 设定显示的图像为石头 */
	PictureBox_SetImage(me_pic_box, &left_stone);
	Widget_Disable(btn_j);
	Widget_Disable(btn_s);
	Widget_Disable(btn_b);
	Widget_Enable(btn_next);
	run_game(0);/* 进入游戏 */
}
Ejemplo n.º 17
0
Archivo: main.c Proyecto: Osyx/mr2d
int main(void) {

	hardware_init();
	display_init();
	start();
	start_select();
	settings_select();
	opening();
	run_game();
	you_died();
	score_screen();
	main();

	return 0;
}
Ejemplo n.º 18
0
int AgiEngine::go() {
	CursorMan.showMouse(true);

	report(" \nAGI engine " VERSION " is ready.\n");
	if (game.state < STATE_LOADED) {
		do {
			main_cycle();
		} while (game.state < STATE_RUNNING);
		if (game.ver < 0)
			game.ver = 0;	/* Enable conf file warning */
	}

	run_game();

	return 0;
}
Ejemplo n.º 19
0
RallyX::RallyX()
{
	resources.display = NULL;
	resources.event_queue = NULL;
	resources.font = NULL;
	_bitmaps.out_of_bounds = NULL;
	_bitmaps.road = NULL;
	resources.timer = NULL;
	_bitmaps.wall = NULL;
	setup_allegro();
	Load_map("map_level_1.txt");

	tiled_map1 = _game_map.get_map();

	run_game();
}
Ejemplo n.º 20
0
int		afirstchaos()
{
  t_game_goodies	*nfo;

  nfo = (t_game_goodies*)xmalloc(sizeof(*nfo));
  nfo->db_info = (t_db_info*)xmalloc(sizeof(*(nfo->db_info)));
  nfo->events = (t_event*)xmalloc(sizeof(*(nfo->events)));
  init_log("afirstchaos.log");
  fprintf(fd_log, "%s: A First Chaos starting...\n", NAME);
  if (init_game(nfo))
    return (1);
  if (run_game(nfo))
    return (1);
  SDLNet_Quit();
  SDL_Quit();
  fprintf(fd_log, "%s: bye bye\n", NAME);
  return (0);
}
Ejemplo n.º 21
0
int main(int argc, char *argv[])
{
    int err;
    err = SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
    if(err){
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    }


    scaled = SDL_SetVideoMode(SCREENX * 2, SCREENY * 2, 32, SDL_DOUBLEBUF | SDL_SWSURFACE);

    main_screen = SDL_CreateRGBSurface(SDL_SWSURFACE,
            SCREENX,
            SCREENY,
            scaled->format->BitsPerPixel,
            scaled->format->Rmask,
            scaled->format->Gmask,
            scaled->format->Bmask,
            scaled->format->Amask
            );


    if (!main_screen){
        fprintf(stderr, "SDL failed screen init: %s\n", SDL_GetError());
    }

    err = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 2048);
    if (err){
        fprintf(stderr, "SDL audio failed: %s\n", SDL_GetError());
    }
    init_font();
    key_state = SDL_GetKeyState(NULL);
    game_state = 1;
    srand(time(NULL));
    load_game_resources();

    while(game_state != QUIT){
        run_menu();
        if(game_state != QUIT){
            run_game();
        }
    }
    return 0;
}
Ejemplo n.º 22
0
static void initGame(JNIEnv *env, jclass classz) {
	real_game.random_seed = time(NULL);

	/* Load card designs */
	read_cards();

	/* Load card images */
	// done in Java onCreate()
	//load_images();

	/* Read preference file */
	read_prefs();

	apply_options();

	/* Create choice logs for each player */
	int i;
	for (i = 0; i < MAX_PLAYER; i++) {
		/* Create log */
		real_game.p[i].choice_log = (int *)malloc(sizeof(int) * 4096);

		/* Save original log */
		orig_log[i] = real_game.p[i].choice_log;

		/* Create history of log sizes */
		real_game.p[i].choice_history = (int*)malloc(sizeof(int) * 512);

		/* Save original history */
		orig_history[i] = real_game.p[i].choice_history;

		/* Clear choice log size and position */
		real_game.p[i].choice_size = 0;
		real_game.p[i].choice_pos = 0;
	}

 	reset_gui();
	modify_gui(); // adjust for the number of players

	/* Start new game */
	restart_loop = RESTART_NEW;

	run_game();
}
Ejemplo n.º 23
0
int play_game(int game_index, struct ui_options *opts)
{
	extern int throttle;
	extern int attenuation;
	int original_leds;
	int err;

	options.antialias = opts->enable_antialias;
	options.translucency = opts->enable_translucency;
	options.samplerate = opts->enable_sound ? 44100 : 0;
	options.use_samples = 1;
	options.use_filter = 1;
	options.vector_flicker = (float) (opts->enable_flicker ? 255 : 0);
	options.vector_width = win_gfx_width;
	options.vector_height = win_gfx_height;
	options.color_depth = 0;
	options.beam = 0x00010000;
	options.use_artwork = 0;
	options.cheat = 0;
	options.mame_debug = 0;
	options.playback = NULL;
	options.record = NULL;
	options.gui_host = 1;

#ifdef MESS
	options.mess_printf_output = wince_mess_vprintf;
#endif

	attenuation = 0;
	throttle = opts->enable_throttle;
	win_window_mode = 0;

	/* remember the initial LED states */
	original_leds = osd_get_leds();

	err = run_game(game_index);

	/* restore the original LED state */
	osd_set_leds(original_leds);

	return err;
}
Ejemplo n.º 24
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
	UInt16 err;

	if (cmd != sysAppLaunchCmdNormalLaunch)
		return sysErrParamErr;

	if (!(buffer = WinCreateOffscreenWindow (160, 160, screenFormat, &err)))
		return err;

	if ((err = StartApplication()) != 0)
		return err;

	ticks = SysTicksPerSecond() / FRAME_RATE;

	run_game ();
	/* EventLoop(); */
	StopApplication();

	WinDeleteWindow (buffer, false);

	return 0;
}
Ejemplo n.º 25
0
void proc_joy_event() {
	timeout_restart();

	switch (joy_event.type) {
		case JS_EVENT_AXIS:
			if (joy_event.number == 0) {
				if (joy_event.value < 0) {
					/* left */
					if (flynn_state.gx > 0) {
						if (joy_wait != 1) {
							joy_wait = 1;
							if (isrotated()) { 
								flynn_state.gy--;
							}
							else { 
								flynn_state.gx--; 
							}
							set_timer();
						}
					}
				} 
				else if (joy_event.value > 0) {
					/* right */
					if (flynn_state.gx < COLUMNS-1) {
						if (joy_wait != 1) {
							joy_wait = 1;
							if (isrotated()) { 
								flynn_state.gy++;
							}
							else { 
								flynn_state.gx++; 
							}				
							set_timer();
						}
					}
				}
			} 
			else if (joy_event.number == 1) {
				if (joy_event.value < 0) {
					/* up */
					if (flynn_state.gy > 0) {
						if (joy_wait != 1) {
							joy_wait = 1;
							if (isrotated()) { 
								flynn_state.gx++;
							}
							else { 
								flynn_state.gy--; 
							}							
							set_timer();
						}
					}
				} 
				else if (joy_event.value > 0) {
					/* down */
					if (flynn_state.gy < (num_games+COLUMNS-1)/COLUMNS -1) {
						if (joy_wait != 1) {
							joy_wait = 1;
							if (isrotated()) { 
								flynn_state.gx--;
							}
							else { 
								flynn_state.gy++; 
							}							
							set_timer();
						}
					}
				}
			}
			break;
		case JS_EVENT_BUTTON:
			//printf("button %d pressed\n",joy_event.number);
			if (joy_event.number == 0) {
				temparg0 = "-ror";    
			}
			else {
				temparg0 = "-noror";
			}
			run_game();
			break;
		default:
			break;
	}
}
Ejemplo n.º 26
0
int utf8_main(int argc, char **argv)
{
	int game_index;
	char *ext;
	int res = 0;
	HMODULE library;

	// initialize common controls
	InitCommonControls();

	// set up exception handling
	pass_thru_filter = SetUnhandledExceptionFilter(exception_filter);

#ifndef WINUI
	// check for double-clicky starts
	if (check_for_double_click_start(argc) != 0)
		return 1;
#endif

	// see if we can use TryEnterCriticalSection
	try_enter_critical_section = NULL;
	library = LoadLibrary(TEXT("kernel32.dll"));
	if (library != NULL)
		try_enter_critical_section = (try_enter_critical_section_ptr)GetProcAddress(library, "TryEnterCriticalSection");


	strcpy(mapfile_name, argv[0]);
	ext = strchr(mapfile_name, '.');
	if (ext)
		strcpy(ext, ".map");
	else
		strcat(mapfile_name, ".map");

	// parse config and cmdline options
	game_index = cli_frontend_init(argc, argv);

	// have we decided on a game?
	if (game_index != -1)
	{
		TIMECAPS caps;
		MMRESULT result;

		// crank up the multimedia timer resolution to its max
		// this gives the system much finer timeslices
		result = timeGetDevCaps(&caps, sizeof(caps));
		if (result == TIMERR_NOERROR)
			timeBeginPeriod(caps.wPeriodMin);

		start_profiler();

		// run the game
		res = run_game(game_index);

		stop_profiler();

		// restore the timer resolution
		if (result == TIMERR_NOERROR)
			timeEndPeriod(caps.wPeriodMin);
	}

	// one last pass at events
	winwindow_process_events(0);

	// close errorlog, input and playback
	cli_frontend_exit();

	return res;
}
Ejemplo n.º 27
0
int main(int argc, char** argv){
	run_game(argc, argv);
	return 0;
}
Ejemplo n.º 28
0
static messtest_result_t run_test(int flags, struct messtest_results *results)
{
	int driver_num;
	messtest_result_t rc;
	clock_t begin_time;
	double real_run_time;

	/* lookup driver */
	for (driver_num = 0; drivers[driver_num]; driver_num++)
	{
		if (!mame_stricmp(current_testcase.driver, drivers[driver_num]->name))
			break;
	}

	/* cannot find driver? */
	if (!drivers[driver_num])
	{
		report_message(MSG_FAILURE, "Cannot find driver '%s'", current_testcase.driver);
		return MESSTEST_RESULT_STARTFAILURE;
	}

	/* prepare testing state */
	current_command = current_testcase.commands;
	state = STATE_READY;
	test_flags = flags;
	screenshot_num = 0;
	runtime_hash = 0;
	had_failure = FALSE;
	seen_first_update = FALSE;

	/* set up options */
	memset(&options, 0, sizeof(options));
	options.skip_disclaimer = 1;
	options.skip_gameinfo = 1;
	options.skip_warnings = 1;
	options.disable_normal_ui = 1;
	options.ram = current_testcase.ram;
	options.vector_intensity = 1.5;
	options.use_artwork = 1;
	options.samplerate = 44100;
	options.mame_debug = 1;

	/* preload any needed images */
	while(current_command->command_type == MESSTEST_COMMAND_IMAGE_PRELOAD)
	{
		options.image_files[options.image_count].name = current_command->u.image_args.filename;
		options.image_files[options.image_count].type = current_command->u.image_args.device_type;
		options.image_count++;
		current_command++;
	}

	/* perform the test */
	report_message(MSG_INFO, "Beginning test (driver '%s')", current_testcase.driver);
	begin_time = clock();
	if (setjmp(die_jmpbuf) == 0)
		run_game(driver_num);
	real_run_time = ((double) (clock() - begin_time)) / CLOCKS_PER_SEC;

	/* what happened? */
	switch(state)
	{
		case STATE_ABORTED:
			report_message(MSG_FAILURE, "Test aborted");
			rc = MESSTEST_RESULT_RUNTIMEFAILURE;
			break;

		case STATE_DONE:
			if (had_failure)
			{
				report_message(MSG_FAILURE, "Test failed (real time %.2f; emu time %.2f [%i%%])",
					real_run_time, final_time, (int) ((final_time / real_run_time) * 100));
				rc = MESSTEST_RESULT_RUNTIMEFAILURE;
			}
			else
			{
				report_message(MSG_INFO, "Test succeeded (real time %.2f; emu time %.2f [%i%%])",
					real_run_time, final_time, (int) ((final_time / real_run_time) * 100));
				rc = MESSTEST_RESULT_SUCCESS;
			}
			break;

		default:
			state = STATE_ABORTED;
			report_message(MSG_FAILURE, "Abnormal termination");
			rc = MESSTEST_RESULT_STARTFAILURE;
			break;
	}

	if (results)
	{
		results->rc = rc;
		results->runtime_hash = runtime_hash;
	}
	return rc;
}
Ejemplo n.º 29
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);
}
Ejemplo n.º 30
0
bool retro_load_game(const struct retro_game_info *game)
{
    // Find game index
    driverIndex = getDriverIndex(game->path);
    
    if(driverIndex)
    {
        fallbackDir = strdup(game->path);
        int orientation;
        unsigned rotateMode;
        static const int uiModes[] = {ROT0, ROT90, ROT180, ROT270};
        
        /* Get system directory from frontend */
        environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY,&systemDir);
        if (systemDir == NULL || systemDir[0] == '\0')
        {
            /* if non set, use old method */
            systemDir = normalizePath(fallbackDir);
            systemDir = peelPathItem(systemDir);
        }
        
        /* Get save directory from frontend */
        environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY,&saveDir);
        if (saveDir == NULL || saveDir[0] == '\0')
        {
            /* if non set, use old method */
            saveDir = normalizePath(fallbackDir);
            saveDir = peelPathItem(saveDir);
        }

        // Get ROM directory
        romDir = normalizePath(fallbackDir);
        romDir = peelPathItem(romDir);

        // Setup Rotation
        orientation = drivers[driverIndex]->flags & ORIENTATION_MASK;
        rotateMode = 0;
        
        rotateMode = (orientation == ROT270) ? 1 : rotateMode;
        rotateMode = (orientation == ROT180) ? 2 : rotateMode;
        rotateMode = (orientation == ROT90) ? 3 : rotateMode;
        
        environ_cb(RETRO_ENVIRONMENT_SET_ROTATION, &rotateMode);

        // Set all options before starting the game
        options.samplerate = sample_rate;
        options.ui_orientation = uiModes[rotateMode];
        options.vector_intensity = vector_intensity;
        options.vector_antialising = vector_antialising;
        options.beam = vector_beam;
        options.vector_flicker = vector_flicker;
        options.vector_translucency = vector_translucency;
        options.skip_disclaimer = skip_disclaimer;
        options.skip_warnings = skip_warnings;
        options.use_samples = samples;
        options.cheat = cheats;

        // Boot the emulator
        return run_game(driverIndex) == 0;
    }
    else
    {
        return false;
    }
}