www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/20/16:25:52

Xref: news2.mv.net comp.os.msdos.djgpp:5216
From: Jonathan Markland <jrm101 AT tower DOT york DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro's Grabber
Date: Thu, 20 Jun 1996 16:38:33 +0100
Organization: The University of York, UK
Lines: 42
Message-ID: <31C97079.5CD3@tower.york.ac.uk>
References: <Pine DOT SGI DOT 3 DOT 91 DOT 960618173249 DOT 174C-100000 AT tower DOT york DOT ac DOT uk> <835267355snz AT flag DOT demon DOT co DOT uk>
NNTP-Posting-Host: cst124.york.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> In article <Pine DOT SGI DOT 3 DOT 91 DOT 960618173249 DOT 174C-100000 AT tower DOT york DOT ac DOT uk>
>            slh100 AT york DOT ac DOT uk "Shawn Hargreaves" writes:
>
> > [stuff snipped] 
> > If you want to remove the grid, edit grabber.c and in the function:
> >
> > void grab_bitmap(BITMAP *bmp)
> > {
> >    ... stuff deleted ...
> >
> >    while (!mouse_b) {
> >       x = mouse_x & 0xFFF0;             <----- delete this line!
> >       if (x + bmp->w > graphic->w)
> >          x = (graphic->w - bmp->w) & 0xFFF0;
> >       if (x < 0)
> >          x = 0;
> >       y = mouse_y & 0xFFF0;             <----- delete this line!

[stuff snipped]

Observing the butchered version of the code reveals something a bit
suspicious. I guess that Shawn offered the solution in a moment of haste.
I know, it happens to me too! ;)

Try this instead:

> >    while (!mouse_b) {
> >       x = mouse_x;                      <----- I've changed this
> >       if (x + bmp->w > graphic->w)
> >          x = (graphic->w - bmp->w) & 0xFFF0;  <--- [See below]
> >       if (x < 0)
> >          x = 0;
> >       y = mouse_y;                      <----- I've changed this too

Also, I think the line that I have indicated may also need the "& 0xFFF0" removing?

This would explain why the grabbing box never moves, as the variables X and Y are
never updated (they probably get fixed at zero)!

Hope this helps.

Jonathan.

- Raw text -


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