Ejemplo n.º 1
0
FRESULT pf_open (
	const char *path	/* Pointer to the file name */
)
{
	FRESULT res;
	DIR dj;
	BYTE sp[12], dir[32];
	FATFS *fs = FatFs;


	if (!fs) return FR_NOT_ENABLED;		/* Check file system */

	fs->flag = 0;
	dj.fn = sp;
	res = follow_path(&dj, dir, path);	/* Follow the file path */
	if (res != FR_OK) return res;		/* Follow failed */
	if (!dir[0] || (dir[DIR_Attr] & AM_DIR))	/* It is a directory */
		return FR_NO_FILE;

	fs->org_clust = get_clust(dir);		/* File start cluster */
	fs->fsize = LD_DWORD(dir+DIR_FileSize);	/* File size */
	fs->fptr = 0;						/* File pointer */
	fs->flag = FA_OPENED;

	return FR_OK;
}
Ejemplo n.º 2
0
FRESULT pf_open (
	const char *path	/* Pointer to the file name */
)
{
	FRESULT res;
	DIR dj;
	BYTE sp[12], dir[32];
	FATFS *fs = FatFs;


	if (!fs)						/* Check file system */
		return FR_NOT_ENABLED;

	fs->flag = 0;
	fs->buf = dir;
	dj.fn = sp;
	res = follow_path(&dj, path);	/* Follow the file path */
	if (res != FR_OK) return res;	/* Follow failed */
	if (!dir[0] || (dir[DIR_Attr] & AM_DIR))	/* It is a directory */
		return FR_NO_FILE;

	fs->org_clust =						/* File start cluster */
#if _FS_FAT32
		((DWORD)LD_WORD(dir+DIR_FstClusHI) << 16) |
#endif
		LD_WORD(dir+DIR_FstClusLO);
	fs->fsize = LD_DWORD(dir+DIR_FileSize);	/* File size */
	fs->fptr = 0;						/* File pointer */
	fs->flag = FA_READ;

	return FR_OK;
}
Ejemplo n.º 3
0
FRESULT pf_opendir (
	DIR *dj,			/* Pointer to directory object to create */
	const char *path	/* Pointer to the directory path */
)
{
	FRESULT res;
	BYTE sp[12], dir[32];
	FATFS *fs = FatFs;


	if (!fs) {				/* Check file system */
		res = FR_NOT_ENABLED;
	} else {
		dj->fn = sp;
		res = follow_path(dj, dir, path);		/* Follow the path to the directory */
		if (res == FR_OK) {						/* Follow completed */
			if (dir[0]) {						/* It is not the root dir */
				if (dir[DIR_Attr] & AM_DIR)		/* The object is a directory */
					dj->sclust = get_clust(dir);
				else							/* The object is not a directory */
					res = FR_NO_FILE;
			}
			if (res == FR_OK)
				res = dir_rewind(dj);			/* Rewind dir */
		}
	}

	return res;
}
Ejemplo n.º 4
0
void baiter_enemy(void)
{
	OBJECT *obj=current_proc->pa8;
	short ta4;

	/* be_e1 */
	do
	{
		obj->oxpos.u.intpos=wave_x_position+(short)obj->ochar;
		obj->oypos.u.intpos=wave_y_position+(short)obj->oid;
		obj->oxvel.u.intpos=wave_x_velocity;
		obj->oyvel.u.intpos=wave_y_velocity;
		if (are_we_shot()==SYSTEM_CARRY_SET)
			be_9d;

		if (are_we_hitting_player()!=0)
		{
			kill_player();
			be_9d;
		}

		/* be_e3 */
		process_sleep(1);
		if (randper(dive_randper)==SYSTEM_CARRY_SET)
		{
			if (follow_path(srandarc(SCX(0x20000)),SCY(0x12000)+srandarc(SCY(0x2000)),be_pr)==SYSTEM_CARRY_SET)
				be_99;
			else obj->oypos.u.intpos=-5;

			/* be_e5 */
			do
			{
				ta4=move_to_point(wave_x_position+(short)obj->ochar,wave_y_position+(short)obj->oid,2);
				if (ta4<2)
					break;

				process_sleep(1);
				if (are_we_shot()==SYSTEM_CARRY_SET)
					be_9d;

				if (are_we_hitting_player()!=0)
				{
					kill_player();
					be_9d;
				}

			}
			while(1);
		}
	}
	while(1);
}
void CALifeMonsterDetailPathManager::update					(const ALife::_TIME_ID &time_delta)
{
	// first update has enormous time delta, therefore just skip it
	if (!m_last_update_time)
		return;

	if (completed())
		return;

	if (!actual()) {
		actualize					();

		if (failed())
			return;
	}

	follow_path						(time_delta);
}
Ejemplo n.º 6
0
FRESULT pf_opendir (
	DIR *dj,			/* Pointer to directory object to create */
	const char *path	/* Pointer to the directory path */
)
{
	FRESULT res;
	BYTE sp[12], dir[32];
	FATFS *fs = FatFs;


	if (!fs) {				/* Check file system */
		res = FR_NOT_ENABLED;
	} else {
		fs->buf = dir;
		dj->fn = sp;
		res = follow_path(dj, path);			/* Follow the path to the directory */
		if (res == FR_OK) {						/* Follow completed */
			if (dir[0]) {						/* It is not the root dir */
				if (dir[DIR_Attr] & AM_DIR) {	/* The object is a directory */
					dj->sclust =
#if _FS_FAT32
					((DWORD)LD_WORD(dir+DIR_FstClusHI) << 16) |
#endif
					LD_WORD(dir+DIR_FstClusLO);
				} else {						/* The object is not a directory */
					res = FR_NO_PATH;
				}
			}
			if (res == FR_OK) {
				res = dir_rewind(dj);			/* Rewind dir */
			}
		}
		if (res == FR_NO_FILE) res = FR_NO_PATH;
	}

	return res;
}
Ejemplo n.º 7
0
int main() {
	connect_to_robot();
	initialize_robot();
	set_origin();

	printf("Ghandy-Bot activated, destroy!!!\n");

	//Set front IR sensors to to face left and right
	set_ir_angle(LEFT, -45);
    set_ir_angle(RIGHT, 45);

	init_map();
    print_map();

	robot.map[1][1].walls[0] = 1;
    robot.map[1][2].walls[2] = 1;

    robot.map[1][1].walls[1] = 1;
    robot.map[2][1].walls[3] = 1;

    robot.map[1][3].walls[2] = 1;
    robot.map[1][2].walls[0] = 1;

    robot.map[0][4].walls[2] = 1;
    robot.map[0][3].walls[0] = 1;

    robot.map[3][4].walls[3] = 1;
    robot.map[2][4].walls[1] = 1;

    robot.map[3][2].walls[2] = 1;
    robot.map[3][1].walls[0] = 1;

    robot.map[3][2].walls[3] = 1;
    robot.map[2][2].walls[1] = 1;
    int i;
    for(i=1;i<=4;i++)
        robot.map[0][i].walls[3] = 1;
   	for(i=1;i<=4;i++)
        robot.map[i][1].walls[2] = 1;
    for(i=1;i<=4;i++)
        robot.map[3][i].walls[1] = 1; 
    print_map();
    /* Phase 1 */

    //Perform depth first search on maze
    //dfs(0, 0, M_PI / 2);

    /* Phase 2 */
    lee(0,1); //Update matrix with Lee costs from node [0,1]

    /* Generate shortest path to node [3,4] (finish line) */
    generate_path(3,4); 

    follow_path(); //Follow the generated path to finish

    //Phew, did we win???

	printf("Ghandy-Bot deactivated!\n");

	return 0;
}
Ejemplo n.º 8
0
WORD follow_path_11(PATHPTR *pa10)
{
	return(follow_path(0x10000,0x10000,pa10));
}