A: Here is some code, that makes the sound of Turbo Pascal:
Note: This code is untried and contains elements that must be adjusted for Delphi.
{This should be re-written using TTimer.}
Function Waiting(ms: LongInt): BOOLEAN;
VAR
TickCount: LongInt;
Begin
Waiting:= false;
TickCount:= GetTickCount;
While GetTickCount - TickCount < ms do yield; {see multi-tasking}
Waiting:= true;
End;
{Works.}
Procedure NoSound;
Begin
port[$61]:= port[$61] and $FC;
End;
{Works, but just plays one tone.}
Function Sound(freq, dauer: Word): BOOLEAN;
VAR
b: byte;
Begin
if freq > 18 then begin
freq:= word(1193181 div longint(freq));
b:= port[$61];
if (b and 3)=0 then
begin
port[$61]:= b or 3;
port[$43]:= $b6;
end;
port[$42]:= byte(freq);
port[$42]:= byte(freq shr 8);
end;
Waiting(dauer);
NoSound;
End;