www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/20/10:29:07

Date: Thu, 20 Mar 1997 18:11:49 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: woolly-h AT eftr DOT demon DOT co DOT uk
cc: djgpp AT delorie DOT com
Subject: Re: Memory Models
In-Reply-To: <MPG.d9a45e1d2b4691998968e@news.demon.co.uk>
Message-ID: <Pine.SUN.3.91.970320181055.24420K-100000@is>
MIME-Version: 1.0

On Wed, 19 Mar 1997, Alex wrote:

> byte *VGA=(byte *)0xA0000000L;        /* this points to video memory. */
> word *my_clock=(word *)0x0000046C;    /* this points to the 18.2hz system
>                                          clock. */
[snip]
>       mouse->under[bitmap_offset] = VGA[screen_offset+mx+x];
>       /* check for screen boundries */
>       if (mx+x < SCREEN_WIDTH  && mx+x >= 0 &&
>           my+y < SCREEN_HEIGHT && my+y >= 0)
>       {
>         data = mouse->bmp->data[bitmap_offset];
>         if (data) VGA[screen_offset+mx+x] = data;
>       }
>     }
>     screen_offset+=SCREEN_WIDTH;
>   }
> }
> 
[snip]
>     do {                              /* check mouse status */
>       get_mouse_motion(&dx,&dy);
>       press   = get_mouse_press(LEFT_BUTTON);
>       release = get_mouse_release(LEFT_BUTTON);
>     } while (dx==0 && dy==0 && press==0 && release==0 &&
>       *my_clock==last_time);

> 
>     if (*my_clock!=last_time)         /* check animation clock */
>     {
>       if (mouse.bmp!=mouse.bmp->next)
>       {
>         redraw=1;
>         mouse.bmp = mouse.bmp->next;
>       }
>       else
>         last_time = *my_clock;
>     }

These two snippets exhibit the source of your grief.  In DJGPP, you
can't put an arbitrary value (such as 0x46C) into a pointer, then
dereference it and hope to get to the BIOS clock tick counter or to
the VGA video RAM, because DJGPP is a protected-mode environment: it
doesn't let you reference random memory regions to which you don't
have access.

The DJGPP FAQ list (available as v2/faq210b.zip from the same place
you get DJGPP) explains in chapter 18 how to do such things.  As
somebody already said here: please read the FAQ.

- Raw text -


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