Board index » delphi » CRT-replacement

CRT-replacement

Hi everybody,

I'm looking for the source code of the CRT unit or of a replacement of
it. The reason is that as I have written most of the CRT procedures
myself I (nearly) don't need the CRT unit anymore. The only procedures I
haven't rewritten are the Sound, Delay and NoSound procedures.

Important: There are lots of messages about runtime error #200.
           If anybody can send me the source code of the          
procedures ahead I'd be glad if the code run on of            faster
(>200Mhz) computers, too.

Thank you in advance,

Yours, Olaf

 

Re:CRT-replacement


Quote
Olaf Uebersch?r (Olaf.Uebersch...@t-online.de) wrote:

: I'm looking for the source code of the CRT unit or of a replacement of
: it. The reason is that as I have written most of the CRT procedures
: myself I (nearly) don't need the CRT unit anymore. The only procedures I
: haven't rewritten are the Sound, Delay and NoSound procedures.

: Important: There are lots of messages about runtime error #200.
:            If anybody can send me the source code of the          
: procedures ahead I'd be glad if the code run on of            faster
: (>200Mhz) computers, too.

If you have all required procedures, you don't need the original crt.tpu.
Just create your own one with identical declarations (look up the
variables in the online help) and put this into turbo.tpl with tpumover.

newdelay can be found on my homepage in the section run time error 200,
for sound and nosound try these:

procedure sound (freq:word);
begin
  if freq = 0 then exit;
  freq := 1193180 div freq;
  port [$43] := $B6;               { set timer 2 to square wave generator }
  port [$42] := lo(freq);          { set reload value }
  port [$42] := hi(freq);
  port [$61] := port [$61] or 3;   { enable speaker }
end;

procedure nosound;
begin
  port [$61] := port [$61] and $FC; { disable speaker }
end;

Klaus
--
Klaus Hartnegg, Institut fuer Biophysik, Hansa-Strasse 9a, D-79104 Freiburg
hartn...@uni-freiburg.de   http://www.brain.uni-freiburg.de/~klaus/

Re:CRT-replacement


JRS:  In article <6tm87i$hv...@news02.btx.dtag.de> of Tue, 15 Sep 1998
17:30:26 in comp.lang.pascal.borland, =?iso-8859-1?q?Olaf_Uebersch=E4r?=

Quote
<Olaf.Uebersch...@t-online.de> wrote:
>I'm looking for the source code of the CRT unit or of a replacement of
>it. The reason is that as I have written most of the CRT procedures
>myself I (nearly) don't need the CRT unit anymore. The only procedures I
>haven't rewritten are the Sound, Delay and NoSound procedures.

If that is literally true, then, if you place them somewhere from which
that can be fetched for some of us to test, they should do to fill the
gaps in the list in TSFAQP #124.

Doubtless you will be offered at least one new Delay; they're referred
to frequently here.

IIRC, both Sound and NoSound are trivial enough.

If, indeed, your work can be completed and given to the public, and if
it can be said to be intellectually independent of the contents of
Borland's Crt unit, and if it is compatible with BP7 DOS & DPMI modes,
hence TP7, and maybe TP<7, and anything I've forgotten, then it would be
a valuable replacement, after testing, for the original Crt unit.
Borland would probably be quietly relieved.

-

I believe this is as good as Borland's NoSound, plus the converse :

 procedure Silence ;
 begin Port[$61] := Port[$61] and not $03 end {Silence} ;

 procedure Speaker ;
 begin Port[$61] := Port[$61] or $03 end {Speaker} ;

-

Timo: the text of TSFAQP #124 refers to various solutions for Delay, but
the **list** only cites your FAQ #67.  How about adding " (and above)"
after the "FAQ #67"?

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL:http://www.merlyn.demon.co.uk/> - TP/BP/&c.  FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:CRT-replacement


Quote
Olaf Uebersch?r wrote:

> Hi everybody,

> I'm looking for the source code of the CRT unit or of a replacement of
> it. The reason is that as I have written most of the CRT procedures
> myself I (nearly) don't need the CRT unit anymore. The only procedures I
> haven't rewritten are the Sound, Delay and NoSound procedures.

> Important: There are lots of messages about runtime error #200.
>            If anybody can send me the source code of the
> procedures ahead I'd be glad if the code run on of            faster
> (>200Mhz) computers, too.

> Thank you in advance,

> Yours, Olaf

see

{*********************************************************}
procedure Sound (hz: word);
var   sv: word;
begin
  if hz < 19 then hz := 19;
  sv := 1193180 div hz; {18.206...  * 65536 = 1193180}
  asm
    in al,61h;  or al,3;  out 61h,al
    in al,61h;  or al,3;  out 61h,al
    mov cx, sv                 {set timer #3}
    mov al,0B6h; out 43h,al    {port [$43] := $B6;}
    mov al,cl;   out 42h,al    {port [$42] := lo (sv);}
    mov al,ch;   out 42h,al    {port [$42] := hi (sv);}
  end;
end;
{*********************************************************}
procedure NoSound;
begin
  asm
    in  al,61h
    and al,0fch
    out 61h,al
  end;
end;

Re:CRT-replacement


Quote
Olaf Uebersch?r wrote:
> The only procedures I
> haven't rewritten are the Sound, Delay and NoSound procedures.

Here are the Pascal-ized versions of Sound & NoSound, taken from by
BASIC interpretor which was written in assembler.  They worked in my
BASIC, so they should also work under TP.

Procedure Sound(freq : integer); assembler;

asm
        mov     bx, [freq]
        mov     ax, $34dd
        mov     dx, $0012
        cmp     dx, bx         {is it too low?}
        jnb     @snd2          {exit if so}
        div     bx             {divide to get value to stuff into
counter}
        mov     bx, ax
        in      al, $61
        test    al, $03        {ready?}
        jne     @snd1
        or      al, $03        {then make so}
        out     $61, al
        mov     al, $b6
        out     $43, al
@snd1:  mov     al, bl         {shove the count into the port}
        out     $42, al
        mov     al, bh         {one byte at a time}
        out     $42, al
@snd2:
end;

Procedure NoSound; assembler;

asm
        in      al, $61        {turn off the speaker}
        and     al, $fc
        out     $61, al
end;

--
Will <nospam.wdeco...@geocities.com.nospam>
(If you are a human, then you can figure out my real address.)

Come see me at my web site:
http://www.geocities.com/SiliconValley/Pines/9447

Other Threads