    #define Compliment(x) ((x>0)?(x=0):(x=1))

    #include "include.h"
    #include "cgraph.h"
    #include "cbitmap.h"
    #include "cfonts.h"
    #include "cmouse.h"
    #include "ckey.h"
    #include "csprite.h"
    #include "cspritea.h"
    #include "cscroll.h"
    #include "cobjects.h"
    #include "cusage.h"

    int KeyboardInstalled=0;
    cscroll         image;
    #include "coptions.h"


    void __cdecl main (void)
    {
       MAIN:
     cgraphics video;
     char   PlayerSuccessfull=0;

    sprintf(GameMessage[0],"Press SpaceBar For Option Menu.");
    sprintf(GameMessage[1],"Press Tab For Controller Menu.");
    sprintf(GameMessage[2],"The Control Key Enables Homing Fires.");
    sprintf(GameMessage[3],"This Is A Message-Board.");
    sprintf(GameMessage[4],"The Alter Key Enables Straight Fires.");
    sprintf(GameMessage[5],"Action Always Speaks Louder Than Words.");
    sprintf(GameMessage[6],"Watch-Out !");
    sprintf(GameMessage[7],"Use Directional Cursors to Steer.");
    sprintf(GameMessage[8],"Programmed By Kami At FastIcs Karachi. ");
    sprintf(GameMessage[9],"There Is No Knowledge That Is Not Power.");

	// setup sound
	snd_init();

	 // setup the display mode
	 set_video_mode(vga256);
	 // create a double buffer
	 video.create_double_buffer();

	// set keyboard interrupt system
	 install_keyboard();
	 KeyboardInstalled=1;

	 // show startup

	 // show startup
	 set_double_buffer(0);
	 show_double_buffer();
	 FadeBitmap("D:\\bitmaps\\menumap.bmp",0);
	 delay(1000);
	 FadeAway();

		 // wallpaper
	 bitmap_load("D:\\bitmaps\\stage1.bmp",&image.wallpaper);
	 //set skipping of bitmap
	 image.Skip=150;
	 // initialize image;
	 image.initialize();
	 // setscroll speed
	 image.speed=-1;

	 //set clouds
	 LoadBackSprites();

	 // Get the cool Palette
	 GetSystemPalette();
	 //Load Bitmaps
	 LoadConstantBitmaps ();
	 // Load Mother imagery
	 LoadMotherSprites();
	 // Load enemy Strings
	 LoadWaveSprites();
	 // load our own stuff
	 LoadCharacterSprites();

	 //setmouse sensitivity
	 SenseMouse(30,30);

	 // get into a menu
	 MainMenu();

	 // set keyboard interrupt system (moved to beginning)
	 //install_keyboard();
	 //KeyboardInstalled=1;
	  // call mother ship
	 int MothersCalled = 0;

	 while(!key_ESC)

	 {
	 // count frame number for frame animation
	 if (GameLoopCount++>1000)GameLoopCount=0;

/////////////////////////////////////////////////////////////////////////////////////////////
	 // shut any sound and create some
	 nosound();
	 sound(random(150)+20);

	 // clear screen to the blue color shade;
	 set_double_buffer(3);
/////////////////////////////////////////////////////////////////////////////////////////////

    //move the wallpaper and leave 150 upper lines
	image.partially_scroll_bitmap_horizontally_db();


    // place some dumb clouds
	 ScrollBackSprites();

/////////////////////////////////////////////////////////////////////////////////////////////
     // bring on the enemies
	 if (WavesPassed > 10)
	 {
	 if (MothersCalled==0 && PalChanged==0)
	 {ChangePalette('b');image.speed=-5;PalChanged = 1;
	 }

	 if (MothersCalled < 1) {Mother();if(MotherCall())MothersCalled++;
	 }
	   else  {
  PrintRomString(6,100+10,248, "                 great !             ",0);

		  object[1].sprite.state=1;
		  object[1].sprite.paste_x_db();
		  object[1].sprite.x++;
		  object[1].Smoulder();
		  object[1].SmoulderCall();
		  object[1].Explode();
		  object[1].ExplodeCall();

		  if (GameLoopCount%10==1)
		 {
		 if (image.speed--<-35)
		 {
		 PlayerSuccessfull=1;

		 {


		 break;
    }

		 }
		 }


		 }
	 }// end wave > 5



	 Wave();
	 if (WaveCall()){WaveType=random(4);}

/////////////////////////////////////////////////////////////////////////////////////////////

	 // end game if the players
	  if (object[0].sprite.state<2)
	 // ask user to quit.
	  if (AskForContinueScreen())break;


	 // Take care of our darlin
	 ControlSpriteCharacters();

/////////////////////////////////////////////////////////////////////////////////////////////

	 // menu and options
	   if (key_SPACEBAR)
	      {
	   // cool menu
	   Options();
	      }

	    if (key_TAB)
	      {
	   WaveStatus=SPRITE_DEAD;
	    //PauseMenu();
	      }
/////////////////////////////////////////////////////////////////////////////////////////////
	 // Show the message screen
	 CallMessageBox(1);
	 DisplayMessageBox();


	 // lock on to the video
	 waitretrace();
	 show_double_buffer();
	 if (key_ESC){ break; }




	 }// end of the main game loop
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////


	 nosound();
	 delay(1000);
	 // bring down the screen
	 smooth();
	 // fade away

	 FadeBitmap("D:\\bitmaps\\menumap.bmp",0);
	 delay(1000);
	 FadeAway();
	reboot();

	 free (BasicFire);
	 free (image.wallpaper.data);
	 free (Explosion);
	 free (Smoke);
	 free (Exhaust);
	 // remove the clouds
	 free (BackSprite);
	 free (SystemPalette);
	 // farfree the video buffer
	 free (object);
	 free (EnemyWave);
	 free (double_buffer);


	 // restore the graphics screen to text mode
	 set_video_mode(text);
	 uninstall_keyboard();
	 KeyboardInstalled=0;



      puts(" Programmed By Kami in Collaboration With Khurram, ");
      puts(" FastIcs karachi.                     [1999-2000]");
      puts(" Send Your Programming Requests To :> kamransethi@hotmail.com ");
      puts("  ");
      puts(" Hit Any Key To Continue.");
      getch();
	 }


