//////////////////////////////////////////////////////////////////////////////////////
// void capturescreen16(GPDRAWSURFACE *gpdraws, char *path)
// save the screen gpdraws in path (24 bpp bmp) (for 16 bits mode)
//////////////////////////////////////////////////////////////////////////////////////
unsigned char bmp[320*240*3];
const unsigned char header[54] = {
66, 77, 54, 132, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 
0, 0, 64, 1, 0, 0, 240, 0, 0, 0, 1, 0, 24, 0, 0, 0, 
0, 0, 0, 132, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0
};
void capturescreen16(GPDRAWSURFACE *gpdraws, char *path)
{
 F_HANDLE f2;
 unsigned short *image;
 int x, y;
 unsigned char r, v, b, i;
 image = (unsigned short*)gpdraws->ptbuffer;
 GpFileCreate(path, ALWAYS_CREATE, &f2);
 GpFileWrite(f2, &header, 54);
 for (x = 0; x < 320; x++)
  for (y = 0; y < 240; y++)
  {
   r = (image[y+(x*240)] >> 1) * 8;
   v = (image[y+(x*240)] >> 6) * 8;
   b = (image[y+(x*240)] >> 11) * 8;
   i = (image[y+(x*240)] << 7) >> 7;
   if (i == 1) // highlight bit ??
   {
    if (r < 255) r++;
    if (v < 255) v++;
    if (b < 255) b++;
   }
   bmp[(x+y*320)*3] = r;
   bmp[(x+y*320)*3+1] = v;
   bmp[(x+y*320)*3+2] = b;
  }
  GpFileWrite(f2, &bmp, sizeof(bmp));
  GpFileClose(f2);
}
//////////////////////////////////////////////////////////////////////////////////////
// void capturescreen8(GPDRAWSURFACE *gpdraws, char *path)
// save the screen gpdraws in path (24 bpp bmp) (for 8 bits mode)
//////////////////////////////////////////////////////////////////////////////////////
unsigned char bmp[320*240*3];
const unsigned char header[54] = {
66, 77, 54, 132, 3, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40, 0, 
0, 0, 64, 1, 0, 0, 240, 0, 0, 0, 1, 0, 24, 0, 0, 0, 
0, 0, 0, 132, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0
};
void capturescreen8(GPDRAWSURFACE *gpdraws, char *path)
{
 F_HANDLE f2;
 unsigned char *image;
 int x, y;
 unsigned char r, v, b, i;
 long *pal = (long *)0x14a00400;
 image = (unsigned char*)gpdraws->ptbuffer;
 GpFileCreate(path, ALWAYS_CREATE, &f2);
 GpFileWrite(f2, &header, 54);
 for (x = 0; x < 320; x++)
  for (y = 0; y < 240; y++)
  {
   r = (pal[image[y+(x*240)]] >> 1) * 8;
   v = (pal[image[y+(x*240)]] >> 6) * 8;
   b = (pal[image[y+(x*240)]] >> 11) * 8;
   i = (pal[image[y+(x*240)]] << 7) >> 7;
   if (i == 1) // highlight bit ??
   {
    if (r < 255) r++;
    if (v < 255) v++;
    if (b < 255) b++;
   }
   bmp[(x+y*320)*3] = r;
   bmp[(x+y*320)*3+1] = v;
   bmp[(x+y*320)*3+2] = b;
  }
  GpFileWrite(f2, &bmp, sizeof(bmp));
  GpFileClose(f2);
}