[comp.sys.ibm.pc.digest] Info-IBMPC Digest V89 #29

Info-IBMPC@WSMR-SIMTEL20.ARMY.MIL (02/26/89)

Info-IBMPC Digest           Sat, 25 Feb 89       Volume 89 : Issue  29

Today's Editor:
         Gregory Hicks - Chinhae Korea <COMFLEACT@Taegu-EMH1.army.mil>

Today's Topics:
                              F11 & F12
               Documentation files with weird characters
                A problem with a program called MANDELEX
                         EGA and PRINT-SCREEN
                          VT100 Escape codes
                Still More on Random Number Generators
                        Re: VT100 Reverse Video
                      Re: Trouble with MS Windows
                Still more on Random Number Generators
                           Typing programs
                      A Question on Data Files
                Expansion Box for an IBM PC Portable

----------------------------------------------------------------------

Date: 20 Feb 89 13:04 +0100
From: Skule Johansen <S_Johansen%AVH.UNIT.UNINett%NORUNIX.BITNET@CUNYVM.CUNY.EDU>
Subject: F11 & F12

Hi,
I have read some letters about getting keycodes (F11 & F12). So here is
some help cooked together.

To read what ever you want from the keyboard, the easiest way is to read
the original key-code from the keyboard before the keyboard driver
translates it. When a keyboard interrupt occurs, you read from Port 60H.
Here is the physical number of the key. That is ^[ESC|=1, ^[1/!|=2,
^[2/@|=3, ^[3/#|=4 and so on. F11=87 and F12=88 (? try it!).  When you
have read the keycode, you pass the control to the keyboard driver
(original). If it is an extended/brake code, then there is 0 (for PC) or
224 (for AT) in port 60H. To get the real keycode, you shift bit 7 in port
61H, write the value back to port 60H, shift bit 7 back again and finally
write it to port 61H. Now the real code is in port 60H. (60H = port A, 61H
= port B).

Ex:  (in TP)
        Procedure Int09; Interrupt;
        Begin
                key := Port$60|;
                If (key=0 {PC}) or (key=224 {AT} Then Begin
                   {This is a extended code (brake)}
                End;
                If (key=My_Key_nr) Then My_Key_Pressed := True
                Else My_Key_Pressed := False;
                InLine($....); {call original interrupt}
        End;

Another way is, you can read the code after that the keyboard driver has
done its work. It is easy and safe, but varying on wich codes the driver
makes of your keys. After a keyinterrupt, the driver has made a code, and
puts the code, and the keynumber in the 16*2 byte keyboard buffer. So it
is just to read the buffer, and look for the keycode that your driver make
of your keys (F11,F12). There is diffrent codes if some of the shift keys
are also pressed.

Ex:
         Procedure Int09; Interrupt;
         Begin
              InLine($....); {call original interrupt}
              If Mem$0040:Mem0:$041C|-1| = My_Key
                 Then My_Key_Pressed := True
              Else My_Key_Pressed := False;
         End;

You find the last keypress in the cryptical Mem..., and the code in
Mem ....-2|. If You want to change the values too, then write the new
value to the same memory location.

Remember to make a interrupt of your procedures for 9H. The last code may
be done outside (or without) an own interrupt procedure.

Hope this helps anyone (it did for me). I did not have my programs or
books nearby, so the code (or text) may have some minor errors.

Regards
Skule Johansen
University of Trondheim/AVH

[There is also a program in the Archives called F11F12.ASM.  Another one that
might do the trick is FIX101KY.ARC.  Both of these can be found in 
PD1:<MSDOS.KEYBOARD> and is are available via ANONYMOUS ftp.  gph]

------------------------------

Date: 20 February 1989 17:59:54 CST
From: "Michael J. Steiner" <U23405%UICVM.bitnet@cunyvm.cuny.edu>
Subject:  Documentation files with weird characters...

I have had some documentation files that were barely readable when I
listed them on the screen, but printed out perfectly. Why does this
happen? Are some characters automatically converted to others when being
printed? Is there a way I can make these character conversions without
printing the file?

                                            Thanks in advance,
                                            Michael Steiner
                                            Email: U23405@UICVM.BITNET

[Try one of the programs in the Archives that 'strip' the 2^7th bit from
each byte.  Such a program is available via anonymous ftp from Simtel20 
in sub-directory PD1:<msdos.txtutl> in file HISTRIP.ARC, STRIP15.LBR or 
STRIP21.ARC. gph]

-----------------------------

Date: 20 February 1989 17:58:07 CST
From: "Michael J. Steiner  " <U23405%UICVM.bitnet@cunyvm.cuny.edu>
Subject:  A problem with a program called MANDELEX...

I recently transferred and downloaded a package from SIMTEL20 called
MANDELEX, which is supposed to graph the Mandelbrot set (fractals).  When
I try to execute it, it says "ERROR: unrecognized computer".  I am using a
Zenith PC (Z-100, I think), and just about all of the other graphics
programs I have used worked on this PC. I even tried out this MANDELEX
program on a Zenith PC with CGA, and I got the same message.

Does anyone have any experience with this program, and could tell me how
to get it to run? (It was in the PD1:<PC-BLUE.VOL358> directory)

                                       Thanks in advance,
                                       Michael Steiner
                                       Email: U23405@UICVM.BITNET

------------------------------

Date: 20-FEB-1989 18:13:02.41
From: <FAUCONNE%FRSIM51.bitnet@cunyvm.cuny.edu>
Subj: EGA and PRINT-SCREEN

    Hi Net-land,

    Ahem... pardon for this rather naive question, but I'm a VAX manager
myself and I've been asked this by one of my users also working on an
AT-class machine.

    This folk is complaining because SHIFT-PRTSC does not seem to work
when he wants to print graphics present on his screen. The screen hardcopy
works ok when in text mode, but not when in EGA hi-res mode.

    His configuration is : "true blue" AT-3, EGA board, DOS 3.3,
GRAPHICS.COM loaded, IBM graphic printer, graphics drawn by a QuickBasic
program.

    I assume this is a rather obvious issue for you PC-wizards, so if
someone can help... please answer directly.

    Many thanks in advance...

+-------------------------------------------------------------------------+
|  Alain ("HAL 1") Fauconnet   Research laboratory in medical informatics |
|  System Manager              (expert systems, NL proc., statistics...)  |
|  SIM/INSERM U194             EARN/Bitnet:       FAUCONNE@FRSIM51        |
|  Faculte de Medecine         VMS PSI Mail: PSI%+208075090517::FAUCONNET |
|  91 Boulevard de l'Hopital   PTT net:      (+33) 1-45-85-15-29          |
|  75634 PARIS CEDEX 13 FRANCE     "HAL... open the door, please!"        |
+-------------------------------------------------------------------------+

------------------------------

Date:     Mon, 20 Feb 89 15:38 EST
From:     <BRUCEH%UTKVX3.bitnet@cunyvm.cuny.edu>
Subject:  VT100 Escape codes

Someone asked what the VT100 escape sequences were for bold characters.
The escape sequence is as follows:

    ESC[x;x;...m

     x  Meaning
     ---------------------------
     0  attributes off
     1  Bold or increaded intensity
     4  Underscore
     5  Blink
     7  Negative image (reverse vidio)

     all other parameters are ignored.  You must have the advanced vidio
option to obtain the above.

     more than one attribute may be specified in a command, seperate them
with semicolons.  The final character is a lower case m, it must be lower
case.

     If x is not supplied, the default is 0 (zero).

Thanks,

Bruce Harrison
Univ. of Tenn. at Martin
Computer Center
Martin, TN  38238

BRUCEH@UTKVX  (bitnet)

------------------------------

Date:     Mon, 20 Feb 89 21:41:15 PST
From:     madler@Hamlet.Bitnet (Mark Adler)
Subject:  Still More on Random Number Generators

This is in response to comments by Rich Wales at UCLA on the comments I
made concerning the Park and Miller CACM article on random number
generators.  In summary, I said that 314159269 was an acceptable
multiplier modulo 2^31-1 and that 16807 (the one Park and Miller used) was
not.  Furthermore, I took issue with the idea (implied by the person who
mentioned the Park+Miller article on this listserver in the first place)
that their algorithm, or ANY algorithm could be the "definitive" random
number generator.

First, Rich asked if 314159269 was a primitive element modulo 2^31-1,
since this is what is required to get a full period random number
generator (that is it would go through all 2^31-2 possibilities before
repeating).  Yes, it is.  There is a very quick way to find out, using a
little number theory.  For p prime, a is a primitive element modulo p if
and only if:

        a != 0 mod p

and for all primes q that divide p-1,

        a^((p-1)/q) != 1 mod p

(where != means "not equivalent").  To compute a^n mod p for large n
quickly, you can take successive squares of a (that is a^(2^j) mod p) and
then using the locations of the 1's in the binary representation of n,
select those squares and multiply them together, mod p, to get a^n.  The
prime factorization of 2^31-1 is 2*3^2*7*11*31*151*331, so you need to
test the second expression above for q = 2, 3, 7, 11, 31, 151, and 331.
Doing this for a = 314159269 shows that it is a primitive element modulo
2^31-1.

Second, Rich pointed out, quite correctly, that you cannot use a =
314159269 with the algorithm used for a = 16807 by Park and Miller.  For
that algorithm to work, a^2 must be less than m.  If anyone out there is
trying to use 314159269 with the portable algorithm, don't.  I'm sorry if
I misled anyone on that point.

Someone else (I forgot to save who) mentioned another CACM article
(Efficient and Portable Random Number Generators by L'Ecuyer in vol 31,
no. 6, June 1988), which has several a's and m's that are much better than
either 16807 or 314159269.  This is an excellent article and this guy did
some very large searches to find good multipliers and modulos for portable
generators.  All of them pass Knuth's Spectral test with "flying colors"
(I tested them myself) and all the ones I'm copying here satisfy a^2 < m
for the portable generator (and, of course, a is a primitive element mod m
for all of these):

        m               a
        2147483647      39373
        2147483563      40014
        2147483399      40692
        2147482811      41546
        2147482801      42024
        2147482739      45742

The first shows a mulitplier for m=2^31-1 that is better than either 16807
or 314159269.  The next five, however, are better still and are, by a
measure described in L'Ecuyer's article, the best multipliers that satisfy
a^2<m for m in the set of the 50 largest primes less than 2^31.  In other
words, for efficient portable generators with 32 bit arithmetic, this is
about as good as it gets.  (For nitpickers, the "best" one is a = 40692.)

Furthermore, L'Ecuyer suggests combining two such generators to make a
generators with a much longer period and (hopefully) more random numbers.
Although he provides no theoretical basis for the randomness of such a
sequence, he does have some very convincing looking empirical results that
indicate that the combined generator is "more random" than either
generator alone.  In particular, he combines the generators with a = 40692
and a = 40014 since their m's are related in a way that gives the maximum
period of (m1-1)*(m2-1)/2.  His algorithm is copied here (except that I
have recoded it in C):

        long s1,        /* Seed 1: set to value in 1..2147483562 */
             s2;        /* Seed 2: set to value in 1..2147483398 */

        double uniform(void) {
          long k;

          k = s1 / 53688;
          s1 = 40014 * (s1 - k * 53668) - k * 12211;
          if (s1 < 0) s1 += 2147483563;

          k = s2 / 52774;
          s2 = 40692 * (s2 - k * 52774) - k * 3791;
          if (s2 < 0) s2 += 2147483399;

          k = s1 - s2;
          if (k < 1) k += 2147483562;
          return k * 4.656613e-10;
        }

The two seeds are combined in integer arithmetic at the end for reasons of
speed, but the result is only an approximation for random numbers when
they are near zero and one.  Also, the factor in the return statement is
only given to 23 bit mantissa precision (it should have been written:
(1./2147483563.).  I think that the last three statements should be
replaced by:

          r = (s1 * (1./2147483562.)) - (s2 * (1./2147483398.));
          return r < 0. ? r + 1. : r;

along with a declaration at the top:  "double r;".  This assumes that the
compiler is smart enough to compute the reciprocals of those integers at
compile time.  The Park and Miller algorithm (a single linear congruential
generator) can be replaced by the first three statements of the above
routine followed by the line:

          return (s1 - 1) * (1./2147483562.);

The third comment Rich made was about the intentions of Park and Miller.
I agree with his summary which is that they wanted a simple, portable
generator (that was better than the terrible generators usually suggested)
to be used as a "minimal" standard.  One should use this minimal standard
unless one has an alternative generator that is definitely better.  Well,
the 314159269 that I suggested was not better because it could not be put
into the efficient algorithm used for 16807.  However, 40692 (with its
corresponding m) can be used in place of 16807 and makes for a much better
random number generator.

Something tells me that this random number discussion will go on forever.
Those of you not interested should probably write a program to filter out
any articles that have the words "random" and "generator" in them.  Of
course, it would be easier still if I just didn't keep writing them.  I
can quit whenever I want.  Really.

------------------------------

Date: Tue, 21 Feb 89 01:45 EST
From: <VY7469%BINGVAXA.BITNET@CORNELLC.ccs.cornell.edu>
Subject: Re: VT100 Reverse Video

In response to Brian C. Anderson's question regarding reverse video on a
VT100 terminal, you must send the terminal ESC [ 7 m <cr> to activate
reverse video, and ESC [ 2 ; 7 m <cr> to deactivate reverse video.  For
those interseted, other VT100 screen attributes follow...

CSI = 'ESC [' or '^[ [

        CSI Ps ; ...Ps m
                where Ps      Action
                      0       All attributes off
                      1       Display at increased intensity
                      4       Display underscored
                      5       Display blinking
                      7       Display negative(reverse) video
                      2  2    Display normal intensity
                      2  4    Display not underlined
                      2  5    Display not blinking
                      2  7    Display positive image

[The above has been taken from the 'VT220 Pocket Programmer's Guide']

If you have any more questions about implementing this contact me directly
via the bitnet address in the From: above.

                             Rick Dickens

[Judgement comes from experience;  experience comes from poor judgement.]

------------------------------

Date: Mon, 20 Feb 89 16:54:22 EST
From: billc@prism.TMC.COM (Bill Callahan)
Subject: Trouble with MS Windows

> From: <VY7106%BINGVAXA.BITNET@CORNELLC.ccs.cornell.edu>

Rick Dickens wrote about how he got the "Not enough memory..." dialog box
when he went to run a .PIF file, but how he did indeed have enough memory.
One possible cause of this is that Windows can't find the .EXE file
associated with the .PIF file.  This can either be because the information
in the .PIF file is wrong, or the .EXE file is missing or in the wrong
directory, or the PATH doesn't include the directory where the .EXE file
lives.  Note that if the application has dynamically linked libraries, the
.EXE file for each called library must be present, as well as the main
application's .exe file.  This last fact is a likely source of the error,
since one doesn't always know exactly which .EXE's are linked in.

Bill Callahan			 billc@mirror.TMC.COM
		{mit-eddie, pyramid, wjh12, xait, datacube}!mirror!billc
Mirror Systems
2067 Massachusetts Ave.		617\661-0777	x149
Cambridge, MA  02140

------------------------------

Date: Mon, 20 Feb 89 13:38 EST
From: Richard Ohrbach <ORMOHRBH@ubvmsc.cc.buffalo.edu>
Subject: Typing programs

Manuel--

I have used a public domain program that uses pre-listed sequences of text
(comes with a default set; the user can also add his own). Beeps on
errors, and then requires that the user enter the correct text before
continuing. Times the progress, counts errors, gives percent correct
'hits'.

The good thing about this program, especially for kids, would be the
ability to use their favorite sayings or quotes or stories as the text to
type.

The program is PC-TOUCH, from
Dean Hannotte
324 East Ninth St.
NY, NY  10003
(212) 674-5848

 -----------------------------------------------------------------------------
|  Richard Ohrbach              |  (716) 832-2164                             | 
|  315 Squire Hall              |  bitnet: ORMohrbh@ubvmsd                    |
|  University at Buffalo        |  internet: ORMohrbh@ubvmsd.cc.buffalo.edu   | 
|  Buffalo, NY 14214            |                                             |
 -----------------------------------------------------------------------------

------------------------------

Date:  Tue, 21 Feb 1989  14:50:19 GMT
From:  YAVUZ%TRMETU.BITNET@CUNYVM.CUNY.EDU
Subject: A Question on Data Files

     Is there anyone out there to tell me, how to locate the data
files which are not in my current directory. For example I want to
tell my PC, where the overlay files of wordstar actually lie. I don't
want to have a copy of them in each directory I am working with
wordstar. Thanks.

                                              Yavuz Yardim

------------------------------

Date: Sun, 19 Feb 89 19:04 EST
From: V584TJK8@ubvmsc.cc.buffalo.edu
Subject: Expansion Box for an IBM PC Portable

Hello:

	Here is a good question for or the hardware specialists. I have an
IBM Pc portable and I already used up my two available slots. I remember
that there was a Pc external expansion chassis or box that  allowed you to
expand the  computer to your will. I have replaced my mother board to a
better and faster one  with a NecV20-10 for speed and an improved bios. I
already have have installed a hard and expanded the memory.

	My question, is there such chassis/box external expansion unit.
Who makes it? How could I buy one? Could I build such a unit?

	All replies are welcomed with an open mind. Thanks..

						Cordially,
						Pedro A Cruz 
						  ( ACE )

  Pedro A Cruz                Compuserve user ID: 72371,1101. 
  432 porter quad             The Source user ID: bfq056      
  State University of NY                                              
  at Buffalo                                                          
  Amherst NY 14261.
  Voice 716 636 5194
  V584tjk8@ubvmsa.bitnet

------------------------------

End of Info-IBMPC Digest
************************
-------