unit flprsprt;

interface

Function upstring(name:string):string;
Procedure blip(freq,duration:word);
Procedure PrintHeader(progname,progdesc,progvers:string;progdate:longint);
Procedure PositionCursor(x,y:byte);

implementation

uses
  support,
  TInterrupts;

Procedure blip(freq,duration:word);
var
  loops:word;
  l:longint;
begin
  {sound}
  Chan2SquarewaveOn(freq);
  {delay}
  l:=tickssincemidnight;
  for loops:=(duration div 18) downto 0 do begin
    repeat until l<>tickssincemidnight;
    l:=tickssincemidnight;
  end;
  {nosound}
  Chan2SquarewaveOff;
end;

Function upstring(name:string):string;
var
  foo:string;
  loop:byte;
begin
  for loop := 1 to Length(name) do
    foo[loop] := UpCase(name[loop]);
  foo[0]:=name[0];
  upstring:=foo;
end;

Procedure PrintHeader(progname,progdesc,progvers:string;progdate:longint);
const
  spacer=' ³ ';
{prints a standard welcome header for the utilities}
begin
  Writeln(progname,spacer,progdesc,spacer,'Version ',progvers,spacer,progdate);
  Writeln('Written by trixter@oldskool.org for the (now defunct) Flopper Project.');
  writeln('Use /? for available command-line options.');
end;

procedure PositionCursor(x,y:byte); assembler;
asm
  {position "cursor"}
  mov     ah,02
  mov     bh,0
  mov     dh,y
  mov     dl,x
  int     10h
end;

end.