   Allegro blit problem
  Hi.I've got the "compiles and runs, then crashes immediately" problem with my code, which seems to be caused by (?my misuse of?) the Allegro blit command.  (well, everything runs better if uglier with the line commented out).  The line in question is blit (bmpMap, bmpVisibleMap,0,0,0,0,bmpMap->w,bmpMap->h);which appears in the very bottom function of my GAME.cpp file:#include "GAME.h"GAME::GAME(void){loadBitmaps();// create and initialise screen bufferbuffer = create_bitmap(1024, 768);clear_bitmap(buffer);// load the mouse cursormousePointer = load_bitmap("mouse.bmp", NULL);set_mouse_sprite(mousePointer);set_mouse_sprite_focus(4,4);// set initial map focus coordsmapOriginX = 540;mapOriginY = 940;targetX = 540;targetY = 950;// initialise myArmymyArmy = new ARMY(16,16,1, p1army);// get some info into the visible mapbmpVisibleMap = create_bitmap(bmpMap->w, bmpMap->h);updateVisibleMap();}GAME::~GAME(void){}void GAME::collateScreen(){//if the map's not centred, move it towards centreif (!mapCentered())shiftMap();// write the map to the output bufferblit(bmpVisibleMap, buffer, mapOriginX, mapOriginY,0,128,768,640); // write the title to the otuput bufferblit(bmpTitle,buffer,0,0,0,0,1024,64);// write the menu bar bitmaps to the output bufferblit(bmpMBbg,buffer,0,0,0,64,1024,64);blit(bmpMBgame,buffer,0,0,16,80,224,32);blit(bmpMBarmy,buffer,0,0,272,80,224,32);blit(bmpMBcity,buffer,0,0,528,80,224,32);blit(bmpMBstgs,buffer,0,0,784,80,224,32);// write the side bar bitmaps to the output bufferblit(bmpSBbg,buffer,0,0,768,128,256,640);blit(bmpSBinfo,buffer,0,0,784,128,224,240);blit(bmpSBstats,buffer,0,0,784,384,224,64);blit(bmpSBzin,buffer,0,0,784,464,224,64);blit(bmpSBzout,buffer,0,0,784,544,224,64);blit(bmpSBnext,buffer,0,0,784,624,224,128);}void GAME::loadBitmaps(){bmpTitle = load_bitmap("title.bmp", NULL);bmpMBbg = load_bitmap("MB-bg.bmp", NULL);bmpMBgame = load_bitmap("MB-game.bmp", NULL);bmpMBarmy = load_bitmap("MB-army.bmp", NULL);bmpMBcity = load_bitmap("MB-city.bmp", NULL);bmpMBstgs = load_bitmap("MB-stgs.bmp", NULL);bmpSBbg = load_bitmap("SB-bg.bmp", NULL);bmpSBinfo = load_bitmap("SB-info.bmp", NULL);bmpSBstats = load_bitmap("SB-stats.bmp", NULL);bmpSBzin = load_bitmap("SB-z-in.bmp", NULL);bmpSBzout = load_bitmap("SB-z-out.bmp", NULL);bmpSBnext = load_bitmap("SB-next.bmp", NULL);// chucked here for the time being - not where it should be I guessp1army = load_bitmap("p1army.bmp", NULL);}void GAME::setTarget(int x, int y){targetX = mapOriginX-384+x;targetY = mapOriginY-320-128+y;if (targetX < 0) targetX = 0;if (targetX > 2048-768) targetX = 2048-768;if (targetY < 0) targetY = 0;if (targetY > 2048-640) targetY = 2048-640;}void GAME::screenOut(){blit(buffer,screen,0,0,0,0,1024,768);}bool GAME::mapCentered(){if (targetX > mapOriginX+8 || targetX < mapOriginX-8 || targetY > mapOriginY+8 || targetY < mapOriginY-8) {return 0;}else return 1;}void GAME::shiftMap() {// upif (targetY < mapOriginY-8){mapOriginY = mapOriginY-2;}// downif (targetY > mapOriginY+8){mapOriginY = mapOriginY+2;}// leftif (targetX < mapOriginX-8){mapOriginX = mapOriginX-2;}// rightif (targetX > mapOriginX+8){mapOriginX = mapOriginX+2;}}void GAME::updateVisibleMap(){// make a new copy of the map and insert unit icons onto itblit (bmpMap, bmpVisibleMap,0,0,0,0,bmpMap->w,bmpMap->h);// since there's only one army for now.  eventually this will be "for every army"// place army icons onto the mapblit(myArmy->getIcon(), bmpVisibleMap, 0,0,myArmy->getMapX()*32,myArmy->getMapY()*32 ,32,32);}which has this corresponding header file GAME.h#pragma once#include <allegro.h>#include "ARMY.h"#define MAP_H 64#define MAP_W 64#define TILE_H 32#define TILE_W 32class GAME{public:GAME(void);~GAME(void);// accessorsBITMAP* getMap(){return bmpMap;}void setMap(BITMAP *newMap){bmpMap = newMap;}void setTarget(int x, int y);// other methodsvoid collateScreen();void screenOut();void loadBitmaps();void shiftMap();bool mapCentered();void updateVisibleMap();private:BITMAP *bmpMap, *bmpTitle, *buffer, *mousePointer, *bmpVisibleMap;BITMAP *bmpMBbg, *bmpMBgame, *bmpMBarmy, *bmpMBcity, *bmpMBstgs, *p1army;BITMAP *bmpSBbg, *bmpSBinfo, *bmpSBstats, *bmpSBzin, *bmpSBzout, *bmpSBnext;int mapOriginX, mapOriginY, targetX, targetY;ARMY* myArmy;};apologies for the "under construction" code.  I'm putting things together, and had just implemented an army class, and was trying to get an army showing on-map.Any thoughts on the problem, or the ugliness of the code in general, are appreciated.   
  It's tough, if not impossible, to misuse blit() in a way that causes a program crash. Firstly, make sure your bitmaps are being loaded correctly; make sure load_bitmap() isn't returning NULL. Secondly, and more likely .... you don't have a global GAME object, do you? Creating bitmaps before Allegro is initialized and set_gfx_mode() is called is the usual cause in these cases ....   ;  No, GAME wasn't global, but here's the problem in main:   // create an item of type gameGAME game;// use WORLDMAP to populate game's bitmap of the world mapWORLDMAP *world = new WORLDMAP();game.setMap(world->getBitmap());delete(world);by assigning things to and fro in GAME's constructor, I was calling a bitmap that didn't really exist yet.   