void fatfs_init(unsigned char prio)
{
	FRESULT fret;
	
	raw_printf("FatFs init...\r\t\t\t\t");
	disk_initialize(0);
	fret = f_mount(&_FS, _T("0"), 0);
	if(FR_OK != fret)
	{
		RAW_ASSERT(0);
	}
	raw_printf("[OK]\n");
	
//	if( need_format(0) )
	if(1)
	{
		raw_printf("mkfs ...\r\t\t\t\t");
		fret = f_mkfs(_T("0:"), 0, 512);
		if(FR_OK != fret)
		{
			RAW_ASSERT(0);
		}
		raw_printf("[OK]\n");
	}
}
示例#2
0
文件: gl_role.c 项目: Arc0re/acehack
void Sdlgl_player_selection(void)
{
  /* -AJA- Note that the initrole, initrace, initgend and initalign
   *       fields of the `flag' global have been set to ROLE_NONE in
   *       the initoptions() routine in src/options.c.  Those values
   *       may then be updated by the system code (sys/unixmain.c)
   *       depending on command line options.
   */
 
  int pick4u = 0;

  /* avoid unnecessary prompts further down */
  do_random_role_checks();
  rigid_role_checks();

  if (select_auto_pick(&pick4u) < 0)
    sdlgl_error("Quit from pick-for-you prompt.\n");

  for (;;)
  {
    if (select_a_role(pick4u) < 0)
      sdlgl_error("Quit from player selection menu.\n");

    if (select_a_race(pick4u) < 0)
      continue;

    if (select_a_gender(pick4u) < 0)
      continue;

    if (select_an_alignment(pick4u) < 0)
      continue;

    break;
  }

  if (flags.initrole < 0 || flags.initrace < 0 ||
      flags.initgend < 0 || flags.initalign < 0)
  {
    raw_printf("WARNING: failed to select a valid character !  "
        "(%d,%d,%d,%d)\n", flags.initrole, flags.initrace,
        flags.initgend, flags.initalign);

    /* do nothing -- let init_role() deal with it */
  }
}
示例#3
0
enum nh_restore_status nh_restore_game(int fd, struct nh_window_procs *rwinprocs,
				       boolean force_replay)
{
    int playmode, irole, irace, igend, ialign;
    char namebuf[PL_NSIZ];
    
    /* some compilers can't cope with the fact that all subsequent stores to error
     * are not dead, but become important if the error handler longjumps back
     * volatile is required to prevent invalid optimization based on that wrong
     * assumption. */
    volatile enum nh_restore_status error = GAME_RESTORED;
    
    if (fd == -1)
	return ERR_BAD_ARGS;
    
    switch (nh_get_savegame_status(fd, NULL)) {
	case LS_INVALID:	return ERR_BAD_FILE;
	case LS_DONE:		return ERR_GAME_OVER;
	case LS_CRASHED:	force_replay = TRUE; break;
	case LS_IN_PROGRESS:	return ERR_IN_PROGRESS;
	case LS_SAVED:		break; /* default, everything is A-OK */
    }
    
    if (!api_entry_checkpoint())
	goto error_out;
    
    error = ERR_BAD_FILE;
    replay_set_logfile(fd); /* store the fd and try to get a lock or exit */
    replay_begin();

    program_state.restoring = TRUE;
    iflags.disable_log = TRUE; /* don't log any of the commands, they're already in the log */

    /* Read the log header for this game. */
    replay_read_newgame(&turntime, &playmode, namebuf,
			&irole, &irace, &igend, &ialign);

    /* set special windowprocs which will autofill requests for user input
     * with data from the log file */
    replay_setup_windowprocs(rwinprocs);

    startup_common(namebuf, playmode);
    u.initrole = irole;
    u.initrace = irace;
    u.initgend = igend;
    u.initalign = ialign;

    if (!force_replay) {
	error = ERR_RESTORE_FAILED;
	replay_run_cmdloop(TRUE, FALSE, TRUE);
	replay_jump_to_endpos();
	if (!dorecover_fd(fd)) {
	    replay_undo_jump_to_endpos();
	    goto error_out2;
	}
	replay_undo_jump_to_endpos();
	wd_message();
	program_state.game_running = 1;
	post_init_tasks();
    } else {
	replay_run_cmdloop(TRUE, TRUE, FALSE); /* option setup only */
	newgame();
	/* try replaying instead */
	error = ERR_REPLAY_FAILED;
	replay_run_cmdloop(FALSE, FALSE, TRUE);
	replay_sync_save();
    }
    
    /* restore standard window procs */
    replay_restore_windowprocs();
    program_state.restoring = FALSE;
    iflags.disable_log = FALSE;

    /* clean up data used for replay */
    replay_end();
    log_truncate();
    log_init(); /* must be called before we start writing to the log */

    /* info might not have reached the ui while alternate window procs were set */
    doredraw();

    /* nh_start_game() does this via newgame(), but since this function doesn't
     * call newgame(), we have to do it here instead. */
    notify_levelchange(NULL);

    bot();
    flush_screen();
    was_on_elbereth = !sengr_at("Elbereth", u.ux, u.uy); /* force botl update later */

    welcome(FALSE);
    realtime_messages(TRUE, TRUE);
    update_inventory();
    
    api_exit();
    return GAME_RESTORED;

error_out2:
    api_exit();
    
error_out:
    replay_restore_windowprocs();
    program_state.restoring = FALSE;
    iflags.disable_log = FALSE;
    replay_end();
    unlock_fd(fd);
    
    if (error == ERR_RESTORE_FAILED) {
	raw_printf("Restore failed. Attempting to replay instead.\n");
	error = nh_restore_game(fd, rwinprocs, TRUE);
    }
    
    return error;
}