delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/10/00:01:28

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Mouse driver
Date: Thu, 9 Oct 1997 00:05:57 +0100
Organization: None
Distribution: world
Message-ID: <eE3EVmAVHBP0EwiE@talula.demon.co.uk>
References: <01bcd417$eeb1d760$25f582c1 AT nicland>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 20
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Nicholas Law writes:
>I'm writing a program in DJGPP that needs mouse support. However, when 
>I try to call function 0x00B to get the relative movement of the mouse 
>I get nonsense numbers. It seems to work when moving to the right or 
>down, but when moved up or left I get numbers like 3276750 (minimum) in 
>the CX or DX register.

That is what happens when you treat a negative number as an unsigned
value, and zero extend it to 32 bits rather than sign extending it as
you should. Grab the nearest computer science textbook and read the
section about 2's compliment number encoding, then it will all make
sense...

Basically you need to cast the cx and dx values to a signed short before
you use them, so that the sign will be preserved...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


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