[comp.lang.pascal] Mouse problems

binni@rhi.hi.is (Brynjolfur Thorsson) (02/08/89)

I am currently developing a measurement program for use in one of our
laboratorys using Turbo Pascal 5.0.  My computer is equipped with a
Hercules card and I use entirely graphics mode.  Now I am
trying to incorporate a mouse in the program.  Below is a listing of my
sample program.

Program MouseTst;
Uses Dos,Graph;

Var Regs:Registers;

Function GraphInit:Boolean
Var GD,GM:Integer;
Begin
   GD := Detect;
   InitGraph(GD,GM,'c:\tp\drivers4);
   GraphInit:=GraphResult=GrOk;
End;

Begin
   If Not GraphInit Then Halt;
   With Regs Do Begin
      Ax:=0;
      Intr($33,Regs);
      If Ax <> $FFFF Then Halt;
      Ax:=1;
      Intr($33,Regs);
      ReadLn;
      Ax:=2;
      Intr($33,Regs);
   End;
   RestoreCrtMode;
End.

This Program works fine in Text Mode (If I skip GraphInit), but if I try it
like it is above I get strange results.  It is as though the mousedriver
thinks that the screen is in text mode.  I sholud also mention that I have
tried it wiht different combinations of hardware, different computers,
mouse drivers and different mouses.  The above program works fine on a
computer with an EGA monitor and driver.
If someone understands my problem and knows what I am doing I would
appreciate a mailed answer.

                           Sincerely 
                            
                           Brynjolfur Thorsson.

dmurdoch@watdcsu.waterloo.edu (D.J. Murdoch - Statistics) (02/10/89)

In article <744@krafla.rhi.hi.is> binni@rhi.hi.is (Brynjolfur Thorsson) writes:
>I am currently developing a measurement program for use in one of our
>laboratorys using Turbo Pascal 5.0.  My computer is equipped with a
>Hercules card and I use entirely graphics mode.  

Sorry for posting, but my mail hasn't been making it out lately.

The Microsoft Mouse Programmer's Reference talks about exactly this situation,
and you have to do something special. The trouble is that the driver can't
determine whether a Herc card is in text mode or graphics mode, so you 
have to tell it explicitly. I don't have the manual handy, but the following
code should work:

gd = detect;
initgraph(gd,gm,driver_path);  { Change display to graphics mode }
if gd = HercMono then
  mem[$40:$49] := 6; { Change "video mode" byte to 6 for page 0, 5 for page 1 }

mReset;              { Now reset the mouse. }


Duncan Murdoch