delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/20/11:27:16

From: Edward Hill <edward_hill AT gec DOT nospam DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Memory Access Problem
Date: Wed, 20 Jan 1999 16:17:08 -0800
Organization: Easams, Engineering Systems
Lines: 39
Message-ID: <36A67204.5AF0@gec.nospam.com>
References: <36A13B53 DOT D1A46262 AT bellsouth DOT net>
NNTP-Posting-Host: pc02372.gmsws.gecm.com
Mime-Version: 1.0
X-Mailer: Mozilla 3.01C-GECMMTL (Win95; I; 16bit)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

david bryant wrote:
[sippety snip snip]
> I allocate memory to *background by the statement
> background=(char *)malloc(sprite_width * sprite_height);

  You shouldn't cast the return of malloc, it was orig used
  to silence compiler warning messages but since ANSI/ISO and
  the void * type it has become redundant and sometimes masks
  errors.  

  Ok, make sure you have #include <stdlib.h>, I've forgotten this
  before and the cast will mask this.

> A similar method is used to allocate memory for the sprite frames.
> The problem is this :
> When I read the background of the sprite from the virtual screen like
> this EXAMPLE : source->background[x]=virtual_screen[(y<<6)+(y<<8)+x]
> with my blit engine
> and try to blit it back with the line EXAMPLE :
> virtual_screen[(y<<6)+(y<<8)+x)=background[x],
> and blit the virtual screen to video memory with the _dosmemputl()
> function, I don't see my blit.
> I've debugged and according to all my variable checking, the data is
> going where it's supposed to go and the proper values are being
> assigned.
[chop]   
   going where it's supposed to go? could you elabourate on this,
   is the background updated correctly with BACKGROUND = VIRT
   is the virtual screen updated correctly with VIRT = BACKGROUND
   what do you see when you blit to the vid mem? blank? garbage?
   the background? half a frame?

   perhaps if you included with this information some sample code,
   your blit function for a start and the relavent malloc sections for 
   the background and sprite. 
   
    Do you test the return of malloc?
   
Ed Hill

- Raw text -


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