Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / XMS and arrays in C Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Fabrice Léré (aka Drealmer)

March 11, 1999, 03:37 AM

I'm working with a 2D game-engine for Dos (yeah, really old-fashionned :o) )

I've have lots of sprites of kind 64x64x16b, so I want to put them in XMS...

No problem, my XMS subroutines work well, but I have a really strange problem:

I was having memory crashs 2000 lines after a local array. I was using it to store the bitmap
and to push them on XMS, then I was freeing this array. To avoid the problem, I've found
that I can oversize the array, but can't understand why... Later, when I was trying to
put some bitmaps over the screen, I've found that I was loosing the last part (down)
of the bitmap... After a lot of tests & crash & reboot, I have a suspiçion over the way
C/C++ store the arrays. I explain:

- I think that when I'm using a big array (8192 bytes in this case), the C/C++ optimizes
the use of memory by putting these arrays on different segments. One part in a segment to
fill it, then next part in next segment. But, I want to know if, when he uses two
segments for an array, the two segment are contiguous? As I can see, there are, but the
first is after (!) the second... So, when I pass the adress of the buffer to XMS manager,
it will take the first part of the array, and a random part in the "next" segment...
This will explain all my problems, but I have really trouble to understand.

Can someone explain, and tell me where I'm wrong or not, and what I can do ?
I'm not sure this is really the source of the problem, but I mean.

nb: I'm using BC++ 4.52 (16b)

Thank you for any help.

>> fabrice.lete@umh.ac.be

 
Michael Stewart

May 06, 1999, 08:18 AM

Fabrice Léré (aka Drealmer) wrote:
>>I'm working with a 2D game-engine for Dos (yeah, really old-fashionned :o) )
There are alot of people using DOS. Me included :-)

>>I've have lots of sprites of kind 64x64x16b, so I want to put them in XMS...
>>nb: I'm using BC++ 4.52 (16b)
Why are you using XMS or a 16 bits compiler ? DJGPP (free compiler + tools) is a 32 bit protected mode compiler (available from www.delorie.com/djgpp/). Using this you can allocate any amount of data (providing you have the memory [or swap space]) without worrying about EMS and XMS.

Mike

 
This thread contains 2 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.