Category : BASIC Source Code
Archive   : VANDEGFT.ZIP
Filename : HIDEFILE.BAS
20 REM * HideFile by John Vandegrift *
30 REM * *
40 REM * This program allows the user to modify diskette files in the *
50 REM * following ways. First, the user can change a file to a normal *
60 REM * file, hidden file, system file or hidden/system file. The file *
70 REM * to be changed can be any of the above. The second function of *
80 REM * this program is to allow the user to undelete files. Although *
90 REM * this will undelete files, it is limited in its ability to do so.*
100 REM * If a file is bigger than 512 bytes (1 sector), then the file *
110 REM * will have to be in on contiguous set of sectors, as this program*
120 REM * doesn't know where else the sectors belonging to deleted file *
130 REM * were. What this program does if a file is bigger than 512 bytes*
140 REM * is check the sectors following the first sector of the program *
150 REM * to see if they are allocated. If not, it assumes that those *
160 REM * sectors belong to that file and uses them. If they are in use *
170 REM * then this program cannot undelete that file. A user can also *
180 REM * use this to scan through the directory of a file. *
190 REM * *
200 REM * Limitations: If the diskette is double-sided, then this reads *
210 REM * the first 64 directory entries. The diskette in *
220 REM * drive A is the diskette to be read, although *
230 REM * provision is made for reading drive B if the user *
240 REM * wants to add the user i/o for the drive. The *
245 REM * user must have 64k memory and 1 disk drive, *
246 REM * minimum configuration. *
250 REM ********************************************************************
260 CLEAR ,&H4000:KEY OFF
270 DEF SEG=0
275 GOSUB 1880
280 REM Assembler Routine
290 REM
300 REM This routine pokes a machine language subroutine into high memory.
310 REM This subroutine reads and writes the diskette directory and FAT
320 REM from/to the diskette to/from upper memory.
330 REM The diskette buffer area starts at &hcc00 and is 3072 bytes.
340 REM The subroutine is loaded at &hE000 and is 36 bytes.
350 REM
360 DATA &h55,&h06,&hb8,&h00,&h00
370 DATA &h8e,&hc0,&h8b,&hec,&h8b
380 DATA &h76,&h0a,&h8b,&h04,&h8a
390 DATA &he0,&hb0,&h06,&hbb,&h00
400 DATA &hcc,&hb9,&h02,&h00,&h8b
410 DATA &h76,&h08,&h8b,&h14,&hcd
420 DATA &h13,&h07,&h5d,&hca,&h04
430 DATA &h00
440 FOR I=1 TO 36:READ J:SUM=SUM+J:NEXT I
450 IF SUM<>3470 THEN CLS:PRINT "Sum = ";SUM;". Data Error!":STOP
460 RESTORE
470 FOR I=0 TO 35:READ J:POKE &HE000+I,J:NEXT I
480 SUBRT=&HE000
490 REM
500 REM Call the routine to read FAT and Directory from diskette
510 REM and check for single-sided format.
520 REM
530 A%=2 '2 for read or 3 for write
540 B%=0 '0 for drive A or 1 for drive B
550 CALL SUBRT (A%, B%)
560 IF PEEK(&HCC00)=&HFE THEN NOSIDES=1 ELSE NOSIDES=2
590 REM
600 REM Master Menu
610 REM
620 REM The user may want to follow the options in order of occurance,
630 REM first reading the directory, then altering it and finally
640 REM writing it back to the diskette.
650 REM
655 GOSUB 2130
660 CLS:LOCATE 2,37:PRINT "HideFile"
662 LOCATE 23,30:IF NOSIDES=1 THEN PRINT "Single-sided diskette":GOTO 670
665 PRINT "Double-sided diskette"
670 LOCATE 10,30:PRINT "1. File Directory"
680 LOCATE 11,30:PRINT "2. Alter Directory"
690 LOCATE 12,30:PRINT "3. Update Diskette"
700 LOCATE 13,30:PRINT "4. Help"
705 LOCATE 14,30:PRINT "5. Exit"
710 LOCATE 16,30:INPUT "Choice";IANS
730 ON IANS GOSUB 790,1030,750,2210,1880
735 IF IANS=5 THEN KEY ON:END
740 GOTO 660
745 REM
750 REM Put Directory on diskette
751 REM
752 REM This routine takes the diskette directory and FAT images
753 REM in upper memory and writes them to the diskette. Here
754 REM drive A is assumed, just as it is when data is read from
755 REM the diskette.
756 REM
760 A%=3:B%=0
770 CALL SUBRT (A%, B%)
780 RETURN
785 REM
790 REM Display Files Routine
791 REM
792 REM This is a simple directory function that reads the directory
793 REM information from upper memory and displays to the user. The
794 REM user can use this to look at all of the directory entries.
795 REM It will show what type of file is there, whether it has been
796 REM deleted, or if the entry has never been used.
797 REM
800 CLS
810 FOR I=0 TO 2016 STEP 32
820 IF PEEK(I+&HD000)=&HE5 AND PEEK(I+&HD001)=246 THEN 1010
830 IF PEEK(I+&HD000)=&HE5 THEN DEL$="*del*" ELSE DEL$=" "
840 LOCATE ,15
850 FOR J=0 TO 7:PRINT CHR$(PEEK(J+I+&HD000));:NEXT J
860 PRINT ".";
870 FOR J=8 TO 10:PRINT CHR$(PEEK(J+I+&HD000));:NEXT J
880 A=PEEK(I+&HD00B)
890 IF A=0 THEN PRINT " Normal File ";
900 IF A=2 THEN PRINT " Hidden File ";
910 IF A=4 THEN PRINT " System File ";
920 IF A=6 THEN PRINT " Hidden/System File";
930 MONTH$ = STR$((PEEK(I+&HD019) AND 1)*8 + ((PEEK(I+&HD018) AND 224)/32))
940 IF LEN(MONTH$)>2 THEN MONTH$=RIGHT$(MONTH$,2)
950 DAY$ = STR$(PEEK(I+&HD018) AND 31):IF LEN(DAY$)>2 THEN DAY$=RIGHT$(DAY$,2)
960 YEAR$ = RIGHT$(STR$((INT(PEEK(I+&HD019)/2))+1980),4)
970 THEDATE$=MONTH$+"/"+DAY$+"/"+YEAR$
980 SIZE=PEEK(I+&HD01C)+(PEEK(I+&HD01D)*256)+(PEEK(I+&HD01E)*65536!)
990 PRINT THEDATE$;" ";DEL$;" ";SIZE
995 IF ((I/32)+1) MOD 20 = 0 THEN GOSUB 1010:CLS
1000 NEXT I
1010 LOCATE 23,28:INPUT "Press return to continue",IANS
1020 RETURN
1025 REM
1030 REM Alter Directory Entries Routine
1031 REM
1032 REM Allows the user to page through the entries of the diskette
1033 REM directory. The user can change the file attribute from
1034 REM Normal, Hidden, System, or Hidden/System to any of the same.
1035 REM The user can also undelete deleted files.
1036 REM This function does not save these changes to diskette!
1037 REM
1040 I=0
1050 CLS
1060 TITLE$=""
1070 LOCATE 2,30:PRINT "Directory Entry ";I/32+1
1080 IF PEEK(I+&HD000)=&HE5 THEN IF PEEK(I+&HD001)=246 THEN TITLE$="Unused":DEL$="":GOTO 1120 ELSE DEL$="*deleted*" ELSE DEL$=""
1090 FOR J=0 TO 7:TITLE$=TITLE$+CHR$(PEEK(J+I+&HD000)):NEXT J
1100 TITLE$=TITLE$+"."
1110 FOR J=8 TO 10:TITLE$=TITLE$+CHR$(PEEK(J+I+&HD000)):NEXT J
1120 LOCATE 10,20:PRINT TITLE$;
1130 A=PEEK(I+&HD00B)
1140 IF A=0 THEN PRINT " Normal File ";
1150 IF A=2 THEN PRINT " Hidden File ";
1160 IF A=4 THEN PRINT " System File ";
1170 IF A=6 THEN PRINT " Hidden/System File";
1180 PRINT " "+DEL$
1190 LOCATE 23,10:PRINT "D - Delete toggle F - File toggle X - eXit ";CHR$(75);" ";CHR$(77);" - Paging"
1200 A$=INKEY$:IF A$="" THEN 1200
1210 IF A$="X" OR A$="x" THEN RETURN
1220 IF A$="f" OR A$="F" THEN GOSUB 1280:POKE (I+&HD00B),ATTRIBUTE
1230 IF A$="d" OR A$="D" THEN GOSUB 1400:POKE (I+&HD000),LETTER1
1240 IF LEN(A$)=2 THEN A$=RIGHT$(A$,1)
1250 IF A$=CHR$(75) THEN IF I>31 THEN I=I-32
1260 IF A$=CHR$(77) THEN IF I<1985 THEN I=I+32
1270 GOTO 1050
1280 REM Get New File Attribute
1290 LOCATE 23,10:PRINT STRING$(65,32)
1300 LOCATE 14,30:PRINT "File Attribute:"
1310 LOCATE 16,30:PRINT "1. Normal file"
1320 LOCATE 17,30:PRINT "2. Hidden file"
1330 LOCATE 18,30:PRINT "3. System file"
1340 LOCATE 19,30:PRINT "4. Hidden/System file"
1350 LOCATE 20,30:PRINT "5. Exit"
1355 LOCATE 22,30:INPUT "Choice ";IANS
1356 IF IANS=5 THEN ATTRIBUTE=PEEK(I+&HD00B):GOTO 1380
1360 IF IANS<1 OR IANS>4 THEN LOCATE 20,35:PRINT STRING$(30,32):GOTO 1280
1370 ATTRIBUTE=(IANS-1)*2
1380 FOR K=14 TO 22:LOCATE K,30:PRINT STRING$(45,32):NEXT K
1390 RETURN
1395 REM
1400 REM Undelete File
1401 REM
1402 REM This routine allows the user to undelete a deleted file.
1403 REM The size of the file is obtained from the directory and the
1404 REM necessary number of sectors are checked following the first
1405 REM sector of the file. If none of the sectors following the
1406 REM the first sector are allocated, the program assumes those
1407 REM are the sectors belonging to the deleted program. Otherwise,
1408 REM it will not undelete the file!
1409 REM
1410 LOCATE 23,10:PRINT STRING$(65,32)
1420 LETTER1=PEEK(I+&HD000):IF LETTER1=&HE5 THEN 1460
1430 LOCATE 15,25:INPUT "This is not a deleted file. Press return";IANS$
1450 LOCATE 15,25:PRINT STRING$(53,32):RETURN
1460 SIZE=PEEK(I+&HD01C)+(PEEK(I+&HD01D)*256)+(PEEK(I+&HD01E)*65536!)
1470 SECTORS=INT((SIZE-1)/512)+1
1480 LOCATE 20,21:PRINT "File Size is ";SIZE;" bytes,";SECTORS;" sectors."
1490 CLUSTER = PEEK(I+&HD01A)+PEEK(I+&HD01B)*256
1500 LOCATE 21,21:PRINT "Starting Cluster is ";CLUSTER
1510 GOSUB 1600
1520 IF FLAG$="yes" THEN 1530 ELSE PRINT "There are sectors allocated after cluster ";CLUSTER;"!! Press return.";:INPUT IANS:GOTO 1580
1530 LOCATE 15,25:INPUT "Do you want to undelete this file?";IANS$
1540 IF LEFT$(IANS$,1)<>"Y" AND LEFT$(IANS$,1)<>"y" THEN 1580
1550 LOCATE 16,23:INPUT "Enter first letter for filename";IANS$
1560 LETTER1=ASC(IANS$)
1562 IF LETTER1<123 AND LETTER1>96 THEN LETTER1=LETTER1-31
1565 IF LETTER1<65 OR LETTER1>90 THEN 1530
1570 GOSUB 1680
1580 LOCATE 15,25:PRINT STRING$(53,32)
1590 LOCATE 16,25:PRINT STRING$(53,32):RETURN
1595 REM
1600 REM Cluster's Last Stand(checks clusters)
1601 REM
1602 REM This is the routine that checks the needed number of sectors
1603 REM immediatly following the first sector of the file being
1604 REM undeleted! FLAG$ contains the indicator as to the outcome
1605 REM of the check.
1606 REM
1608 IF NOSIDES=1 THEN RANGE=SECTORS ELSE RANGE=INT((SECTORS+1)/2)
1610 FOR INC=1 TO RANGE
1620 TEMP=INT((CLUSTER+INC-1)*1.5)
1630 IF CLUSTER MOD 2 = 1 THEN NEWCLUS=((PEEK(&HCC00+TEMP) AND 240)/16)+PEEK(&HCC00+TEMP+1)*256 ELSE NEWCLUS=PEEK(&HCC00+TEMP)+((PEEK(&HCC00+TEMP+1) AND 15)*256)
1640 IF NEWCLUS<>0 THEN FLAG$="no":GOTO 1670
1650 NEXT INC
1660 FLAG$="yes"
1670 RETURN
1675 REM
1680 REM Cluster's Last Stand(updates clusters)
1681 REM
1682 REM This routine reallocates the sectors following the first sector.
1683 REM Appendix C of the DOS Manual gives the technique for accessing
1684 REM this information.
1685 REM
1688 IF NOSIDES=1 THEN RANGE=SECTORS-1 ELSE RANGE=INT((SECTORS+1)/2)-1
1690 FOR INC=1 TO RANGE
1700 TEMP=INT((CLUSTER+INC-1)*1.5)
1710 IF (CLUSTER+INC-1) MOD 2 = 1 THEN BYTE1=(PEEK(&HCC00+TEMP) AND 15) + (((CLUSTER + INC) AND 15)*16):BYTE2=INT((CLUSTER+INC)/16):GOTO 1730
1720 BYTE1=(CLUSTER+INC) AND 255:BYTE2=(PEEK(&HCC00+TEMP+1) AND 240) + INT((CLUSTER+INC)/256)
1730 POKE (&HCC00+TEMP),BYTE1:POKE (&HCE00+TEMP),BYTE1
1740 POKE (&HCC00+TEMP+1),BYTE2:POKE (&HCE00+TEMP+1),BYTE2
1750 NEXT INC
1760 REM poke end of file
1770 TEMP=INT((CLUSTER+RANGE)*1.5)
1780 IF (CLUSTER+RANGE) MOD 2 = 1 THEN BYTE1=(PEEK(&HCC00+TEMP) AND 15) + 240:BYTE2=255:GOTO 1800
1790 BYTE1=255:BYTE2=(PEEK(&HCC00+TEMP+1) AND 240) + 15
1800 POKE (&HCC00+TEMP),BYTE1:POKE (&HCE00+TEMP),BYTE1
1810 POKE (&HCC00+TEMP+1),BYTE2:POKE (&HCE00+TEMP+1),BYTE2
1820 RETURN
1880 REM
1890 REM Ending Routine
1895 REM
2000 CLS
2010 A$="HideFile":B$="b":C$="y":D$="John Vandegrift":COUNT=10
2020 GOSUB 2060
2030 A$=" ":B$=" ":C$=" ":D$=" ":COUNT=9
2040 GOSUB 2060
2050 LOCATE 23,1:RETURN
2060 FOR I=1 TO COUNT
2070 LOCATE I,37:PRINT A$;
2080 LOCATE 12,4*I:PRINT B$;
2090 LOCATE 12,81-(4*I):PRINT C$;
2100 LOCATE 24-I,33:PRINT D$;
2110 NEXT I
2120 RETURN
2130 REM
2140 REM Move Header back to top
2150 REM
2160 FOR I=14 TO 13 STEP -1:LOCATE I,33:PRINT SPACE$(15);:NEXT I
2170 A$="HideFile":FOR I=12 TO 3 STEP -1
2180 LOCATE I-1,37:PRINT A$;
2190 LOCATE I,37:PRINT SPACE$(8);
2195 NEXT I
2200 RETURN
2210 REM
2220 REM Help Routine
2230 REM
2240 CLS:LOCATE 4,10:PRINT "(1) File Directory lists the directory of the diskette."
2250 LOCATE 7,10:PRINT "(2) Alter Directory allows the user to change directory attributes."
2260 LOCATE 10,10:PRINT "(3) Save Changes is the only way to write changes (2) to the diskette."
2270 LOCATE 13,10:PRINT "(4) EXIT ALLOWS THE USER TO EXIT THE PROGRAM."
2280 LOCATE 16,10:PRINT "(5) Help is this screen."
2290 LOCATE 19,10:INPUT "Press return to continue....",IANS
2300 RETURN
65399 '** DONE - PRESS ENTER TO RETURN TO MENU **
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/