Mail Archives: djgpp/2000/06/29/23:01:40
This whole entire discussion was started, when I kept getting
SEGFAULTS (what I called "core-dumps")
What my projected needed (needs) is to be able to dynamically,
on-the-fly, create an ARRAY of BITMAP*'s and an equal number
of PALETTE's....
THEN to properly reference, and when done, of course, a
convenient way to destroy them.
Fortunately, for 1600x1200 screen modes, this comes to less
than 4000 bitmaps (most of which are small, but all true color).
and becuase my problems were DIRECTLY related to
segment-faults, with DJGPP/Allegro specific packages, it seemed proper
to expect that somebody would help me out... instead I get silly
"you're being off topic" nonsense.
Right now, this is whats being done:
Globally:
BITMAP **Pieces=NULL; //POINTER to an Array_of_Pointers to
Bitmap's
PALLETE *PPpal=NULL; //Pointer to an Array of Pallete's
and then,
int Allocanbc(int PUZ_SIZE) {
int ALLOC_OK;
ALLOC_OK = 0;
[SNIP]
if (Pieces = (BITMAP**)malloc(PUZ_SIZE * sizeof(BITMAP*)))==NULL )
{
printf("ERROR: Unable to allocate Pieces Array\n");
exit(101);
}
else { ++ALLOC_OK; }
if ( (PPpal = (PALLETE*)malloc(RIV_SIZE * sizeof(PALLETE)))==NULL
) {
printf("ERROR: Unable to allocate Pieces Array\n");
exit(101);
}
else { ++ALLOC_OK; }
if ( ALLOC_OK != 3 ) return (-1);
else return (0);
} //AllocPuzzle
is this any good programming practice, or what?
THANKS!
Email always welcomed: radsmail AT juno DOT com
http://members.tripod.com/~RadSurfer/
On 29 Jun 2000 14:50:28 -0700, Nate Eldredge <neldredge AT hmc DOT edu>
wrote:
>Sinan_Unur AT mail DOT com (A. Sinan Unur) writes:
>
>> as for BITMAP and PALLETE, all one should care about is the API
>> through which you access these structures (that is the whole point
>> why you are provided with a BITMAP data type rather than an array of
>> int.) further, BITMAP and PALLETE are logically separate concepts
>> regardless of any affinity that might exist between their underlying
>> implementations.
>
>And in fact, there isn't any.
>
>typedef struct BITMAP /* a bitmap structure */
>{
> int w, h; /* width and height in pixels */
> int clip; /* flag if clipping is turned on */
> int cl, cr, ct, cb; /* clip left, right, top and bottom values */
> GFX_VTABLE *vtable; /* drawing functions */
> void (*write_bank)(); /* write bank selector, see bank.s */
> void (*read_bank)(); /* read bank selector, see bank.s */
> void *dat; /* the memory we allocated for the bitmap */
> int bitmap_id; /* for identifying sub-bitmaps */
> void *extra; /* points to a structure with more info */
> int line_ofs; /* line offset (for screen sub-bitmaps) */
> int seg; /* bitmap segment */
> unsigned char *line[0]; /* pointers to the start of each line */
>} BITMAP;
>
>vs.
>
>typedef struct RGB
>{
> unsigned char r, g, b;
> unsigned char filler;
>} RGB;
>typedef RGB PALLETE[PAL_SIZE];
>
>No similarities whatever.
- Raw text -