/*  Grafx2 - The Ultimate 256-color bitmap paint program
    Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
    Grafx2 is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; version 2
    of the License.
    Grafx2 is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Grafx2; if not, see  or
    write to the Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
typedef unsigned char  byte;
typedef unsigned short word;
typedef unsigned long  dword;
#include 
#include 
#include 
#include "vesa.h"
char * Version_to_string(word Version)
{
  static char Chaine[20];
  sprintf(Chaine,"%d",(Version>>8));
  strcat(Chaine,".");
  sprintf(Chaine+strlen(Chaine),"%d",(Version & 0xFF));
  return Chaine;
}
void Lire_infos_VESA(void)
{
  struct S_Buffer_VESA      Buffer_VESA;
  struct S_Buffer_mode_VESA Buffer_mode_VESA;
  word   Retour;
  int    Nombre_de_modes;
  word * Liste_des_modes;
  int    Offset1;
  int    Offset2;
  char   Libelle_du_nombre_de_couleurs[16];
  int    Nombre_de_bits;
  Retour=Get_VESA_info(&Buffer_VESA);
  if (Retour==0x004F)
  {
    if (memcmp(Buffer_VESA.Signature,"VESA",4)==0)
    {
      printf("VESA version : %s\n",Version_to_string(Buffer_VESA.Version));
      printf("Builder      : %s\n",Buffer_VESA.Fabricant);
      printf("Capabilities : %d\n",Buffer_VESA.Capacite);
      printf("Video memory : %dK\n",Buffer_VESA.Memoire*64);
      if (Buffer_VESA.Version>=0x0200)
      {
        printf("OEM version  : %s\n",Version_to_string(Buffer_VESA.Version_bios));
        printf("Vendor       : %s\n",Buffer_VESA.Vendeur);
        printf("Product      : %s\n",Buffer_VESA.Produit);
        printf("Revision     : %s\n",Buffer_VESA.Revision);
      }
      // Comptage du nombre de modes:
      Nombre_de_modes=0;
      for (Offset1=0;Buffer_VESA.Liste_des_modes[Offset1]!=0xFFFF;Offset1++)
        Nombre_de_modes++;
      // Allocation d'une liste dupliqu‚e des modes:
      Liste_des_modes=(word *)malloc(sizeof(word)*Nombre_de_modes);
      // Copie de la liste des modes originale vers la dupliqu‚e:
      memcpy(Liste_des_modes,Buffer_VESA.Liste_des_modes,sizeof(word)*Nombre_de_modes);
      // Affichage de la liste des modes:
      for (Offset1=0;Offset1