Board index » delphi » Unredirectable screen output without Crt unit

Unredirectable screen output without Crt unit

In TP5, TP7, BP7, I have a program as follows :

program P ; uses Crt ;
var F : text ;
begin
Write('Not ') ;
Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
end.

The above is from memory, may have typos, and omits a lot of other code.

Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
give "Not".

What is the easiest way of getting the same effect without using Crt?  I
wish to make such programs immune to RTE200 on fast CPUs (and suspect
that the TP5 version may be OK; that's all Crt is used for).

AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
cured by a TSR which soaks up half the CPU power, and if so can one be
recommended?

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

 

Re:Unredirectable screen output without Crt unit


Quote
Dr John Stockton wrote:
> In TP5, TP7, BP7, I have a program as follows :

> program P ; uses Crt ;
> var F : text ;
> begin
> Write('Not ') ;
> Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
> end.

> The above is from memory, may have typos, and omits a lot of other code.

> Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
> give "Not".

Could you provide a bona fide sample?  As is, it writes both via the CRT
direct video routines.  Is what you meant there "Writeln(F,'Redirected);"?

Making this change causes it to behave it the way you describe.

Quote
> What is the easiest way of getting the same effect without using Crt?  I
> wish to make such programs immune to RTE200 on fast CPUs (and suspect
> that the TP5 version may be OK; that's all Crt is used for).

You could write your own TFDD that behaves like Crt, or you could write to
stderr instead of stdout, which isn't easily redirected (4DOS allows stderr
redirection though).  I have a unit which allows this -- I can put it up on my
webpage.

Quote
> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
> cured by a TSR which soaks up half the CPU power, and if so can one be
> recommended?

Seems to me like a bad way to fix a problem to me.  If it works, it fixes the
symptoms without fixing the problem.  Along the lines of increasing the stack
size when you have a program that overflows the stack, instead of trying to
figure out why it's doing it in the first place.

Quote
> --
> John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
>   Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
>   Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
>   Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Re:Unredirectable screen output without Crt unit


Dr John Stockton came forth and muttered:

Quote
>In TP5, TP7, BP7, I have a program as follows :

>program P ; uses Crt ;
>var F : text ;
>begin
>Write('Not ') ;
>Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
>end.

>The above is from memory, may have typos, and omits a lot of other code.

>Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
>give "Not".

>What is the easiest way of getting the same effect without using Crt?  

Changing to Writeln(F,'Redirected'); give the effect you are looking
for.

I presume you want some text to always appear on the screen despite
output being redirected ?

Printing to StdErr those bits that need to appear on the screen and
standard writelns for the rest would save you having to write a TFDD (or
pull it out of the RTL source) to emulate the same behaviour.

Print strings to StdErr with

procedure printstring(s:string);
begin
Inline(
  $1E/                   {PUSH  DS}
  $C5/$76/$06/           {LDS   SI,[bp+6]}
  $FC/                   {CLD}
  $AC/                   {LODSB}
  $30/$E4/               {XOR   AH,AH}
  $91/                   {XCHG  AX,CX}
  $B4/$40/               {MOV   AH,$40}
  $BB/$02/$00/           {MOV   BX,2}     (2 = StdErr)
  $89/$F2/               {MOV   DX,SI}
  $CD/$21/               {INT   $21}
  $1F);                  {POP   DS}
end;

Quote
>AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
>cured by a TSR which soaks up half the CPU power, and if so can one be
>recommended?

That would certainly work by soaking up 50% of the timer ticks. The
problem is that the whole system will slow down. What we would need is a
ISR that will switch itself on or off depending on, say, an interrupt
that can be coded into the running program to switch on/off the timer-
tick-soak once the program is ending/running or by rerunning the TSR
With a new switch.

The only problem that I can see is educating program users to run the
TSR and then, maually disable/enable it.

However, further thought suggests a unit that is called *before* crt
which mucks around with the timer tick to make it appear to be a slow
computer which can be turned off (mucking round not the computer) after
the CRT unit initialises. Perhaps I can use a derivative of the unit I
use (posted here a bit ago) to test code for running on faster CPU's
than I have. I will look into this and drop you a note if anything
useful comes of it.

--
Pedt Scragg                    <postmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Unredirectable screen output without Crt unit


On Sun, 1 Feb 1998 21:20:09 +0000, Dr John Stockton

Quote
<j...@merlyn.demon.co.uk> wrote:
>In TP5, TP7, BP7, I have a program as follows :

>program P ; uses Crt ;
>var F : text ;
>begin
>Write('Not ') ;
>Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
>end.

>The above is from memory, may have typos, and omits a lot of other code.

>Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
>give "Not".

>What is the easiest way of getting the same effect without using Crt?  I
>wish to make such programs immune to RTE200 on fast CPUs (and suspect
>that the TP5 version may be OK; that's all Crt is used for).

The typical procedure is to assign a TEXT variable by force to
DOS-stderr and to write "visible" output to stderr.

Quote
>----------------------------------------------------------------<

uses dos;
function Dup2(OldHandle, NewHandle:word):integer;
{ Assigns the file which is assigned to OldHandle
  to the handle NewHandle.
  If NewHandle is already assigned to an open file,
  this file will be closed prior the the assignment.
  Returns DOS-error, otherwise 0.
Quote
}

assembler;
asm
   mov ah, 46h
   mov bx, OldHandle
   mov cx, NewHandle
   int 21h
   jb  @Exit
   xor ax, ax
@Exit:
end;

const
  STDERRHANDLE=2;
var
  StdErr:text;
(*
  regs:registers;
*)
begin
  { open a file which must exist }
  assign(StdErr,'NUL');rewrite(StdErr);
  { redirect the handle of StdErr to the file
    of handle 2. NUL will be closed. }
  DUP2(STDERRHANDLE,textrec(StdErr).handle);
(*
  with regs do begin
    AH:=$46;
    BX:=STDERRHANDLE;
    CX:=textrec(stderr).handle;
    MsDOS(regs);
    if Flags and FCarry<>0 then
    { There is something wrong with you
      operation system. Should never happen. }
  end;
*)
  writeln(StdErr,'Not redirected');
end.

Quote
>----------------------------------------------------------------<

As for the standard TEXT-files Input and Output there is no need to
close StdErr at the end of the program.

Regards
Horst

Re:Unredirectable screen output without Crt unit


Dr John Stockton (j...@merlyn.demon.co.uk) writes:

Quote
> In TP5, TP7, BP7, I have a program as follows :

> program P ; uses Crt ;
> var F : text ;
> begin
> Write('Not ') ;
> Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
> end.

> The above is from memory, may have typos, and omits a lot of other code.

> Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
> give "Not".

> What is the easiest way of getting the same effect without using Crt?  I
> wish to make such programs immune to RTE200 on fast CPUs (and suspect
> that the TP5 version may be OK; that's all Crt is used for).

> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
> cured by a TSR which soaks up half the CPU power, and if so can one be
> recommended?

Set the CRT variable DirectVideo to false.

Steve
--
   * * *   Author of Imagic and APE - The Atari Peripheral Emulator!   * * *
   * * *       Turn your 8-bit Atari into a powerhouse with APE!       * * *
  *  *  *         Ape Homepage: http://www.nacs.net/~classics         *  *  *
 !! Request my *FOR SALE* LISTING OF CLASSIC VIDEO GAME STUFF !! 2000+ Lines !!

Re:Unredirectable screen output without Crt unit


JRS:  In article <34D54A7D.B31386CE@_ix.netcom.com> of Sun, 1 Feb 1998
23:24:29 in comp.lang.pascal.borland, Scott Earnest

Quote
<setech@_ix.netcom.com> wrote:
>Dr John Stockton wrote:

>> In TP5, TP7, BP7, I have a program as follows :

>> program P ; uses Crt ;
>> var F : text ;
>> begin
>> Write('Not ') ;
>> Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
>> end.

>> The above is from memory, may have typos, and omits a lot of other code.

>> Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
>> give "Not".

>Could you provide a bona fide sample?  As is, it writes both via the CRT
>direct video routines.  Is what you meant there "Writeln(F,'Redirected);"?

Certainly the F was omitted   :-(  (covered by "may have typos" <g>) !

BF sample is  Web <URL: http://www.merlyn.demon.co.uk/programs/hunt.pas>
of 98/01/04; it is this that I wish to change (I've already replaced
Crt.ReadKey).  I want the header line non-redirectable and the rest
redirectable.  BTW, I wrote most of HUNT long ago, when MSDOS DIR was
inferior to RT-11 DIR - nice to see so many of its features now
available in MSDOS DIR & Win95 - though AFAIK not yet all.

I'll try Pedt's StdErr code - it looks appropriate - thanks to both.

Quote
>> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
>> cured by a TSR which soaks up half the CPU power, and if so can one be
>> recommended?

>Seems to me like a bad way to fix a problem to me.  If it works, it fixes the
>symptoms without fixing the problem.  Along the lines of increasing the stack
>size when you have a program that overflows the stack, instead of trying to
>figure out why it's doing it in the first place.

It's a bad way for the programmer to use in a deliverable.

But if one has just the EXE, and upgrades from 486DX33 to PII/233 (say),
it may be the easiest way.

Also, when developing in the IDE, it's probably easier to slow the PC to
<200MHz than to have to run TPPatch every time; though upgrading Crt
should be the best way here.

One day soon I hope to be able to test these speed-related things at
speed!

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

Re:Unredirectable screen output without Crt unit


In article <hnrUCBA5zV10E...@pedt.demon.co.uk>,
Pedt Scragg  <postmas...@pedt.demon.co.uk> wrote:

Quote

>However, further thought suggests a unit that is called *before* crt
>which mucks around with the timer tick to make it appear to be a slow
>computer which can be turned off (mucking round not the computer) after
>the CRT unit initialises. Perhaps I can use a derivative of the unit I
>use (posted here a bit ago) to test code for running on faster CPU's
>than I have. I will look into this and drop you a note if anything
>useful comes of it.

If one uses an unit then there is no need to mess with the timer, one
can just trap the error caused by the division and handle it. I posted
such an unit here some time ago.

If one plays with the timer there are problems. On slow machines it
could cause too much slowdown. On faster ones it might not be enough.

Note that TP measures time between two interrupt calls, so a routine
that just its in the ISR until next interrupt is not going to help a bit.

Osmo

Re:Unredirectable screen output without Crt unit


In <PTQLLOAJcO10E...@merlyn.demon.co.uk>,
Dr John Stockton <j...@merlyn.demon.co.uk> wrote:

Quote
> Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
> give "Not".

> What is the easiest way of getting the same effect without using Crt?

The easiest way seems writing to 'CON'. I didn't test it, but I see no reason
why this shouldn't work...

Some others suggested writing to StdErr, but only gave assembler solutions.
So here's a way in Pascal, for a change (though, of course, this code is is
no way portable since it depends heavily on internals of the System and Dos
units and of Dos itself):

uses Dos;

var StdErr : Text;

begin
  Assign (StdErr, '');
  Rewrite (StdErr);
  TextRec (StdErr).Handle := 2;
  Writeln (StdErr, 'Hello StdErr.');
  Close (StdErr)
end.

So, you just open a file to standard output, and then change its handle to
StdErr. This is possible because opening and closing of these special handles
is done by Dos and not in the System unit, anyway. (Which means in particular,
that you can, but don't have to, close StdErr at the end of the program.)

Quote
> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
> cured by a TSR which soaks up half the CPU power, and if so can one be
> recommended?

I've seen some such things long time ago, AFAIR for speeding down the "fast"
(10 MHz) CPUs for games written for the original 4.77 PC or something like
that. But I don't suggest to use them here -- is there anything wrong with
applying one the patches?

--
Frank Heckenbach, Erlangen, Germany
fjf@[NOSPAM.REMOVE.THIS]gmx.de
Internet links:  http://home.pages.de/~fjf/links.htm
Pascal programs: http://home.pages.de/~fjf/programs.htm

Re:Unredirectable screen output without Crt unit


JRS:  In article <fe.19980202225...@mi.uni-erlangen.de> of Mon, 2 Feb
1998 22:57:00 in comp.lang.pascal.borland, Frank Heckenbach

Quote
<d...@spam.me> wrote:
>In <PTQLLOAJcO10E...@merlyn.demon.co.uk>,
>Dr John Stockton <j...@merlyn.demon.co.uk> wrote:

>> Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
>> give "Not".

>> What is the easiest way of getting the same effect without using Crt?

>The easiest way seems writing to 'CON'. I didn't test it, but I see no reason
>why this shouldn't work...

Now you mention it, I have a vague recollection ....    to be tested.

Quote
>Some others suggested writing to StdErr, but only gave assembler solutions.
>So here's a way in Pascal, for a change (though, of course, this code is is
>no way portable since it depends heavily on internals of the System and Dos
>units and of Dos itself):

>uses Dos;

>var StdErr : Text;

>begin
>  Assign (StdErr, '');
>  Rewrite (StdErr);
>  TextRec (StdErr).Handle := 2;
>  Writeln (StdErr, 'Hello StdErr.');
>  Close (StdErr)
>end.

That made it work - thanks.  That gives nicer code than Pedt's (Sorry!),
as I want    Writeln(StdErr, 'S1', StrFunc(), 'S2') ; .

<URL: http://www.merlyn.demon.co.uk/programs/hunt.pas> , from its next
upload, will, barring surprises, use this.

Quote
>> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
>> cured by a TSR which soaks up half the CPU power, and if so can one be
>> recommended?

>I've seen some such things long time ago, AFAIR for speeding down the "fast"
>(10 MHz) CPUs for games written for the original 4.77 PC or something like
>that. But I don't suggest to use them here -- is there anything wrong with
>applying one the patches?

If one is the programmer, then it must be best to fix the Crt unit,
once.

If one has just the EXE files, and the correct patch(es), that's OK.

If one just has various EXE & COM files, of uncertain origin, then
slowing the machine may perhaps be the only way.  For example, I once,
long long ago, wrote an "arcade" game
        <URL: http://www.merlyn.demon.co.uk/games/game.pas>
        <URL: http://www.merlyn.demon.co.uk/games/game.exe>
using Delay to govern speed, on a machine of about 8MHz 286 grade.  On a
486/33, it was much too fast; at which I realised that much of the
"delay" had been the program's tasks, not in its Delay() calls.
(I may have fixed the timing; I forget which compiler I used - in 1991).

--
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:Unredirectable screen output without Crt unit


Pedt Scragg came forth and muttered:

Quote

>Print strings to StdErr with

>procedure printstring(s:string);

Forgot to add the {$F+} and {$F-} for use in a program - it was designed
to be in a unit and thus called Far. Thanks John.

--
Pedt Scragg                    <postmas...@pedt.demon.co.uk>

Never curse the Crocodile's mother before crossing the river

Re:Unredirectable screen output without Crt unit


Quote
Dr John Stockton wrote:
> [...]
> BF sample is  Web <URL: http://www.merlyn.demon.co.uk/programs/hunt.pas>
> of 98/01/04; it is this that I wish to change (I've already replaced
> Crt.ReadKey).  I want the header line non-redirectable and the rest
> redirectable.  BTW, I wrote most of HUNT long ago, when MSDOS DIR was
> inferior to RT-11 DIR - nice to see so many of its features now
> available in MSDOS DIR & Win95 - though AFAIK not yet all.

Hm, will give it a brief look-over.

Quote
> I'll try Pedt's StdErr code - it looks appropriate - thanks to both.

You can use that, but I put my unit up on my code page nevertheless.  Note:
just setting the handle field of the text variable isn't necessarily enough.
You may have text that shows up at the wrong time because it's being
buffered.  Check my unit and you should see how to get around this.  Note:  I
credited a "DM" in this source for helping me locate this problem before;
unfortunately, I didn't give due credit to whomever DM was -- Duncan Murdoch,
perhaps.

Quote
> >> AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to Crt) be
> >> cured by a TSR which soaks up half the CPU power, and if so can one be
> >> recommended?

> >Seems to me like a bad way to fix a problem to me.  If it works, it fixes the
> >symptoms without fixing the problem.  Along the lines of increasing the stack
> >size when you have a program that overflows the stack, instead of trying to
> >figure out why it's doing it in the first place.

> It's a bad way for the programmer to use in a deliverable.

> But if one has just the EXE, and upgrades from 486DX33 to PII/233 (say),
> it may be the easiest way.

> Also, when developing in the IDE, it's probably easier to slow the PC to
> <200MHz than to have to run TPPatch every time; though upgrading Crt
> should be the best way here.

> One day soon I hope to be able to test these speed-related things at
> speed!

Okay, I can see what you're getting at.  One I've heard of, now that I can
think of it, is Mo'Slo -- it's commercial (US$20), but you can visit

http://www.hpaa.com/moslo/

For details, purchase, and an evaluation version to see if it does exactly
what you want it to do.

Quote
> --
> John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
>   Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
>   Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
>   Don't Mail News to me.      Before a reply, quote with ">" / "> " (SoRFC1036)

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Re:Unredirectable screen output without Crt unit


Quote
Pedt Scragg wrote in message ...
>Dr John Stockton came forth and muttered:
>> ...
>>AISB, probably elsewhere, can RTE200 on a 300MHz PC (when due to
Crt) be
>>cured by a TSR which soaks up half the CPU power, and if so can one
be
>>recommended?

>That would certainly work by soaking up 50% of the timer ticks. The
>problem is that the whole system will slow down. What we would need
is a
>ISR that will switch itself on or off depending on, say, an interrupt
>that can be coded into the running program to switch on/off the
timer-
>tick-soak once the program is ending/running or by rerunning the TSR
>With a new switch.
> ...
>However, further thought suggests a unit that is called *before* crt
>which mucks around with the timer tick to make it appear to be a slow
>computer which can be turned off (mucking round not the computer)
after
>the CRT unit initialises. Perhaps I can use a derivative of the unit
I
>use (posted here a bit ago) to test code for running on faster CPU's
>than I have.

This still slows down the computer. Since the problem is only with 1
version of the compiler and 1 version of the CRT unit, how about using
the fact that the offset of the initialisation section of the CRT unit
and of the offending DIV instruction are known? like this... (real
mode only)

{ This is for BP7 in real mode
  Search for the CRT unit and hook the Delay function. Removes the
run-time
  error 200 on fast machines with the CRT unit

Quote
}

Unit UpDel;
Interface
Implementation

Procedure Error;
Begin
  Writeln('Error: cannot find the correct CRT unit');
  Halt;
End;

Type
  tInitUnit = Record
    Opcode: Byte;
    Ofs : Word;
    Sgm : Word;
  End;
  ptByte = ^Byte;

Const
  CallOp = $9A; { opcode at start of call to unit initialiser }
  CrtOfs = $D;  { Offset of initialisation of CRT unit }
  SigOfs = $8E; { address of identifying sequence }
  SigBytes : Array[0..4] of Byte = ($B9,$37,$00,$F7,$F1);
{ identifier }
  NopOfs = $91; { offset of code to NOP out }
  NopLgt = 2;   { no. of bytes to wipe }

Var
  pInitUnit : ^tInitUnit;
  i : Integer;
  IsCrt : Boolean;

Begin
  asm { Get pointer to calls for uninitialised units }
    mov ax, [bp+2]
    mov word(pInitUnit), ax
    mov ax, [bp+4]
    mov word(pInitUnit)+2, ax
  end;
  While (pInitUnit^.Opcode=CallOp) do
  Begin
    if (pInitUnit^.Ofs=CrtOfs) then
    Begin
      { Check that this is really the CRT unit
        (some other unit could start at this offset)
      }
      IsCrt := True;
      For i := 0 to high(SigBytes) do
        IsCrt := IsCrt and
          (ptByte(Ptr(pInitUnit^.Sgm,SigOfs+i))^=SigBytes[i]);
      If IsCrt then
      Begin
        For i := NopOfs to NopOfs+NopLgt-1 do
          ptByte(Ptr(pInitUnit^.Sgm, i))^ := $90;
        exit;
      End;
    End;
    Inc(pInitUnit);
  End;
  Error; { should have hit Exit before now }
End.

This is put at the start of the Uses clause in the main program. The
program starts with a sequence of far calls, this unit gets the
address of the first far call after its own. Then it loops until it
runs out of calls or finds one with the right offset. If one has the
right offset, it is checked to see if it is the CRT unit and the DIV
instruction is NOPped out.

A further refinement of this unit would be for it to contain a Delay
function that works, and to replace the start of the CRT delay routine
with a far jump to the working routine. But I couldn't be bothered. I
had to search for an old Turbo.TPL to test the above on, I've applied
the patch and intend always to use the patched library.

FP

Re:Unredirectable screen output without Crt unit


Quote
Dr John Stockton wrote:
> If one just has various EXE & COM files, of uncertain origin, then
> slowing the machine may perhaps be the only way.

As far as the RTE200 bug is concerned, rather than slowing down the
whole machine, I'd rather catch the division by zero interrupt in a
TSR as it's done in the patches. If TP programs redirect this
interrupt (I don't konw offhand), it might be necessary to catch the
"set interrupt" Dos interrupt as well and actually set the new
interrupt after the division by zero has been caught. Something like
this. I don't have the time to try it, but since there are so many
assembler experts around here, perhaps someone will do it?

Quote
> For example, I once,
> long long ago, wrote an "arcade" game
>         <URL: http://www.merlyn.demon.co.uk/games/game.pas>
>         <URL: http://www.merlyn.demon.co.uk/games/game.exe>
> using Delay to govern speed, on a machine of about 8MHz 286 grade.  On a
> 486/33, it was much too fast; at which I realised that much of the
> "delay" had been the program's tasks, not in its Delay() calls.

OK, that's something different. A quick look at Garbo showed a file
/pc/tsr/slow300.zip, but I don't know how well it works and what other
programs there are. Timo, any comments?

Quote
> (I may have fixed the timing; I forget which compiler I used - in 1991).

Tying the timing to a system clock seems the right thing to do here.

--
Frank Heckenbach, Erlangen, Germany
fjf@[NOSPAM.REMOVE.THIS]gmx.de
Internet links:  http://home.pages.de/~fjf/links.htm
Pascal programs: http://home.pages.de/~fjf/programs.htm

Re:Unredirectable screen output without Crt unit


In article <fe.19980203132...@mi.uni-erlangen.de>,

Quote
Frank Heckenbach <heckenb@[NOSPAM.REMOVE.THIS]mi.uni-erlangen.de> wrote:
>Dr John Stockton wrote:

>> If one just has various EXE & COM files, of uncertain origin, then
>> slowing the machine may perhaps be the only way.

>As far as the RTE200 bug is concerned, rather than slowing down the
>whole machine, I'd rather catch the division by zero interrupt in a
>TSR as it's done in the patches. If TP programs redirect this
>interrupt (I don't konw offhand), it might be necessary to catch the
>"set interrupt" Dos interrupt as well and actually set the new
>interrupt after the division by zero has been caught. Something like
>this. I don't have the time to try it, but since there are so many
>assembler experts around here, perhaps someone will do it?

Like this:

Unit Fdelay;             { Use this before CRT }

interface

const dfix:word=1;       { call delay() dfix times }

implementation

uses dos;

procedure oldints; assembler; { "variables" in the code segment }
          asm dd 0,0 end;

Procedure error;
begin
  runerror(200);
End;

Procedure Int0; assembler;
          asm
          cmp cx,55       { If CX<>55 we are at some other point }
          je @ok
          sti
          call error
@ok:
          shr dx,1        { divide dx:ax by 2 }
          rcr ax,1
          shl Dfix,1      { multiply Dfix by 2 }
          iret            { return to the DIV (286+) }
          end;

{ Int21h handler removes the int0 handler (as well as itself) from the
  memory when CtrlBreak vector is set by CRT right after calculating
  the delay counter. Note DS does NOT point to the data segment when
  this is called }

Procedure Int21h; assembler;
          asm
          cmp ax,$251B
          jne @old               { Not setint 1Bh? }

          push es; push si; push di
          mov si,offset oldints
          xor di,di
          mov es,di
          cld
          segcs; movsw
          segcs; movsw           { restore int 0 }

          mov di,$21*4
          segcs; movsw           { restore int 21h }
          segcs; movsw
          pop di; pop si; pop es

@old:     db $2e,$ff,$2e         { jmp far indirect cs:[oldints+4] }
          dw offset oldints+4
          end;

type tr=record int0,int21:pointer; End;
     pr=^tr;

begin
  GetIntVec(0,pr(@oldints)^.int0);
  GetIntVec($21,pr(@oldints)^.int21);

  SetIntVec(0,@int0);
  SetIntVec($21,@int21h);
end.

Note, instead of delay(1000) one should use: for i:=1 to dfix do
delay(1000); or delay(dfix*1000) (note the at least theoretical chance
of overflow in the future with the latter)

Osmo

Re:Unredirectable screen output without Crt unit


Quote
> > In TP5, TP7, BP7, I have a program as follows :

> > program P ; uses Crt ;
> > var F : text ;
> > begin
> > Write('Not ') ;
> > Assign(F, '') ; Rewrite(F) ; Writeln('Redirected') ; Close(F) ;
> > end.

> > The above is from memory, may have typos, and omits a lot of other code.

> > Now "C:\>P" will give "Not Redirected" on screen, and "C:\>P>nul" will
> > give "Not".

> > What is the easiest way of getting the same effect without using Crt?  I
> > wish to make such programs immune to RTE200 on fast CPUs (and suspect
> > that the TP5 version may be OK; that's all Crt is used for).

how about writing directly to video memory ...

program direct_write;

type
  scrT = array[1..25, 1..80] of
    record
      ch : char;
      at : byte;
    end;

var
  scr : scrT absolute $b800:0000; {ega/vga only}

begin
  with scr[1, 1] do
    begin
      ch := '!';
      at := $0f; { white on black }
    end;
end.

note the following :

  - it won't work on monochrome displays (but who cares!)
  - it's scr[y, x] not scr[x, y] as you would expect
  - you should set both the character and the attribute bytes, but you
don't have to :)

with this is should be easy to write a 'writeln' that advances the cursor
etc ... set up a global with the current text attributes (like crt's
textattr).

Go to page: [1] [2]

Other Threads