🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.os.msdos
Article #4022

Re: cp/m m->msdos

#4022
From: Kensuke Nouno
Date: Tue, 02 Feb 1993 02:30
860 lines
22577 bytes
 >   $@EZ20!wC^GHBg!&2=3X$H?=$7$^$9!#(J
 >   $@:#992?$r$H(J$@$$$o$l$=$&$J$s$G$9$,!&!&!&(J
 >   CP/M80$@$r(JOS$@$H$9$k7WB,AuCV$,$"$k$N$G$9$,1i;;=hM}$,CY$/$F(J
 >   $@;HMQ$KBQ$((J$@Fq$/$J$C$F$-$^$7$?!#$G!"$3$N%G!<%?(J(binary?)$@$r(J
 >   MS-DOS$@MQ$KJQ49$7$?$$$N$G$9$,;THN$N%U%!%$%k%3%s%P!<(J$@%?$O(J
 >   $@$3$NL\E*$KBQ$($k$N$G$7$g$&$+!)!!$^$?:#;~$^$@$3$s$JJ*$,(J
 >   $@Gd$C$F$$$k$N$G$7$g$&$+!)!!CN$C$F(J$@$$$k8B$jL>A0$r>e$2$^$9$H(J

 >   File Master II $@!J%+%N!<%W%9EE;R!K(J
 >   $@%U%!%$%k%3%s%P!<%?(JC&M$@!J%7%9%F%`(J$@%]!<%H!K(J
 >   MC$@%3%s%P!<%?!J#I#H%G%8%?%k8&5f=j!K(J

 >   $@!J$3$l$i$O$$$:$l$b(JPC98$@MQ$G$9$,2?J,85$N%G!<%?$,(J$@5-O?$5$l$k%a%G%#%"$,(J
 >   8"$@$J$b$N$G<j;}$A$G$3$l$,$D$J$,$k$N$,$3$l$7$+$J$$!#(J
 >   $@Ha$7$$!#!K(J

 >   $@0J(J$@>e$h$m$7$/$*4j$$$7$^$9!#(J

    PC-98$@MQ$N(J8inch$@$,6a$/$K$"$k$N$J$i!"0J2<$N(Jsource$@$r%3%s%Q%$%k$9$l$P(J
    $@FI(J$@$a$k$h$&$K$J$k$H;W$$$^$9!#(J

/* =============================================================
    DS7's C-CP/M File <==> NEC PC-9800's MS-DOS File (2HD)
    M16's   CP/M File <==> NEC PC-9800's MS-DOS File (2HD)
                          PROGRAMED BY Y.MIYAMOTO
                          1985 12/04
=========================================================== */

#include  <stdio.h>
#include  <dos.h>
#include  <ctype.h>

#define DEBUG 0

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<=(b)?(a):(b))

#define  PC98M  0
#define  DS7    0
#define  M16    1
#define  MARK1C	0
#define  AI	0


#if     PC98M
#define BLENGTH  2048
#define DBLEN    8192
#define SECLEN    256
#define DIRSIZE     4
#define SEC_TRK    26
#define SEC_CYL    52
#define SEC_BLK     8
#define REC_TRK     1
#define ESIZE       2
#define SYSNAME "NEC PC9800m CP/M"
#define SYSKNAME "$@#P#C#9#8(J"
#define CPMKNAME "$@#C#P!?#M(J"
#define DISKTYP "5-2HD"
#define DIRMAX  256
#define MASK    0xffff
#define BIOS_READ      0x4690
#define BIOS_SKREAD    0x5690
#define BIOS_WRITE     0x4590
#define BIOS_SKWRITE   0x5590
#define calc(a,b)      ((a&0xff)|(b<<8))
int    *ip;
int     trsec[26]={
                   1,4,7,10,13,16,19,22,25,2,5,8,11,
                   14,17,20,23,26,3,6,9,12,15,18,21,24
                  };
#endif

#if     DS7   
#define BLENGTH  2048
#define DIRSIZE     2
#define DBLEN    4096
#define SECLEN   1024
#define SEC_TRK     8
#define SEC_CYL    16
#define SEC_BLK     2
#define REC_TRK     1
#define ESIZE       2
#define SYSNAME "DS7's C-CP/M"
#define SYSKNAME "$@#D#S#7(J"
#define CPMKNAME "$@#C!<#C#P!?#M(J"
#define DISKTYP "5-2HD"
#define DIRMAX  256
#define MASK    0xffff
#define BIOS_READ      0x4690
#define BIOS_SKREAD    0x5690
#define BIOS_WRITE     0x4590
#define BIOS_SKWRITE   0x5590
#define calc(a,b)      ((a&0xff)|(b<<8))
int    *ip;
int     trsec[8]={
                   1,2,3,4,5,6,7,8
                  };
#endif

#if     M16
#define BLENGTH  4096
#define DBLEN    4096   /* BLENGTH*DIRSIZE */
#define SECLEN    256
#define DIRSIZE     1
#define SEC_TRK    26
#define SEC_CYL    52
#define SEC_BLK    16   /* BLENGTH/SECLEN  */
#define REC_TRK     2
#define ESIZE       1
#define SYSNAME "MELCOM M16-3"
#define DISKTYP "5-2HD"
#define CPMKNAME "$@#C#P!?#M(J"
#define SYSKNAME "$@#M#1#6(J"
#define DIRMAX  128
#define MASK    0xff
#define BIOS_READ      0x4690
#define BIOS_SKREAD    0x5690
#define BIOS_WRITE     0x4590
#define BIOS_SKWRITE   0x5590
#define calc(a,b)      ((a&0xff)|(b&0))
int    *ip;
int     trsec[26]={
                   1,2,3,4,5,6,7,8,9,10,11,12,13,14,
                   15,16,17,18,19,20,21,22,23,24,25,26
                  };
#endif

#if     MARK1C
#define BLENGTH  2048
#define DBLEN    8192
#define SECLEN    512
#define DIRSIZE     4
#define SEC_TRK    16
#define SEC_CYL    32
#define SEC_BLK     4
#define REC_TRK     1
#define ESIZE       2
#define SYSNAME "Ncc Mark 1/c CP/M-68K"
#define SYSKNAME "$@#M#a#r#k!!#1!?#c(J"
#define CPMKNAME "$@#C#P!?#M!]#6#8#K(J"
#define DISKTYP "5-2HD"
#define DIRMAX  256
#define MASK    0xffff
#define BIOS_READ      0x4690
#define BIOS_SKREAD    0x5690
#define BIOS_WRITE     0x4590
#define BIOS_SKWRITE   0x5590
#define calc(a,b)      ((a&0xff)|(b<<8))
int    *ip;
int     trsec[16]={
		    1,12, 7, 2,13, 8, 3,14,
		    9, 4,15,10, 5,16,11, 6
                  };
#endif


#if     AI
#define BLENGTH  2048
#define DBLEN    4096   /* BLENGTH*DIRSIZE */
#define SECLEN    512
#define DIRSIZE     2
#define SEC_TRK    15
#define SEC_CYL    30
#define SEC_BLK     4   /* BLENGTH/SECLEN  */
#define REC_TRK     1
#define ESIZE       2
#define SYSNAME "AI Denshi"
#define DISKTYP "5-2HD"
#define CPMKNAME "$@#C#P!?#M(J"
#define SYSKNAME "$@#A#IEE;R(J"
#define DIRMAX  128
#define MASK    0xff
#define BIOS_READ      0x4690
#define BIOS_SKREAD    0x5690
#define BIOS_WRITE     0x4590
#define BIOS_SKWRITE   0x5590
#define calc(a,b)      ((a&0xff)|(b&0))
int    *ip;
int     trsec[15]={
                   1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
                  };
#endif

/* ======================================================== */

#define DIRBLK  0 
#define MAX_TRK 76

#define DELMARK 0xe5
#define OK      1
#define ZERO    0
#define SPACE   ' '
#define FALSE   0
#define TRUE    1
#define FOREVER for(;;)
#define RECSIZE  128

/* ========================================================== */

#define SYSCAL intr(0x1b,&preg)

struct REGPACK preg;

/* =========================================================== */

char bf[DBLEN];

char dsp[DBLEN];
char *dp;

struct  directory  {
  char   mark;
  char   *filename;
  int    reclen;
  int    *filemap;
}      dir[DIRMAX];

int    posn;   /* rel. posn in dir. */
int    dirp;
int    drv;    /* dirve number      */
FILE   *out;
int    oldcyl=-1;

/* ======================================= MAIN ================= */

int  copy_last_blk=DIRSIZE;
int  copy_blk_count=0;
int  dir_ptr=0;
int  copy_start_blk=0;
long  copy_size=0;
char line[80];

main()
{ int cin;
 printf("  $@!c!c!!#P#C#9#8!<(J%s   $@#V#1(J.$@#2#0(J   by Y.Miyamoto $@!!!!!d!d(J\n",SYSKNAME);
 printf("        $@#P#C#9#8$H(J%s$@$N%U%!%$%k$rJQ49$7$^$9!#(J\n \n",SYSKNAME);
 printf("         1) %s$@$N%U%!%$%k$r#P#C(J$@#9#8MQ$KJQ49!#(J\n",SYSKNAME);
 printf("         2) $@#P#C#9#8$N%U%!%$%k$r(J%s$@MQ$KJQ49!#(J\n",SYSKNAME);
retry:
 printf("            $@=hM}A*Br(J (1 or 2) ?=");
     cin=getch();
     printf("%c \n",cin);
     switch (cin){
        case '1' :  ds7_to_pc98();
                    break;
        case '2' :  pc98_to_ds7();
                    break;
        defalut  :  goto retry ;
      }
 printf("\n");
 printf(" $@!!(J$@$*$D$+$l$5$^$G$7$?!#(J");
}

ds7_to_pc98()
{   init();
    set_dir();
    choose();
    copying();
}
pc98_to_ds7()
{int fd_copy,i;
 char  cin;

  init2();
  if(read_blk(DIRBLK,DIRSIZE,bf)!=OK){
     printf("\n   Dir Block can't be read %02x \n",preg.r_ax);
     printf("   $@O@M}%I%i%$%V#2$N%G%#%9%1%C%H$N7A(J$@<0$r3NG'$7$F$/$@$5$$!#(J\n");
     exit(0);
   }
   for(i=0;i<DBLEN;i++){
     bf[i]=DELMARK;}
next_file:
   printf("\n");
   choose2(&fd_copy);
   copy_size=0;
   copying2(fd_copy);
   set_dir2();
   out_dir();
   printf("   $@JL$N%U%!%$%k$bJQ49$7$^$9$+(J? (Y/N)=");
 wait_yn:
   cin=getch();
   if((cin=='y')||(cin=='Y')){ goto next_file;}
   if((cin=='n')||(cin=='N')){ return;}
   goto wait_yn;
}
/* ======================================== INIT ===============  */

init()
{
	char cc;
	struct SREGS segs;
  segread(&segs);
  preg.r_es=segs.ss;

 printf("\n");
 printf("   %s$@$G:n@.$7$?(J%s$@$N%U%!%$%k$r(J\n",SYSKNAME,CPMKNAME);
 printf("   $@#P#C#9#8$N#M#S!<#D#O#S%U%!%$%k$KJQ49$7$^$9!#(J\n",SYSKNAME);
 printf("   %s  %s to MS-DOS File conv. \n",SYSNAME,DISKTYP);
 printf("   %s$@$G:n@.$7$?(J%s$@$N%G%#%9%C%1%H$rO@M}%I%i%$%V(J$@#2$KF~$l$F2<$5$$!#(J\n",CPMKNAME,SYSKNAME,drv);
 printf("   $@%+%l%s%H!&%I%i%$%V$X#M#S!<#D#O#S%U%!%$%k$KJQ(J$@49$7$F=PNO$7$^$9!#(J\n");
 printf("   $@=`Hw40N;(J (Y/N)=");
  cc=getch();
  if((cc=='N')||(cc=='n')){exit();}
  dp=dsp;
  dirp=posn=0;
  drv = 1;  /* DRIVE 2 assumed */
}


init2()
{
	char cc;
	struct SREGS segs;
	int i;
  segread(&segs);
  preg.r_es=segs.ss;

 printf("\n");
 printf("   PC9800 MS-DOS File conv.TO %s %s  \n",SYSNAME,DISKTYP);
 printf("   $@#P#C#9#8$G:n@.$7$?#M#S!]#D#O#S$N%U%!%$%k$r(J\n");
 printf("   %s$@$N(J%s$@%U%!%$%k$KJQ49$7$^$9!#(J\n",SYSKNAME,CPMKNAME);
 printf("   $@;XDj$5$l$?#M#S!<#D#O#S%U%!%$%k(J$@$rJQ49$7O@M}%I%i%$%V#2$X=PNO$7$^$9!#(J\n");
 printf("   %s$@MQ$K%U%)!<%^%C%H$7$?%G%#%9%/$rO@M}%I%i%$%V#2$K(J$@F~$l$F2<$5$$!#(J\n",SYSKNAME);
 printf("   $@$J$*!"O@M}%I%i%$%V#2$N%G%#%9%/$NFbMF$OGK2u$5$l$^$9!#(J\n");

  printf("   $@=`Hw40N;(J (Y/N)=");
  cc=getch();
  printf("\n");
  if((cc=='N')||(cc=='n')){exit();}
  dp=dsp;
  dirp=posn=0;
  drv=1;  /* b: assumed */
  /* dir area init */
  for(i=0;i<DBLEN;i++){
     bf[i]=DELMARK;}
}

/*============================= ds7 to pc980 sbroutine ================*/

set_dir()
{
  int  i;

  i=read_blk(DIRBLK,DIRSIZE,bf);
  if(i!=OK){
     printf("\n   Dir Block can't be read %02x \n",preg.r_ax);
     printf("   $@O@M}%I%i%$%V#2$N%G%#%9%1%C%H$N7A<0$r3NG'$7$F$/$@$5$$!#(J\n");
     exit(0);
   }
   FOREVER {
     i=getlstname();
     if(i!=OK) break;
     copy_fname();
     copy_rlen();
     copy_fmap();
     posn++;
     dirp++;
    }
}

read_blk (n,size,bf)
  int n;     /* relative block number */
  int size;  /* block size */
  char *bf;
{
   int  tmp,icyl,cyl,ihead,head,isec,sec;
   int  i,j,rc;
   char *bfp;


   bfp=bf;
   for (j=n; j<n+size; j++){
      tmp= SEC_BLK*j ;
      icyl=cyl=(tmp/SEC_CYL)+REC_TRK ;
      ihead=head=(tmp/SEC_TRK)&1;
      sec=tmp%SEC_TRK;
      preg.r_bx=SECLEN;

#if DEBUG
      printf("icyl = %d cyl = %d tmp= %d %d\n",icyl,cyl,tmp,SEC_CYL);
      printf("ihead= %d head= %d sec= %d\n",ihead,head,sec);
      getch();
#endif
      for (i=sec; i<sec+SEC_BLK; i++) {
        if (i>=SEC_TRK) {
              isec=trsec[i-SEC_TRK];
              if (head!=0) {
                 icyl=cyl+1;
                 ihead=0;
                 }
                 else{
                   ihead=head+1;
                 }
               }
           else {
              isec=trsec[i];
            }
        if (icyl==oldcyl)
            { preg.r_ax = BIOS_READ | drv; }
           else{
              preg.r_ax = BIOS_SKREAD | drv; }
        if (icyl>MAX_TRK) {
            printf(" Exceede track %d\n",MAX_TRK);
            exit(1);
            }
        if (SECLEN<=0x200){
             preg.r_cx = (SECLEN&0xff00) | icyl ;
             }
           else { if (SECLEN==0x400)
                      { preg.r_cx = 0x0300 | icyl ;}
                     else{
                      printf (" internal preg.r_cx set error !!\n");
                      eixt();
                         }
                 }

        preg.r_dx = (ihead << 8)    | isec ;
        oldcyl = icyl;

        preg.r_bp = bfp ;

#if DEBUG
        printf(" ax = %04x\n",preg.r_ax);
        printf(" bx = %04x\n",preg.r_bx);
        printf(" cx = %04x\n",preg.r_cx);
        printf(" dx = %04x\n",preg.r_dx);
#endif

        SYSCAL ;
        rc = preg.r_ax;
        if ((rc<<8)&1) return !OK ;
        bfp += SECLEN ;
       }
      }
      return OK;
}
/* ==================================== CHOOSE ============= */

static char *ln;

choose()
{
   int  i,j,k,m,n,set;
   char *lin,*gets();

 again:
   printf("\n$@O@M}%I%i%$%V#2$NFbMF!'(J*$@0u$N%U%!%$%k$rJQ49$7$^$9!#(J");
   for(i=0; i<dirp; i+=64) {
     printf("\n");
     for( j=i; j<min(i+64, dirp); j++) {
        printf("%3d %c %-12s%s",j+1,
                 dir[j].mark==FALSE?' ':'*',
                 dir[j].filename,
                 (j%4)==3?"\n":"  ");
     }
     printf("\n");
     printf(" *$@!!$rF~NO$9$k$HJQ49$r;O$a$^$9!#(J\n");
     printf(" $@JQ49$7(J$@$?$$%U%!%$%k$NHV9f$rF~NO$7$F$/$@$5$$(J= ");
     /* printf("\nEnter [n{-n} | -n{-n} ] >> "); */
     lin=gets (line);
     if (line[0]=='*') break ;
     if (strlen(line)==0) continue ;
     ln=line ;
     FOREVER {
        if (leading(&set)) break;
        getnum(&n,&m);
        for (k=n; k<=m; k++)
          if (k>0 && k<= dirp)
             dir[k-1].mark=set;
     }
    }
    if (line[0]!='*') {
                       goto again ;
                       }
}
leading (set)
 int    *set;
{
  int c1;

  *set=TRUE;
  while (c1=*ln) {
     if (c1 == '-') *set=FALSE ;
     if (isdigit(c1)) return(0);
     ln++;
   }
   return (1);
}

getnum(n,m)
 int *n,*m;
{
   int k;

   k= (*ln - '0' );

   while (isdigit(*++ln))
     k=10*k+(*ln - '0' );
   *n=k;
   if (*ln != '-') {
     *m=k ;
     return ;
   }
   k= (*++ln - '0' );
   while (isdigit(*++ln))
     k=10*k+(*ln - '0' );
     *m=k ;
     return ;
}
/* ==================================================== */
copying ()
{
  int blen, i, k,m,n;
  int *j; /* ???? */

  printf(" \n");
  for(i=0; i<dirp; i++) {
    if(dir[i].mark==FALSE) continue;
    printf("%3d %12s  ",i+1,
        dir[i].filename);
    out=fopen(dir[i].filename,"wb");
    if (out==NULL) {
       printf("cannot open file : %s\n",
               dir[i].filename);
       continue;
    }
    j=dir[i].filemap;
    printf(" $@$r#M#S!<#D#O#S%U%!%$%k$KJQ49Cf!#(J\n");

    /* ------- debug --------------
    FOREVER {
       if (*j==ZERO) break;
       printf ("%02x ", (*j++)&MASK);
    }
    putchar('\n');
    ---------------------------------*/

    j=dir[i].filemap;
    FOREVER {
      if (*j==ZERO)  break;
      blen = dir[i].reclen;
      k=read_blk((*j++)&MASK, 1, bf);
      if(k!=OK) {
          printf("Read error \n");
          break;
      }
      if (*j==ZERO) {
         blen--;
         blen=blen&0x1f;
         blen++;
         blen=blen<<7;
         }
        else{
         blen=BLENGTH;
         }
      fwrite(bf, 1, blen, out);
     }
     fclose(out);
    }
 }
copy_fmap()
{
   int apos, i, j, c1;

   apos = posn*32;

   ip=(int *)dp;

   dir[dirp].filemap=ip;
   dir[dirp].mark=FALSE;
   bf[apos]=DELMARK;
   for (i=16; i<32; i+=ESIZE) {
     c1=calc(bf[apos+i], bf[apos+i+1]);
     if (c1==ZERO) goto nomore;
     *ip++=c1;
   }
   for (j=posn+1; j<DIRMAX; j++){
     if (same_name(posn, j)) {
       apos = j*32;
       dir[dirp].reclen=bf[apos+15]&0xff;
       bf[apos]=DELMARK;
       for(i=16; i<32; i+=ESIZE) {
         c1=calc(bf[apos+i], bf[apos+i+1]);
         if (c1==ZERO) goto nomore;
         *ip++ = c1;
       }
     }
    }
 nomore:
   *ip++ = 0;
   dp=(char *)ip;
}

copy_rlen()
{
  int  apos;

  apos = posn*32;
  dir[dirp].reclen = bf [apos+15]&0xff;
}

copy_fname()
{
  int i, apos;
  char   c1;

  apos=posn*32;
  dir[dirp].filename = dp;
  for (i=1; i<=8; i++) {
     if ((c1=bf[apos+i]) != SPACE)
	     *dp++ = c1;
  }
  *dp++ =  '.';
  for (i=9; i<=11; i++) {
     if ((c1=bf[apos+i]) != SPACE)
     	*dp++ = ( c1 & 0x7f );
  }
  *dp++ = 0;
}

getlstname()
{
   int  apos, i, tmp;

again:
   FOREVER {
      apos = posn*32;
      if (apos >= DBLEN) return (!OK);
      tmp = bf [apos] & 0xff ;
      if (tmp != DELMARK) break;
      posn++;
   }
   for (i=0; i<posn; i++) {
      apos = i*32;
      tmp  = bf[apos] & 0xff;
      if (tmp != DELMARK) continue;
      if (same_name(posn, i)) {
          posn++;
          goto again;
      }
   }
   return(OK);
}

same_name(i, j)
  int i,j;
{
  int k;

    i *= 32;
    j *= 32;
    for (k=1; k<=11; k++)
      if (bf[i+k] != bf[j+k])
          return(FALSE);
    return(TRUE);
}

/* =========================  pc98 to ds7  sburoutine ============== */

choose2(fd_copy)
 int *fd_copy;
{ int i; 
  char *lin,*gets();

  printf(" $@JQ49$9$k%U%!%$%kL>$rF~NO$7$F$/$@$5$$(J=");
  gets(line);
  printf("\n");
  for (i=0;i<80;i++){          /* TO UPPER CHAR */
     if (('a'<=line[i])&&(line[i]<='z')){
           line[i]=line[i]-'a'+'A'; }
  }
  if ((*fd_copy=open(line,0x8000))<=0)
      {  printf(" %s  not found !!!\n",line);
         close(*fd_copy);
         exit();
      }
}
char copy_buf[BLENGTH];
copying2(fd_copy)
 int fd_copy;
{ int read_lng,i,copy_blk_count;

  copy_size=0;
  copy_blk_count=0;
  copy_start_blk=copy_last_blk;
  while((read_lng=read(fd_copy,copy_buf,BLENGTH))>0){
       /* for(i=0;i<read_lng;i++){
              printf("%c",copy_buf[i]);}   */
          for(i=read_lng;i<BLENGTH;i++){
               copy_buf[i]=0x1a; }        /*  EOF MARK FILL */
           write_blk(copy_last_blk,1,copy_buf); 
           copy_last_blk++;
           copy_blk_count++;
           copy_size+=read_lng;
     } 
  close(fd_copy);
}

write_blk (n,size,bf)
  int n;     /* relative block number */
  int size;  /* block size */
  char *bf;
{
   int  tmp,icyl,cyl,ihead,head,isec,sec;
   int  i,j,rc;
   char *bfp;


   bfp=bf;
   for (j=n; j<n+size; j++){
      tmp= SEC_BLK*j ;
      icyl=cyl=(tmp/SEC_CYL)+REC_TRK ;
      ihead=head=(tmp/SEC_TRK)&1;
      sec=tmp%SEC_TRK;
      preg.r_bx=SECLEN;

/*----------- debug -----------
      printf("icyl = %d cyl = %d tmp= %d %d\n",icyl,cyl,tmp,SEC_CYL);
      printf("ihead= %d head= %d sec= %d\n",ihead,head,sec);
      getch();
  ------------------------------ */
      for (i=sec; i<sec+SEC_BLK; i++) {
        if (i>=SEC_TRK) {
              isec=trsec[i-SEC_TRK];
              if (head!=0) {
                 icyl=cyl+1;
                 ihead=0;
                 }
                 else{
                   ihead=head+1;
                 }
               }
           else {  
              isec=trsec[i]; 
            }
        if (icyl==oldcyl)
            { preg.r_ax = BIOS_WRITE   | drv; }
           else{
              preg.r_ax = BIOS_SKWRITE | drv; }
        if (icyl>MAX_TRK) {
            printf(" Exceede track %d\n",MAX_TRK);
            exit(1);
            }
        if (SECLEN<=0x200){
             preg.r_cx = (SECLEN&0xff00) | icyl ;
             }
           else { if (SECLEN==0x400)
                      { preg.r_cx = 0x0300 | icyl ;}
                     else{
                      printf (" internal preg.r_cx set error !!\n");
                      eixt();
                         }
                 }

        preg.r_dx = (ihead << 8)    | isec ;
        oldcyl = icyl;

        preg.r_bp = bfp ;

       /* ---  DEBUG ---------------
        printf(" ax = %04x\n",preg.r_ax);
        printf(" bx = %04x\n",preg.r_bx);
        printf(" cx = %04x\n",preg.r_cx);
        printf(" dx = %04x\n",preg.r_dx);
         -------------------------- */

        SYSCAL ;
        rc = preg.r_ax;
        if ((rc<<8)&1) return !OK ;
        bfp += SECLEN ;
       }
      }
      return OK;
}
set_dir2()
{ int j,i,copyed_lng,jj;
  int block_ptr,ext_file;
  unsigned int uns_int;
  long llint;

   block_ptr=copy_start_blk;
   ext_file=0;
   llint=copy_size;

   while(copy_size>0){
      /* clear */
      bf[dir_ptr    ]=0;
      for(i=1;i<12;i++){
        bf[dir_ptr+i]=' '; }
      for(i=13;i<32;i++){
        bf[dir_ptr+i]=0; }
      bf[dir_ptr+12 ]=ext_file++;
      copyed_lng=0;

      /* name set */
      j=1;
      for(i=0;;i++){
        if(i>79){ printf(" filename error \n");
                  exit();}
        if(line[i]==0){ break; }
        bf[dir_ptr+j]=line[i];
        j++;
        if(line[i]=='.'){
                          for(jj=dir_ptr+j-1;jj<=dir_ptr+11;jj++){
                            bf[jj]=' ';}
                          j=9;}  /*  file ext. pointer  */
        if(line[i]==':'){j=1;}  /*  drive name omit */
        if(line[i]=='\\'){j=1;}  /*  sub dir. name omit */
      }
     /* block pointer set */

     for(i=0;i<16;i+=ESIZE){
             bf[dir_ptr+16+i   ]=block_ptr&0xff;
            if ( ESIZE==2){
             bf[dir_ptr+16+i+1 ]=block_ptr>>8;
            }
       if (copy_size < BLENGTH ){ copyed_lng+=copy_size;
                                  copy_size=0;
                                  break; }
       block_ptr++;
       copy_size-=BLENGTH;
       copyed_lng+=BLENGTH;
      }
  /*  printf(" last block %ld %d\n",llint,copyed_lng); */
      uns_int=(copyed_lng+RECSIZE-1)/RECSIZE;
      bf[dir_ptr+15]=uns_int&0xff;

   /* ========================== debug ==============
     for(i=0;i<32;i++){
        printf("%02x ",bf[dir_ptr+i]);}
      printf("\n");
      =============================================== */

     if(copy_size<0){ break;}
     dir_ptr+=32;
     if(dir_ptr>DBLEN){
         printf(" DIR BUFFER OVER FLOW !!!\n");
       }
   }
 rtnend: 
   return 0;
}
out_dir()
{
    if(write_blk(DIRBLK,DIRSIZE,bf)!=OK){
         printf(" Dir BLOCK  can't write %02x \n",preg.r_ax);
       }
}


--

                                             ############################
                                             $@6e=#7]=Q9)2JBg(J$@3X9)6H@_7W3X2J(J
                                                       $@G=Ln(J  $@8,2p(J
                                             e-mail nouno@kyushu-id.ac.jp
                                                    Tel 092-553-4528
                                                    Fax 092-553-4569
                                             ############################
Technical Details
Message-ID: <NOUNO.93Feb2113143@imips.kyushu-id.ac.jp>
Path: arc1-ca.pugleaf.net!sparky!uunet!ccut!news.u-tokyo.ac.jp!s.u-tokyo!kuis!kudpc!hakata!kyu-cs!wnoc-fukuoka-news!ctcses41!kidss2!nouno
References: <22999@ume.cc.tsukuba.ac.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: ff2c9,5a49df18c961b2a5
X-Google-Attributes: gidff2c9,public
X-Google-ArrivalTime: 1993-02-01 18:30:05 PST
Newsgroups: fj.os.msdos
Path: arc1-ca.pugleaf.net!sparky!uunet!ccut!news.u-tokyo.ac.jp!s.u-tokyo!kuis!kudpc!hakata!kyu-cs!wnoc-fukuoka-news!ctcses41!kidss2!nouno
From: nouno@kyushu-id.ac.jp (Kensuke Nouno)
Subject: Re: cp/m m->msdos
In-Reply-To: masahiro@sakura.cc.tsukuba.ac.jp's message of 28 Jan 93 22:35:39 GMT
Message-ID: <NOUNO.93Feb2113143@imips.kyushu-id.ac.jp>
Lines: 860
Sender: news@kyushu-id.ac.jp
Organization: Kyushu Institute of Design
References: <22999@ume.cc.tsukuba.ac.jp>
Date: Tue, 2 Feb 1993 02:30:05 GMT