delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/08/05:17:17

Date: Wed, 8 Jul 1998 12:16:31 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Endlisnis <s257m AT unb DOT ca>
cc: djgpp AT delorie DOT com
Subject: Re: Mouse Handling
In-Reply-To: <Pine.SOL.3.96.980705120455.14877A-100000@sol.sun.csd.unb.ca>
Message-ID: <Pine.SUN.3.91.980708121610.5286a-100000@is>
MIME-Version: 1.0

On Sun, 5 Jul 1998, Endlisnis wrote:

> 	I tried to set up one of the examples shown in the FAQ to have a
> function of mine called every time a mouse event occurs.  My function
> doesn't contain any code, it is just blank.  Yet anytime the mouse moves,
> the system crashes.

The FAQ has inadvertently omitted a crucial part of setting up the
mouse handler: you must assign callback_info.rm_segment and
callback_info.rm_offset to r.x.es and r.x.dx, respectively.
Otherwise, you pass a bogus address to the mouse driver, which will
surely crash your system when the driver calls that address.  The FAQ
text explains that, but the example omits these lines, sorry.

I really suggest that you browse the documentation of the specific
function you are invoking (in this case, function 0Ch of Int 33h) when
writing such code.  I would imagine that you would have found this bug
in the FAQ example much faster if you did that.

Some additional comments about your test program, while we are at
that:

>  _go32_dpmi_lock_data(func,Size);

You need to use _go32_dpmi_lock_code here, since you are locking the
code, not the data.

Btw, I don't think you even need to lock anything when you install a
mouse handler, since the handler isn't called in a context of a
hardware interrupt.

>  while(Mouse.x!=80)
>   cout << Mouse.x << "," << Mouse.y << "," << Mouse.b << "\r";
>  }

In a real production program, you need to disable your handler (by
calling function 00h of Int 33h, or by calling the same function 0Ch
with a zero mask in CX register), and then deallocate it (by calling
_go32_dpmi_free_real_mode_callback).  If you fail to do that, your
program might crash when it exits.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019