home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG005.ARC
/
DISC.C
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
156 lines
/* DISC MAP Dave Nowlan
.po0
May 85 */
#include "bdscio.h"
#include "wdefines.h"
#define CURRENT_DRIVE 25
#define SEARCH_FIRST 17
#define SEARCH_NEXT 18
#define SET_DRIVE 14
char fcb[36]; /* file control block for searches */
char text[36]; /* to hold the results of sprintf's */
struct Window map,headings,fileline,action; /* set up the windows */
/*---------------------------------------------------------------------------*/
main()
{ char c;
char orig_drive; /* current drive when we came in */
char *Wgets(); /* Wgets returns the address of chars*/
int i,j,n;
int x; /* character to show on the map */
initial();
orig_drive = bdos(CURRENT_DRIVE);
loop: do { c=getdrive(orig_drive);
} while (c < 'A' || c > 'P');
sprintf(text,"%cDrive %c selected %c", Home, c, Clrpage);
Wputs(fileline,text);
c -= 'A';
Wputchar(map,Clear); /* clear the scrren map */
bdos(SET_DRIVE,c); /* set to the drive selected by user */
setfcb(fcb,"*.*"); /* initialise fcb to get all files */
fcb[0]='?'; fcb[12]='?'; /* for all users and for all extents */
i = bdos(SEARCH_FIRST,fcb); /* get first directory entry if any */
if (i == 255)
{ Wputchar(fileline,Home);
Wputs(fileline," No files on drive ");
Wputchar(fileline,c+'A');
Wputchar(fileline,Clrpage);
goto loop;
}
x='A'; /* set first character for the map */
while (i != 255) /* keep going until it runs out */
{ x = do_an_entry((0x80 + i * 32),x);
i = bdos(SEARCH_NEXT,fcb);
}
sprintf(text,"%cAll files on drive %c displayed%c",Home,c+'A',Clrpage);
Wputs(fileline,text);
Wputchar(action,Home); /* go to origin of the action window */
Wputs(action,"Press any key to continue");
Wputchar(action,Clrpage); /* clear rest of the action window */
c = Wgetchar(action); /* wait until any key pressed */
goto loop;
}
/*---------------------------------------------------------------------------*/
do_an_entry(entry,x) /* routine to display directory entry */
char entry[]; /* the directory entry */
int x; /* character to be xused on the display */
{ char c;
int i,j,n;
struct Window *wp1,*wp2; /* pointers to window structures */
wp1=&fileline; /* point to the fileline window */
wp2=↦ /* point to the map window */
wp1->Fore += 1;
if ((wp1->Fore) > 7)
wp1->Fore=1; /* get colour for next file */
wp2->Fore=wp1->Fore;
Wputchar(fileline,Home); /* go to start of fileline */
sprintf(text," %2x ", entry[0]); /* user byte */
Wputs(fileline,text);
for (i=1; i<9; i++)
Wputchar(fileline,entry[i]); /* primary name */è Wputchar(fileline,'.');
for (; i<12; i++)
Wputchar(fileline,entry[i]); /* secondary name */è sprintf(text,"%3d", entry[12]); /* extent number */
Wputs(fileline,text);
if (entry[0]==0xe5) /* see if this file is deleted */
{ Wputs(fileline," D E L E T E D ");
Wputchar(fileline,Clrpage);
return(x);
}
for (i=16; i<32; i++) /* for each of the allocation units */
{ n=entry[i];
sprintf(text," %2x",n); /* print on the fileline */
Wputs(fileline,text);
if (n==0) /* do not show on map if zero */
continue;
n *= 8; /* allocation unit times 8 */
for (j=0; j<8; j++,n++)
{ wp2->CursX = (n / 20) + 2; /* column number */
wp2->CursY = (n % 20); /* row number */
Wputchar(map,x);
}
}
Wputchar(fileline,Clrpage);
if (++x == Delete)
x='!'; /* set next character for display */
else if (x==96)
x++;
return(x);
}
/*---------------------------------------------------------------------------*/
initial() /* routine to clear screen and set up the windows */
{ struct Window *wp; /* pointer to a window */
Winitial(TRUE,TRUE,TRUE,TRUE); /* Initial call to set up Screen */
wp=↦ /* point to the map window */
wp->Column=0; wp->Row=0; /* map starts at 0,0 */
wp->Width=80; wp->Depth=20; /* and is 20 lines of 80 characters */
wp->Fore=1; wp->Back=0; /* set up as red on black */
wp=&headings; /* point to the headings windows */
wp->Column=0; wp->Row=20; /* headings start on line 20 */
wp->Width=80; wp->Depth=3; /* and go for 3 lines */
wp->Fore=7; wp->Back=0; /* and are white on black */
Wputchar(headings,Home); /* go to origin of the window */
Wputs(headings," 1 2 3 ");
Wputs(headings,"4 5 6 7 ");
Wputs(headings,"0123456789012345678901234567890123456789");
Wputs(headings,"0123456789012345678901234567890123456789");
Wputchar(headings,Clrpage); /* and clear the rest of it */
wp=&fileline; /* point to the file line */
wp->Column=0; wp->Row=22; /* line starts at 23,0 */
wp->Width=80; wp->Depth=1; /* and is 1 line of 80 characters */
wp->Fore=1; wp->Back=0; /* set up red on black */
Wputchar(fileline,Clear); /* clear the window */
wp=&action; /* point to the file line */
wp->Column=0; wp->Row=23; /* line starts at 24,0 */
wp->Width=80; wp->Depth=1; /* and is 1 line of 80 characters */
wp->Fore=7; wp->Back=0; /* set up white on black */
Wputchar(action,Clear); /* clear the window */
return;
}
/*---------------------------------------------------------------------------*/
getdrive(orig_drive) /* routine to get drive to map */
char orig_drive; /* drive when we came in */
{ char c;
Wputchar(action,Clear); /* clear the window */
Wputs(action,"Which drive (A B C D)? or RETURN to exit ");
c = Wgetchar(); /* get the character */
if (c==10 || c==13) /* if return reset drive and exit */
{ bdos(SET_DRIVE,orig_drive);
exit();
}
return(toupper(c)); /* return the drive */
}
/*---------------------------------------------------------------------------*/
/* the window routines must be included somewhere OUTSIDE a function */
#include "windows.c"