delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/21/16:31:48

From: bigphil AT solutions DOT mb DOT ca (Mark Phillips)
Newsgroups: comp.os.msdos.djgpp
Subject: allegro bmp/pcx loading problems
Date: Sun, 21 Dec 1997 21:03:11 GMT
Organization: Escape Communications Corp. (http://www.escape.ca)
Lines: 81
Message-ID: <349d836a.0@news3.escape.ca>
NNTP-Posting-Host: 9444 AT 198 DOT 163 DOT 232 DOT 253
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a program which uses allegro to load 6 bitmaps, all of size
77x105 and i want to keep writing them over top of each other to do
some crude animation.  However, half of the time when I try to compile
the program, the compiler gives me the error: "virtual memory
exhausted" the other half of the time it compiles but i get a general
protection fault after it has displayed 2 frames.  What am I doing
wrong? here is the source if you're interested (I am just trying stuff
out and so I just modified one of the allegro examples). oh yeah by
the way, i accidentally overwrote allegro example #15 so if someone
could just post ex15.c that would be great too.


#include <stdlib.h>
#include <stdio.h>

#include "allegro.h"

void pause(int);

void main()
{
   int i;
   BITMAP *the_image[4];
   PALLETE the_pallete[4];

   /* read in the bitmap files */
   the_image[0] = load_bitmap("run1.bmp", the_pallete[0]);
   if (!the_image[0]) {printf("Error reading bitmap file run1.bmp");
exit(1);}
   the_image[1] = load_bitmap("run2.bmp", the_pallete[1]);
   if (!the_image[1]) {printf("Error reading bitmap file run2.bmp");
exit(1);}
   the_image[2] = load_bitmap("run3.bmp", the_pallete[2]);
   if (!the_image[2]) {printf("Error reading bitmap file run3.bmp");
exit(1);}
   the_image[2] = load_bitmap("run4.bmp", the_pallete[3]);
   if (!the_image[3]) {printf("Error reading bitmap file run4.bmp");
exit(1);}
//   the_image[2] = load_bitmap("run5.bmp", the_pallete[4]);
//   if (!the_image[4]) {printf("Error reading bitmap file run5.bmp");
exit(1);}
//  the_image[2] = load_bitmap("run6.bmp", the_pallete[5]);
//   if (!the_image[5]) {printf("Error reading bitmap file run6.bmp");
exit(1);}

   allegro_init();
   install_keyboard(); 
   if (set_gfx_mode (GFX_AUTODETECT, 640, 480, 0, 0)!=0) exit(1);

   i = 0;

   while (!key[KEY_ESC]) {

     /* select the bitmap pallete */
     set_pallete(the_pallete[i]);

     /* blit the image onto the screen */
     blit(the_image[i], screen, 0, 0, 0, 0, 77, 105);

     pause(100);

     i++;
     if (i==4) i=0;

   }

   for (i=0;i<4;i++)
   /* destroy the bitmap */
   destroy_bitmap(the_image[i]);


   readkey();
   exit(0);
}

void pause(int l) {
  int i;
  for(i=0;i<l*10000;i++) {;}
}


- Raw text -


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