10 '******************************************************************** 20 '* * 30 '* PDRIVE.BAS Programm zur Formateinstellung in PDRIVE.SYS * 40 '* Copyright (c) by Klaus K{mpf Softwareentwicklung 1985, 1986 * 50 '* Version 2.1 vom 26.05.86 * 60 '* * 70 '* NUR F]R GENIE IIIs CP/M 2.2 AB VERSION 2.4 * 80 '* Originalversion 2.0 vom 10.07.85 * 90 '* Neue Version f}r 128 Formate 26.05.86 * 100 '* * 110 '* Kurze Erkl{rung der verwendeten Variablen: * 120 '* n$(x) : 128 Formatnamen * 130 '* sec(x) : Skew-Tabelle * 140 '* dpb(x) : 15 Bytes Drive Parameter Block * 150 '* dpb$ : Hexadezimal Darstellung von DPB(x) * 160 '* s(x) : Stellen an denen in DPB$ Freizeichen sind * 170 '* w$(x) : Menuepunkte * 180 '* mp : Anzahl der Menuepunkte -1 * 190 '* ds$(x) : Arten des R}ckseitenzugriffs * 200 '* st$(x) : STAT DSK: Parameter Texte * 210 '* st(x) : Werte zu st$(x) * 220 '* sm(x) : Maximalwerte zu st(x) * 230 '* nmax : Anzahl der benutzten Formate * 240 '* f$ : Aktueller Formatnamen * 250 '* f : Aktuelle Formatnummer * 260 '* fi$ : Filenamen des PDRIVE.SYS-Files * 270 '* spt : Sectors per Track * 280 '* bsh : Block Shift Factor * 290 '* blm : Block Lenght Mask * 300 '* exm : EXtent Mask * 310 '* dsm : maximum data block number (-1) * 320 '* drm : number of directory entries (-1) * 330 '* al0,al1: bit string for directory blocks * 340 '* cks : length of directory check vector (drm+1)/4 * 350 '* off : number of reserved tracks * 360 '* s2 : =1 falls doppelseitiger Zugriff * 370 '* sl : Physikalische Sektorl{nge (128,256,512,1024) * 380 '* dd : =1 falls double density * 390 '* iv : =1 falls Sektoren invertiert * 400 '* dt : =1 falls double track * 410 '* ds : falls s2=1: Art des doppelseitigen Zugriffs * 420 '* md : Maximale art# des ds-zugriffs * 430 '* db : Anzahl der Directory Blocks * 440 '* ps : Anzahl der physikalischen Sektoren pro Spur * 450 '* neu : [nderungsflag (1=neues Format, 0=altes Format) * 460 '* bu : Buildflag (1=Build only, 0=Build&show) * 470 '* i : Allesvariable * 480 '* j : Antwort von Upro Get Answer * 490 '* * 500 '******************************************************************** 510 ' ************** INITIALISIERUNG *************** 520 DIM N$(127),SEC(63),DPB(14),W$(9),DS$(7),ST$(7),ST(7) 530 DIM S(14),SM(7) 540 ON ERROR GOTO 4540 550 FOR I = 0 TO 14:READ S(I):NEXT I 560 DATA 0,1,1,1,1,0,1,0,1,0,1,0,1,0,0 570 FOR I = 0 TO 7:READ SM(I):NEXT I 580 DATA 65536,8192,8192,512,2048,128,512,160 590 FI$="PDRIVE.SYS" '*** Filenamen (evtl. mit Laufwerksangabe) 600 B$=CHR$(7)+CHR$(11)+CHR$(13)+CHR$(27)+"t" 610 B1$=CHR$(7)+CHR$(8)+CHR$(32)+CHR$(8) 620 W$(1)="Alle Formatnamen anzeigen" 630 W$(2)="Format anzeigen" 640 W$(3)="Neues Format eingeben" 650 W$(4)="Bestehendes Format {ndern" 660 W$(5)="Format l|schen" 670 W$(6)="Formatnamen {ndern" 680 W$(7)=" " 690 W$(8)=" " 700 W$(9)=" " 710 W$(0)="Ende des Programms" 720 MP=6 'maximaler Menuepunkt 730 DS$(0)="R}ckseite laut Sektortabelle" 740 DS$(1)="Abwechselnd Vorder- und R}ckseite" 750 DS$(2)="Vorderseite ab Track 0, R}ckseite ab Track 0" 760 DS$(3)="Sektor-offset auf R}ckseite" 770 DS$(4)="Vorderseite ab Track 0, R}ckseite ab Track 79 (39)" 780 DS$(5)=" " 790 DS$(6)=" " 800 DS$(7)=" " 810 MD=4 'maximale ds-Art 820 ST$(0)="128 Byte Record Capacity" 830 ST$(1)="Kilobyte Drive Capacity" 840 ST$(2)="32 Byte Directory Entries" 850 ST$(3)="Checked Directory Entries" 860 ST$(4)="Records / Extend" 870 ST$(5)="Records / Block" 880 ST$(6)="Sectors / Track" 890 ST$(7)="Reserved Tracks" 900 ' ******** Einlesen der Namen in N$(x) ************* 910 OPEN"R",1,FI$,128 920 FIELD 1,128 AS DUMMY$ 930 FOR I=0 TO 15 940 GET 1,I+1 950 FOR J=0 TO 7 960 FIELD 1,J*16 AS DUMMY$,16 AS N$ 970 N$(I*8+J)=N$ 980 IF NMAX=0 AND ASC(N$)=26 THEN NMAX=I*8+J 990 NEXT J 1000 NEXT I 1010 ' ********** Hauptmenue ************ 1020 PRINT CHR$(26) 1030 PRINT"PDRIVE.SYS-Einstellungsprogramm (c) 1985 by Klaus K{mpf Softwareentwicklung" 1040 PRINT CHR$(27)".1"CHR$(27)"_2" 1050 PRINT CHR$(9)"Auswahl:" 1060 PRINT 1070 FOR I = 1 TO MP 1080 PRINT CHR$(9);"(";I;") : ";W$(I) 1090 NEXT I 1100 PRINT 1110 PRINT CHR$(9);"( 0 ) : ";W$(0) 1120 PRINT 1130 PRINT CHR$(9)"Ihre Wahl: "; 1140 GOSUB 1190 1150 IF A<48 OR A>57 THEN PRINT CHR$(7);:GOTO 1140 1160 W=A-48:PRINT CHR$(26);W$(W):PRINT 1170 ON W+1 GOSUB 2690,2800,2910,2990,4000,4090,4230,4450,4470,4490 1180 GOTO 1010 1190 ' ******** UPRO INKEY ********* 1200 A$=INKEY$ 1210 A$=INKEY$:IF A$="" THEN 1210 1220 A=ASC(A$):RETURN 1230 ' ******** UPRO HEXCONV ******** 1240 H$=HEX$(H):IF H<16 THEN H$="0"+H$ 1250 RETURN 1260 ' ******** UPRO ASK Q/N/J ******** 1270 A$="Alles richtig (Q/J/N)":A1$="QqNnJj" 1280 ' ******** UPRO GET ANSWER ******** 1290 PRINT CHR$(27)".1";A$;" ";:INPUT X$ 1300 IF X$="" THEN PRINT B$;:GOTO 1290 1310 IF INSTR(A1$,X$)=0 THEN PRINT B$;:GOTO 1290 1320 J=INT((INSTR(A1$,X$)+1)/2) 1330 RETURN 1340 ' ******** UPRO DPB$ BUILD ******** 1350 DPB$="" 1360 FOR I = 0 TO 14 1370 H=DPB(I):GOSUB 1230:DPB$=DPB$+H$ 1380 IF S(I)=1 THEN DPB$=DPB$+" " 1390 NEXT I 1400 RETURN 1410 ' ******** UPRO GET FORMAT NAME ******** 1420 INPUT"Welches Format (Nummer oder Name)";F$ 1430 IF F$="x" OR F$="X" THEN F=-1:RETURN 1440 IF LEN(F$) > 16 THEN PRINT CHR$(7)"Name zu lang !!":GOTO 1410 1450 IF LEN(F$) < 16 THEN F$=F$+" ":GOTO 1450 1460 F=VAL(F$):IF F>0 AND F127 THEN S2=1 1850 NEXT I 1860 PDB=ASC(P$) 1870 DD=PDB AND 1 1880 IV=INT(PDB/2) AND 1 1890 SL=128 * 2^(INT(PDB/4) AND 3) 1900 DT=INT(PDB/128) AND 1 1910 DS=INT(PDB/16) AND 7 1920 PS=SPT*128/SL 1930 IF DS<>0 THEN S2=1 1940 RETURN 1950 ' ************* UPRO PUT FORMAT PARAMETER **************** 1960 FIELD 1,15 AS D$,1 AS P$,64 AS S$,32 AS DUMMY$,16 AS N$ 1970 AL=0: DB=INT((ST(2)*32)/(128*ST(5))) 1980 IF DB=0 THEN DB=1 1990 FOR I=15 TO 16-DB STEP -1 2000 AL=AL+2^I 2010 NEXT I 2020 AL0=INT(AL/256):AL1=AL-AL0*256 2030 DPB(0)=ST(6)-256*DPB(1) 2040 DPB(1)=INT(ST(6)/256) 2050 DPB(2)=LOG(ST(5))/LOG(2) 2060 DPB(3)=ST(5)-1 2070 DPB(4)=ST(4)/128-1 2080 I=ST(0)/ST(5)-1:I1=INT(I/256) 2090 DPB(5)=I-256*I1 2100 DPB(6)=I1 2110 I=ST(2)-1:I1=INT(I/256) 2120 DPB(7)=I-256*I1 2130 DPB(8)=I1 2140 DPB(9)=AL0 2150 DPB(10)=AL1 2160 I=ST(3)/4:I1=INT(I/256) 2170 DPB(11)=I-256*I1 2180 DPB(12)=I1 2190 I=INT(ST(7)/256) 2200 DPB(13)=ST(7)-256*I 2210 DPB(14)=I 2220 GOSUB 1340 'Build DPB$ 2230 PDB=DD+2*IV+4*(LOG(SL)/LOG(2)-7)+16*DS+128*DT 2240 PDB$=CHR$(PDB) 2250 FOR I = 0 TO 14 2260 D1$=D1$+CHR$(DPB(I)) 2270 NEXT I 2280 SEC$="" 2290 FOR I = 0 TO 63:SEC$=SEC$+CHR$(SEC(I)):NEXT I 2300 IF BU=1 THEN RETURN 2310 FIELD 1,15 AS D$,1 AS P$,64 AS S$,32 AS DUMMY$,16 AS N$ 2320 LSET D$=D1$:LSET P$=PDB$:LSET S$=SEC$ 2330 LSET DUMMY$=STRING$(32,192):LSET N$=F$ 2340 GOSUB 2420 'Show new parameters 2350 PRINT:PRINT:A$="Alles richtig (J/N)":A1$="QqNnJj":GOSUB 1280 2360 IF J<>3 THEN GOTO 2410 'No put if not correct 2370 PRINT:PRINT"Neue Parameter gespeichert" 2380 FOR I = 1 TO 2000:NEXT I 2390 IF NEU=1 THEN N$(NMAX)=F$:NMAX=F 'set nmax if new format 2400 PUT 1,16+F 2410 RETURN 2420 ' ********* SHOW FORMAT PARAMETER *********** 2430 PRINT CHR$(26)CHR$(27)".0Format Nummer "F": "F$ 2440 PRINT:PRINT"Logische Parameter:":PRINT 2450 FOR I = 0 TO 7:PRINT CHR$(9);ST(I);CHR$(9);ST$(I):NEXT I 2460 PRINT:PRINT:PRINT CHR$(9);"Drive Parameter Block (DPB):" 2470 PRINT:PRINT CHR$(9);DPB$:PRINT:PRINT:PRINT:PRINT 2480 PRINT"Taste dr}cken zur Anzeige der physikalischen Parameter" 2490 GOSUB 1190 'Wait for key 2500 PRINT CHR$(26)"Format Nummer "F": "F$ 2510 PRINT:PRINT"Physikalische Parameter":PRINT 2520 PRINT"Sektorl{nge:";SL;"Bytes" 2530 IF DD=0 THEN PRINT"Single"; ELSE PRINT"Double"; 2540 PRINT" Density" 2550 IF IV=0 THEN PRINT"Normale"; ELSE PRINT"Invertierte"; 2560 PRINT" Aufzeichnung" 2570 IF DT=1 THEN PRINT"Double Step" 2580 IF S2=1 THEN PRINT:PRINT"Doppelseitig":PRINT DS$(DS) 2590 PRINT:PRINT"Sektortabelle: ";PS;"Physikalische Sektoren":PRINT 2600 FOR I = 0 TO PS-1 2610 PRINT USING"### ";(SEC(I) AND 127); 2620 IF (DS<>0) OR (S2=0) THEN 2640 2630 IF SEC(I)>127 THEN PRINT"R"; ELSE PRINT"V"; 2640 PRINT" , "; 2650 IF ((I+1) MOD 8) = 0 THEN PRINT STRING$(3,8);" " 2660 NEXT I 2670 PRINT STRING$(3,8);" " 2680 RETURN 2690 ' ********** (0) *********** 2700 FOR I=0 TO 15 2710 FOR J=0 TO 7 2720 FIELD 1,J*16 AS DUMMY$,16 AS NA$ 2730 LSET NA$=N$(I*8+J) 2740 NEXT J 2750 PUT 1,I+1 2760 NEXT I 2770 CLOSE 2780 PRINT CHR$(27);".4" 2790 END 2800 ' ******** (1) ******* 2810 PRINT CHR$(27)".0"; 2820 S=0 2830 FOR I= 0 TO NMAX-1 2840 PRINT USING "###: ";I+1;:PRINT N$(I); 2850 S=S+1:IF S MOD 3 = 0 THEN PRINT:PRINT 2860 IF S MOD 30 <> 0 THEN 2890 2870 PRINT CHR$(27)"=7 Taste dr}cken f}r n{chste Seite"; 2880 GOSUB 1190 : PRINT CHR$(26):PRINT 2890 NEXT I 2900 GOTO 1190 'Wait for key 2910 ' ********** (2) ************ 2920 GOSUB 1410 'Get Format name 2930 IF F=-1 THEN RETURN 2940 GET 1,16+F 'Get record from PDRIVE.SYS 2950 GOSUB 1550 'Get Format Parameter 2960 GOSUB 2420 'Show Format Parameter 2970 GOSUB 1190 'Wait for key 2980 RETURN 2990 ' ********** (3) ************ 3000 I=1:NA$=STRING$(17,32) 3010 PRINT:PRINT CHR$(27)".1"; 3020 PRINT CHR$(9);"Name des neuen Formates ? ";STRING$(16,"_");STRING$(16,8); 3030 GOSUB 1190 'Wait for key 3040 IF A>95 THEN A=A-32:A$=CHR$(A) 3050 IF A<>8 THEN 3100 3060 IF I=1 THEN PRINT CHR$(7);:GOTO 3030 3070 MID$(NA$,I,1)=" ":PRINT A$;"_";A$; 3080 IF I>1 THEN I=I-1 3090 GOTO 3030 3100 IF (I=1) AND (A=13) THEN RETURN 'No name given 3110 IF (I=17) AND (A<>13) THEN PRINT CHR$(7);:GOTO 3030 3120 IF A=13 THEN NA$=LEFT$(NA$,16):PRINT STRING$(17-I," "):GOTO 3140 3130 MID$(NA$,I,1)=A$:I=I+1:PRINT A$;:GOTO 3030 3140 F=NMAX+1:F$=NA$:NEU=1 3150 ' ******** UPRO CHANGE FORMAT ******** 3160 PRINT:PRINT CHR$(9);"Format Nummer";F;": ";F$ 3170 PRINT:PRINT"Eingabe der logischen Parameter":PRINT 3180 FOR I = 0 TO 7 3190 SX=0:PRINT ST$(I);TAB(26);" (";ST(I);")";TAB(38);"? "; 3200 SX=0:ST$="" 3210 SX$=INKEY$: IF SX$="" THEN 3210 3220 PRINT SX$;:IF SX$=CHR$(13) THEN PRINT CHR$(10);:GOTO 3290 3230 IF SX$=CHR$(8) AND SX=0 THEN PRINT CHR$(7);" ";:GOTO 3210 3240 IF SX$<>CHR$(8) THEN 3270 3250 IF SX>0 THEN PRINT " ";CHR$(8);:SX=SX-1 3260 IF SX=0 THEN GOTO 3200 ELSE ST$=LEFT$(ST$,SX):GOTO 3210 3270 IF ASC(SX$)<48 OR ASC(SX$)>57 THEN PRINT B1$;:GOTO 3210 3280 ST$=ST$+SX$:SX=SX+1:GOTO 3210 3290 IF SX <> 0 THEN ST(I)=VAL(ST$) 3300 IF ST(I)>SM(I) THEN PRINT B$;:GOTO 3190 3310 NEXT I 3320 SL=128:BU=1:GOSUB 1950 'Put Format Parameter for DPB$ Build 3330 PRINT:PRINT"Dies ergibt folgenden Drive Parameter Block:":PRINT 3340 PRINT CHR$(9);DPB$:PRINT 3350 GOSUB 1260 3360 IF J=1 THEN RETURN 3370 IF J=2 THEN PRINT CHR$(27)"=( ";CHR$(27);"Y":GOTO 3180 3380 PRINT CHR$(26);W$(W):PRINT:PRINT 3390 PRINT"Eingabe der physikalischen Parameter" 3400 PRINT 3410 INPUT"Physikalische Sektorl{nge ";SL 3420 IF SL<128 OR SL>1024 THEN PRINT B$;:GOTO 3410 3430 IF INT(LOG(SL)/LOG(2)) <> (LOG(SL)/LOG(2)) THEN PRINT B$;:GOTO 3410 3440 A$="(S)ingle oder (D)ouble Density":A1$="SsDd":GOSUB 1280 3450 DD=J-1 3460 A$="(N)ormale oder (I)nvertierte Aufzeichnung":A1$="NnIi":GOSUB 1280 3470 IV=J-1 3480 A$="Double Step (J/N)":A1$="NnJj":GOSUB 1280 3490 DT=J-1 3500 A$="Doppelseitig (J/N)":A1$="NnJj":GOSUB 1280 3510 S2=J-1 3520 IF S2=0 THEN 3570 'not double sided 3530 PRINT:PRINT"Art der doppelseitigen Aufzeichnung ?":PRINT 3540 FOR I = 0 TO MD:PRINT "(";I+1;") ";DS$(I):NEXT I:PRINT 3550 A$="Welche Art":A1$="1122334455":GOSUB 1280 3560 DS=J-1 3570 PRINT CHR$(26);W$(W):PRINT:PRINT 3580 PRINT"Eingabe der Sektortabelle" 3590 PS=ST(6)*128/SL 'Anzahl der phys. Sektoren 3600 PRINT 3610 IF (DS=0) AND (S2=1) THEN 3880 3620 A$="Eingabe von Hand (J/N)":A1$="NnJj":GOSUB 1280 3630 IF J=2 THEN 3880 3640 PRINT 3650 A$="Nummer des ersten Sektors (0/1)":A1$="0011":GOSUB 1280 3660 LS=J-1 3670 PRINT 3680 PRINT"Skewfaktor (1-";:PRINT USING"##";PS-1;:PRINT") ";:INPUT SK 3690 HS=LS+PS-1 'Highest sektor # 3700 GN=SK:GM=PS 3710 GR=GM MOD GN 3720 GM=GN:GN=GR 3730 IF GR<>0 THEN 3710 3740 GN=GM 3750 N=PS/GN 'GN = ggT von sk und ps, n=wraparound number 3760 N1=N 3770 NB=0:SE=NB 3780 FOR I = 0 TO PS-1 3790 SEC(I) = SE+LS 3800 SE = SE + SK 3810 IF SE > HS THEN SE=SE-PS 3820 N1=N1-1 3830 IF N1=0 THEN NB=NB+1:SE=NB:N1=N 3840 NEXT I 3850 FOR I = PS TO 63:SEC(I)=0:NEXT I 3860 GOTO 3970 3870 '******** 3880 PRINT:PRINT"Eingabe der Sektortabelle von Hand":PRINT 3890 FOR I = 0 TO PS-1 3900 PRINT"Sektor Nummer";I+1;:INPUT SEC(I) 3910 IF SEC(I)>127 THEN PRINT B$;:GOTO 3900 3920 IF (DS<>0) OR (S2=0) THEN 3960 3930 PRINT "Sektor Nummer";I+1;": ";SEC(I);CHR$(9); 3940 A$="(V)order- oder (R)}ckseite":A1$="VvRr":GOSUB 1280 3950 SEC(I)=SEC(I)+128*(J-1) 3960 NEXT I 3970 BU=0:GOSUB 1950 'Put Format Parameter & ask if correct 3980 IF J=1 THEN GOTO 3380 'Ask physical again 3990 RETURN 4000 ' ********** (4) ************ 4010 GOSUB 1410 'Get Format name 4020 IF F=-1 THEN RETURN 4030 GET 1,16+F 'Get record 4040 GOSUB 1550 'Get Format parameter 4050 PRINT CHR$(26):PRINT:PRINT:PRINT 4060 NEU=0 4070 GOSUB 3150 4080 RETURN 4090 ' ********** (5) ************ 4100 GOSUB 1410 'Get Format name 4110 IF F=-1 THEN RETURN 4120 PRINT:PRINT:PRINT"Format Nummer";F;": ";F$:PRINT 4130 A$="Soll dieses Format gel|scht werden (J/N)":A1$="NnJj":GOSUB 1280 4140 IF J<>2 THEN RETURN 4150 FOR I = F TO 127 4160 GET 1,I+17:PUT 1,I+16 4170 N$(I-1)=N$(I) 4180 NEXT I 4190 N$(I-1)=STRING$(16,26) 4200 FIELD 1,128 AS A$:LSET A$=STRING$(128,26):PUT 1,144 4210 NMAX=NMAX-1 4220 RETURN 4230 ' ********** (6) ************ 4240 GOSUB 1410 4250 IF F=-1 THEN RETURN 4260 PRINT:PRINT:PRINT"Format Nummer";F;": ";F$:PRINT 4270 I=1:NA$=STRING$(17,32) 4280 PRINT:PRINT CHR$(27)".1"; 4290 PRINT CHR$(9);"Neuer Formatname ? ";STRING$(16,"_");STRING$(16,8); 4300 GOSUB 1190 'Wait for key 4310 IF A>95 THEN A=A-32:A$=CHR$(A) 4320 IF A<>8 THEN 4370 4330 IF I=1 THEN PRINT CHR$(7);:GOTO 4300 4340 MID$(NA$,I,1)=" ":PRINT A$;"_";A$; 4350 IF I>1 THEN I=I-1 4360 GOTO 4300 4370 IF (I=1) AND (A=13) THEN RETURN 'No name given 4380 IF (I=17) AND (A<>13) THEN PRINT CHR$(7);:GOTO 4300 4390 IF A=13 THEN NA$=LEFT$(NA$,16):PRINT STRING$(17-I," "):GOTO 4410 4400 MID$(NA$,I,1)=A$:I=I+1:PRINT A$;:GOTO 4300 4410 FIELD 1,112 AS DUMMY$,16 AS A1$ 4420 GET 1,F+16:LSET A1$=NA$:PUT 1,F+16 'Change name in record 4430 N$(F-1)=NA$ 'Change name in nametable 4440 RETURN 4450 ' ********** (7) ************ 4460 GOTO 4510 4470 ' ********** (8) ************ 4480 GOTO 4510 4490 ' ********** (9) ************ 4500 GOTO 4510 4510 ' ******** UNDEFINED FUNCTION ******** 4520 PRINT CHR$(26):PRINT:PRINT:PRINT 4530 PRINT CHR$(9)"Keine Funktion !":GOTO 1190 4540 ' ******** ERROR PROCESSING ******** 4550 PRINT CHR$(26);CHR$(7):PRINT:PRINT 4560 PRINT CHR$(9)"F E H L E R ! !": GOSUB 1190 4570 RESUME 1010 CESSING ******** 4550 PRINT CHR$(26);CHR$(7):PRINT:PRINT 4560 PRINT CHR$(9)"F E H L E