ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/09/21:12:37

From: Jeremy Penner <pzp655 AT freenet DOT mb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro crashes!
Date: Sat, 9 Nov 1996 16:13:37 -0600
Organization: The University of Manitoba
Lines: 152
Message-ID: <Pine.SOL.3.91.961109160845.14821B-100000@winnie.freenet.mb.ca>
NNTP-Posting-Host: winnie.freenet.mb.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm writing a little test program for Allegro in which you will 
eventually be able to kill Barney, limb by limb.  Anyhoo, right now I'd 
be happy to get all the different body parts displayed on the screen.  

It compiles fine (though with -g it complains about some multiple 
definitions), but as soon as I start it, it exits and fills up half the 
screen with traceback info.  I think it happens right around where I set 
my palette, but I tried commenting it out and it still crashed.  Here's 
the source:

-- barney.h --
/* Allegro data file object indexes, produced by grabber.exe */
/* Do not hand edit! */

#define ARML                0       /* (bmp)  */
#define ARMR                1       /* (bmp)  */
#define BARNEY_PALETTE      2       /* (pal)  */
#define BLOOD               3       /* (bmp)  */
#define BODY                4       /* (bmp)  */
#define CROSSHAIR           5       /* (bmp)  */
#define HEAD                6       /* (bmp)  */
#define LEGL                7       /* (bmp)  */
#define LEGR                8       /* (bmp)  */

-- barney.c --

/*
 * Barney Mutilator
 * By Jeremy Penner
 */


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

#include <allegro.h>
#include "barney.h"


void main()
{
   BITMAP *buffer;
   DATAFILE *barneydat;

   /* int arrays for holding x and y values of sprites--use constants in
      BARNEY.H for initializing them */

   int spritex[8];
   int spritey[8];

   allegro_init();
   install_timer();
   install_keyboard();

   if (!install_mouse())
        {
        allegro_exit();
        printf("No mouse driver installed!!\n");
        exit(1);
        }


   /* Set sprite x & y values */
   spritex[LEGR]=117;
   spritey[LEGR]=151;
   spritex[LEGL]=39;
   spritey[LEGL]=140;
   spritex[HEAD]=110;
   spritey[HEAD]=87;
   spritex[ARML]=75;
   spritey[ARML]=9;
   spritex[ARMR]=185;
   spritey[ARMR]=67;
   spritex[BODY]=69;
   spritey[BODY]=56;

   set_gfx_mode(GFX_VGA, 320, 200, 0, 0);
   set_pallete(barneydat[BARNEY_PALETTE].dat);

   set_mouse_sprite(barneydat[CROSSHAIR].dat);
   set_mouse_sprite_focus(12,12);

   barneydat=load_datafile("barney.dat");
   
   if (!barneydat)
        {
        allegro_exit();
        printf("Error loading barney.dat!");
        exit(1);
        }

 
   /* allocate the memory buffer */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);
   
   /* Set where mouse is to be seen */
   show_mouse(screen);

   while(!key[KEY_ESC])
   {
   clear(buffer);
   /* Draw all the sprites */
   draw_sprite(buffer, barneydat[ARML].dat, spritex[ARML], spritey[ARML]);  
   draw_sprite(buffer, barneydat[ARMR].dat, spritex[ARMR], spritey[ARMR]);
   draw_sprite(buffer, barneydat[LEGL].dat, spritex[LEGL], spritey[LEGL]);
   draw_sprite(buffer, barneydat[LEGR].dat, spritex[LEGR], spritey[LEGR]);
   draw_sprite(buffer, barneydat[HEAD].dat, spritex[HEAD], spritey[HEAD]);
   draw_sprite(buffer, barneydat[BODY].dat, spritex[BODY], spritey[BODY]);

   /* hide mouse for screen update */

   show_mouse(NULL);
   
   /* Blit to screen */
   blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
     
   /* Show mouse */
   show_mouse(screen);
    
   /* Wait 1/20 of a second */
   rest(50);
   }
   show_mouse(NULL);
   destroy_bitmap(buffer);
   remove_mouse();  
   unload_datafile(barneydat);

   exit(0);
}

------------------

Any suggestions?

--Jeremy Penner

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This incoherent babble brought to you by Jeremy Penner, AKA...
 _______                              _____ _____  ______  ___                
 ___    |_______________ ___ ________ ___(_)__  /_ ___   |/  /______ ________ 
 __  /| |__  ___/__  __ `__ \___  __ \__  / _  __/ __  /|_/ / _  __ `/__  __ \
 _  ___ |_  /    _  / / / / /__  /_/ /_  /  / /_   _  /  / /  / /_/ / _  / / /
 /_/  |_|/_/     /_/ /_/ /_/ _  .___/ /_/   \__/   /_/  /_/   \__,_/  /_/ /_/ 
 pzp655 AT freenet DOT mb DOT ca         /_/http://members.tripod.com/~ArmpitMan
 
"If the *Alive* guys                 +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
 had some Spam on board the plane,   | Armpit Man -- Lunitic AT large |
 what would they eat first?"         :"If a tree fell in the forest:
                                     |      and it hit a mime,     |
   A spam haiku by some guy          :     would anyone care?"     :
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-

- Raw text -


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