// This is an ICP Doom Storyboard program . . . by Retard Jay.
// This file is an example of some of the WORST coding anyone has ever seen.

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

PALETTE my_palette;
BITMAP *scr_buffer;
SAMPLE *the_noise;
BITMAP *sprite;

int card, w, h;
int depth;
int err_vmode;
int loop;

BEGIN_GFX_DRIVER_LIST
   GFX_DRIVER_VESA2B
END_GFX_DRIVER_LIST;

BEGIN_COLOR_DEPTH_LIST
   COLOR_DEPTH_24
END_COLOR_DEPTH_LIST;

int main(int argc, char *argv[])
{
   char picture_name[256];
   char sprite_name[256];
   char noise_name[256];

   allegro_init();
   install_keyboard();

   replace_filename(picture_name, argv[0], "icp.bmp", sizeof(picture_name));
   replace_filename(sprite_name, argv[1], "spriteone.bmp", sizeof(sprite_name));
   replace_filename(noise_name, argv[2], "icpnoises.wav", sizeof(noise_name));

   printf("ICP DooM Storyboard Program by Retard Jay");

   readkey();
   clear_keybuf ();

   depth = 24;
   card = GFX_VESA2B;
   w = 640;
   h = 480;

   set_color_depth(depth);
   err_vmode = set_gfx_mode(card, w, h, 0, 0);
   install_sound(DIGI_AUTODETECT, MIDI_NONE, argv[0]);

   if ( err_vmode != 0)
   {
   printf("ERROR SETTING UP THE GRAPHICS, ABORTING . . .\n");
   allegro_exit ();
   return 1;
   }

   /* original list of data to be used */
   /*                                  */
   scr_buffer = load_bitmap (picture_name,my_palette);
   sprite = load_bitmap (sprite_name,my_palette);
   the_noise = load_sample(noise_name);

   /* blit the image onto the screen */
   /*                                */
   blit(scr_buffer, screen, 0, 0, (SCREEN_W-scr_buffer->w)/2,
   	     (SCREEN_H-scr_buffer->h)/2, scr_buffer->w, scr_buffer->h);

   printf("ICP DooM BITCH!!!\n");
   printf("This is the story of ICP DooM . . .\n");
   printf("It begins . . .\n");

   /* destroy the bitmap */
   /*                    */
   destroy_bitmap(scr_buffer);

   readkey();

   replace_filename(picture_name, argv[0], "beginning.bmp", sizeof(picture_name));

   scr_buffer = load_bitmap (picture_name,my_palette);

   blit(scr_buffer, screen, 0, 0, (SCREEN_W-scr_buffer->w)/2,
   	     (SCREEN_H-scr_buffer->h)/2, scr_buffer->w, scr_buffer->h);

   loop = 0;

   play_sample(the_noise, 255, 128, 1000, loop);

   destroy_bitmap(scr_buffer);

   readkey();

   replace_filename(picture_name, argv[0], "backdrop.bmp", sizeof(picture_name));
   replace_filename(noise_name, argv[1], "riddlebox.wav", sizeof(noise_name));

   scr_buffer = load_bitmap (picture_name,my_palette);
   the_noise = load_sample(noise_name);

   blit(scr_buffer, screen, 0, 0, (SCREEN_W-scr_buffer->w)/2,
   	     (SCREEN_H-scr_buffer->h)/2, scr_buffer->w, scr_buffer->h);

   //draw_sprite(screen,sprite, 200, 100);
   stretch_sprite(screen,sprite, 200, 150, 40, 100);
   //clear_to_color(sprite, 0);

   play_sample(the_noise, 255, 128, 1000, loop);

   destroy_bitmap(scr_buffer);

   readkey();

   printf("THE END, SO FAR . . . [still got plenty to go . . .]");

   return 0;

}