#define ENTER 13 //
#define UP 20      //
#define DOWN 21      //
#define RIGHT 22      //
#define LEFT 23      //
#define ESC 27  //[]
#define UPUP 19      //Ϸҳ(˫ϼ)
#define DOWNDOWN 14       //·ҳ(˫¼)
#define F1 28     //[]
#define F2 29     //[ɾ]
#define F3 30     //[]
#define F4 31     //[޸]
#define HELP 25 //[]
#define SHIFT 26//[Ӣ]
#define CAPS 18  //[뷨]
#define SOUND 15//        17

char filepath[61],filename[20],fp,filetype[4];
int topage,i,page;
long filesize;

char File(int filepathtmp,int filenametmp)
{
char Filepathtmp[61];
char Filenametmp[20];
int tmp;
ChDir("/");
strcpy(Filepathtmp,"/");
tmp=0;
for(;;)
    {
        if(!FileList(Filenametmp) || !strcmp(Filenametmp,".."))
           {tmp--;
           if (tmp<0)exit(1);
           Filepathtmp[strlen(Filepathtmp)-1]=0;
           for(;Filepathtmp[strlen(Filepathtmp)-1]!='/';)
             Filepathtmp[strlen(Filepathtmp)-1]=0;
           ChDir("..");
           continue ;
           }
        if(ChDir(Filenametmp))
          {
          tmp++;
          strcat(Filepathtmp,Filenametmp);
          strcat(Filepathtmp,"/");
          continue ;
          }else tmp--;
        strcat(Filepathtmp,Filenametmp);
        strcpy(filepathtmp,Filepathtmp);
        strcpy(filenametmp,Filenametmp);
        return 1;
   }
}

void fileatter()
{
SetScreen(0);
Locate(0,0);
printf("ļ:%s\nͼƬҳ:%d\nļС:%d",filename,topage+1,filesize);
getchar();
}

void main()
{

for (;;)
    {
    if (!File(filepath,filename))continue;
    if ((fp=fopen(filename,"rb+"))==0)
       {
       SetScreen(0);
       Locate(2,3);
       printf("ļ򿪴");
       getchar();
       continue;
       }
    fread(filetype,1,3,fp);
    if (strcmp(filetype,"B16"))
       {
       SetScreen(0);
       Locate(2,3);
       printf("B16ļ!");
       fclose(fp);
       getchar();
       continue;
       }
    fseek(fp,4,0);
    fread(&i,1,1,fp);
    topage=i-1;
    fseek(fp,0,2);
    filesize=ftell(fp);
    fileatter();
    for (page=0;;)
       {
       for (i=0;i<=14;i++)
           {
           fseek(fp,i*1600+20+page*15*1600,0);
           fread(_GRAPH,1,1600,fp);
           }
       if(i=Inkey())
           {
           ClearScreen();
           Refresh();
           if (i==DOWN)
               {
               if (page==topage)page=0;
               else page++;
               }
           if (i==UP)
               {
               if (page)page--;
               else page=topage;
               }
           if (i==ESC)
               {
               break;
               }
           if (i==ENTER)
               {
               fileatter();
               }
           if (i==HELP)
               {
               SetScreen(0);
               printf("***** ߰ *****  ");
               getchar();
               }
           }
        }
    }
fclose(fp);
}               