about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-07-29 19:46:41 +0200
committerLeah Neukirchen <leah@vuxu.org>2023-07-29 19:46:41 +0200
commit1e7725ed6dfe6b1fe5a50ddd08dfb2509e2e3e82 (patch)
tree5594d1b0671be7e9d6dba7d0490bb2cb16585094
downloaddosfetch-1e7725ed6dfe6b1fe5a50ddd08dfb2509e2e3e82.tar.gz
dosfetch-1e7725ed6dfe6b1fe5a50ddd08dfb2509e2e3e82.tar.xz
dosfetch-1e7725ed6dfe6b1fe5a50ddd08dfb2509e2e3e82.zip
initial import of dosfetch
-rw-r--r--dosfetch.pas137
1 files changed, 137 insertions, 0 deletions
diff --git a/dosfetch.pas b/dosfetch.pas
new file mode 100644
index 0000000..c50cc97
--- /dev/null
+++ b/dosfetch.pas
@@ -0,0 +1,137 @@
+(* dosfetch - a neofetch clone for DOS
+ *
+ * Written by Leah Neukirchen <leah@vuxu.org>
+ *
+ * To the extent possible under law, the creator of this work has waived
+ * all copyright and related or neighboring rights to this work.
+ *)
+
+program dosfetch;
+
+uses crt, dos;
+
+{
+More ideas:
+- uptime (hard)
+- CPU details
+}
+
+function cmos(cmd: byte): byte;
+begin
+   port[$70] := cmd;
+   cmos := port[$71];
+end;
+
+procedure base_memory;
+begin
+   writeln(cmos($15) + 256*cmos($16), ' KB');
+end;
+
+procedure extended_memory;
+begin
+   writeln(cmos($17) + 256*longint(cmos($18)), ' KB');
+end;
+
+procedure disksize(disk: byte);
+var a, b, c, d : integer;
+   total, free : longint;
+begin
+   asm
+     mov ah, $36;
+     mov dl, disk;
+     int $21;
+     mov a, ax;
+     mov b, bx;
+     mov c, cx;
+     mov d, dx;
+   end;
+   free := longint(a)*longint(c)*longint(b);
+   total := longint(a)*longint(c)*longint(d);
+   write(free div 1024, '/', total div 1024, ' KB (');
+   writeln(round(100-(free/total)*100), '% free)');
+end;
+
+procedure dosver;
+var maj, min, ven : byte;
+    smaj, smin, sven :  string;
+begin
+   asm
+     mov ax, $3000;
+     int $21;
+     mov ven, bh;
+     mov ax, $3306;
+     int $21;
+     mov maj, bl;
+     mov min, bh;
+   end;
+
+  case ven of
+    $00 : write('IBM DOS ');
+    $FD : write('FreeDOS ');
+    $FF : write('MS DOS ');
+    else write('Unknown DOS ');
+  end;
+  writeln(maj, '.', min);
+end;
+
+procedure floppy;
+var a : byte; f : integer;
+begin
+   asm
+     int $11;
+     mov a, al;
+  end;
+  if ((a and $1) = $1) then
+     f := (a shr 6) + 1
+  else
+     f := 0;
+  writeln(f);
+end;
+
+procedure fpu;
+var a : byte;
+begin
+   asm
+     int $11;
+     mov a, al;
+  end;
+  if ((a and $2) = $2) then
+     writeln('YES')
+  else
+     writeln('no');
+end;
+
+
+procedure colorline(s : string);
+var y, b, r : string;
+begin
+   write(' ');
+   textcolor(yellow);     write(copy(s, 1, 14));
+   textcolor(lightblue);  write(copy(s, 15,14));
+   textcolor(lightred);   write(copy(s, 29,14));
+   normvideo;
+   write('  ');
+end;
+
+begin
+   clrscr;
+   writeln;
+
+   colorline('88888888ba,     ,ad8888ba,    ad88888ba  ');
+   textcolor(white); write('OS: '); normvideo; dosver; 
+   colorline('88      `"8b   d8"''    `"8b  d8"     "8b ');
+   textcolor(white); write('Shell: '); normvideo; writeln(getenv('COMSPEC')); 
+   colorline('88        `8b d8''        `8b Y8,         ');
+   textcolor(white); write('Floppy drives: '); normvideo; floppy;
+   colorline('88         88 88          88 `Y8aaaaa,   ');
+   textcolor(white); write('Disk: '); normvideo; disksize(0);
+   colorline('88         88 88          88   `"""""8b, ');
+   textcolor(white); write('Base Memory: '); normvideo; base_memory;
+   colorline('88         8P Y8,        ,8P         `8b ');
+   textcolor(white); write('Ext. Memory: '); normvideo; extended_memory;
+   colorline('88      .a8P   Y8a.    .a8P  Y8a     a8P ');
+   textcolor(white); write('Floating Point Unit: '); normvideo; fpu;
+   colorline('88888888Y"''     `"Y8888Y"''    "Y88888P"');
+
+   writeln;
+end.