home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a014 / 1.ddi / CDBINC.EXE / TSYSBS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-27  |  12.3 KB  |  386 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include <string.h>
  5. #include "system.c"
  6. #include "system2.c"
  7. char scr[10][250];
  8. int x,y;
  9. int curr,curc;
  10. int Ins,width;
  11. char *level[11];
  12. int count3;
  13. main(argc,argv)
  14. int argc;
  15. char *argv[];
  16. {
  17.     int dow[2],dol[2];
  18.     int dcount1,dcount2;
  19.     int i,j,m,n,hanzi;
  20.     int srow[2],scol[2];
  21.     int logic;
  22.     char mid[250],c1,c2;
  23.     int charact;
  24.     FILE *fp;
  25.     level[0]="⌐º";level[1]="⌐Ñ";level[2]="⌐∩";
  26.     level[3]="⌐╫";level[4]="⌐╟";level[5]="⌐╧";
  27.     level[6]="⌐▀";level[7]="⌐│";level[8]="⌐╖";
  28.     level[9]="⌐╗";level[10]="⌐┐"; width=250;
  29.     dcount1=dcount2=0; curr=0; curc=0;  Ins=0;
  30.     x=0; y=0; setcursor(x,y);
  31.     for (i=0;i<10;i++)
  32.     for (j=0;j<250;j++)
  33.         scr[i][j]='\n';
  34.     if ((fp=fopen(argv[1],"r"))!=NULL)
  35.        while (fgets(mid,250,fp)!=NULL)
  36.          {
  37.          for (i=0;i<9;i++)
  38.          for (j=0;j<width;j++)
  39.              scr[i][j]=scr[i+1][j];
  40.          for (j=0;j<width;j++)
  41.          scr[9][j]='\n';
  42.          sscanf(mid,"#%[^#]#",scr[9]);
  43.          }
  44.     fclose(fp);
  45.     for (x=0;x<10;x++) {
  46.     setcursor(x,0);
  47.     for (y=0;y<78;y++) {
  48.         if (scr[curr+x][y]!='\n') printf("%c",scr[curr+x][y]);
  49.         else printf(" ");
  50.         }
  51.     }
  52.     count3=0;
  53.     setcursor(0,0); display();
  54.     while ((charact=getchb())!=27){       switch (charact){
  55.        case 12:getcursor(&x,&y);
  56.            if ((curc+y)%2==1){
  57.       setcursor(24,0);printf("╣Γ ▒Ω ┴╨ ╩² ▒╪ ╨δ ╬¬ ┼╝ ╩²ú");
  58.           printf("╝ⁿ ╚╬ ╥Γ ╝ⁿ ╝╠ ╨° ...");
  59.       getchb();setcursor(x,y);display();break;}
  60.       srow[count3]=x+curr;scol[count3++]=curc+y;
  61.       if (count3!=2) break;
  62.       if (srow[0]>srow[1])
  63.          {i=srow[0]; srow[0]=srow[1]; srow[1]=i;}
  64.       if (scol[0]>scol[1])
  65.          {i=scol[0]; scol[1]=scol[0]; scol[1]=i;}
  66.       for (m=srow[0];m<=srow[1];m++)
  67.           for (n=0;n<=scol[1]+1;n++)
  68.           if (scr[m][n]=='\n') scr[m][n]=' ';
  69.       if (srow[0]==srow[1]){
  70.          lline(srow[0],scol[0],scol[1]);count3=0;continue;}
  71.       if (scol[1]==scol[0]){
  72.          hline(scol[0],srow[0],srow[1]);count3=0;continue;}
  73.       hline(scol[1],srow[0],srow[1]);
  74.       hline(scol[0],srow[0],srow[1]);
  75.       lline(srow[1],scol[0],scol[1]);
  76.           lline(srow[0],scol[0],scol[1]);
  77.       count3=0;
  78.       display(); break;
  79.        case 20:getcursor(&x,&y);
  80.            if ((y+curc)%2==1){
  81.       setcursor(24,0);
  82.       printf("╣Γ ▒Ω ┴╨ ╩² ▒╪ ╨δ ╬¬ ┼╝ ╩²ú¼ ╝ⁿ ╚╬ ╥Γ ╝ⁿ ╝╠ ╨° ...          ");
  83.       getchb();setcursor(x,y);display();break;}
  84.                dow[dcount2]=curr+x;dol[dcount2++]=curc+y;
  85.            if (((dcount2%2)==0)&&(dol[0]==dol[1])){
  86.       if (dow[0]>dow[1]){
  87.          i=dow[0];dow[0]=dow[1];dow[1]=i;}
  88.       for (i=dow[0];i<=dow[1];i++){
  89.          mid[0]=scr[i][dol[0]];mid[1]=scr[i][dol[0]+1];mid[2]='\0';
  90.          if (streq(mid,level[0])){
  91.         scr[i][dol[0]]=' ';scr[i][dol[0]+1]=' ';
  92.         continue;}
  93.          logic=0;
  94.          for (j=2;j<11;j++)
  95.              logic=logic||streq(mid,level[j]);
  96.          logic=logic||streq(mid,level[0]);
  97.          if (logic&&(i!=dow[0])&&(i!=dow[1])){        scr[i][dol[0]]=level[1][0];scr[i][dol[0]+1]=level[1][1];continue;}
  98.              if (i==dow[0]){
  99.             logic=streq(mid,level[3])||streq(mid,level[7])||streq(mid,level[8]);
  100.             if (logic){
  101.                scr[i][dol[0]]=level[1][0];scr[i][dol[0]+1]=level[1][1];continue;}
  102.                         if (streq(mid,level[2])){
  103.                scr[i][dol[0]]=level[6][0];scr[i][dol[0]+1]=level[6][1];continue;}
  104.             if (streq(mid,level[4])){
  105.                scr[i][dol[0]]=level[9][0];scr[i][dol[0]+1]=level[9][1];continue;}
  106.             if (streq(mid,level[5])){
  107.                scr[i][dol[0]]=level[10][0];scr[i][dol[0]+1]=level[10][1];continue;}
  108.             }
  109.          if (i==dow[1]){
  110.             logic=streq(mid,level[6])||streq(mid,level[9])||streq(mid,level[10]);
  111.             if (logic){
  112.                scr[i][dol[0]]=level[1][0];scr[i][dol[0]+1]=level[1][1];continue;}
  113.             if (streq(mid,level[2])){
  114.                scr[i][dol[0]]=level[3][0];scr[i][dol[0]+1]=level[3][1];continue;}
  115.             if (streq(mid,level[4])){
  116.                scr[i][dol[0]]=level[7][0];scr[i][dol[0]+1]=level[7][1];continue;}
  117.             if (streq(mid,level[5])){
  118.                scr[i][dol[0]]=level[8][0];scr[i][dol[0]+1]=level[8][1];continue;}
  119.             }
  120.                   }
  121.                if (dow[0]<curr){
  122.       for (i=curr;i<=dow[1];i++){
  123.          setcursor(i-curr,dol[0]-curc);
  124.          printf("%c%c",scr[i][dol[0]],scr[i][dol[0]+1]);}     }
  125.                if (dow[1]>curr+8){
  126.       for (i=dow[0];i<curr+19;i++){
  127.           setcursor(i-curr,dol[0]-curc);
  128.           printf("%c%c",scr[i][dol[0]],scr[i][dol[0]+1]);}
  129.       }
  130.                if (dow[0]>=curr&&dow[1]<=curr+8){
  131.       for (i=dow[0];i<=dow[1];i++){
  132.           setcursor(i-curr,dol[0]-curc);
  133.           printf("%c%c",scr[i][dol[0]],scr[i][dol[0]+1]);}
  134.       }
  135.                dcount2=0;}
  136.            if (dcount2%2==0&&dol[0]!=dol[1]) dcount2=0;
  137.                display();break;
  138.        case  4:getcursor(&x,&y);
  139.            if ((y+curc)%2==1){
  140.       setcursor(24,0);
  141.       printf("╣Γ ▒Ω ┴╨ ╩² ▒╪ ╨δ ╬¬ ┼╝ ╩²ú¼╝ⁿ ╚╬ ╥Γ ╝ⁿ ╝╠ ╨δ ...           ");
  142.       getchb();setcursor(x,y);display();break;}
  143.                dow[dcount1]=curr+x;dol[dcount1++]=curc+y;
  144.                if (((dcount1%2)==0)&&(dow[0]==dow[1])){
  145.      if (dol[0]>dol[1]){
  146.         i=dol[0];dol[0]=dol[1];dol[1]=i;}
  147.                  for (i=dol[0];i<=dol[1];i=i+2){
  148.       mid[0]=scr[dow[0]][i];mid[1]=scr[dow[1]][i+1];mid[2]='\0';
  149.       if (streq(mid,level[1])){
  150.          scr[dow[0]][i]=' ';scr[dow[0]][i+1]=' ';continue;}
  151.       logic=0;          for(j=2;j<11;j++)
  152.          logic=logic||streq(mid,level[j]);
  153.       if (logic&&(i!=dol[0])&&(i!=dol[1])){
  154.          scr[dow[0]][i]=level[0][0];scr[dow[0]][i+1]=level[0][1];continue;}
  155.       if (i==dol[0]){
  156.                      logic=streq(mid,level[4])||streq(mid,level[7])||streq(mid,level[9]);
  157.                      if (logic){
  158.             scr[dow[0]][i]=level[0][0];scr[dow[0]][i+1]=level[0][1];continue;}
  159.                      if (streq(mid,level[2])){
  160.             scr[dow[0]][i]=level[5][0];scr[dow[0]][i+1]=level[5][1];continue;}
  161.          if (streq(mid,level[3])){
  162.             scr[dow[0]][i]=level[8][0];scr[dow[0]][i+1]=level[8][1];continue;}
  163.          if (streq(mid,level[6])){
  164.             scr[dow[0]][i]=level[10][0];scr[dow[0]][i+1]=level[10][1];continue;}
  165.          }
  166.       if (i==dol[1]){
  167.          logic=streq(mid,level[5])||streq(mid,level[8])||streq(mid,level[10]);
  168.          if (logic){
  169.             scr[dow[0]][i]=level[0][0];scr[dow[0]][i+1]=level[0][1];continue;}
  170.          if (streq(mid,level[2])){
  171.             scr[dow[0]][i]=level[4][0];scr[dow[0]][i+1]=level[4][1];continue;}
  172.          if (streq(mid,level[6])){
  173.             scr[dow[0]][i]=level[9][0];scr[dow[0]][i+1]=level[9][1];continue;}
  174.          if (streq(mid,level[3])){
  175.             scr[dow[0]][i]=level[7][0];scr[dow[0]][i+1]=level[7][1];continue;}
  176.          }
  177.                }           if  (dol[0]<curc){
  178.        i=curc; setcursor(dow[0]-curr,i-curc);
  179.        while (i<=dol[1]+1){
  180.           printf("%c",scr[dow[0]][i++]);}
  181.        }
  182.                if  (dol[1]>curc+79){
  183.        setcursor(dow[0]-curr,dol[0]-curc);
  184.        for (i=dol[0];i<curc+80;i++)
  185.             printf("%c",scr[dow[0]][i]);
  186.        }
  187.                if ((dol[0]>=curc)&&(dol[1]<=curc+79)){
  188.        setcursor(dow[0]-curr,dol[0]-curc);
  189.        for (i=dol[0];i<=dol[1]+1;i++)
  190.           printf("%c",scr[dow[0]][i]);
  191.        }
  192.                dcount1=0;}
  193.                if ((dcount1%2==0)&&(dow[0]!=dow[1])) dcount1=0;
  194.            display(); break;
  195. /*       case 259:help();
  196.         clear();
  197.         display_all();
  198.         break;
  199.        case 260:save_format(); break;*/
  200.        case 272:top_move(); break;
  201.        case 280:bottom_move(); break;
  202.        case 275:left_move(); break;
  203.        case 277:right_move(); break;
  204.        case 271:row_head(); break;
  205.        case 279:row_tail(); break;
  206.        case 282:Ins=(Ins==0)?1:0; break;
  207.        case   9:getcursor(&x,&y);
  208.         if (curc>=234) break;
  209.         if (y+10>75) {
  210.            curc=curc+39; display_all();
  211.            y=y-39;
  212.            }
  213.         y=y+10; setcursor(x,y); break;
  214.        case   1:getcursor(&x,&y);
  215.         if ((y-10<0)&&(curc==0)) {setcursor(x,0); break;}
  216.         if ((y-10<0)&&(curc!=0)) {
  217.            curc=curc-39; y=y+39;
  218.            display_all();
  219.            }        y=y-10; setcursor(x,y); break;
  220.        case   8:getcursor(&x,&y);
  221.         if ((y==0)&&(curc==0)) break;
  222.         if ((y==0)&&(curc!=0)) {
  223.            curc=curc-39; y=y+39;
  224.            display_all();
  225.            setcursor(x,y);
  226.            }
  227.         n=y+curc;
  228.         scr[curr+x][n-1]=scr[curr+x][n];
  229.         display_row(); setcursor(x,y-1);
  230.         break;
  231.        case 283:getcursor(&x,&y); m=curc+y;
  232.         if (scr[curr+x][curc+y]=='\n') break;
  233.         while (scr[curr+x][m]!='\n'){
  234.            scr[curr+x][m]=scr[curr+x][m+1]; m++;}
  235.         display_row(); setcursor(x,y); break;
  236.        case  25:getcursor(&x,&y);
  237.         logic=0;        for (m=curr+x;m>=1;m--){
  238.            for (n=0;n<width;n++)
  239.                scr[m][n]=scr[m-1][n];}
  240.         for (n=0;n<width;n++) scr[m][n]='\n';
  241.         setcursor(1,0);
  242.         display_all(); setcursor(x,0);
  243.         break;
  244.        case  14:getcursor(&x,&y);
  245.         for (m=curr+x;m>=1;m--)
  246.            for (n=0;n<width;n++)
  247.                scr[m-1][n]=scr[m][n];
  248.         for (n=0;n<width;n++)
  249.             scr[curr+x][n]='\n';
  250.         downmove(x,9,1); setcursor(x,0);
  251.         display_row();
  252.         setcursor(x,0);
  253.         display();        break;
  254.        case  13:getcursor(&x,&y);
  255.         if (curc==0&&x<9) {setcursor(x+1,0); break;}
  256.         if (curc!=0) curc=0;
  257.         display_all(); setcursor(x,0);
  258.         break;
  259.        default: getcursor(&x,&y);
  260.         if (y+1>74){
  261.            curc=curc+40;
  262.            display_all(); y=y-40;
  263.            setcursor(x,y);
  264.            break;
  265.            }
  266.         if ((charact<=26)||(charact>255)) break;
  267.         n=y+curc;
  268.         putchar(charact);
  269.         if (scr[curr+x][n]=='\n'){
  270.            scr[curr+x][n]=charact;
  271.            n--;
  272.            while (scr[curr+x][n]=='\n') scr[curr+x][n--]=' ';
  273.            break;
  274.            }
  275.         switch(Ins){
  276.         case 1:while (scr[curr+x][n]!='\n') {
  277.               n++;
  278.               }
  279.                while (n>y+curc){
  280.               scr[curr+x][n]=scr[curr+x][n-1];
  281.               n--;}
  282.                scr[curr+x][y]=charact; getcursor(&x,&y);
  283.                display_row(); setcursor(x,y);
  284.                break;
  285.         case 0:if (scr[curr+x][n]=='&') {
  286.               setcursor(x,y); putchar('&'); break;
  287.               }
  288.                scr[curr+x][n]=charact;
  289.                break;
  290.         }
  291.        }
  292.     display();
  293.     }
  294.  /*   setcursor(24,0);
  295.     printf("╩╟ ╖± ╜½ ╕± ╩╜ ╬─ ╝■ ┤µ ┼╠ (Y/N)                            ");
  296.     charact=getchb();
  297.     if ((charact=='y')||(charact=='Y')) save_format();
  298.     return(1);*/
  299.     fp=fopen(argv[1],"w");
  300.     for (i=0;i<10;i++)
  301.     {
  302.     if (scr[i][0]=='\n') continue;
  303.     fprintf(fp,"#");
  304.     for (j=0;j<width;j++)
  305.         {
  306.         if (scr[i][j]!='\n') fprintf(fp,"%c",scr[i][j]);
  307.         else break;
  308.         }
  309.     fprintf(fp,"#,#F#,,\n");
  310.     }
  311.     fclose(fp);
  312. }
  313.  
  314. /*-------------------------------display_all-------------------------------*/
  315. display_all()
  316. {
  317.    int curbuf;   curbuf=x;
  318.    for (x=0;x<10;x++) {setcursor(x,0); display_row();}
  319.    x=curbuf;
  320. }
  321. /*-------------------------------right_move--------------------------------*/
  322. right_move()
  323. {
  324.    getcursor(&x,&y);
  325.    if (y+curc==width-2) return(0);
  326.    if (y+1<75)  setcursor(x,y+1);
  327.    else {
  328.       curc=curc+39;
  329.       display_all(); y=y-39; setcursor(x,y);
  330.       }
  331. }
  332. /*--------------------------------left_move--------------------------------*/
  333. left_move()
  334. {
  335.    getcursor(&x,&y);
  336.    if ((y==0)&&(curc==0)) return(0);
  337.    if ((y==0)&&(curc!=0)) {
  338.       curc=curc-39; y=y+39; display_all();
  339.       }
  340.    setcursor(x,y-1);
  341. }
  342. /*---------------------------------top_move-------------------------------*/
  343. top_move()
  344. {
  345.    int curbuf;
  346.    getcursor(&x,&y);
  347.    if (x>0) { setcursor(x-1,y); return(0);}
  348.    display_row();
  349. }
  350. /*---------------------------------bottom_move-----------------------------*/
  351. bottom_move(){
  352.    int curbuf;
  353.    getcursor(&x,&y);
  354.    if (curr+x==9) return(0);
  355.    if (x<9) {setcursor(x+1,y); return(0);}
  356. }
  357. /*---------------------------------row_head--------------------------------*/
  358. row_head()
  359. {
  360.    int curbuf;
  361.    getcursor(&x,&y); curbuf=x;
  362.    if (curc==0) {setcursor(x,0); return(0);}
  363.    curc=0;
  364.    display_all(); setcursor(curbuf,0);
  365. }
  366. /*----------------------------------row_tail-------------------------------*/
  367. row_tail()
  368. {
  369.    int curbuf,m;
  370.    getcursor(&x,&y); curbuf=x;
  371.    for (m=0;scr[x+curr][m]!='\n';m++);
  372.    curc=(m/39)*39; y=m%39;
  373.    display_all(); setcursor(curbuf,y);
  374. }
  375. /*----------------------------------display------------------------------*/
  376. display()
  377. {
  378.    getcursor(&x,&y);
  379.    x=x & 0x0ff;
  380.    setcursor(24,0);
  381.    if (Ins==1)
  382.       printf("     ╣Γ  ▒Ω  ╨╨ ║┼:%2d   ┴╨ :%2d        ▓σ ╚δ               ",curr+x+1,curc+y);
  383.    if (Ins==0)
  384.       printf("     ╣Γ  ▒Ω  ╨╨ ║┼:%2d   ┴╨ :%2d        ╕▓ ╕╟               ",curr+x+1,curc+y);
  385.    setcursor(x,y);
  386. }