

#include <stdlib.h>
#include <conio.h>
#include <wgt4.h>
#include <dos.h>

void main (void)
{
  block screenbuf;
  color pal[256];
  char *filename;
  int oldmode;
  wgtfont little;
  int ctr;

  if ( !vgadetected() )
  {
    printf ("Error - VGA card required for any WGT program.\n");
    exit (0);
  }

  oldmode = wgetmode();         /* Store current video mode     */
  vga256();                     /* Initialize WGT system        */


  minit ();                                     /* Mouse must be on */

  wreadpalette (0, 255, pal);                   /* Store current palette */

  wsetpalette(0,255,pal);
  little = wloadfont ("little.wfn");    /* Load our font for selector */
  filefont = little;                    /* Set the font variable */

  /*screenbuf=wnewblock(0,0,319,199);*/
  screenbuf=wloadpcx256("test.pcx",pal);
  msetbounds(40,10,100,100);
  /* Now open a moveable file selector which will prompt for BLK files */
  filename = wfilesel ("pcx", "Load MAP File", 40, 10, screenbuf);
  moff ();
  mdeinit ();

  wfreefont (little);               /* Deallocate the font */

  if (filename != NULL)             /* Did the user select a file? */
  {
    screenbuf = wloadpcx256(filename,pal);          /* Load the image */
    wsetpalette(0,255,pal);
    wputblock (0, 0, screenbuf,0);        /* Display it */
		     /* Free the memory */
    getch ();                                   /* Wait for a keypress */
  }
    wfreeblock (screenbuf);
  wsetmode (oldmode);
}
