summaryrefslogtreecommitdiff
path: root/packages/extra/amunits/demos/showdevs.pas
blob: f2aad4940bfc78eaba801d36cb8ae4b5cad99005 (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
program ShowDevs;

{

  Programm       : Devices  - listet angemeldet Devices auf
  Sprache        : PCQ-Pascal 1.2b nach einem kleinen Hack von
                   mir in MCC-Pascal V2.04
  Autor          : Andreas Neumann für Purity
  Datum          : 01.03.1992

}

{

  Translated to fpc pascal
  24 Mar 2001.

  nils.sjoholm@mailbox.swipnet.se

}


uses exec,amigados;

CONST   Device_Types : Array [0..2] OF pchar = (('DEVICE     '),
                                                 ('DIRECTORY  '),
                                                 ('VOLUME     '));

VAR
    mydosbase    : pDOSLibrary;
    myrootptr    : pRootNode;
    myinfoptr    : pDosInfo;
    mydeviceptr  : pDeviceNode;
    mystr        : pchar;
    eingabe      : CHAR;
    mystartup    : pFileSysStartupMsg;
    myenvec      : pDOSEnvec;
    i            : longint;

BEGIN
 WRITELN;
 WRITELN ('Device-Lister PD © 1992 by Andreas Neumann (NEUDELSoft) für Purity');

 mydosbase:= pDOSLibrary(_DosBase);

 { Man braucht ja die Adresse der DOSLibrary                      }

 myrootptr:=mydosbase^.dl_Root;
 myinfoptr:=BADDR(myrootptr^.rn_Info);
 mydeviceptr:=BADDR(myinfoptr^.di_DevInfo);

 { Man hangelt sich von Struktur zu Struktur                      }

 WHILE mydeviceptr<>NIL DO
 BEGIN
  WITH mydeviceptr^ DO
  BEGIN
   WRITELN;

   {mystr:=Address(Integer(BPTRtoAPTR(dn_Name))+1);}
   mystr:=pointer(longint(BADDR(dn_Name))+1);

   { Trick : dn_Name ist ein BSTR. Dies ist ein BPTR auf ein Feld, das }
   {         mit der Anzahl der Stringzeichen beginnt (daher +1) und   }
   {         dann die Zeichen enthält.                                 }

   WRITELN ('Name        : ',mystr,':');
   WRITELN ('Type        : ',Device_Types[dn_Type]);
   IF NOT (dn_Lock=0) THEN
    WRITELN ('there is a lock on this Device')
   ELSE
    WRITELN;
   WRITELN;

   mystartup:=BADDR(dn_Startup);
   myenvec:=BADDR(mystartup^.fssm_Environ);

   IF (NOT(dn_Startup=0)) AND (dn_Type=DLT_DEVICE) AND (myenvec^.de_SizeBlock>0) THEN
   BEGIN

    {          es ist ein dateiorientiertes Device !!!             }
    {  im Gegensatz hierzu : ein logisches Device wie L: oder S:   }

    WRITELN ('More information regarding the Organisation of Devices: ');
    WITH myenvec^ DO
    BEGIN
     WRITELN;
     WRITELN ('Size of the sectors        : ',de_SizeBlock*4,' Bytes');
     WRITELN ('Number of sectors per Block: ',de_SectorPerBlock);
     WRITELN ('Blocks per Track           : ',de_BlocksPerTrack);
     WRITELN ('Startcylinder              : ',de_LowCyl);
     WRITELN ('Endcylinder                : ',de_HighCyl);
     WRITELN ('Surfaces                   : ',de_Surfaces);

     i:=(de_HighCyl+1-de_LowCyl)*(de_Surfaces)*
         (de_BlocksPerTrack)*(de_SectorPerBlock)*(de_SizeBlock*4);

     { Anzahl der Zylinder * Anzahl der Oberflächen * Anzahl der Blöcke
        pro Spur * Anzahl der Sektoren pro Block * Größe eines
        Blockes * 4                                                     }

     WRITELN ('Storage capacity  : ',i,' Bytes    = ',i DIV 1024,' KBytes');
    END;
    WRITELN;
    writeln('The exec unit number is ',mystartup^.fssm_Unit);
   END;
  END;

  WRITELN ('(M)ore oder (S)top ?');
  READLN (eingabe);

  mydeviceptr:=BADDR(mydeviceptr^.dn_Next);
  IF (UpCase(eingabe)='S') THEN mydeviceptr:=NIL;
 END;

 WRITELN ('Good Bye. NEUDELSoft wünscht noch viel Spaß mit Amiga und Pascal.');

END.