Esempio n. 1
0
void set_store_hs(void)
{
    const struct set *s = SET_GET(sets, curr);
    fs_file fp;

    if ((fp = fs_open(config_cheat() ? s->cheat_scores : s->user_scores, "w")))
    {
        int i;

        fs_printf(fp, "version %d\nset %s\n", SCORE_VERSION, s->id);

        put_score(fp, &s->time_score);
        put_score(fp, &s->coin_score);

        for (i = 0; i < s->count; i++)
        {
            const struct level *l = &level_v[i];

            int flags = 0;

            if (l->is_locked)    flags |= LEVEL_LOCKED;
            if (l->is_completed) flags |= LEVEL_COMPLETED;

            fs_printf(fp, "level %d %d %s\n", flags, l->version_num, l->file);

            put_score(fp, &l->scores[SCORE_TIME]);
            put_score(fp, &l->scores[SCORE_GOAL]);
            put_score(fp, &l->scores[SCORE_COIN]);
        }

        fs_close(fp);
    }
}
Esempio n. 2
0
void display_all_gdesc(struct bgdt_t *gdescs, int cnt)
{
    int i;
    fs_printf("\ngdescs: \n");
    for(i = 0; i < cnt; i++) {
        fs_printf("the %dth gdesc: \n", i);
        display_gdesc(gdescs + i);
        fs_printf("\n");
    }
}
Esempio n. 3
0
void display_inode(struct inode_t *inode)
{
    fs_printf("i_blocks: %d\n", inode->i_blocks);
    fs_printf("i_mode: %d\n", inode->i_mode);

    fs_printf("imode: 0x%x\n", inode->i_mode);
    if(inode->i_mode & EXT2_S_IFDIR) {
        fs_printf("yes root is a directory!\n");
    } else {
        fs_printf("Oops, root should be a directory!\n");
    }
}
Esempio n. 4
0
static void put_score(fs_file fp, const struct score *s)
{
    int i;

    for (i = RANK_HARD; i <= RANK_EASY; i++)
        fs_printf(fp, "%d %d %s\n", s->timer[i], s->coins[i], s->player[i]);
}
Esempio n. 5
0
void display_gdesc(struct bgdt_t *gdesc)
{
    fs_printf("bg_used_dirs_count: %d\n", gdesc->bg_used_dirs_count);
    fs_printf("bg_free_inodes_count: %d\n", gdesc->bg_free_inodes_count);
    fs_printf("bg_free_blocks_count: %d\n", gdesc->bg_free_blocks_count);
    fs_printf("bg_inode_table: %d\n", gdesc->bg_inode_table);
    fs_printf("bg_inode_bitmap: %d\n", gdesc->bg_inode_bitmap);
    fs_printf("bg_block_bitmap: %d\n", gdesc->bg_block_bitmap);
}
Esempio n. 6
0
File: main.c Progetto: kikimo/ext2fs
int main(int argc, char **argv)
{
    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);

    fuse_opt_parse(&args, NULL, NULL, fuse_ext2_opt_args);

    if(ext2_dev) {
        if(fuse_ext2_init(ext2_dev) == -1) {
            fs_printf("unable to initialize disk device.\n");
            return -1;
        }        
    } else {
        // TODO
    }

    return (fuse_main(args.argc, args.argv, &fuse_ext2_ops, NULL)); 
}
Esempio n. 7
0
static int g_write (lua_State *L, int f, int arg) {
  int nargs = lua_gettop(L) - 1;
  int status = 1;
  for (; nargs--; arg++) {
#if 0
    if (lua_type(L, arg) == LUA_TNUMBER) {
      /* optimization: could be done exactly as for strings */
      status = status &&
          fs_printf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0;
    }
    else 
#endif
    {
      size_t l;
      const char *s = luaL_checklstring(L, arg, &l);
      status = status && (fs_write(f, s, l) == l);
    }
  }
  return pushresult(L, status, NULL);
}
Esempio n. 8
0
void config_save(void)
{
    fs_file fh;

    if (dirty && (fh = fs_open(USER_CONFIG_FILE, "w")))
    {
        int i;

        /* Write out integer options. */

        for (i = 0; i < ARRAYSIZE(option_d); i++)
        {
            const char *s = NULL;

            /* Translate some integers to strings. */

            if (i == CONFIG_MOUSE_CAMERA_1      ||
                i == CONFIG_MOUSE_CAMERA_2      ||
                i == CONFIG_MOUSE_CAMERA_3      ||
                i == CONFIG_MOUSE_CAMERA_TOGGLE ||
                i == CONFIG_MOUSE_CAMERA_L      ||
                i == CONFIG_MOUSE_CAMERA_R)
            {
                s = config_mouse_name(option_d[i].cur);
            }
            else if (i == CONFIG_KEY_FORWARD       ||
                     i == CONFIG_KEY_BACKWARD      ||
                     i == CONFIG_KEY_LEFT          ||
                     i == CONFIG_KEY_RIGHT         ||
                     i == CONFIG_KEY_CAMERA_1      ||
                     i == CONFIG_KEY_CAMERA_2      ||
                     i == CONFIG_KEY_CAMERA_3      ||
                     i == CONFIG_KEY_CAMERA_TOGGLE ||
                     i == CONFIG_KEY_CAMERA_R      ||
                     i == CONFIG_KEY_CAMERA_L      ||
                     i == CONFIG_KEY_PAUSE         ||
                     i == CONFIG_KEY_RESTART       ||
                     i == CONFIG_KEY_SCORE_NEXT    ||
                     i == CONFIG_KEY_ROTATE_FAST)
            {
                s = SDL_GetKeyName((SDLKey) option_d[i].cur);
            }
            else if (i == CONFIG_CHEAT)
            {
                if (!config_cheat())
                    continue;
            }

            if (s)
                fs_printf(fh, "%-25s %s\n", option_d[i].name, s);
            else
                fs_printf(fh, "%-25s %d\n", option_d[i].name, option_d[i].cur);
        }

        /* Write out string options. */

        for (i = 0; i < ARRAYSIZE(option_s); i++)
        {
            if (option_s[i].cur && *option_s[i].cur)
                fs_printf(fh, "%-25s %s\n", option_s[i].name, option_s[i].cur);
        }

        fs_close(fh);
    }

    dirty = 0;
}
Esempio n. 9
0
DSTATUS disk_initialize (
	BYTE drv				/* Physical drive nmuber (0..) */
)
{
	SD_CardInfo mSDCardInfo;	/* 定义SD卡状态信息结构体 */
	uint32_t DeviceSizeMul = 0, NumberOfBlocks = 0;	
	uint16_t Status;

	switch(drv)
	{
	 case SD_CARD://SD卡
	//SD卡初始化--------------------------------------------------------------------------
				Status = SD_Init();
				if (Status != SD_OK)	
				{
					fs_printf("SD_Init() fail (%d) : file %s on line %d\r\n", Status, __FILE__, __LINE__);
					goto retfail;
				}
			
				SD_GetCardInfo(&mSDCardInfo);	/* 读取SD卡的信息 */
				SD_SelectDeselect((uint32_t) (mSDCardInfo.RCA << 16));
				DeviceSizeMul = (mSDCardInfo.SD_csd.DeviceSizeMul + 2);
				
				if (mSDCardInfo.CardType == SDIO_HIGH_CAPACITY_SD_CARD)	/* 高容量SD卡 SDHC */
				{
					Mass_Block_Count = (mSDCardInfo.SD_csd.DeviceSize + 1) * 1024;
				}
				else	/* 普通SD卡, 最大4G */
				{
					NumberOfBlocks  = ((1 << (mSDCardInfo.SD_csd.RdBlockLen)) / 512);
					Mass_Block_Count = ((mSDCardInfo.SD_csd.DeviceSize + 1) * (1 << DeviceSizeMul) << (NumberOfBlocks/2));
				}
				
				Status = SD_SelectDeselect((uint32_t) (mSDCardInfo.RCA << 16)); 
				Status = SD_EnableWideBusOperation(SDIO_BusWide_4b); 
				if (Status != SD_OK)
				{
					fs_printf("SD_EnableWideBusOperation(SDIO_BusWide_4b) Fail (%d)\r\n", Status);
					goto retfail;
				}
				
				Status = SD_SetDeviceMode(SD_DMA_MODE);    /* 设置SD卡工作模式为DMA, 其它模式由中断、轮询 */     
				if (Status != SD_OK)
				{
					fs_printf("SD_SetDeviceMode(SD_DMA_MODE) Fail (%d)\r\n", Status);				
					goto retfail;
				} 
			
				/* 显示容量 */
				Mass_Block_Size  = 512;
				if (mSDCardInfo.CardType == SDIO_HIGH_CAPACITY_SD_CARD)	/* 高容量SD卡 SDHC */
				{	
					fs_printf("SDHC Card, Memory Size = %uMB\r\n", Mass_Block_Count / (1024 * 4));
				}
				else
				{
					fs_printf("Normal Card, Memory Size = %uMB\r\n", (Mass_Block_Count * Mass_Block_Size) /(1024*1024));
				}

	//SD卡初始化结束--------------------------------------------------------------------------
				break;

	case EX_FLASH://外部flash
			SPI_Flash_Init();
			if(SPI_FLASH_TYPE==W25Q64)FLASH_SECTOR_COUNT=2048*6;//W25Q64
			else FLASH_SECTOR_COUNT=2048*2;						//其他
 			break;
	default:
			goto retfail;
	}
			
	return RES_OK;
retfail:	
	return RES_ERROR;
}