delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/01/04:20:20

From: demitri AT valint DOT net (Tim Elliott)
Newsgroups: comp.os.msdos.djgpp
Subject: Problem....
Date: Sat, 31 Jan 1998 18:17:36 -0800
Message-ID: <MPG.f3d7b1abfd86ac6989684@news.rmci.net>
NNTP-Posting-Host: 206.107.184.67
Lines: 102
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I did this using DJGPP & ALLEGRO.
I am having some problems with my program, it works for about 2 seconds, 
then it gives me some big error with a bunch of memory addresses and 
stuff.

anyways, here is my source.  if you need my *.dat file, email me at 
demitri AT valint DOT net.  The problem is in the area of the (do while) part of 
main.  if you take out the the line with

do{

and

}while ( !key[KEY_ESC] );

the program works fine.  please help.


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

#include <stdlib.h>
#include <stdio.h>
#include <dir.h>
#include <pc.h>
#include "allegro.h"
#include "bp.h"

DATAFILE *bp_data;
BITMAP *background;
BITMAP *double_buffer;
BITMAP *hero[5];

int hx,hy,hframe;
int change = 0;

void init_game()
{
int index;

double_buffer = create_bitmap(320,200);
clear(double_buffer);

background = create_bitmap(320,200);
background = (BITMAP *) bp_data[BG].dat;

for (index=0; index<5; index++)
	hero[index] = create_bitmap(25,35);

hero[0] = (BITMAP *) bp_data[RS_HERO].dat;
hero[1] = (BITMAP *) bp_data[HR_1].dat;
hero[2] = (BITMAP *) bp_data[HR_2].dat;
hero[3] = (BITMAP *) bp_data[HR_3].dat;
hero[4] = (BITMAP *) bp_data[HR_4].dat;

}

void main()
{  

   char data_filename[10] = "bp.dat";
   hframe = 0;
   hx = (160 - 25);
   hy = (100 - 35);

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

   set_gfx_mode(GFX_VGA, 320, 200, 0, 0);   
   bp_data = load_datafile (data_filename);
   set_pallete(bp_data[MAIN_PAL].dat);
 
   init_game();
    
   blit(background,double_buffer,0,0,0,0,320,200);
   draw_sprite(double_buffer, hero[hframe], hx, hy);  
   blit(double_buffer,screen,0,0,0,0,320,200);

clear_keybuf();


do{

	hy--;
	hframe++;
      change = 1;
	
	
	vsync(); vsync(); vsync();
	clear( double_buffer);
	blit( background, double_buffer,0,0,0,0,320,200);
	draw_sprite(double_buffer,hero[hframe],hx,hy);
	blit(double_buffer,screen,0,0,0,0,320,200);
}while ( !key[KEY_ESC] );	

  readkey();
   unload_datafile (bp_data);
   allegro_exit();
   
}

- Raw text -


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